package com.ld.igds.quantity.service;
|
|
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
|
import com.bstek.dorado.data.provider.Page;
|
import com.ld.igds.models.Quantity;
|
import com.ld.igds.quantity.dto.QuantityData;
|
import com.ld.igds.util.ContextUtil;
|
import com.ld.igds.util.DateUtil;
|
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
import org.springframework.stereotype.Repository;
|
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
*
|
* @author: andy.jia
|
* @description:
|
* @version:
|
* @data:2020年1月16日
|
*
|
*/
|
@Repository
|
public class HQuantityDataService extends HibernateDao {
|
|
public void getData(Page<QuantityData> page, Map<String, Object> parameter)
|
throws Exception {
|
if (null == parameter) {
|
parameter = new HashMap<String, Object>();
|
}
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
|
// 默认获取6个月的数据信息
|
Date date = (Date) parameter.get("start");
|
if (null == date) {
|
date = DateUtils.addMonths(new Date(), -6);
|
}
|
|
String hql = " from " + Quantity.class.getName()
|
+ " where companyId=:companyId";
|
args.put("companyId", ContextUtil.getCompanyId());
|
|
String arg = (String) parameter.get("depotId");
|
if (StringUtils.isNotEmpty(arg)) {
|
hql += " and depotId = :depotId";
|
args.put("depotId", arg);
|
}
|
|
if (null != date) {
|
hql += " and receiveDate >=:start";
|
args.put("start", DateUtil.getCurZero(date));
|
}
|
|
date = (Date) parameter.get("end");
|
if (null != date) {
|
hql += " and receiveDate < :end";
|
args.put("end", DateUtil.getNextZero(date));
|
}
|
|
String countHql = "select count(*) " + hql;
|
hql += " order by batchId desc";
|
|
this.pagingQuery(page, hql, countHql, args);
|
}
|
|
}
|