| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.google.protobuf.ServiceException; |
| | | import com.vci.ubcs.code.applyjtcodeservice.feign.IMdmInterJtClient; |
| | | import com.vci.ubcs.code.bo.AttributeValue; |
| | | import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; |
| | |
| | | |
| | | @Value("${batchadd.redis.time:6000000}") |
| | | public int BATCHADD_REDIS_TIME; |
| | | |
| | | @Value("${batchadd.import_data_limit:5001}") |
| | | private Integer IMPORT_DATA_LIMIT; |
| | | |
| | | /** |
| | | * 主题库分类的服务 |
| | | */ |
| | | @Resource |
| | | private ICodeClassifyService classifyService; |
| | | |
| | | @Resource |
| | | private MdmEngineService mdmEngineService; |
| | | |
| | | /** |
| | | * 通用查询 |
| | | */ |
| | | @Resource |
| | | private CommonsMapper commonsMapper; |
| | | |
| | | /**** |
| | | * 码值服务 |
| | | */ |
| | |
| | | @Override |
| | | public String createImportExcel(String codeClassifyOid, boolean isHistory) { |
| | | List<CodeClassifyTemplateVO> templateVOList=new ArrayList<>(); |
| | | |
| | | VciBaseUtil.alertNotNull("导出模板","导出的配置",codeClassifyOid,"主题库分类的主键"); |
| | | |
| | | CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid); |
| | | |
| | | //获取码段宽度 |
| | | //String secWidth = getCodeSegmentWidth(codeClassifyVO.getOid()); |
| | | |
| | | if(isHistory){ |
| | | templateVOList= templateService.childTemplates(codeClassifyOid); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取码段宽度 |
| | | * @param codeClassifyOid |
| | | * @return |
| | | */ |
| | | private String getCodeSegmentWidth(String codeClassifyOid){ |
| | | CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid); |
| | | // 要获取码段宽度,先要获取规则,当前没有往上找 |
| | | CodeRuleVO codeRuleByClassifyFullInfo = mdmEngineService.getCodeRuleByClassifyFullInfo(classifyService.getClassifyFullInfo(codeClassifyOid)); |
| | | List<CodeBasicSecVO> secVOList = codeRuleByClassifyFullInfo.getSecVOList(); |
| | | if(secVOList.isEmpty()){ |
| | | return ""; |
| | | } |
| | | |
| | | StringBuffer secWidth = new StringBuffer(""); |
| | | |
| | | for (int j = 0; j < secVOList.size(); j++) { |
| | | CodeBasicSecVO secVO = secVOList.get(j); |
| | | int width = VciBaseUtil.getInt(secVO.getCodeSecLength()) + ((secVO.getPrefixCode() + secVO.getSuffixCode()).length()); |
| | | secWidth.append(width).append("#"); |
| | | } |
| | | return secWidth.toString().substring(0, secWidth.length() - 1); |
| | | } |
| | | |
| | | /** |
| | | * 导出的时候封装必输和关键属性 |
| | | * @param attrVO 属性的显示对象 |
| | | * @param text 单元格的值 |
| | |
| | | //校验模板是不是最新的 |
| | | checkTemplateSync(sheetDataSetList,templateVO,0); |
| | | //先不用管属性是否都存在,先转换一下数据 |
| | | Map<String,String> errorMap = new HashMap<>(); |
| | | Map<String,String> errorMap = new ConcurrentHashMap<>(); |
| | | String redisUUid=batchImportCodes(orderDTO,templateVO,dataSet,errorMap,true); |
| | | CodeImProtRusultVO codeImProtRusultVO = new CodeImProtRusultVO(); |
| | | List<String> needRowIndexList = new ArrayList<>(); |
| | |
| | | //2.判断必输项。。需要全部的属性,如果是必输,但是表单里面不显示的,只能是分类注入或者组合规则 |
| | | batchCheckRequiredAttrOnOrder(templateVO,allCboList,errorMap); |
| | | //3.判断关键属性 |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, allCboList); |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, allCboList,errorMap); |
| | | Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); |
| | | Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList(); |
| | | if(!CollectionUtils.isEmpty(selfRepeatRowIndexList)){ |
| | |
| | | } |
| | | if(!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)){ |
| | | keyAttrRepeatRowIndexList.stream().forEach(rowIndex->{ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";关键属性与系统中的重复" ); |
| | | errorMap.put(rowIndex, "关键属性与系统中的重复;" + errorMap.getOrDefault(rowIndex,"") ); |
| | | }); |
| | | } |
| | | //分类注入 |
| | |
| | | || sheetDataSetList.get(i).getRowData().size() < 1) { |
| | | continue; |
| | | } |
| | | // 单次导入数量限制 |
| | | if(sheetDataSetList.get(i).getRowData().size() > IMPORT_DATA_LIMIT){ |
| | | throw new ServiceException("为了保证系统的稳定性,请一次不要导入超过"+IMPORT_DATA_LIMIT+"条的数据"); |
| | | } |
| | | //历史导入的时候不处理编码 |
| | | //----逻辑内容---- |
| | | //1. 分类的路径可以在页面上选择是分类编号还是分类的名称 |
| | |
| | | //判断必输项 |
| | | batchCheckRequiredAttrOnOrder(templateVO, cboList, errorMap); |
| | | |
| | | //有限校验编码是否存在 |
| | | //优先校验编码是否存在 |
| | | batchCheckIdExistOnOrder(templateVO, cboList, errorMap); |
| | | |
| | | //boolean |
| | |
| | | batchSwitchEnumAttrOnOrder(attrVOS, cboList, errorMap); |
| | | |
| | | batchSwitchReferAttrOnOrder(attrVOS, cboList, errorMap); |
| | | |
| | | //6.处理分类注入 |
| | | batchSwitchClassifyAttrOnOrder(attrVOS, cboList, classifyFullInfo,true); |
| | | |
| | | //设置默认值 |
| | | batchSwitchAttrDefault(attrVOS, cboList); |
| | | |
| | | //7.处理组合规则 |
| | | batchSwitchComponentAttrOnOrder(attrVOS, cboList); |
| | | |
| | | //3.判断关键属性 |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList); |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList,errorMap); |
| | | Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); |
| | | Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList(); |
| | | if (!CollectionUtils.isEmpty(selfRepeatRowIndexList)) { |
| | |
| | | } |
| | | if (!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)) { |
| | | keyAttrRepeatRowIndexList.stream().forEach(rowIndex -> { |
| | | errorMap.put(rowIndex, errorMap.getOrDefault(rowIndex, "") + ";关键属性与系统中的重复"); |
| | | errorMap.put(rowIndex, "关键属性与系统中的重复;" + errorMap.getOrDefault(rowIndex, "")); |
| | | }); |
| | | } |
| | | //4.校验规则 |
| | |
| | | if (CollectionUtils.isEmpty(ruleOidMap.values())) { |
| | | throw new VciBaseException("导入的数据所选择的分类都没有设置编码规则"); |
| | | } |
| | | // TODO: 改用oid查询规则的,别用id |
| | | // 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<>(); |
| | |
| | | //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | List<String> rowIndexList = ruleRowIndexMap.get(ruleOid); |
| | | List<ClientBusinessObject> thisCbos = finalNeedSaveCboList.stream().filter(cbo -> rowIndexList.contains(cbo.getAttributeValue(IMPORT_ROW_INDEX)) && !errorMap.containsKey(cbo.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList()); |
| | | List<BaseModel> dataCBOList=new ArrayList<>(); |
| | | List<BaseModel> dataCBOList=new CopyOnWriteArrayList<>(); |
| | | thisCbos.stream().forEach(clientBusinessObject -> { |
| | | BaseModel baseModel=new BaseModel(); |
| | | BeanUtil.convert(clientBusinessObject,baseModel); |
| | |
| | | //2.判断必输项。。需要全部的属性,如果是必输,但是表单里面不显示的,只能是分类注入或者组合规则 |
| | | batchCheckRequiredAttrOnOrder(templateVO,cboList,errorMap); |
| | | //3.判断关键属性 |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList); |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList,errorMap); |
| | | Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); |
| | | Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList(); |
| | | if(!CollectionUtils.isEmpty(selfRepeatRowIndexList)){ |
| | |
| | | } |
| | | if(!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)){ |
| | | keyAttrRepeatRowIndexList.stream().forEach(rowIndex->{ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";关键属性与系统中的重复" ); |
| | | errorMap.put(rowIndex,"关键属性与系统中的重复;" + errorMap.getOrDefault(rowIndex,"")); |
| | | }); |
| | | } |
| | | //分类注入 |
| | |
| | | total += commonsMapper.queryCountBySql(countSql); |
| | | } |
| | | }else{ |
| | | |
| | | total = commonsMapper.queryCountBySql(countSql); |
| | | } |
| | | List<String> selectFieldList = new ArrayList<>(); |
| | |
| | | ).collect(Collectors.toList()); |
| | | String fullPath = getFullPath(classifyFullInfo); |
| | | excelToCbo(classifyFullInfo,fieldIndexMap,rowDataList, codeClassifyTemplateVO,cboList,fullPath,!isImprot); |
| | | Map<String,String> errorMap=new HashMap<>(); |
| | | Map<String,String> errorMap=new ConcurrentHashMap<>(); |
| | | Map<String/**路径**/, CodeClassifyVO> pathMap=new HashMap<>() ; |
| | | //校验编码规则和码段是否正确 |
| | | Map<String, List<String>> ruleRowIndexMap = new ConcurrentHashMap<>(); |
| | |
| | | //最后弄组合规则 |
| | | batchSwitchComponentAttrOnOrder(attrVOS,cboList); |
| | | //3.判断关键属性 |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, codeClassifyTemplateVO, cboList); |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, codeClassifyTemplateVO, cboList,errorMap); |
| | | Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); |
| | | Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList(); |
| | | if(!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)){ |
| | | keyAttrRepeatRowIndexList.stream().forEach(rowIndex->{ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";关键属性与系统中的重复" ); |
| | | errorMap.put(rowIndex,"关键属性与系统中的重复;" + errorMap.getOrDefault(rowIndex,"")); |
| | | }); |
| | | } |
| | | //4.校验规则 |
| | |
| | | */ |
| | | @Override |
| | | public void batchSyncApplyCode(CodeOrderDTO orderDTO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs,boolean isCodeOrGroupCode) { |
| | | Map<String,String> errorMap=new HashMap<>(); |
| | | Map<String,String> errorMap=new ConcurrentHashMap<>(); |
| | | VciBaseUtil.alertNotNull(orderDTO,"编码申请相关的数据",orderDTO.getCodeClassifyOid(),"主题库分类主键"); |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); |
| | | //规则的主键需要去获取 |
| | |
| | | //都转换完了。需要批量检查 |
| | | //如果出错了,我们依然执行有效的数据,无效的数据写回到excel中 |
| | | |
| | | |
| | | Map<String,String> errorKeyMap=new HashMap<>(); |
| | | //1.分类注入 |
| | | batchSwitchClassifyAttrOnOrder(attrVOS,cboList,classifyFullInfo,false); |
| | |
| | | //最后弄组合规则 |
| | | batchSwitchComponentAttrOnOrder(attrVOS,cboList); |
| | | //3.判断关键属性 |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList); |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList,errorKeyMap); |
| | | Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); |
| | | Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList(); |
| | | |
| | | Map<String,List<String>>keyAttrOkOidTORepeatOidMap= keyResultVO.getKeyAttrOkOidTORepeatOidMap(); |
| | | if(!CollectionUtils.isEmpty(selfRepeatRowIndexList)){ |
| | | selfRepeatRowIndexList.stream().forEach(rowIndex->{ |
| | |
| | | resultDataObjectDetailDO.setMsg(errorMap.getOrDefault(rowIndex,"") + ";关键属性与系统中的重复" ); |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | */ |
| | | errorKeyMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";关键属性与系统中的重复" ); |
| | | Map<String, List<BaseModel>> indexTODataMap=keyResultVO.getIndexTODataMap(); |
| | | if(indexTODataMap.containsKey(rowIndex)){ |
| | | List<BaseModel> baseModelList= indexTODataMap.get(rowIndex); |
| | | } |
| | | errorKeyMap.put(rowIndex, "关键属性与系统中的重复;" + errorKeyMap.getOrDefault(rowIndex,"")); |
| | | }); |
| | | } |
| | | //校验属性是否正确错误信息 |
| | |
| | | } |
| | | return resultDataObjectDetailDOs; |
| | | } |
| | | |
| | | /*** |
| | | * 集成批量同步更新接口 |
| | | * @param codeClassifyVO; |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换组合规则的值 |
| | | * |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验关键属性 |
| | | * |
| | |
| | | }); |
| | | |
| | | //没有限制分类,但是一个模板只可能在一个业务类型里面,所以直接查询这个业务类型即可 |
| | | |
| | | if (!CollectionUtils.isEmpty(conditionMap)) { |
| | | String tableName=""; |
| | | R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId()); |
| | |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(tableName)) { |
| | | String errormsg="根据业务类型为查询到相关业务表"; |
| | | String errormsg="根据业务类型未查询到相关业务表"; |
| | | errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+errormsg); |
| | | return; |
| | | } |
| | | final String[] sql = {"select count(*) from " + tableName + " t where 1 = 1 "}; |
| | | //final String[] sql = {"select count(*) from " + tableName + " t where 1 = 1 "}; |
| | | final String[] sql = {"select t.id from " + tableName + " t where 1 = 1 "}; |
| | | conditionMap.forEach((key, value) -> { |
| | | if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)){ |
| | | sql[0] += " and " + key + " is null "; |
| | |
| | | } else if (StringUtils.isNotBlank(orderDTO.getCopyFromVersion())) { |
| | | sql[0] += " and t.oid != '" + orderDTO.getCopyFromVersion() + "'"; |
| | | } |
| | | // 不需要参与校验的规则oid |
| | | String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid()); |
| | | if(Func.isNotBlank(isParticipateCheckOids)){ |
| | | sql[0] += " and codeclsfid not in("+isParticipateCheckOids+")"; |
| | | } |
| | | sql[0] += " and t.lastR = '1' and t.lastV = '1' "; |
| | | if (commonsMapper.queryCountBySql(sql[0]) > 0) { |
| | | List<String> repeatData = commonsMapper.selectList(sql[0]); |
| | | if (!repeatData.isEmpty()) { |
| | | String ruleInfoMsg = keyRuleVO == null ? "" : "查询规则:去除空格--{0},忽略大小写--{1},忽略全半角--{2},忽略全部空格--{3}"; |
| | | String[] objs = new String[]{trim ? "是" : "否", ignoreCase ? "是" : "否", ignoreWidth ? "是" : "否", trimAll ? "是" : "否"}; |
| | | String defaultValue=";根据您填写的关键属性的内容,结合关键属性查询规则,发现这个数据已经在系统中存在了。请修正!。"; |
| | | String defaultValue=";根据您填写的关键属性的内容,结合关键属性查询规则,发现这个数据已经在系统中存在了,数据的编号如下:"+repeatData.stream().collect(Collectors.joining(","))+"。请修正!。"; |
| | | String errormsg=defaultValue+ MessageFormat.format(ruleInfoMsg, objs); |
| | | errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+errormsg); |
| | | // throw new VciBaseException("根据您填写的关键属性的内容,结合关键属性查询规则,发现这个数据已经在系统中存在了。请修正!。" + ruleInfoMsg, objs); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验枚举的内容 |
| | | * |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换时间的格式 |
| | | * |
| | |
| | | // if (lifeCycleVO != null) { |
| | | // cbo.setLcStatus(lifeCycleVO.getStartStatus()); |
| | | // } else { |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | // } |
| | | } else { |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | } |
| | | |
| | | } |
| | |
| | | orderDTO.getData().put(attrId, value); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 从编码申请信息对象上获取某个属性的值 |
| | | * |
| | |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * 处理分类注入的信息 |
| | | * |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * |
| | | * @param codeClassifyVO |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * excel转换为cbo的对象 |
| | | * @param classifyFullInfo 分类的全部信息 |
| | |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * excel转换为cbo的对象 |
| | | * @param classifyFullInfo 分类的全部信息 |
| | |
| | | Integer userSecret = VciBaseUtil.getCurrentUserSecret(); |
| | | cbo.setAttributeValue(SECRET_FIELD,String.valueOf((userSecret==null || userSecret ==0)? UserSecretEnum.NONE.getValue():userSecret)); |
| | | } |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | }else{ |
| | | //此时还没有转换路径 |
| | | //cbo.setAttributeValue(CODE_FULL_PATH_FILED, childOidPathMap.getOrDefault(rowData.getData().getOrDefault(CODE_CLASSIFY_OID_FIELD,""),fullPath)); |
| | |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * excel转换为cbo的对象 |
| | | * @param classifyFullInfo 分类的全部信息 |
| | |
| | | ClientBusinessObject cbo=new ClientBusinessObject(); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(cbo, classifyFullInfo.getTopClassifyVO().getBtmTypeId()); |
| | | rowData.getData().forEach((index,value)->{ |
| | | String field = fieldIndexMap.get(index); |
| | | String field = fieldIndexMap.get(index); |
| | | if (StringUtils.isBlank(field)) { |
| | | throw new VciBaseException("第" + (index + 1) + "列的标题在系统中不存在"); |
| | | } |
| | |
| | | Integer userSecret = VciBaseUtil.getCurrentUserSecret(); |
| | | cbo.setAttributeValue(SECRET_FIELD,String.valueOf((userSecret==null || userSecret ==0)? UserSecretEnum.NONE.getValue():userSecret)); |
| | | } |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | }else{ |
| | | //此时还没有转换路径 |
| | | //cbo.setAttributeValue(CODE_FULL_PATH_FILED, childOidPathMap.getOrDefault(rowData.getData().getOrDefault(CODE_CLASSIFY_OID_FIELD,""),fullPath)); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 批量转换时间都为指定的格式 |
| | | * @param attrVOS 模板属性 |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 批量检查企业编码是否存在 |
| | | * @param templateVO 模板的显示对象 |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * 校验分类对应的模板信息 |
| | | * @param titleRowData |
| | |
| | | } |
| | | return codeClassifyTemplateVOList ; |
| | | } |
| | | |
| | | /** |
| | | * 从属性上获取参照的内容 |
| | | * @param attrVO 属性的信息 |
| | |
| | | } |
| | | return showText; |
| | | } |
| | | |
| | | /** |
| | | * 处理枚举的显示对象 |
| | | * @param attrVOS 模板属性 |
| | |
| | | if(!CollectionUtils.isEmpty(nullRowIndex)){ |
| | | String checkAttr = requiredAttrMap.values().stream().map(CodeClassifyTemplateAttrVO::getName).collect(Collectors.joining(",")); |
| | | nullRowIndex.stream().forEach(rowIndex->{ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";校验规则不通过,有校验的属性为" + checkAttr); |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";校验规则必填项不通过,如果有必填属性为空,则填【/】代替,有校验的属性为" + checkAttr); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理分类注入 |
| | | * @param attrVOS 模板属性 |
| | |
| | | * @param cboList 批量的数据 |
| | | */ |
| | | private CodeImportResultVO batchCheckKeyAttrOnOrder(CodeClassifyFullInfoBO classifyFullInfo, CodeClassifyTemplateVO templateVO, |
| | | List<ClientBusinessObject> cboList) { |
| | | List<ClientBusinessObject> cboList,Map<String,String> errorMap) { |
| | | //与MdmEngineServiceImpl里的checkKeyAttrOnOrder相似 |
| | | //先获取关键属性的规则,也利用继承的方式 |
| | | CodeKeyAttrRepeatVO keyRuleVO = keyRuleService.getRuleByClassifyFullInfo(classifyFullInfo); |
| | |
| | | //2.判断关键属性在系统里是否重复 |
| | | //因为数据量很大,所以得想办法并行 |
| | | //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | Map<String,List<BaseModel>> indexTODataMap=new HashMap<>(); |
| | | Map<String,List<BaseModel>> indexTODataMap=new ConcurrentHashMap<>(); |
| | | // 查询不需要参与关键属性校验的除自己以外的所有分类oid |
| | | final String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid()); |
| | | List<ClientBusinessObject> repeatDataMap = cboList.parallelStream().filter(cbo -> { |
| | | //每行都得查询.如果其中出现了错误,我们就直接抛出异常,其余的显示 |
| | | //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | |
| | | engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); |
| | | }); |
| | | if (!CollectionUtils.isEmpty(ketAttrMap)) { |
| | | // 添加不参与关键属性校验的分类oid判断 |
| | | if(Func.isNotBlank(isParticipateCheckOids)){ |
| | | conditionMap.put("t.codeclsfid",QueryOptionConstant.NOTIN+isParticipateCheckOids); |
| | | } |
| | | CodeTemplateAttrSqlBO sqlBO = engineService.getSqlByTemplateVO(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), templateVO, conditionMap, null); |
| | | boolean isKeyCheck= commonsMapper.queryCountBySql(sqlBO.getSqlCount()) > 0; |
| | | if(isKeyCheck){ |
| | | List<Map<String,String>> newDataList= commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlUnPage()); |
| | | //List<ClientBusinessObject> newCboList= ChangeMapTOClientBusinessObjects(newDataList); |
| | | List<BaseModel> newCboList=new ArrayList<>(); |
| | | List<String> repeatData = commonsMapper.selectList(sqlBO.getSqlId()); |
| | | if(!repeatData.isEmpty()){ |
| | | final List<Map<String,String>> newDataList = commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlUnPage()); |
| | | //List<ClientBusinessObject> newCboList=ChangeMapTOClientBusinessObjects(newDataList); |
| | | List<BaseModel> newCboList = new ArrayList<>(); |
| | | newDataList.stream().forEach(stringStringMap -> { |
| | | BaseModel baseModel=new BaseModel(); |
| | | DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(stringStringMap,baseModel); |
| | | newCboList.add(baseModel); |
| | | }); |
| | | // 添加错误值 |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(rowIndex, "重复的记录编号为:"+repeatData.stream().collect(Collectors.joining(","))); |
| | | if(!CollectionUtils.isEmpty(newCboList)) { |
| | | indexTODataMap.put(cbo.getAttributeValue(IMPORT_ROW_INDEX), newCboList); |
| | | } |
| | | } |
| | | return isKeyCheck; |
| | | return !repeatData.isEmpty(); |
| | | }else{ |
| | | return false; |
| | | } |
| | |
| | | if(StringUtils.isBlank(classifyPath)){ |
| | | classifyPath = "#current#"; |
| | | } |
| | | if ( !pathMap.containsKey(classifyPath)) { |
| | | if (!pathMap.containsKey(classifyPath)) { |
| | | String row_index = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(row_index,errorMap.getOrDefault(row_index,"") + ";分类路径不存在"); |
| | | } else { |
| | |
| | | childOidPathMap.put(childPath.getOid(),thisClassifyPath); |
| | | }); |
| | | } |
| | | String path=classifyFullInfo.getCurrentClassifyVO().getId(); |
| | | //根据客户选择的分类路径未id,还是name确定路径拼接 |
| | | childOidPathMap.put(classifyFullInfo.getCurrentClassifyVO().getOid(),fullPath); |
| | | return childOidPathMap; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取导入的内容中关键属性重复的行号 |
| | |
| | | List<String>newOidList=new ArrayList<>(); |
| | | newOidList.add(oid); |
| | | if(keyAttrOkOidTORepeatOidMap.containsKey(okOid)){ |
| | | List<String> oldOidList= keyAttrOkOidTORepeatOidMap.get(okOid); |
| | | List<String> oldOidList = keyAttrOkOidTORepeatOidMap.get(okOid); |
| | | newOidList.addAll(oldOidList); |
| | | |
| | | } |
| | |
| | | resultVO.setKeyAttrRepeatRowIndexList(selfRepeatRowIndexList); |
| | | resultVO.setKeyAttrOkOidTORepeatOidMap(keyAttrOkOidTORepeatOidMap); |
| | | } |
| | | |
| | | /** |
| | | * excel的标题上获取字段所在的位置 |
| | | * @param titleRowData 标题的内容 |
| | |
| | | codeClassifyDatas.addAll(newCodeImprotDataVO); |
| | | log.info("222"); |
| | | } |
| | | |
| | | /*** |
| | | * @param titleRowData |
| | | * @param newTemplateVO |
| | |
| | | codeImprotDataVO.setColNames(colNames); |
| | | codeImprotDataVO.getDatas().add(filedValueMap); |
| | | } |
| | | /*** |
| | | |
| | | /** |
| | | * 正确错误数据redis缓存 |
| | | * @param uuid |
| | | * @param templateVO |
| | |
| | | mdmInterJtClient.receiveEditApply(oids,btmName); |
| | | } |
| | | } |
| | | |
| | | } |