From 79e81a02076cdd1e828eb06029cd51eb37522f42 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期四, 18 九月 2025 09:11:37 +0800
Subject: [PATCH] 首页下载问题修复

---
 blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/DNCSendBackService.java |  367 ++++++++++++++++++++++++++++------------------------
 1 files changed, 198 insertions(+), 169 deletions(-)

diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/DNCSendBackService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/DNCSendBackService.java
index 43455e4..62af8a0 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/DNCSendBackService.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/DNCSendBackService.java
@@ -1,13 +1,13 @@
 
 package org.springblade.mdm.program.service;
 
-import com.alibaba.fastjson.JSONObject;
-import io.netty.util.internal.StringUtil;
 import lombok.AllArgsConstructor;
+import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springblade.core.log.exception.ServiceException;
-import org.springblade.core.mp.base.BizEntity;
 import org.springblade.core.mp.base.BizServiceImpl;
 import org.springblade.core.oss.OssTemplate;
 import org.springblade.core.oss.model.BladeFile;
@@ -16,27 +16,35 @@
 import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.FileUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.mdm.basesetting.machine.entity.Machine;
+import org.springblade.mdm.basesetting.machine.service.MachineService;
+import org.springblade.mdm.commons.service.ParamService;
 import org.springblade.mdm.flow.entity.FlowProgramFile;
 import org.springblade.mdm.flow.service.CureFlowService;
 import org.springblade.mdm.flow.service.FlowCommonService;
-import org.springblade.mdm.flow.service.FlowProgramFileService;
+import org.springblade.mdm.program.entity.DncBackFile;
 import org.springblade.mdm.program.entity.NcNode;
 import org.springblade.mdm.program.entity.NcProgramExchange;
 import org.springblade.mdm.program.mapper.NcProgramExchangeMapper;
+import org.springblade.mdm.program.service.programannotation.*;
 import org.springblade.mdm.program.vo.DncSendBackData;
-import org.springblade.mdm.utils.EntityUtil;
+import org.springblade.mdm.program.vo.DncSendBackFile;
+import org.springblade.mdm.program.vo.ProgramAnnotation;
 import org.springblade.mdm.utils.FileContentUtil;
-import org.springframework.beans.BeanUtils;
+import org.springblade.mdm.utils.ZipTextFileContentUtil;
+import org.springblade.system.pojo.entity.DictBiz;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.*;
+import java.lang.annotation.Annotation;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
 import java.time.Duration;
 import java.util.*;
+import java.util.regex.Pattern;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
@@ -50,14 +58,23 @@
 @AllArgsConstructor
 public class DNCSendBackService extends BizServiceImpl<NcProgramExchangeMapper, NcProgramExchange> {
 	private final CureFlowService cureFlowService;
-	private final FlowProgramFileService flowProgramFileService;
+	private final ProgramAnnotationService programAnnotationService;
 	private final NcNodeService ncNodeService;
 	private final OssTemplate ossTemplate;
 	private final BladeRedis bladeRedis;
 	private final FlowCommonService flowCommonService;
+	private final DncBackFileService dncBackFileService;
+	private final MachineService machineService;
+	private final ParamService paramService;
+	private final MachineAnnotationConfig machineAnnotationConfig;
+
+	/**
+	 * 鍋忕鍗曟枃浠舵湯灏剧殑妯″紡锛歅+鏁板瓧
+	 */
+	private static final String P_NUMBER_PATTERN = "(?i)P\\d+";
 
 	private String getFileKey(){
-		return "dncexpfile-"+ AuthUtil.getUserId();
+		return "dncimpfile-"+ AuthUtil.getUserId();
 	}
 	/**
 	 * dnc鍥炰紶鏂囦欢涓婁紶
@@ -78,10 +95,9 @@
 			//璁剧疆涓�涓紦瀛橈紝2灏忔椂杩囨湡
 			bladeRedis.setEx(getFileKey(),bfile.getName(), Duration.ofHours(2));
 
-			InputStream zipFileInputStream = file.getInputStream();//test
-
-			list = parseProgramListFromZip(zipFileInputStream);
-
+			try(InputStream zipFileInputStream = ossTemplate.statFileStream(bfile.getName());) {
+				list = parseProgramListFromZip(zipFileInputStream);
+			}
 		} catch (IOException e) {
 			log.error("涓婁紶dnc鍥炰紶鏂囦欢澶辫触",e);
 			throw new ServiceException("瑙f瀽DNC鍥炰紶鏁版嵁澶辫触");
@@ -101,7 +117,7 @@
 		Path tempZipFile = createTempFile(inputStream);
 
 		List<String> fileEntryNameList = new ArrayList<>();
-		List<String> dirEntryNameList = new ArrayList<>();
+		List<String> dirEntryNameList = new ArrayList<>();//绋嬪簭鍖呭悕+宸ュ簭鐗堟 浣滀负鏂囦欢澶瑰悕
 		try (ZipFile zipFile = new ZipFile(tempZipFile.toFile())) {
 
 			Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
@@ -117,40 +133,87 @@
 				}
 			}
 
+			List<DictBiz> annotionDictList = programAnnotationService.getAnnotionDictList();
 			NcNode programPackageNode;
 			//鐩綍鍒楄〃锛屽嵆绋嬪簭鍖呭垪琛�
 			for(String entryName : dirEntryNameList){
 				DncSendBackData progData = new DncSendBackData();
-				String packageName = StringUtils.removeEnd(entryName,"/");
+				String folderName = StringUtils.removeEnd(entryName,"/");
+
+				//PackageAndProcessEdition pkgAndEdition = parseProgramPackageFromFolderName(folderName);
+				String packageName = folderName;//pkgAndEdition.getProgramPackageName();
+				//String processEdition = pkgAndEdition.getProcessEdition();
+				/*
+				if(StringUtils.isBlank(packageName) || StringUtils.isBlank(processEdition)){
+					throw new ServiceException("鍖呭唴鏂囦欢澶瑰悕鏍煎紡閿欒锛屽簲璇ヤ负[闆剁粍浠跺彿-宸ュ簭鍙�-宸ュ簭鐗堟]:"+folderName);
+				}*/
+
 				progData.setProgramName(packageName);
-				String statusLine = "";
-				Optional<String> optFilename = fileEntryNameList.stream().filter(n -> n.startsWith(packageName)).findFirst();
+				Optional<String> optFilename = fileEntryNameList.stream().filter(n -> n.startsWith(entryName)).findFirst();
 				if(optFilename.isPresent()){
 					entry = zipFile.getEntry(optFilename.get());
 					InputStream ins = zipFile.getInputStream(entry);
+					ByteArrayInputStream bais = new ByteArrayInputStream(IOUtils.toByteArray(ins));;
 					progData.setFileBackTime(DateUtil.fromInstant(entry.getLastModifiedTime().toInstant()));
-					statusLine = FileContentUtil.readLineAt(ins,2);
+
+					AnnotationProperties defAnnoProperties =AnnotationProperties.getDefault();
+					String statusLine = FileContentUtil.readLineAt(bais,defAnnoProperties.getStatusLineIndex());//鐘舵�佹敞閲婅
+					bais.reset();
+					String sendPathLine = FileContentUtil.readLineAt(bais,defAnnoProperties.getSendPathLineIndex());//鐘舵�佹敞閲婅
+					bais.reset();
+
+
+					if(statusLine.contains("GH")){
+						//鍥哄寲锛屼笉搴斿洖浼狅紝蹇界暐
+						log.warn("鐘舵�亄},涓嶅簲鍥炰紶锛屽拷鐣�",statusLine);
+						continue;
+					}
+
+					Machine machine = this.machineService.getMachineBySendPathAnnotation(sendPathLine);
+					if(machine == null){
+						throw new ServiceException("鏍规嵁涓嬪彂璺緞鏈壘鍒扮▼搴忓搴旂殑鏈哄簥:"+sendPathLine);
+					}
+
 					if(statusLine.contains("SQ")){
 						//璇曞垏
-						programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName);
-					}else if(statusLine.contains("GH")){
-						//鍥哄寲
-						programPackageNode = ncNodeService.getLastEditionCuredProgramPackage(packageName);
+						programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName);//TODO 杩橀渶鏍规嵁鏈哄簥缁勶紙濡備綍鑾峰彇锛熸牴鎹笅鍙戣矾寰勮幏鍙栨満搴婏紝杩涜�岃幏鍙栵級锛�,processEdition
 					}else if(statusLine.contains("PL")){
 						//鍋忕
 						programPackageNode =ncNodeService.getLastEditionDeviationProgramPackage(packageName);
 					}else{
-						throw new ServiceException("鏈壘鍒扮▼搴忔枃浠朵腑鐨勭姸鎬佹敞閲�");
+						//鏌ヨ鏄惁杞﹀簥/鐜板満缂栧埗锛屾槸杞﹀簥鍙互鏀捐繃锛屾寜璇曞垏澶勭悊锛�
+						//TODO 鐜板満缂栧埗鐨勭▼搴忥紝鎵撳寘鏃跺繀椤诲湪鏂囦欢涓鍔犱笅鍙戣矾寰勶紙鍔犲叆鍚庯級
+						programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName);
+						if(programPackageNode!=null){
+							String chechuangVal = paramService.turninngValue();
+							if(StringUtils.equals(machine.getMachineSpec(),chechuangVal)){
+								//杞﹀簥
+								ProgramAnnotation pa = AnnotationUtil.getProgramAnnotationFormat(machine.getControlSystem(),annotionDictList);
+								statusLine = pa.addAnnotation(ProgramAnnotationService.SQ);
+							}
+						}
 					}
+
 					if(programPackageNode != null) {
 						progData.setId(programPackageNode.getId());
 						progData.setProgramNo(programPackageNode.getProgramNo());
+
+						List<String> fileEntryNames  = fileEntryNameList.stream().filter(n -> n.startsWith(packageName)).toList();
+						List<DncSendBackFile> programFiles = new ArrayList<>();
+						fileEntryNames.forEach( filePath ->{
+								DncSendBackFile backFile = new DncSendBackFile();
+								backFile.setEntryName(filePath);
+								backFile.setName(StringUtils.removeStart(filePath,entryName));
+								programFiles.add(backFile);
+						});
+
+						progData.setFiles(programFiles);
 						list.add(progData);
 					}else{
-						throw new ServiceException("鎵句笉鍒扮▼搴忓寘鍚�:"+packageName+statusLine);
+						throw new ServiceException("鎵句笉鍒扮▼搴忓寘鍚�:"+packageName);
 					}
 				}else{
-					throw new ServiceException(entryName+"鍖呬笅鏈壘鍒版枃浠�"+statusLine);
+					throw new ServiceException(entryName+"鍖呬笅鏈壘鍒版枃浠�");
 				}
 
 			}
@@ -159,6 +222,26 @@
 		return list;
 	}
 
+	/**
+	 * 浠庢枃浠跺す鍚嶈В鏋愬嚭绋嬪簭鍖呭悕鍜屽拰宸ュ簭鐗堟
+	 * @param folderName 鏂囦欢澶瑰悕
+	 * @return 缁撴瀯鏁版嵁
+	 */
+	/*
+	PackageAndProcessEdition parseProgramPackageFromFolderName(String folderName){
+		int index = StringUtils.lastIndexOf(folderName,'-');
+		String processEditon = "";
+		String packageName = "";
+		if(index != -1){
+			processEditon = folderName.substring(index+1);
+			packageName = folderName.substring(0,index);
+		}
+
+		PackageAndProcessEdition result = new PackageAndProcessEdition();;
+		result.setProgramPackageName(packageName);
+		result.setProcessEdition(processEditon);
+		return result;
+	}*/
 
 	/**
 	 * 鍏ュ簱鍥炰紶鏂囦欢,骞跺惎鍔ㄥ浐鍖栨祦绋�
@@ -173,31 +256,19 @@
 		String zipFileName = bladeRedis.get(filekey);
 		log.info("filekey={},鏂囦欢鍚�={}",filekey,zipFileName);
 
-		//Map<Long,List<NcNode>> programPackageSubMap = new HashMap<>();
-
 		Map<Long,List<FlowProgramFile>> pkgIdFileMap = dealWithBackFile(zipFileName,acceptIdList);
 
-		///List<NcNode> newProgramPackageList = updateNodeDataByDNCBackData(pkgFileName,idList,programPackageSubMap);
-		//updateNodeDataByDNCBackData(pkgFileName,idList,programPackageSubMap);
-		/*
-		log.info("闇�瑕佸惎鍔ㄥ浐鍖栨祦绋嬬殑绋嬪簭鍖呭悕鏁伴噺:{}",newProgramPackageList.size());
-		for(NcNode pkgNode :newProgramPackageList){
-			exchange = new NcProgramExchange();
-			exchange.setName(pkgNode.getName());
-			exchange.setExchangeType(2);//鍥炰紶
-			exchange.setNcNodeId(pkgNode.getId());
-
-			this.save(exchange);
-		}*/
-		bladeRedis.del(filekey);
-		this.ossTemplate.removeFile(zipFileName);
-		log.info("鍒犻櫎oss鏂囦欢:{}",zipFileName);
-
-		//cureFlowService.startCure(newProgramPackageList,programPackageSubMap);
 		cureFlowService.startCureNew(pkgIdFileMap);
 
 	}
 
+	/**
+	 * 澶勭悊鍥炰紶鏂囦欢
+	 * @param ossFileName
+	 * @param acceptIdList
+	 * @return
+	 * @throws IOException
+	 */
 	private Map<Long, List<FlowProgramFile>> dealWithBackFile(String ossFileName, List<Long> acceptIdList) throws IOException{
 		Map<Long, List<FlowProgramFile>> pkgIdFileMap = new HashMap<>();
 
@@ -218,24 +289,35 @@
 			//鏍规嵁鍐呴儴鏂囦欢锛岃鍙栧拰鍒嗘瀽绋嬪簭鍖呭拰绋嬪簭鏂囦欢鏁版嵁
 			List<String> dirList = entryNameList.stream().filter(s -> s.endsWith("/")).toList();
 			for(String dir : dirList){
-				String programPackageName = StringUtils.removeEnd(dir,"/");
+				String folderName = StringUtils.removeEnd(dir,"/");
+
+				//PackageAndProcessEdition pkgAndEdition = folderName;//parseProgramPackageFromFolderName(folderName);
+				String programPackageName = folderName; //pkgAndEdition.getProgramPackageName();
+
 				Optional<NcNode> optPackageNode = allAcceptPackages.stream().filter(node -> StringUtils.equals(node.getName(),programPackageName)).findFirst();
 
 				if(optPackageNode.isEmpty()){
 					throw new ServiceException("鎵句笉鍒扮▼搴�"+programPackageName);
 				}
-
 				NcNode packageNode = optPackageNode.get();
 				if(packageNode.hasCured()) {
 					throw new ServiceException(programPackageName + "宸茬粡鍥哄寲锛岃鍕块噸澶嶅叆搴撱��");
 				}
-
+				//鍋忕绋嬪簭鍒ゆ柇鏄惁閲嶅鍥炰紶
+				if(packageNode.isDeviationProgram() && packageNode.hasLocked()) {
+					throw new ServiceException(programPackageName + "宸查攣瀹氱殑绋嬪簭涓嶅彲浠ュ啀娆″洖浼犮��");
+				}
 				//妫�鏌ユ槸鍚﹀湪瀹℃壒杩囩▼涓�
-				//鏍规嵁鑺傜偣淇℃伅鏌ヨ娴佺▼
 				boolean active = flowCommonService.isProcessInstanceActive(packageNode.getProcessInstanceId());
 				if(active){
-					throw new ServiceException(programPackageName+"姝e湪瀹℃壒涓紝璇峰嬁閲嶅鍏ュ簱銆�");
+					throw new ServiceException(programPackageName+"姝e湪瀹℃壒涓紝璇峰嬁绛夊緟瀹℃壒瀹屾垚銆�");
 				}
+
+				//楠岃瘉閮借繃浜嗭紝淇濆瓨dncbackFile
+				DncBackFile backFile = new DncBackFile();
+				backFile.setNcNodeId(packageNode.getId());
+				backFile.setOssName(ossFileName);
+				dncBackFileService.save(backFile);
 
 				List<FlowProgramFile> flowFiles = new ArrayList<>();
 				//鏌ユ壘鍖呬笅鐨勬枃浠舵暟鎹�,
@@ -245,7 +327,7 @@
 					if(!entryName.endsWith("/")){
 						//瀹為檯鐨勬枃浠�
 						String fileName = StringUtils.removeStart(entryName,dir);//鍘婚櫎鏂囦欢鍚嶈矾寰勯儴鍒�
-
+						fileName = removeDeviationPart(fileName);
 						try {
 							FlowProgramFile newFlowFile = new FlowProgramFile();
 							newFlowFile.setProgramName(packageNode.getName());
@@ -266,120 +348,29 @@
 
 				pkgIdFileMap.put(packageNode.getId(),flowFiles);
 			}
-
 		}
 
 		return pkgIdFileMap;
 	}
 
-	/**
-	 * 鏇存柊鑺傜偣锛屼富瑕佹槸鍒涘缓 绋嬪簭鍖呭悕 鐨勬柊鐗堟湰銆�
-	 * @param pkgFileName zip鏂囦欢鍚�
-	 * @param programPackageIdList 绋嬪簭鍖呭悕 鑺傜偣鐨刬d鍒楄〃
-	 * @param programPackageSubMap 鏂扮殑 绋嬪簭鍖呰妭鐐筰d -> =鏂囦欢鍒楄〃 map锛岀敤浜庡洖浼犳暟鎹�
-	 * @throws IOException 璁块棶鏂囦欢寮傚父
-	 */
-	List<NcNode> updateNodeDataByDNCBackData(String pkgFileName, List<Long> programPackageIdList,Map<Long,List<NcNode>> programPackageSubMap) throws IOException {
-		InputStream inputStream = this.ossTemplate.statFileStream(pkgFileName);
-		Path tempZipFile = createTempFile(inputStream);
-		List<NcNode> newProgramPackageNodeList = new ArrayList<>();
-		List<String> entryNameList = new ArrayList<>();
-
-		ZipEntry entry;
-		try (java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(tempZipFile.toFile())) {
-			Enumeration<? extends ZipEntry> entries = zipFile.entries();
-			while(entries.hasMoreElements()) {
-				entry = entries.nextElement();
-				entryNameList.add(entry.getName());
+	String removeDeviationPart(String filename){
+		String finalFilename  = filename;
+		//鍘绘帀鏂囦欢鍚嶄腑鍙兘甯︽湁鐨勫亸绂诲崟閮ㄥ垎锛�-P[搴忓彿]
+		String ext = FilenameUtils.getExtension(filename);
+		String dotExt = StringUtils.isNotBlank(ext)?"."+ext:ext;//甯︾偣鐨勬墿灞曞悕
+		String notExtName = StringUtils.removeEnd(filename,dotExt);
+		int idx = notExtName.lastIndexOf("-");
+		if(idx != -1){
+			String endPart = notExtName.substring(idx+1);
+			//Pattern.CASE_INSENSITIVE
+			boolean containsPld = endPart.matches(P_NUMBER_PATTERN);
+			if(containsPld){
+				finalFilename = notExtName.substring(0, idx)+dotExt;
 			}
-			log.info("allentrynames:{}",entryNameList);
-
-			List<NcNode> allAcceptPackages =  this.ncNodeService.lambdaQuery().in(NcNode::getId,programPackageIdList).list();
-			//鏍规嵁鍐呴儴鏂囦欢锛岃鍙栧拰鍒嗘瀽绋嬪簭鍖呭拰绋嬪簭鏂囦欢鏁版嵁
-			List<String> dirList = entryNameList.stream().filter(s -> s.endsWith("/")).toList();
-			for(String dir : dirList){
-				String programPackageName = StringUtils.removeEnd(dir,"/");
-				Optional<NcNode> optPackageNode = allAcceptPackages.stream().filter(node -> StringUtils.equals(node.getName(),programPackageName)).findFirst();
-
-				if(optPackageNode.isEmpty()){
-					throw new ServiceException("鎵句笉鍒扮▼搴�"+programPackageName);
-				}
-
-				NcNode packageNode = optPackageNode.get();
-				if(packageNode.hasCured()) {
-					throw new ServiceException(programPackageName + "宸茬粡鍥哄寲锛岃鍕块噸澶嶅叆搴撱��");
-				}
-
-				//妫�鏌ユ槸鍚﹀湪瀹℃壒杩囩▼涓�
-				//鏍规嵁鑺傜偣淇℃伅鏌ヨ娴佺▼
-				boolean active = flowCommonService.isProcessInstanceActive(packageNode.getProcessInstanceId());
-				if(active){
-					throw new ServiceException(programPackageName+"姝e湪瀹℃壒涓紝璇峰嬁閲嶅鍏ュ簱銆�");
-				}
-
-				NcNode newProgramPkg = new NcNode();
-				BeanUtils.copyProperties(packageNode, newProgramPkg);
-				EntityUtil.clearBaseProperties(newProgramPkg);
-				newProgramPkg.setIsLastEdition(1);
-				ncNodeService.save(newProgramPkg);
-				newProgramPackageNodeList.add(newProgramPkg);
-
-				//鏃ф暟鎹洿鏂颁负鑰佺増鏈�
-				packageNode.setIsLocked(1);//鏃х増鑷姩閿佸畾
-				packageNode.setIsLastEdition(0);;
-				ncNodeService.updateById(packageNode);
-
-				//List<FlowProgramFile> newFlowFiles = new ArrayList<>();
-				List<NcNode> newProgramNodes = new ArrayList<>();
-				//鏌ユ壘鍖呬笅鐨勬枃浠舵暟鎹�,
-				entryNameList.stream().filter(s -> s.startsWith(dir)).forEach(entryName -> {
-					log.info("{}涓嬬殑鏂囦欢锛歿}",dir,entryName);
-					if(!entryName.endsWith("/")){
-						//瀹為檯鐨勬枃浠�
-						String fileName = StringUtils.removeStart(entryName,dir);//鍘婚櫎鏂囦欢鍚嶈矾寰勯儴鍒�
-						NcNode oldProgramNode = this.ncNodeService.getLastEditionProgramFile(fileName,packageNode.getId());
-						if(oldProgramNode == null){
-							log.info("{}鎵句笉鍒扮▼搴忔枃浠�",entryName);
-							throw new ServiceException(programPackageName+"涓嬫壘涓嶅埌绋嬪簭鏂囦欢"+fileName);
-						}
-
-						//鍒涘缓鏂扮増鏈殑绋嬪簭鑺傜偣
-						NcNode newProgramNode = new NcNode();
-						BeanUtils.copyProperties(oldProgramNode, newProgramNode);
-						EntityUtil.clearBaseProperties(newProgramNode);
-						newProgramNode.setIsLastEdition(1);
-						newProgramNode.setParentId(newProgramPkg.getId());
-						newProgramNode.setParentIds(newProgramPkg.getParentIds()+","+newProgramPkg.getId());
-
-						FlowProgramFile oldFlowFile = flowProgramFileService.getById(newProgramNode.getFlowProgramFileId());
-
-						FlowProgramFile newFlowFile = new FlowProgramFile();
-						BeanUtils.copyProperties(oldFlowFile, newFlowFile);
-						newFlowFile.setProcessInstanceId(null);//鍏堢疆涓虹┖锛屽惎鍔ㄦ祦绋嬪悗璁剧疆璇ュ��
-						EntityUtil.clearBaseProperties(newFlowFile);
-
-						try {
-							InputStream ins = zipFile.getInputStream(zipFile.getEntry(entryName));
-							BladeFile newOssFile = ossTemplate.putFile("mdm",fileName,ins);
-							newFlowFile.setOssName(newOssFile.getName());
-						} catch (IOException e) {
-							throw new RuntimeException(e);
-						}
-						newProgramNode.setFlowProgramFile(newFlowFile);
-						newProgramNode.setVersionNumber(oldProgramNode.genNewVersionNumber());
-						newProgramNodes.add(newProgramNode);
-						//鏃ц妭鐐瑰鐞嗭紝鍜嬪姙锛熷鏋滃鍑哄伐鎺х綉 閲嶅瀵煎嚭鍛紵锛宨sLastEdition涓嶇敤璁剧疆浜嗭紝鍥犱负 绋嬪簭鍖呰妭鐐� 鏄柊鐨�
-					}
-				});
-
-				programPackageSubMap.put(newProgramPkg.getId(),newProgramNodes);
-			}
-
 		}
 
-		return newProgramPackageNodeList;
+		return finalFilename;
 	}
-
 	/**
 	 * 鍒涘缓涓�涓复鏃秡ip鏂囦欢
 	 * @param inputStream 鏂囦欢鐨勮緭鍏ユ祦
@@ -394,20 +385,58 @@
 
 		return tempFile;
 	}
-	void setBaseProperties(BizEntity entity, JSONObject jsonObject){
-		entity.setCreateTime(jsonObject.getDate("createTime"));
-		entity.setUpdateTime(jsonObject.getDate("updateTime"));
-		entity.setStatus(jsonObject.getInteger("status"));
-		entity.setCreateUser(jsonObject.getLong("createUser"));
-		entity.setUpdateUser(jsonObject.getLong("updateUser"));
+
+	/**
+	 * 鑾峰彇鍥炰紶鏂囦欢鐨勫唴瀹�
+	 * @param entryName 鏂囦欢鍦ㄥ帇缂╁寘鍐呯殑璺緞
+	 * @return 鏂囦欢鍐呭鏂囨湰
+	 */
+	public String getEntryFileContent(String entryName) throws IOException {
+		String result  = "";
+		String zipFileName = bladeRedis.get(getFileKey());
+		return ZipTextFileContentUtil.getTextContent(this.ossTemplate.statFileStream(zipFileName),entryName);
+
+		/*
+		try(InputStream inputStream = this.ossTemplate.statFileStream(zipFileName);){
+			Path tempZipFile = createTempFile(inputStream);
+
+			ZipEntry entry;
+			try (java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(tempZipFile.toFile())) {
+				Enumeration<? extends ZipEntry> entries = zipFile.entries();
+				while (entries.hasMoreElements()) {
+					entry = entries.nextElement();
+					if (!entryName.equals(entry.getName())) {
+						continue;
+					}
+					try (InputStream fileIns = zipFile.getInputStream(zipFile.getEntry(entryName))) {
+						ByteArrayInputStream bos = new ByteArrayInputStream(fileIns.readAllBytes());
+						boolean isText = StringUtils.endsWithIgnoreCase(entryName,".txt") || StringUtils.endsWithIgnoreCase(entryName,".nc")|| StringUtils.endsWithIgnoreCase(entryName,".xml");
+						if(!isText) {
+							isText = FileContentUtil.isTextFile(bos);
+						}
+						if (isText) {
+							bos.reset();
+							result = FileContentUtil.getContentFromStream(bos);
+						} else {
+							result = "<闈炴枃鏈枃浠�>";
+						}
+					}
+
+				}
+			}
+		}
+
+		return result;*/
 	}
-	/*
-	void clearBaseProperties(BizEntity entity){
-		entity.setId(null);
-		entity.setCreateTime(null);
-		entity.setUpdateTime(null);
-		entity.setStatus(null);
-		entity.setCreateUser(null);
-		entity.setUpdateUser(null);
-	}*/
+
+}
+
+@Data
+class PackageAndProcessEdition{
+	private String programPackageName;
+	private String processEdition;
+
+	public String programName(){
+		return programPackageName+"-"+processEdition;
+	}
 }

--
Gitblit v1.9.3