| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.ubcs.code.constant.MdmEngineConstant.DEFAULT_SYNC_ATTR_LIST; |
| | | import static com.vci.ubcs.code.constant.MdmEngineConstant.IMPORT_ROW_INDEX; |
| | | import static com.vci.ubcs.code.enumpack.CodeSecTypeEnum.CODE_CLASSIFY_SEC; |
| | | |
| | | /*** |
| | |
| | | public ResultOrgData syncDataForPerson(PersonData personData) { |
| | | boolean isUsedFlag= personAndDeptConfig.isUsedFlag(); |
| | | ResultOrgData resultOrgData=new ResultOrgData(); |
| | | List<ResultMdMapping> resultMdMappingList=new ArrayList<>(); |
| | | boolean success=true; |
| | | String message=""; |
| | | if(isUsedFlag){ |
| | |
| | | success=false; |
| | | throw new Throwable ("根据传输的分类,未获取MDM系统中对应模板"); |
| | | } |
| | | |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag()) |
| | | ).collect(Collectors.toList()); |
| | | |
| | | List<PersonMasterData> personMasterDataList= personData.getMasterData(); |
| | | List<Map> dataList=new ArrayList<>(); |
| | | ApplyDatasVO applyDatasVO=new ApplyDatasVO(); |
| | | |
| | | List<String> codeList=new ArrayList<>(); |
| | | |
| | | List<ApplyDataVO> applyDataVOList=new ArrayList<>(); |
| | | List<ApplyDataVO> deleteDataVOList=new ArrayList<>(); |
| | | personMasterDataList.stream().forEach(personMasterData -> { |
| | | ApplyDataVO object=new ApplyDataVO(); |
| | | object.setCode(personMasterData.getLm_code());//编码 |
| | |
| | | object.setEditor(personMasterData.getModifier());//修改者 |
| | | object.setId(personMasterData.getId());//主键 |
| | | object.setStatus(CodeDefaultLC.RELEASED.getValue());//状态则需要判断 |
| | | |
| | | Map<String,String> dataMap= VciBaseUtil.objectToMapString(personMasterData); |
| | | List<ProppertyVO> proppertyVOList=new ArrayList<>(); |
| | | dataMap.forEach((key,vaule)->{ |
| | |
| | | proppertyVOList.add(proppertyVO); |
| | | }); |
| | | object.setProp(proppertyVOList); |
| | | if(personMasterData.getDr()==1){ |
| | | object.setOperate("delete");//操作类型 |
| | | deleteDataVOList.add(object); |
| | | }else{ |
| | | String worker_category=personMasterData.getWorker_category(); |
| | | codeList.add(personMasterData.getLm_code()); |
| | | object.setOperate("create"); |
| | | applyDataVOList.add(object); |
| | | } |
| | | }); |
| | | applyDatasVO.setObject(applyDataVOList); |
| | | DataObjectVO dataObjectVO = new DataObjectVO(); |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag()) |
| | | ).collect(Collectors.toList()); |
| | | this.getConfigDatas("ERP", personLibrary, applyDatasVO, attrVOS, dataObjectVO); |
| | | log.info("end:数据组织完毕"); |
| | | //规则的主键需要去获取 |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyVO.getOid()); |
| | | if(classifyFullInfo==null ||classifyFullInfo.getCurrentClassifyVO()==null || StringUtils.isBlank(classifyFullInfo.getCurrentClassifyVO().getOid())){ |
| | | success=false; |
| | | log.info("classifyFullInfo:"+"根据传输的分类,未获取分类相关信息"); |
| | | throw new Throwable ("根据传输的分类,未获取分类相关信息"); |
| | | } |
| | | CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo); |
| | | if(ruleVO==null||StringUtils.isBlank(ruleVO.getOid())){ |
| | | success=false; |
| | | throw new Throwable ("根据传输的分类,未获取MDM系统中对应规则"); |
| | | } |
| | | log.info("end:规则获取完毕"); |
| | | |
| | | R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId()); |
| | | if(!r.isSuccess()) { |
| | | throw new Throwable(r.getMsg()); |
| | | } |
| | | BtmTypeVO btmTypeVO = r.getData(); |
| | | if (btmTypeVO == null) { |
| | | throw new Throwable("根据业务类型未查询到业务类型对象!"); |
| | | } |
| | | String tableName = btmTypeVO.getTableName(); |
| | | if (com.alibaba.nacos.common.utils.StringUtils.isBlank(tableName)) { |
| | | throw new Throwable("根据业务类型未查询到业务类型相关联的表"); |
| | | } |
| | | StringBuffer sb=new StringBuffer(); |
| | | sb.append(" select * from "); |
| | | sb.append(tableName); |
| | | sb.append(" where 1=1 "); |
| | | sb.append(" and lastr=1 and lastv=1" ); |
| | | sb.append(" and id in ("); |
| | | sb.append(VciBaseUtil.toInSql(codeList.toArray(new String[0]))); |
| | | sb.append(")"); |
| | | List<Map<String,String>> dataMapList=commonsMapper.queryByOnlySqlForMap(sb.toString()); |
| | | List<ClientBusinessObject> cboList= ChangeMapTOClientBusinessObjects(dataMapList); |
| | | ApplyDatasVO applyDatasVO=new ApplyDatasVO(); |
| | | ApplyDatasVO editDatasVO=new ApplyDatasVO(); |
| | | if(!CollectionUtils.isEmpty(cboList)){ |
| | | Map<String,ClientBusinessObject> oldpplyDataVOMap= cboList.stream().filter(data -> data != null && StringUtils.isNotBlank(data.getId())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | //数据库不存在的 |
| | | List<ApplyDataVO> applyApplyDataVOList = applyDataVOList.stream().filter(cbo -> { |
| | | String code =cbo.getCode(); |
| | | return !oldpplyDataVOMap.containsKey(code); |
| | | }).collect(Collectors.toList()); |
| | | applyDatasVO.setObject(applyApplyDataVOList); |
| | | //数据库存在的 |
| | | List<ApplyDataVO> editApplyDataVOList = applyDataVOList.stream().filter(cbo -> { |
| | | String code =cbo.getCode(); |
| | | if(oldpplyDataVOMap.containsKey(code)){ |
| | | cbo.setOperate("update"); |
| | | } |
| | | return oldpplyDataVOMap.containsKey(code); |
| | | }).collect(Collectors.toList()); |
| | | editApplyDataVOList.addAll(deleteDataVOList); |
| | | editDatasVO.setObject(editApplyDataVOList); |
| | | }else{ |
| | | applyDatasVO.setObject(applyDataVOList); |
| | | } |
| | | |
| | | LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs=new LinkedList<>(); |
| | | if(editDatasVO.getObject()!=null&&editDatasVO.getObject().size()>0){ |
| | | DataObjectVO dataObjectVO = new DataObjectVO(); |
| | | this.getConfigDatas("ERP", personLibrary, editDatasVO, attrVOS, dataObjectVO); |
| | | log.info("start:修改数据执行完毕"); |
| | | boolean personApplyGroupCode =personAndDeptConfig.isPersonApplyGroupCode(); |
| | | mdmIOService.batchSyncEditDatas(codeClassifyVO,dataObjectVO, resultDataObjectDetailDOs,personApplyGroupCode); |
| | | log.info("end:修改数据执行完毕"); |
| | | } |
| | | if(applyDatasVO.getObject()!=null&&applyDatasVO.getObject().size()>0) { |
| | | DataObjectVO dataObjectVO = new DataObjectVO(); |
| | | this.getConfigDatas("ERP", personLibrary, editDatasVO, attrVOS, dataObjectVO); |
| | | |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyVO.getOid()); |
| | | CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo); |
| | | if(ruleVO==null||"".equals(ruleVO.getOid())){ |
| | | throw new Throwable("编码规则"); |
| | | } |
| | | List<XMLResultDataObjectDetailDO> xDOs=new CopyOnWriteArrayList<>(); |
| | | dataObjectVO.getRowData().parallelStream().forEach(rowData->{ |
| | | String mesg=""; |
| | | try { |
| | | CodeOrderDTO orderDTO = new CodeOrderDTO(); |
| | | List<CodeOrderSecDTO> codeOrderSecDTOList=new ArrayList<>(); |
| | | orderDTO.setCodeClassifyOid(codeClassifyVO.getOid());//分类主键 |
| | | if(!CollectionUtils.isEmpty(ruleVO.getSecVOList())) { |
| | | ruleVO.getSecVOList().stream().forEach(codeBasicSecVO -> { |
| | | if (codeBasicSecVO.getSecType().equals("codevariablesec")) {//规则之定义为可变码段存储主数据传递过来的数据 |
| | | CodeOrderSecDTO CodeOrderSecDTO = new CodeOrderSecDTO(); |
| | | CodeOrderSecDTO.setSecOid(codeBasicSecVO.getOid()); |
| | | CodeOrderSecDTO.setSecValue(rowData.getCode()); |
| | | codeOrderSecDTOList.add(CodeOrderSecDTO); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | orderDTO.setSecDTOList(codeOrderSecDTOList);//存储编码 |
| | | orderDTO.setData(rowData.getFiledValue()); |
| | | engineService.addSaveCode(orderDTO); |
| | | } catch (Exception e) { |
| | | mesg=e.getMessage(); |
| | | e.getMessage(); |
| | | e.printStackTrace(); |
| | | }finally { |
| | | XMLResultDataObjectDetailDO x=new XMLResultDataObjectDetailDO(); |
| | | x.setId(rowData.getOid()); |
| | | x.setCode(rowData.getCode()); |
| | | x.setMsg(mesg); |
| | | x.setErrorid("1"); |
| | | xDOs.add(x); |
| | | } |
| | | }); |
| | | resultDataObjectDetailDOs.addAll(xDOs); |
| | | boolean finalSuccess1 = success; |
| | | String finalMessage1 = message; |
| | | resultDataObjectDetailDOs.stream().forEach(resultDataObjectDetailDO->{ |
| | | ResultMdMapping resultMdMapping=new ResultMdMapping(); |
| | | resultMdMapping.setBusiDataId(resultDataObjectDetailDO.getId()); |
| | | resultMdMapping.setSuccess(finalSuccess1); |
| | | resultMdMapping.setEntityCode(" "); |
| | | resultMdMapping.setMdmCode(resultDataObjectDetailDO.getCode()); |
| | | resultMdMapping.setMessage(finalMessage1); |
| | | resultMdMapping.setSubMdMappings(null); |
| | | resultMdMappingList.add(resultMdMapping); |
| | | }); |
| | | log.info("end:申请获取完毕"); |
| | | } |
| | | }catch (Throwable e){ |
| | | success=false; |
| | | message="人员数据接受失败:"+e.getMessage(); |
| | | }finally { |
| | | //组织返回结果 |
| | | boolean finalSuccess = success; |
| | | String finalMessage = message; |
| | | masterDataList.stream().forEach(masterData -> { |
| | | ResultMdMapping resultMdMapping=new ResultMdMapping(); |
| | | resultMdMapping.setBusiDataId(masterData.getId()); |
| | | resultMdMapping.setSuccess(finalSuccess); |
| | | resultMdMapping.setEntityCode(" "); |
| | | resultMdMapping.setMdmCode(masterData.getLm_code()); |
| | | resultMdMapping.setMessage(finalMessage); |
| | | resultMdMapping.setSubMdMappings(null); |
| | | }); |
| | | }finally { |
| | | resultOrgData.setMessage(message); |
| | | resultOrgData.setSuccess(success); |
| | | resultOrgData.setMdMappings(resultMdMappingList); |
| | | Object object = JSONObject.toJSON(resultOrgData); |
| | | return resultOrgData; |
| | | } |
| | | |
| | | } |
| | | |
| | | Object object = JSONObject.toJSON(resultOrgData); |
| | | return resultOrgData; |
| | | } |
| | | /**** |