对象建模——枚举和枚举项的查询、新增、修改、删除、查看使用范围、下载导入模板、导入、导出接口并联调。
已修改8个文件
已添加1个文件
599 ■■■■■ 文件已修改
Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/bo/WriteExcelData.java 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-poi/src/main/java/com/vci/starter/poi/util/ExcelUtil.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsEnumPO.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/SmUserPO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java 322 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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开始
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()));
            });
        }
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<>();
}
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
 */
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)
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
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();
        }
    }
}
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是枚举的英文名称
     */
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);
        //手动设置主键,否则平台直接用没有主键的枚举放进了缓存中,导致后续查询的数据没有oid
        osEnumDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
        osEnumDTO.setLastModifier(userId);
        return platformClientUtil.getEnumService().addEnumType(this.osEnumDTO2EnumType(osEnumDTO));
    }
@@ -308,7 +337,7 @@
        //3、枚举项判重,和长度等校验
        checkOsEnumItem(osEnumDTO);
        //将osEnumVO中的默认值赋值给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[]{"待删除的枚举列表中主键【oid】和调整时间【ts】不能为空!"});
            }
            //判断枚举是否有被引用
            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("枚举名称", "标签", "返回类型", "长度", "枚举项名称", "枚举值", "描述"));
        //写excel
        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å¹´MM月dd日 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å¹´MM月dd日 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的写法"));
        //写excel
        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("导入的excel文件不存在,{0}",new String[]{file.getPath()});
        }
        try{
            //1、读取excel中的数据,组成对象
            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) {
                //拼接用来作为分组的key
                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中是否重复用的判重Map:(key:账号,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()+"】行,enumnameerror");
                }else if(Func.isBlank(osEnumPO.getEnumValueDataType())){
                    throw new VciBaseException("第【"+osEnumPO.getRowIndex()+"】行,typeerror");
                }else if(Func.isEmpty(osEnumPO.getLength())){
                    throw new VciBaseException("第【"+osEnumPO.getRowIndex()+"】行,lengtherror");
                }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();
                //生成存储的DTO对象
                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)) {
            //获取正则,主要是针对Integer类型的时候
            String regular = "Integer".equals(osEnumDTO.getEnumValueDataType()) ? "^[0-9]+$" : "";
            String regular = "Integer".equals(osEnumDTO.getEnumValueDataType()) ? "^-?\\d+$" : "";
            //利用set的add返回值进行name判重
            Set<String> uniqueNames = new HashSet<>();
            for (OsEnumItemDTO item : items) {