package com.ld.igds.check.service; import com.bstek.bdf2.core.orm.hibernate.HibernateDao; import com.ld.igds.models.CheckStandard; 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 HCheckStandardService extends HibernateDao { public List listStandard(Map param) { String hql = " from " + CheckStandard.class.getName() + " where companyId=:companyId"; Map args = new HashMap(); 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 foodVariety"; return this.query(hql,args); } public String saveStandard(CheckStandard data) { Session session = this.getSessionFactory().openSession(); try { if(null == data.getCompanyId()){ data.setCompanyId(ContextUtil.getCompanyId()); } if(null == data.getId()){ data.setId(ContextUtil.getTimeId()); } if(null == data.getDeptId()){ data.setDeptId(ContextUtil.subDeptId(ContextUtil.getLoginUser())); } if(null == data.getUpperLimit()) data.setUpperLimit(0.0); data.setUpdateTime(new Date()); session.saveOrUpdate(data); } finally { session.flush(); session.close(); } return null; } public String delStandard(CheckStandard 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; } }