From 9810791a41d381a10451f3e9770cfcfedf98e886 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期五, 22 八月 2025 00:39:34 +0800
Subject: [PATCH] 增加首页搜索接口

---
 blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramApprovedService.java |  133 ++-----------------------------------------
 1 files changed, 8 insertions(+), 125 deletions(-)

diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramApprovedService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramApprovedService.java
index 46c4b00..f9248ef 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramApprovedService.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramApprovedService.java
@@ -8,11 +8,13 @@
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.compress.archivers.zip.ZipUtil;
+import org.apache.commons.lang3.StringUtils;
 import org.springblade.core.mp.base.BizEntity;
 import org.springblade.core.mp.base.BizServiceImpl;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.oss.OssTemplate;
+import org.springblade.core.tool.utils.Func;
 import org.springblade.mdm.flow.entity.ApproveRecord;
 import org.springblade.mdm.flow.service.ApproveRecordService;
 import org.springblade.mdm.program.entity.NcNode;
@@ -24,6 +26,7 @@
 import org.springblade.mdm.program.vo.NcProgramExportDncQueryVO;
 import org.springblade.mdm.utils.CustomBinaryWriter;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -53,136 +56,16 @@
 	 * @param query 鏌ヨ鍙傛暟
 	 * @return
 	 */
+	@Transactional(readOnly = true)
 	public IPage<NcProgramExportDncPageVO> exportDncPageQuery(NcProgramExportDncQueryVO query) {
-
-		IPage<NcProgramExportDncPageVO> page = this.getBaseMapper().exportDncPageQuery(Condition.getPage(query),query);
-
-		return page;
-
-	}
-
-	/**
-	 * 瀵煎嚭dnc
-	 * @param approvedIdArr 寰呭鍑哄鎵硅〃id鏁扮粍
-	 */
-	public void exportDnc(Long[] approvedIdArr, OutputStream os) throws IOException {
-		ZipOutputStream zipOut = new ZipOutputStream(os);
-
-		ArrayList<Long> programIdList = new ArrayList<Long>();
-
-		for (Long approvedId : approvedIdArr) {
-			NcProgramApproved approved = this.getById(approvedId);
-			programIdList.add(approved.getNcProgramId());
-
-			NcProgram prog = progService.getById(approved.getNcProgramId());
-
-			String filename = prog.getOssName();
-			InputStream inputStream = ossTemplate.statFileStream(filename);
-
-			addInputStreamToZip(zipOut, inputStream, prog.getName());
-
+		//濡傛灉涓嶆槸鏌ヨ宸插姙灏遍兘绠楁煡璇㈠緟鍔�(鏈鍑�)鐨�
+		if(query.getStatus() != NcProgramApproved.STATUS_EXPORTED){
+			query.setStatus(NcProgramApproved.STATUS_NOT_EXPORT);
 		}
-		addDataJson(zipOut, programIdList);
-
+		return this.getBaseMapper().exportDncPageQuery(Condition.getPage(query),query);
 	}
 
-	/**
-	 * 瀵煎叆鏁版嵁鏂囦欢
-	 * @param zipOut
-	 */
-	void addDataJson(ZipOutputStream zipOut, List<Long> programIdList) throws IOException {
-		//
-		addApproveRecordDataJson(zipOut, programIdList);
 
-		addNcNodeDataJson(zipOut, programIdList);
-	}
 
-	/**
-	 * 瀵煎叆瀹℃壒璁板綍
-	 * @param zipOut
-	 * @param programIdList
-	 */
-	void addApproveRecordDataJson(ZipOutputStream zipOut, List<Long> programIdList) throws IOException {
-		LambdaQueryWrapper<ApproveRecord> queryWrapper = new LambdaQueryWrapper<>();
-		queryWrapper.in(ApproveRecord::getNcProgramId, programIdList);
-		List<ApproveRecord> records = approvedService.list(queryWrapper);
-		JSONArray jsonArray = new JSONArray();
-		for(ApproveRecord record : records){
-			JSONObject recObj = new JSONObject();
-			recObj.put("id", record.getId());
-			recObj.put("comment", record.getComment());
-			recObj.put("userId",record.getUserId());
-			recObj.put("userNickname",record.getUserNickname());
-			recObj.put("operateTime",record.getOperateTime());
-			recObj.put("operateResult",record.getOperateResult());
-			recObj.put("taskName",record.getTaskName());
-			recObj.put("ncProgramId",record.getNcProgramId());
-			recObj.put("processInstanceId",record.getProcessInstanceId());
-
-			addSuperProperties(recObj,record);
-
-			jsonArray.add(recObj);
-		}
-		addInputStreamToZip(zipOut,new ByteArrayInputStream(jsonArray.toJSONString().getBytes(StandardCharsets.UTF_8)),"exp_mdm_approve_record.json");
-
-	}
-
-	/**
-	 * 瀵煎叆鑺傜偣
-	 * @param zipOut
-	 * @param programIdList
-	 */
-	void addNcNodeDataJson(ZipOutputStream zipOut, List<Long> programIdList) throws IOException {
-		LambdaQueryWrapper<NcProgram> queryWrapper = new LambdaQueryWrapper<>();
-		queryWrapper.in(NcProgram::getId, programIdList);
-
-		List<NcProgram> programs = progService.list(queryWrapper);
-		JSONArray jsonArray = new JSONArray();
-		ArrayList<NcNode> nodeList 	= new ArrayList<>();
-		for(NcProgram program : programs){
-			JSONObject recObj = new JSONObject();
-			NcNode ncNode = ncNodeService.getById(program.getNcNodeId());
-
-			nodeList.add(ncNode);
-
-		}
-
-		for(NcNode node : nodeList){
-			JSONObject recObj = new JSONObject();
-
-			recObj.put("id", node.getId());
-			recObj.put("nodeType", node.getNodeType());
-			recObj.put("machineCode",node.getMachineCode());
-
-			addSuperProperties(recObj,node);
-		}
-		addInputStreamToZip(zipOut,new ByteArrayInputStream(jsonArray.toJSONString().getBytes(StandardCharsets.UTF_8)),"exp_mdm_nc_node.json");
-	}
-
-	void addSuperProperties(JSONObject recObj, BizEntity entity){
-		recObj.put("createTime",entity.getCreateTime());
-		recObj.put("updateTime",entity.getUpdateTime());
-		recObj.put("createUser",entity.getCreateUser());
-		recObj.put("updateUser",entity.getUpdateUser());
-		recObj.put("status",entity.getStatus());
-		recObj.put("createDept",entity.getCreateDept());
-	}
-
-	public void addInputStreamToZip(ZipOutputStream zipOut, InputStream inputStream, String entryName)
-		throws IOException {
-		// 鍒涘缓鏂扮殑 ZIP 鏉$洰
-		ZipEntry zipEntry = new ZipEntry(entryName);
-		zipOut.putNextEntry(zipEntry);
-
-		// 灏嗚緭鍏ユ祦鍐欏叆 ZIP 杈撳嚭娴�
-		byte[] buffer = new byte[1024];
-		int length;
-		while ((length = inputStream.read(buffer)) >= 0) {
-			zipOut.write(buffer, 0, length);
-		}
-
-		// 鍏抽棴褰撳墠鏉$洰
-		zipOut.closeEntry();
-	}
 }
 

--
Gitblit v1.9.3