| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.thoughtworks.xstream.XStream; |
| | | import com.thoughtworks.xstream.io.xml.DomDriver; |
| | | import com.vci.ubcs.code.Scheduling.NonWebRequestAttributes; |
| | | import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; |
| | | import com.vci.ubcs.code.constant.MdmDuckingConstant; |
| | | import com.vci.ubcs.code.dto.CodeOrderDTO; |
| | | import com.vci.ubcs.code.dto.CodeOrderSecDTO; |
| | | import com.vci.ubcs.code.dto.datapush.classify.JsonRootDataDTO; |
| | | import com.vci.ubcs.code.dto.datapush.classify.NodeClassifyDTO; |
| | | import com.vci.ubcs.code.dto.datapush.classify.NodeDataDTO; |
| | |
| | | import com.vci.ubcs.code.dto.datapush.result.ResultNodeDataDTO; |
| | | import com.vci.ubcs.code.dto.datapush.result.ResultNodeObjectDTO; |
| | | import com.vci.ubcs.code.entity.*; |
| | | import com.vci.ubcs.code.enumpack.CodeDefaultLC; |
| | | import com.vci.ubcs.code.enumpack.CodeSecTypeEnum; |
| | | import com.vci.ubcs.code.enumpack.SysIntegrationDataFlowTypeEnum; |
| | | import com.vci.ubcs.code.feign.MdmSearchItemCodeProvider; |
| | | import com.vci.ubcs.code.mapper.CommonsMapper; |
| | | import com.vci.ubcs.code.service.*; |
| | | import com.vci.ubcs.code.util.gennerAttrMapUtil; |
| | | import com.vci.ubcs.code.vo.pagemodel.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.apply.ApplyDataVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.apply.ApplyDatasVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.apply.ProppertyVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.apply.SectionVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.applybz.ApplyBZDataVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.applybz.ApplyBZDatasVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.attrmap.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultDataObjectDetailDO; |
| | | import com.vci.ubcs.code.webService.config.AttributeMapConfig; |
| | | import com.vci.ubcs.omd.feign.IBtmTypeClient; |
| | | import com.vci.ubcs.omd.vo.BtmTypeVO; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.revision.model.BaseModel; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.util.HttpUtils; |
| | | import com.vci.ubcs.code.util.WsErpClientUtil; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO; |
| | | import com.vci.ubcs.starter.web.enumpck.UserSecretEnum; |
| | | import com.vci.ubcs.starter.web.pagemodel.SessionInfo; |
| | | import com.vci.ubcs.starter.web.util.BeanUtil; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.WebUtil; |
| | | import com.vci.ubcs.system.user.entity.User; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.map.CaseInsensitiveMap; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.mock.web.MockHttpServletRequest; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.support.DefaultTransactionStatus; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.context.request.RequestAttributes; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.jws.WebMethod; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.xml.ws.WebServiceContext; |
| | | import javax.xml.ws.handler.MessageContext; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.ubcs.code.constant.MdmDuckingConstant.*; |
| | | import static com.vci.ubcs.code.constant.MdmEngineConstant.DEFAULT_SYNC_ATTR_LIST; |
| | | import static com.vci.ubcs.code.enumpack.CodeSecTypeEnum.CODE_CLASSIFY_SEC; |
| | | |
| | | |
| | | /* |
| | |
| | | public class CodeDuckingSyncServiceImpl implements ICodeDuckingSyncService { |
| | | @Value("${dataSyncPush.dataParamName:xmlData}") |
| | | public String DATA_PARAM_NAME; |
| | | @Value("${dataSyncPush.dataId:itemid}") |
| | | private String itemId; |
| | | @Value("${erp.item.attrKey:xhdh}") |
| | | public String attrKey; |
| | | |
| | | @Value("${erp.item.systemId:ERP}") |
| | | public String systemId; |
| | | @Value("${erp.item.secName:固定码段}") |
| | | public String secName; |
| | | @Value("${erp.item.secValue:A}") |
| | | public String secValue; |
| | | |
| | | @Value("${erp.item.btmName:XHDH}") |
| | | public String btmName; |
| | | /** |
| | | * 业务类型的服务 |
| | | */ |
| | | @Autowired |
| | | private IBtmTypeClient btmTypeClient; |
| | | /** |
| | | * 通用查询 |
| | | */ |
| | | @Resource |
| | | private CommonsMapper commonsMapper; |
| | | @Resource |
| | | private MdmEngineService mdmEngineServiceI; |
| | | /** |
| | | * 批量处理的服务 |
| | | */ |
| | | @Resource |
| | | private MdmIOService mdmIOService; |
| | | @Resource |
| | | private IPasswordFreeLoginService passwordFreeLoginService; |
| | | |
| | | @Resource |
| | | private IDockingLogeService dockingLogeService; |
| | |
| | | private IDockingSystemConfigService dockingSystemConfigService; |
| | | @Resource |
| | | private ICodeClassifyService codeClassifyService; |
| | | |
| | | @Autowired |
| | | private ICodeClassifyValueService codeClassifyValueService; |
| | | @Autowired(required = false) |
| | | private AttributeMapConfig attributeMapConfig; |
| | | /*** |
| | | * resdis缓存服务 |
| | | */ |
| | |
| | | private IDockingSysIntParamService dockingSysIntParamService; |
| | | @Resource |
| | | private IDockingSysIntHeaderService dockingSysIntHeaderService; |
| | | |
| | | |
| | | |
| | | @Autowired(required = false) |
| | | private MdmSearchItemCodeProvider mdmSearchItemCodeProvider; |
| | | @Autowired |
| | | HttpServletRequest request; |
| | | @Override |
| | | public void DockingDataSyncScheduing() { |
| | | |
| | |
| | | }); |
| | | return R.success("手动推送完成,请核对是否推送成功"); |
| | | } |
| | | private SearchItemDataVO initData(String status,String itemCode,String mmCode){ |
| | | SearchItemDataVO searchItemDataVO=new SearchItemDataVO(); |
| | | searchItemDataVO.setLastchangedon(new Date()); |
| | | searchItemDataVO.setLastchangedby("19831133"); |
| | | searchItemDataVO.setCreatby("19831133"); |
| | | searchItemDataVO.setCreatedon(new Date()); |
| | | searchItemDataVO.setIsenabled(status); |
| | | searchItemDataVO.setMaterialcode("XMDH0001"); |
| | | searchItemDataVO.setStatus("1"); |
| | | searchItemDataVO.setProjectcode("3333"); |
| | | searchItemDataVO.setProjectitem(itemCode); |
| | | searchItemDataVO.setMmodelcode(mmCode); |
| | | |
| | | return searchItemDataVO; |
| | | } |
| | | |
| | | public HttpServletRequest getRequest(){ |
| | | HttpServletRequest request =null; |
| | | RequestAttributes requestAttributes = null; |
| | | try{ |
| | | requestAttributes = RequestContextHolder.currentRequestAttributes(); |
| | | }catch (IllegalStateException e){ |
| | | //requestAttributes = new NonWebRequestAttributes(); |
| | | //RequestContextHolder.setRequestAttributes(requestAttributes, true); |
| | | request = new MockHttpServletRequest(); |
| | | RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request),true); |
| | | }finally { |
| | | if (requestAttributes instanceof ServletRequestAttributes) { |
| | | ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.currentRequestAttributes(); |
| | | request = servletRequestAttributes.getRequest(); |
| | | } |
| | | } |
| | | return request; |
| | | } |
| | | /*** |
| | | * 同步型号代号 |
| | | */ |
| | | @Override |
| | | public void saveItemDataSyncScheduing(String endDate) { |
| | | String paramString=""; |
| | | String backString="成功"; |
| | | String msg="成功"; |
| | | boolean success=true; |
| | | SearchItemParam searchItemParam=new SearchItemParam(); |
| | | searchItemParam.setSystag("VCI"); //调用系统标识 |
| | | SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String lastchangedon=""; |
| | | if(StringUtils.isBlank(endDate)) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | log.info("查询时间------->"+calendar.getTime()); |
| | | lastchangedon= dft.format(calendar.getTime()); |
| | | }else{ |
| | | lastchangedon=endDate; |
| | | } |
| | | searchItemParam.setLastchangedon(lastchangedon); |
| | | searchItemParam.setStatus("1");// |
| | | Map<String,String>searchDataMap= VciBaseUtil.objectToMapString(searchItemParam); |
| | | SearchItemVO searchItemVO= mdmSearchItemCodeProvider.getppModelByElem(searchDataMap); |
| | | /*SearchItemVO searchItemVO=new SearchItemVO(); |
| | | List<SearchItemDataVO> data=new ArrayList<>(); |
| | | SearchItemDataVO searchItemDataVO1=initData("1","","pro-00001"); |
| | | SearchItemDataVO searchItemDataVO2=initData("0","item-00001",""); |
| | | data.add(searchItemDataVO1); |
| | | data.add(searchItemDataVO2); |
| | | searchItemVO.setData(data); |
| | | searchItemVO.setCode("200"); |
| | | searchItemVO.setMsg("");*/ |
| | | if(searchItemVO!=null) { |
| | | paramString = JSONObject.toJSON(searchItemVO).toString(); |
| | | try { |
| | | //免密登录申请token,request中添加用户信息 |
| | | try { |
| | | passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(Locale.ROOT),getRequest()); |
| | | }catch (Throwable e){ |
| | | throw new Throwable("用户鉴权失败."); |
| | | } |
| | | final BladeUser user = AuthUtil.getUser(); |
| | | List<CodeClassify> codeClassifyList = codeClassifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().in(CodeClassify::getId, btmName)); |
| | | if (CollectionUtils.isEmpty(codeClassifyList)) { |
| | | throw new Throwable("分类未查询到"); |
| | | } |
| | | CodeClassify codeClassify= codeClassifyList.get(0); |
| | | CodeClassifyTemplateVO templateVO = mdmEngineServiceI.getUsedTemplateByClassifyOid(codeClassify.getOid()); |
| | | if(templateVO==null||StringUtils.isBlank(templateVO.getOid())){ |
| | | throw new Throwable ("根据传输的分类,未获取MDM系统中对应模板"); |
| | | } |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && |
| | | ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | List<SearchItemDataVO> dataList = searchItemVO.getData(); |
| | | Map<String, SearchItemDataVO> dataVOMap = new HashMap<>(); |
| | | List<String> itemCodeList = new ArrayList<>(); |
| | | ApplyDatasVO allDatasVO = new ApplyDatasVO(); |
| | | List<ApplyDataVO> allObjectList=new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(dataList)) { |
| | | dataList.stream().forEach(searchItemDataVO -> { |
| | | String itemCode = StringUtils.isNotBlank(searchItemDataVO.getProjectitem()) ? searchItemDataVO.getProjectitem() : searchItemDataVO.getMmodelcode();//项目代号 |
| | | dataVOMap.put(itemCode, searchItemDataVO); |
| | | itemCodeList.add(itemCode); |
| | | }); |
| | | String tableName = ""; |
| | | R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(codeClassify.getBtmTypeId()); |
| | | if (!r.isSuccess()) { |
| | | throw new Throwable(r.getMsg()); |
| | | } |
| | | BtmTypeVO btmTypeVO = r.getData(); |
| | | if (btmTypeVO == null) { |
| | | throw new Throwable("根据业务类型未查询到业务类型对象!"); |
| | | } |
| | | tableName = btmTypeVO.getTableName(); |
| | | if (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 codeclsfid = '" + codeClassify.getOid() + "' "); |
| | | sb.append(" and "+ VciBaseUtil.toInSql(attrKey,itemCodeList.toArray(new String[]{}))); |
| | | List<Map<String, String>> newDataList = commonsMapper.queryByOnlySqlForMap(sb.toString()); |
| | | //List<BaseModel> baseModelList=new ArrayList<>(); |
| | | Map<String,BaseModel> baseModelMap=new HashMap<>(); |
| | | newDataList.stream().forEach(dataMap->{ |
| | | BaseModel baseModel=new BaseModel(); |
| | | Map<String,String> newDateMap=new CaseInsensitiveMap<>(dataMap); |
| | | DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(newDateMap,baseModel,true,user); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(baseModel,user); |
| | | //baseModelList.add(baseModel); |
| | | |
| | | String attrKeyValue=newDateMap.getOrDefault(attrKey,""); |
| | | baseModelMap.put(attrKeyValue,baseModel); |
| | | }); |
| | | |
| | | List<ApplyDataVO> addObjectList=new ArrayList<>(); |
| | | List<ApplyDataVO> editObjectList=new ArrayList<>(); |
| | | dataVOMap.forEach((key,value)->{ |
| | | if(baseModelMap.containsKey(key)){ |
| | | BaseModel baseModel=baseModelMap.get(key); |
| | | changeObjectToMap(value,baseModel.getId(),user,"editstatus",editObjectList); |
| | | }else{ |
| | | changeObjectToMap(value,"",user,"create",addObjectList); |
| | | } |
| | | }); |
| | | allObjectList.addAll(addObjectList); |
| | | allObjectList.addAll(editObjectList); |
| | | allDatasVO.setObject(allObjectList); |
| | | LinkedList<XMLResultDataObjectDetailDO> allResultDataObjectDetailDOS=new LinkedList<>(); |
| | | if(!CollectionUtils.isEmpty(addObjectList)){ |
| | | //规则的主键需要去获取 |
| | | CodeClassifyFullInfoBO classifyFullInfo = codeClassifyService.getClassifyFullInfo(codeClassify.getOid()); |
| | | if(classifyFullInfo==null ||classifyFullInfo.getCurrentClassifyVO()==null || StringUtils.isBlank(classifyFullInfo.getCurrentClassifyVO().getOid())){ |
| | | log.info("classifyFullInfo:"+"根据传输的分类,未获取分类相关信息"); |
| | | throw new Throwable ("根据传输的分类,未获取分类相关信息"); |
| | | } |
| | | CodeRuleVO ruleVO = mdmEngineServiceI.getCodeRuleByClassifyFullInfo(classifyFullInfo); |
| | | if(ruleVO==null||StringUtils.isBlank(ruleVO.getOid())){ |
| | | throw new Throwable ("根据传输的分类,未获取MDM系统中对应规则"); |
| | | } |
| | | DataObjectVO dataObjectVO = new DataObjectVO(); |
| | | ApplyDatasVO applyDatasVO = new ApplyDatasVO(); |
| | | applyDatasVO.setObject(addObjectList); |
| | | LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs = new LinkedList<>(); |
| | | this.getConfigDatas(systemId, btmName, applyDatasVO, attrVOS, dataObjectVO); |
| | | CodeOrderDTO orderDTO = new CodeOrderDTO(); |
| | | orderDTO.setCodeClassifyOid(codeClassify.getOid());//分类主键 |
| | | //码段设置 |
| | | List<SectionVO> section=new ArrayList<>(); |
| | | SectionVO sectionVO=new SectionVO(); |
| | | sectionVO.setValue(secValue); |
| | | sectionVO.setName(secName); |
| | | section.add(sectionVO); |
| | | log.info("end:规则获取完毕"); |
| | | List<CodeOrderSecDTO> codeOrderSecDTOList = getRuleCodeOrderSecDTOs(section, ruleVO,classifyFullInfo); |
| | | log.info("end:码段获取完毕"); |
| | | orderDTO.setSecDTOList(codeOrderSecDTOList);//分类码段 |
| | | mdmIOService.batchSyncApplyCode(orderDTO, dataObjectVO, resultDataObjectDetailDOs,false); |
| | | allResultDataObjectDetailDOS.addAll(resultDataObjectDetailDOs); |
| | | } |
| | | //更新数据(更新状态) |
| | | if(!CollectionUtils.isEmpty(editObjectList)){ |
| | | DataObjectVO dataObjectVO = new DataObjectVO(); |
| | | ApplyDatasVO applyDatasVO = new ApplyDatasVO(); |
| | | applyDatasVO.setObject(editObjectList); |
| | | LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs = new LinkedList<>(); |
| | | CodeClassifyVO codeClassifyVO=new CodeClassifyVO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassify, codeClassifyVO); |
| | | this.getConfigDatas(systemId, btmName, applyDatasVO, attrVOS, dataObjectVO); |
| | | mdmIOService.batchSyncEditDatas(codeClassifyVO,dataObjectVO, resultDataObjectDetailDOs,false); |
| | | allResultDataObjectDetailDOS.addAll(resultDataObjectDetailDOs); |
| | | } |
| | | Object paramObject = JSONObject.toJSON(allDatasVO); |
| | | paramString=Func.isEmpty(paramObject)?"":paramObject.toString(); |
| | | Object backObject = JSONObject.toJSON(allResultDataObjectDetailDOS); |
| | | backString=Func.isEmpty(backObject)?"":backObject.toString(); |
| | | } |
| | | } |
| | | catch (Throwable e){ |
| | | e.printStackTrace();; |
| | | log.error("查询失败--->"+e); |
| | | success=false; |
| | | backString="查询失败--->"+e; |
| | | msg="查询失败--->"+e; |
| | | throw new VciBaseException(e.getMessage()); |
| | | }finally { |
| | | try { |
| | | //记录日志 |
| | | this.saveLogs(systemId, systemId, paramString, backString, success, msg, "queryData"); |
| | | }catch (Throwable e){ |
| | | e.printStackTrace(); |
| | | log.error(e.getMessage()); |
| | | throw new VciBaseException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * 记录日志信息 |
| | | * @param systemId |
| | | * @param parmaData |
| | | * @param result |
| | | * @return |
| | | */ |
| | | private void saveLogs(String systemId,String systemName,String parmaData, String result,boolean isSucess,String msg,String operation){ |
| | | //记录日志信息 |
| | | DockingLog dockingLoge=new DockingLog(); |
| | | //String oid=redisService.getUUIDEveryDay(); |
| | | dockingLoge.setSystemCode(StringUtils.isBlank(systemId)?"-":systemId);//设置系统标识 |
| | | dockingLoge.setSystemName(StringUtils.isBlank(systemName)?"-":systemName); |
| | | dockingLoge.setMsg(msg);//日志消息 |
| | | dockingLoge.setClassifyId("-");//分类编号 |
| | | dockingLoge.setClassifyName("-");//分类名称 |
| | | dockingLoge.setClassifyOid("-");//分类主键 |
| | | dockingLoge.setUniqueCode("-");//唯一标识 |
| | | dockingLoge.setSystemOid("-");//系统标识 |
| | | // dockingLogeDO.setName(operation); |
| | | //dockingLogeDO.setOid(oid);//日志主键 |
| | | dockingLoge.setParamString(parmaData);//参数信息 |
| | | dockingLoge.setReturnString(result);//返回信息 |
| | | dockingLoge.setType(operation);//日志操作类型 |
| | | dockingLoge.setCreateTime(new Date()); |
| | | if(isSucess) { |
| | | dockingLoge.setInterfaceStatus("true");//接口集成状态 |
| | | }else{ |
| | | dockingLoge.setInterfaceStatus("false");//接口集成状态 |
| | | } |
| | | dockingLogeService.save(dockingLoge); |
| | | log.info("集成推送数据成功,systemId:"+systemId+",systemname:"+systemName+",operation:"+operation+",param:"+parmaData); |
| | | } |
| | | |
| | | /*** |
| | | * 根据传入的参数信息校验码段规则 |
| | | */ |
| | | private List<CodeOrderSecDTO> getRuleCodeOrderSecDTOs(List<SectionVO> SectionVOList, CodeRuleVO ruleVO, CodeClassifyFullInfoBO classifyFullInfo) throws Throwable{ |
| | | List<CodeBasicSecVO> codeBasicSecVOS= ruleVO.getSecVOList(); |
| | | Map<String,String> sectionVOMap=new HashMap<>(); |
| | | SectionVOList.stream().forEach(SectionVO->{ |
| | | sectionVOMap.put(SectionVO.getName(),SectionVO.getValue()); |
| | | }); |
| | | //Map<String,CodeClassifyVO> codeClassifyVOMap= classifyFullInfo.getParentClassifyVOs().stream().collect(Collectors.toMap(s -> s.getId(), t -> t,(o1, o2)->o2)); |
| | | List<CodeOrderSecDTO> codeOrderSecDTOList=new ArrayList<>(); |
| | | Map<String,String> errorMap=new HashMap<>(); |
| | | for(CodeBasicSecVO codeBasicSecVO: codeBasicSecVOS) { |
| | | String sectype = codeBasicSecVO.getSecType(); |
| | | String newSecName=codeBasicSecVO.getName(); |
| | | String classifySecOid= codeBasicSecVO.getOid(); |
| | | String message=""; |
| | | if (!sectype.equals(CodeSecTypeEnum.CODE_SERIAL_SEC.getValue())) { |
| | | String name = codeBasicSecVO.getName(); |
| | | String sectypeText = codeBasicSecVO.getSecTypeText(); |
| | | log.info("码段名称:"+name); |
| | | log.info("描述:"+sectypeText); |
| | | CodeOrderSecDTO CodeOrderSecDTO = new CodeOrderSecDTO(); |
| | | if (sectionVOMap.containsKey(name)) { |
| | | CodeOrderSecDTO.setSecOid(codeBasicSecVO.getOid()); |
| | | String sectypeValue = sectionVOMap.get(name); |
| | | log.info("码段值:"+sectypeValue); |
| | | CodeSecTypeEnum secType = CodeSecTypeEnum.forValue(sectype); |
| | | if(CODE_CLASSIFY_SEC.equals(secType)) {//如果是分类的话,则需要匹配传过来的分类代号与 |
| | | //先简称是否有关联模板,有模板要先删除 |
| | | List<CodeClassifyValue> codeClassifyValueDOList = codeClassifyValueService.list(Wrappers.<CodeClassifyValue>query().lambda().eq(CodeClassifyValue::getCodeClassifySecOid,classifySecOid)); |
| | | |
| | | if (!CollectionUtils.isEmpty(codeClassifyValueDOList)) { |
| | | Map<String, CodeClassifyValue> codeClassifyValueDOMap = codeClassifyValueDOList.stream().collect(Collectors.toMap(s -> s.getId(), t -> t, (o1, o2) -> o2)); |
| | | if(codeClassifyValueDOMap.containsKey(sectypeValue)){ |
| | | CodeClassifyValue codeClassifyValue= codeClassifyValueDOMap.get(sectypeValue); |
| | | sectypeValue=codeClassifyValue.getOid(); |
| | | }else { |
| | | //throw new Throwable("传入的分类码段:【" + name + " 值:" + sectypeValue + "】,不符合当前分类层级代号"); |
| | | message="传入的分类码段:【" + name + " 值:" + sectypeValue + "】,不符合当前分类层级代号"; |
| | | errorMap.put("error",errorMap.getOrDefault("error","")+";"+message); |
| | | } |
| | | } |
| | | } |
| | | if(StringUtils.isBlank(sectypeValue)){ |
| | | message="传入的分类码段:【" + name + " 】的值不允许为空"; |
| | | errorMap.put("error",errorMap.getOrDefault("error","")+";"+message); |
| | | } |
| | | CodeOrderSecDTO.setSecValue(sectypeValue); |
| | | codeOrderSecDTOList.add(CodeOrderSecDTO); |
| | | } else { |
| | | message="传入的码段规则缺少" + name; |
| | | errorMap.put("error",errorMap.getOrDefault("error","")+";"+message); |
| | | } |
| | | } |
| | | } |
| | | if(errorMap.size()>0){ |
| | | throw new Throwable(errorMap.getOrDefault("error","")); |
| | | } |
| | | return codeOrderSecDTOList; |
| | | } |
| | | /*** |
| | | * 读取属性映射配置信息 |
| | | * @param systemId |
| | | * @param libray |
| | | * @param applyDatasVO |
| | | * @param codeClassifyTemplateAttrVOList |
| | | * @param dataObjectVO |
| | | * @throws Throwable |
| | | */ |
| | | public void getConfigDatas(String systemId,String libray, ApplyDatasVO applyDatasVO,List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOList,DataObjectVO dataObjectVO) throws Throwable { |
| | | |
| | | LinkedHashMap<String,LinkedHashMap<String,String>> dataKeyValueMap=new LinkedHashMap<>(); |
| | | //如果将数据转换成所需要的数据对象 |
| | | Map<String, String> attrMapConfigMap=new HashMap<>(); |
| | | Map<String, String> propMaps=new HashMap<>(); |
| | | log.info("开始读取系统配置文件 start"); |
| | | Map<String, String> stringStringMap=attributeMapConfig.getSystem_attrmap(); |
| | | log.info("集成系统属性映射配置文件条目数-》"+stringStringMap.size()); |
| | | //stringStringMap.put("RLM","D:\\RLM.xml"); |
| | | if(!CollectionUtils.isEmpty(stringStringMap)) { |
| | | List<LibraryClsfDO> libraryClsfDOList=new ArrayList<>(); |
| | | try { |
| | | log.info("info:需要读取配置文件"); |
| | | LibraryDO libraryDO = gennerAttrMapUtil.getNewInstance().gennerAttrMapBySystem(systemId, stringStringMap); |
| | | libraryClsfDOList = libraryDO.getClsf(); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | throw new Throwable("集成系统标识为:【" + systemId + "】,分类库为:【" + libray + "】的集成属性配置文件读取失败"); |
| | | } |
| | | String path = stringStringMap.get(systemId); |
| | | if (!CollectionUtils.isEmpty(libraryClsfDOList)) { |
| | | Map<String, List<ClsfAttrMappingDO>> libPropMaps = libraryClsfDOList.stream().collect(Collectors.toMap(LibraryClsfDO::getLibrary, LibraryClsfDO::getProp, (key1, key2) -> key2)); |
| | | log.info("根据参数:libray:-》" + libray + "从配置文件中找对应属性映射配置"); |
| | | if (libPropMaps.containsKey(libray.toUpperCase(Locale.ROOT))) { |
| | | log.info("根据参数:libray:-》" + libray + "匹配到相应的属性映射信息"); |
| | | List<ClsfAttrMappingDO> clsfAttrMappingDOList = libPropMaps.get(libray.toUpperCase(Locale.ROOT)); |
| | | propMaps = clsfAttrMappingDOList.stream().collect(Collectors.toMap(ClsfAttrMappingDO::getSourceKey, ClsfAttrMappingDO::getTargetKey, (key1, key2) -> key2)); |
| | | log.info("根据参数:libray:-》" + libray + "匹配到相应的属性映射信息,属性映射条目数+" + clsfAttrMappingDOList.size()); |
| | | } else { |
| | | throw new Throwable("根据系统标识【" + systemId + "】找到对应的配置文件:【" + path + "】,但未获取到对应的库【" + libray + "】属性映射信息配置"); |
| | | } |
| | | }else{ |
| | | throw new Throwable("根据系统标识【" + systemId + "】找到对应的配置文件:【" + path + "】,但未获取到对应的库【" + libray + "】属性映射信息配置"); |
| | | } |
| | | }else{ |
| | | throw new Throwable("未获取到集成属性映射系统配置信息"); |
| | | } |
| | | log.info("根据参数:libray:-》"+libray+"从配置文件中找对应属性映射配置 end "); |
| | | LinkedList<String> rowNameList=new LinkedList<>(); |
| | | LinkedHashMap<String,Integer> filedIndexMap=new LinkedHashMap<>(); |
| | | //根据分类模板组织数据 |
| | | final int[] index = {0}; |
| | | try { |
| | | //除去默认的属性.还有只有具有分类注入的才过滤出来 |
| | | codeClassifyTemplateAttrVOList = codeClassifyTemplateAttrVOList.stream().filter( |
| | | s ->!DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && |
| | | ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | codeClassifyTemplateAttrVOList.stream().forEach(codeClassifyTemplateAttrVO -> { |
| | | String attrName = codeClassifyTemplateAttrVO.getName(); |
| | | String field = codeClassifyTemplateAttrVO.getId(); |
| | | rowNameList.add(attrName); |
| | | filedIndexMap.put(field, index[0]++); |
| | | }); |
| | | dataObjectVO.setColName(rowNameList);//放入属性 |
| | | attrMapConfigMap.putAll(propMaps); |
| | | LinkedList<RowDatas> rowDataList = new LinkedList<>(); |
| | | List<ApplyDataVO> applyDataVOList=new ArrayList<>(); |
| | | |
| | | if(!CollectionUtils.isEmpty(applyDatasVO.getObject())){ |
| | | applyDataVOList=applyDatasVO.getObject(); |
| | | } |
| | | //Map<String, List<ProppertyVO>> dataPropMap = applyDataVOList.stream().collect(Collectors.toMap(ApplyDataVO::getId, ApplyDataVO::getProp, (key1, key2) -> key2)); |
| | | final int[] rowIndex = {0}; |
| | | applyDataVOList.stream().forEach(applyDataVO -> { |
| | | rowIndex[0]++; |
| | | RowDatas rowDatas = new RowDatas(); |
| | | rowDatas.setOid(applyDataVO.getId()); |
| | | rowDatas.setCreator(applyDataVO.getCreator()); |
| | | rowDatas.setEditor(applyDataVO.getEditor()); |
| | | rowDatas.setCode(applyDataVO.getCode()); |
| | | rowDatas.setOperation(applyDataVO.getOperate()); |
| | | rowDatas.setStatus(applyDataVO.getStatus()); |
| | | rowDatas.setRowIndex(rowIndex[0] + ""); |
| | | List<ProppertyVO> proppertyVOList = applyDataVO.getProp(); |
| | | |
| | | LinkedHashMap<Integer, String> integerValueMap = new LinkedHashMap<>(); |
| | | Map<String, String> filedValueMap = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(proppertyVOList)) { |
| | | Map<String, String> sourceKeyValueMap = proppertyVOList.stream().collect(Collectors.toMap(ProppertyVO::getKey, ProppertyVO::getValue, (key1, key2) -> key2)); |
| | | Map<String, String> keyValueMap = new HashMap<>(); |
| | | //判断attrMapConfigMap是否有值,如果没有则说明基础默认的是编码系统字段 |
| | | if (!CollectionUtils.isEmpty(attrMapConfigMap)) { |
| | | sourceKeyValueMap.keySet().forEach(sourceKey -> { |
| | | String dataValue = sourceKeyValueMap.get(sourceKey); |
| | | if (attrMapConfigMap.containsKey(sourceKey)) { |
| | | String targetKey = attrMapConfigMap.get(sourceKey); |
| | | keyValueMap.put(targetKey, StringUtils.isBlank(dataValue)?"":dataValue); |
| | | } |
| | | }); |
| | | } else { |
| | | sourceKeyValueMap.forEach((filed,value)->{ |
| | | keyValueMap.put(filed,StringUtils.isBlank(value)?"":value) ; |
| | | }); |
| | | } |
| | | |
| | | filedIndexMap.forEach((attrKey, column) -> { |
| | | String keyValue = ""; |
| | | if (keyValueMap.containsKey(attrKey)) { |
| | | keyValue =StringUtils.isBlank(keyValueMap.get(attrKey))?"":keyValueMap.get(attrKey); |
| | | } |
| | | integerValueMap.put(column, keyValue); |
| | | filedValueMap.put(attrKey, keyValue); |
| | | }); |
| | | } |
| | | rowDatas.setData(integerValueMap); |
| | | rowDatas.setFiledValue(filedValueMap); |
| | | rowDataList.add(rowDatas); |
| | | }); |
| | | dataObjectVO.setRowData(rowDataList); |
| | | }catch (Throwable e){ |
| | | throw new Throwable("组织数据映射值失败"); |
| | | } |
| | | } |
| | | private void changeObjectToMap(SearchItemDataVO searchItemDataVO, String code, BladeUser user,String operation,List<ApplyDataVO> object){ |
| | | ApplyDataVO applyDataVO=new ApplyDataVO(); |
| | | List<ProppertyVO> propList=new ArrayList<>(); |
| | | //String status= searchItemDataVO.getStatus();//数据状态 字符型,枚举值;制单:0;审批中:1;通过:2;驳回:3; |
| | | |
| | | String mmodelCode=searchItemDataVO.getMmodelcode();//制造型号代号 |
| | | initProperty("mmodelcode","",mmodelCode,propList); |
| | | String projectCode= searchItemDataVO.getProjectcode();//项目编码 |
| | | initProperty("projectcode","",projectCode,propList); |
| | | String projectItem=searchItemDataVO.getProjectitem();//项目代号 |
| | | initProperty("projectitem","",projectItem,propList); |
| | | String materialCode=searchItemDataVO.getMaterialcode();//产品编码 |
| | | initProperty("materialcode","",materialCode,propList); |
| | | //组合属性的处理 |
| | | initProperty(attrKey,"",StringUtils.isNotBlank(projectItem)?projectItem:mmodelCode,propList); |
| | | String creatBy=searchItemDataVO.getCreatby();//创建者 |
| | | Date cretaeDon= searchItemDataVO.getCreatedon();//创建日期 日期型,如:2023-09-08 19:24:11 |
| | | String lastchangeBy=searchItemDataVO.getLastchangedby();//更改者 |
| | | Date lastchangeDon=searchItemDataVO.getLastchangedon();//更改时间 日期型,如:2023-09-08 19:24:11 |
| | | String isenabled= searchItemDataVO.getIsenabled();//字符型,枚举值;停用:0;启用:1; |
| | | applyDataVO.setOperate(operation); |
| | | applyDataVO.setCode(code); |
| | | if(isenabled.equals("0")){ |
| | | applyDataVO.setStatus(CodeDefaultLC.DISABLE.getValue()); |
| | | }else{ |
| | | applyDataVO.setStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | } |
| | | applyDataVO.setId(VciBaseUtil.getPk()); |
| | | applyDataVO.setEditor(lastchangeBy); |
| | | applyDataVO.setCreator(creatBy); |
| | | applyDataVO.setProp(propList); |
| | | object.add(applyDataVO); |
| | | } |
| | | private void initProperty(String key,String text,String value,List<ProppertyVO> propList){ |
| | | ProppertyVO vo=new ProppertyVO(); |
| | | vo.setKey(key); |
| | | vo.setText(text); |
| | | vo.setValue(value); |
| | | propList.add(vo); |
| | | } |
| | | /*** |
| | | * 查询redis中数据,对比后插入dockingtask |
| | | * @param type |
| | |
| | | //表示是主数据 |
| | | CodeClassifyTemplateVO codeClassifyTemplateVO = mdmEngineServiceI.getUsedTemplateByClassifyOid(classifyoid); |
| | | R<List<Map<String, String>>> r = mdmEngineServiceI.getDataByOid(btmoid, codeClassifyTemplateVO.getOid()); |
| | | |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = codeClassifyTemplateVO.getAttributes(); |
| | | Map<String/**英文名称**/, String/**中文名称**/> attrIdNameMap = attrVOS.stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t.getName(), (o1, o2) -> o2)); |
| | | Map<String, String> data = new HashMap<>(); |
| | |
| | | } |
| | | List<NodeProDTO> nodeProDTOS = new ArrayList<>(); |
| | | Map<String, String> finalData = data; |
| | | AtomicReference<String> newItemId= new AtomicReference<>(""); |
| | | attrIdNameMap.keySet().forEach(field -> { |
| | | if(field.toLowerCase(Locale.ROOT).equals(itemId.toLowerCase(Locale.ROOT))){ |
| | | String Value = finalData.get(field); |
| | | newItemId.set(Value); |
| | | } |
| | | String outName = attrIdNameMap.get(field); |
| | | if (finalData.containsKey(field)) { |
| | | String Value = finalData.get(field); |
| | |
| | | nodeObjectDTO.setCode(code);//设置编码 |
| | | nodeObjectDTO.setClassCode(classCodeLeves[0]); |
| | | nodeObjectDTO.setStatus(data.get("lcstatus")); |
| | | nodeObjectDTO.setItemid(newItemId.get()); |
| | | nodeObjectDTO.setLibrary(classCodeLeves[classCodeLeves.length - 1]); |
| | | nodeObjectDTO.setPro(nodeProDTOS); |
| | | List<NodeObjectDTO> nodeObjectDTOS = new ArrayList<>(); |
| | |
| | | } |
| | | ResultNodeDataDTO resultNodeDataDTO=resultJsonDTO.getData(); |
| | | resultNodeObjectDTOS=resultNodeDataDTO.getObject(); |
| | | |
| | | }catch (Throwable e){ |
| | | msg="调用接口失败:"+e.getMessage(); |
| | | e.printStackTrace(); |