yun-zuoyi
lbwgithub 6 years ago
parent d2c3045575
commit 2cf4759c21

@ -215,6 +215,8 @@ public interface BaseRepository <T, ID extends Serializable> extends JpaReposito
List<T> findByProperty(String propertyName, Object value); List<T> findByProperty(String propertyName, Object value);
List<T> findByWasProperty(String[] propertyNames, Object[] values);
List<T> findByProperty(String[] propertyNames, Object[] values); List<T> findByProperty(String[] propertyNames, Object[] values);
List<T> findByProperty(String propertyName, Object value,String orderByStuff); List<T> findByProperty(String propertyName, Object value,String orderByStuff);

@ -3,6 +3,7 @@ package cn.estsh.i3plus.pojo.base.jpa.daoimpl;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.WmsEnumUtil;
import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository; import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -219,6 +220,7 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
/** /**
* *
*
* @param conditionName * @param conditionName
* @param conditionValue * @param conditionValue
* @param propertyName * @param propertyName
@ -412,6 +414,34 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
} }
@Override @Override
public List<T> findByWasProperty(String[] propertyNames, Object[] values) {
if (propertyNames.length != values.length) {
throw new IllegalArgumentException("参数名的数量和参数值不匹配!propertyNames:" + propertyNames.length + ",values:" + values.length);
}
StringBuffer queryString = new StringBuffer();
queryString.append(" select new "+persistentClass.getSimpleName()+"(snStatus,whNo,locateNo,partNo,partNameRdd,lotNo,sum(qty)) from " + persistentClass.getSimpleName() + " ");
int size = propertyNames.length;
if (size > 0) {
queryString.append("where 1=1 and snStatus in ('"+ WmsEnumUtil.STOCK_SN_STATUS.PRE_INSTOCK.getValue()+"','"+WmsEnumUtil.STOCK_SN_STATUS.INSTOCKED.getValue()+"','"+WmsEnumUtil.STOCK_SN_STATUS.PICKED.getValue()+"','"+WmsEnumUtil.STOCK_SN_STATUS.QUALITY_CONTROL.getValue()+"') ");
}
for (int i = 0; i < size; i++) {
if (values[i] != null) {
queryString.append(" and " + propertyNames[i] + "= :" + propertyNames[i]);
}
}
queryString.append("/n group by lotNo,dateCode");
Query queryObject = entityManager.createQuery(queryString.toString());
for (int i = 0; i < size; i++) {
if (values[i] != null) {
queryObject.setParameter(propertyNames[i], values[i]);
}
}
return queryObject.getResultList();
}
@Override
public List<T> findByProperty(String[] propertyNames, Object[] values) { public List<T> findByProperty(String[] propertyNames, Object[] values) {
if(propertyNames.length != values.length){ if(propertyNames.length != values.length){
throw new IllegalArgumentException("参数名的数量和参数值不匹配!propertyNames:" + propertyNames.length + ",values:" + values.length); throw new IllegalArgumentException("参数名的数量和参数值不匹配!propertyNames:" + propertyNames.length + ",values:" + values.length);

@ -286,4 +286,15 @@ public class WmsStockSn extends BaseBean {
this.isDeleted = isDeleted; this.isDeleted = isDeleted;
this.isValid = isValid; this.isValid = isValid;
} }
public WmsStockSn(Integer snStatus,String whNo,String locateNo,String partNo,String partNameRdd,String lotNo,Double qty){
this.snStatus=snStatus;
this.whNo = whNo;
this.locateNo = locateNo;
this.partNo = partNo;
this.partNameRdd = partNameRdd;
this.lotNo = lotNo;
this.qty = qty;
}
} }

Loading…
Cancel
Save