From 980a7eab362b5a8c00f13427c73053382ca4ba44 Mon Sep 17 00:00:00 2001
From: xiejun <xj@2023>
Date: 星期三, 06 十二月 2023 09:31:31 +0800
Subject: [PATCH] 集团码导入功能开发

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java |   42 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java
index e82445c..061a6b4 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java
@@ -844,17 +844,53 @@
 	 */
 	@GetMapping("/exportGroupCodeExcel")
 	@VciBusinessLog(operateName = "瀵煎嚭闆嗗洟鐮�")
-	public void exportGroupCodeExcel(String codeClassifyOid, HttpServletResponse response) throws IOException{
-
+	public R exportGroupCodeExcel(String codeClassifyOid, HttpServletResponse response) throws IOException{
 		try {
 			String excelName = mdmIOService.exportGroupCodeExcel(codeClassifyOid);
+			ControllerUtil.writeFileToResponse(response,excelName);
 		} catch (Throwable e) {
 			//濡傛灉鍑洪敊,鎶婇敊璇俊鎭啓鍒皌ext
 			String msg = LangBaseUtil.getErrorMsg(e);
 			if(StringUtils.isBlank(msg)){
 				msg = "鏈煡閿欒";
 			}
-			ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null);
+			return R.fail(msg);
+		//	ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null);
 		}
+		return R.status(true);
+	}
+
+	/***
+	 * 闆嗗洟鐮佸鍏�
+	 * @param codeClassifyOid
+	 * @param file
+	 * @param response
+	 * @return
+	 */
+	@PostMapping("/importGroupCode")
+	public R  importGroupCode(String codeClassifyOid,MultipartFile file,HttpServletResponse response){
+
+		String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + file.getOriginalFilename();
+		File file1 = new File(excelFileName);
+		try {
+			file.transferTo(new File(excelFileName));
+			mdmIOService.importGroupCode(codeClassifyOid,file1);
+			return R.success("鎿嶄綔鎴愬姛锛�");
+		}catch (Throwable e) {
+			logger.error("瀵煎叆閿欒",e);
+			String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "閿欒.txt";
+			LocalFileUtil.writeContentToFile(LangBaseUtil.getErrorMsg(e),errorFile);
+			String uuid=ControllerUtil.putErrorFile(errorFile);
+			CodeImProtRusultVO codeImProtRusultVO =new CodeImProtRusultVO();
+			codeImProtRusultVO.setRedisUuid("");
+			codeImProtRusultVO.setFileOid(uuid);
+			codeImProtRusultVO.setFilePath(errorFile);
+			R r = R.fail("瀵煎叆澶辫触");
+			r.setData(codeImProtRusultVO);
+			return r;
+		}finally {
+			file1.delete();
+		}
+
 	}
 }

--
Gitblit v1.9.3