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 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,6 +189,8 @@ if (guideCardBatch==null) { return Result.ok("未找到对应的程序加工确认表"); } Result result=reStartDispatchFile(id); if (result==null) { //填充数据 guideCardBatch.setCompiler(user.getUsername()); guideCardBatch.setCompilerTime(new Date()); @@ -197,14 +204,141 @@ 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()) { 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; } } /** * 重新启动 * @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) { // 实际业务中调用服务接口获取组成员 return sysUserRoleService.getUserNameByRoleId(groupId); } /** * 流程节点审核 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("已被定型的文档不能进行升版"); } //是否又进行的升版 AssignEquipmentFileStream productAssignEquipmentFileStream = this.getOne( new QueryWrapper<AssignEquipmentFileStream>().eq("doc_id", productDocInfo.getDocId()) .isNull("audit_type")); if(productAssignEquipmentFileStream!=null){ return Result.error("该文档已经进行过升版"); } //获取产品文档信息对应最新程序加工确认表 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("该文档已经进行过升版"); } //获取设备 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()) { lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
@@ -254,10 +254,6 @@ } handleFileTransfer(mdcEquipment, docFile); //注意----区分工控网与涉密网!!! 涉密网进行NC文件的拷贝,工控网负责进行解析NC文件 if (deployType.equals(DeployEnum.SMW.getCode())) { handleFileProcessing(docFile, mdcEquipment, secretFolder); } synchronizedFlagService.updateFlag(2); return Result.OK("操作成功"); } @@ -382,10 +378,6 @@ docFile.getFileName(),docFile.getFileSuffix()); } } } //注意----区分工控网与涉密网!!! 涉密网进行NC文件的拷贝,工控网负责进行解析NC文件 if (deployType.equals(DeployEnum.SMW.getCode())) { handleFileProcessing(docFile, mdcEquipment, secretFolder); } return synchronizedFlagService.updateFlag(1); }else if(up.getStatus() == 3) { 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;