| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.vci.ubcs.code.applyjtcodeservice.feign.IMdmInterJtClient; |
| | | import com.vci.ubcs.code.bo.AttributeValue; |
| | | import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; |
| | | import com.vci.ubcs.code.bo.CodeTemplateAttrSqlBO; |
| | |
| | | import com.vci.ubcs.code.entity.CodeAllCode; |
| | | import com.vci.ubcs.code.enumpack.CodeDefaultLC; |
| | | import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum; |
| | | import com.vci.ubcs.code.enumpack.sysIntegrationPushTypeEnum; |
| | | import com.vci.ubcs.code.lifecycle.CodeAllCodeLC; |
| | | import com.vci.ubcs.code.mapper.CommonsMapper; |
| | | import com.vci.ubcs.code.service.*; |
| | |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | */ |
| | | @Autowired |
| | | private IBtmTypeClient btmTypeClient; |
| | | |
| | | /*** |
| | | * 申请集团编码服务 |
| | | */ |
| | | @Resource |
| | | private IMdmInterJtClient mdmInterJtClient; |
| | | /*** |
| | | * 密级服务 |
| | | */ |
| | |
| | | * @return excel的文件地址 |
| | | */ |
| | | @Override |
| | | public String downloadTopImportExcel(String codeClassifyOid){ |
| | | public String downloadTopImportExcel(String codeClassifyOid){ |
| | | List<CodeClassifyTemplateVO> templateVOList=new ArrayList<>(); |
| | | VciBaseUtil.alertNotNull("导出模板","导出的配置",codeClassifyOid,"主题库分类的主键"); |
| | | CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid); |
| | |
| | | //参照的自行输入名称 |
| | | //分类注入的不用,都是导入后自动处理的 |
| | | //编码,状态等字段不导入 |
| | | List<CodeClassifyTemplateAttrVO> templateAttrVOS = templateVO.getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) |
| | | && StringUtils.isBlank(s.getComponentRule()) |
| | | && StringUtils.isBlank(s.getClassifyInvokeAttr()) |
| | | && (VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(templateAttrVOS)){ |
| | | throw new VciBaseException("模板没有配置任何【表单显示】为【是】的属性"); |
| | | } |
| | | templateAttrVOS.stream().forEach(codetemplateAttr ->{ |
| | | String field=codetemplateAttr.getId(); |
| | | String name=codetemplateAttr.getName(); |
| | | CodeClassifyTemplateAttrVO codeBaseAttributeDTO=new CodeClassifyTemplateAttrVO(); |
| | | boolean res=(StringUtils.isNotBlank(codetemplateAttr.getAttributeGroup())&& codetemplateAttr.getAttributeGroup().equals(BATCHADD_EXCEPORT_ATTR_TYPE))//基本属性字段显示 |
| | | ||(StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag()))//关键属性的存入 |
| | | ||(StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) //相似属性的存入 |
| | | ||(StringUtils.isNotBlank(codetemplateAttr.getRequireFlag())&&Boolean.parseBoolean(codetemplateAttr.getRequireFlag())); |
| | | if(allFieldToOutNameMap.containsKey(name)){//如果存在的话则需要根据具体的去赋值 |
| | | codeBaseAttributeDTO= allFieldToOutNameMap.get(name); |
| | | if(StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag())){ |
| | | codeBaseAttributeDTO.setKeyAttrFlag(codetemplateAttr.getKeyAttrFlag());//属性关键属性 |
| | | } |
| | | if(StringUtils.isNotBlank(codetemplateAttr.getRequireFlag())&&Boolean.parseBoolean(codetemplateAttr.getRequireFlag())){ |
| | | codeBaseAttributeDTO.setRequireFlag(codetemplateAttr.getRequireFlag());//属性必填项 |
| | | } |
| | | if(StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())){ |
| | | codeBaseAttributeDTO.setSameRepeatAttrFlag(codetemplateAttr.getSameRepeatAttrFlag());//属性相似属性 |
| | | } |
| | | }else if(res){ |
| | | allFieldToOutNameMap.put(name,codetemplateAttr); |
| | | if(!CollectionUtils.isEmpty(templateVO.getAttributes())) { |
| | | List<CodeClassifyTemplateAttrVO> templateAttrVOS = templateVO.getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) |
| | | && StringUtils.isBlank(s.getComponentRule()) |
| | | && StringUtils.isBlank(s.getClassifyInvokeAttr()) |
| | | && (VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(templateAttrVOS)){ |
| | | throw new VciBaseException("模板没有配置任何【表单显示】为【是】的属性"); |
| | | } |
| | | }); |
| | | templateAttrVOS.stream().forEach(codetemplateAttr -> { |
| | | String field = codetemplateAttr.getId(); |
| | | String name = codetemplateAttr.getName(); |
| | | CodeClassifyTemplateAttrVO codeBaseAttributeDTO = new CodeClassifyTemplateAttrVO(); |
| | | boolean res = (StringUtils.isNotBlank(codetemplateAttr.getAttributeGroup()) && codetemplateAttr.getAttributeGroup().equals(BATCHADD_EXCEPORT_ATTR_TYPE))//基本属性字段显示 |
| | | || (StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag()))//关键属性的存入 |
| | | || (StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) //相似属性的存入 |
| | | || (StringUtils.isNotBlank(codetemplateAttr.getRequireFlag()) && Boolean.parseBoolean(codetemplateAttr.getRequireFlag())); |
| | | if (allFieldToOutNameMap.containsKey(name)) {//如果存在的话则需要根据具体的去赋值 |
| | | codeBaseAttributeDTO = allFieldToOutNameMap.get(name); |
| | | if (StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag())) { |
| | | codeBaseAttributeDTO.setKeyAttrFlag(codetemplateAttr.getKeyAttrFlag());//属性关键属性 |
| | | } |
| | | if (StringUtils.isNotBlank(codetemplateAttr.getRequireFlag()) && Boolean.parseBoolean(codetemplateAttr.getRequireFlag())) { |
| | | codeBaseAttributeDTO.setRequireFlag(codetemplateAttr.getRequireFlag());//属性必填项 |
| | | } |
| | | if (StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) { |
| | | codeBaseAttributeDTO.setSameRepeatAttrFlag(codetemplateAttr.getSameRepeatAttrFlag());//属性相似属性 |
| | | } |
| | | } else if (res) { |
| | | allFieldToOutNameMap.put(name, codetemplateAttr); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | //整理好所有模板需要写入execl的属性信息 |
| | | Workbook workbook = new HSSFWorkbook(); |
| | |
| | | return text; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量申请编码数据 |
| | | * |
| | |
| | | // return null; |
| | | return codeImProtRusultVO; |
| | | } |
| | | |
| | | |
| | | /*** |
| | | * 从顶层批量申请导入方法 |
| | |
| | | |
| | | }); |
| | | |
| | | |
| | | //都转换完了。需要批量检查 |
| | | //如果出错了,我们依然执行有效的数据,无效的数据写回到excel中 |
| | | //2.判断必输项。。需要全部的属性,如果是必输,但是表单里面不显示的,只能是分类注入或者组合规则 |
| | |
| | | createRedisDatas(uuid + "-ok",codeImprotDataVOS, newErrorMap,true); |
| | | |
| | | }); |
| | | |
| | | //往物品节点上加模板 |
| | | |
| | | |
| | | |
| | | List<String> needRowIndexList=new ArrayList<>(); |
| | | CodeImProtRusultVO codeImProtRusultVO = new CodeImProtRusultVO(); |
| | | if(errorMap.size()>0) { |
| | |
| | | String uuid=VciBaseUtil.getPk(); |
| | | boolean isCreateUUid=false; |
| | | boolean isExport=false; |
| | | 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) { |
| | |
| | | // 5.3 企业编码的长度,和编码规则的长度要对应上 |
| | | // 5.4 获取流水码段的值,去除填充的字符,看流水号是多少,然后将流水号和现在的最大流水号判断,小于就直接录入,大于则修改最大流水号 |
| | | // 5.5 存储企业编码到allcode中 |
| | | |
| | | //查询分类和模板 |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyOid); |
| | | |
| | |
| | | ruleRowIndexMap.keySet().parallelStream().forEach(ruleOid -> { |
| | | List<String> rowIndexList = ruleRowIndexMap.get(ruleOid); |
| | | List<ClientBusinessObject> thisCbos = cboList.stream().filter(cbo -> rowIndexList.contains(cbo.getAttributeValue(IMPORT_ROW_INDEX)) && !errorMap.containsKey(cbo.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList()); |
| | | //我们需要先查询一下,内容是否已经存在 |
| | | //我们需要先查询一下,内容是否已经存在 |
| | | if(!CollectionUtils.isEmpty(thisCbos)){ |
| | | List<String> existIds = new ArrayList<>(); |
| | | VciBaseUtil.switchCollectionForOracleIn(thisCbos).stream().forEach(cbos -> { |
| | |
| | | |
| | | if (!CollectionUtils.isEmpty(thisCbos)) { |
| | | try { |
| | | // TODO 多线程流问题 |
| | | productCodeService.productCodeAndSaveData(classifyFullInfo, finalTemplateVO, ruleVOMap.get(ruleOid), null, dataCBOList); |
| | | } catch (Throwable e) { |
| | | log.error("批量产生编码的时候出错了", e); |
| | |
| | | engineService.batchSaveSelectChar(templateVO, dataCBOIdList); |
| | | } |
| | | } |
| | | long end = System.currentTimeMillis(); |
| | | //log.info("=============for执行时间================="+String.valueOf((end-start)/1000)); |
| | | String excelFileName=""; |
| | | if(isExport&&!CollectionUtils.isEmpty(shetNameMap)) { |
| | | excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误信息.xls"; |
| | |
| | | |
| | | return codeImProtRusultVO; |
| | | } |
| | | |
| | | /*private void converBaseModels(List<ClientBusinessObject> clientBusinessObjects,List<BaseModel>dataCBOList){ |
| | | clientBusinessObjects.stream().forEach(clientBusinessObject -> { |
| | | BaseModel baseModel=new BaseModel(); |
| | |
| | | }); |
| | | |
| | | }*/ |
| | | |
| | | /*** |
| | | * 从execl里构建对象 |
| | | * @param rowDataList |
| | |
| | | conditionMap.put("lastr", "1"); |
| | | conditionMap.put("lastv", "1"); |
| | | |
| | | String countSql = "select count(*) from " + VciBaseUtil.getTableName(btmTypeId) +" where 1=1" + |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Arrays.asList(btmTypeId)); |
| | | String tableName = ""; |
| | | if(listR.isSuccess() && !listR.getData().isEmpty()){ |
| | | tableName = Func.isNotBlank(listR.getData().get(0).getTableName()) ? listR.getData().get(0).getTableName():VciBaseUtil.getTableName(btmTypeId); |
| | | }else{ |
| | | tableName = VciBaseUtil.getTableName(btmTypeId); |
| | | } |
| | | |
| | | String countSql = "select count(*) from " + tableName +" where 1=1" + |
| | | " and lastr = '1'" + |
| | | " and lastv='1'" + |
| | | " and codeclsfpath like '%" + exportAttrDTO.getCodeClassifyOid() + "%'"; |
| | |
| | | * @return 有错误信息的excel |
| | | */ |
| | | @Override |
| | | public void batchSyncApplyCode(CodeOrderDTO orderDTO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs) { |
| | | public void batchSyncApplyCode(CodeOrderDTO orderDTO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs,boolean isCodeOrGroupCode) { |
| | | Map<String,String> errorMap=new HashMap<>(); |
| | | VciBaseUtil.alertNotNull(orderDTO,"编码申请相关的数据",orderDTO.getCodeClassifyOid(),"主题库分类主键"); |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); |
| | |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList); |
| | | 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->{ |
| | | /* //传入数据之间关键属性的校验 |
| | |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | | } |
| | | String code=""; |
| | | String groupCode=""; |
| | | String errorid="103"; |
| | | String mes=errorMap.get(rowIndex); |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(code); |
| | | if(isCodeOrGroupCode){ |
| | | resultDataObjectDetailDO.setCode(groupCode); |
| | | }else{ |
| | | resultDataObjectDetailDO.setCode(code); |
| | | } |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid(errorid); |
| | | resultDataObjectDetailDO.setMsg(mes); |
| | |
| | | String oid = cbo.getOid(); |
| | | String sourceOid = oid; |
| | | String code = ""; |
| | | String groupCode=""; |
| | | String errorid = "201"; |
| | | if(codeOidToSystemOidMap.containsKey(oid)){ |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | |
| | | String lcstatus =newCbo.getLcStatus(); |
| | | String newOid =newCbo.getOid(); |
| | | Date ts =newCbo.getTs(); |
| | | code=newCbo.getId(); |
| | | code = StringUtils.isBlank(newCbo.getId())?"":newCbo.getId(); |
| | | groupCode=newCbo.getData().getOrDefault("GROUPCODE",""); |
| | | String lastmodifier=newCbo.getLastModifier(); |
| | | if (!lcstatus.equals(CodeDefaultLC.RELEASED.getValue())) { |
| | | if (lcstatus!=null&&!lcstatus.equals(CodeDefaultLC.RELEASED.getValue())) { |
| | | newCbo.setOid(newOid); |
| | | newCbo.setLastModifier(lastmodifier); |
| | | newCbo.setId(code); |
| | | /*if(isCodeOrGroupCode) { |
| | | newCbo.setId(code); |
| | | }else{ |
| | | newCbo.getData().put("groupcode",groupCode); |
| | | }*/ |
| | | newCbo.setTs(ts); |
| | | cbo.setLastModifier(cbo.getLastModifier()); |
| | | editBoList.add(newCbo); |
| | | } |
| | | String mes = errorKeyMap.get(rowIndex); |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO = new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(code); |
| | | if(isCodeOrGroupCode) { |
| | | if(StringUtils.isBlank(groupCode)){ |
| | | errorid="1"; |
| | | mes+=";申请的编码类型为集团码,等待集团编码赋值"; |
| | | } |
| | | resultDataObjectDetailDO.setCode(groupCode); |
| | | }else{ |
| | | resultDataObjectDetailDO.setCode(code); |
| | | } |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid(errorid); |
| | | resultDataObjectDetailDO.setMsg(mes); |
| | | |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | } |
| | | } |
| | |
| | | allNeedSaveCboList.add(baseModel.getOid()); |
| | | }); |
| | | try { |
| | | List<String>applyGroupCodeIdList=new ArrayList<>(); |
| | | productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), dataCBOList); |
| | | //如果是编码生成失败,则直接就失败了,其他的判断出来有错误的我们都统一返回到excel里面 |
| | | engineService.batchSaveSelectChar(templateVO, dataCBOList); |
| | | // if(!isProcess){ |
| | | dataCBOList.stream().forEach(needSaveCbo->{ |
| | | |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(needSaveCbo.getId()); |
| | | String code=StringUtils.isBlank(needSaveCbo.getId())?" ":needSaveCbo.getId(); |
| | | String groupCode=needSaveCbo.getData().getOrDefault("GROUPCODE"," "); |
| | | //resultDataObjectDetailDO.setCode(needSaveCbo.getId()); |
| | | String msg="申请编码成功"; |
| | | String oid=needSaveCbo.getOid(); |
| | | String sourceOid=oid; |
| | | applyGroupCodeIdList.add(oid); |
| | | if(codeOidToSystemOidMap.containsKey(oid)){ |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | | } |
| | | if(isCodeOrGroupCode) { |
| | | if(StringUtils.isBlank(groupCode)){ |
| | | resultDataObjectDetailDO.setErrorid("1"); |
| | | msg="申请的编码类型为集团码,等待集团编码赋值"; |
| | | } |
| | | resultDataObjectDetailDO.setCode(groupCode); |
| | | }else{ |
| | | resultDataObjectDetailDO.setCode(code); |
| | | resultDataObjectDetailDO.setErrorid("0"); |
| | | } |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid("0"); |
| | | resultDataObjectDetailDO.setMsg("申请编码成功"); |
| | | |
| | | resultDataObjectDetailDO.setMsg(msg); |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | //处理传送的数据中关键属性重复的,直接拿到已经申请到编码的数据编码直接将赋给关键属性重复的数据 |
| | | LinkedList<XMLResultDataObjectDetailDO> repeatDataObjectDetailDOS=handleApplyDataKeyAttrRepeat(keyAttrOkOidTORepeatOidMap,codeOidToSystemOidMap,needSaveCbo,isCodeOrGroupCode); |
| | | resultDataObjectDetailDOs.addAll(repeatDataObjectDetailDOS); |
| | | }); |
| | | /* }else{ |
| | | needSaveCboList.stream().forEach(needSaveCbo->{ |
| | |
| | | }); |
| | | |
| | | }*/ |
| | | //是否调用集团接口申请接口 |
| | | if(isCodeOrGroupCode){ |
| | | if(!CollectionUtils.isEmpty(applyGroupCodeIdList)) { |
| | | this.sendApplyGroupcode(applyGroupCodeIdList, classifyFullInfo.getTopClassifyVO().getId(), sysIntegrationPushTypeEnum.ACCPET_APPCODE.getValue()); |
| | | } |
| | | } |
| | | |
| | | }catch (Throwable e){ |
| | | e.printStackTrace(); |
| | | needSaveCboList.stream().forEach(needSaveCbo->{ |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /*** |
| | | *给同一批申请编码存在关键属性的数据赋上一致编码 |
| | | * @param keyAttrOkOidTORepeatOidMap 一批申请数据关键属性一致的重复数据映射关系 |
| | | * @param codeOidToSystemOidMap |
| | | * @param needSaveCbo |
| | | * @param isCodeOrGroupCode |
| | | */ |
| | | private LinkedList<XMLResultDataObjectDetailDO> handleApplyDataKeyAttrRepeat(Map<String,List<String>>keyAttrOkOidTORepeatOidMap,Map<String,String> codeOidToSystemOidMap,BaseModel needSaveCbo,boolean isCodeOrGroupCode){ |
| | | LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs=new LinkedList<>(); |
| | | String oid=needSaveCbo.getOid(); |
| | | if(keyAttrOkOidTORepeatOidMap.containsKey(oid)){ |
| | | List<String> repeatOidList= keyAttrOkOidTORepeatOidMap.get(oid); |
| | | if(!CollectionUtils.isEmpty(repeatOidList)){ |
| | | String sourceNewOid=needSaveCbo.getOid(); |
| | | String sourceOid=sourceNewOid; |
| | | if(codeOidToSystemOidMap.containsKey(oid)){ |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | | } |
| | | String code=StringUtils.isBlank(needSaveCbo.getId())?" ":needSaveCbo.getId(); |
| | | String groupCode=needSaveCbo.getData().getOrDefault("GROUPCODE"," "); |
| | | String finalSourceOid = sourceOid; |
| | | repeatOidList.stream().forEach(repeatOid->{ |
| | | if(codeOidToSystemOidMap.containsKey(repeatOid)){ |
| | | XMLResultDataObjectDetailDO repeatresultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | String repeatSourceOid=codeOidToSystemOidMap.get(repeatOid); |
| | | String repeatMsg="此数据与申请的编码数据id为【"+ finalSourceOid +"】的关键属性一致,则取相同编码"; |
| | | if(isCodeOrGroupCode) { |
| | | if(StringUtils.isBlank(groupCode)){ |
| | | repeatMsg="申请的编码类型为集团码,等待集团编码赋值"; |
| | | } |
| | | repeatresultDataObjectDetailDO.setCode(groupCode); |
| | | }else{ |
| | | repeatresultDataObjectDetailDO.setCode(code); |
| | | } |
| | | repeatresultDataObjectDetailDO.setId(repeatSourceOid); |
| | | repeatresultDataObjectDetailDO.setErrorid("0"); |
| | | repeatresultDataObjectDetailDO.setMsg(repeatMsg); |
| | | resultDataObjectDetailDOs.add(repeatresultDataObjectDetailDO); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | return resultDataObjectDetailDOs; |
| | | } |
| | | /*** |
| | | * 集成批量同步更新接口 |
| | | * @param codeClassifyVO; |
| | | * @param dataObjectVO 数据信息 |
| | | * @param resultDataObjectDetailDOs 错误信息 |
| | | * @param isCodeOrGroupCode 是否更集团系统数据 |
| | | */ |
| | | @Transactional(rollbackFor = VciBaseException.class) |
| | | @Override |
| | | public void batchSyncEditDatas(CodeClassifyVO codeClassifyVO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs) { |
| | | public void batchSyncEditDatas(CodeClassifyVO codeClassifyVO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs,boolean isCodeOrGroupCode) { |
| | | String errorid=""; |
| | | String msg=""; |
| | | //查询分类和模板 |
| | |
| | | List<String> titleRowData = dataObjectVO.getColName(); |
| | | Map<String/**中文名称**/, String/**英文名称**/> attrNameIdMap = attrVOS.stream().collect(Collectors.toMap(s -> s.getName(), t -> t.getId().toLowerCase(Locale.ROOT), (o1, o2) -> o2)); |
| | | getFieldIndexMap(titleRowData, attrNameIdMap, fieldIndexMap); |
| | | Map<String, String> cboOidMap = new HashMap<>(); |
| | | cboOidMap.put("id", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])) + ")"); |
| | | //Map<String, String> cboOidMap = new HashMap<>(); |
| | | //cboOidMap.put("id", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])) + ")"); |
| | | String tableName =""; |
| | | try { |
| | | R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId()); |
| | |
| | | sb.append(" select * from "); |
| | | sb.append(tableName); |
| | | sb.append(" where 1=1 "); |
| | | sb.append(" id in ("); |
| | | sb.append(VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0]))); |
| | | sb.append(")"); |
| | | sb.append(" and lastr=1 and lastv=1" ); |
| | | if(isCodeOrGroupCode) { |
| | | sb.append(" and ( groupcode in ("); |
| | | sb.append(VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0]))); |
| | | sb.append(")"); |
| | | sb.append(" or id in ("); |
| | | sb.append(VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0]))); |
| | | sb.append("))"); |
| | | }else{ |
| | | sb.append(" and id in ("); |
| | | sb.append(VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0]))); |
| | | sb.append(")"); |
| | | } |
| | | |
| | | List<Map<String,String>> dataMapList=commonsMapper.queryByOnlySqlForMap(sb.toString()); |
| | | List<ClientBusinessObject> cboList= ChangeMapTOClientBusinessObjects(dataMapList); |
| | | Map<String, ClientBusinessObject> codeSystemObjectMap = cboList.stream().filter(systeDataObject -> systeDataObject != null && StringUtils.isNotBlank(systeDataObject.getId())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getId(), t -> t)); |
| | | Map<String, String> errorMap = new HashMap<>(); |
| | | List<CodeOrderDTO> codeOrderDTOList = new ArrayList<>(); |
| | | this.getCodeOrderDTOs(codeClassifyVO, templateVO, codeDataMap, codeSystemObjectMap, codeOrderDTOList, errorMap); |
| | | this.getCodeOrderDTOs(codeClassifyVO, templateVO, codeDataMap, codeSystemObjectMap, codeOrderDTOList, errorMap,isCodeOrGroupCode); |
| | | // List<CodeClassifyProcessTempVO> codeClassifyProcessTempVOS=codeClassifyProcessTempService.listProcessTemplate(templateVO.getOid(),"code_cls_flow_use_order"); |
| | | boolean isProcess=false; |
| | | /** if(!CollectionUtils.isEmpty(codeClassifyProcessTempVOS)){ |
| | |
| | | RowDatas rowData=codeDataMap.get(code); |
| | | String status=rowData.getStatus(); |
| | | String operation=rowData.getOperation(); |
| | | if (cbo.getTs().compareTo(orderDTO.getTs())==0?true:false) { |
| | | if (cbo.getTs().compareTo(orderDTO.getTs())==0?false:true) { |
| | | // throw new VciBaseException("数据不是最新的,可能他人已经修改,请刷新后再试"); |
| | | errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+";数据不是最新的,可能他人已经修改,请刷新后再试"); |
| | | } |
| | |
| | | |
| | | List<CodeAllCode>newCodeAllCodeList= codeAllCodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCreateCodeOid, cbo.getOid())); |
| | | if (!CollectionUtils.isEmpty(newCodeAllCodeList)) { |
| | | CodeAllCode codeCbo = codeAllCodeList.get(0); |
| | | CodeAllCode codeCbo = newCodeAllCodeList.get(0); |
| | | log.info("codeCbos code:" + codeCbo.getId()); |
| | | codeCbo.setLcStatus(status); |
| | | codeAllCodeList.add(codeCbo); |
| | |
| | | List<CodeAllCode>newCodeAllCodeList= codeAllCodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCreateCodeOid, cbo.getOid())); |
| | | log.info("codeCbos size:" + newCodeAllCodeList.size()); |
| | | if (!CollectionUtils.isEmpty(newCodeAllCodeList)) { |
| | | CodeAllCode codeCbo = codeAllCodeList.get(0); |
| | | CodeAllCode codeCbo = newCodeAllCodeList.get(0); |
| | | log.info("codeCbos code:" + codeCbo.getId()); |
| | | codeCbo.setLcStatus(CodeDefaultLC.TASK_BACK.getValue()); |
| | | codeAllCodeList.add(codeCbo); |
| | |
| | | //存储数据 |
| | | try { |
| | | engineService.updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(),updateList); |
| | | codeAllCodeService.saveBatch(codeAllCodeList); |
| | | codeAllCodeService.saveOrUpdateBatch(codeAllCodeList); |
| | | if(deleteList.size()>0) { |
| | | commonsMapper.deleteByTaleAndOid(tableName, VciBaseUtil.array2String(deleteList.toArray(new String[]{}))); |
| | | } |
| | | //是否调用集团接口申请接口 |
| | | if(isCodeOrGroupCode){ |
| | | List<String> IdList=resultDataObjectDetailDOs.stream().filter(xMLResultDataObjectDetailDO-> com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(xMLResultDataObjectDetailDO.getId())).map(XMLResultDataObjectDetailDO::getId).distinct().collect(Collectors.toList()); |
| | | |
| | | |
| | | |
| | | if(!CollectionUtils.isEmpty(IdList)) { |
| | | this.sendApplyGroupcode(IdList, classifyFullInfo.getTopClassifyVO().getBtmTypeId(),sysIntegrationPushTypeEnum.ACCPET_EDITCODE.getValue()); |
| | | } |
| | | } |
| | | errorid="0"; |
| | | msg="更新/状态更改/删除成功!"; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验属性是否为必输 |
| | | * |
| | |
| | | //没有限制分类,但是一个模板只可能在一个业务类型里面,所以直接查询这个业务类型即可 |
| | | |
| | | if (!CollectionUtils.isEmpty(conditionMap)) { |
| | | final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmTypeId()) + " where 1 = 1 "}; |
| | | String tableName=""; |
| | | R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId()); |
| | | if(r.isSuccess()) { |
| | | BtmTypeVO btmTypeVO = r.getData(); |
| | | if (btmTypeVO != null) { |
| | | tableName = btmTypeVO.getTableName(); |
| | | |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(tableName)) { |
| | | String errormsg="根据业务类型为查询到相关业务表"; |
| | | errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+errormsg); |
| | | return; |
| | | } |
| | | final String[] sql = {"select count(*) from " + tableName + " t where 1 = 1 "}; |
| | | conditionMap.forEach((key, value) -> { |
| | | sql[0] += " and " + key + " = " + value; |
| | | if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)){ |
| | | sql[0] += " and " + key + " is null "; |
| | | }else{ |
| | | sql[0] += " and " + key + " = " + value; |
| | | } |
| | | |
| | | }); |
| | | if (StringUtils.isNotBlank(orderDTO.getOid())) { |
| | | //修改的时候,需要排除自己 |
| | | sql[0] += " and oid != '" + orderDTO.getOid() + "'"; |
| | | sql[0] += " and t.oid != '" + orderDTO.getOid() + "'"; |
| | | } else if (StringUtils.isNotBlank(orderDTO.getCopyFromVersion())) { |
| | | sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'"; |
| | | sql[0] += " and t.oid != '" + orderDTO.getCopyFromVersion() + "'"; |
| | | } |
| | | sql[0] += " and lastR = '1' and lastV = '1' "; |
| | | sql[0] += " and t.lastR = '1' and t.lastV = '1' "; |
| | | if (commonsMapper.queryCountBySql(sql[0]) > 0) { |
| | | String ruleInfoMsg = keyRuleVO == null ? "" : "查询规则:去除空格--{0},忽略大小写--{1},忽略全半角--{2},忽略全部空格--{3}"; |
| | | String[] objs = new String[]{trim ? "是" : "否", ignoreCase ? "是" : "否", ignoreWidth ? "是" : "否", trimAll ? "是" : "否"}; |
| | |
| | | * @param errorMap |
| | | * @return |
| | | */ |
| | | private void getCodeOrderDTOs(CodeClassifyVO codeClassifyVO,CodeClassifyTemplateVO templateVO,Map<String ,RowDatas>codeDataMap,Map<String, ClientBusinessObject> codeSystemObjectMap,List<CodeOrderDTO> codeOrderDTOList,Map<String,String> errorMap){ |
| | | codeDataMap.keySet().forEach(code->{ |
| | | RowDatas rowDatas=codeDataMap.get(code); |
| | | Map<String, String> data= rowDatas.getFiledValue(); |
| | | private void getCodeOrderDTOs(CodeClassifyVO codeClassifyVO,CodeClassifyTemplateVO templateVO,Map<String ,RowDatas>codeDataMap,Map<String, ClientBusinessObject> codeSystemObjectMap,List<CodeOrderDTO> codeOrderDTOList,Map<String,String> errorMap,boolean isCodeOrGroupCode){ |
| | | codeSystemObjectMap.keySet().forEach(code->{ |
| | | ClientBusinessObject sysDataObject= codeSystemObjectMap.get(code); |
| | | if(isCodeOrGroupCode){ |
| | | code=sysDataObject.getAttributeValue("GROUPCODE"); |
| | | if(StringUtils.isBlank(code)){ |
| | | code=sysDataObject.getId(); |
| | | } |
| | | } |
| | | CodeOrderDTO orderDTO = new CodeOrderDTO(); |
| | | if(codeSystemObjectMap.containsKey(code)){ |
| | | ClientBusinessObject sysDataObject= codeSystemObjectMap.get(code); |
| | | if(codeDataMap.containsKey(code)){ |
| | | RowDatas rowDatas=codeDataMap.get(code); |
| | | Map<String, String> data= rowDatas.getFiledValue(); |
| | | orderDTO.setCodeClassifyOid(codeClassifyVO.getOid());//分类主键 |
| | | orderDTO.setOid(sysDataObject.getOid());//数据oid |
| | | orderDTO.setLcStatus(rowDatas.getStatus());//状态 |
| | |
| | | CodeImportResultVO resultVO = new CodeImportResultVO(); |
| | | resultVO.setKeyAttrRuleInfo(String.format(keyRuleVO ==null?"":"查询规则:去除空格--{0},忽略大小写--{1},忽略全半角--{2},忽略全部空格--{3}", |
| | | new String[]{trim?"是":"否",ignoreCase?"是":"否",ignoreWidth?"是":"否",trimAll?"是":"否"})); |
| | | resultVO.setSelfRepeatRowIndexList(getSelfRepeatRowIndex(ketAttrMap,cboList,keyRuleVO)); |
| | | //resultVO.setSelfRepeatRowIndexList(getSelfRepeatRowIndex(ketAttrMap,cboList,keyRuleVO)); |
| | | getSelfRepeatRowIndex(ketAttrMap,cboList,keyRuleVO,resultVO); |
| | | if(!CollectionUtils.isEmpty(resultVO.getSelfRepeatRowIndexList())){ |
| | | //我们移除本身重复的数据 |
| | | cboList = cboList.stream().filter(s->!resultVO.getSelfRepeatRowIndexList().contains(s.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList()); |
| | |
| | | * @param keyRuleVO 关键属性控制规则 |
| | | * @return 重复的行号 |
| | | */ |
| | | private Set<String> getSelfRepeatRowIndex(Map<String/**属性的编号**/, CodeClassifyTemplateAttrVO> ketAttrMap, |
| | | List<ClientBusinessObject> dataList,CodeKeyAttrRepeatVO keyRuleVO){ |
| | | private void getSelfRepeatRowIndex(Map<String/**属性的编号**/, CodeClassifyTemplateAttrVO> ketAttrMap, |
| | | List<ClientBusinessObject> dataList,CodeKeyAttrRepeatVO keyRuleVO,CodeImportResultVO resultVO){ |
| | | Set<String> selfRepeatRowIndexList = new CopyOnWriteArraySet<>(); |
| | | Map<String,List<String>> keyAttrOkOidTORepeatOidMap=new HashMap<>(); |
| | | boolean trimAll =keyRuleVO ==null?false: VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag()); |
| | | //全部去空的优先级大于去空 |
| | | boolean trim =keyRuleVO ==null?false: VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag()); |
| | |
| | | //必须将属性按照顺序排序好 |
| | | List<CodeClassifyTemplateAttrVO> attrVOList = ketAttrMap.values().stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList()); |
| | | Map<String/**行号**/,String/**关键属性的组合内容**/> rowIndexKeyStringMap = new HashMap<>(); |
| | | Map<String/**关键属性的组合内容**/,String/**第一个关键属性的数据oid**/> okOidKeyStringMap = new HashMap<>(); |
| | | dataList.parallelStream().forEach(cbo-> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | String oid=cbo.getOid(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < attrVOList.size(); i++) { |
| | | CodeClassifyTemplateAttrVO attrVO = attrVOList.get(i); |
| | |
| | | String keyString = sb.toString(); |
| | | if(rowIndexKeyStringMap.containsValue(keyString) && StringUtils.isNotBlank(keyString)){ |
| | | selfRepeatRowIndexList.add(rowIndex); |
| | | String okOid=okOidKeyStringMap.getOrDefault(keyString,""); |
| | | if(StringUtils.isNotBlank(okOid)){ |
| | | List<String>newOidList=new ArrayList<>(); |
| | | newOidList.add(oid); |
| | | if(keyAttrOkOidTORepeatOidMap.containsKey(okOid)){ |
| | | List<String> oldOidList= keyAttrOkOidTORepeatOidMap.get(okOid); |
| | | newOidList.addAll(oldOidList); |
| | | |
| | | } |
| | | keyAttrOkOidTORepeatOidMap.put(okOid,newOidList); |
| | | } |
| | | }else { |
| | | okOidKeyStringMap.put(sb.toString(),oid); |
| | | rowIndexKeyStringMap.put(rowIndex, sb.toString()); |
| | | } |
| | | }); |
| | | //因为只是关键属性重复,所以我们不能重复的多条选一条来报错 |
| | | return selfRepeatRowIndexList; |
| | | resultVO.setKeyAttrRepeatRowIndexList(selfRepeatRowIndexList); |
| | | resultVO.setKeyAttrOkOidTORepeatOidMap(keyAttrOkOidTORepeatOidMap); |
| | | } |
| | | /** |
| | | * excel的标题上获取字段所在的位置 |
| | |
| | | DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(dataMap,clientBusinessObject); |
| | | for (String key:dataMap.keySet()){ |
| | | Object value= dataMap.getOrDefault(key,""); |
| | | clientBusinessObject.setAttributeValue(key,value.toString()); |
| | | clientBusinessObject.setAttributeValue(key.toLowerCase(Locale.ROOT),value==null?"":value.toString()); |
| | | } |
| | | clientBusinessObjectList.add(clientBusinessObject); |
| | | }); |
| | |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * 申请集团编码 |
| | | * @param idList |
| | | * @param btmName |
| | | */ |
| | | public void sendApplyGroupcode(List<String> idList,String btmName,String operationType){ |
| | | String oids=VciBaseUtil.array2String(idList.toArray(new String[]{})); |
| | | if(operationType.equals(sysIntegrationPushTypeEnum.ACCPET_APPCODE.getValue())) { |
| | | mdmInterJtClient.applyGroupCode(oids,btmName); |
| | | }else if(operationType.equals(sysIntegrationPushTypeEnum.ACCPET_EDITCODE)){ |
| | | mdmInterJtClient.receiveEditApply(oids,btmName); |
| | | } |
| | | } |
| | | } |