From 71049a2149033ced0d498f2f9ed3d5d1b9ed644d Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期五, 19 七月 2024 16:12:34 +0800
Subject: [PATCH] 对象建模——枚举和枚举项的查询、新增、修改、删除、查看使用范围、下载导入模板、导入、导出接口并联调。

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java |    3 
 Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/bo/WriteExcelData.java                            |   35 +++
 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/SmUserPO.java                                          |    2 
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java  |   30 +++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java                               |   29 ++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java                         |   93 ++++++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java                       |  322 ++++++++++++++++++++++++++++++-
 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsEnumPO.java                                          |   81 ++++++++
 Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/util/ExcelUtil.java                               |    4 
 9 files changed, 566 insertions(+), 33 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/bo/WriteExcelData.java b/Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/bo/WriteExcelData.java
index 34ab1ba..9d534fe 100644
--- a/Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/bo/WriteExcelData.java
+++ b/Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/bo/WriteExcelData.java
@@ -1,8 +1,5 @@
 package com.vci.starter.poi.bo;
 
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Font;
-
 import java.util.List;
 
 /**
@@ -107,7 +104,6 @@
 	 */
 	private Integer width;
 
-
 	public String getFontColor() {
 		return fontColor;
 	}
@@ -145,6 +141,37 @@
 	}
 
 	/**
+	 * 鏋勯�犳柟娉�
+	 * @param row 琛�
+	 * @param col 鍒�
+	 * @param obj 鍊�
+	 */
+	public WriteExcelData(int row, int col, boolean center, Object obj){
+		this.row = row;
+		this.col = col;
+		this.center = center;
+		this.obj = obj;
+	}
+
+	/**
+	 * 鏋勯�犳柟娉�
+	 * @param row 琛�
+	 * @param rowTo 鍚堝苟琛�
+	 * @param merged 鏄惁鍚堝苟鍗曞厓鏍�
+	 * @param center 鏄惁灞呬腑
+	 * @param col 鍒�
+	 * @param obj 鍊�
+	 */
+	public WriteExcelData(int row,int rowTo,boolean merged,boolean center, int col, Object obj){
+		this.row = row;
+		this.rowTo = rowTo;
+		this.merged = merged;
+		this.center = center;
+		this.col = col;
+		this.obj = obj;
+	}
+
+	/**
 	 * 鍐欏叕寮�
 	 * @param row 琛屽彿 浠�0 寮�濮�
 	 * @param col 鍒楀彿浠�0寮�濮�
diff --git a/Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/util/ExcelUtil.java b/Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/util/ExcelUtil.java
index aedbcdf..2ed445e 100644
--- a/Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/util/ExcelUtil.java
+++ b/Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/util/ExcelUtil.java
@@ -1,5 +1,6 @@
 package com.vci.starter.poi.util;
 
+import cn.hutool.core.collection.CollUtil;
 import com.vci.starter.poi.annotation.ExcelColumn;
 import com.vci.starter.poi.annotation.ExcelTitle;
 import com.vci.starter.poi.bo.*;
@@ -630,6 +631,8 @@
 					//鍐欏��
 					setCellValue(cell, value);
 				}
+				//璁剧疆鑷�傚簲鍒楀
+				sheet.autoSizeColumn(ed.getCol());
 				if(ed.getWidth()!=null && ed.getWidth()>0){
 					sheet.setColumnWidth(cell.getColumnIndex(),(int)(ed.getWidth() + 0.72)*256);
 				}
@@ -855,6 +858,7 @@
 				if (ed.getColTo() < ed.getCol()) {
 					ed.setColTo(ed.getCol());
 				}
+				List<CellRangeAddress> cellRangeAddressList = sheet.getMergedRegions();
 				sheet.addMergedRegion(new CellRangeAddress(ed.getRow(), ed.getRowTo(), ed.getCol(), ed.getColTo()));
 			});
 		}
diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsEnumPO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsEnumPO.java
new file mode 100644
index 0000000..4bab322
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsEnumPO.java
@@ -0,0 +1,81 @@
+package com.vci.po;
+
+import com.vci.dto.OsEnumItemDTO;
+import com.vci.starter.poi.annotation.ExcelColumn;
+import com.vci.starter.web.pagemodel.BaseModelVO;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 鏋氫妇瀵煎叆瀵硅薄
+ * @author ludc
+ * @date 2024/7/19 11:11
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class OsEnumPO extends BaseModelVO {
+
+    /**
+     * 绂佹淇敼杩欎釜鍊�
+     */
+    private static final long serialVersionUID = -2239512786206928201L;
+
+    /**
+     * 鎵�鍦ㄦ暟鎹
+     */
+    @ExcelColumn(rowIndexColumn = true,value = "")
+    private String rowIndex;
+
+    /**
+     * 灞炴�ц嫳鏂囧悕绉�
+     */
+    @ExcelColumn(value="鏋氫妇鍚嶇О",nullable = false)
+    private String id;
+
+    /**
+     * 鏍囩
+     */
+    @ExcelColumn(value="鏍囩")
+    private String name;
+
+    /**
+     * 杩斿洖绫诲瀷
+     */
+    @ExcelColumn(value="杩斿洖绫诲瀷",nullable = false)
+    private String enumValueDataType;
+
+    /**
+     * 闀垮害
+     */
+    @ExcelColumn(value="闀垮害",nullable = false)
+    private Integer length;
+
+    /**
+     * 鏋氫妇椤瑰悕
+     */
+    @ExcelColumn(value="鏋氫妇椤瑰悕绉�(褰撳墠鏋氫妇涓嬫湁鏋氫妇椤规椂蹇呭~)",nullable = false)
+    private String enumItemName;
+
+    /**
+     * 鏋氫妇鍊�
+     */
+    @ExcelColumn(value="鏋氫妇鍊�(褰撳墠鏋氫妇涓嬫湁鏋氫妇椤规椂蹇呭~)",nullable = false)
+    private String value;
+
+    /**
+     * 鎻忚堪
+     */
+    @ExcelColumn(value="鎻忚堪")
+    private String description;
+
+    /**
+     * 鐢ㄤ簬鏁寸悊鎴�1瀵瑰鍏崇郴鏃朵娇鐢紝涓嶉拡瀵瑰鍏ヤ娇鐢�
+     */
+    private List<OsEnumItemDTO> items = new ArrayList<>();
+
+}
diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/SmUserPO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/SmUserPO.java
index 192eda0..7376c81 100644
--- a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/SmUserPO.java
+++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/SmUserPO.java
@@ -7,7 +7,7 @@
 import lombok.NoArgsConstructor;
 
 /**
- * 鐢ㄦ埛鐨勫鍏ュ鍑哄璞�
+ * 鐢ㄦ埛鐨勫鍏ュ璞�
  * @author ludc
  * @date 2024/7/1 16:53
  */
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java
index edaa600..6393e9f 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java
@@ -703,7 +703,8 @@
 	@Override
 	public boolean deleteDept(String[] ids) throws PLException {
 		VciBaseUtil.alertNotNull(ids,"瑕佸垹闄ょ殑閮ㄩ棬涓婚敭");
-		//TODO: 搴旇鏄笉鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝绛栫暐鍒犻櫎鍚庣敤鎴峰叧鑱旂殑鏃犵敤閮ㄩ棬杩樺湪,鑰冭檻鍚庢湡鏄惁闇�瑕佸仛锛屾暟鎹噺涓嶅ぇ鍙互涓嶅仛杩炲甫鍒犻櫎
+		//TODO:鑰冭檻鏄惁闇�瑕佹坊鍔犲垹闄ゅ墠鍒ゆ柇閮ㄩ棬涓嬫槸鍚﹂厤缃湁鐢ㄦ埛锛岃繖绉嶆儏鍐靛簲璇ヤ笉鍏佽鍒犻櫎
+		//TODO: 搴旇鏄笉鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝閮ㄩ棬鍒犻櫎鍚庣敤鎴峰叧鑱旂殑鏃犵敤閮ㄩ棬杩樺湪,鑰冭檻鍚庢湡鏄惁闇�瑕佸仛锛屾暟鎹噺涓嶅ぇ鍙互涓嶅仛杩炲甫鍒犻櫎
 		return platformClientUtil.getFrameworkService().deleteDepartment(
 				ids,
 				new UserEntityInfo("developer"/*WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId()*/, null)
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java
index 2320280..cf9ee4b 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java
@@ -8,9 +8,11 @@
 import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI;
 import com.vci.constant.FrameWorkBtmTypeConstant;
 import com.vci.dto.SmRoleDTO;
+import com.vci.frameworkcore.compatibility.SmUserQueryServiceI;
 import com.vci.frameworkcore.enumpck.RoleClassifyEnum;
 import com.vci.frameworkcore.enumpck.RoleControlAreaEnum;
 import com.vci.model.SmRoleForPlatform1;
+import com.vci.pagemodel.SmUserVO;
 import com.vci.po.SmRolePO;
 import com.vci.pagemodel.SmRoleVO;
 import com.vci.omd.utils.ObjectTool;
@@ -34,6 +36,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
@@ -56,6 +59,13 @@
 	 */
 	@Autowired
 	private WebBoServiceI boService;
+
+	/**
+	 * 鐢ㄦ埛鏌ヨ鏈嶅姟
+	 */
+	@Autowired
+	@Lazy
+	private SmUserQueryServiceI smUserQueryServiceI;
 
 	/**
 	 * 骞冲彴璋冪敤瀹㈡埛绔�
@@ -679,6 +689,13 @@
 	@Override
 	public boolean deleteRole(String[] ids) throws PLException {
 		VciBaseUtil.alertNotNull(ids,"瑕佸垹闄ょ殑瑙掕壊涓婚敭");
+		//浣跨敤涓婚敭鍒ゆ柇瑙掕壊鏄惁琚敤鎴峰紩鐢�
+		for (int i = 0; i < ids.length; i++) {
+			String roleName = this.checkIsUsed(ids[i]);
+			if(Func.isNotBlank(roleName)){
+				throw new PLException("500",new String[]{"褰撳墠閫変腑瑕佸垹闄ょ殑瑙掕壊涓瓨鍦ㄣ��"+roleName+"銆戣寮曠敤!"});
+			}
+		}
 		//鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝濡傝鑹茶彍鍗曟巿鏉冭〃閲岄潰鐨勬巿鏉冧俊鎭�
 		return platformClientUtil.getFrameworkService().deleteRole(
 				ids,
@@ -687,6 +704,19 @@
 	}
 
 	/**
+	 * 妫�鏌ヨ鑹叉槸鍚︽湁鍦ㄥ紩鐢�
+	 * @param roleOid
+	 * @return
+	 */
+	private String checkIsUsed(String roleOid){
+		List<SmUserVO> smUserVOS = smUserQueryServiceI.listUserByRoleOid(roleOid, null);
+		if (Func.isNotEmpty(smUserVOS)) {
+			return this.getRoleNameByRoleOid(roleOid);
+		}
+		return null;
+	}
+
+	/**
 	 * 瀵煎叆瑙掕壊
 	 * @param file
 	 * @return
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..d9a5837 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,21 +1,33 @@
 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;
 
 
@@ -93,7 +105,6 @@
 	 */
 	@GetMapping( "/getEnumTypeList")
 	@VciBusinessLog(operateName = "鏋氫妇鍒楄〃")
-	@VciUnCheckRight
 	public BaseResult<List<OsEnumVO>> getEnumTypeList(String enumName) {
 		try {
 			return BaseResult.dataList(enumService.getEnumTypeList(enumName));
@@ -112,7 +123,6 @@
 	 */
 	@PostMapping( "/addEnumType")
 	@VciBusinessLog(operateName = "娣诲姞鏋氫妇")
-	@VciUnCheckRight
 	public BaseResult addEnumType(@RequestBody OsEnumDTO osEnumDTO) {
 		try {
 			return enumService.addEnumType(osEnumDTO) ? BaseResult.success("鏋氫妇绫诲瀷娣诲姞鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷娣诲姞澶辫触锛�");
@@ -131,7 +141,6 @@
 	 */
 	@PutMapping( "/updateEnumType")
 	@VciBusinessLog(operateName = "淇敼鏋氫妇")
-	@VciUnCheckRight
 	public BaseResult updateEnumType(@RequestBody OsEnumDTO osEnumDTO) {
 		try {
 			return enumService.updateEnumType(osEnumDTO) ? BaseResult.success("鏋氫妇绫诲瀷淇敼鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷淇敼澶辫触锛�");
@@ -150,7 +159,6 @@
 	 */
 	@DeleteMapping( "/deleteEnumTypes")
 	@VciBusinessLog(operateName = "鍒犻櫎鏋氫妇")
-	@VciUnCheckRight
 	public BaseResult deleteEnumTypes(@RequestBody List<OsEnumDTO> osEnumDTOS) {
 		try {
 			return enumService.deleteEnumTypes(osEnumDTOS) ? BaseResult.success("鏋氫妇绫诲瀷鍒犻櫎鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷鍒犻櫎澶辫触锛�");
@@ -164,12 +172,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 +188,76 @@
 		}
 	}
 
+	/**
+	 * 瀵煎嚭閫変腑鐨勬灇涓剧被鍨�
+	 * @param exportFileName 瀵煎嚭鐨勬枃浠跺悕
+	 * @param enumNames 闇�瑕佸鍑虹殑鏋氫妇鍚嶇О
+	 * @param response
+	 */
+	@GetMapping( "/exportEnumTypes")
+	@VciBusinessLog(operateName = "瀵煎嚭鏋氫妇绫诲瀷")
+	@VciUnCheckRight
+	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 = "瀵煎嚭鏋氫妇绫诲瀷")
+	@VciUnCheckRight
+	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();
+		}
+	}
+
 }
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java
index 21881ba..615269e 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java
@@ -3,12 +3,14 @@
 import com.vci.corba.omd.etm.EnumType;
 import com.vci.dto.OsEnumDTO;
 import com.vci.starter.web.exception.VciBaseException;
+import com.vci.starter.web.pagemodel.BaseResult;
 import com.vci.starter.web.pagemodel.DataGrid;
 import com.vci.starter.web.pagemodel.PageHelper;
 import com.vci.pagemodel.KeyValue;
 import com.vci.pagemodel.OsEnumItemVO;
 import com.vci.pagemodel.OsEnumVO;
 
+import java.io.File;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -69,11 +71,11 @@
 
 	/**
 	 * 鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥�
-	 * @param enumName
+	 * @param enumName 鏋氫妇鍚嶇О
 	 * @return
 	 * @throws PLException
 	 */
-	List<OsEnumVO> getUsedEnumList(String enumName) throws PLException;
+	List<Map<String,String>> getUsedEnumList(String enumName) throws PLException;
 
 	/**
 	 * 鏍规嵁鏋氫妇鑻辨枃鍚嶇О鑾峰彇鏋氫妇绫诲瀷
@@ -104,6 +106,29 @@
 	boolean deleteEnumTypes(List<OsEnumDTO> osEnumDTOS) throws PLException;
 
 	/**
+	 * 瀵煎嚭鏋氫妇绫诲瀷
+	 * @param exportFileName 瀵煎嚭鐨勬枃浠跺悕
+	 * @param enumNames 闇�瑕佸鍑虹殑鏋氫妇鍚嶇О
+	 * @return
+	 */
+	String exportEnumTypes(String exportFileName,String enumNames) throws PLException;
+
+	/**
+	 * 瀵煎叆鏋氫妇
+	 * @param file
+	 * @return
+	 * @throws Exception
+	 */
+	BaseResult importEnumTypes(File file) throws Exception;
+
+	/**
+	 * 涓嬭浇瀵煎叆妯℃澘
+	 * @param exportFileName
+	 * @return
+	 */
+	String downloadEnumTemplate(String exportFileName);
+
+	/**
 	 * 鏌ヨ鎵�鏈夌殑鏋氫妇鏄犲皠
 	 * @return key鏄灇涓剧殑鑻辨枃鍚嶇О
 	 */
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java
index 2173b0a..05f3a5c 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java
@@ -1,25 +1,31 @@
 package com.vci.web.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.vci.corba.common.PLException;
+import com.vci.corba.common.data.UserEntityInfo;
 import com.vci.corba.omd.data.BusinessObject;
 import com.vci.corba.omd.etm.EnumItem;
 import com.vci.corba.omd.etm.EnumType;
 import com.vci.dto.OsEnumDTO;
 import com.vci.dto.OsEnumItemDTO;
+import com.vci.dto.SmUserDTO;
 import com.vci.omd.utils.ObjectTool;
+import com.vci.pagemodel.*;
+import com.vci.po.OsEnumPO;
+import com.vci.po.SmUserPO;
+import com.vci.starter.poi.bo.ReadExcelOption;
+import com.vci.starter.poi.bo.WriteExcelData;
+import com.vci.starter.poi.bo.WriteExcelOption;
+import com.vci.starter.poi.constant.ExcelLangCodeConstant;
+import com.vci.starter.poi.util.ExcelUtil;
 import com.vci.starter.web.annotation.log.VciUnLog;
 import com.vci.starter.web.enumpck.UserSecretEnum;
 import com.vci.starter.web.exception.VciBaseException;
+import com.vci.starter.web.pagemodel.BaseResult;
 import com.vci.starter.web.pagemodel.DataGrid;
 import com.vci.starter.web.pagemodel.PageHelper;
-import com.vci.starter.web.util.VciBaseUtil;
-import com.vci.starter.web.util.VciDateUtil;
+import com.vci.starter.web.util.*;
 import com.vci.constant.EnumIdConstant;
-import com.vci.pagemodel.KeyValue;
-import com.vci.pagemodel.OsEnumItemVO;
-import com.vci.pagemodel.OsEnumVO;
-import com.vci.pagemodel.OsStatusVO;
-import com.vci.starter.web.util.WebThreadLocalUtil;
 import com.vci.web.service.OsEnumServiceI;
 import com.vci.web.service.OsLifeCycleServiceI;
 import com.vci.web.service.WebBoServiceI;
@@ -27,6 +33,7 @@
 import com.vci.web.util.PlatformClientUtil;
 import com.vci.web.util.WebUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.util.HSSFColor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +42,7 @@
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.util.HtmlUtils;
 
+import java.io.File;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -72,16 +80,21 @@
 	private WebBoServiceI boService;
 
 	/**
-	 * 鏃ュ織
-	 */
-	private Logger logger = LoggerFactory.getLogger(getClass());
-
-	/**
 	 * 鍔犺浇鑷韩
 	 */
 	@Autowired(required = false)
 	@Lazy
 	private OsEnumServiceI self;
+
+	/**
+	 * 蹇呭~鍒�
+	 */
+	private ArrayList<Integer> ColumnNameisRed = new ArrayList<Integer>();
+
+	/**
+	 * 鏃ュ織
+	 */
+	private Logger logger = LoggerFactory.getLogger(getClass());
 
 	/**
 	 * 浣跨敤缂栧彿鑾峰彇鏋氫妇鏄庣粏
@@ -231,13 +244,27 @@
 
 	/**
 	 * 鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥�
-	 * @param enumName
+	 * @param enumName 鏋氫妇鍚嶇О
 	 * @return
 	 * @throws PLException
 	 */
 	@Override
-	public List<OsEnumVO> getUsedEnumList(String enumName) throws PLException {
-		return null;
+	public List<Map<String,String>> getUsedEnumList(String enumName) throws PLException {
+		if(Func.isBlank(enumName)){
+			throw new PLException("500",new String[]{"璇烽�夋嫨瑕佹煡璇㈠簲鐢ㄨ寖鍥寸殑鏋氫妇!"});
+		}
+		String[] attrubyteNames = platformClientUtil.getAttributeService().getAttrubyteNamesByEMName(enumName);
+		if(Func.isEmpty(attrubyteNames)){
+			return new ArrayList<>();
+		}
+		List<Map<String,String>> attrubyteMapList = new ArrayList<>();
+		Arrays.stream(attrubyteNames).forEach(attrName->{
+			Map<String, String> itemMap = new HashMap<>();
+			itemMap.put("enumName",enumName);
+			itemMap.put("source",attrName);
+			attrubyteMapList.add(itemMap);
+		});
+		return attrubyteMapList;
 	}
 
 	/**
@@ -279,8 +306,10 @@
 		//鏋氫妇椤瑰悕绉板垽閲嶇瓑鎿嶄綔
 		checkOsEnumItem(osEnumDTO);
 		//榛樿鍊煎鐞�
-		String userId = "developer";//WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+		String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
 		osEnumDTO.setCreator(userId);
+		//鎵嬪姩璁剧疆涓婚敭锛屽惁鍒欏钩鍙扮洿鎺ョ敤娌℃湁涓婚敭鐨勬灇涓炬斁杩涗簡缂撳瓨涓紝瀵艰嚧鍚庣画鏌ヨ鐨勬暟鎹病鏈塷id
+		osEnumDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
 		osEnumDTO.setLastModifier(userId);
 		return platformClientUtil.getEnumService().addEnumType(this.osEnumDTO2EnumType(osEnumDTO));
 	}
@@ -308,7 +337,7 @@
 		//3銆佹灇涓鹃」鍒ら噸锛屽拰闀垮害绛夋牎楠�
 		checkOsEnumItem(osEnumDTO);
 		//灏唎sEnumVO涓殑榛樿鍊艰祴鍊肩粰osEnumDTO瀵硅薄
-		String userId = "developer";//WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+		String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
 		osEnumDTO.setLastModifier(userId);
 		osEnumDTO.setCreator(osEnumVO.getCreator());
 		osEnumDTO.setCreateTime(osEnumVO.getCreateTime());
@@ -335,6 +364,11 @@
 			if(Func.isBlank(oid) || Func.isBlank(name) || Func.isEmpty(ts)){
 				throw new PLException("500",new String[]{"寰呭垹闄ょ殑鏋氫妇鍒楄〃涓富閿�恛id銆戝拰璋冩暣鏃堕棿銆恡s銆戜笉鑳戒负绌猴紒"});
 			}
+			//鍒ゆ柇鏋氫妇鏄惁鏈夎寮曠敤
+			List<Map<String, String>> usedEnumList = this.getUsedEnumList(name);
+			if(Func.isNotEmpty(usedEnumList)){
+				throw new PLException("500",new String[]{"鍒犻櫎鐨勬灇涓句腑銆�" + name + "銆�,宸茶寮曠敤锛�"});
+			}
 			EnumType enumType = new EnumType();
 			enumType.oid = oid;
 			enumType.name = name;
@@ -348,6 +382,258 @@
 	}
 
 	/**
+	 * 瀵煎嚭鏋氫妇绫诲瀷
+	 * @param exportFileName 瀵煎嚭鐨勬枃浠跺悕
+	 * @param enumNames 闇�瑕佸鍑虹殑鏋氫妇鍚嶇О
+	 * @return
+	 */
+	@Override
+	public String exportEnumTypes(String exportFileName,String enumNames) throws PLException {
+		if(Func.isBlank(enumNames)){
+			throw new PLException("500",new String[]{"璇峰嬀閫夎瀵煎嚭鐨勬灇涓�!"});
+		}
+		//鐣岄潰娌′紶鍚嶇О锛屼娇鐢ㄩ粯璁ゅ鍑哄悕绉�
+		exportFileName = Func.isBlank(exportFileName) ?  "鏋氫妇绫诲瀷瀵煎嚭_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):exportFileName;
+		//璁剧疆鍒楀悕
+		List<String> columns = new ArrayList<>(Arrays.asList("鏋氫妇鍚嶇О", "鏍囩", "杩斿洖绫诲瀷", "闀垮害", "鏋氫妇椤瑰悕绉�", "鏋氫妇鍊�", "鎻忚堪"));
+
+		//鍐檈xcel
+		String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + exportFileName +  ".xls";
+		try {
+			new File(excelPath).createNewFile();
+		} catch (Throwable e) {
+			throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelPath}, e);
+		}
+		//璁剧疆鍒�
+		List<WriteExcelData> excelDataList = new ArrayList<>();
+		//璁剧疆鍒楀ご
+		for (int index = 0; index < columns.size(); index++) {
+			excelDataList.add(new WriteExcelData(0,index, columns.get(index)));
+		}
+		//鎸夌収鏋氫妇鍚嶆煡璇㈡灇涓撅紝鐒跺悗澶勭悊鏋氫妇瀵煎嚭
+		List<String> enumNameList = Func.toStrList(enumNames);
+		int startRow = 1;
+		for (int i = 0; i < enumNameList.size(); i++) {
+			//鏍规嵁鏋氫妇鍚嶇О鏌ヨ鏋氫妇鍜屾灇涓鹃」
+			OsEnumVO osEnumVO = this.getEnumTypeById(enumNameList.get(i));
+			//OsEnumVO osEnumVO = getTestJson(i);
+			//鏌ヨ缁撴灉涓嶅簲璇ヤ负绌�
+			if(Func.isEmpty(osEnumVO) && Func.isBlank(osEnumVO.getOid())){
+				throw new PLException("500",new String[]{"鏈煡璇㈠埌鏋氫妇鍚嶄负銆�" + enumNameList.get(i) + "銆戠殑鏋氫妇锛岃鍒锋柊鍚庨噸鏂板鍑�!"});
+			}
+			//鏋氫妇椤逛笉涓虹┖鏃堕渶瑕佽�冭檻鍚堝苟琛岄棶棰�
+			List<OsEnumItemVO> enumVOItems = osEnumVO.getItems();
+			//鏋氫妇椤逛笉涓虹┖鏃堕渶瑕佽繘琛屽悎骞惰澶勭悊
+			if(Func.isNotEmpty(enumVOItems) || enumVOItems.size() > 1){
+				//excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,0, osEnumVO.getOid()));
+				excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,0, osEnumVO.getId()));
+				excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,1, osEnumVO.getName()));
+				excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,2, osEnumVO.getEnumValueDataType()+"("+osEnumVO.getEnumValueDataTypeText()+")"));
+				excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,3, osEnumVO.getLength()));
+				//excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,5, osEnumVO.getCreator()));
+				excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,4, Func.format(osEnumVO.getCreateTime(),"yyyy骞碝M鏈坉d鏃� hh:mm:ss")));
+
+				//澶勭悊鏋氫妇椤瑰啓鍏�
+				for (int j = 0; j < enumVOItems.size(); j++) {
+					OsEnumItemVO osEnumItemVO = enumVOItems.get(j);
+					excelDataList.add(new WriteExcelData(startRow+j,7, true,osEnumItemVO.getName()));
+					excelDataList.add(new WriteExcelData(startRow+j,8, true, osEnumItemVO.getValue()));
+					excelDataList.add(new WriteExcelData(startRow+j,9, true, osEnumItemVO.getDescription()));
+				}
+
+				startRow += enumVOItems.size();
+			}else{
+				//鏋氫妇椤逛负绌烘椂灏变笉闇�瑕佸悎骞惰
+				//excelDataList.add(new WriteExcelData(startRow,0, true,osEnumVO.getOid()));
+				excelDataList.add(new WriteExcelData(startRow,0, true, osEnumVO.getId()));
+				excelDataList.add(new WriteExcelData(startRow,1, true, osEnumVO.getName()));
+				excelDataList.add(new WriteExcelData(startRow,1, true, osEnumVO.getEnumValueDataType()+"("+osEnumVO.getEnumValueDataTypeText()+")"));
+				excelDataList.add(new WriteExcelData(startRow,3, true, osEnumVO.getLength()));
+				//excelDataList.add(new WriteExcelData(startRow,5, true, osEnumVO.getCreator()));
+				excelDataList.add(new WriteExcelData(startRow,4, true, Func.format(osEnumVO.getCreateTime(),"yyyy骞碝M鏈坉d鏃� hh:mm:ss")));
+			}
+			//璁板綍涓嬩笂涓�缁勬暟鎹粨鏉熸椂鐨勮鍙凤紝鏂逛究鐢ㄥ仛鍚堝苟琛岀殑璧峰琛�
+			startRow += 1;
+		}
+		WriteExcelOption excelOption = new WriteExcelOption(excelDataList);
+		ExcelUtil.writeDataToFile(excelPath, excelOption);
+		return excelPath;
+	}
+
+	/**
+	 * 涓嬭浇瀵煎叆妯℃澘
+	 * @param exportFileName
+	 * @return
+	 */
+	@Override
+	public String downloadEnumTemplate(String exportFileName) {
+		//鐣岄潰娌′紶鍚嶇О锛屼娇鐢ㄩ粯璁ゅ鍑哄悕绉�
+		exportFileName = Func.isBlank(exportFileName) ?  "鏋氫妇瀵煎叆妯℃澘_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):exportFileName;
+		//璁剧疆鍒楀悕
+		List<String> columns = new ArrayList<>(Arrays.asList("鏋氫妇鍚嶇О", "鏍囩", "杩斿洖绫诲瀷", "闀垮害", "鏋氫妇椤瑰悕绉�(褰撳墠鏋氫妇涓嬫湁鏋氫妇椤规椂蹇呭~)", "鏋氫妇鍊�(褰撳墠鏋氫妇涓嬫湁鏋氫妇椤规椂蹇呭~)", "鎻忚堪","*娉ㄦ剰*:绗簩琛屽紑濮嬬殑鏁版嵁涓虹ず渚嬫暟鎹紝瀵煎叆鍓嶈灏嗗叾鍒犻櫎锛屽綋瀵煎叆鐨勬灇涓句笅鍏峰澶氫釜鏋氫妇椤规椂锛屽簲鎸夌収绀轰緥enum2鐨勫啓娉�"));
+		//鍐檈xcel
+		String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + exportFileName +  ".xls";
+		//璁剧疆蹇呭~鍒�
+		ColumnNameisRed.clear();
+		ColumnNameisRed.add(0);
+		ColumnNameisRed.add(2);
+		ColumnNameisRed.add(3);
+		ColumnNameisRed.add(4);
+		ColumnNameisRed.add(5);
+		try {
+			new File(excelPath).createNewFile();
+		} catch (Throwable e) {
+			throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelPath}, e);
+		}
+		//璁剧疆鍒�
+		List<WriteExcelData> excelDataList = new ArrayList<>();
+		//璁剧疆鍒楀ご
+		for (int index = 0; index < columns.size(); index++) {
+			//鍒ゆ柇鏄惁涓哄繀濉垪锛岀粰蹇呭~鍒楄缃鑹�
+			if(ColumnNameisRed.contains(index)){
+				WriteExcelData excelData = new WriteExcelData(0, index, columns.get(index));
+				excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex()));
+				excelDataList.add(excelData);
+			}else{
+				excelDataList.add(new WriteExcelData(0,index, columns.get(index)));
+			}
+		}
+		List<OsEnumVO> exportEnumTempExample = this.getExportEnumTempExample();
+		for (int i = 0; i < exportEnumTempExample.size(); i++) {
+			OsEnumVO osEnumVO = exportEnumTempExample.get(i);
+			List<OsEnumItemVO> enumVOItems = osEnumVO.getItems();
+			for (int j = 0; j < enumVOItems.size(); j++) {
+				OsEnumItemVO osEnumItemVO = enumVOItems.get(j);
+				excelDataList.add(new WriteExcelData(i+j+1,0, osEnumVO.getId()));
+				excelDataList.add(new WriteExcelData(i+j+1,1, osEnumVO.getName()));
+				excelDataList.add(new WriteExcelData(i+j+1,2, osEnumVO.getEnumValueDataType()));
+				excelDataList.add(new WriteExcelData(i+j+1,3, osEnumVO.getLength()));
+
+				excelDataList.add(new WriteExcelData(i+j+1,4,osEnumItemVO.getName()));
+				excelDataList.add(new WriteExcelData(i+j+1,5, osEnumItemVO.getValue()));
+				excelDataList.add(new WriteExcelData(i+j+1,6, osEnumItemVO.getDescription()));
+			}
+		}
+		WriteExcelOption excelOption = new WriteExcelOption(excelDataList);
+		ExcelUtil.writeDataToFile(excelPath, excelOption);
+		return excelPath;
+	}
+
+	/**
+	 * 瀵煎叆鏋氫妇
+	 * @param file
+	 * @return
+	 * @throws Exception
+	 */
+	@Override
+	public BaseResult importEnumTypes(File file) throws Exception {
+		VciBaseUtil.alertNotNull(file,"excel鏂囦欢");
+		if(!file.exists()){
+			throw new VciBaseException("瀵煎叆鐨別xcel鏂囦欢涓嶅瓨鍦�,{0}",new String[]{file.getPath()});
+		}
+		try{
+			//1銆佽鍙杄xcel涓殑鏁版嵁锛岀粍鎴愬璞�
+			ReadExcelOption excelOption = new ReadExcelOption();
+			List<OsEnumPO> poList = ExcelUtil.readDataObjectFromExcel(file, OsEnumPO.class,excelOption,(value, po, fieldName)->{});
+			//鍘婚櫎閮芥槸绌虹殑鎯呭喌
+			if(CollectionUtils.isEmpty(poList)){
+				return BaseResult.fail(ExcelLangCodeConstant.IMPORT_CONTENT_NULL,new String[]{});
+			}
+			//灏嗘灇涓惧拰鏋氫妇椤瑰鐞嗘垚涓�瀵瑰鍏崇郴鐨勫璞�
+			Map<String, OsEnumPO> groupPOMap = new HashMap<>();
+			for (OsEnumPO po : poList) {
+				//鎷兼帴鐢ㄦ潵浣滀负鍒嗙粍鐨刱ey
+				String key = po.getId() + "_" + po.getName() + "_" + po.getEnumValueDataType() + "_" + po.getLength();
+				OsEnumPO group = groupPOMap.get(key);
+				if (group == null) {
+					group = new OsEnumPO();
+					//鎷垮嚭鐜扮殑棣栬鍋氬悗缁殑鎻愮ず琛�
+					group.setRowIndex(po.getRowIndex());
+					group.setId(po.getId());
+					group.setName(po.getName());
+					group.setEnumValueDataType(po.getEnumValueDataType());
+					group.setLength(po.getLength());
+					groupPOMap.put(key, group);
+				}
+
+				OsEnumItemDTO itemDTO = new OsEnumItemDTO();
+				itemDTO.setName(po.getEnumItemName());
+				itemDTO.setValue(po.getValue());
+				itemDTO.setDescription(po.getDescription());
+
+				group.getItems().add(itemDTO);
+			}
+			Collection<OsEnumPO> newPOList = groupPOMap.values();
+			//鏁版嵁搴撴煡璇㈡槸鍚︽湁宸插瓨鍦ㄧ殑鏋氫妇鍚嶏紝鏂逛究鍚庣画鍋氬垽閲嶅鐞�
+			List<OsEnumVO> osEnumVOList = this.listEnumByIdCollection(poList.stream().map(OsEnumPO::getId).collect(Collectors.toSet()));
+			List<String> repeatEnumId = new ArrayList<>();
+			if(Func.isNotEmpty(osEnumVOList)){
+				repeatEnumId = osEnumVOList.stream().map(OsEnumVO::getId).collect(Collectors.toList());
+			}
+			//褰撳墠excel涓槸鍚﹂噸澶嶇敤鐨勫垽閲峂ap:锛坘ey锛氳处鍙凤紝value锛氳鍙凤級
+			Map<String, String> excelReapeat = new HashMap<>();
+			//鍒ゆ柇蹇呭~灞炴�ф槸鍚︿负绌猴紝鐢ㄦ埛鏄惁宸插瓨鍦紝浠ュ強閮ㄩ棬鏄惁濉敊绛夋牎楠岄�昏緫
+			List<String> finalRepeatEnumId = repeatEnumId;
+			newPOList.stream().forEach(osEnumPO -> {
+				if(Func.isBlank(osEnumPO.getId())){//鏋氫妇鍚�
+					throw new VciBaseException("绗��"+osEnumPO.getRowIndex()+"銆戣锛宔numnameerror");
+				}else if(Func.isBlank(osEnumPO.getEnumValueDataType())){
+					throw new VciBaseException("绗��"+osEnumPO.getRowIndex()+"銆戣锛宼ypeerror");
+				}else if(Func.isEmpty(osEnumPO.getLength())){
+					throw new VciBaseException("绗��"+osEnumPO.getRowIndex()+"銆戣锛宭engtherror");
+				}else if(!osEnumPO.getId().matches("^[A-Za-z]+$")){
+					throw new VciBaseException("绗��"+osEnumPO.getRowIndex()+"銆戣鏁版嵁锛屾灇涓惧悕绉板彧鑳戒负鑻辨枃瀛楁瘝");
+				}else if(excelReapeat.containsKey(osEnumPO.getId())){//鏋氫妇鍚嶈〃鏍间腑鍒ら噸
+					throw new VciBaseException("绗��"+excelReapeat.get(osEnumPO.getId())+"銆戣鍜岀銆�"+osEnumPO.getRowIndex()+"銆戣鏁版嵁锛屾灇涓惧悕閲嶅");
+				}else if (Func.isNotEmpty(osEnumVOList) && finalRepeatEnumId.contains(osEnumPO.getId())){//2銆佸垽鏂灇涓惧悕鏄惁涓庣郴缁熶腑閲嶅
+					throw new VciBaseException("绗��"+osEnumPO.getRowIndex()+"銆戣锛屾灇涓惧悕鍦ㄧ郴缁熶腑宸茬粡瀛樺湪,璇蜂慨鏀�!");
+				}
+				//鍏堝蹇呭~灞炴�у垽绌哄鐞�
+				excelReapeat.put(osEnumPO.getId(),osEnumPO.getRowIndex());
+			});
+			//淇濆瓨閫昏緫
+			for (OsEnumPO osEnumPO : newPOList) {
+				OsEnumDTO osEnumDTO = new OsEnumDTO();
+				//鐢熸垚瀛樺偍鐨凞TO瀵硅薄
+				osEnumDTO.setId(osEnumPO.getId());
+				osEnumDTO.setName(osEnumPO.getName());
+				osEnumDTO.setEnumValueDataType(osEnumPO.getEnumValueDataType());
+				osEnumDTO.setLength(osEnumPO.getLength());
+				osEnumDTO.setItems(osEnumPO.getItems());
+
+				//璋冪敤鏂板鏋氫妇鏂规硶
+				boolean addBoolean = this.addEnumType(osEnumDTO);
+				if(!addBoolean){
+					throw new PLException("500",new String[]{"淇濆瓨鏋氫妇鍚嶄负銆�" + osEnumDTO.getId() + "銆戠殑鏁版嵁鏃跺嚭鐜伴敊璇�!"});
+				}
+			}
+		}catch (Exception e){
+			if(logger.isErrorEnabled()){
+				logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e));
+			}
+			e.printStackTrace();
+			return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e);
+		}
+		return BaseResult.success("鏋氫妇瀵煎叆鎴愬姛锛�");
+	}
+
+	/*	private OsEnumVO getTestJson(int i){
+		String testJosn = "[{\"createTime\":\"2024-07-17 17:06:30.170\",\"creator\":\"developer\",\"enumValueDataType\":\"String\",\"enumValueDataTypeText\":\"瀛楃涓瞈",\"id\":\"test\",\"items\":[{\"description\":\"\",\"name\":\"1\",\"value\":\"11\"},{\"description\":\"\",\"name\":\"1\",\"value\":\"11\"}],\"lastModifier\":\"developer\",\"lastModifyTime\":\"2024-07-17 17:06:30.170\",\"length\":2,\"name\":\"test1\",\"oid\":\"4F9B4094-A4F5-E3CD-AC7C-1F33AA65F1E7\",\"ts\":\"2024-07-18 09:40:52.512\"},{\"createTime\":\"2024-07-17 09:49:31.592\",\"creator\":\"developer\",\"description\":null,\"enumValueDataType\":\"String\",\"enumValueDataTypeText\":\"瀛楃涓瞈",\"id\":\"testString\",\"items\":[{\"description\":\"11\",\"name\":\"11\",\"value\":\"11\"},{\"description\":\"\",\"name\":\"test1\",\"value\":\"1\"},,{\"description\":\"\",\"name\":\"test1\",\"value\":\"1\"}],\"lastModifier\":\"developer\",\"lastModifyTime\":\"2024-07-17 09:49:31.592\",\"length\":6,\"name\":\"testString\",\"oid\":\"AB3A7718-55C6-555E-A1FD-934763ACA3F2\",\"ts\":\"2024-07-17 16:47:33.038\"}]";
+		List<OsEnumVO> OsEnumVOs = JSON.parseArray(testJosn,OsEnumVO.class);
+		return OsEnumVOs.get(i);
+	}*/
+
+	/**
+	 * 鑾峰彇瀵煎叆妯℃澘鐨勭ず渚嬫暟鎹�
+	 * @return
+	 */
+	private List<OsEnumVO> getExportEnumTempExample(){
+		String testJosn = "[{\"enumValueDataType\":\"String\",\"id\":\"enum1\",\"items\":[{\"description\":\"enumitem1.1\",\"name\":\"enumitem1.1\",\"value\":\"1\"},{\"description\":\"enumitem1.2\",\"name\":\"enumitem1.2\",\"value\":\"2\"}],\"length\":2,\"name\":\"enum1\"},{\"enumValueDataType\":\"String\",\"id\":\"enum2\",\"items\":[{\"description\":\"enumitem2.1\",\"name\":\"enumitem2.1\",\"value\":\"1\"},{\"description\":\"enumitem2.2\",\"name\":\"enumitem2.2\",\"value\":\"2\"},{\"description\":\"enumitem2.3\",\"name\":\"enumitem2.3\",\"value\":\"3\"}],\"length\":6,\"name\":\"enum2\"}]";
+		List<OsEnumVO> OsEnumVOs = JSON.parseArray(testJosn,OsEnumVO.class);
+		return OsEnumVOs;
+	}
+
+	/**
 	 * 鏋氫妇椤规牎楠�
 	 * @param osEnumDTO
 	 * @return 鏍¢獙澶辫触鐩存帴鎶涘嚭寮傚父锛屽惁鍒欎笉浼氬仛浠讳綍杩斿洖
@@ -356,7 +642,7 @@
 		List<OsEnumItemDTO> items = osEnumDTO.getItems();
 		if (Func.isNotEmpty(items)) {
 			//鑾峰彇姝e垯锛屼富瑕佹槸閽堝Integer绫诲瀷鐨勬椂鍊�
-			String regular = "Integer".equals(osEnumDTO.getEnumValueDataType()) ? "^[0-9]+$" : "";
+			String regular = "Integer".equals(osEnumDTO.getEnumValueDataType()) ? "^-?\\d+$" : "";
 			//鍒╃敤set鐨刟dd杩斿洖鍊艰繘琛宯ame鍒ら噸
 			Set<String> uniqueNames = new HashSet<>();
 			for (OsEnumItemDTO item : items) {

--
Gitblit v1.9.3