From 6043e2e1c832db2bf7bb1868ae9ca727f7b988b3 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期四, 14 八月 2025 15:10:52 +0800
Subject: [PATCH] 固化流程1
---
blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/ReplaceFlowService.java | 146 ++++++++++++++++++++++++++++++++++--------------
1 files changed, 104 insertions(+), 42 deletions(-)
diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/ReplaceFlowService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/ReplaceFlowService.java
index c1d1eef..a44762d 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/ReplaceFlowService.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/ReplaceFlowService.java
@@ -8,6 +8,9 @@
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.simpleframework.xml.core.Replace;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.oss.OssTemplate;
+import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.mdm.basesetting.machine.MachineService;
import org.springblade.mdm.basesetting.machine.entity.Machine;
@@ -15,14 +18,21 @@
import org.springblade.mdm.flow.entity.FlowProgramFile;
import org.springblade.mdm.flow.entity.ReplaceProgramFile;
import org.springblade.mdm.flow.vo.ReplaceFlowStartVO;
+import org.springblade.mdm.flow.vo.ReplaceUploadVO;
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.program.vo.NcNodeVO;
import org.springblade.mdm.utils.EntityUtil;
+import org.springblade.mdm.utils.ProgramFileNameCheckUtil;
import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -32,20 +42,21 @@
@Service
public class ReplaceFlowService {
private final NcNodeService nodeService;
- private final TaskService taskService;
private final RuntimeService runtimeService;
+ private final TaskService taskService;
private final IdentityService identityService;
private final FlowProgramFileService flowProgramFileService;
private final ReplaceProgramFileService replaceProgramFileService;
- private final MachineService machineService;
-
+ private final NodeDeptQueryService nodeDeptQueryService;
+ private OssTemplate ossTemplate;
public static final String NODE_ID = "nodeId";
/**
* 杞淳锛屽苟璁板綍鑷繁鐨勫娉ㄤ俊鎭�
* @param nodeId 鏇挎崲鐨勮妭鐐筰d
*/
+ /*
@Transactional
- public void pre(long nodeId,String tempInstanceId) {
+ public void prestart(long nodeId,String tempInstanceId) {
List<NcNode> fileNodes = nodeService.lambdaQuery()
.eq(NcNode::getParentId, nodeId)
.eq(NcNode::getIsLastEdition,1)
@@ -58,21 +69,48 @@
//灏嗙幇鏈夋枃浠跺鍒跺埌鐙珛鐨勮〃涓紝鍚庣画浣滀负瀹℃壒鐨勬枃浠讹紝瀹℃壒鐣岄潰璋冪敤鐨勬帴鍙d篃涓嶅悓锛屾渶濂藉崟鐙紑鍙�
for(FlowProgramFile programFile : programFiles) {
- /*
- ReplaceProgramFile replaceProgramFile = new ReplaceProgramFile();
- BeanUtils.copyProperties(programFile, replaceProgramFile);
- EntityUtil.clearBaseProperties(replaceProgramFile);
- replaceProgramFile.setTempId(tempId);
-
- replaceProgramFileService.save(replaceProgramFile);
-
- */
FlowProgramFile newFile = new FlowProgramFile();
BeanUtils.copyProperties(programFile, newFile);
EntityUtil.clearBaseProperties(newFile);
newFile.setProcessInstanceId(tempInstanceId);
flowProgramFileService.save(newFile);
}
+ }
+
+ */
+
+ @Transactional
+ public NcNodeVO pre(long nodeId, String tempInstanceId) {
+
+ List<NcNode> fileNodes = nodeService.lambdaQuery()
+ .eq(NcNode::getParentId, nodeId)
+ .eq(NcNode::getIsLastEdition,1)
+ .eq(NcNode::getNodeType,NcNode.TYPE_PROGRAM_FILE).list();
+ List<Long> fileIds = fileNodes.stream().map(NcNode::getFlowProgramFileId).toList();
+ if(fileIds.isEmpty()){
+ throw new RuntimeException("鏈壘鍒扮▼搴忔枃浠�");
+ }
+ List<FlowProgramFile> programFiles = flowProgramFileService.lambdaQuery()
+ .in(FlowProgramFile::getId, fileIds).list();
+
+
+ //灏嗙幇鏈夋枃浠跺鍒跺埌鐙珛鐨勮〃涓紝鍚庣画浣滀负瀹℃壒鐨勬枃浠讹紝瀹℃壒鐣岄潰璋冪敤鐨勬帴鍙d篃涓嶅悓锛屾渶濂藉崟鐙紑鍙�
+ for(FlowProgramFile programFile : programFiles) {
+ FlowProgramFile newFile = new FlowProgramFile();
+ BeanUtils.copyProperties(programFile, newFile);
+ EntityUtil.clearBaseProperties(newFile);
+ newFile.setProcessInstanceId(tempInstanceId);
+ flowProgramFileService.save(newFile);
+ }
+
+ NcNode node = nodeService.getById(nodeId);
+ NcNodeVO vo = new NcNodeVO();
+ BeanUtils.copyProperties(node, vo);
+ vo.setProcessInstanceId(tempInstanceId);
+
+ vo.setWorkshop(nodeDeptQueryService.getWorkshopNameByMachineCode(node.getMachineCode()));
+
+ return vo;
}
/**
@@ -85,54 +123,78 @@
vars.put(FlowContants.ASSIGNEE,startVO.getAssignee());//绗竴涓鎵圭敤鎴�
vars.put(FlowContants.TITLE,startVO.getTitle());
- NcNode programPackge = nodeService.getById(startVO.getNodeId());
+ NcNode programPackage = nodeService.getById(startVO.getNodeId());
//鏈哄簥缂栧彿
- vars.put(FlowContants.MACHINE_CODE,programPackge.getMachineCode());
+ vars.put(FlowContants.MACHINE_CODE,programPackage.getMachineCode());
//Machine machine = machineService.getByCode(programPackge.getMachineCode());
//鏈哄簥鍨嬪彿
//if(machine != null) {
//vars.put(FlowContants.MACHINE_MODE, programPackge.getMachineMode());
//}
- vars.put(FlowContants.PROCESS_NO,programPackge.getProcessNo());
- vars.put(FlowContants.PROCESS_NAME,programPackge.getProcessName());
- vars.put(FlowContants.PROCESS_EDITION,programPackge.getProcessEdition());
- vars.put(FlowContants.CRAFT_EDITION,programPackge.getCraftEdition());
+ vars.put(FlowContants.PROCESS_NO,programPackage.getProcessNo());
+ vars.put(FlowContants.PROCESS_NAME,programPackage.getProcessName());
+ vars.put(FlowContants.PROCESS_EDITION,programPackage.getProcessEdition());
+ vars.put(FlowContants.CRAFT_EDITION,programPackage.getCraftEdition());
- vars.put(FlowContants.DRAWING_NO,programPackge.getDrawingNo());
- vars.put(FlowContants.DRAWING_NO_EDITION,programPackge.getDrawingNoEdition());
+ vars.put(FlowContants.DRAWING_NO,programPackage.getDrawingNo());
+ vars.put(FlowContants.DRAWING_NO_EDITION,programPackage.getDrawingNoEdition());
- vars.put(FlowContants.PRODUCT_MODEL,programPackge.getProductModel());
+ vars.put(FlowContants.PROGRAM_PACKAGE_NAME,programPackage.getName());
+
+ vars.put(FlowContants.PRODUCT_MODEL,programPackage.getProductModel());
vars.put(NODE_ID, startVO.getNodeId());
+
+ vars.put("comment", startVO.getComment());
identityService.setAuthenticatedUserId(String.valueOf(AuthUtil.getUserId()));//璁剧疆娴佺▼鍙戣捣浜�
ProcessInstance inst = runtimeService.startProcessInstanceByKey(FlowContants.REPLACE_PROCESS_KEY,startVO.getNodeId()+"",vars);
//replaceProgramFileService.lambdaUpdate().eq(ReplaceProgramFile::getTempId,startVO.getTempId()).set(ReplaceProgramFile::getProcessInstanceId,inst.getProcessInstanceId());
+ /*
+ Task startTask = taskService.createTaskQuery()
+ .processInstanceId(inst.getId())
+ .singleResult();
+
+ // 娣诲姞璇勮
+ taskService.addComment(startTask.getId(), inst.getProcessInstanceId(),startVO.getComment());
+ */
flowProgramFileService.lambdaUpdate()
.eq(FlowProgramFile::getProcessInstanceId,startVO.getTempInstanceId())
.set(FlowProgramFile::getProcessInstanceId,inst.getProcessInstanceId()).update();
- /*
- List<ReplaceProgramFile> repFiles = replaceProgramFileService.lambdaQuery().eq(ReplaceProgramFile::getTempId,startVO.getTempId()).list();
-
- for(ReplaceProgramFile repFile : repFiles) {
- FlowProgramFile flowProgramFile = new FlowProgramFile();
- BeanUtils.copyProperties(repFile, flowProgramFile);
- flowProgramFile.setProgramName(programPackge.getName());
-
- EntityUtil.clearBaseProperties(flowProgramFile);
- flowProgramFile.setProcessInstanceId(inst.getId());
- flowProgramFile.setIsCured(0);
-
- flowProgramFileService.save(flowProgramFile);
- }
-
- //鏆傛椂娉ㄩ噴锛屾祴璇曟柟渚�
- replaceProgramFileService.deleteByTempId(startVO.getTempId());
-
- */
- //return inst.getProcessInstanceId();
}
+
+ /**
+ * 涓婁紶绋嬪簭寰愭枃浠讹紙缂栧埗鑺傜偣璋冪敤锛�
+ * @param uploadVO 涓婁紶瀵硅薄
+ */
+ public void uploadReplaceProgramFile(ReplaceUploadVO uploadVO) {
+
+ //FlowProgramProperties progProps= flowCommonService.getProgramProperties(uploadVO.getProcessInstanceId());
+ MultipartFile file = uploadVO.getFile();
+ if(file.getSize() == 0){
+ throw new ServiceException("绋嬪簭鏂囦欢涓嶅彲涓虹┖鏂囦欢");
+ }
+ FlowProgramProperties progProps = new FlowProgramProperties();
+ progProps.setDrawingNo(uploadVO.getDrawingNo());
+ progProps.setProcessNo(uploadVO.getProcessNo());
+ progProps.setProcessEdition(uploadVO.getProcessEdition());
+
+ ProgramFileNameCheckUtil.checkFilename(file.getOriginalFilename(),progProps);
+
+ String programName = NcNodeService.genProgramName(progProps.getDrawingNo(),progProps.getProcessNo());
+
+ BladeFile bfile = ossTemplate.putFile(file);
+
+ FlowProgramFile progFile = new FlowProgramFile();
+ progFile.setName(file.getOriginalFilename());
+ progFile.setOssName(bfile.getName());
+ progFile.setProcessInstanceId(uploadVO.getProcessInstanceId());
+ progFile.setProgramName(programName);
+
+ flowProgramFileService.save(progFile);
+
+ }
}
--
Gitblit v1.9.3