| | |
| | | checkName(osAttributeDTO.getId()); |
| | | //检查默认值与属性类型是否匹配 |
| | | checkDefValue(osAttributeDTO); |
| | | //dto对象转换为存储所需对象 |
| | | osAttributeDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT)); |
| | | //osAttributeDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT)); |
| | | AttributeDef attributeDef = this.osAttributeDTO2AttributeDef(osAttributeDTO); |
| | | return platformClientUtil.getAttributeService().addAttributeDef(attributeDef); |
| | | } |
| | |
| | | } |
| | | //检查属性名是否已存在与系统中 |
| | | if(platformClientUtil.getAttributeService().checkRowIsExists(abName)){ |
| | | throw new PLException("500",new String[]{"属性名称在系统中已存在!"}); |
| | | throw new PLException("500",new String[]{"属性名称【" + abName + "】在系统中已存在!"}); |
| | | } |
| | | } |
| | | |
| | |
| | | excelDataList.add(new WriteExcelData(0,index, columns.get(index))); |
| | | } |
| | | //按照属性名查询属性,然后处理属性导出 |
| | | List<String> enumNameList = Func.toStrList(attrNames); |
| | | List<OsAttributeVO> osAttributeVOS = this.listAttrByIds(enumNameList); |
| | | List<String> attrameList = Func.toStrList(attrNames); |
| | | List<OsAttributeVO> osAttributeVOS = this.listAttrByIds(attrameList); |
| | | if(Func.isEmpty(osAttributeVOS)){ |
| | | excelDataList.add(new WriteExcelData(1,1, "根据属性名称未查询到属性信息,请刷新后尝试重新导出!")); |
| | | }else{ |
| | |
| | | List<OsAttributeDTO> dtoList = new ArrayList<>(); |
| | | //当前excel中是否重复用的判重Map:(key:判重属性,value:行号) |
| | | Map<String, String> excelReapeat = new HashMap<>(); |
| | | //判断必填属性是否为空,用户是否已存在,以及部门是否填错等校验逻辑 |
| | | poList.stream().forEach(osAttributePO -> { |
| | | if(Func.isBlank(osAttributePO.getId())){//属性名判空 |
| | | throw new VciBaseException("第【"+osAttributePO.getRowIndex()+"】行,enumnameerror"); |
| | | throw new VciBaseException("第【"+osAttributePO.getRowIndex()+"】行,attrnameerror"); |
| | | }else if(Func.isBlank(osAttributePO.getAttributeDataType())){ |
| | | throw new VciBaseException("第【"+osAttributePO.getRowIndex()+"】行,typeerror"); |
| | | }else if(excelReapeat.containsKey(osAttributePO.getId())){//属性名表格中判重 |
| | |
| | | //属性名excel中判重处理 |
| | | excelReapeat.put(osAttributePO.getId(),osAttributePO.getRowIndex()); |
| | | OsAttributeDTO osAttributeDTO = new OsAttributeDTO(); |
| | | //查询枚举是否存在,填写了枚举但没填写取值范围,这时候直接使用枚举项值作为默认的range |
| | | //查询属性是否存在,填写了枚举但没填写取值范围,这时候直接使用枚举项值作为默认的range |
| | | if(Func.isNotBlank(osAttributePO.getEnumId()) && Func.isBlank(osAttributePO.getRange())){ |
| | | try { |
| | | OsEnumVO enumVO = enumService.getEnumTypeById(osAttributePO.getEnumId()); |
| | |
| | | checkDefValue(osAttributeDTO); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | throw new VciBaseException(e.getMessage()); |
| | | throw new VciBaseException(VciBaseUtil.getExceptionMessage(e)); |
| | | } |
| | | dtoList.add(osAttributeDTO); |
| | | }); |
| | |
| | | e.printStackTrace(); |
| | | return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e); |
| | | } |
| | | return BaseResult.success("枚举导入成功!"); |
| | | return BaseResult.success("属性导入成功!"); |
| | | } |
| | | |
| | | /** |