From 206871a4f1bf2461c848b9917bc40e93ac9c976a Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期五, 30 五月 2025 16:42:04 +0800
Subject: [PATCH] art: 设备管理-维修、点检、周保 启动流程,流程描述信息修改

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java |   81 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java
index 31fa8f9..af99fcd 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java
@@ -30,12 +30,15 @@
 import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery;
 import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest;
 import org.jeecg.modules.eam.service.*;
+import org.jeecg.modules.eam.vo.EquipmentInspectionStatistics;
+import org.jeecg.modules.eam.vo.EquipmentMaintenanceStatistics;
 import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness;
 import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService;
 import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI;
 import org.jeecg.modules.flowable.apithird.service.FlowCommonService;
 import org.jeecg.modules.flowable.service.IFlowDefinitionService;
 import org.jeecg.modules.flowable.service.IFlowTaskService;
+import org.jeecg.modules.system.service.IMdcProductionService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.jeecg.modules.system.vo.UserSelector;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +46,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.time.LocalDate;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -80,10 +84,16 @@
     private IEamReportRepairService eamReportRepairService;
     @Autowired
     private IEamEquipmentExtendService eamEquipmentExtendService;
+    @Autowired
+    private IMdcProductionService mdcProductionService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean addWeekMaintenance(EamWeekMaintenanceRequest request) {
+        EamEquipment equipment = eamEquipmentService.getById(request.getEquipmentId());
+        if (equipment == null) {
+            throw new JeecgBootException("璁惧涓嶅瓨鍦紝娣诲姞澶辫触锛�");
+        }
         EamWeekMaintenanceOrder order = new EamWeekMaintenanceOrder();
         order.setOrderNum(request.getOrderNum());
         order.setEquipmentId(request.getEquipmentId());
@@ -108,7 +118,7 @@
         //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋�
         if (StringUtils.isNotBlank(order.getOperator())) {
             //鍚姩娴佺▼
-            flowCommonService.initActBusiness("宸ュ崟鍙�:" + order.getOrderNum() + ";寮�濮嬭繘琛岃澶囧懆淇�",
+            flowCommonService.initActBusiness("宸ュ崟鍙�: " + order.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";瀹夎浣嶇疆: " + equipment.getInstallationPosition(),
                     order.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null);
             Map<String, Object> variables = new HashMap<>();
             variables.put("dataId", order.getId());
@@ -129,10 +139,10 @@
                 order.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
                 order.setActualStartTime(new Date());
                 eamWeekMaintenanceOrderMapper.updateById(order);
+                //鏇存柊璁惧淇濆吇鐘舵��
+                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name());
                 return result.isSuccess();
             }
-            //鏇存柊璁惧淇濆吇鐘舵��
-            eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name());
         }
 
         return true;
@@ -168,6 +178,20 @@
             if (query.getMaintenanceDateBegin() != null && query.getMaintenanceDateEnd() != null) {
                 queryWrapper.between("wmo.maintenance_date", query.getMaintenanceDateBegin(), query.getMaintenanceDateEnd());
             }
+            if(StringUtils.isNotBlank(query.getRandomInspectionFlag())) {
+                if(CommonConstant.DEFAULT_1.equals(query.getRandomInspectionFlag())) {
+                    queryWrapper.eq("wmo.random_inspection_flag", CommonConstant.DEFAULT_1);
+                }else {
+                    queryWrapper.and(q -> q.eq("wmo.random_inspection_flag", CommonConstant.DEFAULT_0).or().isNull("wmo.random_inspection_flag"));
+                }
+            }
+            if(StringUtils.isNotBlank(query.getFinalRandomInspectionFlag())) {
+                if(CommonConstant.DEFAULT_1.equals(query.getFinalRandomInspectionFlag())) {
+                    queryWrapper.eq("wmo.final_random_inspection_flag", CommonConstant.DEFAULT_1);
+                }else {
+                    queryWrapper.and(q -> q.eq("wmo.final_random_inspection_flag", CommonConstant.DEFAULT_0).or().isNull("wmo.final_random_inspection_flag"));
+                }
+            }
             //鎺掑簭
             if (StringUtils.isNotBlank(query.getColumn()) && StringUtils.isNotBlank(query.getOrder())) {
                 String column = query.getColumn();
@@ -192,6 +216,10 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean editWeekMaintenance(EamWeekMaintenanceRequest request) {
+        EamEquipment equipment = eamEquipmentService.getById(request.getEquipmentId());
+        if (equipment == null) {
+            throw new JeecgBootException("璁惧涓嶅瓨鍦紝娣诲姞澶辫触锛�");
+        }
         EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(request.getId());
         if (entity == null) {
             throw new JeecgBootException("缂栬緫鐨勬暟鎹凡鍒犻櫎锛岃鍒锋柊閲嶈瘯锛�");
@@ -230,7 +258,7 @@
         //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋�
         if (StringUtils.isNotBlank(entity.getOperator())) {
             //鍚姩娴佺▼
-            flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";寮�濮嬭繘琛岃澶囧懆淇�",
+            flowCommonService.initActBusiness("宸ュ崟鍙�: " + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";瀹夎浣嶇疆: " + equipment.getInstallationPosition(),
                     entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null);
             Map<String, Object> variables = new HashMap<>();
             variables.put("dataId", entity.getId());
@@ -251,10 +279,11 @@
                 entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
                 entity.setActualStartTime(new Date());
                 eamWeekMaintenanceOrderMapper.updateById(entity);
+                //鏇存柊璁惧淇濆吇鐘舵��
+                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name());
                 return result.isSuccess();
             }
-            //鏇存柊璁惧淇濆吇鐘舵��
-            eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name());
+
         }
         return true;
     }
@@ -269,14 +298,21 @@
         if (!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) {
             throw new JeecgBootException("璇ュ伐鍗曞凡杩涜杩囬鍙栵紒");
         }
+        EamEquipment equipment = eamEquipmentService.getById(entity.getEquipmentId());
+        if (equipment == null) {
+            throw new JeecgBootException("璁惧涓嶅瓨鍦紝娣诲姞澶辫触锛�");
+        }
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if(sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) {
+            throw new JeecgBootException("涓嶆槸鎿嶄綔宸ワ紝鏃犳硶棰嗗彇姝ゅ伐鍗曪紒");
+        }
         entity.setOperator(sysUser.getUsername());
         entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
         entity.setActualStartTime(new Date());
         eamWeekMaintenanceOrderMapper.updateById(entity);
 
         //鍚姩娴佺▼
-        flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";寮�濮嬭繘琛岃澶囧懆淇�",
+        flowCommonService.initActBusiness("宸ュ崟鍙�: " + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";瀹夎浣嶇疆: " + equipment.getInstallationPosition(),
                 entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null);
         Map<String, Object> variables = new HashMap<>();
         variables.put("dataId", entity.getId());
@@ -375,7 +411,7 @@
                 eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.WAIT_CONFIRM.name());
                 break;
             case WAIT_CONFIRM:
-                if(StringUtils.isBlank(equipment.getEquipmentManager())) {
+                if (StringUtils.isBlank(equipment.getEquipmentManager())) {
                     throw new JeecgBootException("璁惧鏈垎閰嶈澶囩鐞嗗憳锛屾棤娉曡繘鍏ヤ笅绾у鎵癸紒");
                 }
                 //鐝粍闀跨‘璁�
@@ -422,6 +458,7 @@
                 entity.setInitialAcceptanceUser(user.getUsername());
                 entity.setInitialAcceptanceComment(request.getInitialAcceptanceComment());
                 entity.setInitialAcceptanceTime(new Date());
+                entity.setRandomInspectionFlag(request.getRandomInspectionFlag());
                 //澶勭悊闄勪欢
                 if (CollectionUtil.isNotEmpty(request.getInitialAcceptanceFilesResult())) {
                     List<FileUploadResult> fileUploadResultList = request.getInitialAcceptanceFilesResult();
@@ -436,14 +473,15 @@
                 break;
             case WAIT_FINAL_ACCEPTANCE:
                 values.put("dataId", entity.getId());
-                values.put("organization", request.getInitialAcceptanceComment());
-                values.put("comment", request.getInitialAcceptanceComment());
-                request.setComment(request.getInitialAcceptanceComment());
+                values.put("organization", request.getFinalAcceptanceComment());
+                values.put("comment", request.getFinalAcceptanceComment());
+                request.setComment(request.getFinalAcceptanceComment());
                 //璁剧疆entity
                 entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.COMPLETE.name());
                 entity.setFinalAcceptanceUser(user.getUsername());
                 entity.setFinalAcceptanceComment(request.getFinalAcceptanceComment());
                 entity.setFinalAcceptanceTime(new Date());
+                entity.setFinalRandomInspectionFlag(request.getFinalRandomInspectionFlag());
                 //澶勭悊闄勪欢
                 if (CollectionUtil.isNotEmpty(request.getFinalAcceptanceFilesResult())) {
                     List<FileUploadResult> fileUploadResultList = request.getFinalAcceptanceFilesResult();
@@ -483,6 +521,27 @@
         return eamWeekMaintenanceOrderMapper.selectList(queryWrapper);
     }
 
+    @Override
+    public List<EquipmentMaintenanceStatistics> equipmentMaintenanceStatistics(String productionId, LocalDate firstOfMonth, LocalDate today) {
+        if (StringUtils.isNotBlank(productionId)) {
+            //杞﹂棿缂栫爜涓嶄负绌�
+            List<String> productIds = mdcProductionService.recursionChildren(productionId);
+            if (CollectionUtil.isEmpty(productIds)) {
+                return Collections.emptyList();
+            }
+            List<EquipmentMaintenanceStatistics> list = this.baseMapper.equipmentMaintenanceStatistics(productIds, firstOfMonth.toString(), today.plusDays(1).toString());
+            if (CollectionUtil.isEmpty(list)) {
+                return Collections.emptyList();
+            }
+            return list;
+        }
+        List<EquipmentMaintenanceStatistics> list = this.baseMapper.equipmentMaintenanceStatistics(null, firstOfMonth.toString(), today.plusDays(1).toString());
+        if (CollectionUtil.isEmpty(list)) {
+            return Collections.emptyList();
+        }
+        return list;
+    }
+
     private boolean isUserAuthorized(FlowMyBusiness flowMyBusiness, LoginUser user) {
         List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class);
         return todoUsers != null && todoUsers.contains(user.getUsername());

--
Gitblit v1.9.3