jiazx0107@163.com
2023-11-04 43ce77a85d8297a53dc25430fff10ead57296167
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);
   }
}