From 34c25ddf37a3eb8da9efb04efedad089f13efe83 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期三, 24 七月 2024 18:20:27 +0800
Subject: [PATCH] 部门导入调整,按照部门名称/实现层级关系。枚举导入功能接口上传,属性池添加新增、查询、修改、导出、查看应用范围等接口。业务类型、链接类型、枚举类型增加等接口属性是否产生数据检查、根据属性名修改业务类型和连接类型中对应属性方法,以及属性池中需要的一些下拉查询接口。

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java |  111 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 103 insertions(+), 8 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java
index e8beb3e..e5c3025 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java
@@ -1,22 +1,35 @@
 package com.vci.web.controller;
 
+import com.vci.constant.FrameWorkLangCodeConstant;
 import com.vci.dto.OsEnumDTO;
 import com.vci.starter.web.annotation.controller.VciUnCheckRight;
 import com.vci.starter.web.annotation.log.VciBusinessLog;
+import com.vci.starter.web.exception.VciBaseException;
 import com.vci.starter.web.pagemodel.BaseQueryObject;
 import com.vci.starter.web.pagemodel.BaseResult;
 import com.vci.starter.web.pagemodel.DataGrid;
 import com.vci.pagemodel.KeyValue;
 import com.vci.pagemodel.OsEnumItemVO;
 import com.vci.pagemodel.OsEnumVO;
+import com.vci.starter.web.util.ControllerUtil;
+import com.vci.starter.web.util.LangBaseUtil;
+import com.vci.starter.web.util.LocalFileUtil;
 import com.vci.starter.web.util.VciBaseUtil;
 import com.vci.web.service.OsEnumServiceI;
+import com.vci.web.util.Func;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -46,7 +59,6 @@
 	 * @return 鏋氫妇鐨勪笅鎷夊��
 	 */
 	@VciBusinessLog(notStore=true,operateName="鑾峰彇鏋氫妇")
-	@VciUnCheckRight
 	@GetMapping("/getEnum")
 	public BaseResult<List<KeyValue>> getEnum(String comboxKey){
 		return BaseResult.success(enumService.getEnum(comboxKey));
@@ -87,13 +99,30 @@
 	}
 
 	/**
+	 * 鏍规嵁鏋氫妇绫诲瀷鑾峰彇鏋氫妇
+	 * @param enumType 鏌ヨ鏉′欢name
+	 * @return 鍒楄〃鐨勫唴瀹�
+	 */
+	@GetMapping( "/getEnumMapByType")
+	@VciBusinessLog(operateName = "鏋氫妇鍒楄〃")
+	public BaseResult getEnumMapByType(String enumType) {
+		try {
+			return BaseResult.dataList(enumService.getEnumMapByType(enumType));
+		}catch (Exception e) {
+			e.printStackTrace();
+			String exceptionMessage = "鏋氫妇绠$悊鍒楄〃鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+			logger.error(exceptionMessage);
+			return BaseResult.fail(exceptionMessage);
+		}
+	}
+
+	/**
 	 * 鏋氫妇鍒楄〃
 	 * @param enumName 鏌ヨ鏉′欢name
 	 * @return 鍒楄〃鐨勫唴瀹�
 	 */
 	@GetMapping( "/getEnumTypeList")
 	@VciBusinessLog(operateName = "鏋氫妇鍒楄〃")
-	@VciUnCheckRight
 	public BaseResult<List<OsEnumVO>> getEnumTypeList(String enumName) {
 		try {
 			return BaseResult.dataList(enumService.getEnumTypeList(enumName));
@@ -112,7 +141,6 @@
 	 */
 	@PostMapping( "/addEnumType")
 	@VciBusinessLog(operateName = "娣诲姞鏋氫妇")
-	@VciUnCheckRight
 	public BaseResult addEnumType(@RequestBody OsEnumDTO osEnumDTO) {
 		try {
 			return enumService.addEnumType(osEnumDTO) ? BaseResult.success("鏋氫妇绫诲瀷娣诲姞鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷娣诲姞澶辫触锛�");
@@ -131,7 +159,6 @@
 	 */
 	@PutMapping( "/updateEnumType")
 	@VciBusinessLog(operateName = "淇敼鏋氫妇")
-	@VciUnCheckRight
 	public BaseResult updateEnumType(@RequestBody OsEnumDTO osEnumDTO) {
 		try {
 			return enumService.updateEnumType(osEnumDTO) ? BaseResult.success("鏋氫妇绫诲瀷淇敼鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷淇敼澶辫触锛�");
@@ -150,7 +177,6 @@
 	 */
 	@DeleteMapping( "/deleteEnumTypes")
 	@VciBusinessLog(operateName = "鍒犻櫎鏋氫妇")
-	@VciUnCheckRight
 	public BaseResult deleteEnumTypes(@RequestBody List<OsEnumDTO> osEnumDTOS) {
 		try {
 			return enumService.deleteEnumTypes(osEnumDTOS) ? BaseResult.success("鏋氫妇绫诲瀷鍒犻櫎鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷鍒犻櫎澶辫触锛�");
@@ -164,12 +190,11 @@
 
 	/**
 	 * 鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥�
-	 * @param enumName
-	 * @return 鍒楄〃鐨勫唴瀹�
+	 * @param enumName 鏋氫妇鍚嶇О
+	 * @return map瀵硅薄
 	 */
 	@GetMapping( "/getUsedEnumList")
 	@VciBusinessLog(operateName = "鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥�")
-	@VciUnCheckRight
 	public BaseResult getUsedEnumList(String enumName) {
 		try {
 			return BaseResult.dataList(enumService.getUsedEnumList(enumName));
@@ -181,4 +206,74 @@
 		}
 	}
 
+	/**
+	 * 瀵煎嚭閫変腑鐨勬灇涓剧被鍨�
+	 * @param exportFileName 瀵煎嚭鐨勬枃浠跺悕
+	 * @param enumNames 闇�瑕佸鍑虹殑鏋氫妇鍚嶇О
+	 * @param response
+	 */
+	@GetMapping( "/exportEnumTypes")
+	@VciBusinessLog(operateName = "瀵煎嚭鏋氫妇绫诲瀷")
+	public void exportEnumTypes(String exportFileName,String enumNames, HttpServletResponse response){
+		try {
+			String excelPath = enumService.exportEnumTypes(exportFileName,enumNames);
+			ControllerUtil.writeFileToResponse(response,excelPath);
+		} catch (Exception e) {
+			String msg = "瀵煎嚭鏋氫妇鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+			try {
+				//鍑洪敊鏃�
+				e.printStackTrace();
+				ControllerUtil.writeDataToResponse(response,"error_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss") + ".txt", StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null);
+			} catch (IOException ioException) {
+				ioException.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * 涓嬭浇瀵煎叆妯℃澘
+	 * @param exportFileName
+	 * @param response
+	 */
+	@GetMapping( "/downloadEnumTemplate")
+	@VciBusinessLog(operateName = "瀵煎嚭鏋氫妇绫诲瀷")
+	public void downloadEnumTemplate(String exportFileName, HttpServletResponse response){
+		try {
+			String excelPath = enumService.downloadEnumTemplate(exportFileName);
+			ControllerUtil.writeFileToResponse(response,excelPath);
+		} catch (Exception e) {
+			String msg = "涓嬭浇鏋氫妇瀵煎叆妯℃澘鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+			try {
+				//鍑洪敊鏃�
+				e.printStackTrace();
+				ControllerUtil.writeDataToResponse(response,"error_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss") + ".txt", StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null);
+			} catch (IOException ioException) {
+				ioException.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * 瀵煎叆鏋氫妇
+	 * @param file
+	 * @return
+	 */
+	@RequestMapping(value = "/importEnumTypes",method = RequestMethod.POST)
+	public BaseResult importEnumTypes(MultipartFile file){
+		String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename());
+		File file1 = new File(excelFileName);
+		try {
+			file.transferTo(new File(excelFileName));
+			if (file != null) {
+				return enumService.importEnumTypes(file1);
+			} else {
+				return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"});
+			}
+		}catch (Throwable e) {
+			throw new VciBaseException(e.getMessage(),new String[0],e);
+		}finally {
+			file1.delete();
+		}
+	}
+
 }

--
Gitblit v1.9.3