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<CheckStandard> listStandard(Map<String, Object> param) {
|
String hql = " from " + CheckStandard.class.getName()
|
+ " where companyId=:companyId";
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
|
args.put("companyId", ContextUtil.getCompanyId());
|
|
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.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;
|
}
|
}
|