Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java
@@ -1,11 +1,7 @@
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;
@@ -280,17 +276,19 @@
    public boolean addSave(OsStatusDTO statusDTO) throws Exception {
        VciBaseUtil.alertNotNull(
            statusDTO,"状态的信息",
            statusDTO.getId(),"状态的英文名称",
            statusDTO.getName(),"状态的中文名称"
            statusDTO.getId(),"状态的英文名称"
        );
        StatePool dbStatePool = platformClientUtil.getStatePoolService().getStatePool(statusDTO.getId());
        if (Func.isNotEmpty(dbStatePool) && Func.isNotBlank(dbStatePool.oid)) {
            throw new PLException("500",new String[]{"名称重复请更换名称!"});
        if (statusDTO.getId().length()>50) {
            throw new PLException("500",new String[]{"状态英文名称不能超过50个字符!"});
        }
        // 状态池名称只能为英文字母
        String regex = "[a-z A-Z]*";
        if ((!statusDTO.getId().matches(regex))) {
        if (!statusDTO.getId().matches(regex)) {
            throw new PLException("500",new String[]{"名称只能为英文!"});
        }
        StatePool dbStatePool = platformClientUtil.getStatePoolService().getStatePool(statusDTO.getId());
        if (Func.isNotEmpty(dbStatePool) && Func.isNotBlank(dbStatePool.oid)) {
            throw new PLException("500",new String[]{"名称重复请更换名称!"});
        }
        //虽然会自动生成oid,但是这儿设置主键,避免放入缓存的数据是没有oid的
        statusDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
@@ -351,26 +349,23 @@
        for(OsStatusDTO statusDTO : osStatusDTOS){
            //oid和ts判空
            String oid = statusDTO.getOid();
            //name主要用来对缓存数据删除
            String name = statusDTO.getName();
            //id主要用来对缓存数据删除
            String id = statusDTO.getId();
            //后台会用ts进行数据一致性校验
            Date ts = statusDTO.getTs();
            if(Func.isBlank(oid) || Func.isBlank(name) || Func.isEmpty(ts)){
            if(Func.isBlank(oid) || Func.isBlank(id) || Func.isEmpty(ts)){
                throw new PLException("500",new String[]{"待删除的状态列表中主键【oid】、调整时间【ts】、状态名称【name】不能为空!"});
            }
            StatePool statePool = new StatePool();
            statePool.oid = oid;
            statePool.name = name;
            statePool.name = id;
            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 + "】的数据时出现错误!"});
            }
        }
        boolean res = platformClientUtil.getStatePoolService().deleteStatePools(statePoolList.toArray(new StatePool[statePoolList.size()]));
        //clearCache();
        self.selectAllStatusMap();
        return true;
        return res;
    }
    /**
@@ -384,7 +379,7 @@
        statePool.oid = statusDTO.getOid();
        statePool.id = "";
        statePool.name = statusDTO.getId();
        statePool.imagePath = statusDTO.getImagePath();
        //statePool.imagePath = statusDTO.getImagePath();
        statePool.description = statusDTO.getDescription()==null?"":statusDTO.getDescription();
        String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
        long now = VciDateUtil.getNowTime();
@@ -404,14 +399,14 @@
     * @return
     */
    @Override
    public String exportStatus(String exportFileName, String statusOids) throws PLException {
    public String exportStatus(String exportFileName, String statusOids,boolean flag/*控制导出的列名是否和导入模板一致*/) 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("名称", "标签", "图片", "描述"));
        List<String> columns = this.getCloumns(flag);
        //写excel
        String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + exportFileName +  ".xls";
@@ -433,7 +428,7 @@
            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(),2, osStatusVO.getImagePath()));
            excelDataList.add(new WriteExcelData(i.get(),3, osStatusVO.getDescription()));
            i.getAndIncrement();
        });
@@ -453,9 +448,7 @@
        //界面没传名称,使用默认导出名称
        exportFileName = Func.isBlank(exportFileName) ?  "状态池导入模板_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):exportFileName;
        //设置列名
        List<String> columns = new ArrayList<>(
                Arrays.asList("名称(不能为空)", "标签(对名称的解释)","图片(路径)", "描述(可以为空)")
        );
        List<String> columns = this.getCloumns(true);
        //设置必填列
        ColumnNameisRed.clear();
        ColumnNameisRed.add(0);
@@ -486,6 +479,20 @@
    }
    /**
     * 获取导出或导入模板的列名
     * @param flag 是否获取导入模板列名
     * @return
     */
    private List<String> getCloumns(boolean flag){
        if(flag){
            return new ArrayList<>(
                    Arrays.asList("名称(不能为空)", "标签(对名称的解释)"/*,"图片(路径)"*/, "描述(可以为空)")
            );
        }
        return new ArrayList<>(Arrays.asList("名称", "标签"/*, "图片"*/, "描述"));
    }
    /**
     * 导入状态
     * @param file
     * @return
@@ -508,7 +515,6 @@
            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());
@@ -518,14 +524,14 @@
                } catch (PLException e) {
                    e.printStackTrace();
                    logger.error(e.getMessage());
                    throw new VciBaseException(e.getMessage());
                    throw new VciBaseException(VciBaseUtil.getExceptionMessage(e));
                }
                if(Func.isBlank(osStatusPO.getId())){//属性名判空
                    throw new VciBaseException("第【"+osStatusPO.getRowIndex()+"】行,enumnameerror");
                if(Func.isBlank(osStatusPO.getId())){//状态名判空
                    throw new VciBaseException("第【"+osStatusPO.getRowIndex()+"】行,statusnameerror");
                }else if(!osStatusPO.getId().matches("[a-z A-Z]*")){
                    // 状态池名称只能为英文字母
                    throw new VciBaseException("名称只能为英文!");
                }else if(excelReapeat.containsKey(osStatusPO.getId())){//属性名表格中判重
                }else if(excelReapeat.containsKey(osStatusPO.getId())){//状态名表格中判重
                    throw new VciBaseException("第【"+excelReapeat.get(osStatusPO.getId())+"】行和第【"+osStatusPO.getRowIndex()+"】行数据,名称重复");
                }
                //状态名excel中判重处理
@@ -534,7 +540,7 @@
                osStatusDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
                osStatusDTO.setId(osStatusPO.getId());
                osStatusDTO.setName(osStatusPO.getName());
                osStatusDTO.setImagePath(osStatusPO.getImagePath());
                //osStatusDTO.setImagePath(osStatusPO.getImagePath());
                osStatusDTO.setDescription(osStatusPO.getDescription());
                statePoolList.add(statusDTO2DO(osStatusDTO));
@@ -548,7 +554,7 @@
            e.printStackTrace();
            return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e);
        }
        return BaseResult.success("枚举导入成功!");
        return BaseResult.success("状态导入成功!");
    }
    /**