From 23396e93588f52941f729fc63cea84a70847d3bc Mon Sep 17 00:00:00 2001 From: hyingbo <1363390067@qq.com> Date: 星期四, 11 九月 2025 11:08:12 +0800 Subject: [PATCH] 二保三保设备保养时间调整 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java | 136 +++++++++++++++++++++++--------------------- 1 files changed, 71 insertions(+), 65 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java index 74d7f13..2a6e4f1 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java @@ -3,6 +3,7 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -19,13 +20,12 @@ import org.jeecg.common.constant.DataBaseConstant; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.common.util.DateUtils; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog; -import org.jeecg.modules.eam.constant.BusinessCodeConst; -import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus; -import org.jeecg.modules.eam.constant.EquipmentOperationTagEnum; -import org.jeecg.modules.eam.constant.ThirdMaintenanceStatusEnum; +import org.jeecg.modules.eam.constant.*; import org.jeecg.modules.eam.entity.EamEquipment; +import org.jeecg.modules.eam.entity.EamMaintenanceStandard; import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrder; import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrderDetail; import org.jeecg.modules.eam.mapper.EamThirdMaintenanceOrderMapper; @@ -45,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -81,6 +82,8 @@ private IEamEquipmentExtendService eamEquipmentExtendService; @Autowired private IEamPrecisionCheckDetailService precisionCheckDetailService; + @Autowired + private IEamMaintenanceStandardService eamMaintenanceStandardService; @Override public IPage<EamThirdMaintenanceOrder> queryPageList(Page<EamThirdMaintenanceOrder> page, EamThirdMaintenanceQuery query) { @@ -171,32 +174,28 @@ } //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋� if (StringUtils.isNotBlank(order.getOperator())) { - //鍚姩娴佺▼ TODO -// flowCommonService.initActBusiness("宸ュ崟鍙�:" + order.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";杩涜璁惧浜屼繚", -// order.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null); -// Map<String, Object> variables = new HashMap<>(); -// variables.put("dataId", order.getId()); -// if (StrUtil.isEmpty(order.getRemark())) { -// variables.put("organization", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼"); -// variables.put("comment", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼"); -// } else { -// variables.put("organization", order.getRemark()); -// variables.put("comment", order.getRemark()); -// } -// variables.put("proofreading", true); -// List<String> usernames = new ArrayList<>(); -// usernames.add(order.getOperator()); -// variables.put("NextAssignee", usernames); -// Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables); -// if (result != null) { -// //鏇存柊鍛ㄤ繚鐘舵�� -// order.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); -// order.setActualStartTime(new Date()); -// eamWeekMaintenanceOrderMapper.updateById(order); -// //鏇存柊璁惧淇濆吇鐘舵�� -// eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name()); -// return result.isSuccess(); -// } + //鍚姩娴佺▼ + flowCommonService.initActBusiness("宸ュ崟鍙�:" + order.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";瀹夎浣嶇疆" + equipment.getInstallationPosition(), + order.getId(), "IEamThirdMaintenanceOrderService", "third_maintenance_process", null); + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", order.getId()); + if (StrUtil.isEmpty(order.getRemark())) { + variables.put("organization", "鏂板涓変繚宸ュ崟榛樿鍚姩娴佺▼"); + variables.put("comment", "鏂板涓変繚宸ュ崟榛樿鍚姩娴佺▼"); + } else { + variables.put("organization", order.getRemark()); + variables.put("comment", order.getRemark()); + } + variables.put("proofreading", true); + //骞惰浠诲姟浼氱 + variables.put("maintenance_execution", Collections.singletonList(request.getOperator())); + variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager())); + Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables); + if (result != null) { + //鏇存柊璁惧淇濆吇鐘舵�� + eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name(), null, null); + return result.isSuccess(); + } } return true; @@ -246,32 +245,28 @@ } //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋� if (StringUtils.isNotBlank(entity.getOperator())) { - //鍚姩娴佺▼ TODO -// flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";杩涜璁惧鍛ㄤ繚", -// entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null); -// Map<String, Object> variables = new HashMap<>(); -// variables.put("dataId", entity.getId()); -// if (StrUtil.isEmpty(entity.getRemark())) { -// variables.put("organization", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼"); -// variables.put("comment", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼"); -// } else { -// variables.put("organization", entity.getRemark()); -// variables.put("comment", entity.getRemark()); -// } -// variables.put("proofreading", true); -// List<String> usernames = new ArrayList<>(); -// usernames.add(entity.getOperator()); -// variables.put("NextAssignee", usernames); -// Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables); -// if (result != null) { -// //鏇存柊鍛ㄤ繚鐘舵�� -// entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); -// entity.setActualStartTime(new Date()); -// eamWeekMaintenanceOrderMapper.updateById(entity); -// //鏇存柊璁惧淇濆吇鐘舵�� -// eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name()); -// return result.isSuccess(); -// } + //鍚姩娴佺▼ + flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";瀹夎浣嶇疆" + equipment.getInstallationPosition(), + entity.getId(), "IEamThirdMaintenanceOrderService", "third_maintenance_process", null); + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", entity.getId()); + if (StrUtil.isEmpty(entity.getRemark())) { + variables.put("organization", "鏂板涓変繚宸ュ崟榛樿鍚姩娴佺▼"); + variables.put("comment", "鏂板涓変繚宸ュ崟榛樿鍚姩娴佺▼"); + } else { + variables.put("organization", entity.getRemark()); + variables.put("comment", entity.getRemark()); + } + variables.put("proofreading", true); + //骞惰浠诲姟浼氱 + variables.put("maintenance_execution", Collections.singletonList(request.getOperator())); + variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager())); + Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables); + if (result != null) { + //鏇存柊璁惧淇濆吇鐘舵�� + eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name(), null, null); + return result.isSuccess(); + } } return true; @@ -291,9 +286,11 @@ if (equipment == null) { throw new JeecgBootException("璁惧涓嶅瓨鍦紝娣诲姞澶辫触锛�"); } - if (StringUtils.isBlank(equipment.getEquipmentManager())) { - throw new JeecgBootException("璁惧鏈垎閰嶈澶囩鐞嗗憳锛屾棤娉曡繘鍏ヤ笅绾у鎵癸紒"); + List<UserSelector> userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0002); + if (CollectionUtil.isEmpty(userSelectors)) { + throw new JeecgBootException("璁惧鏈垎閰嶇粰缁翠慨宸ワ紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); } + List<String> userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); if (sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { throw new JeecgBootException("涓嶆槸鎿嶄綔宸ワ紝鏃犳硶棰嗗彇姝ゅ伐鍗曪紒"); @@ -304,7 +301,7 @@ eamThirdMaintenanceOrderMapper.updateById(entity); //鍚姩娴佺▼ - flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";杩涜璁惧涓変繚", + flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";瀹夎浣嶇疆" + equipment.getInstallationPosition(), entity.getId(), "IEamThirdMaintenanceOrderService", "third_maintenance_process", null); Map<String, Object> variables = new HashMap<>(); boolean equipmentPrecisionFlag = precisionCheckDetailService.hasPrecisionCheckDetail(entity.getId()); @@ -319,12 +316,14 @@ } variables.put("proofreading", true); //骞惰浠诲姟浼氱 + //鎿嶄綔宸ユ墽琛屼繚鍏� variables.put("maintenance_execution", Collections.singletonList(sysUser.getUsername())); - variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager())); + //缁翠慨宸ョ簿搴︽楠� + variables.put("precision_check", userApprovalList); Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables); if (result != null) { //鏇存柊璁惧淇濆吇鐘舵�� - eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name()); + eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name(), null, null); return result.isSuccess(); } return true; @@ -378,7 +377,7 @@ //鎵ц瀹屾垚 userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0006); if (CollectionUtil.isEmpty(userSelectors)) { - throw new JeecgBootException("璁惧鏈垎閰嶇粰杞﹂棿鐝粍闀匡紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + throw new JeecgBootException("璁惧鏈垎閰嶇粰鏈哄姩鍔烇紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); } userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); values.put("dataId", entity.getId()); @@ -420,13 +419,13 @@ } if (parallelCompletion) { //鏇存柊璁惧淇濆吇鐘舵�� - eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.THIRD_MAINTENANCE_WAIT_CONFIRM.name()); + eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.THIRD_MAINTENANCE_WAIT_CONFIRM.name(), null, null); } break; case WAIT_CONFIRM: userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0003); if (CollectionUtil.isEmpty(userSelectors)) { - throw new JeecgBootException("璁惧鏈垎閰嶇粰杞﹂棿鐝粍闀匡紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + throw new JeecgBootException("璁惧鏈垎閰嶇粰缁翠慨涓讳换锛屾棤娉曡繘鍏ヤ笅绾у鎵癸紒"); } //鐝粍闀跨‘璁� userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); @@ -457,8 +456,15 @@ entity.setConfirmLeader(user.getUsername()); entity.setLeaderConfirmComment(request.getLeaderConfirmComment()); entity.setLeaderConfirmTime(new Date()); + + //鏌ヨ淇濆吇鏍囧噯 + EamMaintenanceStandard standard = eamMaintenanceStandardService.getOne(new LambdaQueryWrapper<EamMaintenanceStandard>() + .eq(EamMaintenanceStandard::getEquipmentId, entity.getEquipmentId()) + .eq(EamMaintenanceStandard::getMaintenanceCategory, MaintenanceCategoryEnum.THIRD_MAINTENANCE.name())); + LocalDate nextThirdMaintenanceDate = DateUtils.dateToLocalDate(standard.getInitialDate()).plusDays(standard.getMaintenancePeriod()); + //鏇存柊璁惧淇濆吇鐘舵�� - eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); + eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name(), standard.getMaintenanceCategory(), DateUtils.localDateToDate(nextThirdMaintenanceDate)); break; } request.setValues(values); -- Gitblit v1.9.3