| | |
| | | |
| | | 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; |
| | |
| | | /** |
| | | * 必填列 |
| | | */ |
| | | private ArrayList<Integer> ColumnNameisRed = new ArrayList<Integer>(); |
| | | private List<Integer> ColumnNameisRed = new ArrayList<Integer>(); |
| | | |
| | | /** |
| | | * 日志 |
| | |
| | | if(Func.isBlank(enumName)){ |
| | | throw new PLException("500",new String[]{"请选择要查询应用范围的枚举!"}); |
| | | } |
| | | String[] attrubyteNames = platformClientUtil.getAttributeService().getAttrubyteNamesByEMName(enumName); |
| | | if(Func.isEmpty(attrubyteNames)){ |
| | | String[] attrubuteNames = platformClientUtil.getAttributeService().getAttrubyteNamesByEMName(enumName); |
| | | if(Func.isEmpty(attrubuteNames)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Map<String,String>> attrubyteMapList = new ArrayList<>(); |
| | | Arrays.stream(attrubyteNames).forEach(attrName->{ |
| | | List<Map<String,String>> attrubuteMapList = new ArrayList<>(); |
| | | Arrays.stream(attrubuteNames).forEach(attrName->{ |
| | | Map<String, String> itemMap = new HashMap<>(); |
| | | itemMap.put("enumName",enumName); |
| | | itemMap.put("source",attrName); |
| | | attrubyteMapList.add(itemMap); |
| | | attrubuteMapList.add(itemMap); |
| | | }); |
| | | return attrubyteMapList; |
| | | return attrubuteMapList; |
| | | } |
| | | |
| | | /** |
| | |
| | | String name = osEnumDTO.getName(); |
| | | Date ts = osEnumDTO.getTs(); |
| | | if(Func.isBlank(oid) || Func.isBlank(name) || Func.isEmpty(ts)){ |
| | | throw new PLException("500",new String[]{"待删除的枚举列表中主键【oid】和调整时间【ts】不能为空!"}); |
| | | throw new PLException("500",new String[]{"待删除的枚举列表中主键【oid】、调整时间【ts】、属性名【name】不能为空!"}); |
| | | } |
| | | //判断枚举是否有被引用 |
| | | List<Map<String, String>> usedEnumList = this.getUsedEnumList(name); |
| | | if(Func.isNotEmpty(usedEnumList)){ |
| | | throw new PLException("500",new String[]{"删除的枚举中【" + name + "】,已被引用!"}); |
| | | throw new PLException("500",new String[]{"删除的枚举中,枚举名称为:【" + name + "】,已被引用!"}); |
| | | } |
| | | EnumType enumType = new EnumType(); |
| | | enumType.oid = oid; |
| | |
| | | if(Func.isNotEmpty(osEnumVOList)){ |
| | | repeatEnumId = osEnumVOList.stream().map(OsEnumVO::getId).collect(Collectors.toList()); |
| | | } |
| | | //当前excel中是否重复用的判重Map:(key:账号,value:行号) |
| | | //当前excel中是否重复用的判重Map:(key:判重属性,value:行号) |
| | | Map<String, String> excelReapeat = new HashMap<>(); |
| | | //判断必填属性是否为空,用户是否已存在,以及部门是否填错等校验逻辑 |
| | | List<String> finalRepeatEnumId = repeatEnumId; |
| | |
| | | }else if (Func.isNotEmpty(osEnumVOList) && finalRepeatEnumId.contains(osEnumPO.getId())){//2、判断枚举名是否与系统中重复 |
| | | throw new VciBaseException("第【"+osEnumPO.getRowIndex()+"】行,枚举名在系统中已经存在,请修改!"); |
| | | } |
| | | //先对必填属性判空处理 |
| | | //先对枚举名excel中需要判重处理 |
| | | excelReapeat.put(osEnumPO.getId(),osEnumPO.getRowIndex()); |
| | | }); |
| | | //保存逻辑 |
| | |
| | | } |
| | | 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); |
| | | }*/ |
| | | |
| | | /** |
| | | * 获取导入模板的示例数据 |
| | |
| | | private EnumType osEnumDTO2EnumType(OsEnumDTO osEnumDTO){ |
| | | EnumType enumType = new EnumType(); |
| | | enumType.oid = osEnumDTO.getOid(); |
| | | enumType.name = osEnumDTO.getId(); |
| | | //枚举名统一转成小写,避免后期出现其他问题 |
| | | enumType.name = osEnumDTO.getId().toLowerCase(Locale.ROOT); |
| | | enumType.label = osEnumDTO.getName(); |
| | | enumType.length = osEnumDTO.getLength(); |
| | | enumType.creator = osEnumDTO.getCreator(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据枚举类型查询枚举:枚举名 , 枚举 |
| | | * @param enumType:String, Integer |
| | | * @return |
| | | */ |
| | | public List<Map<String,List<String>>> getEnumMapByType(String enumType){ |
| | | List<Map<String,List<String>>> enumMapList = new ArrayList<>(); |
| | | EnumType[] emArray = null; |
| | | try { |
| | | emArray = platformClientUtil.getEnumService().getEnumTypesByType(enumType); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(emArray == null || emArray.length == 0){ |
| | | return null; |
| | | } |
| | | EnumType emItem; |
| | | for(int i = 0; i < emArray.length; i++){ |
| | | emItem = emArray[i]; |
| | | EnumItem[] emChildren = emItem.items; |
| | | ArrayList<String> valueList = new ArrayList<String>(); |
| | | for(int k = 0; k < emChildren.length; k++){ |
| | | EnumItem emChild = emChildren[k]; |
| | | String value = emChild.value; |
| | | valueList.add(value); |
| | | } |
| | | Map<String, List<String>> enumMap = new HashMap<>(); |
| | | enumMap.put(emItem.name, valueList); |
| | | enumMapList.add(enumMap); |
| | | } |
| | | return enumMapList; |
| | | } |
| | | |
| | | /** |
| | | * 清除缓存 |
| | | */ |
| | | @Override |