From 3baca21e0e6563f8379359ef2ba78c224eb4bc80 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期二, 23 九月 2025 22:45:51 +0800
Subject: [PATCH] 修复审批表,确认表内容
---
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcNodeAutoCreateService.java | 137 +++++++++++++++++++++++++++------------------
1 files changed, 81 insertions(+), 56 deletions(-)
diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcNodeAutoCreateService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcNodeAutoCreateService.java
index 7fecd89..1536d58 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcNodeAutoCreateService.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcNodeAutoCreateService.java
@@ -5,12 +5,14 @@
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.Func;
-import org.springblade.mdm.flow.constants.FlowContants;
+import org.springblade.mdm.flow.constants.FlowConstant;
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.service.FlowProgramProperties;
import org.springblade.mdm.program.entity.NcNode;
+import org.springblade.mdm.utils.EntityUtil;
+import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -29,21 +31,23 @@
private final NcNodeService ncNodeService;
private final FlowCommonService flowCommonService;
private final FlowProgramFileService flowProgramFileService;
- private final ProgramSeqService programSeqService;
+
public static final String TRY_NAME = "璇曞垏";
public static final String CURE_NAME = "鍥哄寲";
- public static final String DEVIATION_NAME = "鍋忕";
+ public static final String DEVIATION_NAME = "涓存椂鏇存敼鍗�";
/**
* 鍒涘缓鏍戝埌鏈哄簥绾у埆
* @param programProperties 绋嬪簭灞炴��
*/
@Transactional
- public NcNode createNodeTreeToMachine(FlowProgramProperties programProperties) {
+ public NcNode createNodeTreeToMachineGroup(FlowProgramProperties programProperties) {
NcNode root;
- if(programProperties.getProcessDefinitionKey().equals(FlowContants.TRY_PROCESS_KEY)){
- if(Func.isEmpty(programProperties.getDeviation())){
- //璇曞垏
+ if(programProperties.getProcessDefinitionKey().equals(FlowConstant.TRY_PROCESS_KEY)){
+ if(Func.isEmpty(programProperties.getDeviation()) ||
+ (FlowConstant.Y.equals(programProperties.getHasCuredProgram()) && FlowConstant.N.equals(programProperties.getCureProgramUseable()))){
+ //鏅�氳瘯鍒囷紝鎴栬�呮湁鍥哄寲涓嶅彲鐢紝寤虹珛璇曞垏鑺傜偣
+ //璇曞垏鏍硅妭鐐�
root = rootNodeByName(TRY_NAME);
if (root == null) {
root = createTryNode();
@@ -55,7 +59,7 @@
root = createDeviationNode();
}
}
- }else if(programProperties.getProcessDefinitionKey().equals(FlowContants.CURE_PROCESS_KEY)){
+ }else if(programProperties.getProcessDefinitionKey().equals(FlowConstant.CURE_PROCESS_KEY)){
root = rootNodeByName(CURE_NAME);
if(root == null){
root = createCureNode();
@@ -64,74 +68,61 @@
throw new ServiceException("娴佺▼瀹氫箟涓嶅湪鑼冨洿鍐�");
}
//鍒涘缓浜у搧鍨嬪彿鑺傜偣
- NcNode productModelNode = createNodeIfNotExists(programProperties.getProductModel(),NcNode.TYPE_PRODUCT_MODEL, root,programProperties);
+ NcNode productModelNode = createNodeIfNotExists(programProperties.getProductModel(),NcNode.TYPE_PRODUCT_MODEL, root,programProperties,null);
//闆剁粍浠跺彿鑺傜偣
- NcNode drawingNoNode = createNodeIfNotExists(programProperties.getDrawingNo(),NcNode.TYPE_DRAWING_NO, productModelNode,programProperties);
+ NcNode drawingNoNode = createNodeIfNotExists(programProperties.getDrawingNo(),NcNode.TYPE_DRAWING_NO, productModelNode,programProperties,null);
//宸ヨ壓鐗堟鑺傜偣
//NcNode craftEditionNode = createNodeIfNotExists(programProperties.getCraftEdition(),NcNode.TYPE_CRAFT_EDITION, drawingNoNode,programProperties);
//宸ュ簭鍙疯妭
- NcNode processNoNode = createNodeIfNotExists(programProperties.getProcessNo(),NcNode.TYPE_PROCESS_NO, drawingNoNode,programProperties);
+ NcNode processNoNode = createNodeIfNotExists(programProperties.getProcessNo(),NcNode.TYPE_PROCESS_NO, drawingNoNode,programProperties,null);
//宸ュ簭鐗堟鑺傜偣
- NcNode processEditionNode = createNodeIfNotExists(programProperties.getProcessEdition(),NcNode.TYPE_PROCESS_EDITION, processNoNode,programProperties);
+ NcNode processEditionNode = createNodeIfNotExists(programProperties.getProcessEdition(),NcNode.TYPE_PROCESS_EDITION, processNoNode,programProperties,null);
//鍔犲伐鏈哄簥鑺傜偣
- return createNodeIfNotExists(programProperties.getMachineCode(),NcNode.TYPE_MACHINE_CODE, processEditionNode,programProperties);
+ return createNodeIfNotExists(programProperties.getMachineGroupCode(),NcNode.TYPE_MACHINE_GROUP, processEditionNode,programProperties,null);
}
+
/**
* 鏍规嵁娴佺▼淇℃伅锛岃嚜鍔ㄥ垱寤哄悇涓妭鐐�,鍖呮嫭绋嬪簭鑺傜偣
* @param programProperties 绋嬪簭灞炴��
+ * @return 绋嬪簭鍖呰妭鐐瑰疄渚�
*/
@Transactional
- public void createNodeTreeWithProgram(FlowProgramProperties programProperties) {
- //,int rootNodeCatgory = 1:璇曞垏锛�2鍥哄寲锛�3鍋忕
+ public NcNode createNodeTreeWithProgram(FlowProgramProperties programProperties) {
NcNode programPkdNode = createTreeToPackage(programProperties);
//鍒犻櫎涔嬪墠鍒涘缓杩囩殑绋嬪簭鏂囦欢鑺傜偣(鍥犱负閲嶅鍦ㄧ紪鍒惰妭鐐瑰鎵�)锛岄伩鍏嶉噸澶嶆暟鎹�
- //this.ncNodeService.lambdaUpdate().eq(NcNode::getParentId, programPkdNode.getId()).remove();
- ncNodeService.deleteSubNodes(programPkdNode.getId());
+ //ncNodeService.deleteSubNodes(programPkdNode.getId());//del 0923 18:07
- List<FlowProgramFile> programFiles = flowProgramFileService.lambdaQuery().eq(FlowProgramFile::getProcessInstanceId, programProperties.getProcessInstanceId()).list();
+ List<FlowProgramFile> programFiles = flowProgramFileService.listByProcessInstanceId(programProperties.getProcessInstanceId());
for (FlowProgramFile programFile : programFiles) {
- if(programFile.isProgram()) {
- createProgramFileNode(programFile, programPkdNode, programProperties);
- }
+ createProgramFileNode(programFile, programPkdNode);//鎵�鏈夋枃浠跺寘鎷▼搴忓拰鍏朵粬锛岄兘闇�瑕佸缓绔嬭妭鐐�
}
- createOtherNode(programFiles);
+
+ return programPkdNode;
}
- void createOtherNode(List<FlowProgramFile> programFiles){
-//111mqita 鑺傜偣
- }
+
/**
* 寤虹珛绋嬪簭鏂囦欢鑺傜偣
* @param programFile 娴佺▼鏂囦欢
* @param programPkdNode 绋嬪簭鍖呭悕 鑺傜偣锛岀▼搴忚妭鐐圭殑 涓婄骇
- * @param programProperties 娴佺▼鍙戣捣鐨勭▼搴忕殑灞炴��
+ * @param versionNumber 鐗堟湰鍙�
*/
- private void createProgramFileNode(FlowProgramFile programFile, NcNode programPkdNode, FlowProgramProperties programProperties) {
+ private void createProgramFileNode(FlowProgramFile programFile, NcNode programPkdNode) {
//姝ゅ搴旈伩鍏嶉噸澶嶅垱寤�
NcNode node = new NcNode();
+ BeanUtils.copyProperties(programPkdNode, node);
+ EntityUtil.clearBaseProperties(node);
+
node.setNodeType(NcNode.TYPE_PROGRAM_FILE);
node.setName(programFile.getName());//鏂囦欢鍚嶏紝
node.setIsLastEdition(1);
- node.setDrawingNo(programPkdNode.getDrawingNo());
- node.setDrawingNoEdition(programProperties.getDrawingNoEdition());
- node.setCraftEdition(programProperties.getCraftEdition());
- node.setProcessName(programProperties.getProcessName());
- node.setProcessNo(programProperties.getProcessNo());
- node.setProcessEdition(programProperties.getProcessEdition());
- node.setMachineCode(programProperties.getMachineCode());
- node.setProductModel(programProperties.getProductModel());
+
node.setFlowProgramFileId(programFile.getId());
- node.setVersionNumber(1);
+
node.setParentId(programPkdNode.getId());
node.setParentIds(programPkdNode.getParentIds()+","+programPkdNode.getId());
- /*
- if("program".equals(programFile.getFileType())){
- }else{
- //鍏朵粬鏂囦欢锛屽拰绋嬪簭鍖呭悕鍚岀骇骞跺垪
-
- }*/
ncNodeService.save(node);
}
@@ -143,21 +134,48 @@
*/
@Transactional
public NcNode createTreeToPackage(FlowProgramProperties programProperties) {
- NcNode machineCodeNode = createNodeTreeToMachine(programProperties);
- NcNode processEditionNode = this.ncNodeService.getById(machineCodeNode.getParentId());
- //鑾峰彇宸ュ簭鐗堟涓嬪叾浠栨満搴婂悕锛屽瓨鍦ㄥ垯鍒犻櫎
- ncNodeService.lambdaUpdate().eq(NcNode::getNodeType,NcNode.TYPE_MACHINE_CODE)
- .eq(NcNode::getParentId,processEditionNode.getId()).eq(NcNode::getIsLastEdition,1)
- .ne(NcNode::getName,machineCodeNode.getName()).remove();
+ NcNode machineGroupNode = createNodeTreeToMachineGroup(programProperties);
//淇濇寔鍔犲伐鏈哄簥鏄渶鏂颁笅鍙戜换鍔$殑鏈哄簥锛屼笉鏄柊寤轰竴涓満搴婅妭鐐癸紝鎻掑彊宸ュ簭鐗堟涓嬫槸鍚︽湁鍏朵粬鐨勬満搴婏紙闆朵欢鍙蜂竴鑷达紝宸ュ簭鍙凤紝宸ュ簭鐗堟涓�鑷达級
- //鑾峰彇
- //鍔犲伐鏈哄簥鍜岀▼搴忓寘鍚嶅湪鍚屼竴绾ц妭鐐�,鍚屽湪宸ュ簭鐗堟涓嬬骇
- String programPkgName = NcNodeService.genProgramName(programProperties.getDrawingNo(),programProperties.getProcessNo());
- return createNodeIfNotExists(programPkgName ,NcNode.TYPE_PROGRAM_PACKAGE, processEditionNode,programProperties);
+ return createProgramPackageNode(programProperties,machineGroupNode);
+
+ //return createNodeIfNotExists(programPkgName ,NcNode.TYPE_PROGRAM_PACKAGE, machineGroupNode,programProperties,versionNumber);
}
+ /**
+ * 鍒涘缓绋嬪簭鍖呭悕鑺傜偣
+ * @param programProperties
+ * @param parentNode
+ * @return
+ */
+ NcNode createProgramPackageNode(FlowProgramProperties programProperties,NcNode parentNode){
+ NcNode node = new NcNode();
+
+ node.setNodeType(NcNode.TYPE_PROGRAM_PACKAGE);
+ node.setName(NcNodeService.genProgramName(programProperties.getDrawingNo(),programProperties.getProcessNo(),programProperties.getProcessEdition()));
+ node.setProcessInstanceId(programProperties.getProcessInstanceId());
+ node.setDrawingNo(programProperties.getDrawingNo());
+ node.setDrawingNoEdition(programProperties.getDrawingNoEdition());
+ node.setCraftEdition(programProperties.getCraftEdition());
+ node.setProcessNo(programProperties.getProcessNo());
+ node.setProcessEdition(programProperties.getProcessEdition());
+ node.setProcessName(programProperties.getProcessName());
+ node.setMachineCode(programProperties.getMachineCode());
+ node.setMachineGroupCode(programProperties.getMachineGroupCode());
+ node.setProductModel(programProperties.getProductModel());
+
+ node.setDeviation(programProperties.getDeviation());
+ node.setProgramNo(programProperties.getProgramNo());
+ //node.setVersionNumber(versionNumber);
+
+ node.setParentId(parentNode.getId());
+ node.setParentIds(parentNode.subNodeParentIds());
+
+ ncNodeService.save(node);
+
+ return node;
+ }
/**
* 涓嶅瓨鍦ㄥ垯鍒涘缓鑺傜偣
* @param name 鑺傜偣鍚嶇О
@@ -166,7 +184,7 @@
* @param programProperties 娴佺▼绋嬪簭灞炴��
* @return 鍒涘缓鎴栧凡瀛樺湪鐨勮妭鐐规垨
*/
- NcNode createNodeIfNotExists(String name,String nodeType,NcNode parentNode,FlowProgramProperties programProperties) {
+ NcNode createNodeIfNotExists(String name,String nodeType,NcNode parentNode,FlowProgramProperties programProperties,Integer versionNumber) {
Optional<NcNode> nodeOpt = this.ncNodeService.lambdaQuery().eq(NcNode::getName,name).eq(NcNode::getNodeType,nodeType)
.eq(NcNode::getParentId,parentNode.getId()).eq(NcNode::getIsLastEdition,1).oneOpt();
if(nodeOpt.isPresent()){
@@ -177,13 +195,15 @@
ncNode.setParentId(parentNode.getId());
ncNode.setParentIds(parentNode.getParentIds() + "," + parentNode.getId());
ncNode.setNodeType(nodeType);
- ncNode.setVersionNumber(1);
+ if(versionNumber == null){
+ ncNode.setVersionNumber(1);
+ }else{
+ ncNode.setVersionNumber(versionNumber);
+ }
//绋嬪簭鍖呰妭鐐瑰拰绋嬪簭鏂囦欢鑺傜偣鏁版嵁
if(NcNode.TYPE_PROGRAM_PACKAGE.equals(nodeType) || NcNode.TYPE_PROGRAM_FILE.equals(nodeType)){
- String programNo = programSeqService.generageProgramNo();
- ncNode.setProgramNo(programNo);
ncNode.setProcessInstanceId(programProperties.getProcessInstanceId());
ncNode.setDrawingNo(programProperties.getDrawingNo());
ncNode.setDrawingNoEdition(programProperties.getDrawingNoEdition());
@@ -192,9 +212,14 @@
ncNode.setProcessEdition(programProperties.getProcessEdition());
ncNode.setProcessName(programProperties.getProcessName());
ncNode.setMachineCode(programProperties.getMachineCode());
+ ncNode.setMachineGroupCode(programProperties.getMachineGroupCode());
ncNode.setProductModel(programProperties.getProductModel());
ncNode.setDeviation(programProperties.getDeviation());
+
+ if(NcNode.TYPE_PROGRAM_PACKAGE.equals(nodeType)) {//绋嬪簭鍖呰妭鐐癸紝鍒嗛厤绋嬪簭缂栧彿
+ ncNode.setProgramNo(programProperties.getProgramNo());
+ }
}
ncNode.setIsLastEdition(1);
--
Gitblit v1.9.3