ludc
2024-07-30 1b223b109ec65a2934e283bb0be2c0e116b013e4
状态池相关接口上传(已测试待联调)
已修改6个文件
已添加1个文件
489 ■■■■ 文件已修改
Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsAttributePO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsStatusPO.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLinkTypeController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/VciOsStatusController.java 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsStatusServiceI.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java 267 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsAttributePO.java
@@ -52,7 +52,7 @@
    /**
     * å±žæ€§ç±»åž‹
     */
    @ExcelColumn(value="属性类型",nullable = false)
    @ExcelColumn(value="属性类型(请参照新增界面的属性类型填写)",nullable = false)
    private String attributeDataType;
    /**
@@ -112,7 +112,7 @@
    /**
     * å±žæ€§é•¿åº¦
     */
    @ExcelColumn(value="取值范围")
    @ExcelColumn(value="取值范围)")
    private String range;
}
Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsStatusPO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,54 @@
package com.vci.po;
import com.vci.starter.poi.annotation.ExcelColumn;
import com.vci.starter.web.pagemodel.BaseModelVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
 * å±žæ€§æ± å¯¼å…¥å¯¹è±¡
 * @author ludc
 * @date 2024/7/19 11:11
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OsStatusPO 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="图片(路径)")
    private String imagePath;
    /**
     * æè¿°
     */
    @ExcelColumn(value="描述(可以为空)")
    private String description;
}
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLinkTypeController.java
@@ -60,7 +60,6 @@
     * @return é“¾æŽ¥ç±»åž‹çš„æ˜¾ç¤ºå¯¹è±¡
     */
    @GetMapping("/getAllLtName")
    @VciUnCheckRight
    public BaseResult getAllLtName(){
        try {
            return BaseResult.dataList(linkTypeService.getAllLtName());
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/VciOsStatusController.java
@@ -1,20 +1,33 @@
package com.vci.web.controller;
import com.vci.constant.FrameWorkLangCodeConstant;
import com.vci.dto.OsAttributeDTO;
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.dto.OsStatusDTO;
import com.vci.pagemodel.OsLifeCycleVO;
import com.vci.pagemodel.OsStatusVO;
import com.vci.starter.web.util.ControllerUtil;
import com.vci.starter.web.util.LocalFileUtil;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.web.service.OsLifeCycleServiceI;
import com.vci.web.service.OsStatusServiceI;
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;
/**
 * çŠ¶æ€çš„æŽ§åˆ¶å™¨
@@ -87,7 +100,6 @@
     * @return æ‰§è¡Œç»“æžœ
     */
    @PostMapping("/addSave")
    @VciUnCheckRight
    public BaseResult addSave(@RequestBody OsStatusDTO statusDTO){
        try {
            return statusService.addSave(statusDTO) ? BaseResult.success("添加状态成功!"):BaseResult.fail("添加状态失败!");
@@ -118,13 +130,19 @@
    /**
     * åˆ é™¤çŠ¶æ€
     * @param oids çŠ¶æ€çš„ä¸»é”®
     * @param osStatusDTOS çŠ¶æ€çš„DTO对象
     * @return æ‰§è¡Œç»“æžœ
     */
    @DeleteMapping("/delete")
    public BaseResult delete(String oids){
        statusService.delete(oids);
        return BaseResult.success();
    @DeleteMapping("/deleteStatus")
    public BaseResult deleteStatus(@RequestBody List<OsStatusDTO> osStatusDTOS){
        try {
            return statusService.deleteStatus(osStatusDTOS) ? BaseResult.success("删除状态成功!"):BaseResult.fail("删除状态失败!");
        }catch (Exception e) {
            e.printStackTrace();
            String exceptionMessage = "删除状态时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
            logger.error(exceptionMessage);
            return BaseResult.fail(exceptionMessage);
        }
    }
    /**
@@ -137,4 +155,75 @@
        return BaseResult.success(statusService.getObjectByOid(oid));
    }
    /**
     * å¯¼å‡ºçŠ¶æ€
     * @param exportFileName
     * @param statusOids
     * @param response
     */
    @GetMapping( "/exportStatus")
    @VciBusinessLog(operateName = "导出状态")
    public void exportStatus(String exportFileName,String statusOids, HttpServletResponse response){
        try {
            String excelPath = statusService.exportStatus(exportFileName,statusOids);
            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( "/downloadStatusTemplate")
    @VciBusinessLog(operateName = "导出状态")
    public void downloadStatusTemplate(String exportFileName, HttpServletResponse response){
        try {
            String excelPath = statusService.downloadStatusTemplate(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
     */
    @PostMapping("/importStatus")
    @VciBusinessLog(operateName = "导入状态")
    public BaseResult importStatus(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 statusService.importStatus(file1);
            } else {
                return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"无导入的文件"});
            }
        }catch (Throwable e) {
            throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e);
        }finally {
            file1.delete();
        }
    }
}
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsStatusServiceI.java
@@ -1,11 +1,14 @@
package com.vci.web.service;
import com.vci.corba.common.PLException;
import com.vci.corba.omd.stm.StatePool;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.starter.web.pagemodel.PageHelper;
import com.vci.dto.OsStatusDTO;
import com.vci.pagemodel.OsStatusVO;
import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -98,9 +101,9 @@
    /**
     * åˆ é™¤çŠ¶æ€
     * @param oids ä¸»é”®
     * @param osStatusDTOS
     */
    boolean delete(String oids);
    boolean deleteStatus(List<OsStatusDTO> osStatusDTOS) throws PLException;
    /**
     * çŠ¶æ€çš„æ•°æ®ä¼ è¾“å¯¹è±¡è½¬æ¢ä¸ºæ•°æ®å¯¹è±¡
@@ -108,4 +111,28 @@
     * @return å¹³å°çš„æ•°æ®å¯¹è±¡
     */
    StatePool statusDTO2DO(OsStatusDTO statusDTO);
    /**
     * å¯¼å‡ºé€‰ä¸­çš„状态
     * @param exportFileName å¯¼å‡ºçš„æ–‡ä»¶å
     * @param statusOids éœ€è¦å¯¼å‡ºçš„属性名称
     * @return
     */
    String exportStatus(String exportFileName,String statusOids) throws PLException;
    /**
     * ä¸‹è½½çŠ¶æ€å¯¼å…¥æ¨¡æ¿
     * @param exportFileName
     * @return
     * @throws PLException
     */
    String downloadStatusTemplate(String exportFileName) throws Exception;
    /**
     * å¯¼å…¥çŠ¶æ€
     * @param file
     * @return
     */
    BaseResult importStatus(File file) throws Exception;
}
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java
@@ -33,6 +33,7 @@
import com.vci.web.properties.UsedNames;
import com.vci.web.service.OsAttributeServiceI;
import com.vci.web.service.OsBaseServiceI;
import com.vci.web.service.OsEnumServiceI;
import com.vci.web.service.OsLinkTypeServiceI;
import com.vci.web.util.Func;
import com.vci.web.util.PlatformClientUtil;
@@ -111,6 +112,13 @@
    @Autowired(required = false)
    @Lazy
    private OsBtmServiceImpl osBtmService;
    /**
     * æžšä¸¾çš„æœåŠ¡
     */
    @Autowired
    @Lazy
    private OsEnumServiceI  enumService;
    /**
     *  å¿…填列
@@ -600,6 +608,7 @@
                if(StringUtils.isNotBlank(osAttributeDTO.getLinkTypeName())){
                    //参照链接类型
                    sb.append(LINKTYPENAME).append(" = ").append(osAttributeDTO.getLinkTypeName()).append(";");
                    sb.append(VERSION).append(" = ").append(osAttributeDTO.getVersion()).append(";");
                }
                sb.append(LENGTH).append(" = ").append(length > osAttributeDTO.getAttrLength()?length:osAttributeDTO.getAttrLength()).append(";");
                if (StringUtils.isNotBlank(osAttributeDTO.getEnumId())) {
@@ -812,7 +821,7 @@
            if(Func.isBlank(oid) || Func.isBlank(name) || Func.isEmpty(ts)){
                throw new PLException("500",new String[]{"待删除的属性列表中主键【oid】、调整时间【ts】、属性名【name】不能为空!"});
            }
            //判断枚举是否有被引用
            //判断属性是否有被引用
            List<Map<String, String>> usedAttrList = this.getUsedAttributeList(name);
            if(Func.isNotEmpty(usedAttrList)){
                throw new PLException("500",new String[]{"删除的属性中,属性名称为:【" + name + "】,已被引用!"});
@@ -934,7 +943,7 @@
        //设置列名
        List<String> columns = new ArrayList<>(
                Arrays.asList("属性名", "标签", "描述",
                        "属性类型", "允许为空(是/否)", "默认值", "使用的枚举英文名称", "参照的业务类型编号",
                        "属性类型(请参照新增界面的属性类型填写)", "允许为空(是/否)", "默认值", "使用的枚举英文名称", "参照的业务类型编号",
                        "参照的链接类型编号","版本版次","属性长度", "小数精度位数","小数刻度位数","取值范围")
        );
        //设置必填列
@@ -1010,6 +1019,22 @@
                //属性名excel中判重处理
                excelReapeat.put(osAttributePO.getId(),osAttributePO.getRowIndex());
                OsAttributeDTO osAttributeDTO = new OsAttributeDTO();
                //查询枚举是否存在,填写了枚举但没填写取值范围,这时候直接使用枚举项值作为默认的range
                if(Func.isNotBlank(osAttributePO.getEnumId()) && Func.isBlank(osAttributePO.getRange())){
                    try {
                        OsEnumVO enumVO = enumService.getEnumTypeById(osAttributePO.getEnumId());
                        if(Func.isEmpty(enumVO)){
                            throw new VciBaseException("第【" + osAttributePO.getRowIndex() + "】行数据,通过枚举名称【" + osAttributePO.getEnumId()
                                    + "】未获取到枚举信息!");
                        }
                        String itemValues = enumVO.getItemMaps().values().stream().collect(Collectors.joining(";"));
                        osAttributeDTO.setRange(itemValues);
                    } catch (PLException e) {
                        e.printStackTrace();
                        throw new VciBaseException("枚举查询失败,原因:"+e.getMessage());
                    }
                    osAttributeDTO.setBtmTypeId(osAttributePO.getEnumId());
                }
                osAttributeDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
                osAttributeDTO.setId(osAttributePO.getId());
                osAttributeDTO.setName(osAttributePO.getName());
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java
@@ -1,19 +1,27 @@
package com.vci.web.service.impl;
import com.vci.corba.common.PLException;
import com.vci.corba.omd.atm.AttributeDef;
import com.vci.corba.omd.stm.StatePool;
import com.vci.dto.OsAttributeDTO;
import com.vci.pagemodel.OsEnumVO;
import com.vci.po.OsAttributePO;
import com.vci.po.OsStatusPO;
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.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.starter.web.pagemodel.PageHelper;
import com.vci.starter.web.util.LangBaseUtil;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.starter.web.util.VciDateUtil;
import com.vci.starter.web.util.*;
import com.vci.dto.OsStatusDTO;
import com.vci.model.OsStatusDO;
import com.vci.pagemodel.OsStatusVO;
import com.vci.starter.web.util.WebThreadLocalUtil;
import com.vci.web.service.OsLifeCycleServiceI;
import com.vci.web.service.OsStatusServiceI;
import com.vci.web.service.WebBoServiceI;
@@ -21,6 +29,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;
@@ -28,8 +37,9 @@
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.swing.*;
import java.io.File;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import static com.vci.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST;
@@ -66,6 +76,11 @@
    @Autowired(required = false)
    @Lazy
    private OsLifeCycleServiceI lifeCycleService;
    /**
     *  å¿…填列
     */
    private List<Integer> ColumnNameisRed = new ArrayList<Integer>();
    /**
     * åŠ è½½è‡ªèº«
@@ -182,8 +197,9 @@
                    throw WebUtil.getVciBaseException(e);
                }
            }
            return true;
        }
        return true;
        return false;
    }
    /**
@@ -267,24 +283,26 @@
            statusDTO.getId(),"状态的英文名称",
            statusDTO.getName(),"状态的中文名称"
        );
        StatePool dbStatePool = platformClientUtil.getStatePoolService().getStatePool(statusDTO.getName());
        if (Func.isNotEmpty(dbStatePool) || Func.isNotBlank(dbStatePool.oid)) {
        StatePool dbStatePool = platformClientUtil.getStatePoolService().getStatePool(statusDTO.getId());
        if (Func.isNotEmpty(dbStatePool) && Func.isNotBlank(dbStatePool.oid)) {
            throw new PLException("500",new String[]{"名称重复请更换名称!"});
        }
        // çŠ¶æ€æ± åç§°åªèƒ½ä¸ºè‹±æ–‡å­—æ¯
        String regex = "[a-z A-Z]*";
        if ((!dbStatePool.name.matches(regex))) {
        if ((!statusDTO.getId().matches(regex))) {
            throw new PLException("500",new String[]{"名称只能为英文!"});
        }
        //虽然会自动生成oid,但是这儿设置主键,避免放入缓存的数据是没有oid的
        statusDTO.setOid(VciBaseUtil.getPk());
        StatePool pool = statusDTO2DO(statusDTO);
        List<StatePool> poolList = new ArrayList<>();
        poolList.add(pool);
        batchAddStatus(poolList);
        //clearCache();
        self.selectAllStatusMap();
        return true;
        statusDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
        try {
            boolean res = batchAddStatus(Arrays.asList(statusDTO2DO(statusDTO)));
            self.selectAllStatusMap();
            return res;
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
            return false;
        }
    }
    /**
@@ -304,34 +322,53 @@
        StatePool pool = statusDTO2DO(statusDTO);
        pool.creator = statusVO.getCreator();
        pool.createTime = VciDateUtil.getTime(statusVO.getCreateTime());
        List<StatePool> poolList = new ArrayList<>();
        poolList.add(pool);
        batchEditSave(poolList);
        clearCache();
        self.selectAllStatusMap();
        return true;
        try {
            boolean res = batchEditSave(Arrays.asList(pool));
            self.selectAllStatusMap();
            return res;
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
            return false;
        }
    }
    /**
     * åˆ é™¤çŠ¶æ€
     * @param oids ä¸»é”®
     * @param osStatusDTOS
     */
    @Override
    public boolean delete(String oids){
        VciBaseUtil.alertNotNull(oids,"主键");
        //判断是否被引用
        List<OsStatusVO> statusVOList1 = selectByOidCollection(VciBaseUtil.str2List(oids));
        if(statusVOList1.stream().anyMatch(statusVO -> lifeCycleService.checkStatusUsed(statusVO))){
    public boolean deleteStatus(List<OsStatusDTO> osStatusDTOS) throws PLException {
        VciBaseUtil.alertNotNull(osStatusDTOS,"待删除的属性列表");
        Set<String> oids = osStatusDTOS.stream().map(OsStatusDTO::getOid).collect(Collectors.toSet());
        List<OsStatusVO> osStatusVOList = selectByOidCollection(oids);
        //判断枚举是否有被引用
        if(osStatusVOList.stream().anyMatch(statusVO -> lifeCycleService.checkStatusUsed(statusVO))){
            throw new VciBaseException("状态在生命周期中被使用,不能删除");
        }
        statusVOList1.stream().forEach(statusVO -> {
            try {
                platformClientUtil.getStatePoolService().deleteStatePool(statusVO2DO(statusVO));
            }catch (Throwable e){
                throw new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[]{},e);
        //平台的deleteStatus方法必传三个参数,oid、name和ts
        List<StatePool> statePoolList = new ArrayList<>();
        for(OsStatusDTO statusDTO : osStatusDTOS){
            //oid和ts判空
            String oid = statusDTO.getOid();
            //name主要用来对缓存数据删除
            String name = statusDTO.getName();
            //后台会用ts进行数据一致性校验
            Date ts = statusDTO.getTs();
            if(Func.isBlank(oid) || Func.isBlank(name) || Func.isEmpty(ts)){
                throw new PLException("500",new String[]{"待删除的状态列表中主键【oid】、调整时间【ts】、状态名称【name】不能为空!"});
            }
        });
        clearCache();
            StatePool statePool = new StatePool();
            statePool.oid = oid;
            statePool.name = name;
            statePool.ts = Func.format(ts,VciDateUtil.DateTimeMillFormat);
            statePoolList.add(statePool);
            boolean res = platformClientUtil.getStatePoolService().deleteStatePool(statePool);
            if(!res){
                throw new PLException("500",new String[]{"删除状态名称为【" + name + "】的数据时出现错误!"});
            }
        }
        //clearCache();
        self.selectAllStatusMap();
        return true;
    }
@@ -351,13 +388,167 @@
        statePool.description = statusDTO.getDescription()==null?"":statusDTO.getDescription();
        String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
        long now = VciDateUtil.getNowTime();
        statePool.creator = userId;
        statePool.creator = Func.isBlank(statusDTO.getCreator()) ? userId:statusDTO.getCreator();
        statePool.createTime = now;
        statePool.modifier = userId;
        statePool.modifyTime = now;
        statePool.ts = statusDTO.getTs()==null?VciDateUtil.getNowString(VciDateUtil.DateTimeMillFormat):VciDateUtil.date2Str(statusDTO.getTs(),VciDateUtil.DateTimeMillFormat);
        statePool.tag = statusDTO.getName();
        return statePool;
    }
    /**
     * å¯¼å‡ºé€‰ä¸­çš„状态
     * @param exportFileName å¯¼å‡ºçš„æ–‡ä»¶å
     * @param statusOids éœ€è¦å¯¼å‡ºçš„属性名称
     * @return
     */
    @Override
    public String exportStatus(String exportFileName, String statusOids) throws PLException {
        if(Func.isBlank(statusOids)){
            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> statusOidList = Func.toStrList(statusOids);
        AtomicInteger i = new AtomicInteger(1);
        statusOidList.stream().forEach(oid->{
            OsStatusVO osStatusVO = this.getObjectByOid(oid);
            excelDataList.add(new WriteExcelData(i.get(),0, osStatusVO.getId()));
            excelDataList.add(new WriteExcelData(i.get(),1, osStatusVO.getName()));
            excelDataList.add(new WriteExcelData(i.get(),2, osStatusVO.getImagePath()));
            excelDataList.add(new WriteExcelData(i.get(),3, osStatusVO.getDescription()));
            i.getAndIncrement();
        });
        WriteExcelOption excelOption = new WriteExcelOption(excelDataList);
        ExcelUtil.writeDataToFile(excelPath, excelOption);
        return excelPath;
    }
    /**
     * ä¸‹è½½çŠ¶æ€å¯¼å…¥æ¨¡æ¿
     * @param exportFileName
     * @return
     * @throws PLException
     */
    @Override
    public String downloadStatusTemplate(String exportFileName) throws Exception {
        //界面没传名称,使用默认导出名称
        exportFileName = Func.isBlank(exportFileName) ?  "状态池导入模板_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):exportFileName;
        //设置列名
        List<String> columns = new ArrayList<>(
                Arrays.asList("名称(不能为空)", "标签(对名称的解释)","图片(路径)", "描述(可以为空)")
        );
        //设置必填列
        ColumnNameisRed.clear();
        ColumnNameisRed.add(0);
        //写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++) {
            //判断是否为必填列,给必填列设置颜色
            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)));
            }
        }
        WriteExcelOption excelOption = new WriteExcelOption(excelDataList);
        ExcelUtil.writeDataToFile(excelPath, excelOption);
        return excelPath;
    }
    /**
     * å¯¼å…¥çŠ¶æ€
     * @param file
     * @return
     */
    @Override
    public BaseResult importStatus(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<OsStatusPO> poList = ExcelUtil.readDataObjectFromExcel(file, OsStatusPO.class,excelOption,(value, po, fieldName)->{});
            //去除都是空的情况
            if(CollectionUtils.isEmpty(poList)){
                return BaseResult.fail(ExcelLangCodeConstant.IMPORT_CONTENT_NULL,new String[]{});
            }
            //excel判重,数据校验,dto对象转换,存储对象转换,执行保存
            List<StatePool> statePoolList = new ArrayList<>();
            //当前excel中是否重复用的判重Map:(key:判重属性,value:行号)
            Map<String, String> excelReapeat = new HashMap<>();
            //判断必填属性是否为空,用户是否已存在,以及部门是否填错等校验逻辑
            poList.stream().forEach(osStatusPO -> {
                try {
                    StatePool dbStatePool = platformClientUtil.getStatePoolService().getStatePool(osStatusPO.getId());
                    if(Func.isNotEmpty(dbStatePool) && Func.isNotBlank(dbStatePool.oid)){
                        throw new VciBaseException("第【"+osStatusPO.getRowIndex()+"】行,名称在系统中已经存在,请修改!");
                    }
                } catch (PLException e) {
                    e.printStackTrace();
                    logger.error(e.getMessage());
                    throw new VciBaseException(e.getMessage());
                }
                if(Func.isBlank(osStatusPO.getId())){//属性名判空
                    throw new VciBaseException("第【"+osStatusPO.getRowIndex()+"】行,enumnameerror");
                }else if(!osStatusPO.getId().matches("[a-z A-Z]*")){
                    // çŠ¶æ€æ± åç§°åªèƒ½ä¸ºè‹±æ–‡å­—æ¯
                    throw new VciBaseException("名称只能为英文!");
                }else if(excelReapeat.containsKey(osStatusPO.getId())){//属性名表格中判重
                    throw new VciBaseException("第【"+excelReapeat.get(osStatusPO.getId())+"】行和第【"+osStatusPO.getRowIndex()+"】行数据,名称重复");
                }
                //状态名excel中判重处理
                excelReapeat.put(osStatusPO.getId(),osStatusPO.getRowIndex());
                OsStatusDTO osStatusDTO = new OsStatusDTO();
                osStatusDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
                osStatusDTO.setId(osStatusPO.getId());
                osStatusDTO.setName(osStatusPO.getName());
                osStatusDTO.setImagePath(osStatusPO.getImagePath());
                osStatusDTO.setDescription(osStatusPO.getDescription());
                statePoolList.add(statusDTO2DO(osStatusDTO));
            });
            //执行保存操作
            batchAddStatus(statePoolList);
        }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("枚举导入成功!");
    }
    /**
@@ -381,7 +572,5 @@
        statePool.tag = statusVO.getName();
        return statePool;
    }
}