| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.MessageFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | |
| | | String uuid=VciBaseUtil.getPk(); |
| | | boolean isCreateUUid=false; |
| | | boolean isExport=false; |
| | | long start = System.currentTimeMillis(); |
| | | //long start = System.currentTimeMillis(); |
| | | for(int i=0;i<sheetDataSetList.size()-1;i++) { |
| | | if (CollectionUtils.isEmpty(sheetDataSetList) || CollectionUtils.isEmpty(sheetDataSetList.get(i).getRowData()) |
| | | || sheetDataSetList.get(i).getRowData().size() < 1) { |
| | |
| | | //找第一行,为了找标题 |
| | | CodeClassifyTemplateVO templateVO = new CodeClassifyTemplateVO(); |
| | | /** if (!templateService.checkChildHasSameTemplate(classifyFullInfo.getCurrentClassifyVO().getOid())) { |
| | | throw new VciBaseException("当前的分类以及下级分类的模板不相同"); |
| | | throw new VciBaseException("当前的分类以及下级分类的模板不相同"); |
| | | }***/ |
| | | //都转换完了。需要批量检查 |
| | | //找所有的分类路径,需要校验路径是否正确,是否都在当前的分类的下级 |
| | |
| | | if (CollectionUtils.isEmpty(ruleOidMap.values())) { |
| | | throw new VciBaseException("导入的数据所选择的分类都没有设置编码规则"); |
| | | } |
| | | Map<String, CodeRuleVO> ruleVOMap = ruleService.listCodeRuleByIds(ruleOidMap.values(), true).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | // TODO: 改用oid查询规则的,别用id |
| | | Map<String, CodeRuleVO> ruleVOMap = ruleService.listCodeRuleByOids(ruleOidMap.values()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | //校验编码规则和码段是否正确 |
| | | Map<String, List<String>> ruleRowIndexMap = new ConcurrentHashMap<>(); |
| | | checkSecLengthInHistory(cboList, classifyVOMap, ruleVOMap, ruleOidMap, errorMap, ruleRowIndexMap); |
| | |
| | | engineService.batchSaveSelectChar(templateVO, dataCBOIdList); |
| | | } |
| | | } |
| | | long end = System.currentTimeMillis(); |
| | | //long end = System.currentTimeMillis(); |
| | | //log.info("=============for执行时间================="+String.valueOf((end-start)/1000)); |
| | | String excelFileName=""; |
| | | if(isExport&&!CollectionUtils.isEmpty(shetNameMap)) { |
| | |
| | | Map<String/**分类主键**/, String/**规则主键**/> ruleOidMap = new ConcurrentHashMap<String, String>(); |
| | | List<String> unExistRuleClassifyOidList = new CopyOnWriteArrayList<>(); |
| | | checkRuleOidInHistory(classifyVOMap, ruleOidMap, unExistRuleClassifyOidList); |
| | | ruleVOMap = ruleService.listCodeRuleByIds(ruleOidMap.values(), true).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | // TODO 改用oid查询的,这儿不该用id |
| | | ruleVOMap = ruleService.listCodeRuleByOids(ruleOidMap.values()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | |
| | | checkSecLengthInHistory(cboList, classifyVOMap, ruleVOMap, ruleOidMap, errorMap, ruleRowIndexMap); |
| | | } |
| | |
| | | |
| | | //都转换完了。需要批量检查 |
| | | //如果出错了,我们依然执行有效的数据,无效的数据写回到excel中 |
| | | |
| | | |
| | | Map<String,String> errorKeyMap=new HashMap<>(); |
| | | //1.分类注入 |
| | | batchSwitchClassifyAttrOnOrder(attrVOS,cboList,classifyFullInfo,false); |
| | | //boolean |
| | | reSwitchBooleanAttrOnOrder(attrVOS,cboList); |
| | | // cboList.stream().forEach(cbo->{ |
| | | //2.校验规则 |
| | | batchCheckVerifyOnOrder(attrVOS, cboList,errorMap); |
| | | //3.校验枚举是否正确 |
| | | batchSwitchEnumAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //4.时间格式的验证 |
| | | //4.时间的,必须统一为yyyy-MM-dd HH:mm:ss |
| | | batchSwitchDateAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //5.处理参照的情况 |
| | | batchSwitchReferAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //6设置默认值 |
| | | batchSwitchAttrDefault(attrVOS, cboList); |
| | | //2.判断必输项。。需要全部的属性,如果是必输,但是表单里面不显示的,只能是分类注入或者组合规则 |
| | | batchCheckRequiredAttrOnOrder(templateVO,cboList,errorMap); |
| | | |
| | | |
| | | /** |
| | | * 关键熟悉错误提示 |
| | | */ |
| | | Map<String,String> errorKeyMap=new HashMap<>(); |
| | | |
| | | |
| | | //最后弄组合规则 |
| | | batchSwitchComponentAttrOnOrder(attrVOS,cboList); |
| | | //3.判断关键属性 |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList); |
| | | Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); |
| | |
| | | errorKeyMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";关键属性与系统中的重复" ); |
| | | }); |
| | | } |
| | | //分类注入 |
| | | batchSwitchClassifyAttrOnOrder(attrVOS,cboList,classifyFullInfo,false); |
| | | //boolean |
| | | reSwitchBooleanAttrOnOrder(attrVOS,cboList); |
| | | // cboList.stream().forEach(cbo->{ |
| | | //4.校验规则 |
| | | batchCheckVerifyOnOrder(attrVOS, cboList,errorMap); |
| | | //5.校验枚举是否正确 |
| | | batchSwitchEnumAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //6.时间格式的验证 |
| | | //6.时间的,必须统一为yyyy-MM-dd HH:mm:ss |
| | | batchSwitchDateAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //7.处理参照的情况 |
| | | batchSwitchReferAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //校验属性是否正确错误信息 |
| | | if(errorMap.size()>0){ |
| | | String[] newMsg = {""}; |
| | |
| | | } |
| | | |
| | | // }); |
| | | //设置默认值 |
| | | batchSwitchAttrDefault(attrVOS, cboList); |
| | | //最后弄组合规则 |
| | | batchSwitchComponentAttrOnOrder(attrVOS,cboList); |
| | | |
| | | //要把以上的错误的都抛出后,再继续处理时间和组合规则 |
| | | List<ClientBusinessObject> needSaveCboList = cboList.stream().filter(cbo -> { |
| | | String rowIndex =cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | |
| | | String dataStatus=cbo.getLcStatus(); |
| | | RowDatas rowData=codeDataMap.get(code); |
| | | String status=rowData.getStatus(); |
| | | String lastModifier= rowData.getEditor(); |
| | | String operation=rowData.getOperation(); |
| | | if (cbo.getTs().compareTo(orderDTO.getTs())==0?false:true) { |
| | | // throw new VciBaseException("数据不是最新的,可能他人已经修改,请刷新后再试"); |
| | |
| | | throw new VciBaseException("数据不是{0}的状态,不允许修改", new String[]{CodeDefaultLC.EDITING.getText()}); |
| | | }*/ |
| | | if(operation.equals("update")) { |
| | | //1. 判断必输项 |
| | | checkRequiredAttrOnOrder(templateVO, orderDTO, errorMap); |
| | | //2.先注入,再组合,最后校验 |
| | | //1.先注入,再组合,最后校验 |
| | | switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO, errorMap); |
| | | //3.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的 |
| | | //2.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的 |
| | | switchComponentAttrOnOrder(templateVO, orderDTO); |
| | | //4.校验规则 |
| | | //3.校验规则 |
| | | checkVerifyOnOrder(templateVO, orderDTO, errorMap); |
| | | //5.判断关键属性 |
| | | checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO, errorMap); |
| | | //6.校验枚举的内容是否正确 |
| | | //4.校验枚举的内容是否正确 |
| | | checkEnumOnOrder(templateVO, orderDTO, errorMap); |
| | | //7.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储 |
| | | //5.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储 |
| | | switchDateAttrOnOrder(templateVO, orderDTO); |
| | | //6. 判断必输项 |
| | | checkRequiredAttrOnOrder(templateVO, orderDTO, errorMap); |
| | | //7.判断关键属性 |
| | | checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO, errorMap); |
| | | //默认的内容不能变,所以只需要拷贝自定义的相关属性即可 |
| | | copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, true, errorMap); |
| | | //企业码和集团码的不修改 |
| | |
| | | cbo.setName(orderDTO.getName()); |
| | | try { |
| | | cbo.setAttributeValueWithNoCheck("description", orderDTO.getDescription()); |
| | | cbo.setAttributeValue("name", orderDTO.getName()); |
| | | // cbo.setAttributeValue("name", orderDTO.getName()); |
| | | // if(finalIsProcess){//在流程中不允许更改 |
| | | // errorMap.put(code,errorMap.getOrDefault(code, errorMap.getOrDefault(code,"")+";数据"+code+"在流程中,不允许更改!")); |
| | | // }else{ |
| | | Date date=new Date(); |
| | | cbo.setLcStatus(status); |
| | | cbo.setAttributeValue("lcstatus",status); |
| | | cbo.setLastModifyTime(date); |
| | | cbo.setLastModifier(lastModifier); |
| | | cbo.setLastModifyTime(date); |
| | | cbo.setAttributeValue("lastmodifier",lastModifier); |
| | | cbo.setAttributeValue("lastmodifytime",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(date)); |
| | | cbo.setTs(date); |
| | | cbo.setAttributeValue("ts",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(date)); |
| | | // } |
| | | } catch (VciBaseException e) { |
| | | e.printStackTrace(); |
| | |
| | | */ |
| | | private void batchCheckRequiredAttrOnOrder(CodeClassifyTemplateVO templateVO,List<ClientBusinessObject> cboList,Map<String,String> errorMap){ |
| | | Map<String, CodeClassifyTemplateAttrVO> requiredAttrMap = templateVO.getAttributes().stream().filter(s -> |
| | | VciBaseUtil.getBoolean(s.getRequireFlag()) && StringUtils.isBlank(s.getComponentRule()) && StringUtils.isBlank(s.getClassifyInvokeLevel())//不能是组合的和分类注入的 |
| | | VciBaseUtil.getBoolean(s.getRequireFlag()) && StringUtils.isBlank(s.getComponentRule()) && (StringUtils.isBlank(s.getClassifyInvokeLevel())||s.getClassifyInvokeLevel().equals("none"))//不能是组合的和分类注入的 |
| | | ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | //与MdmEngineServiceImpl里面的checkRequiredAttrOnOrder 逻辑应该相似 |
| | | if(!CollectionUtils.isEmpty(requiredAttrMap)) { |
| | |
| | | } |
| | | } |
| | | CodeClassifyFullInfoBO newClassifyFullInfo= classifyFullInfoMap.get(cbo.getAttributeValue(CODE_CLASSIFY_OID_FIELD)); |
| | | List<CodeClassifyVO> classifyVOS = newClassifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList()); |
| | | List<CodeClassifyVO> classifyVOS = newClassifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> -o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList()); |
| | | |
| | | int level = VciBaseUtil.getInt(attrVO.getClassifyInvokeLevel()); |
| | | if (classifyVOS.size()>=level && level > 0 ) { |
| | | classifyVO = classifyVOS.get(level-1); |