package com.ld.igds.door.service;
|
|
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
|
import com.bstek.dorado.data.provider.Page;
|
import com.ld.igds.models.DoorConf;
|
import com.ld.igds.models.DoorRecord;
|
import com.ld.igds.util.ContextUtil;
|
import com.ld.igds.util.DateUtil;
|
import org.apache.commons.lang3.StringUtils;
|
import org.hibernate.Session;
|
import org.springframework.stereotype.Component;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
|
@Component
|
public class HDoorServiceImpl extends HibernateDao {
|
|
public DoorConf getSysConfData(String deptId) {
|
String hql = " from " + DoorConf.class.getName()
|
+ " where deptId=:deptId ";
|
|
Map<String, Object> args = new HashMap<>();
|
args.put("deptId", deptId);
|
|
List<DoorConf> list = this.query(hql, args);
|
|
if (null == list || list.isEmpty()) return null;
|
|
return list.get(0);
|
}
|
|
public String updateSysConfData(DoorConf data) {
|
Session session = this.getSessionFactory().openSession();
|
if (StringUtils.isEmpty(data.getCompanyId())) {
|
data.setCompanyId(ContextUtil.getCompanyId());
|
}
|
try {
|
session.saveOrUpdate(data);
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
|
public void listDoorRecord(Page<DoorRecord> page, Map<String, Object> param) throws Exception {
|
if (param == null) {
|
param = new HashMap<>();
|
}
|
String hql = " from " + DoorRecord.class.getName()
|
+ " where companyId=:companyId";
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
args.put("companyId", ContextUtil.getCompanyId());
|
|
String deptId = (String) param.get("deptId");
|
if (StringUtils.isEmpty(deptId)) {
|
deptId = ContextUtil.subDeptId(null);
|
}
|
hql += " and deptId =:deptId";
|
args.put("deptId", deptId);
|
|
String str = (String) param.get("depotId");
|
if (StringUtils.isNotEmpty(str)) {
|
hql += " and depotId =:depotId";
|
args.put("depotId", str);
|
}
|
|
Date date = (Date) param.get("startTime");
|
if (null != date) {
|
hql += " and time >=:startTime";
|
args.put("startTime", DateUtil.getCurZero(date));
|
}
|
date = (Date) param.get("endTime");
|
if (null != date) {
|
hql += " and time <=:endTime";
|
args.put("endTime", DateUtil.getNextZero(date));
|
}
|
String countHql = " select count(*) " + hql;
|
hql += " order by time desc";
|
this.pagingQuery(page, hql, countHql, args);
|
}
|
|
}
|