From a3a9933cf1b49006edf470615236f94ebdaa4cb9 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期三, 03 九月 2025 17:04:24 +0800
Subject: [PATCH] 增加车床程序处理;退回改为实际编程员
---
blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/StartDispatcher.java | 145 ++++++++++++++++++++++++++----------------------
1 files changed, 78 insertions(+), 67 deletions(-)
diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/StartDispatcher.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/StartDispatcher.java
index 1c31720..5f7dad7 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/StartDispatcher.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/StartDispatcher.java
@@ -1,24 +1,26 @@
package org.springblade.mdm.flow.excution;
-import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.IdentityService;
import org.flowable.engine.runtime.ProcessInstance;
import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.mdm.basesetting.producedivision.entity.ProduceDivision;
import org.springblade.mdm.flow.constants.FlowContants;
import org.springblade.mdm.flow.entity.FlowProgramFile;
+import org.springblade.mdm.flow.service.FlowCommonService;
import org.springblade.mdm.flow.service.FlowProgramFileService;
import org.springblade.mdm.flow.vo.TaskAssignVO;
import org.springblade.mdm.program.entity.NcNode;
import org.springblade.mdm.program.service.NcNodeService;
+import org.springblade.mdm.program.service.NodeDeptQueryService;
import org.springblade.mdm.utils.EntityUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.flowable.engine.RuntimeService;
import org.springframework.transaction.annotation.Transactional;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -26,16 +28,14 @@
@AllArgsConstructor
@Service("startDispatcher")
public class StartDispatcher {
-
private final RuntimeService runtimeService;
- private final AutoAssignUsersService autoAssignUsersService;
private final IdentityService identityService;
private final NcNodeService ncNodeService;
private final FlowProgramFileService flowProgramFileService;
-
- //public static final String PROCESS_KEY = "dispatch";
+ private final NodeDeptQueryService nodeDeptQueryService;
+ private final FlowCommonService flowCommonService;
/**
* 鍚姩娲惧伐娴佺▼
@@ -44,17 +44,22 @@
*/
@Transactional
public String start(TaskAssignVO startVO){
+ if(!FlowContants.Y.equals(startVO.getIsTempFlow())){
+ startVO.setIsTempFlow(FlowContants.N);
+ }
+ Map<String, Object> vars = new HashMap<>();
- Map<String,Object> preAssignee = autoAssignUsersService.autoAssignUsers(startVO);
- Map<String, Object> vars = new HashMap<>(preAssignee);
- vars.put(FlowContants.ASSIGNEE,preAssignee.get(FlowContants.TEAM_LEADER));//绗竴涓鎵圭敤鎴凤細缁勯暱
+ ProduceDivision div = flowCommonService.putDefaultAssignees(vars,startVO.getDrawingNo(),null);
vars.put(FlowContants.TITLE,startVO.getTitle());
+
//鏈哄簥缂栧彿
vars.put(FlowContants.MACHINE_CODE,startVO.getMachineCode());
-
+ String workshop = nodeDeptQueryService.getWorkshopNameByMachineCode(startVO.getMachineCode());
+ vars.put(FlowContants.WORKSHOP,workshop);
//鏈哄簥鍨嬪彿
vars.put(FlowContants.MACHINE_MODE,startVO.getMachineMode());
+
vars.put(FlowContants.PROCESS_NO,startVO.getProcessNo());
vars.put(FlowContants.PROCESS_NAME,startVO.getProcessName());
vars.put(FlowContants.PROCESS_EDITION,startVO.getProcessEdition());
@@ -65,81 +70,87 @@
vars.put("planLockDays",startVO.getPlanLockDays());
vars.put(FlowContants.PRODUCT_MODEL,startVO.getProductModel());
- String programPkgName = NcNodeService.genProgramName(startVO.getDrawingNo(),startVO.getProcessNo());
-
- NcNode curedProgramPackage = ncNodeService.getLastEditionCuredProgramPackage(programPkgName);
- //璁剧疆鏄惁鏈夊浐鍖栫▼搴忔爣璁�
- vars.put(FlowContants.HAS_CURED_PROGRAM,curedProgramPackage != null ? FlowContants.Y:FlowContants.N);
- //宸ュ簭鐗堟鏄惁涓�鑷达紝鏄惁鍦ㄦ湁鏁堟湡鍐�
- if(curedProgramPackage != null){
- vars.put(FlowContants.CURED_NODE_ID,curedProgramPackage.getId());
- vars.put(FlowContants.IS_PROCESS_EDITION_SAME, StringUtils.equals(curedProgramPackage.getProcessEdition(),startVO.getProcessEdition()) ? "Y":"N");
- vars.put(FlowContants.VALIDITY_PERIOD, curedProgramPackage.withinValidityPeriod() ? FlowContants.Y:FlowContants.N);
- }else{
- vars.put(FlowContants.IS_PROCESS_EDITION_SAME, FlowContants.Y);
- vars.put(FlowContants.VALIDITY_PERIOD, FlowContants.Y);
+ if(StringUtils.isNotBlank(startVO.getDeviation())) {
+ vars.put(FlowContants.DEVIATION, startVO.getDeviation());//鍋忕鍗�
}
+ String programPkgName = NcNodeService.genProgramName(startVO.getDrawingNo(),startVO.getProcessNo());
+ vars.put(FlowContants.PROGRAM_PACKAGE_NAME,programPkgName);
+
+ vars.put(FlowContants.IS_TEMP_FLOW,FlowContants.Y.equals(startVO.getIsTempFlow())?FlowContants.Y:FlowContants.N);
+ NcNode curedProgramPackage = null;
+ if(!startVO.isTemporaryFlow() && !startVO.isDeviationFlow()) {
+ //姝e父娴佺▼(闈炰复鏃舵祦绋�) 涓斾笉鏄� 鍋忕鍗�,鎵嶅尮閰嶅浐鍖栫▼搴�
+ curedProgramPackage = ncNodeService.getLastCuredProgramPackageWithoutProcessEdition(programPkgName,startVO.getMachineCode());
+ //璁剧疆鏄惁鏈夊浐鍖栫▼搴忔爣璁�
+ vars.put(FlowContants.HAS_CURED_PROGRAM, curedProgramPackage != null ? FlowContants.Y : FlowContants.N);
+ //宸ュ簭鐗堟鏄惁涓�鑷达紝鏄惁鍦ㄦ湁鏁堟湡鍐�
+ if (curedProgramPackage != null) {
+ vars.put(FlowContants.CURED_NODE_ID, curedProgramPackage.getId());
+ vars.put(FlowContants.CURED_LOCKED, curedProgramPackage.hasLocked()?FlowContants.Y:FlowContants.N);
+ vars.put(FlowContants.IS_PROCESS_EDITION_SAME, StringUtils.equals(curedProgramPackage.getProcessEdition(), startVO.getProcessEdition()) ? FlowContants.Y : FlowContants.N);
+ vars.put("curedProcessEdition", curedProgramPackage.getProcessEdition());
+ vars.put(FlowContants.VALIDITY_PERIOD, curedProgramPackage.withinValidityPeriod() ? FlowContants.Y : FlowContants.N);
+ } else {
+ vars.put(FlowContants.IS_PROCESS_EDITION_SAME, FlowContants.Y);
+ vars.put(FlowContants.VALIDITY_PERIOD, FlowContants.Y);
+ }
+
+ }else{
+ //涓存椂娴佺▼/鍋忕鍗曪紝涓嶅尮閰嶅浐鍖栫▼搴�
+ vars.put(FlowContants.HAS_CURED_PROGRAM,FlowContants.N);
+ }
+ String myProcessName = "璇曞垏涓嬪彂娴佺▼";
+ if(vars.getOrDefault(FlowContants.IS_TEMP_FLOW,FlowContants.N).equals(FlowContants.Y)){
+ myProcessName = "璇曞垏琛ュ厖娴佺▼";
+ }else if(StringUtils.isNotBlank(startVO.getDeviation()) ){
+ myProcessName = "鍋忕鍗�";
+ }else if(vars.getOrDefault(FlowContants.HAS_CURED_PROGRAM,FlowContants.N).equals(FlowContants.Y)){
+ myProcessName = "鍥哄寲涓嬪彂娴佺▼";
+ }
+
+ vars.put(FlowContants.MY_PROCESS_NAME, myProcessName);
String businessKey = "0";//涓氬姟琛╧ey
identityService.setAuthenticatedUserId(String.valueOf(AuthUtil.getUserId()));//璁剧疆娴佺▼鍙戣捣浜�
- ProcessInstance inst = runtimeService.startProcessInstanceByKey(FlowContants.TRY_PROCESS_KEY,businessKey,vars);
-
- if(curedProgramPackage != null) {//瀛樺湪宸插浐鍖栫▼搴忥紝澶嶅埗鍘熸潵鐨勭▼搴忔枃浠躲�傚垱寤鸿妭鐐逛粛鐒跺湪缂栫▼浜哄憳鎻愪氦浠ュ悗
- copyFlowProgramFiles(curedProgramPackage.getProcessInstanceId(),inst.getProcessInstanceId());
+ ProcessInstance inst;
+ if(startVO.isTemporaryFlow()){
+ vars.put(FlowContants.ASSIGNEE,div.getProgrammerId());//绗竴涓敤鎴风紪鍒朵笂浼犳枃浠�
+ inst = runtimeService.startProcessInstanceByKey(FlowContants.APPEND_PROCESS_KEY,businessKey,vars);
+ }else{
+ vars.put(FlowContants.ASSIGNEE,div.getTeamLeaderId());//绗竴涓敤鎴风粍闀�
+ inst = runtimeService.startProcessInstanceByKey(FlowContants.TRY_PROCESS_KEY,businessKey,vars);
}
+ if(curedProgramPackage != null) {//瀛樺湪宸插浐鍖栫▼搴忥紝澶嶅埗鍘熸潵鐨勭▼搴忔枃浠躲��
+ copyFlowProgramFiles(curedProgramPackage.getId(),inst.getProcessInstanceId());
+ curedProgramPackage.setProcessInstanceId(inst.getProcessInstanceId());
+ ncNodeService.updateById(curedProgramPackage);
+ }
+
return inst.getProcessInstanceId();
}
- /**
- * 鏍规嵁鍘熸湁鍥哄寲绋嬪簭鍖呭悕鑺傜偣锛屽鍒朵竴涓紝璧嬩簣鏂扮殑娴佺▼瀹炰緥id
- * @param programPkg 鍘熸湁鍥哄寲鐨勭▼搴忓寘鍚嶈妭鐐�
- * @param processInstanceId 娴佺▼瀹炰緥id
- */
-
- void cloneNodes(NcNode programPkg,String processInstanceId){
- NcNode newProgramPkg = new NcNode();
- BeanUtils.copyProperties(programPkg,newProgramPkg);
- EntityUtil.clearBaseProperties(newProgramPkg);
-
- newProgramPkg.setProcessInstanceId(processInstanceId);
- this.ncNodeService.save(newProgramPkg);
- }
/**
* 澶嶅埗娴佺▼绋嬪簭鏂囦欢
* @param processInstanceId 鏂板惎鍔ㄧ殑娴佺▼id
*/
- private void copyFlowProgramFiles(String oldProcessInstanceId,String processInstanceId) {
- List<FlowProgramFile> fileList = flowProgramFileService.lambdaQuery()
- .eq(FlowProgramFile::getProcessInstanceId,oldProcessInstanceId).list();
+ private void copyFlowProgramFiles(long packageNameNodeId,String processInstanceId) {
+ List<Long> fileIds = ncNodeService.getProgramFilesByPackageId(packageNameNodeId).stream().map(NcNode::getFlowProgramFileId).toList();
+ if(!fileIds.isEmpty()) {
+ List<FlowProgramFile> fileList = flowProgramFileService.lambdaQuery().in(FlowProgramFile::getId, fileIds).list();
- for (FlowProgramFile file : fileList) {
- FlowProgramFile newFile = new FlowProgramFile();
- BeanUtils.copyProperties(file, newFile);
- EntityUtil.clearBaseProperties(newFile);
+ for (FlowProgramFile file : fileList) {
+ FlowProgramFile newFile = new FlowProgramFile();
+ BeanUtils.copyProperties(file, newFile);
+ EntityUtil.clearBaseProperties(newFile);
- newFile.setProcessInstanceId(processInstanceId);
+ newFile.setProcessInstanceId(processInstanceId);
- this.flowProgramFileService.save(newFile);
+ this.flowProgramFileService.save(newFile);
+ }
}
}
- /**
- * 鐢熸垚闆剁粍浠剁紪鍙�
- * 鍥惧彿銆佸浘鍙风増娆°�佸伐搴忓彿銆佸伐搴忓悕绉般�佸伐鑹虹増娆°�佸伐搴忕増娆� 缁勫悎璧锋潵鑾峰緱闆剁粍浠跺彿
- * @param startVO
- * @return
- */
- /*
- String generatePartNo(TaskAssignVO startVO){
- //TODO 杩欎釜鏍煎紡鏈‘瀹氾紝闇�瑕佺‘璁�
- return String.format("%s-%s-%s-%s-%s-%s",
- startVO.getPartNo(),
- startVO.getPartNoEdition(),
- startVO.getProcessNo(),
- startVO.getProcessName(),
- startVO.getCraftEdition(),
- startVO.getProcessEdition());
- }*/
+
}
--
Gitblit v1.9.3