package com.ld.igds.m.service;
|
|
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
|
import com.ld.igds.models.InoutCarConf;
|
import com.ld.igds.util.ContextUtil;
|
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 HInoutCarConfService extends HibernateDao {
|
|
public List<InoutCarConf> listCarConf(Map<String, Object> param) {
|
String hql = " from " + InoutCarConf.class.getName()
|
+ " where companyId=:companyId";
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
|
args.put("companyId", ContextUtil.getCompanyId());
|
if(param != null){
|
String str = (String) param.get("deptId");
|
if (StringUtils.isEmpty(str)) {
|
str = ContextUtil.subDeptId(ContextUtil.getLoginUser());
|
}
|
hql += " and deptId =:deptId ";
|
args.put("deptId", str);
|
}
|
|
hql += " order by sort";
|
|
return this.query(hql,args);
|
}
|
|
public String saveCarConf(InoutCarConf data) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
if(null == data.getCompanyId()){
|
data.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if(null == data.getDeptId()){
|
data.setDeptId(ContextUtil.subDeptId(ContextUtil.getLoginUser()));
|
}
|
|
data.setUpdateTime(new Date());
|
session.saveOrUpdate(data);
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
|
public String delCarConf(InoutCarConf data) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
if(null == data.getCompanyId()) data.setCompanyId(ContextUtil.getCompanyId());
|
session.delete(data);
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
|
public List<InoutCarConf> listCarConf(String companyId, String deptId) {
|
String hql = " from " + InoutCarConf.class.getName()
|
+ " where companyId=:companyId";
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
|
args.put("companyId", companyId);
|
|
hql += " and deptId =:deptId ";
|
args.put("deptId", deptId);
|
|
hql += " order by sort";
|
|
return this.query(hql,args);
|
}
|
}
|