From cf20a9f777951dbc61018a4294c12ae9b7421e78 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期六, 12 七月 2025 16:59:55 +0800 Subject: [PATCH] 二保基础流程代码 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java | 124 ++++++++++++++++++++---------- lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/SecondMaintenanceStatusEnum.java | 5 lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/entity/EamSecondMaintenanceOrder.java | 9 + lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamSecondMaintenanceOrderController.java | 45 ----------- 4 files changed, 92 insertions(+), 91 deletions(-) diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/SecondMaintenanceStatusEnum.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/SecondMaintenanceStatusEnum.java index c897f44..f60fa58 100644 --- a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/SecondMaintenanceStatusEnum.java +++ b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/SecondMaintenanceStatusEnum.java @@ -3,10 +3,9 @@ public enum SecondMaintenanceStatusEnum { WAIT_MAINTENANCE, //寰呬繚鍏� UNDER_MAINTENANCE, //淇濆吇涓� - WAIT_CONFIRM, //寰呯‘璁� - WAIT_LEADER_CONFIRM, // 寰呴瀵肩‘璁� + WAIT_ADMIN_CONFIRM, //绠$悊鍛樼‘璁� + WAIT_INSPECTOR_CONFIRM, // 妫�鏌ヤ汉纭 COMPLETE, //宸插畬鎴� - ABOLISH, //宸蹭綔搴� ; public static SecondMaintenanceStatusEnum getInstance(String code) { diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/entity/EamSecondMaintenanceOrder.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/entity/EamSecondMaintenanceOrder.java index 762c118..75db204 100644 --- a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/entity/EamSecondMaintenanceOrder.java +++ b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/entity/EamSecondMaintenanceOrder.java @@ -103,9 +103,11 @@ private Date actualEndTime; /** 鎿嶄綔宸� */ @ApiModelProperty(value = "鎿嶄綔宸�") + @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") private String operator ; /** 缁翠慨宸� */ @ApiModelProperty(value = "缁翠慨宸�") + @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") private String repairman ; /** * 淇濆吇鐘舵�� 寰呬繚鍏汇�佷繚鍏讳腑銆佺鐞嗗憳纭銆佹鏌ヤ汉纭銆佸凡瀹屾垚 @@ -126,7 +128,7 @@ */ @Excel(name = "绠$悊鍛樼‘璁�", width = 15) @ApiModelProperty(value = "绠$悊鍛樼‘璁�") - @Dict(dicCode = "sys_user, realname, username") + @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") private String manageUser; /** 闂鎻忚堪;榛樿 鏃� */ @ApiModelProperty(name = "闂鎻忚堪",notes = "榛樿 鏃�") @@ -141,13 +143,16 @@ private Date confirmTime ; /** 妫�鏌ヤ汉纭 */ @ApiModelProperty(name = "妫�鏌ヤ汉纭",notes = "") + @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") private String inspector; /** 妫�鏌ヤ汉鎰忚 */ @ApiModelProperty(name = "妫�鏌ヤ汉鎰忚",notes = "") private String inspectConfirmComment; /** 妫�鏌ヤ汉纭鏃堕棿 */ @ApiModelProperty(name = "妫�鏌ヤ汉纭鏃堕棿",notes = "") - private String inspectConfirmTime; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date inspectConfirmTime; /** HF缂栫爜 */ @ApiModelProperty(name = "HF缂栫爜",notes = "") private String hfCode; diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamSecondMaintenanceOrderController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamSecondMaintenanceOrderController.java index c17443f..056eb5f 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamSecondMaintenanceOrderController.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamSecondMaintenanceOrderController.java @@ -131,28 +131,6 @@ } /** - * 閫氳繃id浣滃簾 - * - * @param id - * @return - */ - @AutoLog(value = "璁惧浜岀骇淇濆吇-浣滃簾") - @ApiOperation(value = "璁惧浜岀骇淇濆吇-浣滃簾", notes = "璁惧浜岀骇淇濆吇-浣滃簾") - @DeleteMapping(value = "/abolish") - public Result<?> abolish(@RequestParam(name = "id", required = true) String id) { - EamSecondMaintenanceOrder entity = eamSecondMaintenanceOrderService.getById(id); - if (entity == null) { - return Result.error("瑕佷綔搴熺殑鏁版嵁涓嶅瓨鍦紝璇峰埛鏂伴噸璇曪紒"); - } - if (!SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { - return Result.error("璇ョ姸鎬佺殑鏁版嵁涓嶅厑璁歌繘琛屼綔搴燂紒"); - } - entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.ABOLISH.name()); - eamSecondMaintenanceOrderService.updateById(entity); - return Result.OK("浣滃簾鎴愬姛!"); - } - - /** * 閫氳繃id棰嗗彇 * * @param id @@ -167,29 +145,6 @@ Result.OK("棰嗗彇澶辫触!"); } return Result.OK("棰嗗彇鎴愬姛!"); - } - - /** - * 閫氳繃id鎵归噺浣滃簾 - * - * @param ids - * @return - */ - @AutoLog(value = "鍛ㄤ繚宸ュ崟-鎵归噺浣滃簾") - @ApiOperation(value = "鍛ㄤ繚宸ュ崟-鎵归噺浣滃簾", notes = "鍛ㄤ繚宸ュ崟-鎵归噺浣滃簾") - @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 -> { - EamSecondMaintenanceOrder entity = eamSecondMaintenanceOrderService.getById(id); - if (entity != null && SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { - entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.ABOLISH.name()); - eamSecondMaintenanceOrderService.updateById(entity); - i.getAndIncrement(); - } - }); - return Result.OK("鎵归噺浣滃簾鎴愬姛 " + i.get() + " 鏉″伐鍗曪紒"); } /** diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java index b26bfbe..75ab1fa 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java @@ -254,17 +254,25 @@ throw new JeecgBootException("璁惧涓嶅瓨鍦紝娣诲姞澶辫触锛�"); } LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - if(sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { - throw new JeecgBootException("涓嶆槸鎿嶄綔宸ワ紝鏃犳硶棰嗗彇姝ゅ伐鍗曪紒"); + if(sysUser != null) { + if (!BusinessCodeConst.PCR0001.equals(sysUser.getPost()) && !BusinessCodeConst.PCR0002.equals(sysUser.getPost())){ + throw new JeecgBootException("涓嶆槸鎿嶄綔宸ワ紝鏃犳硶棰嗗彇姝ゅ伐鍗曪紒"); + } } - entity.setOperator(sysUser.getUsername()); + if (sysUser != null) { + entity.setOperator(sysUser.getUsername()); + } + if (BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { + entity.setOperator(sysUser.getUsername()); + }else if (BusinessCodeConst.PCR0002.equals(sysUser.getPost())) { + entity.setRepairman(sysUser.getUsername()); + } entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); entity.setActualStartTime(new Date()); eamSecondMaintenanceOrderMapper.updateById(entity); - //鍚姩娴佺▼ - flowCommonService.initActBusiness("宸ュ崟鍙�: " + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";瀹夎浣嶇疆" + equipment.getInstallationPosition(), - entity.getId(), "IEamSecondMaintenanceOrderService", "second_maintenance_process", null); + flowCommonService.initActBusiness("宸ュ崟鍙�: " + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + "杩涜璁惧浜岀骇淇濆吇", + entity.getId(), "IEamSecondMaintenanceOrderService", "SecondMaintenance_Process", null); Map<String, Object> variables = new HashMap<>(); variables.put("dataId", entity.getId()); if (StrUtil.isEmpty(entity.getRemark())) { @@ -277,8 +285,24 @@ variables.put("proofreading", true); List<String> usernames = new ArrayList<>(); usernames.add(entity.getOperator()); - variables.put("NextAssignee", usernames); - Result result = flowDefinitionService.startProcessInstanceByKey("second_maintenance_process", variables); + if (sysUser != null) { + if (BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { + variables.put("operator_task", usernames); + List<UserSelector> userSelectorList = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002); + if (!CollectionUtils.isEmpty(userSelectorList)) { + List<String> usernameList = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + variables.put("maintenance_task",usernameList); + } + }else if (BusinessCodeConst.PCR0002.equals(sysUser.getPost())) { + variables.put("maintenance_task", usernames); + List<UserSelector> userSelectorList = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0001); + if (!CollectionUtils.isEmpty(userSelectorList)) { + List<String> usernameList = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + variables.put("operator_task",usernameList); + } + } + } + Result result = flowDefinitionService.startProcessInstanceByKey("SecondMaintenance_Process", variables); if (result != null) { //鏇存柊璁惧淇濆吇鐘舵�� eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_SECOND_MAINTENANCE.name()); @@ -302,7 +326,7 @@ } request.setAssignee(user.getUsername()); // 鑾峰彇娴佺▼涓氬姟璁板綍 - FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(request.getInstanceId()); + FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(request.getInstanceId(), request.getTaskId()); if (flowMyBusiness == null) { throw new JeecgBootException("娴佺▼瀹炰緥涓嶅瓨鍦紝璇峰埛鏂板悗閲嶈瘯锛�"); } @@ -331,45 +355,63 @@ List<UserSelector> userSelectors; switch (status) { case UNDER_MAINTENANCE: + //淇濆吇涓� + boolean parallelCompletion = flowTaskService.checkParallelCompletion(flowMyBusiness.getTaskId()); //鎵ц瀹屾垚 - //璁惧绠$悊鍛樼‘璁� -// String equipmentManager = equipment.getEquipmentManager(); -// if(StringUtils.isBlank(equipmentManager)) { -// throw new JeecgBootException("璁惧鏈垎閰嶈澶囩鐞嗗憳锛屾棤娉曡繘鍏ヤ笅绾у鎵癸紒"); -// } -// userApprovalList = Collections.singletonList(equipmentManager); - values.put("dataId", entity.getId()); - values.put("organization", "浜屼繚鎵ц缁撴潫"); - values.put("comment", "浜屼繚鎵ц缁撴潫"); -// values.put("NextAssignee", userApprovalList); - request.setComment("浜屼繚鎵ц缁撴潫"); - //璁剧疆entity - entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_CONFIRM.name()); - entity.setActualEndTime(new Date()); - //鏇存柊璁惧淇濆吇鐘舵�� - eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.SECOND_MAINTENANCE_WAIT_CONFIRM.name()); - break; - case WAIT_CONFIRM: - userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(),null, BusinessCodeConst.PCR0003); + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0004); if (CollectionUtil.isEmpty(userSelectors)) { - throw new JeecgBootException("璁惧鏈垎閰嶇粰杞﹂棿鐝粍闀匡紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + throw new JeecgBootException("璁惧鏈瓨鍦ㄧ鐞嗗憳锛屾棤娉曡繘鍏ヤ笅绾у鎵癸紒"); + }else{ + userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + if (parallelCompletion) { + values.put("NextAssignee", userApprovalList); + entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_ADMIN_CONFIRM.name()); + entity.setActualEndTime(new Date()); + } } - //鐝粍闀跨‘璁� - userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); - //璁剧疆entity - entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_LEADER_CONFIRM.name()); - entity.setConfirmTime(new Date()); - break; - case WAIT_LEADER_CONFIRM: + if (BusinessCodeConst.PCR0001.equals(user.getPost())) { + entity.setOperator(user.getUsername()); + //澶勭悊瀵瑰簲璇︽儏 + }else if (BusinessCodeConst.PCR0002.equals(user.getPost())) { + entity.setRepairman(user.getUsername()); + //澶勭悊瀵瑰簲璇︽儏 + } values.put("dataId", entity.getId()); - //璁剧疆entity - entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.COMPLETE.name()); - //鏇存柊璁惧淇濆吇鐘舵�� - eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); + values.put("organization", "涓変繚鎵ц缁撴潫"); + values.put("comment", "涓変繚鎵ц缁撴潫"); break; + case WAIT_ADMIN_CONFIRM: + //绠$悊鍛樼‘璁� + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0003); + if (CollectionUtil.isEmpty(userSelectors)) { + throw new JeecgBootException("璁惧鏈瓨鍦ㄦ鏌ヤ汉锛屾棤娉曡繘鍏ヤ笅绾у鎵癸紒"); + }else{ + userApprovalList= userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + values.put("NextAssignee", userApprovalList); + values.put("dataId", entity.getId()); + values.put("organization",request.getComment()); + values.put("comment", request.getComment()); + entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_INSPECTOR_CONFIRM.name()); + entity.setManageUser(user.getUsername()); + entity.setProblemDescription(request.getProblemDescription()); + entity.setDealDescription(request.getComment()); + entity.setConfirmTime(new Date()); + } + break; + case WAIT_INSPECTOR_CONFIRM: + //妫�鏌ヤ汉纭 + values.put("dataId", entity.getId()); + values.put("organization",request.getComment()); + values.put("comment", request.getComment()); + entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.COMPLETE.name()); + entity.setInspector(user.getUsername()); + entity.setInspectConfirmComment(request.getInspectConfirmComment()); + entity.setInspectConfirmTime(new Date()); + break; + default: + throw new JeecgBootException("瀹℃壒澶辫触"); } request.setValues(values); - // 瀹屾垚娴佺▼浠诲姟 Result result = flowTaskService.complete(request); if (!result.isSuccess()) { -- Gitblit v1.9.3