| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.vci.ubcs.code.vo.webserviceModel.mdm.MDMParamData; |
| | | import com.vci.ubcs.code.vo.webserviceModel.mdm.MdmResultData; |
| | | import com.vci.ubcs.code.vo.webserviceModel.person.EnumerableData; |
| | | import com.vci.ubcs.code.vo.webserviceModel.person.PersonMasterData; |
| | | import com.vci.ubcs.code.vo.webserviceModel.person.ResultMdMapping; |
| | | import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultDataObjectDetailDO; |
| | | import com.vci.ubcs.code.webService.config.AttributeMapConfig; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.xml.ws.WebServiceContext; |
| | | import javax.xml.ws.handler.MessageContext; |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.concurrent.ForkJoinPool; |
| | |
| | | // webservice请求方式获取HttpServletRequest对象 |
| | | request = (HttpServletRequest)webServiceContext.getMessageContext().get(MessageContext.SERVLET_REQUEST); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | log.error("获取httpServletRequest失败,原因:***********:",e); |
| | | throw new ServiceException("获取httpServletRequest失败,原因:"+e.getMessage()); |
| | | } |
| | | }else { |
| | |
| | | List<ResultMdMapping> resultMdMappingList=new ArrayList<>(); |
| | | String message=""; |
| | | AtomicBoolean success = new AtomicBoolean(true); |
| | | List<Map<String,String>> masterDataList = new ArrayList<>(); |
| | | List<Map<String,Object>> masterDataList = new ArrayList<>(); |
| | | AtomicReference<ClassifyConfig> currentClassifyConfig = new AtomicReference<>(new ClassifyConfig()); |
| | | try { |
| | | if (mdmParamData == null) { |
| | |
| | | throw new Throwable("用户鉴权失败"); |
| | | } |
| | | List<ClassifyConfig> classifyConfigList=mdmInterFaceConfig.getClassifyconfigs(); |
| | | //masterDataList |
| | | String masterDataStr = mdmParamData.getMasterData(); |
| | | masterDataList = JSONArray.parseObject(masterDataStr,List.class); |
| | | |
| | | if(StringUtils.isNotBlank(library)&&StringUtils.isNotBlank(classifyCode)){ |
| | | String finalLibrary = library; |
| | | classifyConfigList.stream().forEach(classifyConfig -> { |
| | |
| | | }); |
| | | masterDataList.stream().forEach(masterData -> { |
| | | masterData.forEach((field, vaule) -> { |
| | | String newValue=""; |
| | | if (fieldClassifyConfigMap.containsKey(field)) { |
| | | vaule=StringUtils.isBlank(vaule) ? "" : vaule; |
| | | //vaule=StringUtils.isBlank(vaule) ? "" : vaule; |
| | | newValue=objectToStr(vaule); |
| | | List<ClassifyConfig> classifyConfigs = fieldClassifyConfigMap.get(field); |
| | | Map<String, ClassifyConfig> classifyConfigMap = classifyConfigs.stream().filter(classify -> classify != null && StringUtils.isNotBlank(classify.getSourceClassifyCode())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getSourceClassifyCode(), t -> t)); |
| | | if (classifyConfigMap.containsKey(vaule)) { |
| | | currentClassifyConfig.set(classifyConfigMap.get(vaule)); |
| | | if (classifyConfigMap.containsKey(newValue)) { |
| | | currentClassifyConfig.set(classifyConfigMap.get(newValue)); |
| | | } |
| | | } |
| | | }); |
| | |
| | | if (com.alibaba.nacos.common.utils.StringUtils.isBlank(tableName)) { |
| | | throw new Throwable("根据业务类型未查询到业务类型相关联的表"); |
| | | } |
| | | masterDataList = mdmParamData.getMasterData(); |
| | | |
| | | List<String> codeList = new ArrayList<>(); |
| | | List<ApplyDataVO> applyDataVOList = new ArrayList<>(); |
| | | List<ApplyDataVO> deleteDataVOList = new ArrayList<>(); |
| | |
| | | /*** |
| | | * 根据配置文件获取枚举值 |
| | | */ |
| | | String newValue=objectToStr(vaule); |
| | | if(fields.contains(field)){//如果是枚举,则需要转换枚举值 |
| | | String enumFiled = masterData.get(field); |
| | | String enumFiled = newValue; |
| | | EnumerableData enumerableData = JSONObject.toJavaObject(JSONObject.parseObject(enumFiled), EnumerableData.class); |
| | | String enumCode = enumerableData.getCode(); |
| | | //String enumCodeValue=enumerableData.getName(); |
| | |
| | | }else { |
| | | ProppertyVO proppertyVO = new ProppertyVO(); |
| | | proppertyVO.setKey(field); |
| | | proppertyVO.setValue(vaule); |
| | | proppertyVO.setValue(newValue); |
| | | proppertyVOList.add(proppertyVO); |
| | | } |
| | | |
| | |
| | | String fixedField=fixedFieldMap.getOrDefault("dr",""); |
| | | dr = masterData.getOrDefault(fixedField, "").toString(); |
| | | } |
| | | object.setCode(masterData.getOrDefault(currentClassifyConfig.get().getSourceCodeKey(),"").toString());//编码 |
| | | List<String> sourceCodeKeyList=VciBaseUtil.str2List(currentClassifyConfig.get().getSourceCodeKey()); |
| | | //object.setCode(masterData.getOrDefault(currentClassifyConfig.get().getSourceCodeKey(),"").toString());//编码 |
| | | if(!CollectionUtils.isEmpty(sourceCodeKeyList)) { |
| | | sourceCodeKeyList.stream().forEach(codekey -> { |
| | | if (StringUtils.isNotBlank(masterData.getOrDefault(codekey, "").toString())) { |
| | | object.setCode(masterData.getOrDefault(codekey, "").toString());//编码 |
| | | } |
| | | }); |
| | | } |
| | | object.setProp(proppertyVOList); |
| | | |
| | | if (dr.equals(1)) { |
| | |
| | | codeList.add(object.getCode()); |
| | | |
| | | }); |
| | | if(CollectionUtils.isEmpty(codeList)){ |
| | | throw new Throwable("检查配置文件:【sourceCodeKey】,唯一标识字段是否正确"); |
| | | } |
| | | String targetCodeKey=currentClassifyConfig.get().getTargetCodeKey(); |
| | | StringBuffer sb = new StringBuffer(); |
| | | sb.append(" select * from "); |
| | |
| | | ApplyDatasVO editDatasVO = new ApplyDatasVO(); |
| | | if (!CollectionUtils.isEmpty(cboList)) { |
| | | //根据MDM编码去判断数据是否重复. |
| | | Map<String, ClientBusinessObject> oldpplyDataVOMap = cboList.stream().filter(data -> data != null && StringUtils.isNotBlank(data.getAttributeValue(targetCodeKey))).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getAttributeValue(targetCodeKey).toLowerCase(Locale.ROOT), t -> t)); |
| | | Map<String, ClientBusinessObject> oldpplyDataVOMap = cboList.stream().filter(data -> data != null && StringUtils.isNotBlank(data.getAttributeValue(targetCodeKey))).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getAttributeValue(targetCodeKey), t -> t)); |
| | | //数据库不存在的 |
| | | List<ApplyDataVO> applyApplyDataVOList = applyDataVOList.stream().filter(cbo -> { |
| | | String code = cbo.getCode(); |
| | |
| | | List<ApplyDataVO> editApplyDataVOList = applyDataVOList.stream().filter(cbo -> { |
| | | String code = cbo.getCode(); |
| | | if (oldpplyDataVOMap.containsKey(code)) { |
| | | ClientBusinessObject object= oldpplyDataVOMap.get(code); |
| | | cbo.setCode(object.getId()); |
| | | cbo.setOperate("update"); |
| | | } |
| | | return oldpplyDataVOMap.containsKey(code); |
| | |
| | | }); |
| | | }catch (Throwable e){ |
| | | mesg="计算码段码值出现异常:"+e.getMessage(); |
| | | e.printStackTrace(); |
| | | log.error("计算码段码值出现异常,原因:***********:",e); |
| | | new Throwable("计算码段码值出现异常:"+e.getMessage()); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("集成系统:【"+systemCode+"】申请编码失败:,原因:***********:",e); |
| | | mesg="集成系统:【"+systemCode+"】申请编码失败:" + e.getMessage(); |
| | | mesg = e.getMessage(); |
| | | e.printStackTrace(); |
| | | throw new ServiceException(e.getMessage()); |
| | | // throw new ServiceException(e.getMessage()); |
| | | } finally { |
| | | XMLResultDataObjectDetailDO x = new XMLResultDataObjectDetailDO(); |
| | | x.setId(rowData.getOid()); |
| | |
| | | log.info("end:申请获取完毕"); |
| | | } |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | log.error("集成系统:【"+systemCode+"】执行集成失败:",e); |
| | | success.set(false); |
| | | message = "集成系统:【"+systemCode+"】执行集成失败:" + e.getMessage(); |
| | | msg ="集成系统:【"+systemCode+"】执行集成失败" + e.getMessage(); |
| | |
| | | //记录日志 |
| | | this.saveLogs(systemCode, systemCode, data, resultStr, success.get(), msg, "syncDataForMDM"); |
| | | } catch (Throwable e) { |
| | | log.error("保存日志出错,原因:",e); |
| | | e.printStackTrace(); |
| | | } |
| | | return mdmResultData; |
| | |
| | | } |
| | | }catch (Throwable e){ |
| | | objerrorCode="100"; |
| | | log.error("获取分类信息失败:",e); |
| | | e.printStackTrace(); |
| | | throw new Throwable("获取分类信息失败:"+e.getMessage()); |
| | | } |
| | | return classifyVO; |
| | |
| | | } catch (Throwable e) { |
| | | objerrorCode = "1"; |
| | | e.printStackTrace(); |
| | | log.error("集成系统标识为:【" + systemId + "】,分类库为:【" + libray + "】的集成属性配置文件读取失败",e); |
| | | throw new Throwable("集成系统标识为:【" + systemId + "】,分类库为:【" + libray + "】的集成属性配置文件读取失败"); |
| | | } |
| | | // String path = stringStringMap.get(systemId); |
| | |
| | | String dataValue = sourceKeyValueMap.get(sourceKey); |
| | | if (attrMapConfigMap.containsKey(sourceKey)) { |
| | | String targetKey = attrMapConfigMap.get(sourceKey); |
| | | log.info("xxxxx属性映射值:sourceKey【"+sourceKey+"】——》+targetKey---》"+targetKey+":"+dataValue); |
| | | keyValueMap.put(targetKey, StringUtils.isBlank(dataValue)?"":dataValue); |
| | | } |
| | | }); |
| | |
| | | dataObjectVO.setRowData(rowDataList); |
| | | }catch (Throwable e){ |
| | | objerrorCode="1"; |
| | | throw new Throwable("组织数据映射值失败"); |
| | | e.printStackTrace(); |
| | | log.error("组织数据映射值失败",e); |
| | | throw new Throwable("组织数据映射值失败"+e); |
| | | } |
| | | } |
| | | /*private void codeValueList(List<CodeBasicSecVO> secVOList,String codeseclengthfield ){ |
| | |
| | | dockingLogeService.save(dockingLoge); |
| | | log.info("集成推送数据,systemId:"+systemId+",systemname:"+systemName+",operation:"+operation+",param:"+parmaData); |
| | | } |
| | | |
| | | /*** |
| | | * 属性类型转换 |
| | | * @param vaule |
| | | * @return |
| | | */ |
| | | private String objectToStr(Object vaule) { |
| | | String newValue=""; |
| | | if(vaule ==null||"".equals(vaule)||vaule==""){ |
| | | return ""; |
| | | } |
| | | try { |
| | | if (vaule instanceof Integer) { |
| | | Integer intValue = (Integer) vaule; |
| | | newValue = String.valueOf(intValue); |
| | | } else if (vaule instanceof Boolean) { |
| | | boolean boolValue = (Boolean) vaule; |
| | | newValue = Boolean.toString(boolValue); |
| | | } else if (vaule instanceof Timestamp) { |
| | | Timestamp timestampValue = (Timestamp) vaule; |
| | | newValue = timestamp2Str(timestampValue); |
| | | } else if (vaule instanceof Date) { |
| | | Date dataValue = (Date) vaule; |
| | | newValue = date2Str(dataValue, "yyyy-MM-dd HH:mm:ss"); |
| | | }else if (vaule instanceof BigDecimal){ |
| | | BigDecimal bigDecimal=(BigDecimal)vaule; |
| | | newValue = bigDecimal.toString(); |
| | | } else { |
| | | return vaule.toString(); |
| | | } |
| | | }catch (Throwable e){ |
| | | // log.error("属性类型转换错误",e); |
| | | e.printStackTrace(); |
| | | } |
| | | return newValue; |
| | | } |
| | | |
| | | private String date2Str(Date date, String format) { |
| | | if (null == date) { |
| | | return null; |
| | | } else { |
| | | if (format == null || format.trim().length() == 0) { |
| | | format = "yyyy-MM-dd HH:mm:ss.SSS"; |
| | | } |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat(format); |
| | | return sdf.format(date); |
| | | } |
| | | } |
| | | |
| | | private String timestamp2Str(Timestamp time) { |
| | | Date date = null; |
| | | if (null == time) { |
| | | return null; |
| | | } else { |
| | | if (null != time) { |
| | | date = new Date(time.getTime()); |
| | | } |
| | | |
| | | return date2Str(date, "yyyy-MM-dd HH:mm:ss.SSS"); |
| | | } |
| | | } |
| | | } |