From fab8208b83a3c710cdfc3805655f04f0b7466be5 Mon Sep 17 00:00:00 2001 From: xiejun <xiejun@vci-tech.com> Date: 星期三, 08 一月 2025 11:26:00 +0800 Subject: [PATCH] 产品型号集成,类型转换,人员组织加日志,申请接口引用码段值校验 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeMdmInfaceImpl.java | 895 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 895 insertions(+), 0 deletions(-) diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeMdmInfaceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeMdmInfaceImpl.java new file mode 100644 index 0000000..0708de7 --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeMdmInfaceImpl.java @@ -0,0 +1,895 @@ +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.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.entity.CodeClassify; +import com.vci.ubcs.code.entity.DockingLog; +import com.vci.ubcs.code.entity.DockingSystemConfig; +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.enumpack.sysIntegrationPushTypeEnum; +import com.vci.ubcs.code.mapper.CommonsMapper; +import com.vci.ubcs.code.service.*; +import com.vci.ubcs.code.util.ClientBusinessObject; +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.ClassfyVO; +import com.vci.ubcs.code.vo.webserviceModel.apply.ProppertyVO; +import com.vci.ubcs.code.vo.webserviceModel.attrmap.*; +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 com.vci.ubcs.code.webService.config.ClassifyConfig; +import com.vci.ubcs.code.webService.config.MDMInterFaceConfig; +import com.vci.ubcs.omd.feign.IBtmTypeClient; +import com.vci.ubcs.omd.vo.BtmTypeVO; +import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; +import com.vci.ubcs.starter.web.util.BeanUtilForVCI; +import com.vci.ubcs.starter.web.util.VciBaseUtil; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +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.stereotype.Service; +import org.springframework.util.CollectionUtils; + +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.math.BigDecimal; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +import static com.vci.ubcs.code.constant.MdmEngineConstant.CODE_SEC_LENGTH_FIELD; +import static com.vci.ubcs.code.constant.MdmEngineConstant.DEFAULT_SYNC_ATTR_LIST; +import static com.vci.ubcs.code.enumpack.CodeSecTypeEnum.CODE_SERIAL_SEC; + +/*** + * 缁熶竴鎺ュ彛 + */ +@Service +@Slf4j +public class CodeMdmInfaceImpl implements CodeMdmInfaceI { + + + @Autowired(required = false) + private AttributeMapConfig attributeMapConfig; + + /**** + * 鍏充簬璺烳DM闆嗘垚閰嶇疆 + */ + @Autowired(required = false) + private MDMInterFaceConfig mdmInterFaceConfig; + /** + * 涓婚搴撳垎绫荤殑鏈嶅姟 + */ + @Autowired(required = false) + private ICodeClassifyService classifyService; + /** + * 涓氬姟绫诲瀷鐨勬湇鍔� + */ + @Autowired + private IBtmTypeClient btmTypeClient; + /** + * 閫氱敤鏌ヨ + */ + @Resource + private CommonsMapper commonsMapper; + + /** + * 涓绘暟鎹紩鎿庣殑鏈嶅姟 + */ + @Resource + private MdmEngineService engineService; + + /** + * 瀵嗙骇鐨勬湇鍔� + */ + @Resource + private MdmIOService mdmIOService; + + @Resource + private IDockingSystemConfigService dockingSystemConfigService; + + + /*** + * 闆嗘垚鎺ュ彛鏃ュ織鏈嶅姟鐨勯厤缃� + */ + @Resource + private IDockingLogeService dockingLogeService; + + @Resource + private IPasswordFreeLoginService passwordFreeLoginService; + /*** + * 鏄惁鏍¢獙鎺ュ彛绠$悊 + */ + @Value("${code.universalinterface.checkSystemConfig:true}") + public boolean CODE_CHECKCONFIG; + + /** + * 鑷畾涔夊苟鍙慒orkJoinPool + */ + private static final ForkJoinPool customForkJoinPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors() - 1); + + private static String separator="##VCI##"; + private String errorid="0"; + private String msg="鎴愬姛"; + private String objerrorCode="0"; + private String objerrorMsg="鎴愬姛"; + + private final ThreadLocal<HttpServletRequest> threadLocal = new ThreadLocal<>(); + + @Resource + private WebServiceContext webServiceContext; + @Override + public void setThreadLocal(ThreadLocal<HttpServletRequest> requestThreadLocal){ + this.threadLocal.set(requestThreadLocal.get()); + requestThreadLocal.remove(); + } + @WebMethod + private HttpServletRequest getRequest() { + //rest璇锋眰鏂瑰紡鑾峰彇request + HttpServletRequest request = this.threadLocal.get(); + if(Func.isEmpty(request)){ + try { + // 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 { + this.threadLocal.remove(); + } + return request; + } + @Override + public MdmResultData syncDataForMDM(MDMParamData mdmParamData,String library,String classifyCode) { + boolean isCodeOrGroupCode=false; + MdmResultData mdmResultData=new MdmResultData(); + String systemCode=mdmParamData.getSystemCode(); + List<ResultMdMapping> resultMdMappingList=new ArrayList<>(); + String message=""; + AtomicBoolean success = new AtomicBoolean(true); + List<Map<String,Object>> masterDataList = new ArrayList<>(); + AtomicReference<ClassifyConfig> currentClassifyConfig = new AtomicReference<>(new ClassifyConfig()); + try { + if (mdmParamData == null) { + throw new Throwable("浼犲叆鍙傛暟涓簄ull"); + } + try { + passwordFreeLoginService.pwdFreeLoginByBoolean(systemCode.toLowerCase(), this.getRequest()); + } catch (Throwable e) { + 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 -> { + String currentClassifyCode=classifyConfig.getClassCode(); + String currentLibrary=classifyConfig.getLibrary(); + if(finalLibrary.equals(currentLibrary)&&classifyCode.equals(currentClassifyCode)){ + currentClassifyConfig.set(classifyConfig); + } + }); + }else{ + Map<String,List<ClassifyConfig>> fieldClassifyConfigMap=new HashMap<>(); + classifyConfigList.stream().forEach(classifyConfig -> { + String sourceKey=classifyConfig.getSourceKey();//鍒嗙被鏍囪瘑瀛楁 + //String sourceClassifyCode=classifyConfig.getSourceClassifyCode();//鍒嗙被鏍囪瘑 + List<ClassifyConfig> classifyConfigs = new ArrayList<>(); + if(fieldClassifyConfigMap.containsKey(sourceKey)) { + List<ClassifyConfig> oldClassifyConfigs= fieldClassifyConfigMap.get(sourceKey); + classifyConfigs.addAll(oldClassifyConfigs); + } + classifyConfigs.add(classifyConfig); + fieldClassifyConfigMap.put(sourceKey,classifyConfigs); + }); + masterDataList.stream().forEach(masterData -> { + masterData.forEach((field, vaule) -> { + String newValue=""; + if (fieldClassifyConfigMap.containsKey(field)) { + //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(newValue)) { + currentClassifyConfig.set(classifyConfigMap.get(newValue)); + } + } + }); + }); + } + library= currentClassifyConfig.get().getLibrary(); + if (StringUtils.isBlank(library)) { + success.set(false); + log.info("涓嶮DM闆嗘垚閰嶇疆缂哄皯搴撹妭鐐逛俊鎭�,library->" + library); + throw new Throwable("涓嶮DM闆嗘垚閰嶇疆缂哄皯搴撹妭鐐逛俊鎭�,library->" + library); + } + String classCode= currentClassifyConfig.get().getClassCode(); + ClassfyVO classfyVO = new ClassfyVO(); + classfyVO.setLibrary(library); + classfyVO.setClassCode(classCode); + CodeClassifyVO codeClassifyVO = this.getClassfy(classfyVO, library); + log.info("end锛氬垎绫绘煡璇㈠畬姣�"); + //鑾峰彇鍒嗙被妯℃澘淇℃伅 + if (codeClassifyVO == null || StringUtils.isBlank(codeClassifyVO.getOid())) { + success.set(false); + throw new Throwable("鏍规嵁閰嶇疆鍒嗙被鐨勫垎绫荤紪鍙凤紝鏈幏鍙栧埌鍒嗙被淇℃伅"); + } + CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(codeClassifyVO.getOid()); + if (templateVO == null || StringUtils.isBlank(templateVO.getOid())) { + success.set(false); + throw new Throwable("鏍规嵁浼犺緭鐨勫垎绫伙紝鏈幏鍙朚DM绯荤粺涓搴旀ā鏉�"); + } + if(CODE_CHECKCONFIG) { + //鏍¢獙鏄惁閰嶇疆 + DockingSystemConfig dockingSystemConfig=null; + dockingSystemConfig=checkIspass(systemCode, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_APPCODE.getValue(),codeClassifyVO.getOid()); + if(dockingSystemConfig==null||StringUtils.isBlank(dockingSystemConfig.getOid())){ + throw new Throwable("绯荤粺鏍囪瘑涓恒��"+ systemCode +"銆戯紝闆嗘垚鍒嗙被涓恒��"+codeClassifyVO.getName()+"銆戜互涓婂垎绫伙紝"+sysIntegrationPushTypeEnum.ACCPET_APPCODE.getText()+"鎺ュ彛閰嶇疆宸插仠鐢ㄦ垨鑰呮湭閰嶇疆锛岃鑱旂郴缂栫爜绠$悊鍛橈紒"); + } + isCodeOrGroupCode="true".equals(dockingSystemConfig.getIsGroupCodeFlag())?true:false; + } + 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()); + 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("鏍规嵁涓氬姟绫诲瀷鏈煡璇㈠埌涓氬姟绫诲瀷鐩稿叧鑱旂殑琛�"); + } + + List<String> codeList = new ArrayList<>(); + List<ApplyDataVO> applyDataVOList = new ArrayList<>(); + List<ApplyDataVO> deleteDataVOList = new ArrayList<>(); + List<String> fields = Func.toStrList(currentClassifyConfig.get().getEnumFields()); + masterDataList.stream().forEach(masterData -> { + ApplyDataVO object = new ApplyDataVO(); + List<ProppertyVO> proppertyVOList = new ArrayList<>(); + masterData.forEach((field, vaule) -> { + /*** + * 鏍规嵁閰嶇疆鏂囦欢鑾峰彇鏋氫妇鍊� + */ + String newValue=objectToStr(vaule); + if(fields.contains(field)){//濡傛灉鏄灇涓撅紝鍒欓渶瑕佽浆鎹㈡灇涓惧�� + String enumFiled = newValue; + EnumerableData enumerableData = JSONObject.toJavaObject(JSONObject.parseObject(enumFiled), EnumerableData.class); + String enumCode = enumerableData.getCode(); + //String enumCodeValue=enumerableData.getName(); + ProppertyVO proppertyVO = new ProppertyVO(); + proppertyVO.setKey(field); + proppertyVO.setValue(enumCode); + proppertyVOList.add(proppertyVO); + }else { + ProppertyVO proppertyVO = new ProppertyVO(); + proppertyVO.setKey(field); + proppertyVO.setValue(newValue); + proppertyVOList.add(proppertyVO); + } + + }); + + Map<String,String> fixedFieldMap = currentClassifyConfig.get().getFixedFieldMap(); + if(fixedFieldMap.containsKey("creator")){ + String fixedField=fixedFieldMap.getOrDefault("creator",""); + object.setCreator(masterData.getOrDefault(fixedField,"").toString());//鍒涘缓鑰� + } + if(fixedFieldMap.containsKey("modifier")) { + String fixedField=fixedFieldMap.getOrDefault("modifier",""); + object.setEditor(masterData.getOrDefault(fixedField, "").toString());//淇敼鑰� + } + if(fixedFieldMap.containsKey("id")) { + String fixedField=fixedFieldMap.getOrDefault("id",""); + object.setId(masterData.getOrDefault(fixedField, "").toString());//涓婚敭 + } + object.setStatus(CodeDefaultLC.RELEASED.getValue());//鐘舵�佸垯闇�瑕佸垽鏂� + String dr="0"; + if(fixedFieldMap.containsKey("dr")) { + String fixedField=fixedFieldMap.getOrDefault("dr",""); + dr = masterData.getOrDefault(fixedField, "").toString(); + } + object.setCode(masterData.getOrDefault(currentClassifyConfig.get().getSourceCodeKey(),"").toString());//缂栫爜 + object.setProp(proppertyVOList); + + if (dr.equals(1)) { + //鎿嶄綔绫诲瀷 + object.setOperate("delete"); + deleteDataVOList.add(object); + } else { + //String worker_category=personMasterData.getWorker_category(); + object.setOperate("create"); + applyDataVOList.add(object); + } + codeList.add(object.getCode()); + + }); + String targetCodeKey=currentClassifyConfig.get().getTargetCodeKey(); + 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 "+targetCodeKey+" in ("); + sb.append(VciBaseUtil.toInSql(codeList.toArray(new String[0]))); + sb.append(")"); + List<Map<String, String>> dataMapList = commonsMapper.queryByOnlySqlForMap(sb.toString()); + DefaultAttrAssimtUtil.mapToLowerCase(dataMapList, true); + List<ClientBusinessObject> cboList = ChangeMapTOClientBusinessObjects(dataMapList); + ApplyDatasVO applyDatasVO = new ApplyDatasVO(); + 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)); + //鏁版嵁搴撲笉瀛樺湪鐨� + 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(systemCode, library, editDatasVO, attrVOS, dataObjectVO); + log.info("start锛氫慨鏀规暟鎹墽琛屽畬姣�"); + //boolean personApplyGroupCode = personAndDeptConfig.isPersonApplyGroupCode(); + mdmIOService.batchSyncEditDatas(codeClassifyVO, dataObjectVO, resultDataObjectDetailDOs, isCodeOrGroupCode); + log.info("end锛氫慨鏀规暟鎹墽琛屽畬姣�"); + } + if (applyDatasVO.getObject() != null && applyDatasVO.getObject().size() > 0) { + DataObjectVO dataObjectVO = new DataObjectVO(); + this.getConfigDatas(systemCode, library, applyDatasVO, 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<>(); + final List<RowDatas> rowDatas = dataObjectVO.getRowData(); + boolean finalIsCodeOrGroupCode = isCodeOrGroupCode; + rowDatas.parallelStream().forEach(rowData -> { + String mesg = ""; + try { + CodeOrderDTO orderDTO = new CodeOrderDTO(); + List<CodeOrderSecDTO> codeOrderSecDTOList = new ArrayList<>(); + orderDTO.setCodeClassifyOid(codeClassifyVO.getOid());//鍒嗙被涓婚敭 + orderDTO.setTemplateOid(templateVO.getOid()); + orderDTO.setCreator(rowData.getCreator()); + orderDTO.setLastModifier(rowData.getEditor()); + orderDTO.setLcStatus(rowData.getStatus()); + if (!CollectionUtils.isEmpty(ruleVO.getSecVOList())) {//绠楄鍒� + boolean usedFlag=currentClassifyConfig.get().isUsedFlag();//鏄惁渚濇嵁缂栫爜瑙勫垯 + String codeFilter=currentClassifyConfig.get().getCodeFilter();//鏍规嵁缂栫爜鍊兼埅鍙� + if(usedFlag){//濡傛灉渚濇嵁MDM缂栫爜涓虹紪鐮佺郴缁熺紪鐮佺殑璇濓紝鍒欐牴鎹涓烘槸鍙彉鐮佹 + if(ruleVO.getSecVOList().size()==1) { + 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); + } + }); + }else{ + mesg="鏍规嵁閰嶇疆缂栫爜渚濇嵁闆嗘垚绯荤粺:["+systemCode+"]鐨勬暟鎹紪鐮佷负渚濇嵁锛岀紪鐮佽鍒欏簲涓哄彲鍙樼爜娈�"; + new Throwable("鏍规嵁閰嶇疆缂栫爜渚濇嵁闆嗘垚绯荤粺:["+systemCode+"]鐨勬暟鎹紪鐮佷负渚濇嵁锛岀紪鐮佽鍒欏簲涓哄彲鍙樼爜娈�"); + } + }else {//濡傛灉涓嶄緷鎹甅DM缂栫爜涓虹紪鐮佺郴缁熺紪鐮佺殑璇濓紝鍒欐牴鎹厤缃敓鎴愮紪鐮佽鍒� + String[] secValues = currentClassifyConfig.get().getSecValueFilter().split("#"); + final int[] index = {0}; + try { + ruleVO.getSecVOList().stream().forEach(codeBasicSecVO -> { + if (!CODE_SERIAL_SEC.getValue().equals(codeBasicSecVO.getSecType())) { + CodeOrderSecDTO CodeOrderSecDTO = new CodeOrderSecDTO(); + CodeOrderSecDTO.setSecOid(codeBasicSecVO.getOid()); + CodeOrderSecDTO.setSecValue(secValues[index[0]]); + codeOrderSecDTOList.add(CodeOrderSecDTO); + index[0]++; + } + }); + }catch (Throwable e){ + mesg="璁$畻鐮佹鐮佸�煎嚭鐜板紓甯�:"+e.getMessage(); + e.printStackTrace(); + log.error("璁$畻鐮佹鐮佸�煎嚭鐜板紓甯�,鍘熷洜:***********:",e); + new Throwable("璁$畻鐮佹鐮佸�煎嚭鐜板紓甯�:"+e.getMessage()); + } + } + + } + if(CollectionUtils.isEmpty(codeOrderSecDTOList)){ + throw new Exception(mesg); + } + orderDTO.setCodeRuleOid(ruleVO.getOid()); + orderDTO.setSecDTOList(codeOrderSecDTOList);//瀛樺偍缂栫爜 + orderDTO.setData(rowData.getFiledValue()); + String code = engineService.addSaveCodeNotauthUser(orderDTO, false); + if (StringUtils.isNotBlank(code)) { + StringBuffer sqlsb = new StringBuffer(); + sqlsb.append(" select * from "); + sqlsb.append(tableName); + sqlsb.append(" where 1=1 "); + sqlsb.append(" and lastr=1 and lastv=1"); + sqlsb.append(" and id in ("); + sqlsb.append(VciBaseUtil.toInSql(code)); + sqlsb.append(")"); + List<Map<String, String>> newDataMapList = commonsMapper.queryByOnlySqlForMap(sqlsb.toString()); + if (!CollectionUtils.isEmpty(newDataMapList)) { + String oid = StringUtils.isBlank(newDataMapList.get(0).get("OID")) ? "" : newDataMapList.get(0).get("OID"); + List<String> oidList = new ArrayList<>(); + oidList.add(oid); + //濡傛灉鏈夌敵璇峰氨鍘昏皟鐢ㄧ敵璇烽泦鍥㈢爜 + if (finalIsCodeOrGroupCode) { + mdmIOService.sendApplyGroupcode(oidList, templateVO.getBtmTypeId(), sysIntegrationPushTypeEnum.ACCPET_APPCODE.getValue()); + success.set(true); + mesg = "鏁版嵁淇濆瓨鎴愬姛锛岀瓑寰呯敵璇烽泦鍥㈢爜"; + } + } + } + } catch (Exception e) { + log.error("闆嗘垚绯荤粺锛氥��"+systemCode+"銆戠敵璇风紪鐮佸け璐�:锛屽師鍥�:***********:",e); + mesg="闆嗘垚绯荤粺锛氥��"+systemCode+"銆戠敵璇风紪鐮佸け璐�:" + e.getMessage(); + mesg = e.getMessage(); + e.printStackTrace(); + throw new ServiceException(e.getMessage()); + } 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.get(); + String finalMessage1 = message; + // 闄愬埗绾跨▼骞惰鏁伴噺 + customForkJoinPool.submit(() -> { + 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); + }); + }).join(); + log.info("end锛氱敵璇疯幏鍙栧畬姣�"); + } + } catch (Throwable e) { + e.printStackTrace(); + log.error("闆嗘垚绯荤粺锛氥��"+systemCode+"銆戞墽琛岄泦鎴愬け璐�:",e); + success.set(false); + message = "闆嗘垚绯荤粺锛氥��"+systemCode+"銆戞墽琛岄泦鎴愬け璐�:" + e.getMessage(); + msg ="闆嗘垚绯荤粺锛氥��"+systemCode+"銆戞墽琛岄泦鎴愬け璐�" + e.getMessage(); + //缁勭粐杩斿洖缁撴灉 + boolean finalSuccess = success.get(); + String finalMessage = message; + masterDataList.stream().forEach(masterData -> { + Map<String, String> dataMap = VciBaseUtil.objectToMapString(masterData); + ResultMdMapping resultMdMapping = new ResultMdMapping(); + resultMdMapping.setBusiDataId(dataMap.getOrDefault("id","")); + resultMdMapping.setSuccess(finalSuccess); + resultMdMapping.setEntityCode(" "); + resultMdMapping.setMdmCode(dataMap.getOrDefault(currentClassifyConfig.get(),"")); + resultMdMapping.setMessage(finalMessage); + resultMdMapping.setSubMdMappings(null); + }); + } finally { + mdmResultData.setMessage(message); + mdmResultData.setSuccess(success.get()); + mdmResultData.setMdMappings(resultMdMappingList); + //Object object = JSONObject.toJSON(resultOrgData); + } + String resultStr = JSONObject.toJSONString(mdmResultData); + String data = JSONObject.toJSONString(mdmParamData); + try { + //璁板綍鏃ュ織 + this.saveLogs(systemCode, systemCode, data, resultStr, success.get(), msg, "syncDataForMDM"); + } catch (Throwable e) { + log.error("淇濆瓨鏃ュ織鍑洪敊,鍘熷洜:",e); + e.printStackTrace(); + } + return mdmResultData; + } + private List<ClientBusinessObject> ChangeMapTOClientBusinessObjects(List<Map<String,String>> oldDataMap){ + List<ClientBusinessObject> clientBusinessObjectList=new ArrayList<>(); + DefaultAttrAssimtUtil.mapToLowerCase(oldDataMap,true); + final BladeUser user = AuthUtil.getUser(); + oldDataMap.stream().forEach(dataMap->{ + ClientBusinessObject clientBusinessObject=new ClientBusinessObject(); + DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(dataMap,clientBusinessObject,false,user); + for (String key:dataMap.keySet()){ + Object value= dataMap.getOrDefault(key,""); + clientBusinessObject.setAttributeValue(key.toLowerCase(Locale.ROOT),value==null?"":value.toString()); + } + clientBusinessObjectList.add(clientBusinessObject); + }); + return clientBusinessObjectList; + } + /*** + * 鏌ヨ鏍¢獙鍒嗙被淇℃伅 + * @param classfyVO + */ + private CodeClassifyVO getClassfy(ClassfyVO classfyVO,String libray) throws Throwable{ + CodeClassifyVO classifyVO = new CodeClassifyVO(); + try { + String classCode = classfyVO.getClassCode(); + String className = classfyVO.getFullclsfNamePath(); + //鏍规嵁鍒嗙被浠e彿鏌ヨ鍒嗙被淇℃伅 + if (StringUtils.isNotBlank(classfyVO.getClassCode())) { + Map<String, String> conditionMap = new HashMap<>(); + List<CodeClassify> codeClassifyList = classifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().eq(CodeClassify::getId, classCode)); + final CodeClassify[] newCodeClassify = {new CodeClassify()}; + if (!CollectionUtils.isEmpty(codeClassifyList)) { + codeClassifyList.stream().forEach(codeClassify -> { + CodeClassifyVO codeClassifyVO= classifyService.getTopClassifyVO(codeClassify.getOid()); + if(codeClassifyVO.getId().toUpperCase(Locale.ROOT).equals(libray.toUpperCase(Locale.ROOT))){ + newCodeClassify[0] =codeClassify; + } + }); + classifyVO = new CodeClassifyVO(); + BeanUtilForVCI.copyPropertiesIgnoreCase(newCodeClassify[0], classifyVO); + //灏咲TO杞崲涓篋O + if(StringUtils.isBlank(classifyVO.getOid())){ + throw new Throwable("鐢宠缂栫爜鐨勫垎绫伙細銆�"+classCode+"銆戜笉灞炰簬搴撹妭鐐广��"+libray+"銆戯紝璇锋鏌ュ弬鏁板垎绫昏妭鐐�/搴撹妭鐐逛俊鎭槸鍚﹀尮閰�"); + } + }else{ + throw new Throwable("鏍规嵁鍒嗙被浠e彿鏈煡璇㈠埌鐩稿簲鐨勫垎绫讳俊鎭�"); + } + } else { + classifyVO = classifyService.getObjectByClsfNamePath(className.replace(separator, "/")); + if(StringUtils.isBlank(classifyVO.getOid())){ + throw new Throwable("鏍规嵁鍒嗙被鍚嶇О璺緞鏈煡璇㈠埌鐩稿簲鐨勫垎绫讳俊鎭�"); + } + } + }catch (Throwable e){ + objerrorCode="100"; + log.error("鑾峰彇鍒嗙被淇℃伅澶辫触:",e); + e.printStackTrace(); + throw new Throwable("鑾峰彇鍒嗙被淇℃伅澶辫触:"+e.getMessage()); + } + return classifyVO; + } + 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()); + 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) { + objerrorCode = "1"; + e.printStackTrace(); + log.error("闆嗘垚绯荤粺鏍囪瘑涓猴細銆�" + systemId + "銆戯紝鍒嗙被搴撲负:銆�" + libray + "銆戠殑闆嗘垚灞炴�ч厤缃枃浠惰鍙栧け璐�",e); + throw new Throwable("闆嗘垚绯荤粺鏍囪瘑涓猴細銆�" + systemId + "銆戯紝鍒嗙被搴撲负:銆�" + libray + "銆戠殑闆嗘垚灞炴�ч厤缃枃浠惰鍙栧け璐�"); + } + // String path = stringStringMap.get(systemId); + // 蹇界暐key澶у皬鍐欙紝鑾峰彇閰嶇疆鐨勬槧灏勬枃浠惰矾寰� + String path = VciBaseUtil.getMapStrValueIgnoreCase(stringStringMap,systemId); + if (!CollectionUtils.isEmpty(libraryClsfDOList)) { + Map<String, List<ClsfAttrMappingDO>> libPropMaps = libraryClsfDOList.stream().collect(Collectors.toMap(LibraryClsfDO::getLibrary, LibraryClsfDO::getProp, (key1, key2) -> key2)); + log.info("鏍规嵁鍙傛暟锛歭ibray锛�-銆�" + libray + "浠庨厤缃枃浠朵腑鎵惧搴斿睘鎬ф槧灏勯厤缃�"); + if (libPropMaps.containsKey(libray.toUpperCase(Locale.ROOT))) { + log.info("鏍规嵁鍙傛暟锛歭ibray锛�-銆�" + 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("鏍规嵁鍙傛暟锛歭ibray锛�-銆�" + libray + "鍖归厤鍒扮浉搴旂殑灞炴�ф槧灏勪俊鎭�,灞炴�ф槧灏勬潯鐩暟+" + clsfAttrMappingDOList.size()); + } else { + objerrorCode = "1"; + throw new Throwable("鏍规嵁绯荤粺鏍囪瘑銆�" + systemId + "銆戞壘鍒板搴旂殑閰嶇疆鏂囦欢:銆�" + path + "銆戯紝浣嗘湭鑾峰彇鍒板搴旂殑搴撱��" + libray + "銆戝睘鎬ф槧灏勪俊鎭厤缃�"); + } + }else{ + objerrorCode = "1"; + throw new Throwable("鏍规嵁绯荤粺鏍囪瘑銆�" + systemId + "銆戞壘鍒板搴旂殑閰嶇疆鏂囦欢:銆�" + path + "銆戯紝浣嗘湭鑾峰彇鍒板搴旂殑搴撱��" + libray + "銆戝睘鎬ф槧灏勪俊鎭厤缃�"); + } + }else{ + objerrorCode = "1"; + throw new Throwable("鏈幏鍙栧埌闆嗘垚灞炴�ф槧灏勭郴缁熼厤缃俊鎭�"); + } + log.info("鏍规嵁鍙傛暟锛歭ibray锛�-銆�"+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){ + objerrorCode="1"; + e.printStackTrace(); + log.error("缁勭粐鏁版嵁鏄犲皠鍊煎け璐�",e); + throw new Throwable("缁勭粐鏁版嵁鏄犲皠鍊煎け璐�"+e); + } + } + /*private void codeValueList(List<CodeBasicSecVO> secVOList,String codeseclengthfield ){ + if(StringUtils.isNotBlank(codeseclengthfield)) { + + String[] secLengths = codeseclengthfield.split("#"); + for (int i = 0; i < secLengths.length; i++) { + CodeBasicSecVO secVO = secVOList.get(i); + String thisSecValue = ""; + *//*if(i == 0){ + thisSecValue = seclenghStr.contains("#")?code.substring(0,VciBaseUtil.getInt(secLengths[i])):code; + } else if(i == secLengths.length-1){ + //鏈�鍚� + thisSecValue = seclenghStr.contains("#")?code.substring(VciBaseUtil.getInt(secLengths[i-1]),code.length()):code; + }else {*//* + int start = 0; + for (int j = 0; j < i; j++) { + start += VciBaseUtil.getInt(secLengths[j]); + } + thisSecValue = code.substring(start, start + VciBaseUtil.getInt(secLengths[i])); + // } + if (VciBaseUtil.getBoolean(secVO.getSerialDependFlag())) { + serialUnitList.add(thisSecValue); + serialSecOidIndexMap.put(secVO.getOid(), i); + } + if (CODE_SERIAL_SEC.getValue().equalsIgnoreCase(secVO.getSecType())) { + serialValueMap.put(secVO.getOid(), thisSecValue); + } + codeValueList.add(thisSecValue); + } + }else{ + + } + }*/ + /*** + * 鏍¢獙鏄惁鍋氫簡閰嶇疆 + * @param systemId,绯荤粺鏍囪瘑 + * @param type:鎺ュ彛绫诲瀷 + * @param operationType:鎺ュ彛鎿嶄綔绫诲瀷 + * @return + */ + private DockingSystemConfig checkIspass(String systemId,String type,String operationType,String classOid){ + log.info("systemId锛�"+systemId+",type:"+SysIntegrationDataFlowTypeEnum.getTextByValue(type)+",operationType:"+sysIntegrationPushTypeEnum.getTextByValue(operationType)+",classOid:"+classOid); + //CodeClassifyVO codeClassifyVO= classifyService.getObjectByOid(classOid); + List<CodeClassify> codeClassifyList= classifyService.selectAllLevelParentByOid(classOid); + List<String> classifyOids=new ArrayList<>(); + if(!CollectionUtils.isEmpty(codeClassifyList)) { + classifyOids = codeClassifyList.stream().map(CodeClassify::getOid).collect(Collectors.toList()); + }else{ + return null; + } + //classOid=codeClassifyVO.getOid(); + //鏍规嵁绫诲瀷鍘绘煡璇㈤渶瑕侀泦鎴愮殑鍒嗙被鎴栬�呮暟鎹� + LambdaQueryWrapper<DockingSystemConfig> queryWrapper = Wrappers.<DockingSystemConfig>lambdaQuery(); + queryWrapper.eq(DockingSystemConfig::getUsedFlag, MdmDuckingConstant.SEND_FLAG_TRUE); + queryWrapper.eq(DockingSystemConfig::getSysBaseId,systemId); + queryWrapper.eq(DockingSystemConfig::getDataFlowType,type); + queryWrapper.eq(DockingSystemConfig::getPushType,operationType); + if(StringUtils.isNotBlank(classOid)){ + queryWrapper.in(DockingSystemConfig::getClassifyOid,classifyOids); + } + List<DockingSystemConfig> dockingSystemConfigList=new ArrayList<>(); + dockingSystemConfigList= dockingSystemConfigList=dockingSystemConfigService.list(queryWrapper); + if(!CollectionUtils.isEmpty(dockingSystemConfigList)){ + return dockingSystemConfigList.get(0); + }else{ + return null; + } + } + /*** + * 璁板綍鏃ュ織淇℃伅 + * @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); + } + + /*** + * 灞炴�х被鍨嬭浆鎹� + * @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"); + } + } +} -- Gitblit v1.9.3