| | |
| | | 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.*; |
| | |
| | | */ |
| | | @Autowired |
| | | private IBtmTypeClient btmTypeClient; |
| | | |
| | | /*** |
| | | * 申请集团编码服务 |
| | | */ |
| | | @Resource |
| | | private IMdmInterJtClient mdmInterJtClient; |
| | | /*** |
| | | * 密级服务 |
| | | */ |
| | |
| | | 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->{ |
| | | /* //传入数据之间关键属性的校验 |
| | |
| | | String lcstatus =newCbo.getLcStatus(); |
| | | String newOid =newCbo.getOid(); |
| | | Date ts =newCbo.getTs(); |
| | | groupCode=newCbo.getData().get("GROUPCODE"); |
| | | code=newCbo.getId(); |
| | | code = StringUtils.isBlank(newCbo.getId())?"":newCbo.getId(); |
| | | groupCode=newCbo.getData().getOrDefault("GROUPCODE",""); |
| | | String lastmodifier=newCbo.getLastModifier(); |
| | | if (lcstatus!=null&&!lcstatus.equals(CodeDefaultLC.RELEASED.getValue())) { |
| | | newCbo.setOid(newOid); |
| | |
| | | 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(); |
| | | String code=needSaveCbo.getId(); |
| | | String groupCode=needSaveCbo.getData().getOrDefault("GROUPCODE",""); |
| | | 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); |
| | | } |
| | |
| | | resultDataObjectDetailDO.setErrorid("0"); |
| | | 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()); |
| | |
| | | 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="更新/状态更改/删除成功!"; |
| | | }catch (Throwable e){ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验属性是否为必输 |
| | | * |
| | |
| | | * @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){ |
| | | 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(); |
| | |
| | | if(rowIndexKeyStringMap.containsValue(keyString) && StringUtils.isNotBlank(keyString)){ |
| | | selfRepeatRowIndexList.add(rowIndex); |
| | | String okOid=okOidKeyStringMap.getOrDefault(keyString,""); |
| | | if(StringUtils.isBlank(okOid)){ |
| | | if(StringUtils.isNotBlank(okOid)){ |
| | | List<String>newOidList=new ArrayList<>(); |
| | | newOidList.add(oid); |
| | | if(keyAttrOkOidTORepeatOidMap.containsKey(okOid)){ |
| | |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * 申请集团编码 |
| | | * @param idList |
| | | * @param btmName |
| | | */ |
| | | private 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); |
| | | } |
| | | } |
| | | } |