package com.ld.igds.inout.service;
|
|
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
|
import com.ld.igds.models.InoutRecord;
|
import com.ld.igds.util.ContextUtil;
|
import com.ld.igds.util.DateUtil;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Component;
|
import java.util.*;
|
|
@Component
|
public class HInoutReportService extends HibernateDao {
|
|
public static final String BEAN_ID = "hibeInoutReportServiceImpl";
|
|
public List<InoutRecord> listRecord(Map<String, Object> param)
|
throws Exception {
|
|
String hql = " from " + InoutRecord.class.getName()
|
+ " where companyId=:companyId ";
|
Map<String, Object> args = new HashMap<String, Object>();
|
args.put("companyId", ContextUtil.getCompanyId());
|
|
if (null != param) {
|
String str = (String) param.get("depotId");
|
if (StringUtils.isNotEmpty(str)) {
|
hql += " and depotId=:depotId ";
|
args.put("depotId", str);
|
}
|
|
str = (String) param.get("foodVariety");
|
if (StringUtils.isNotEmpty(str)) {
|
hql += " and foodVariety=:foodVariety ";
|
args.put("foodVariety", str);
|
}
|
|
str = (String) param.get("type");
|
if (StringUtils.isNotEmpty(str)) {
|
hql += " and type=:type ";
|
args.put("type", str);
|
}
|
|
str = (String) param.get("type");
|
if (StringUtils.isEmpty(str)) {
|
hql += " and type <> 'LOSS' and type <> 'OVER'";
|
} else {
|
hql += " and type=:type ";
|
args.put("type", str);
|
}
|
|
str = (String) param.get("customerId");
|
if (StringUtils.isNotEmpty(str)) {
|
hql += " and customerId=:customerId ";
|
args.put("customerId", str);
|
}
|
|
str = (String) param.get("progress");
|
if (StringUtils.isNotEmpty(str)) {
|
hql += " and progress=:progress ";
|
args.put("progress", str);
|
}
|
|
str = (String) param.get("deptId");
|
if (StringUtils.isNotEmpty(str)) {
|
hql += " and deptId=:deptId ";
|
args.put("deptId", str);
|
}
|
|
Date date = (Date) param.get("start");
|
if (null != date) {
|
hql += " and completeTime >= :start ";
|
args.put("start", DateUtil.getCurZero(date));
|
}
|
|
date = (Date) param.get("end");
|
if (null != date) {
|
hql += " and completeTime <= :end ";
|
args.put("end", DateUtil.getNextZero(date));
|
}
|
|
date = (Date) param.get("day");
|
if (null != date) {
|
hql += " and completeTime >=:day1 and completeTime <= :day2 ";
|
args.put("day1", DateUtil.getCurZero(date));
|
args.put("day2", DateUtil.getNextZero(date));
|
}
|
}
|
|
hql += " and TYPE_ <> 'NONE' and RECORD_STATUS_ <> 'ERROR' and RECORD_STATUS_ <> 'DEL' order by id asc ";
|
return this.query(hql, args);
|
}
|
}
|