From a117bd6e8ca607537e4f1889b474bcb0e24ba32b Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期四, 21 八月 2025 15:10:21 +0800
Subject: [PATCH] 导出程序包内文件夹增加工序版次

---
 blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcNodeService.java |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 52 insertions(+), 7 deletions(-)

diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcNodeService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcNodeService.java
index 4255df9..fbfc9d6 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcNodeService.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcNodeService.java
@@ -5,6 +5,8 @@
 import lombok.extern.slf4j.Slf4j;
 import org.springblade.core.mp.base.BizServiceImpl;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.mdm.basesetting.machine.MachineService;
+import org.springblade.mdm.basesetting.machine.entity.Machine;
 import org.springblade.mdm.program.entity.NcNode;
 import org.springblade.mdm.program.mapper.NcNodeMapper;
 import org.springblade.mdm.program.vo.*;
@@ -27,6 +29,7 @@
 @AllArgsConstructor
 public class NcNodeService extends BizServiceImpl<NcNodeMapper, NcNode> {
 
+	private final MachineService machineService;
 
 	public void saveNcCode(NcNodeVO vo) {
 		NcNode ncNode = new NcNode();
@@ -186,13 +189,13 @@
 	 * @param name 鑺傜偣鍚嶇О
 	 * @return 鏈�鏂扮増鏈▼搴忔姤鍚嶈妭鐐�
 	 */
-	public NcNode getLastEditionTryingProgramPackage(String name){
+	public NcNode getLastEditionTryingProgramPackage(String name,String processEdition){
 		//.or(NcNode::getIsCured,0)
 		List<NcNode> pkgList = lambdaQuery().eq(NcNode::getNodeType,NcNode.TYPE_PROGRAM_PACKAGE)
 			.eq(NcNode::getName, name).and(i->{
 				i.eq(NcNode::getIsCured, 0).or().isNull(NcNode::getIsCured);
 			}).likeRight(NcNode::getParentIds,"0,1,")
-			.eq(NcNode::getIsLastEdition,1).orderByDesc(NcNode::getCreateTime).list();
+			.eq(NcNode::getIsLastEdition,1).eq(NcNode::getProcessEdition,processEdition).orderByDesc(NcNode::getCreateTime).list();
 
 		if(pkgList.isEmpty()){
 			return null;
@@ -224,7 +227,7 @@
 	 */
     public List<NcNode> getNodeHistory(NcNode pkgNode) {
 		return this.lambdaQuery().eq(NcNode::getParentId,pkgNode.getParentId())
-			.eq(NcNode::getName,pkgNode.getName()).list();
+			.eq(NcNode::getName,pkgNode.getName()).list();//.ne(NcNode::getId,pkgNode.getId())
     }
 
 	/**
@@ -242,9 +245,32 @@
 	 * @param programPkgName
 	 * @return
 	 */
-	public NcNode getLastEditionCuredProgramPackage(String programPkgName) {
+	public NcNode getLastEditionCuredProgramPackage(String programPkgName,String processEdition) {
 		List<NcNode> nodes = lambdaQuery().eq(NcNode::getNodeType,NcNode.TYPE_PROGRAM_PACKAGE)
 			.eq(NcNode::getName, programPkgName).likeRight(NcNode::getParentIds,"0,2,").eq(NcNode::getIsCured,1)
+			.eq(NcNode::getProcessEdition, processEdition)
+			.eq(NcNode::getIsLastEdition,1).list();
+
+		if(nodes.isEmpty()){
+			return null;
+		}else {
+			return nodes.get(0);
+		}
+	}
+
+	/**
+	 * 鑾峰彇鏈�鏂扮増鏈殑 宸插浐鍖栬妭鐐�
+	 * @param programPkgName 绋嬪簭鍖呭悕
+	 * @param machineCode 鏈哄簥缂栧彿
+	 * @return
+	 */
+	public NcNode getCuredProgramPackage(String programPkgName,String machineCode) {
+		Machine machine = machineService.getByCode(machineCode);
+		List<Machine> sameGroupMachines = machineService.lambdaQuery().eq(Machine::getMachineGroupCode,machine.getMachineGroupCode()).list();
+		List<String> machineCodesInGroup = sameGroupMachines.stream().map(Machine::getCode).toList();
+		List<NcNode> nodes = lambdaQuery().eq(NcNode::getNodeType,NcNode.TYPE_PROGRAM_PACKAGE)
+			.eq(NcNode::getName, programPkgName).likeRight(NcNode::getParentIds,"0,2,").eq(NcNode::getIsCured,1)
+			.in(!machineCodesInGroup.isEmpty(),NcNode::getMachineCode,machineCodesInGroup)
 			.eq(NcNode::getIsLastEdition,1).list();
 
 		if(nodes.isEmpty()){
@@ -259,9 +285,11 @@
 	 * @param programPkgName 绋嬪簭鍖呭悕
 	 * @return 鍋忕鐨勭▼搴忚妭鐐�
 	 */
-	public NcNode getLastEditionDeviationProgramPackage(String programPkgName) {
+	public NcNode getLastEditionDeviationProgramPackage(String programPkgName,String processEdition) {
 		List<NcNode> nodes = lambdaQuery().eq(NcNode::getNodeType,NcNode.TYPE_PROGRAM_PACKAGE)
-			.eq(NcNode::getName, programPkgName).likeRight(NcNode::getParentIds,"0,3,")
+			.eq(NcNode::getName, programPkgName)
+			.eq(NcNode::getProcessEdition, processEdition)
+			.likeRight(NcNode::getParentIds,"0,3,")
 			.eq(NcNode::getIsLastEdition,1).list();
 
 		if(nodes.isEmpty()){
@@ -306,8 +334,25 @@
 	@Transactional
 	public void upgradeVersionNumber(Long nodeId) {
 		NcNode node = this.getById(nodeId);
-		node.upgradeVersionNUmber();
+		node.upgradeVersionNumber();
 		this.updateById(node);
 
 	}
+
+	/**
+	 * 閿佸畾鑺傜偣
+	 * @param id 绋嬪簭鍖呰妭鐐筰d
+	 */
+	@Transactional
+    public void lock(Long id) {
+		NcNode node = this.getById(id);
+		node.lock();
+		this.updateById(node);
+    }
+	@Transactional
+	public void unlock(Long id) {
+		NcNode node = this.getById(id);
+		node.unlock();
+		this.updateById(node);
+	}
 }

--
Gitblit v1.9.3