From 504333e56f249d16e71e8ac2a435cf2212040c23 Mon Sep 17 00:00:00 2001 From: cuikaidong <ckd2942379034@163.com> Date: 星期二, 27 五月 2025 17:32:50 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java | 536 +++++++++++++++++----------- lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/BusinessCodeConst.java | 2 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamThirdMaintenanceOrderService.java | 7 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java | 6 lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/IFlowTaskService.java | 11 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamThirdMaintenanceRequest.java | 3 lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java | 27 + lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamThirdMaintenanceOrderServiceImpl.java | 259 ++++++++++--- lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/controller/FlowTaskController.java | 4 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceOrderController.java | 24 + lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowDefinitionServiceImpl.java | 240 ++++++++---- lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/IFlowMyBusinessService.java | 16 12 files changed, 774 insertions(+), 361 deletions(-) diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/BusinessCodeConst.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/BusinessCodeConst.java index a27b1a9..7d5cd9e 100644 --- a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/BusinessCodeConst.java +++ b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/BusinessCodeConst.java @@ -49,5 +49,7 @@ String PCR0004 = "PCR0004"; //璁惧鑳芥簮閮� String PCR0005 = "PCR0005"; + //鏈哄姩鍔炵鐞嗗憳 + String PCR0006 = "PCR0006"; } diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceOrderController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceOrderController.java index 790cd00..9f1260a 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceOrderController.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamThirdMaintenanceOrderController.java @@ -1,6 +1,7 @@ package org.jeecg.modules.eam.controller; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; @@ -211,4 +212,27 @@ }); return Result.OK("鎵归噺棰嗗彇鎴愬姛 " + i.get() + " 鏉″伐鍗曪紒"); } + + /** + * 鎴戠殑寰呭姙锛屽鎵瑰姩浣� + * + * @param request + * @return + */ + @ApiOperation(value = "涓変繚宸ュ崟-鎵ц鎿嶄綔", notes = "涓変繚宸ュ崟-鎵ц鎿嶄綔") + @PutMapping(value = "/approval") + public Result<?> approval(@RequestBody EamThirdMaintenanceRequest request) { + if (request == null) { + return Result.error("瀹℃壒鐨勫璞′笉鑳戒负绌猴紒"); + } + // 妫�鏌ヨ姹傚弬鏁� + if (StrUtil.isBlank(request.getTaskId()) || StrUtil.isBlank(request.getDataId()) || StrUtil.isBlank(request.getInstanceId())) { + return Result.error("瀹℃壒浠诲姟閿欒鎴栦笉瀛樺湪锛�"); + } + EamThirdMaintenanceOrder entity = eamThirdMaintenanceOrderService.approval(request); + if (entity == null) { + return Result.error("鎿嶄綔澶辫触锛�"); + } + return Result.ok("鎿嶄綔鎴愬姛锛�"); + } } diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamThirdMaintenanceRequest.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamThirdMaintenanceRequest.java index 959f6cb..8000851 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamThirdMaintenanceRequest.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamThirdMaintenanceRequest.java @@ -75,4 +75,7 @@ private String confirmComment; @ApiModelProperty(value = "纭绫诲瀷") private String confirmDealType; + /**棰嗗纭鎰忚*/ + @ApiModelProperty(value = "棰嗗纭鎰忚") + private String leaderConfirmComment; } diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamThirdMaintenanceOrderService.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamThirdMaintenanceOrderService.java index b4e656e..4fbc0ca 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamThirdMaintenanceOrderService.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamThirdMaintenanceOrderService.java @@ -43,4 +43,11 @@ * @return */ boolean collect(String id); + + /** + * 瀹℃壒娴佺▼ + * @param request + * @return + */ + EamThirdMaintenanceOrder approval(EamThirdMaintenanceRequest request); } 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 6840c49..383da21 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 @@ -7,19 +7,23 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.flowable.engine.TaskService; import org.flowable.task.api.Task; +import org.jeecg.common.api.vo.FileUploadResult; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.DataBaseConstant; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.vo.LoginUser; 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.SecondMaintenanceStatusEnum; +import org.jeecg.modules.eam.constant.EquipmentOperationTagEnum; import org.jeecg.modules.eam.constant.ThirdMaintenanceStatusEnum; import org.jeecg.modules.eam.entity.EamEquipment; import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrder; @@ -35,6 +39,7 @@ import org.jeecg.modules.flowable.service.IFlowDefinitionService; import org.jeecg.modules.flowable.service.IFlowTaskService; import org.jeecg.modules.system.service.ISysUserService; +import org.jeecg.modules.system.vo.UserSelector; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -166,32 +171,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() + ";杩涜璁惧涓変繚", + 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()); + return result.isSuccess(); + } } return true; @@ -241,32 +242,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() + ";杩涜璁惧涓変繚", + 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()); + return result.isSuccess(); + } } return true; @@ -279,15 +276,18 @@ if (entity == null) { throw new JeecgBootException("瑕侀鍙栫殑宸ュ崟涓嶅瓨鍦紝璇峰埛鏂伴噸璇曪紒"); } - if (!SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { + if (!ThirdMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { throw new JeecgBootException("璇ュ伐鍗曞凡杩涜杩囬鍙栵紒"); } EamEquipment equipment = eamEquipmentService.getById(entity.getEquipmentId()); if (equipment == null) { throw new JeecgBootException("璁惧涓嶅瓨鍦紝娣诲姞澶辫触锛�"); } + if (StringUtils.isBlank(equipment.getEquipmentManager())) { + throw new JeecgBootException("璁惧鏈垎閰嶈澶囩鐞嗗憳锛屾棤娉曡繘鍏ヤ笅绾у鎵癸紒"); + } LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - if(sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { + if (sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { throw new JeecgBootException("涓嶆槸鎿嶄綔宸ワ紝鏃犳硶棰嗗彇姝ゅ伐鍗曪紒"); } entity.setOperator(sysUser.getUsername()); @@ -310,9 +310,9 @@ variables.put("comment", entity.getRemark()); } variables.put("proofreading", true); - List<String> usernames = new ArrayList<>(); - usernames.add(entity.getOperator()); - variables.put("NextAssignee", usernames); + //骞惰浠诲姟浼氱 + variables.put("maintenance_execution", Collections.singletonList(sysUser.getUsername())); + variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager())); Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables); if (result != null) { //鏇存柊璁惧淇濆吇鐘舵�� @@ -322,6 +322,149 @@ return true; } + @Override + @Transactional(rollbackFor = Exception.class) + @EquipmentHistoryLog(operationTag = EquipmentOperationTagEnum.THIRD_MAINTENANCE, businessTable = "eam_third_maintenance_order") + public EamThirdMaintenanceOrder approval(EamThirdMaintenanceRequest request) { + EamThirdMaintenanceOrder entity = eamThirdMaintenanceOrderMapper.selectById(request.getId()); + if (entity == null) { + throw new JeecgBootException("瀹℃壒鐨勬暟鎹凡鍒犻櫎锛岃鍒锋柊閲嶈瘯锛�"); + } + // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛 + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + if (user == null || StrUtil.isBlank(user.getId())) { + throw new JeecgBootException("鏈幏鍙栧埌鐧诲綍鐢ㄦ埛锛岃閲嶆柊鐧诲綍鍚庡啀璇曪紒"); + } + request.setAssignee(user.getUsername()); + // 鑾峰彇娴佺▼涓氬姟璁板綍 + FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(request.getInstanceId(), request.getTaskId()); + if (flowMyBusiness == null) { + throw new JeecgBootException("娴佺▼瀹炰緥涓嶅瓨鍦紝璇峰埛鏂板悗閲嶈瘯锛�"); + } + + boolean userAuthorized = isUserAuthorized(flowMyBusiness, user); + if (!userAuthorized) { + throw new JeecgBootException("鐢ㄦ埛鏃犳潈鎿嶄綔姝や换鍔★紝璇峰埛鏂板悗閲嶈瘯锛�"); + } + // 璁ら浠诲姟 + if (!claimTask(flowMyBusiness.getTaskId(), user)) { + throw new JeecgBootException("浠诲姟涓嶅瓨鍦ㄣ�佸凡瀹屾垚鎴栧凡琚粬浜鸿棰嗭紒"); + } + + EamEquipment equipment = eamEquipmentService.getById(entity.getEquipmentId()); + if (equipment == null) { + throw new JeecgBootException("璁惧涓嶅瓨鍦紝璇锋鏌ワ紒"); + } + + ThirdMaintenanceStatusEnum status = ThirdMaintenanceStatusEnum.getInstance(entity.getMaintenanceStatus()); + if (status == null) { + return null; + } + //娴佺▼鍙橀噺 + Map<String, Object> values = new HashMap<>(); + List<String> userApprovalList; + List<UserSelector> userSelectors; + switch (status) { + case UNDER_MAINTENANCE: + boolean parallelCompletion = flowTaskService.checkParallelCompletion(flowMyBusiness.getTaskId()); + //鎵ц瀹屾垚 + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0006); + if (CollectionUtil.isEmpty(userSelectors)) { + throw new JeecgBootException("璁惧鏈垎閰嶇粰杞﹂棿鐝粍闀匡紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + } + userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + values.put("dataId", entity.getId()); + values.put("organization", "涓変繚鎵ц缁撴潫"); + values.put("comment", "涓変繚鎵ц缁撴潫"); + if (parallelCompletion) { + values.put("NextAssignee", userApprovalList); + } + request.setComment("涓変繚鎵ц缁撴潫"); + //璁剧疆entity + if (parallelCompletion) { + entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.WAIT_CONFIRM.name()); + entity.setActualEndTime(new Date()); + } + if ("maintenance_execution".equals(flowMyBusiness.getTaskNameId())) { + //鎵ц淇濆吇 + //澶勭悊闄勪欢 + if (CollectionUtil.isNotEmpty(request.getImageFilesResult())) { + List<FileUploadResult> fileUploadResultList = request.getImageFilesResult(); + ObjectMapper mapper = new ObjectMapper(); + try { + String referenceFile = mapper.writeValueAsString(fileUploadResultList); + entity.setImageFiles(referenceFile); + } catch (JsonProcessingException e) { + log.error("JSON杞崲澶辫触锛�" + e.getMessage(), e); + } + } + //澶勭悊璇︽儏 + if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { + thirdMaintenanceOrderDetailService.updateBatchById(request.getTableDetailList()); + } + } else if ("precision_check".equals(flowMyBusiness.getTaskNameId())) { + entity.setPrecisionChecker(user.getUsername()); + entity.setPrecisionCheckTime(new Date()); + //澶勭悊绮惧害妫�楠� + if (CollectionUtil.isNotEmpty(request.getPrecisionDetailList())) { + precisionCheckDetailService.updateBatchById(request.getPrecisionDetailList()); + } + } + if (parallelCompletion) { + //鏇存柊璁惧淇濆吇鐘舵�� + eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.THIRD_MAINTENANCE_WAIT_CONFIRM.name()); + } + break; + case WAIT_CONFIRM: + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0003); + if (CollectionUtil.isEmpty(userSelectors)) { + throw new JeecgBootException("璁惧鏈垎閰嶇粰杞﹂棿鐝粍闀匡紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); + } + //鐝粍闀跨‘璁� + userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + values.put("dataId", entity.getId()); + values.put("organization", request.getConfirmComment()); + values.put("comment", request.getConfirmComment()); + values.put("NextAssignee", userApprovalList); + values.put("confirmation", request.getConfirmDealType()); + request.setComment(request.getConfirmComment()); + //璁剧疆entity + entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.WAIT_LEADER_CONFIRM.name()); + entity.setConfirmUser(user.getUsername()); + entity.setConfirmComment(request.getConfirmComment()); + entity.setConfirmTime(new Date()); + //澶勭悊鎶ヤ慨 + List<EamThirdMaintenanceOrderDetail> collect = request.getTableDetailList().stream().filter((detail) -> CommonConstant.DEFAULT_1.equals(detail.getReportFlag())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(collect)) { + eamReportRepairService.reportRepairFromThirdMaintenance(equipment.getId(), entity.getOperator(), collect); + } + break; + case WAIT_LEADER_CONFIRM: + values.put("dataId", entity.getId()); + values.put("organization", request.getLeaderConfirmComment()); + values.put("comment", request.getLeaderConfirmComment()); + request.setComment(request.getLeaderConfirmComment()); + //璁剧疆entity + entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.COMPLETE.name()); + entity.setConfirmLeader(user.getUsername()); + entity.setLeaderConfirmComment(request.getLeaderConfirmComment()); + entity.setLeaderConfirmTime(new Date()); + //鏇存柊璁惧淇濆吇鐘舵�� + eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); + break; + } + request.setValues(values); + + // 瀹屾垚娴佺▼浠诲姟 + Result result = flowTaskService.complete(request); + if (!result.isSuccess()) { + throw new JeecgBootException("瀹℃壒澶辫触锛岃鍒锋柊鏌ョ湅锛�"); + } + //淇濆瓨宸ュ崟 + eamThirdMaintenanceOrderMapper.updateById(entity); + return entity; + } + private boolean isUserAuthorized(FlowMyBusiness flowMyBusiness, LoginUser user) { List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); return todoUsers != null && todoUsers.contains(user.getUsername()); 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 01a7462..efc54f1 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 @@ -356,14 +356,16 @@ } //娴佺▼鍙橀噺 Map<String, Object> values = new HashMap<>(); + List<UserSelector> userSelectors; + List<String> userApprovalList; switch (status) { case UNDER_MAINTENANCE: //鎵ц瀹屾垚 - List<UserSelector> userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0003); + userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0003); if (CollectionUtil.isEmpty(userSelectors)) { throw new JeecgBootException("璁惧鏈垎閰嶇粰鐝粍闀匡紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�"); } - List<String> userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); + userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); values.put("dataId", entity.getId()); values.put("organization", "鍛ㄤ繚鎵ц缁撴潫"); values.put("comment", "鍛ㄤ繚鎵ц缁撴潫"); diff --git a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/IFlowMyBusinessService.java b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/IFlowMyBusinessService.java index 0093f0e..2e89d35 100644 --- a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/IFlowMyBusinessService.java +++ b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/IFlowMyBusinessService.java @@ -2,6 +2,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +import java.util.List; + /** * @Description: 娴佺▼涓氬姟鎵╁睍琛� * @Author: jeecg-boot @@ -17,9 +19,23 @@ FlowMyBusiness getFlowMyBusiness(String instanceId); /** + * 鏍规嵁娴佺▼瀹炰緥id 鑾峰彇 娴佺▼瀹炰緥 + * @param instanceId 娴佺▼瀹炰緥id + * @return + */ + FlowMyBusiness getFlowMyBusiness(String instanceId, String taskId); + + /** * 鑾峰彇娴佺▼瀹炰緥 * @param dataId 涓氬姟Id * @return */ FlowMyBusiness selectByDataId(String dataId); + + /** + * 鑾峰彇娴佺▼瀹炰緥 澶氬疄渚嬪苟琛岋紝瀛樺湪澶氭潯璁板綍 + * @param dataId + * @return + */ + List<FlowMyBusiness> selectListByDataId(String dataId); } diff --git a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java index 1cf4f7f..99720f2 100644 --- a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java +++ b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.collections4.CollectionUtils; import org.flowable.engine.HistoryService; import org.flowable.engine.history.HistoricActivityInstance; import org.jeecg.modules.flowable.apithird.business.dto.FlowMyBusinessDto; @@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -37,14 +39,14 @@ public HistoricActivityInstance getPreviousNode(String taskId) { // 鑾峰彇褰撳墠浠诲姟鐨勬墽琛屽疄渚� ID - String executionId = historyService.createHistoricTaskInstanceQuery() + String processInstanceId = historyService.createHistoricTaskInstanceQuery() .taskId(taskId) .singleResult() - .getExecutionId(); + .getProcessInstanceId(); // 鏌ヨ鍘嗗彶娲诲姩瀹炰緥 List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery() - .executionId(executionId) + .processInstanceId(processInstanceId) .activityType("userTask") .finished() .orderByHistoricActivityInstanceEndTime() @@ -135,9 +137,28 @@ } @Override + public FlowMyBusiness getFlowMyBusiness(String instanceId, String taskId) { + List<FlowMyBusiness> businessList = super.list( + new QueryWrapper<FlowMyBusiness>().eq("process_instance_id", instanceId).eq("task_id", taskId)); + return businessList.isEmpty() ? null : businessList.get(0); + } + + @Override public FlowMyBusiness selectByDataId(String dataId) { List<FlowMyBusiness> businessList = super.list( new QueryWrapper<FlowMyBusiness>().eq("data_id", dataId)); return businessList.isEmpty() ? null : businessList.get(0); } + + @Override + public List<FlowMyBusiness> selectListByDataId(String dataId) { + //濡傛灉淇濆瓨鏁版嵁鍓嶆湭璋冪敤蹇呰皟鐨凢lowCommonService.initActBusiness鏂规硶锛屽氨浼氭湁闂 + LambdaQueryWrapper<FlowMyBusiness> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(FlowMyBusiness::getDataId, dataId); + List<FlowMyBusiness> list = flowMyBusinessMapper.selectList(queryWrapper); + if(CollectionUtils.isEmpty(list)){ + return Collections.emptyList(); + } + return list; + } } diff --git a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/controller/FlowTaskController.java b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/controller/FlowTaskController.java index f747af6..030a714 100644 --- a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/controller/FlowTaskController.java +++ b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/controller/FlowTaskController.java @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.flowable.domain.dto.FlowNextDto; import org.jeecg.modules.flowable.domain.dto.FlowTaskDto; import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; import org.jeecg.modules.flowable.service.IFlowTaskService; @@ -17,6 +18,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.List; /** * <p>宸ヤ綔娴佷换鍔$鐞�<p> @@ -154,7 +156,7 @@ @ApiOperation(value = "鑾峰彇涓嬩竴鑺傜偣") @PostMapping(value = "/nextFlowNode") - public Result getNextFlowNode(@RequestBody FlowTaskVo flowTaskVo) { + public Result<List<FlowNextDto>> getNextFlowNode(@RequestBody FlowTaskVo flowTaskVo) { return flowTaskService.getNextFlowNode(flowTaskVo); } diff --git a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/IFlowTaskService.java b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/IFlowTaskService.java index bb5278e..a79def8 100644 --- a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/IFlowTaskService.java +++ b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/IFlowTaskService.java @@ -3,6 +3,7 @@ import org.flowable.task.api.Task; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.flowable.apithird.business.dto.FlowMyBusinessDto; +import org.jeecg.modules.flowable.domain.dto.FlowNextDto; import org.jeecg.modules.flowable.domain.dto.FlowViewerDto; import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; @@ -180,9 +181,13 @@ * @param flowTaskVo 浠诲姟 * @return */ - Result getNextFlowNode(FlowTaskVo flowTaskVo); + Result<List<FlowNextDto>> getNextFlowNode(FlowTaskVo flowTaskVo); - - + /** + * 妫�鏌� 骞惰浠诲姟鑺傜偣鏄惁閮藉凡瀹屾垚 + * @param currentTaskId + * @return + */ + boolean checkParallelCompletion(String currentTaskId); } diff --git a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowDefinitionServiceImpl.java b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowDefinitionServiceImpl.java index bbb90bc..379cfdd 100644 --- a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowDefinitionServiceImpl.java +++ b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowDefinitionServiceImpl.java @@ -1,6 +1,8 @@ package org.jeecg.modules.flowable.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -44,7 +46,6 @@ /** * 娴佺▼瀹氫箟 - * */ @Service public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFlowDefinitionService { @@ -69,8 +70,8 @@ /** * 娴佺▼瀹氫箟鍒楄〃 * - * @param pageNum 褰撳墠椤电爜 - * @param pageSize 姣忛〉鏉℃暟 + * @param pageNum 褰撳墠椤电爜 + * @param pageSize 姣忛〉鏉℃暟 * @param flowProcDefDto * @return 娴佺▼瀹氫箟鍒嗛〉鍒楄〃鏁版嵁 */ @@ -83,19 +84,19 @@ //.processDefinitionId("cs:5:15e953ed-4d09-11ec-85b8-e884a5deddfc") .orderByProcessDefinitionKey().asc().orderByProcessDefinitionVersion().desc(); /*=====鍙傛暟=====*/ - if (StrUtil.isNotBlank(flowProcDefDto.getName())){ - processDefinitionQuery.processDefinitionNameLike("%"+flowProcDefDto.getName()+"%"); + if (StrUtil.isNotBlank(flowProcDefDto.getName())) { + processDefinitionQuery.processDefinitionNameLike("%" + flowProcDefDto.getName() + "%"); } - if (StrUtil.isNotBlank(flowProcDefDto.getCategory())){ + if (StrUtil.isNotBlank(flowProcDefDto.getCategory())) { processDefinitionQuery.processDefinitionCategory(flowProcDefDto.getCategory()); } - if (flowProcDefDto.getSuspensionState() == 1){ + if (flowProcDefDto.getSuspensionState() == 1) { processDefinitionQuery.active(); } - if (StrUtil.isNotBlank(flowProcDefDto.getKey())){ + if (StrUtil.isNotBlank(flowProcDefDto.getKey())) { processDefinitionQuery.processDefinitionKey(flowProcDefDto.getKey()); } - if (flowProcDefDto.getIsLastVersion() == 1){ + if (flowProcDefDto.getIsLastVersion() == 1) { processDefinitionQuery.latestVersion(); } /*============*/ @@ -149,7 +150,7 @@ @Override public Result readXmlByDataId(String dataId) throws IOException { LambdaQueryWrapper<FlowMyBusiness> flowMyBusinessLambdaQueryWrapper = new LambdaQueryWrapper<>(); - flowMyBusinessLambdaQueryWrapper.eq(FlowMyBusiness::getDataId,dataId) + flowMyBusinessLambdaQueryWrapper.eq(FlowMyBusiness::getDataId, dataId) ; //濡傛灉淇濆瓨鏁版嵁鍓嶆湭璋冪敤蹇呰皟鐨凢lowCommonService.initActBusiness鏂规硶锛屽氨浼氭湁闂 FlowMyBusiness business = flowMyBusinessService.getOne(flowMyBusinessLambdaQueryWrapper); @@ -201,6 +202,7 @@ InputStream in = processDiagramGenerator.generateDiagram(bpmnModel, "png", activityIds, flows, engConf.getActivityFontName(), engConf.getLabelFontName(), engConf.getAnnotationFontName(), engConf.getClassLoader(), 1.0, true); return in; } + /** * 璇诲彇xml * @@ -232,7 +234,7 @@ * 鏍规嵁娴佺▼瀹氫箟ID鍚姩娴佺▼瀹炰緥 * * @param procDefKey 娴佺▼瀹氫箟Id - * @param variables 娴佺▼鍙橀噺 + * @param variables 娴佺▼鍙橀噺 * @return */ @Override @@ -241,9 +243,10 @@ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey(procDefKey) .latestVersion().singleResult(); - Result result = startProcessInstanceById(processDefinition.getId(),variables); + Result result = startProcessInstanceById(processDefinition.getId(), variables); return result; } + /** * 鏍规嵁娴佺▼瀹氫箟ID鍚姩娴佺▼瀹炰緥 * @@ -254,28 +257,28 @@ @Override @Transactional public Result<?> startProcessInstanceById(String procDefId, Map<String, Object> variables) { - ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() - .processDefinitionId(procDefId) - .singleResult(); - if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) { - return Result.error("娴佺▼宸茶鎸傝捣,璇峰厛婵�娲绘祦绋�"); - } + ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() + .processDefinitionId(procDefId) + .singleResult(); + if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) { + return Result.error("娴佺▼宸茶鎸傝捣,璇峰厛婵�娲绘祦绋�"); + } // variables.put("skip", true); // variables.put(ProcessConstants.FLOWABLE_SKIP_EXPRESSION_ENABLED, true); - // 璁剧疆娴佺▼鍙戣捣浜篒d鍒版祦绋嬩腑 - SysUser sysUser = iFlowThirdService.getLoginUser(); - identityService.setAuthenticatedUserId(sysUser.getUsername()); - variables.put(ProcessConstants.PROCESS_INITIATOR, sysUser.getUsername()); - ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); - // 缁欑涓�姝ョ敵璇蜂汉鑺傜偣璁剧疆浠诲姟鎵ц浜哄拰鎰忚 - Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult(); - if (Objects.nonNull(task)) { - taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), variables.get("organization").toString()); - taskService.setAssignee(task.getId(), sysUser.getUsername()); - task.setDescription(variables.get("organization").toString()); - //taskService.complete(task.getId(), variables); - } - //璁剧疆鎵�鏈夌敵璇蜂汉 + // 璁剧疆娴佺▼鍙戣捣浜篒d鍒版祦绋嬩腑 + SysUser sysUser = iFlowThirdService.getLoginUser(); + identityService.setAuthenticatedUserId(sysUser.getUsername()); + variables.put(ProcessConstants.PROCESS_INITIATOR, sysUser.getUsername()); + ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); + // 缁欑涓�姝ョ敵璇蜂汉鑺傜偣璁剧疆浠诲姟鎵ц浜哄拰鎰忚 + Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult(); + if (Objects.nonNull(task)) { + taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), variables.get("organization").toString()); + taskService.setAssignee(task.getId(), sysUser.getUsername()); + task.setDescription(variables.get("organization").toString()); + //taskService.complete(task.getId(), variables); + } + //璁剧疆鎵�鏈夌敵璇蜂汉 /*======================todo 鍚姩涔嬪悗 鍥炶皟浠ュ強鍏抽敭鏁版嵁淇濆瓨======================*/ //涓氬姟鏁版嵁id @@ -283,77 +286,146 @@ //濡傛灉淇濆瓨鏁版嵁鍓嶆湭璋冪敤蹇呰皟鐨凢lowCommonService.initActBusiness鏂规硶锛屽氨浼氭湁闂 FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId); //璁剧疆鏁版嵁 - FlowNextDto nextFlowNode = flowTaskService.getNextFlowNode(task.getId(), variables); + List<FlowNextDto> nextFlowNodeList = flowTaskService.getNextFlowNode(task.getId(), variables); taskService.complete(task.getId(), variables); //涓嬩竴涓疄渚嬭妭鐐� 澶氬疄渚嬩細鏄竴涓猯ist,闅忔剰鍙栦竴涓嵆鍙� 鏁扮粍涓畾涔塊ey鏄竴鑷寸殑 //Task task2 = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult(); List<Task> task2List = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().list(); - Task task2 = null; - if(task2List.size()>0) task2 = task2List.get(0); String doneUsers = business.getDoneUsers(); // 澶勭悊杩囨祦绋嬬殑浜� JSONArray doneUserList = new JSONArray(); - if (StrUtil.isNotBlank(doneUsers)){ + if (StrUtil.isNotBlank(doneUsers)) { doneUserList = JSON.parseArray(doneUsers); } - if (!doneUserList.contains(sysUser.getUsername())){ + if (!doneUserList.contains(sysUser.getUsername())) { doneUserList.add(sysUser.getUsername()); } - if (nextFlowNode!=null){ - //**鏈変笅涓�涓妭鐐� - UserTask nextTask = nextFlowNode.getUserTask(); - //鑳藉澶勭悊涓嬩釜鑺傜偣鐨勫�欓�変汉 - List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList(); - - List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList()); - //spring瀹瑰櫒绫诲悕 - String serviceImplName = business.getServiceImplName(); - FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); - List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), variables); - business.setProcessDefinitionId(procDefId) - .setProcessInstanceId(processInstance.getProcessInstanceId()) -//// .setActStatus(ActStatus.start) - .setProposer(sysUser.getUsername()) - .setTaskId(task2.getId()) - .setTaskName(nextTask.getName()) - .setTaskNameId(nextTask.getId()) - .setPriority(nextTask.getPriority()) - .setDoneUsers(doneUserList.toJSONString()); - if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){ - // 鍒犻櫎鍚庨噸鍐� - for (Task task2One : task2List) { - for (String oldUser : collect_username) { - taskService.deleteCandidateUser(task2One.getId(),oldUser); - } - } - // 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� - for (Task task2One : task2List) { - for (String newUser : beforeParamsCandidateUsernames) { - taskService.addCandidateUser(task2One.getId(),newUser); - } - } - business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); - }else { - // 涓氬姟灞傛病鏈夋寚瀹氬�欓�変汉锛岀洿鎺ヨ鐩� - business.setTodoUsers(JSON.toJSONString(collect_username)); - } - } else { - // **娌℃湁涓嬩竴涓妭鐐癸紝娴佺▼宸茬粡缁撴潫浜� + if (CollectionUtil.isEmpty(nextFlowNodeList)) { + // **娌℃湁涓嬩竴涓妭鐐癸紝娴佺▼宸茬粡缁撴潫浜� business.setProcessDefinitionId(procDefId) .setProcessInstanceId(processInstance.getProcessInstanceId()) // .setActStatus(ActStatus.pass) .setProposer(sysUser.getUsername()) .setDoneUsers(doneUserList.toJSONString()) ; + flowMyBusinessService.updateById(business); + } else if (nextFlowNodeList.size() == 1) { + //涓嬩釜鑺傜偣鍙湁涓�涓� + FlowNextDto nextFlowNode = nextFlowNodeList.get(0); + UserTask nextTask = nextFlowNode.getUserTask(); + Task task2 = null; + Optional<Task> first = task2List.stream().filter(t -> t.getTaskDefinitionKey().equals(nextTask.getId())).findFirst(); + if (first.isPresent()) { + task2 = first.get(); + } + if (task2 != null) { + //鑳藉澶勭悊涓嬩釜鑺傜偣鐨勫�欓�変汉 + List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList(); + + List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList()); + //spring瀹瑰櫒绫诲悕 + String serviceImplName = business.getServiceImplName(); + FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); + List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionId(), variables); + business.setProcessDefinitionId(procDefId) + .setProcessInstanceId(processInstance.getProcessInstanceId()) +//// .setActStatus(ActStatus.start) + .setProposer(sysUser.getUsername()) + .setTaskId(task2.getId()) + .setTaskName(nextTask.getName()) + .setTaskNameId(nextTask.getId()) + .setPriority(nextTask.getPriority()) + .setDoneUsers(doneUserList.toJSONString()); + if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { + // 鍒犻櫎鍚庨噸鍐� + for (String oldUser : collect_username) { + taskService.deleteCandidateUser(task2.getId(), oldUser); + } + // 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� + for (String newUser : beforeParamsCandidateUsernames) { + taskService.addCandidateUser(task2.getId(), newUser); + } + business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); + } else { + // 涓氬姟灞傛病鏈夋寚瀹氬�欓�変汉锛岀洿鎺ヨ鐩� + business.setTodoUsers(JSON.toJSONString(collect_username)); + } + flowMyBusinessService.updateById(business); + } + } else { + for (FlowNextDto nextFlowNode : nextFlowNodeList) { + //**鏈変笅涓�涓妭鐐� + UserTask nextTask = nextFlowNode.getUserTask(); + Task task2 = null; + Optional<Task> first = task2List.stream().filter(t -> t.getTaskDefinitionKey().equals(nextTask.getId())).findFirst(); + if (first.isPresent()) { + task2 = first.get(); + } + if (task2 != null) { + //鏂扮殑涓氬姟娴佺▼鑺傜偣 + FlowMyBusiness newBusiness = BeanUtil.copyProperties(business, FlowMyBusiness.class, "id"); + //鑳藉澶勭悊涓嬩釜鑺傜偣鐨勫�欓�変汉 + List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList(); + + List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList()); + //spring瀹瑰櫒绫诲悕 + String serviceImplName = newBusiness.getServiceImplName(); + FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); + List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionId(), variables); + newBusiness.setProcessDefinitionId(procDefId) + .setProcessInstanceId(processInstance.getProcessInstanceId()) +//// .setActStatus(ActStatus.start) + .setProposer(sysUser.getUsername()) + .setTaskId(task2.getId()) + .setTaskName(nextTask.getName()) + .setTaskNameId(nextTask.getId()) + .setPriority(nextTask.getPriority()) + .setDoneUsers(doneUserList.toJSONString()); + if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { + // 鍒犻櫎鍚庨噸鍐� + for (Task task2One : task2List) { + for (String oldUser : beforeParamsCandidateUsernames) { + taskService.deleteCandidateUser(task2One.getId(), oldUser); + } + } + // 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� + for (Task task2One : task2List) { + for (String newUser : beforeParamsCandidateUsernames) { + taskService.addCandidateUser(task2One.getId(), newUser); + } + } + newBusiness.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); + } else { + // 涓氬姟灞傛病鏈夋寚瀹氬�欓�変汉锛岀洿鎺ヨ鐩� + newBusiness.setTodoUsers(JSON.toJSONString(collect_username)); + // 鍒犻櫎鍚庨噸鍐� + for (Task task2One : task2List) { + for (String oldUser : collect_username) { + taskService.deleteCandidateUser(task2One.getId(), oldUser); + } + } + // 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� + for (Task task2One : task2List) { + for (String newUser : collect_username) { + taskService.addCandidateUser(task2One.getId(), newUser); + } + } + } + flowMyBusinessService.save(newBusiness); + } + } + //鍒犻櫎鍘熸湁鐨勪笟鍔℃暟鎹� + flowMyBusinessService.removeById(business.getId()); } - flowMyBusinessService.updateById(business); //spring瀹瑰櫒绫诲悕 String serviceImplName = business.getServiceImplName(); FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); // 娴佺▼澶勭悊瀹屽悗锛岃繘琛屽洖璋冧笟鍔″眰 business.setValues(variables); - if (flowCallBackService!=null)flowCallBackService.afterFlowHandle(business); + if (flowCallBackService != null) { + flowCallBackService.afterFlowHandle(business); + } return Result.OK("娴佺▼鍚姩鎴愬姛"); } @@ -363,13 +435,13 @@ flowMyBusinessLambdaQueryWrapper.eq(FlowMyBusiness::getDataId, dataId) ; FlowMyBusiness business = flowMyBusinessService.getOne(flowMyBusinessLambdaQueryWrapper); - if (business==null){ - return Result.error("鏈壘鍒癲ataId锛�"+dataId); + if (business == null) { + return Result.error("鏈壘鍒癲ataId锛�" + dataId); } - if (StrUtil.isNotBlank(business.getProcessDefinitionId())){ - return this.startProcessInstanceById(business.getProcessDefinitionId(),variables); + if (StrUtil.isNotBlank(business.getProcessDefinitionId())) { + return this.startProcessInstanceById(business.getProcessDefinitionId(), variables); } - return this.startProcessInstanceByKey(business.getProcessDefinitionKey(),variables); + return this.startProcessInstanceByKey(business.getProcessDefinitionKey(), variables); } diff --git a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java index 6b715e9..78a241f 100644 --- a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java +++ b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java @@ -1,5 +1,6 @@ package org.jeecg.modules.flowable.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; @@ -68,6 +69,7 @@ import java.util.stream.Collectors; /** + * **/ @Service @Slf4j @@ -78,6 +80,7 @@ private IFlowThirdService iFlowThirdService; @Autowired FlowMyBusinessServiceImpl flowMyBusinessService; + /** * 瀹屾垚浠诲姟 * @@ -87,23 +90,23 @@ @Override public Result complete(FlowTaskVo taskVo) { Task task = taskService.createTaskQuery().taskId(taskVo.getTaskId()).singleResult(); - if (Objects.isNull(task)){ + if (Objects.isNull(task)) { return Result.error("浠诲姟涓嶅瓨鍦�"); } - if(StringUtils.isNotEmpty(taskVo.getComment())){ + if (StringUtils.isNotEmpty(taskVo.getComment())) { task.setDescription(taskVo.getComment()); taskService.saveTask(task); } SysUser loginUser = iFlowThirdService.getLoginUser(); //鍒ゆ柇鐢ㄦ埛鏄惁鏈夋潈闄� - if (!task.getAssignee().equals(loginUser.getUsername())){ + if (!task.getAssignee().equals(loginUser.getUsername())) { return Result.error("褰撳墠鐢ㄦ埛鏃犳潈闄�"); } if (DelegationState.PENDING.equals(task.getDelegationState())) { taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.DELEGATE.getType(), taskVo.getComment()); //taskService.resolveTask(taskVo.getTaskId(), taskVo.getValues()); } else { - System.out.println("taskVo.getTaskId()--->taskVo.getInstanceId()--->FlowComment.NORMAL.getType()--->taskVo.getComment()"+taskVo.getTaskId() + "---" + taskVo.getInstanceId() + "---" + FlowComment.NORMAL.getType() + "---"+taskVo.getComment() ); + System.out.println("taskVo.getTaskId()--->taskVo.getInstanceId()--->FlowComment.NORMAL.getType()--->taskVo.getComment()" + taskVo.getTaskId() + "---" + taskVo.getInstanceId() + "---" + FlowComment.NORMAL.getType() + "---" + taskVo.getComment()); taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), taskVo.getComment()); taskService.setAssignee(taskVo.getTaskId(), loginUser.getUsername()); } @@ -111,20 +114,22 @@ //涓氬姟鏁版嵁id String dataId = taskVo.getDataId(); //濡傛灉淇濆瓨鏁版嵁鍓嶆湭璋冪敤蹇呰皟鐨凢lowCommonService.initActBusiness鏂规硶锛屽氨浼氭湁闂 - FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId); + FlowMyBusiness business = flowMyBusinessService.getFlowMyBusiness(taskVo.getInstanceId(), taskVo.getTaskId()); //spring瀹瑰櫒绫诲悕 String serviceImplName = business.getServiceImplName(); FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); // 娴佺▼鍙橀噺 - Map<String, Object> flowBeforeParamsValues = flowCallBackService.flowValuesOfTask(business.getTaskNameId(),taskVo.getValues()); + Map<String, Object> flowBeforeParamsValues = flowCallBackService.flowValuesOfTask(business.getTaskNameId(), taskVo.getValues()); //璁剧疆鏁版嵁 Map<String, Object> values = taskVo.getValues(); - if (MapUtil.isNotEmpty(flowBeforeParamsValues)){ - // 涓氬姟灞傛湁璁剧疆鍙橀噺锛屼娇鐢ㄤ笟鍔″眰鐨勫彉閲� + if (MapUtil.isNotEmpty(flowBeforeParamsValues)) { + // 涓氬姟灞傛湁璁剧疆鍙橀噺锛屼娇鐢ㄤ笟鍔″眰鐨勫彉閲� values = flowBeforeParamsValues; } - FlowNextDto nextFlowNode = this.getNextFlowNode(task.getId(), values); + + //骞惰缃戝叧 澶氫换鍔� + List<FlowNextDto> nextFlowNodeList = this.getNextFlowNode(task.getId(), values); //涓嬩竴涓疄渚嬭妭鐐� if (DelegationState.PENDING.equals(task.getDelegationState())) { taskService.resolveTask(taskVo.getTaskId(), values); @@ -132,140 +137,218 @@ taskService.complete(taskVo.getTaskId(), values); } List<Task> task2List = taskService.createTaskQuery().processInstanceId(business.getProcessInstanceId()).active().list(); - Task task2 = null; - if (CollUtil.isNotEmpty(task2List)){ - task2 = task2List.get(0); - } - - // 涓嬩釜鑺傜偣鍊欓�変汉 - List<String> beforeParamsCandidateUsernames = Lists.newArrayList(); - if(task2!=null){ - beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(),taskVo.getValues()); - } - List<String> candidateUsers = taskVo.getCandidateUsers(); - if (CollUtil.isNotEmpty(candidateUsers)){ - // 鍓嶇浼犲叆鍊欓�変汉 瑕嗙洊 - beforeParamsCandidateUsernames = candidateUsers; - } String doneUsers = business.getDoneUsers(); // 澶勭悊杩囨祦绋嬬殑浜� JSONArray doneUserList = new JSONArray(); - if (StrUtil.isNotBlank(doneUsers)){ + if (StrUtil.isNotBlank(doneUsers)) { doneUserList = JSON.parseArray(doneUsers); } - if (!doneUserList.contains(loginUser.getUsername())){ + if (!doneUserList.contains(loginUser.getUsername())) { doneUserList.add(loginUser.getUsername()); } - if (task2!=null && task.getTaskDefinitionKey().equals(task2.getTaskDefinitionKey())){ - // * 褰撳墠鑺傜偣鏄細绛捐妭鐐癸紝娌℃湁璧板畬 - business.setTaskId(task2.getId()) -// .setActStatus(ActStatus.doing) + if (CollectionUtils.isEmpty(nextFlowNodeList)) { + // **娌℃湁涓嬩竴涓妭鐐癸紝娴佺▼宸茬粡缁撴潫浜� + business .setDoneUsers(doneUserList.toJSONString()) + .setTodoUsers("") + .setTaskId("") + .setTaskNameId("") + .setTaskName("") ; - String todoUsersStr = business.getTodoUsers(); - JSONArray todosArr = JSON.parseArray(todoUsersStr); - // 鍒犻櫎鍚庨噸鍐� - for (Task task2One : task2List) { - for (Object oldUser : todosArr) { - taskService.deleteCandidateUser(task2One.getId(),oldUser.toString()); + flowMyBusinessService.updateById(business); + } + else if (nextFlowNodeList.size() == 1) { + FlowNextDto nextFlowNode = nextFlowNodeList.get(0); + UserTask nextTask = nextFlowNode.getUserTask(); + Task task2 = null; + Optional<Task> first = task2List.stream().filter(t -> t.getTaskDefinitionKey().equals(nextTask.getId())).findFirst(); + task2 = first.orElseGet(() -> task2List.get(0)); + if (task2 != null) { + // 涓嬩釜鑺傜偣鍊欓�変汉 + List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), taskVo.getValues()); + List<String> candidateUsers = taskVo.getCandidateUsers(); + if (CollUtil.isNotEmpty(candidateUsers)) { + // 鍓嶇浼犲叆鍊欓�変汉 瑕嗙洊 + beforeParamsCandidateUsernames = candidateUsers; } - } - // 閲嶅啓 - if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){ - beforeParamsCandidateUsernames.remove(loginUser.getUsername()); - // 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� - for (Task task2One : task2List) { - for (String newUser : beforeParamsCandidateUsernames) { - taskService.addCandidateUser(task2One.getId(),newUser); - } - } - business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); - } else { - todosArr.remove(loginUser.getUsername()); - for (Task task2One : task2List) { + if (task.getTaskDefinitionKey().equals(task2.getTaskDefinitionKey())) { + //澶氬疄渚� 浼氱 TODO + // * 褰撳墠鑺傜偣鏄細绛捐妭鐐癸紝娌℃湁璧板畬 + business.setTaskId(task2.getId()) +// .setActStatus(ActStatus.doing) + .setDoneUsers(doneUserList.toJSONString()) + ; + String todoUsersStr = business.getTodoUsers(); + JSONArray todosArr = JSON.parseArray(todoUsersStr); + // 鍒犻櫎鍚庨噸鍐� for (Object oldUser : todosArr) { - taskService.addCandidateUser(task2One.getId(),oldUser.toString()); + taskService.deleteCandidateUser(task2.getId(), oldUser.toString()); + } + // 閲嶅啓 + if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { + beforeParamsCandidateUsernames.remove(loginUser.getUsername()); + // 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� + for (String newUser : beforeParamsCandidateUsernames) { + taskService.addCandidateUser(task2.getId(), newUser); + } + business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); + } else { + todosArr.remove(loginUser.getUsername()); + for (Object oldUser : todosArr) { + taskService.addCandidateUser(task2.getId(), oldUser.toString()); + } + business.setTodoUsers(todosArr.toJSONString()); + } + + } else { + //鑳藉澶勭悊涓嬩釜鑺傜偣鐨勫�欓�変汉 + List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList(); + List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(candidateUsers)) { + // 鍓嶇浼犲叆鍊欓�変汉 + collect_username = candidateUsers; + } + business + .setTaskId(task2.getId()) +// .setActStatus(ActStatus.doing) + .setTaskNameId(nextTask.getId()) + .setTaskName(nextTask.getName()) + .setPriority(nextTask.getPriority()) + .setDoneUsers(doneUserList.toJSONString()) + .setTodoUsers(JSON.toJSONString(collect_username)) + ; + // 鍒犻櫎鍚庨噸鍐� + for (String oldUser : collect_username) { + taskService.deleteCandidateUser(task2.getId(), oldUser); + } + if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { + // 鍓嶇娌℃湁浼犲叆鍊欓�変汉 && 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� + for (String newUser : beforeParamsCandidateUsernames) { + taskService.addCandidateUser(task2.getId(), newUser); + } + business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); + } else { + for (String oldUser : collect_username) { + taskService.addCandidateUser(task2.getId(), oldUser); + } + business.setTodoUsers(JSON.toJSONString(collect_username)); } } - business.setTodoUsers(todosArr.toJSONString()); } - - - } else { - // * 涓嬩竴鑺傜偣鏄細绛捐妭鐐� 鎴� 鏅�氱敤鎴疯妭鐐癸紝閫昏緫涓�鑷� - if (nextFlowNode!=null){ + flowMyBusinessService.updateById(business); + } + else { + for(FlowNextDto nextFlowNode : nextFlowNodeList) { //**鏈変笅涓�涓妭鐐� UserTask nextTask = nextFlowNode.getUserTask(); - //鑳藉澶勭悊涓嬩釜鑺傜偣鐨勫�欓�変汉 - List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList(); - List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(candidateUsers)){ - // 鍓嶇浼犲叆鍊欓�変汉 - collect_username = candidateUsers; + Task task2 = null; + Optional<Task> first = task2List.stream().filter(t -> t.getTaskDefinitionKey().equals(nextTask.getId())).findFirst(); + if (first.isPresent()) { + task2 = first.get(); } - business - .setTaskId(task2.getId()) -// .setActStatus(ActStatus.doing) - .setTaskNameId(nextTask.getId()) - .setTaskName(nextTask.getName()) - .setPriority(nextTask.getPriority()) - .setDoneUsers(doneUserList.toJSONString()) - .setTodoUsers(JSON.toJSONString(collect_username)) - ; - // 鍒犻櫎鍚庨噸鍐� - for (Task task2One : task2List) { - for (String oldUser : collect_username) { - taskService.deleteCandidateUser(task2One.getId(),oldUser); + if (task2 != null) { + //鏂扮殑涓氬姟娴佺▼鑺傜偣 + FlowMyBusiness newBusiness = BeanUtil.copyProperties(business, FlowMyBusiness.class, "id"); + // 涓嬩釜鑺傜偣鍊欓�変汉 + List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), taskVo.getValues()); + List<String> candidateUsers = taskVo.getCandidateUsers(); + if (CollUtil.isNotEmpty(candidateUsers)) { + // 鍓嶇浼犲叆鍊欓�変汉 瑕嗙洊 + beforeParamsCandidateUsernames = candidateUsers; } - } - if (CollUtil.isEmpty(candidateUsers)&&CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){ - // 鍓嶇娌℃湁浼犲叆鍊欓�変汉 && 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� - for (Task task2One : task2List) { - for (String newUser : beforeParamsCandidateUsernames) { - taskService.addCandidateUser(task2One.getId(),newUser); + if (task.getTaskDefinitionKey().equals(task2.getTaskDefinitionKey())) { + //澶氬疄渚� 浼氱 TODO + // * 褰撳墠鑺傜偣鏄細绛捐妭鐐癸紝娌℃湁璧板畬 + newBusiness.setTaskId(task2.getId()) +// .setActStatus(ActStatus.doing) + .setDoneUsers(doneUserList.toJSONString()) + ; + String todoUsersStr = business.getTodoUsers(); + JSONArray todosArr = JSON.parseArray(todoUsersStr); + // 鍒犻櫎鍚庨噸鍐� + for (Object oldUser : todosArr) { + taskService.deleteCandidateUser(task2.getId(), oldUser.toString()); } - } - business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); - } else { - for (Task task2One : task2List) { - for (String oldUser : collect_username) { - taskService.addCandidateUser(task2One.getId(),oldUser); + // 閲嶅啓 + if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { + beforeParamsCandidateUsernames.remove(loginUser.getUsername()); + // 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� + for (String newUser : beforeParamsCandidateUsernames) { + taskService.addCandidateUser(task2.getId(), newUser); + } + newBusiness.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); + } else { + todosArr.remove(loginUser.getUsername()); + for (Object oldUser : todosArr) { + taskService.addCandidateUser(task2.getId(), oldUser.toString()); + } + newBusiness.setTodoUsers(todosArr.toJSONString()); } - } - } - } else { - // **娌℃湁涓嬩竴涓妭鐐癸紝娴佺▼宸茬粡缁撴潫浜� - business - .setDoneUsers(doneUserList.toJSONString()) - .setTodoUsers("") - .setTaskId("") - .setTaskNameId("") - .setTaskName("") - ; + } else { + //鑳藉澶勭悊涓嬩釜鑺傜偣鐨勫�欓�変汉 + List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList(); + List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(candidateUsers)) { + // 鍓嶇浼犲叆鍊欓�変汉 + collect_username = candidateUsers; + } + newBusiness + .setTaskId(task2.getId()) +// .setActStatus(ActStatus.doing) + .setTaskNameId(nextTask.getId()) + .setTaskName(nextTask.getName()) + .setPriority(nextTask.getPriority()) + .setDoneUsers(doneUserList.toJSONString()) + .setTodoUsers(JSON.toJSONString(collect_username)) + ; + // 鍒犻櫎鍚庨噸鍐� + for (String oldUser : collect_username) { + taskService.deleteCandidateUser(task2.getId(), oldUser); + } + if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { + // 鍓嶇娌℃湁浼犲叆鍊欓�変汉 && 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� + for (String newUser : beforeParamsCandidateUsernames) { + taskService.addCandidateUser(task2.getId(), newUser); + } + newBusiness.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); + } else { + for (String oldUser : collect_username) { + taskService.addCandidateUser(task2.getId(), oldUser); + } + newBusiness.setTodoUsers(JSON.toJSONString(collect_username)); + } + } + flowMyBusinessService.save(newBusiness); + } + flowMyBusinessService.updateById(business); } + //鍒犻櫎鍘熸湁鐨勪笟鍔℃暟鎹� + flowMyBusinessService.removeById(business.getId()); } - flowMyBusinessService.updateById(business); // 娴佺▼澶勭悊瀹屽悗锛岃繘琛屽洖璋冧笟鍔″眰 business.setValues(values); - if (flowCallBackService!=null)flowCallBackService.afterFlowHandle(business); + if (flowCallBackService != null) { + flowCallBackService.afterFlowHandle(business); + } return Result.OK(); } @Override @Transactional(rollbackFor = Exception.class) - public Result completeByDateId(FlowTaskVo flowTaskVo){ + public Result completeByDateId(FlowTaskVo flowTaskVo) { return this.complete(flowTaskVo); } @Override - public void taskRejectByDataId(FlowTaskVo flowTaskVo){ + public void taskRejectByDataId(FlowTaskVo flowTaskVo) { FlowMyBusiness business = flowMyBusinessService.getByDataId(flowTaskVo.getDataId()); flowTaskVo.setTaskId(business.getTaskId()); this.taskReject(flowTaskVo); } + /** * 椹冲洖浠诲姟 * @@ -387,7 +470,7 @@ /*======================椹冲洖 鍥炶皟浠ュ強鍏抽敭鏁版嵁淇濆瓨======================*/ //涓氬姟鏁版嵁id String dataId = flowTaskVo.getDataId(); - if (dataId==null) return; + if (dataId == null) return; //濡傛灉淇濆瓨鏁版嵁鍓嶆湭璋冪敤蹇呰皟鐨凢lowCommonService.initActBusiness鏂规硶锛屽氨浼氭湁闂 FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId); // 椹冲洖鍒颁簡涓婁竴涓妭鐐圭瓑寰呭鐞� @@ -397,21 +480,21 @@ String serviceImplName = business.getServiceImplName(); FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); Map<String, Object> values = flowTaskVo.getValues(); - if (values ==null){ + if (values == null) { values = MapUtil.newHashMap(); - values.put("dataId",dataId); + values.put("dataId", dataId); } else { - values.put("dataId",dataId); + values.put("dataId", dataId); } List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), values); //璁剧疆鏁版嵁 String doneUsers = business.getDoneUsers(); // 澶勭悊杩囨祦绋嬬殑浜� JSONArray doneUserList = new JSONArray(); - if (StrUtil.isNotBlank(doneUsers)){ + if (StrUtil.isNotBlank(doneUsers)) { doneUserList = JSON.parseArray(doneUsers); } - if (!doneUserList.contains(loginUser.getUsername())){ + if (!doneUserList.contains(loginUser.getUsername())) { doneUserList.add(loginUser.getUsername()); } business @@ -432,31 +515,31 @@ } } - if (targetElement!=null){ + if (targetElement != null) { UserTask targetTask = (UserTask) targetElement; business.setPriority(targetTask.getPriority()); - if (StrUtil.equals(business.getTaskNameId(),ProcessConstants.START_NODE)){ + if (StrUtil.equals(business.getTaskNameId(), ProcessConstants.START_NODE)) { // 寮�濮嬭妭鐐广�傝缃鐞嗕汉涓虹敵璇蜂汉 business.setTodoUsers(JSON.toJSONString(Lists.newArrayList(business.getProposer()))); - taskService.setAssignee(business.getTaskId(),business.getProposer()); + taskService.setAssignee(business.getTaskId(), business.getProposer()); } else { List<SysUser> sysUserFromTask = getSysUserFromTask(targetTask); List<String> collect_username = sysUserFromTask.stream().map(SysUser::getUsername).collect(Collectors.toList()); // 鍓嶇瀛樺叆鐨勫�欓�変汉 List<String> candidateUsers = flowTaskVo.getCandidateUsers(); - if (CollUtil.isNotEmpty(candidateUsers)){ + if (CollUtil.isNotEmpty(candidateUsers)) { collect_username = candidateUsers; } business.setTodoUsers(JSON.toJSONString(collect_username)); // 鍒犻櫎鍚庨噸鍐� for (Task task2One : task2List) { for (String oldUser : collect_username) { - taskService.deleteCandidateUser(task2One.getId(),oldUser); + taskService.deleteCandidateUser(task2One.getId(), oldUser); } } - if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){ - if (CollUtil.isNotEmpty(candidateUsers)){ + if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { + if (CollUtil.isNotEmpty(candidateUsers)) { beforeParamsCandidateUsernames = candidateUsers; } // 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� @@ -477,9 +560,9 @@ } flowMyBusinessService.updateById(business); - // 娴佺▼澶勭悊瀹屽悗锛岃繘琛屽洖璋冧笟鍔″眰 + // 娴佺▼澶勭悊瀹屽悗锛岃繘琛屽洖璋冧笟鍔″眰 business.setValues(values); - if (flowCallBackService!=null) flowCallBackService.afterFlowHandle(business); + if (flowCallBackService != null) flowCallBackService.afterFlowHandle(business); } catch (FlowableObjectNotFoundException e) { throw new CustomException("鏈壘鍒版祦绋嬪疄渚嬶紝娴佺▼鍙兘宸插彂鐢熷彉鍖�"); } catch (FlowableException e) { @@ -487,13 +570,15 @@ } } + @Override - public void taskReturnByDataId(FlowTaskVo flowTaskVo){ + public void taskReturnByDataId(FlowTaskVo flowTaskVo) { //濡傛灉淇濆瓨鏁版嵁鍓嶆湭璋冪敤蹇呰皟鐨凢lowCommonService.initActBusiness鏂规硶锛屽氨浼氭湁闂 FlowMyBusiness business = flowMyBusinessService.getByDataId(flowTaskVo.getDataId()); flowTaskVo.setTaskId(business.getTaskId()); taskReturn(flowTaskVo); } + /** * 閫�鍥炰换鍔� * @@ -574,7 +659,7 @@ /*======================閫�鍥� 鍥炶皟浠ュ強鍏抽敭鏁版嵁淇濆瓨======================*/ //涓氬姟鏁版嵁id String dataId = flowTaskVo.getDataId(); - if (dataId==null) return; + if (dataId == null) return; //濡傛灉淇濆瓨鏁版嵁鍓嶆湭璋冪敤蹇呰皟鐨凢lowCommonService.initActBusiness鏂规硶锛屽氨浼氭湁闂 FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId); //spring瀹瑰櫒绫诲悕 @@ -584,61 +669,61 @@ String doneUsers = business.getDoneUsers(); // 澶勭悊杩囨祦绋嬬殑浜� JSONArray doneUserList = new JSONArray(); - if (StrUtil.isNotBlank(doneUsers)){ + if (StrUtil.isNotBlank(doneUsers)) { doneUserList = JSON.parseArray(doneUsers); } - if (!doneUserList.contains(loginUser.getUsername())){ + if (!doneUserList.contains(loginUser.getUsername())) { doneUserList.add(loginUser.getUsername()); } - //**璺宠浆鍒扮洰鏍囪妭鐐� + //**璺宠浆鍒扮洰鏍囪妭鐐� List<Task> task2List = taskService.createTaskQuery().processInstanceId(business.getProcessInstanceId()).active().list(); Task targetTask = task2List.get(0); - business - .setTaskId(targetTask.getId()) + business + .setTaskId(targetTask.getId()) // .setActStatus(ActStatus.reject) - .setTaskNameId(targetTask.getTaskDefinitionKey()) - .setTaskName(targetTask.getName()) - .setPriority(targetTask.getPriority()+"") - .setDoneUsers(doneUserList.toJSONString()) - ; - if (target!=null){ + .setTaskNameId(targetTask.getTaskDefinitionKey()) + .setTaskName(targetTask.getName()) + .setPriority(targetTask.getPriority() + "") + .setDoneUsers(doneUserList.toJSONString()) + ; + if (target != null) { UserTask target2 = (UserTask) target; business.setPriority(target2.getPriority()); - if (StrUtil.equals(business.getTaskNameId(),ProcessConstants.START_NODE)){ - // 寮�濮嬭妭鐐广�傝缃鐞嗕汉涓虹敵璇蜂汉 + if (StrUtil.equals(business.getTaskNameId(), ProcessConstants.START_NODE)) { + // 寮�濮嬭妭鐐广�傝缃鐞嗕汉涓虹敵璇蜂汉 business.setTodoUsers(JSON.toJSONString(Lists.newArrayList(business.getProposer()))); - taskService.setAssignee(business.getTaskId(),business.getProposer()); + taskService.setAssignee(business.getTaskId(), business.getProposer()); } else { List<SysUser> sysUserFromTask = getSysUserFromTask(target2); List<String> collect_username = sysUserFromTask.stream().map(SysUser::getUsername).collect(Collectors.toList()); List<String> candidateUsers = flowTaskVo.getCandidateUsers(); - if (CollUtil.isNotEmpty(candidateUsers)){ + if (CollUtil.isNotEmpty(candidateUsers)) { collect_username = candidateUsers; } business.setTodoUsers(JSON.toJSONString(collect_username)); // 鍒犻櫎鍚庨噸鍐� for (Task task2One : task2List) { for (String oldUser : collect_username) { - taskService.deleteCandidateUser(task2One.getId(),oldUser); + taskService.deleteCandidateUser(task2One.getId(), oldUser); } } Map<String, Object> values = flowTaskVo.getValues(); - if (values==null){ + if (values == null) { values = MapUtil.newHashMap(); - values.put("dataId",dataId); + values.put("dataId", dataId); } else { - values.put("dataId",dataId); + values.put("dataId", dataId); } List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(targetTask.getTaskDefinitionKey(), values); - if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){ - if (CollUtil.isNotEmpty(candidateUsers)){ + if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { + if (CollUtil.isNotEmpty(candidateUsers)) { beforeParamsCandidateUsernames = candidateUsers; } // 涓氬姟灞傛湁鎸囧畾鍊欓�変汉锛岃鐩� for (Task task2One : task2List) { for (String newUser : beforeParamsCandidateUsernames) { - taskService.addCandidateUser(task2One.getId(),newUser); + taskService.addCandidateUser(task2One.getId(), newUser); } } business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); @@ -654,7 +739,7 @@ flowMyBusinessService.updateById(business); // 娴佺▼澶勭悊瀹屽悗锛岃繘琛屽洖璋冧笟鍔″眰 business.setValues(flowTaskVo.getValues()); - if (flowCallBackService!=null) flowCallBackService.afterFlowHandle(business); + if (flowCallBackService != null) flowCallBackService.afterFlowHandle(business); } catch (FlowableObjectNotFoundException e) { throw new CustomException("鏈壘鍒版祦绋嬪疄渚嬶紝娴佺▼鍙兘宸插彂鐢熷彉鍖�"); } catch (FlowableException e) { @@ -671,15 +756,16 @@ /** * 缁撴潫娴佺▼ + * * @param processInstanceId 娴佺▼瀹炰緥 ID - * @param deleteReason 瀹氫箟鍒犻櫎鍘熷洜 + * @param deleteReason 瀹氫箟鍒犻櫎鍘熷洜 */ public Result<?> end(String processInstanceId, String deleteReason) { try { // 寮哄埗缁撴潫娴佺▼瀹炰緥 runtimeService.deleteProcessInstance(processInstanceId, deleteReason); // 鍒犻櫎鍏宠仈娴佺▼鐨勪笟鍔� - FlowMyBusiness flowMyBusiness=flowMyBusinessService.getFlowMyBusiness(processInstanceId); + FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(processInstanceId); flowMyBusinessService.removeById(flowMyBusiness.getId()); System.out.println("Process instance with ID " + processInstanceId + " has been forcefully ended."); } catch (Exception e) { @@ -740,7 +826,7 @@ @Override public void deleteTask(FlowTaskVo flowTaskVo) { // todo 寰呯‘璁ゅ垹闄や换鍔℃槸鐗╃悊鍒犻櫎浠诲姟 杩樻槸閫昏緫鍒犻櫎锛岃杩欎釜浠诲姟鐩存帴閫氳繃锛� - taskService.deleteTask(flowTaskVo.getTaskId(),flowTaskVo.getComment()); + taskService.deleteTask(flowTaskVo.getTaskId(), flowTaskVo.getComment()); } /** @@ -785,7 +871,7 @@ @Override @Transactional(rollbackFor = Exception.class) public void assignTask(FlowTaskVo flowTaskVo) { - taskService.setAssignee(flowTaskVo.getTaskId(),flowTaskVo.getAssignee()); + taskService.setAssignee(flowTaskVo.getTaskId(), flowTaskVo.getAssignee()); } /** @@ -803,7 +889,7 @@ .startedBy(username) .orderByProcessInstanceStartTime() .desc(); - List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.listPage((pageNum - 1)*pageSize, pageSize); + List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.listPage((pageNum - 1) * pageSize, pageSize); page.setTotal(historicProcessInstanceQuery.count()); List<FlowTaskDto> flowList = new ArrayList<>(); for (HistoricProcessInstance hisIns : historicProcessInstances) { @@ -942,6 +1028,7 @@ /** * 鍒ゆ柇澶氫釜浠诲姟鏄惁澶勪簬鍚屼竴娴佺▼鑺傜偣 + * * @param taskIds 閫楀彿鍒嗛殧鐨勪换鍔D瀛楃涓� * @return 缁熶竴缁撴灉灏佽 */ @@ -1013,7 +1100,7 @@ .taskAssignee(username) .orderByTaskCreateTime().desc(); page.setTotal(taskQuery.count()); - List<Task> taskList = taskQuery.listPage((pageNum - 1)*pageSize, pageSize); + List<Task> taskList = taskQuery.listPage((pageNum - 1) * pageSize, pageSize); List<FlowTaskDto> flowList = new ArrayList<>(); for (Task task : taskList) { FlowTaskDto flowTask = new FlowTaskDto(); @@ -1040,7 +1127,7 @@ List<String> departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(historicProcessInstance.getStartUserId()); flowTask.setStartUserId(startUser.getUsername()); flowTask.setStartUserName(startUser.getRealname()); - flowTask.setStartDeptName(CollUtil.join(departNamesByUsername,"锛�")); + flowTask.setStartDeptName(CollUtil.join(departNamesByUsername, "锛�")); flowList.add(flowTask); } @@ -1069,15 +1156,15 @@ .processInstanceId(flowTaskDto.getProcInsId()) .singleResult(); SysUser startUser = iFlowThirdService.getUserByUsername(historicProcessInstance.getStartUserId()); - if (startUser!=null){ + if (startUser != null) { flowTaskDto.setStartUserId(startUser.getUsername()); flowTaskDto.setStartUserName(startUser.getRealname()); } List<String> departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(historicProcessInstance.getStartUserId()); - flowTaskDto.setStartDeptName(CollUtil.join(departNamesByUsername,"锛�")); - if (flowTaskDto.getTodoUsers() == null){ + flowTaskDto.setStartDeptName(CollUtil.join(departNamesByUsername, "锛�")); + if (flowTaskDto.getTodoUsers() == null) { flowTaskDto.setTodoUsers(""); - }else { + } else { //鍘婚櫎[] flowTaskDto.setTodoUsers(flowTaskDto.getTodoUsers().replaceAll("\\[", "").replaceAll("\\]", "")); flowTaskDto.setTodoUsers(flowTaskDto.getTodoUsers().replaceAll("\"", "")); @@ -1125,9 +1212,9 @@ flowTask.setAssigneeId(sysUser.getUsername()); flowTask.setAssigneeName(sysUser.getRealname()); List<String> departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(histIns.getAssignee()); - flowTask.setDeptName(CollUtil.join(departNamesByUsername,"锛�")); - if (StrUtil.equals(histIns.getActivityId(),ProcessConstants.START_NODE)){ - // 寮�濮嬭妭鐐癸紝鎶婂�欓�変汉璁剧疆涓哄彂璧蜂汉锛岃繖涓�煎凡琚叾浠栧湴鏂硅缃繃锛屼笌瀹為檯鍔炵悊浜轰竴鑷村嵆鍙� + flowTask.setDeptName(CollUtil.join(departNamesByUsername, "锛�")); + if (StrUtil.equals(histIns.getActivityId(), ProcessConstants.START_NODE)) { + // 寮�濮嬭妭鐐癸紝鎶婂�欓�変汉璁剧疆涓哄彂璧蜂汉锛岃繖涓�煎凡琚叾浠栧湴鏂硅缃繃锛屼笌瀹為檯鍔炵悊浜轰竴鑷村嵆鍙� flowTask.setCandidate(sysUser.getRealname()); } } @@ -1169,9 +1256,9 @@ String serviceImplName = business.getServiceImplName(); FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); // 娴佺▼澶勭悊瀹屽悗锛岃繘琛屽洖璋冧笟鍔″眰 - if (flowCallBackService!=null){ + if (flowCallBackService != null) { Object businessDataById = flowCallBackService.getBusinessDataById(dataId); - map.put("formData",businessDataById); + map.put("formData", businessDataById); } return Result.OK(map); } @@ -1260,8 +1347,8 @@ for (FlowViewerDto viewerDto : flowViewerList) { String key = viewerDto.getKey(); - if (key.equals(flowViewerDto.getKey())){ - // 閲嶅鍒犻櫎鍚庨潰鏇存柊 + if (key.equals(flowViewerDto.getKey())) { + // 閲嶅鍒犻櫎鍚庨潰鏇存柊 flowViewerList.remove(viewerDto); break; } @@ -1276,7 +1363,7 @@ @Override public List<FlowViewerDto> getFlowViewerByDataId(String dataId) { LambdaQueryWrapper<FlowMyBusiness> flowMyBusinessLambdaQueryWrapper = new LambdaQueryWrapper<>(); - flowMyBusinessLambdaQueryWrapper.eq(FlowMyBusiness::getDataId,dataId) + flowMyBusinessLambdaQueryWrapper.eq(FlowMyBusiness::getDataId, dataId) ; //濡傛灉淇濆瓨鏁版嵁鍓嶆湭璋冪敤蹇呰皟鐨凢lowCommonService.initActBusiness鏂规硶锛屽氨浼氭湁闂 FlowMyBusiness business = flowMyBusinessService.getOne(flowMyBusinessLambdaQueryWrapper); @@ -1298,7 +1385,7 @@ String firstKey = stev.getId(); orderKeys.add(firstKey); //椤哄簭鑾峰彇鑺傜偣 - this.appendKeys(orderKeys, firstKey,flowElements); + this.appendKeys(orderKeys, firstKey, flowElements); } catch (Exception e) { break; } @@ -1307,11 +1394,11 @@ for (String key : orderKeys) { Optional<FlowViewerDto> any = flowViewers.stream().filter(o -> StrUtil.equals(o.getKey(), key)).findAny(); - if(any.isPresent()){ + if (any.isPresent()) { FlowViewerDto viewerDto = any.get(); reflowViewers.add(viewerDto); - if (!viewerDto.isCompleted()){ - // 宸插埌姝e湪绛夊緟鎵ц鐨勮妭鐐癸紝鍚庨潰鐨勪笉瑕佷簡 + if (!viewerDto.isCompleted()) { + // 宸插埌姝e湪绛夊緟鎵ц鐨勮妭鐐癸紝鍚庨潰鐨勪笉瑕佷簡 break; } } @@ -1327,8 +1414,9 @@ /** * 椤哄簭鎶藉彇鑺傜偣 - * @param orderKeys 瀹瑰櫒 - * @param sourceKey 婧� + * + * @param orderKeys 瀹瑰櫒 + * @param sourceKey 婧� * @param flowElements 鎵�鏈夌殑鑺傜偣瀵硅薄 */ private void appendKeys(List<String> orderKeys, String sourceKey, List<FlowElement> flowElements) { @@ -1337,9 +1425,9 @@ SequenceFlow sf = (SequenceFlow) flowElement; String sourceRef = sf.getSourceRef(); String targetRef = sf.getTargetRef(); - if (sourceKey.equals(sourceRef)&&targetRef!=null){ + if (sourceKey.equals(sourceRef) && targetRef != null) { orderKeys.add(targetRef); - this.appendKeys(orderKeys,targetRef,flowElements); + this.appendKeys(orderKeys, targetRef, flowElements); } } catch (Exception e) { continue; @@ -1373,89 +1461,116 @@ * @return */ @Override - public Result getNextFlowNode(FlowTaskVo flowTaskVo) { + public Result<List<FlowNextDto>> getNextFlowNode(FlowTaskVo flowTaskVo) { // todo 浼间箮閫昏緫鏈啓瀹岋紝寰呮鏌� - FlowNextDto flowNextDto = this.getNextFlowNode(flowTaskVo.getTaskId(), flowTaskVo.getValues()); - if (flowNextDto==null) { + List<FlowNextDto> nextDtoList = this.getNextFlowNode(flowTaskVo.getTaskId(), flowTaskVo.getValues()); + if (CollectionUtils.isEmpty(nextDtoList)) { return Result.OK("娴佺▼宸插畬缁�", null); } - return Result.OK(flowNextDto); + return Result.OK(nextDtoList); + } + + @Override + public boolean checkParallelCompletion(String currentTaskId) { + //鑾峰彇褰撳墠浠诲姟 + Task currentTask = taskService.createTaskQuery().taskId(currentTaskId).singleResult(); + if (currentTask == null) { + return false; + } + //鑾峰彇褰撳墠鎵ц + Execution execution = runtimeService.createExecutionQuery().executionId(currentTask.getExecutionId()).singleResult(); + if (execution == null) { + return false; + } + String parentId = execution.getParentId(); + if (StringUtils.isBlank(parentId)) { + //娌℃湁鐖惰妭鐐� 浠h〃娌℃湁骞惰浠诲姟 + return true; + } + // 鑾峰彇鎵�鏈夊厔寮熸墽琛� + List<Execution> siblingExecutions = runtimeService.createExecutionQuery() + .parentId(parentId) + .list(); + + for (Execution siblingExecution : siblingExecutions) { + if (!siblingExecution.getId().equals(execution.getId())) { + //闈炶嚜韬殑鍏勫紵鑺傜偣 + long count = runtimeService.createActivityInstanceQuery().executionId(siblingExecution.getId()).unfinished().count(); + if (count > 0) { + return false; + } + } + } + return true; } /** * 鑾峰彇涓嬩竴涓妭鐐逛俊鎭�,娴佺▼瀹氫箟涓婄殑鑺傜偣淇℃伅 + * * @param taskId 褰撳墠鑺傜偣id * @param values 娴佺▼鍙橀噺 * @return 濡傛灉杩斿洖null锛岃〃绀烘病鏈変笅涓�涓妭鐐癸紝娴佺▼缁撴潫 */ - public FlowNextDto getNextFlowNode(String taskId, Map<String, Object> values) { + public List<FlowNextDto> getNextFlowNode(String taskId, Map<String, Object> values) { //褰撳墠鑺傜偣 Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); if (Objects.nonNull(task)) { // 涓嬩釜浠诲姟鑺傜偣 List<UserTask> nextUserTask = FindNextNodeUtil.getNextUserTasks(repositoryService, task, values); if (CollectionUtils.isNotEmpty(nextUserTask)) { - FlowNextDto flowNextDto = new FlowNextDto(); + List<FlowNextDto> nextDtoList = Lists.newArrayList(); + FlowNextDto flowNextDto; for (UserTask userTask : nextUserTask) { + flowNextDto = new FlowNextDto(); flowNextDto.setUserTask(userTask); //寰呭姙浜哄憳 List<SysUser> sysUserFromTask = this.getSysUserFromTask(userTask); flowNextDto.setUserList(sysUserFromTask); - - MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics(); - if (Objects.nonNull(multiInstance)) { - // 浼氱 澶氬疄渚� - String collectionString = multiInstance.getInputDataItem(); - Object colObj = values.get(collectionString); - List<String> userNameList = null; - if(colObj!=null){ - userNameList = (List) colObj; - } - if (CollUtil.isNotEmpty(userNameList)){ - // 寰呭姙浜哄憳浠庡彉閲忎腑鑾峰彇 鍚﹀垯灏辨槸鑺傜偣涓厤缃殑鐢ㄦ埛 sysUserFromTask - List<SysUser> userList = Lists.newArrayList(); - for (String username : userNameList) { - SysUser userByUsername = iFlowThirdService.getUserByUsername(username); - if (userByUsername==null){ - throw new CustomException(username + " 鐢ㄦ埛鍚嶆湭鎵惧埌"); - } else { - userList.add(userByUsername); - } + //澶氫换鍔″苟琛� + Object colObj = values.get(userTask.getId()); + if (Objects.nonNull(colObj)) { + List<String> userNameList = (List) colObj; + // 寰呭姙浜哄憳浠庡彉閲忎腑鑾峰彇 鍚﹀垯灏辨槸鑺傜偣涓厤缃殑鐢ㄦ埛 sysUserFromTask + List<SysUser> userList = Lists.newArrayList(); + for (String username : userNameList) { + SysUser userByUsername = iFlowThirdService.getUserByUsername(username); + if (userByUsername == null) { + throw new CustomException(username + " 鐢ㄦ埛鍚嶆湭鎵惧埌"); + } else { + userList.add(userByUsername); } - flowNextDto.setUserList(userList); - } else { - // 鍙橀噺涓病鏈変紶鍏ワ紝鍐欏叆鑺傜偣涓厤缃殑鐢ㄦ埛 - List<String> collect_username = sysUserFromTask.stream().map(SysUser::getUsername).collect(Collectors.toList()); - values.put(collectionString,collect_username); } + flowNextDto.setUserList(userList); } else { - // todo 璇诲彇鑷畾涔夎妭鐐瑰睘鎬у仛浜涘暐锛� - //String dataType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_DATA_TYPE); - String userType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_USER_TYPE); + // 鍙橀噺涓病鏈変紶鍏ワ紝鍐欏叆鑺傜偣涓厤缃殑鐢ㄦ埛 + List<String> collect_username = sysUserFromTask.stream().map(SysUser::getUsername).collect(Collectors.toList()); + values.put(userTask.getId(), collect_username); } + nextDtoList.add(flowNextDto); } - return flowNextDto; + return nextDtoList; } } return null; } + public List<SysUser> getSysUserFromTask(UserTask userTask) { String assignee = userTask.getAssignee(); - if (StrUtil.isNotBlank(assignee)){ + if (StrUtil.isNotBlank(assignee)) { // 鎸囧畾鍗曚汉 SysUser userByUsername = iFlowThirdService.getUserByUsername(assignee); return Lists.newArrayList(userByUsername); } List<String> candidateUsers = userTask.getCandidateUsers(); - if (CollUtil.isNotEmpty(candidateUsers)){ + if (CollUtil.isNotEmpty(candidateUsers)) { // 鎸囧畾澶氫汉 List<SysUser> list = iFlowThirdService.getAllUser(); - return list.stream().filter(o->candidateUsers.contains(o.getUsername())).collect(Collectors.toList()); + return list.stream().filter(o -> candidateUsers.contains(o.getUsername())).collect(Collectors.toList()); } List<String> candidateGroups = userTask.getCandidateGroups(); - if (CollUtil.isNotEmpty(candidateGroups)){ - // 鎸囧畾澶氱粍 + if (CollUtil.isNotEmpty(candidateGroups)) { + // 鎸囧畾澶氱粍 List<SysUser> userList = Lists.newArrayList(); for (String candidateGroup : candidateGroups) { List<SysUser> usersByRoleId = iFlowThirdService.getUsersByRoleId(candidateGroup); @@ -1465,6 +1580,7 @@ } return Lists.newArrayList(); } + /** * 娴佺▼瀹屾垚鏃堕棿澶勭悊 * -- Gitblit v1.9.3