From 2495e9ab75e6c45af1d6e14414711d8cc79fe2ca Mon Sep 17 00:00:00 2001 From: jiazx0107@163.com <jiazx0107@163.com> Date: 星期二, 30 五月 2023 16:13:13 +0800 Subject: [PATCH] 出入库优化-登记2 --- igds-inout/src/main/java/com/ld/igds/m/service/HInoutConfService.java | 48 +++++++++++++++++++----------------------------- 1 files changed, 19 insertions(+), 29 deletions(-) diff --git a/igds-inout/src/main/java/com/ld/igds/m/service/HInoutConfService.java b/igds-inout/src/main/java/com/ld/igds/m/service/HInoutConfService.java index 5b68639..69581d2 100644 --- a/igds-inout/src/main/java/com/ld/igds/m/service/HInoutConfService.java +++ b/igds-inout/src/main/java/com/ld/igds/m/service/HInoutConfService.java @@ -4,9 +4,11 @@ import com.ld.igds.models.InoutConf; import com.ld.igds.models.InoutSysConf; import com.ld.igds.util.ContextUtil; + import org.apache.commons.lang3.StringUtils; import org.hibernate.Session; import org.springframework.stereotype.Component; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -64,42 +66,30 @@ return null; } - public List<InoutSysConf> getSysConfData(Map<String, Object> param) { - - Map<String, Object> args = new HashMap<String, Object>(); - String hql = " from " + InoutSysConf.class.getName() - + " where companyId=:companyId and deptId=:deptId"; - - args.put("companyId", ContextUtil.getCompanyId()); - String deptId = ""; - if (null != param) { - deptId = (String) param.get("deptId"); - } - - if (StringUtils.isEmpty(deptId)) { - deptId = ContextUtil.subDeptId(null); - } - - args.put("deptId", deptId); - - return this.query(hql, args); - } - public String saveSysConfData(InoutSysConf data) { Session session = this.getSessionFactory().openSession(); try { - if (StringUtils.isEmpty(data.getDeptId())) { - data.setDeptId(ContextUtil.subDeptId(null)); - data.setCompanyId(ContextUtil.getCompanyId()); - session.save(data); - } else { - session.update(data); - } - + session.saveOrUpdate(data); } finally { session.flush(); session.close(); } return null; } + + public InoutSysConf getSysConfData(String companyId, String deptId) { + + String hql = " from " + InoutSysConf.class.getName() + + " where companyId=:companyId and deptId=:deptId"; + + Map<String, Object> args = new HashMap<String, Object>(); + args.put("companyId", companyId); + args.put("deptId", deptId); + + List<InoutSysConf> list = this.query(hql, args); + + if(null == list || list.isEmpty()) return new InoutSysConf(); + + return list.get(0); + } } -- Gitblit v1.9.3