From 9b00a4bf526c0f0d06ab5c1d1f80f52c7f384859 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期五, 25 四月 2025 15:33:07 +0800 Subject: [PATCH] art: 设备管理-点检-换行 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamWeekMaintenanceOrderController.java | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 111 insertions(+), 5 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 6050f33..3e8e42b 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 @@ -11,6 +11,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.beanutils.BeanUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; @@ -19,9 +20,13 @@ 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.*; @@ -29,6 +34,7 @@ import javax.servlet.http.HttpServletRequest; import java.util.Arrays; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; /** * @Description: 鍛ㄤ繚宸ュ崟 @@ -49,6 +55,8 @@ private ObjectMapper objectMapper; @Autowired private TranslateDictTextUtils translateDictTextUtils; + @Autowired + private IEamWeekMaintenanceOrderDetailService weekMaintenanceOrderDetailService; /** * 鍒嗛〉鍒楄〃鏌ヨ @@ -145,10 +153,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()); @@ -167,7 +175,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("棰嗗彇鎴愬姛!"); @@ -198,14 +206,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() + " 鏉″伐鍗曪紒"); } /** @@ -241,6 +275,7 @@ /** * 鎴戠殑寰呭姙锛屽鎵瑰姩浣� + * * @param request * @return */ @@ -258,9 +293,80 @@ return Result.error("瀹℃壒浠诲姟閿欒鎴栦笉瀛樺湪锛�"); } EamWeekMaintenanceOrder b = eamWeekMaintenanceOrderService.approval(request); - if(b == null) { + 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 { + BeanUtils.copyProperties(orderRequest, order); + //瀹℃壒淇℃伅 + 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