From 306945ecc97e77659dce5f4562e2ae2ef1f90315 Mon Sep 17 00:00:00 2001
From: CZT <czt18638530771@163.com>
Date: 星期六, 26 八月 2023 12:18:35 +0800
Subject: [PATCH] 优化调整环流风机操作弹窗
---
igds-inout/src/main/java/com/ld/igds/m/service/HPlanManageService.java | 279 +++++++++++++++++++++++++++++--------------------------
1 files changed, 145 insertions(+), 134 deletions(-)
diff --git a/igds-inout/src/main/java/com/ld/igds/m/service/HPlanManageService.java b/igds-inout/src/main/java/com/ld/igds/m/service/HPlanManageService.java
index d7af8ad..a72adf1 100644
--- a/igds-inout/src/main/java/com/ld/igds/m/service/HPlanManageService.java
+++ b/igds-inout/src/main/java/com/ld/igds/m/service/HPlanManageService.java
@@ -19,164 +19,175 @@
@Component
public class HPlanManageService extends HibernateDao {
- public void pagePlan(Page<InoutPlan> page, Map<String, Object> param)
- throws Exception {
- String hql = " from " + InoutPlan.class.getName()
- + " where companyId =:companyId and deptId =:deptId";
+ public void pagePlan(Page<InoutPlan> page, Map<String, Object> param)
+ throws Exception {
+ String hql = " from " + InoutPlan.class.getName()
+ + " where companyId =:companyId and deptId =:deptId";
- Map<String, Object> args = new HashMap<String, Object>();
- args.put("companyId", ContextUtil.getCompanyId());
- args.put("deptId", ContextUtil.subDeptId(null));
+ Map<String, Object> args = new HashMap<String, Object>();
+ args.put("companyId", ContextUtil.getCompanyId());
+ args.put("deptId", ContextUtil.subDeptId(null));
- if (null != param) {
- String str = (String) param.get("id");
- if (StringUtils.isNotEmpty(str)) {
- hql += " and id like:id";
- args.put("id", "%" + str + "%");
- }
- Integer year = (Integer) param.get("year");
- if (null != year) {
- hql += " and year =:year";
- args.put("year", String.valueOf(year));
- }
- str = (String) param.get("type");
- if (StringUtils.isNotEmpty(str)) {
- hql += " and type =:type";
- args.put("type", str);
- }
- str = (String) param.get("referenceNumber");
- if (StringUtils.isNotEmpty(str)) {
- hql += " and referenceNumber like:referenceNumber";
- args.put("referenceNumber", "%" + str + "%");
- }
- str = (String) param.get("name");
- if (StringUtils.isNotEmpty(str)) {
- hql += " and name like:name";
- args.put("name", "%" + str + "%");
- }
- str = (String) param.get("key");
- if (StringUtils.isNotEmpty(str)) {
- hql += " and (name like :name or referenceNumber like:referenceNumber) ";
- args.put("name", "%" + str + "%");
- args.put("referenceNumber", "%" + str + "%");
- }
- }
+ if (null != param) {
+ String str = (String) param.get("id");
+ if (StringUtils.isNotEmpty(str)) {
+ hql += " and id like:id";
+ args.put("id", "%" + str + "%");
+ }
+ Integer year = (Integer) param.get("year");
+ if (null != year) {
+ hql += " and year =:year";
+ args.put("year", String.valueOf(year));
+ }
+ str = (String) param.get("type");
+ if (StringUtils.isNotEmpty(str)) {
+ hql += " and type =:type";
+ args.put("type", str);
+ }
+ str = (String) param.get("referenceNumber");
+ if (StringUtils.isNotEmpty(str)) {
+ hql += " and referenceNumber like:referenceNumber";
+ args.put("referenceNumber", "%" + str + "%");
+ }
+ str = (String) param.get("name");
+ if (StringUtils.isNotEmpty(str)) {
+ hql += " and name like:name";
+ args.put("name", "%" + str + "%");
+ }
+ str = (String) param.get("key");
+ if (StringUtils.isNotEmpty(str)) {
+ hql += " and (name like :name or referenceNumber like:referenceNumber) ";
+ args.put("name", "%" + str + "%");
+ args.put("referenceNumber", "%" + str + "%");
+ }
+ }
- String count = "select count(*) " + hql;
+ String count = "select count(*) " + hql;
- hql += " order by createTime desc";
+ hql += " order by createTime desc";
- this.pagingQuery(page, hql, count, args);
- }
+ this.pagingQuery(page, hql, count, args);
+ }
+ public List<InoutPlan> listPlan() {
+ String hql = " from " + InoutPlan.class.getName()
+ + " where companyId =:companyId and deptId =:deptId";
+ Map<String, Object> args = new HashMap<String, Object>();
+ args.put("companyId", ContextUtil.getCompanyId());
+ args.put("deptId", ContextUtil.subDeptId(null));
- public List<InoutPlanDetail> listPlanDetail(String planId) {
-
- String hql = " from " + InoutPlanDetail.class.getName();
-
- if(null != planId){
- hql += " where planId=:planId ";
- Map<String, Object> args = new HashMap<String, Object>();
- args.put("planId", planId);
- return this.query(hql, args);
- }
+ return this.query(hql, args);
+ }
- return this.query(hql);
- }
+ public List<InoutPlanDetail> listPlanDetail(String planId) {
- @Transactional
- public String delPlan(InoutPlan data) {
- Session session = this.getSessionFactory().openSession();
- try {
- if (null != data.getId()) {
- this.delPlanDetailByPlanId(data.getId(), session);
- session.delete(data);
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- session.flush();
- session.close();
- }
- return null;
- }
+ String hql = " from " + InoutPlanDetail.class.getName();
- public String delPlanDetail(InoutPlanDetail data) {
- Session session = this.getSessionFactory().openSession();
- try {
- if (null != data.getId()) {
- session.delete(data);
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- session.flush();
- session.close();
- }
- return null;
- }
+ if (null != planId) {
+ hql += " where planId=:planId ";
+ Map<String, Object> args = new HashMap<String, Object>();
+ args.put("planId", planId);
+ return this.query(hql, args);
+ }
- private void delPlanDetailByPlanId(String id, Session session) {
- String hql = " delete from " + InoutPlanDetail.class.getName()
- + " where planId=:planId";
+ return this.query(hql);
+ }
- session.createQuery(hql).setString("planId", id).executeUpdate();
- }
+ @Transactional
+ public String delPlan(InoutPlan data) {
+ Session session = this.getSessionFactory().openSession();
+ try {
+ if (null != data.getId()) {
+ this.delPlanDetailByPlanId(data.getId(), session);
+ session.delete(data);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ session.flush();
+ session.close();
+ }
+ return null;
+ }
- public void savePlan(InoutPlan data) {
- if (null == data.getCompanyId()) {
- data.setCompanyId(ContextUtil.getCompanyId());
- }
+ public String delPlanDetail(InoutPlanDetail data) {
+ Session session = this.getSessionFactory().openSession();
+ try {
+ if (null != data.getId()) {
+ session.delete(data);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ session.flush();
+ session.close();
+ }
+ return null;
+ }
+
+ private void delPlanDetailByPlanId(String id, Session session) {
+ String hql = " delete from " + InoutPlanDetail.class.getName()
+ + " where planId=:planId";
+
+ session.createQuery(hql).setString("planId", id).executeUpdate();
+ }
+
+ public void savePlan(InoutPlan data) {
+ if (null == data.getCompanyId()) {
+ data.setCompanyId(ContextUtil.getCompanyId());
+ }
if (null == data.getDeptId()) {
data.setDeptId(ContextUtil.subDeptId(null));
}
- Session session = this.getSessionFactory().openSession();
- try {
- if (null == data.getId()) {
+ Session session = this.getSessionFactory().openSession();
+ try {
+ if (null == data.getId()) {
List<InoutPlan> list = getPlanId(data);
data.setId(InoutManageUtil.createPlanId(data.getType(), data.getYear(), list));
data.setCreateUser(ContextUtil.getLoginUserCName());
data.setCreateTime(new Date());
- session.save(data);
- } else {
- session.update(data);
- }
- savePlanDetail(data.getDetails(), data.getId(), session);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- session.flush();
- session.close();
- }
- }
+ session.save(data);
+ } else {
+ session.update(data);
+ }
+ savePlanDetail(data.getDetails(), data.getId(), session);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ session.flush();
+ session.close();
+ }
+ }
- private void savePlanDetail(List<InoutPlanDetail> details, String planId,
- Session session) {
- if (null == details || details.isEmpty())
- return;
- for (InoutPlanDetail planDetail : details) {
- if (null == planDetail.getId()) {
- planDetail.setPlanId(planId);
- planDetail.setId(ContextUtil.getUUID());
- session.save(planDetail);
- } else {
- session.update(planDetail);
- }
- }
- }
+ private void savePlanDetail(List<InoutPlanDetail> details, String planId,
+ Session session) {
+ if (null == details || details.isEmpty())
+ return;
+ for (InoutPlanDetail planDetail : details) {
+ if (null == planDetail.getId()) {
+ planDetail.setUpdateTime(new Date());
+ planDetail.setPlanId(planId);
+ planDetail.setId(ContextUtil.getUUID());
+ session.save(planDetail);
+ } else {
+ planDetail.setUpdateTime(new Date());
+ session.update(planDetail);
+ }
+ }
+ }
- public List<InoutPlan> getPlanId(InoutPlan plan){
- String hql = " from " + InoutPlan.class.getName()
- + " where companyId =:companyId and deptId =:deptId and year =:year";
+ public List<InoutPlan> getPlanId(InoutPlan plan) {
+ String hql = " from " + InoutPlan.class.getName()
+ + " where companyId =:companyId and deptId =:deptId and year =:year";
- Map<String,Object> args = new HashMap<String,Object>();
- args.put("companyId", plan.getCompanyId());
- args.put("deptId", plan.getDeptId());
- args.put("year", plan.getYear());
+ Map<String, Object> args = new HashMap<String, Object>();
+ args.put("companyId", plan.getCompanyId());
+ args.put("deptId", plan.getDeptId());
+ args.put("year", plan.getYear());
- hql += " order by createTime desc";
+ hql += " order by createTime desc";
- return this.query(hql, args);
- }
+ return this.query(hql, args);
+ }
}
--
Gitblit v1.9.3