yun-zuoyi
lbwgithub 6 years ago
parent c67fe92297
commit 71a68e8cf6

@ -233,6 +233,8 @@ public interface BaseRepository <T, ID extends Serializable> extends JpaReposito
int findByPropertyCount(String propertyName, Object value); int findByPropertyCount(String propertyName, Object value);
T findByVendorNoProperty(String vendorNo);
int findByPropertyCount(String[] propertyNames, Object[] values); int findByPropertyCount(String[] propertyNames, Object[] values);
List<T> findByPropertyPage(String propertyName, Object value,String orderByStuff,Pager pager); List<T> findByPropertyPage(String propertyName, Object value,String orderByStuff,Pager pager);

@ -8,6 +8,7 @@ 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 cn.estsh.i3plus.pojo.base.util.BeanMapUtils; import cn.estsh.i3plus.pojo.base.util.BeanMapUtils;
import cn.estsh.i3plus.pojo.base.util.StringCastUtils; import cn.estsh.i3plus.pojo.base.util.StringCastUtils;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.hibernate.NonUniqueResultException; import org.hibernate.NonUniqueResultException;
import org.hibernate.SQLQuery; import org.hibernate.SQLQuery;
@ -440,7 +441,7 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
if (values[i] != null) { if (values[i] != null) {
queryString.append(" and a." + StringCastUtils.upperCharToUnderLine(propertyNames[i]) + "= " + values[i]); queryString.append(" and a." + StringCastUtils.upperCharToUnderLine(propertyNames[i]) + "= '" + values[i]+"'");
} }
} }
queryString.append(" group by a.lot_no,a.date_code"); queryString.append(" group by a.lot_no,a.date_code");
@ -607,6 +608,22 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
} }
@Override @Override
public T findByVendorNoProperty(String vendorNoStr) {
List<T> list=null;
try {
if(!StringUtil.isEmpty(vendorNoStr)){
String queryString = "from " + persistentClass.getSimpleName() + " as model where model.vendorNo= :vendorNo";
list=entityManager.createQuery(queryString)
.setParameter("vendorNo", vendorNoStr)
.getResultList();
}
} catch (Exception e) {
e.printStackTrace();
}
return list!=null ? list.get(0): null;
}
@Override
public int findByPropertyCount(String[] propertyNames, Object[] values) { public int findByPropertyCount(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);

@ -0,0 +1,13 @@
package cn.estsh.i3plus.pojo.base.util;
public class StringUtil {
public static boolean isEmpty(Object obj){
if(obj ==null || obj.toString().trim().equals("")){
return true;
}
return false;
}
}

@ -0,0 +1,18 @@
package cn.estsh.i3plus.pojo.wms.repository;
import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository;
import cn.estsh.i3plus.pojo.wms.bean.BasVendor;
import cn.estsh.i3plus.pojo.wms.bean.WmsZones;
import org.springframework.stereotype.Repository;
/**
* @Description :
* @Reference :
* @Author : libiwei
* @CreateDate : 2018-11-06 13:40
* @Modify:
**/
@Repository
public interface WmsBasVendorRepository extends BaseRepository<BasVendor,Long> {
}
Loading…
Cancel
Save