yun-zuoyi
jimmy 6 years ago
commit 6755e5ade3

@ -27,11 +27,14 @@ public class DdlPackBean {
//是否是hql //是否是hql
private boolean isHql; private boolean isHql;
//排序内容 //手动hql尽量避免直接传参使用代替
private String orderByStr; private String hqlAppend;
//where后跟着的hql/sql //where后跟着的hql/sql
private String whereAppend; private StringBuilder whereAppend;
//排序内容
private String orderByStr;
//需要拼接的hql //需要拼接的hql
private StringBuilder sb = null; private StringBuilder sb = null;
@ -39,11 +42,13 @@ public class DdlPackBean {
public DdlPackBean(){ public DdlPackBean(){
this.isHql = true; this.isHql = true;
sb = new StringBuilder(); sb = new StringBuilder();
whereAppend = new StringBuilder();
} }
public DdlPackBean(boolean isHql){ public DdlPackBean(boolean isHql){
this.isHql = isHql; this.isHql = isHql;
sb = new StringBuilder(); sb = new StringBuilder();
whereAppend = new StringBuilder();
} }
public boolean isHql() { public boolean isHql() {
@ -62,12 +67,20 @@ public class DdlPackBean {
this.orderByStr = orderByStr; this.orderByStr = orderByStr;
} }
public String getHqlAppend() {
return hqlAppend;
}
public void setHqlAppend(String hqlAppend) {
this.hqlAppend = hqlAppend;
}
public String getWhereAppend() { public String getWhereAppend() {
return whereAppend; return whereAppend.toString();
} }
public void setWhereAppend(String whereAppend) { public void setWhereAppend(String whereAppend) {
this.whereAppend = whereAppend; this.whereAppend = new StringBuilder(whereAppend);
} }
public HashMap<String, Object> getHqlPreparedMap() { public HashMap<String, Object> getHqlPreparedMap() {
@ -87,7 +100,7 @@ public class DdlPackBean {
hqlPreparedMap.put(column, val); hqlPreparedMap.put(column, val);
} }
sb.append(hql); whereAppend.append(hql);
} }
/** /**
@ -99,6 +112,24 @@ public class DdlPackBean {
} }
/** /**
* hqlddl
* @return
*/
public String getPackedHqlAll(){
if(hqlAppend != null){
sb.append(hqlAppend);
}
if(whereAppend != null){
sb.append(whereAppend);
}
if(orderByStr != null){
sb.append(orderByStr);
}
System.out.println("===" + sb.toString());
return sb.toString();
}
/**
* ddl * ddl
* @return * @return
*/ */

@ -894,8 +894,7 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
@Override @Override
public double findByHqlDouble(DdlPackBean packBean) { public double findByHqlDouble(DdlPackBean packBean) {
try{ try{
Query query = entityManager.createQuery("from " + persistentClass.getSimpleName() Query query = entityManager.createQuery(packBean.getPackedHqlAll(),Double.class);
+ " as model where 1=1 " + packBean.getPackedHql(),Double.class);
for (String key : packBean.getHqlPreparedMap().keySet()) { for (String key : packBean.getHqlPreparedMap().keySet()) {
query.setParameter("m_" + key,packBean.getHqlPreparedMap().get(key)); query.setParameter("m_" + key,packBean.getHqlPreparedMap().get(key));

@ -163,4 +163,8 @@ public class WmsDocMovementDetails extends BaseBean {
public Double getQty() {return qty == null ? 0L : this.qty.doubleValue(); } public Double getQty() {return qty == null ? 0L : this.qty.doubleValue(); }
public Double getOutQty() {return outQty == null ? 0L : this.outQty.doubleValue(); } public Double getOutQty() {return outQty == null ? 0L : this.outQty.doubleValue(); }
public Double getPickQty() {return pickQty == null ? 0L : this.pickQty.doubleValue(); }
public Double getActualQty() {return actualQty == null ? 0L : this.actualQty.doubleValue(); }
} }

@ -96,19 +96,19 @@ public class WmsLocate extends BaseBean {
private Double partQty; private Double partQty;
public Integer getMaxPackageQty() { public Integer getMaxPackageQty() {
return this.maxPackageQty == null ? 0 : this.maxPackageQty; return this.maxPackageQty == null ? 0 : this.maxPackageQty.intValue();
} }
public Double getMaxPartQty() { public Double getMaxPartQty() {
return this.maxPartQty == null ? 0 : this.maxPartQty; return this.maxPartQty == null ? 0 : this.maxPartQty.doubleValue();
} }
public Integer getBoxQty() { public Integer getBoxQty() {
return this.boxQty == null ? 0 : this.boxQty; return this.boxQty == null ? 0 : this.boxQty.intValue();
} }
public Double getPartQty() { public Double getPartQty() {
return this.partQty == null ? 0 : this.partQty; return this.partQty == null ? 0 : this.partQty.doubleValue();
} }
} }

Loading…
Cancel
Save