From 0cd305f943dd0f897928a784be5d0124a2faa851 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期一, 02 六月 2025 11:10:23 +0800
Subject: [PATCH] art:  周保,详情添加字段

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekMaintenanceOrderController.java |  149 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 142 insertions(+), 7 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekMaintenanceOrderController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekMaintenanceOrderController.java
index 42d5d10..269f5df 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekMaintenanceOrderController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekMaintenanceOrderController.java
@@ -2,21 +2,30 @@
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.parser.Feature;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.util.TranslateDictTextUtils;
 import org.jeecg.modules.eam.constant.BusinessCodeConst;
 import org.jeecg.modules.eam.constant.OrderCreationMethodEnum;
 import org.jeecg.modules.eam.constant.WeekMaintenanceStatusEnum;
 import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder;
+import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrderDetail;
+import org.jeecg.modules.eam.request.EamWeekMaintenanceBatchApprovalRequest;
 import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery;
 import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest;
+import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderDetailService;
 import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderService;
+import org.jeecg.modules.flowable.domain.vo.WorkTaskDataVo;
 import org.jeecg.modules.system.service.ISysBusinessCodeRuleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -24,6 +33,7 @@
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * @Description: 鍛ㄤ繚宸ュ崟
@@ -40,6 +50,12 @@
     private IEamWeekMaintenanceOrderService eamWeekMaintenanceOrderService;
     @Autowired
     private ISysBusinessCodeRuleService businessCodeRuleService;
+    @Autowired
+    private ObjectMapper objectMapper;
+    @Autowired
+    private TranslateDictTextUtils translateDictTextUtils;
+    @Autowired
+    private IEamWeekMaintenanceOrderDetailService weekMaintenanceOrderDetailService;
 
     /**
      * 鍒嗛〉鍒楄〃鏌ヨ
@@ -136,10 +152,10 @@
     @DeleteMapping(value = "/abolish")
     public Result<?> abolish(@RequestParam(name = "id", required = true) String id) {
         EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderService.getById(id);
-        if(entity == null) {
+        if (entity == null) {
             return Result.error("瑕佷綔搴熺殑鏁版嵁涓嶅瓨鍦紝璇峰埛鏂伴噸璇曪紒");
         }
-        if(!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) {
+        if (!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) {
             return Result.error("璇ョ姸鎬佺殑鏁版嵁涓嶅厑璁歌繘琛屼綔搴燂紒");
         }
         entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.ABOLISH.name());
@@ -158,7 +174,7 @@
     @GetMapping(value = "/collect")
     public Result<?> collect(@RequestParam(name = "id", required = true) String id) {
         boolean b = eamWeekMaintenanceOrderService.collect(id);
-        if(!b) {
+        if (!b) {
             Result.OK("棰嗗彇澶辫触!");
         }
         return Result.OK("棰嗗彇鎴愬姛!");
@@ -189,14 +205,40 @@
     @DeleteMapping(value = "/abolishBatch")
     public Result<?> abolishBatch(@RequestParam(name = "ids", required = true) String ids) {
         List<String> list = Arrays.asList(ids.split(","));
+        AtomicInteger i = new AtomicInteger();
         list.forEach(id -> {
             EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderService.getById(id);
             if (entity != null && WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) {
                 entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.ABOLISH.name());
                 eamWeekMaintenanceOrderService.updateById(entity);
+                i.getAndIncrement();
             }
         });
-        return Result.OK("鎵归噺浣滃簾鎴愬姛锛�");
+        return Result.OK("鎵归噺浣滃簾鎴愬姛 " + i.get() + " 鏉″伐鍗曪紒");
+    }
+
+    /**
+     * 閫氳繃id鎵归噺棰嗗彇
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "鍛ㄤ繚宸ュ崟-鎵归噺棰嗗彇")
+    @ApiOperation(value = "鍛ㄤ繚宸ュ崟-鎵归噺棰嗗彇", notes = "鍛ㄤ繚宸ュ崟-鎵归噺棰嗗彇")
+    @DeleteMapping(value = "/collectBatch")
+    public Result<?> collectBatch(@RequestParam(name = "ids", required = true) String ids) {
+        List<String> list = Arrays.asList(ids.split(","));
+        AtomicInteger i = new AtomicInteger();
+        list.forEach(id -> {
+            EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderService.getById(id);
+            if (entity != null && WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) {
+                boolean b = eamWeekMaintenanceOrderService.collect(id);
+                if (b) {
+                    i.getAndIncrement();
+                }
+            }
+        });
+        return Result.OK("鎵归噺棰嗗彇鎴愬姛 " + i.get() + " 鏉″伐鍗曪紒");
     }
 
     /**
@@ -209,11 +251,32 @@
     @GetMapping(value = "/queryById")
     public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
         EamWeekMaintenanceOrder eamWeekMaintenanceOrder = eamWeekMaintenanceOrderService.getById(id);
-        return Result.OK(eamWeekMaintenanceOrder);
+        if (eamWeekMaintenanceOrder == null) {
+            return Result.error("鏈壘鍒板搴旀暟鎹�");
+        }
+        try {
+            String json = objectMapper.writeValueAsString(eamWeekMaintenanceOrder);
+            JSONObject item = JSONObject.parseObject(json, Feature.OrderedField);
+            translateDictTextUtils.translateField("equipmentId", eamWeekMaintenanceOrder.getEquipmentId(), item, "eam_equipment,equipment_code,id");
+            translateDictTextUtils.translateField("standardId", eamWeekMaintenanceOrder.getStandardId(), item, "eam_maintenance_standard,standard_name,id");
+            translateDictTextUtils.translateField("operator", eamWeekMaintenanceOrder.getOperator(), item, "sys_user,realname,username");
+            translateDictTextUtils.translateField("operatorPhone", eamWeekMaintenanceOrder.getOperator(), item, "sys_user,phone,username");
+            translateDictTextUtils.translateField("creationMethod", eamWeekMaintenanceOrder.getCreationMethod(), item, "order_creation_method");
+            translateDictTextUtils.translateField("maintenanceStatus", eamWeekMaintenanceOrder.getMaintenanceStatus(), item, "week_maintenance_status");
+            translateDictTextUtils.translateField("confirmUser", eamWeekMaintenanceOrder.getConfirmUser(), item, "sys_user,realname,username");
+            translateDictTextUtils.translateField("confirmDealType", eamWeekMaintenanceOrder.getConfirmDealType(), item, "approved_rejected");
+            translateDictTextUtils.translateField("initialAcceptanceUser", eamWeekMaintenanceOrder.getInitialAcceptanceUser(), item, "sys_user,realname,username");
+            translateDictTextUtils.translateField("finalAcceptanceUser", eamWeekMaintenanceOrder.getFinalAcceptanceUser(), item, "sys_user,realname,username");
+            translateDictTextUtils.translateField("installationPosition", eamWeekMaintenanceOrder.getEquipmentId(), item, "eam_equipment,installation_position,id");
+            return Result.OK(item);
+        } catch (JsonProcessingException e) {
+            return Result.error("鏁版嵁杞瘧澶辫触锛�");
+        }
     }
 
     /**
      * 鎴戠殑寰呭姙锛屽鎵瑰姩浣�
+     *
      * @param request
      * @return
      */
@@ -230,10 +293,82 @@
         if (StrUtil.isBlank(request.getTaskId()) || StrUtil.isBlank(request.getDataId()) || StrUtil.isBlank(request.getInstanceId())) {
             return Result.error("瀹℃壒浠诲姟閿欒鎴栦笉瀛樺湪锛�");
         }
-        boolean b = eamWeekMaintenanceOrderService.approval(request);
-        if(!b) {
+        EamWeekMaintenanceOrder b = eamWeekMaintenanceOrderService.approval(request);
+        if (b == null) {
             return Result.error("鎿嶄綔澶辫触锛�");
         }
         return Result.ok("鎿嶄綔鎴愬姛锛�");
     }
+
+    @ApiOperation(value = "鍛ㄤ繚宸ュ崟-鎵归噺瀹℃壒娴佺▼", notes = "鍛ㄤ繚宸ュ崟-鎵归噺瀹℃壒娴佺▼")
+    @PostMapping("/batchApproval")
+    public Result<?> batchApproval(@RequestBody EamWeekMaintenanceBatchApprovalRequest request) {
+        if (request == null || CollectionUtil.isEmpty(request.getTaskList())) {
+            return Result.error("娌℃湁闇�瑕佸鎵圭殑鏁版嵁锛�");
+        }
+        int n = 0;
+        StringBuilder errorMsg = new StringBuilder();
+        List<WorkTaskDataVo> tastList = request.getTaskList();
+        for (WorkTaskDataVo workTaskDataVo : tastList) {
+            EamWeekMaintenanceRequest orderRequest = new EamWeekMaintenanceRequest();
+            EamWeekMaintenanceOrder order = eamWeekMaintenanceOrderService.getById(workTaskDataVo.getDataId());
+            if (order == null) {
+                errorMsg.append("宸ュ崟ID锛�");
+                errorMsg.append(workTaskDataVo.getDataId());
+                errorMsg.append(",涓嶅瓨鍦ㄦ垨宸茶鍒犻櫎!\n");
+                continue;
+            }
+            if (!(WeekMaintenanceStatusEnum.WAIT_CONFIRM.name().equals(order.getMaintenanceStatus())
+                    || WeekMaintenanceStatusEnum.WAIT_INITIAL_ACCEPTANCE.name().equals(order.getMaintenanceStatus())
+                    || WeekMaintenanceStatusEnum.WAIT_FINAL_ACCEPTANCE.name().equals(order.getMaintenanceStatus()))) {
+                errorMsg.append("宸ュ崟鍙凤細");
+                errorMsg.append(order.getOrderNum());
+                errorMsg.append(",鐘舵�佹棤娉曟壒閲忓鎵�!\n");
+                continue;
+            }
+            List<EamWeekMaintenanceOrderDetail> tableDetailList = weekMaintenanceOrderDetailService.queryListByOrderId(order.getId());
+            try {
+                orderRequest.setId(order.getId());
+                orderRequest.setEquipmentId(order.getEquipmentId());
+                //瀹℃壒淇℃伅
+                if (WeekMaintenanceStatusEnum.WAIT_CONFIRM.name().equals(order.getMaintenanceStatus())) {
+                    orderRequest.setConfirmComment(request.getConfirmComment());
+                    orderRequest.setConfirmDealType(request.getConfirmDealType());
+                } else if (WeekMaintenanceStatusEnum.WAIT_INITIAL_ACCEPTANCE.name().equals(order.getMaintenanceStatus())) {
+                    orderRequest.setInitialAcceptanceComment(request.getInitialAcceptanceComment());
+                    orderRequest.setInitialAcceptanceFilesResult(request.getInitialAcceptanceFilesResult());
+                } else if (WeekMaintenanceStatusEnum.WAIT_FINAL_ACCEPTANCE.name().equals(order.getMaintenanceStatus())) {
+                    orderRequest.setFinalAcceptanceComment(request.getFinalAcceptanceComment());
+                    orderRequest.setFinalAcceptanceFilesResult(request.getFinalAcceptanceFilesResult());
+                }
+                //浠诲姟淇℃伅
+                orderRequest.setDataId(workTaskDataVo.getDataId());
+                orderRequest.setTaskId(workTaskDataVo.getId());
+                orderRequest.setUserId(workTaskDataVo.getAssignee());
+                orderRequest.setInstanceId(workTaskDataVo.getProcInstId());
+                orderRequest.setValues(workTaskDataVo.getVariables());
+                orderRequest.setTableDetailList(tableDetailList);
+                EamWeekMaintenanceOrder result = eamWeekMaintenanceOrderService.approval(orderRequest);
+                if (result == null) {
+                    errorMsg.append("宸ュ崟鍙凤細");
+                    errorMsg.append(order.getOrderNum());
+                    errorMsg.append(",瀹℃壒澶辫触!\n");
+                    continue;
+                }
+                n++;
+
+            } catch (Exception e) {
+                errorMsg.append("宸ュ崟鍙凤細");
+                errorMsg.append(order.getOrderNum());
+                errorMsg.append(",瀹℃壒澶辫触,閿欒鍘熷洜:");
+                errorMsg.append(e.getMessage() + "\n");
+            }
+
+        }
+        if (n > 0) {
+            String message = "鎴愬姛瀹℃壒閫氳繃" + n + "鏉¤褰曪紒\n" + errorMsg;
+            return Result.OK(message);
+        }
+        return Result.error(errorMsg.toString());
+    }
 }

--
Gitblit v1.9.3