From f64ce002aac67c5b7068654ed6229ea02f87520d Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期三, 25 六月 2025 14:17:53 +0800 Subject: [PATCH] 同步工控网 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java | 172 ++++++++++++++++++++++++++++++++++++++---- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IGuideCardBatchService.java | 7 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java | 7 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java | 23 +++++ 4 files changed, 188 insertions(+), 21 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IGuideCardBatchService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IGuideCardBatchService.java index dde62b2..8025a11 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IGuideCardBatchService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IGuideCardBatchService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.dnc.entity.GuideCardBatch; +import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; import org.jeecg.modules.dncFlow.vo.GuideCardBatchFlowTaskVo; /** @@ -35,6 +36,12 @@ Result<?> startGuideCardBatch(String id); /** + * 閲嶆柊鍚姩 + * @param id + */ + Result<?> reStartDispatchFile(String id); + + /** * 娴佺▼鑺傜偣瀹℃牳 * @param guideCardBatchFlowTaskVo * @return diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java index f61a051..100a954 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java @@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.shiro.SecurityUtils; +import org.flowable.common.engine.api.FlowableException; import org.flowable.engine.TaskService; +import org.flowable.identitylink.api.IdentityLink; import org.flowable.task.api.Task; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.vo.LoginUser; @@ -19,6 +21,7 @@ import org.jeecg.modules.dnc.utils.ValidateUtil; import org.jeecg.modules.dncFlow.constant.GuideCardBatchEnum; import org.jeecg.modules.dncFlow.entity.DispatchFile; +import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; import org.jeecg.modules.dncFlow.vo.GuideCardBatchFlowTaskVo; import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; @@ -27,6 +30,7 @@ import org.jeecg.modules.flowable.service.IFlowDefinitionService; import org.jeecg.modules.flowable.service.IFlowTaskService; import org.jeecg.modules.system.service.ISysDictService; +import org.jeecg.modules.system.service.ISysUserRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -72,7 +76,8 @@ private TaskService taskService; @Autowired private IFlowMyBusinessService flowMyBusinessService; - + @Autowired + private ISysUserRoleService sysUserRoleService; /** * 鐢熸垚娴佹按鍙� * @param code @@ -184,28 +189,157 @@ if (guideCardBatch==null) { return Result.ok("鏈壘鍒板搴旂殑绋嬪簭鍔犲伐纭琛�"); } - //濉厖鏁版嵁 - guideCardBatch.setCompiler(user.getUsername()); - guideCardBatch.setCompilerTime(new Date()); - guideCardBatch.setFlowStatus(GuideCardBatchEnum.VERIFY.getCode()); - this.updateById(guideCardBatch); - System.out.println("绋嬪簭鍔犲伐纭琛� 纭娴佺▼锛�" + guideCardBatch.getId()); - flowCommonService.initActBusiness("娴佹按鍙凤細"+guideCardBatch.getSerialNumber()+" 绋嬪簭鍔犲伐纭琛ㄨ繘琛岀‘璁ゆ祦绋�", - guideCardBatch.getId(), "IGuideCardBatchService", "nc_guide_card_batch", null); - Map<String, Object> variables = new HashMap<>(); - variables.put("dataId", guideCardBatch.getId()); - variables.put("organization", "鐢ㄦ埛"+user.getRealname()+"鍙戣捣娴佺▼"); - variables.put("comment", "鐢ㄦ埛"+user.getRealname()+"鍙戣捣娴佺▼"); - variables.put("proofreading",true); - Result result= flowDefinitionService.startProcessInstanceByKey("nc_guide_card_batch", variables); - if (!result.isSuccess()) { - guideCardBatch.setCompiler(null); - guideCardBatch.setCompilerTime(null); + Result result=reStartDispatchFile(id); + if (result==null) { + //濉厖鏁版嵁 + guideCardBatch.setCompiler(user.getUsername()); + guideCardBatch.setCompilerTime(new Date()); + guideCardBatch.setFlowStatus(GuideCardBatchEnum.VERIFY.getCode()); this.updateById(guideCardBatch); + System.out.println("绋嬪簭鍔犲伐纭琛� 纭娴佺▼锛�" + guideCardBatch.getId()); + flowCommonService.initActBusiness("娴佹按鍙凤細"+guideCardBatch.getSerialNumber()+" 绋嬪簭鍔犲伐纭琛ㄨ繘琛岀‘璁ゆ祦绋�", + guideCardBatch.getId(), "IGuideCardBatchService", "nc_guide_card_batch", null); + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", guideCardBatch.getId()); + variables.put("organization", "鐢ㄦ埛"+user.getRealname()+"鍙戣捣娴佺▼"); + variables.put("comment", "鐢ㄦ埛"+user.getRealname()+"鍙戣捣娴佺▼"); + variables.put("proofreading",true); + Result flowResult= flowDefinitionService.startProcessInstanceByKey("nc_guide_card_batch", variables); + if (!flowResult.isSuccess()) { + guideCardBatch.setCompiler(null); + guideCardBatch.setCompilerTime(null); + this.updateById(guideCardBatch); + } + return flowResult; + }else { + return result; } - return result; } + + /** + * 閲嶆柊鍚姩 + * @param id + */ + @Override + @Transactional(rollbackFor = {Exception.class}) + public Result<?> reStartDispatchFile(String id) { + GuideCardBatch guideCardBatch=this.getById(id); + if (guideCardBatch!=null){ + if (!guideCardBatch.getFlowStatus().equals(GuideCardBatchEnum.VERIFY.getCode())){ + //閲嶆柊鍚姩娴佺▼ + try { + // 1. 鑾峰彇褰撳墠鐢ㄦ埛骞舵牎楠岀櫥褰曠姸鎬� + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + if (user == null) { + return Result.error("鐢ㄦ埛鏈櫥褰�"); + } + + // 2. 鏌ヨ娴佺▼涓氬姟璁板綍锛堝鐞嗙┖缁撴灉锛� + List<FlowMyBusiness> businessList = flowMyBusinessService.list( + new QueryWrapper<FlowMyBusiness>() + .eq("data_id", guideCardBatch.getId()) + ); + if (businessList.isEmpty()) { + return Result.error("娴佺▼璁板綍涓嶅瓨鍦�"); + } + FlowMyBusiness flowMyBusiness = businessList.get(0); + + // 3. 鏍¢獙鐢ㄦ埛鏄惁涓哄�欓�夊鐞嗕汉 + List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); + if (todoUsers == null || !todoUsers.contains(user.getUsername())) { + return Result.error("鐢ㄦ埛鏃犳潈鎿嶄綔姝や换鍔�"); + } + + // 4. 璁ら浠诲姟锛堝鐞嗗凡琚棰嗙殑鎯呭喌锛� + String taskId = flowMyBusiness.getTaskId(); + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + if (task == null) { + return Result.error("浠诲姟涓嶅瓨鍦ㄦ垨宸插畬鎴�"); + } + if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) { + return Result.error("浠诲姟宸茶浠栦汉璁ら"); + } + taskService.claim(taskId, user.getUsername()); + + // 5. 瀹屾垚浠诲姟骞朵紶閫掑彉閲� + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", flowMyBusiness.getDataId()); + variables.put("organization","閲嶆柊鍙戣捣娴佺▼"); + variables.put("assignee", user.getUsername()); + variables.put("comment", "閲嶆柊鍙戣捣娴佺▼"); + taskService.complete(taskId, variables); + + // 6. 鑾峰彇涓嬩竴浠诲姟骞舵洿鏂颁笟鍔¤褰� + List<Task> nextTasks = taskService.createTaskQuery() + .processInstanceId(flowMyBusiness.getProcessInstanceId()) + .list(); + if (!nextTasks.isEmpty()) { + Task nextTask = nextTasks.get(0); // 鍋囪鍙栫涓�涓换鍔� + flowMyBusiness.setTaskId(nextTask.getId()); + flowMyBusiness.setTaskName(nextTask.getName()); + + // 鍔ㄦ�佽幏鍙栦笅涓�鑺傜偣鍊欓�変汉锛堢ず渚嬶級 + List<String> nextTodoUsers = getNextTaskCandidates(nextTask.getId()); + flowMyBusiness.setTodoUsers(JSON.toJSONString(nextTodoUsers)); + } else { + // 娴佺▼宸茬粨鏉燂紝娓呯┖浠诲姟淇℃伅 + flowMyBusiness.setTaskId(null); + flowMyBusiness.setTaskName(null); + flowMyBusiness.setTodoUsers(null); + } + flowMyBusinessService.updateById(flowMyBusiness); + guideCardBatch.setFlowStatus(GuideCardBatchEnum.VERIFY.getCode()); + this.updateById(guideCardBatch); + return Result.ok("娴佺▼閲嶅惎鎴愬姛"); + } catch (FlowableException e) { + return Result.error("娴佺▼鎿嶄綔澶辫触: " + e.getMessage()); + } catch (Exception e) { + return Result.error("绯荤粺閿欒: " + e.getMessage()); + } + }else { + return null; + } + } + return Result.error("鏁版嵁涓嶅瓨鍦�"); + } + + // 杈呭姪鏂规硶锛氳幏鍙栦笅涓�浠诲姟鐨勬墍鏈夊�欓�変俊鎭紙澶勭悊浜恒�佸�欓�夌敤鎴枫�佸�欓�夌粍锛� + private List<String> getNextTaskCandidates(String taskId) { + List<IdentityLink> links = taskService.getIdentityLinksForTask(taskId); + List<String> candidates = new ArrayList<>(); + + // 1. 鑾峰彇鐩存帴澶勭悊浜猴紙assignee锛� + links.stream() + .filter(link -> "assignee".equals(link.getType())) + .map(IdentityLink::getUserId) + .filter(Objects::nonNull) + .forEach(candidates::add); + + // 2. 鑾峰彇鍊欓�夌敤鎴峰拰鍊欓�夌粍 + links.stream() + .filter(link -> "candidate".equals(link.getType())) + .forEach(link -> { + if (link.getUserId() != null) { + // 鍊欓�夌敤鎴风洿鎺ユ坊鍔� + candidates.add(link.getUserId()); + } else if (link.getGroupId() != null) { + // 鍊欓�夌粍杞崲涓哄疄闄呯敤鎴凤紙绀轰緥閫昏緫锛岄渶鏍规嵁涓氬姟瀹炵幇锛� + List<String> groupUsers = convertGroupToUsers(link.getGroupId()); + candidates.addAll(groupUsers); + } + }); + + return candidates; + } + + // 绀轰緥鏂规硶锛氬皢鍊欓�夌粍ID杞崲涓虹敤鎴峰垪琛紙闇�鑷畾涔夊疄鐜帮級 + private List<String> convertGroupToUsers(String groupId) { + // 瀹為檯涓氬姟涓皟鐢ㄦ湇鍔℃帴鍙h幏鍙栫粍鎴愬憳 + return sysUserRoleService.getUserNameByRoleId(groupId); + } + + /** * 娴佺▼鑺傜偣瀹℃牳 * @param guideCardBatchFlowTaskVo diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java index 68972da..96d91ed 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java @@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; +import org.flowable.common.engine.api.FlowableException; import org.flowable.engine.TaskService; +import org.flowable.identitylink.api.IdentityLink; import org.flowable.task.api.Task; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.vo.LoginUser; @@ -29,6 +31,7 @@ import org.jeecg.modules.dncFlow.mapper.AssignEquipmentFileStreamMapper; import org.jeecg.modules.dncFlow.service.IAssignEquipmentFileStreamService; import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; +import org.jeecg.modules.dncFlow.vo.DispatchFileFlowTaskVo; import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; @@ -38,6 +41,7 @@ import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.service.IMdcEquipmentService; import org.jeecg.modules.system.service.IMdcProductionService; +import org.jeecg.modules.system.service.ISysUserRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Lazy; @@ -127,6 +131,16 @@ if(productDocInfo==null){ return Result.error("鏈彂鐜拌浜у搧缁撴瀯鏍戝搴旀枃妗�"); } + if (productDocInfo.getDocDispatchStatus()==5){ + return Result.error("宸茶瀹氬瀷鐨勬枃妗d笉鑳借繘琛屽崌鐗�"); + } + //鏄惁鍙堣繘琛岀殑鍗囩増 + AssignEquipmentFileStream productAssignEquipmentFileStream = this.getOne( + new QueryWrapper<AssignEquipmentFileStream>().eq("doc_id", productDocInfo.getDocId()) + .isNull("audit_type")); + if(productAssignEquipmentFileStream!=null){ + return Result.error("璇ユ枃妗e凡缁忚繘琛岃繃鍗囩増"); + } //鑾峰彇浜у搧鏂囨。淇℃伅瀵瑰簲鏈�鏂扮▼搴忓姞宸ョ‘璁よ〃 List<GuideCardBatch> batches = iGuideCardBatchService.list( new QueryWrapper<GuideCardBatch>() @@ -198,6 +212,13 @@ if(productDocInfo==null){ return Result.error("鏈彂鐜拌浜у搧缁撴瀯鏍戝搴旀枃妗�"); } + //鏄惁鍙堣繘琛岀殑鍗囩増 + AssignEquipmentFileStream productAssignEquipmentFileStream = this.getOne( + new QueryWrapper<AssignEquipmentFileStream>().eq("doc_id", productDocInfo.getDocId()) + .isNull("audit_type")); + if(productAssignEquipmentFileStream!=null){ + return Result.error("璇ユ枃妗e凡缁忚繘琛岃繃鍗囩増"); + } //鑾峰彇璁惧 MdcEquipment mdcEquipment =mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId()); if (mdcEquipment==null){ @@ -237,6 +258,8 @@ values.put("comment", assignEquipmentFileStreamVo.getComment()); values.put("organization", assignEquipmentFileStreamVo.getComment()); assignEquipmentFileStreamVo.setValues(values); + assignEquipmentFileStream.setAuditType(assignEquipmentFileStreamVo.getAuditType()); + assignEquipmentFileStream.setAuditReason(assignEquipmentFileStream.getAuditReason()); // 瀹屾垚娴佺▼浠诲姟 Result result = flowTaskService.complete(assignEquipmentFileStreamVo); if (result.isSuccess()) { diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java index a771833..6709cea 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java @@ -412,19 +412,22 @@ checkParam(dispatchFile); //鑾峰彇鏂囦欢淇℃伅 DocInfo docInfo = docInfoService.getById(dispatchFile.getDocId()); + if (docInfo.getDocDispatchStatus()==5){ + return Result.error("瀹氬瀷宸查�氳繃,涓嶈兘閲嶅鎿嶄綔"); + } PermissionStreamNew permissionStreams = getPermissionStreams(dispatchFile); if (permissionStreams==null){ return Result.error("鐢ㄦ埛娌℃湁鏉冮檺"); } super.save(dispatchFile); flowCommonService.initActBusiness(docInfo.getDocName()+"."+docInfo.getDocSuffix()+"鏂囦欢杩涜瀹氬瀷", - dispatchFile.getId(), "IDispatchFileService", "process_rf27duhy", null); + dispatchFile.getId(), "IDispatchFileService", "ncFileSettingProcessApproval", null); Map<String, Object> variables = new HashMap<>(); variables.put("dataId", dispatchFile.getId()); variables.put("organization", "瀵煎叆鏂囨。榛樿鍚姩娴佺▼"); variables.put("comment", "瀵煎叆鏂囨。榛樿鍚姩娴佺▼"); variables.put("proofreading",true); - Result result= flowDefinitionService.startProcessInstanceByKey("process_rf27duhy", variables); + Result result= flowDefinitionService.startProcessInstanceByKey("ncFileSettingProcessApproval", variables); if (!result.isSuccess()) super.removeById(dispatchFile.getId()); return result; -- Gitblit v1.9.3