| | |
| | | |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.shaded.com.google.protobuf.ServiceException; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.thoughtworks.xstream.XStream; |
| | | import com.thoughtworks.xstream.io.xml.DomDriver; |
| | | 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.classify.NodeLibraryDTO; |
| | | import com.vci.ubcs.code.dto.datapush.data.NodeJosnDTO; |
| | | import com.vci.ubcs.code.dto.datapush.data.NodeObjectDTO; |
| | | import com.vci.ubcs.code.dto.datapush.data.NodeProDTO; |
| | | import com.vci.ubcs.code.dto.datapush.data.NodedataDTO; |
| | | import com.vci.ubcs.code.dto.datapush.result.ResultJsonDTO; |
| | | 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.mapper.CommonsMapper; |
| | | import com.vci.ubcs.code.service.*; |
| | | import com.vci.ubcs.starter.web.constant.QueryOptionConstant; |
| | | 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.attrmap.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultDataObjectDetailDO; |
| | | import com.vci.ubcs.code.webService.config.AttributeMapConfig; |
| | | import com.vci.ubcs.omd.cache.EnumCache; |
| | | 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.starter.web.enumpck.UserSecretEnum; |
| | | import com.vci.ubcs.starter.web.pagemodel.SessionInfo; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.VciQueryWrapperForDO; |
| | | import com.vci.ubcs.starter.web.util.WebUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.map.CaseInsensitiveMap; |
| | | 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.http.HttpMethod; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.mock.web.MockHttpServletRequest; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | 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.servlet.http.HttpServletRequest; |
| | | 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; |
| | | |
| | | |
| | | /* |
| | | * 主题库集成服务 |
| | | * @author xiejun |
| | | * @date 2023-06-19 |
| | | **/ |
| | | **/ |
| | | |
| | | @Service |
| | | @Slf4j |
| | | 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.itemStatus:2}") |
| | | public String itemStatus; |
| | | |
| | | @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; |
| | | |
| | | @Value("${erp.item.bearer:bearer: Bearer 7fc32939-0a59-da71-a6e6-6b0d37b53e8a}") |
| | | private String ERPXHDHAUTH; |
| | | |
| | | @Value("${erp.item.url:http://127.0.0.1/api/pp/pp/ext/extend/v1.0}") |
| | | private String ERPXHDHURL; |
| | | |
| | | @Value("${erp.item.tenant:10000}") |
| | | private String ERPXHDHTENANT; |
| | | |
| | | /** |
| | | * 业务类型的服务 |
| | | */ |
| | | @Autowired |
| | | private IBtmTypeClient btmTypeClient; |
| | | |
| | | /** |
| | | * 通用查询 |
| | | */ |
| | | @Resource |
| | | private IDockingSystemService dockingSystemService; |
| | | private CommonsMapper commonsMapper; |
| | | |
| | | @Resource |
| | | private MdmEngineService mdmEngineServiceI; |
| | | |
| | | /** |
| | | * 批量处理的服务 |
| | | */ |
| | | @Resource |
| | | private MdmIOService mdmIOService; |
| | | |
| | | @Resource |
| | | private IPasswordFreeLoginService passwordFreeLoginService; |
| | | |
| | | @Resource |
| | | private IDockingLogeService dockingLogeService; |
| | | |
| | | @Resource |
| | | private IDockingDataService dockingDataService; |
| | | |
| | | @Resource |
| | | private IDockingTaskService dockingTaskService; |
| | | |
| | | @Resource |
| | | private IDockingSystemConfigService dockingSystemConfigService; |
| | | |
| | | @Resource |
| | | private ICodeClassifyService codeClassifyService; |
| | | |
| | | @Autowired |
| | | private ICodeClassifyValueService codeClassifyValueService; |
| | | |
| | | @Autowired(required = false) |
| | | private AttributeMapConfig attributeMapConfig; |
| | | |
| | | /*** |
| | | * resdis缓存服务 |
| | | */ |
| | | //@Resource |
| | | //private BladeRedis bladeRedis; |
| | | |
| | | @Resource |
| | | private IDockingSysIntParamService dockingSysIntParamService; |
| | | |
| | | @Resource |
| | | private IDockingSysIntHeaderService dockingSysIntHeaderService; |
| | | |
| | | //@Autowired(required = false) |
| | | //private MdmSearchItemCodeProvider mdmSearchItemCodeProvider; |
| | | |
| | | @Resource |
| | | private ICodeAllCodeService codeAllCodeService; |
| | | |
| | | @Override |
| | | public void DockingDataSyncScheduing() { |
| | | |
| | | // insertCache2(); |
| | | // insertCache2(); |
| | | initPushDataTaks(1); |
| | | //sendpushDataForService(); |
| | | |
| | | sendpushDataForService(); |
| | | } |
| | | |
| | | /*** |
| | | * |
| | | */ |
| | | @Override |
| | | public void DockingClassSyncScheduing() { |
| | | |
| | | initPushDataTaks(2);//分类推送 |
| | | sendpushClsfForService(); |
| | | } |
| | | |
| | | /*** |
| | | * 手动同步 |
| | | * @param oids |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | @Override |
| | | public R sendData(String oids) { |
| | | |
| | | |
| | | |
| | | return null; |
| | | VciBaseUtil.alertNotNull(oids, "系统集成基础信息数据对象", oids, "系统集成基础信息的主键"); |
| | | List<String> dockingTaskOidList = new ArrayList<>(); |
| | | dockingTaskOidList = VciBaseUtil.str2List(oids); |
| | | List<DockingTask> newDockingTasks = this.dockingTaskService.listByIds(dockingTaskOidList); |
| | | Map<String, List<DockingTask>> typeDockingTaskMap = new HashMap<>(); |
| | | newDockingTasks.stream().forEach(newDockingTaskDO -> { |
| | | String btmId = newDockingTaskDO.getBtmId(); |
| | | if (btmId.equalsIgnoreCase(DOCKING_DEFAULT_CLASSIFY.toLowerCase(Locale.ROOT))) { |
| | | List<DockingTask> dockingTaskList = typeDockingTaskMap.get(DOCKING_DEFAULT_CLASSIFY.toLowerCase(Locale.ROOT)); |
| | | if (CollectionUtils.isEmpty(dockingTaskList)) { |
| | | dockingTaskList = new ArrayList<>(); |
| | | } |
| | | dockingTaskList.add(newDockingTaskDO); |
| | | typeDockingTaskMap.put(DOCKING_DEFAULT_CLASSIFY.toLowerCase(Locale.ROOT), dockingTaskList); |
| | | } else { |
| | | List<DockingTask> dockingTaskDOList = typeDockingTaskMap.get("data"); |
| | | if (CollectionUtils.isEmpty(dockingTaskDOList)) { |
| | | dockingTaskDOList = new ArrayList<>(); |
| | | } |
| | | dockingTaskDOList.add(newDockingTaskDO); |
| | | typeDockingTaskMap.put("data", dockingTaskDOList); |
| | | } |
| | | }); |
| | | typeDockingTaskMap.keySet().forEach(type -> { |
| | | List<DockingTask> DockingTaskList = typeDockingTaskMap.get(type); |
| | | if (!CollectionUtils.isEmpty(DockingTaskList)) { |
| | | if (type.equalsIgnoreCase(DOCKING_DEFAULT_CLASSIFY.toLowerCase(Locale.ROOT))) { |
| | | this.sendpushClsfForService(DockingTaskList); |
| | | } else { |
| | | this.sendpushDataForService(DockingTaskList); |
| | | } |
| | | } |
| | | }); |
| | | 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(); |
| | | } |
| | | org.springblade.core.tool.utils.WebUtil.setRequest(new ServletRequestAttributes(request)); |
| | | } |
| | | return request; |
| | | } |
| | | |
| | | /*** |
| | | * 同步型号代号 |
| | | */ |
| | | @Override |
| | | public void saveItemDataSyncScheduing(String endDate) throws ServiceException { |
| | | 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("查询时间------->" + dft.format(new Date())); |
| | | lastchangedon = dft.format(calendar.getTime()); |
| | | } else { |
| | | lastchangedon = endDate; |
| | | } |
| | | searchItemParam.setLastchangedon(lastchangedon); |
| | | searchItemParam.setIsenabled(""); |
| | | searchItemParam.setStatus(itemStatus); |
| | | //Map<String,String> searchDataMap = VciBaseUtil.objectToMapString(searchItemParam); |
| | | try { |
| | | String sendParamString = JSONObject.toJSON(searchItemParam).toString(); |
| | | // TODO: 改为使用HttpUtils方式进行申请,因为现在申请用之前的方式会报错 |
| | | LinkedMultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); |
| | | headers.add("Authorization", ERPXHDHAUTH); |
| | | headers.add("X-ECC-Current-Tenant", ERPXHDHTENANT); |
| | | headers.add("Accept-Language", "zh-CHS"); |
| | | headers.add("Content-Type", MediaType.APPLICATION_JSON.toString()); |
| | | String res = HttpUtils.request(ERPXHDHURL + "/getppModelByElemNew", sendParamString, headers, HttpMethod.POST, MediaType.APPLICATION_JSON); |
| | | // String res= mdmSearchItemCodeProvider.getppModelByElem(searchItemParam); |
| | | SearchItemVO searchItemVO = JSONObject.toJavaObject(JSONObject.parseObject(res), SearchItemVO.class); |
| | | if (searchItemVO != null) { |
| | | if (!"200".equals(searchItemVO.getStatus())) { |
| | | throw new ServiceException(String.format("接口返回状态码为:%s,原因:%s", searchItemVO.getStatus(), searchItemVO.getMessage())); |
| | | } |
| | | BladeUser finalUser; |
| | | paramString = JSONObject.toJSON(searchItemVO).toString(); |
| | | log.info("型号代号数据值-------》" + paramString); |
| | | HttpServletRequest request = getRequest(); |
| | | try { |
| | | //免密登录申请token,request中添加用户信息 |
| | | try { |
| | | passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(Locale.ROOT), request); |
| | | BladeUser user = AuthUtil.getUser(); |
| | | if (Func.isEmpty(user)) { |
| | | user = request.getAttribute("_BLADE_USER_REQUEST_ATTR_") == null ? null : (BladeUser) request.getAttribute("_BLADE_USER_REQUEST_ATTR_"); |
| | | } |
| | | finalUser = user; |
| | | } catch (Throwable e) { |
| | | throw new Throwable("用户鉴权失败."); |
| | | } |
| | | 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<SearchItemUpperCaseDataVO> dataList = searchItemVO.getData(); |
| | | Map<String, SearchItemUpperCaseDataVO> dataVOMap = new HashMap<>(); |
| | | List<String> itemCodeList = new ArrayList<>(); |
| | | ApplyDatasVO allDatasVO = new ApplyDatasVO(); |
| | | List<ApplyDataVO> allObjectList = new ArrayList<>(); |
| | | if (Func.isNotEmpty(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<>(); |
| | | if (!CollectionUtils.isEmpty(newDataList)) { |
| | | newDataList.stream().forEach(dataMap -> { |
| | | BaseModel baseModel = new BaseModel(); |
| | | Map<String, String> newDateMap = new CaseInsensitiveMap<>(dataMap); |
| | | DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(newDateMap, baseModel, true, finalUser); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(baseModel, finalUser); |
| | | //baseModelList.add(baseModel); |
| | | String attrKeyValue = newDateMap.getOrDefault(attrKey, ""); |
| | | if (StringUtils.isBlank(attrKeyValue)) { |
| | | log.info(baseModel.getId()); |
| | | } |
| | | 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(), finalUser, "editstatus", editObjectList); |
| | | } else { |
| | | changeObjectToMap(value, "", finalUser, "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()); |
| | | } |
| | | } |
| | | } else { |
| | | throw new Throwable("接口未返回信息"); |
| | | } |
| | | } catch (Throwable e1) { |
| | | e1.printStackTrace(); |
| | | log.error("查询失败--->" + e1); |
| | | //paramString=""; |
| | | success = false; |
| | | backString = "查询失败--->" + e1; |
| | | msg = "查询失败--->" + e1; |
| | | try { |
| | | //记录日志 |
| | | this.saveLogs(systemId, systemId, paramString, backString, success, msg, "queryData"); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | log.error(e.getMessage()); |
| | | throw new ServiceException(e.getMessage()); |
| | | } |
| | | throw new ServiceException(e1.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()); |
| | | }); |
| | | List<CodeOrderSecDTO> codeOrderSecDTOList = new ArrayList<>(); |
| | | Map<String, String> errorMap = new HashMap<>(); |
| | | String nullSymbol = EnumCache.getValue("nullSymbol", "NULL"); |
| | | nullSymbol = Func.isBlank(nullSymbol) ? "#NaN?":nullSymbol; |
| | | 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) || nullSymbol.equals(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)&&!name.equals(secName)) { |
| | | 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(SearchItemUpperCaseDataVO 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); |
| | | |
| | | Date cretaeDon = searchItemDataVO.getCREATEDON();//创建日期 日期型,如:2023-09-08 19:24:11 |
| | | initProperty("cretaedon", "", Func.formatDateTime(cretaeDon), propList); |
| | | Date lastchangeDon = searchItemDataVO.getLASTCHANGEDON();//更改时间 日期型,如:2023-09-08 19:24:11 |
| | | initProperty("lastchangedon", "", Func.formatDateTime(lastchangeDon), 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(StringUtils.isBlank(text) ? "" : text); |
| | | vo.setValue(StringUtils.isBlank(value) ? "" : value); |
| | | propList.add(vo); |
| | | } |
| | | |
| | | /*** |
| | | * 查询redis中数据,对比后插入dockingtask |
| | | * @param type |
| | | */ |
| | | private void initPushDataTaks(int type){ |
| | | //initSysadmin(); |
| | | |
| | | private void initPushDataTaks(int type) { |
| | | initSysadmin(); |
| | | List<DockingSystemConfig> dockingSystemConfigList = dockingSystemConfigService.list( |
| | | Wrappers.<DockingSystemConfig>query().lambda().eq(DockingSystemConfig::getUsedFlag,"true") |
| | | .eq(DockingSystemConfig::getPushType,type==2?"2":"1"));//2是代表分类推送,1是代表数据推送 |
| | | Wrappers.<DockingSystemConfig>query().lambda().eq(DockingSystemConfig::getUsedFlag, "true") |
| | | .eq(DockingSystemConfig::getPushType, type == 2 ? "2" : "1").eq(DockingSystemConfig::getDataFlowType, SysIntegrationDataFlowTypeEnum.PUSH.getValue()));//2是代表分类推送,1是代表数据推送 |
| | | |
| | | if(CollectionUtils.isEmpty(dockingSystemConfigList)){ |
| | | String title=type==2?"分类推送":"数据推送"; |
| | | log.info("info->所有集成系统,未查询到相关的【"+title+"】的接口配置信息,配置"); |
| | | if (CollectionUtils.isEmpty(dockingSystemConfigList)) { |
| | | String title = type == 2 ? "分类推送" : "数据推送"; |
| | | log.info("info->所有集成系统,未查询到相关的【" + title + "】的接口配置信息,配置"); |
| | | return; |
| | | } |
| | | Map<String ,List<DockingSystemConfig>> sysIntInfoDOMap = new HashMap<>();//key=classifyoid,value=list<map> |
| | | for (DockingSystemConfig dockingSystemConfig:dockingSystemConfigList){ |
| | | List<DockingSystemConfig> dockingSystemList = sysIntInfoDOMap.get(dockingSystemConfig.getClassifyOid()); |
| | | if(dockingSystemList==null){ |
| | | dockingSystemList = new ArrayList<>(); |
| | | } |
| | | dockingSystemList.add(dockingSystemConfig); |
| | | sysIntInfoDOMap.put(dockingSystemConfig.getClassifyOid(),dockingSystemList); |
| | | } |
| | | //根据类型去查询需要集成的分类或者数据 |
| | | LambdaQueryWrapper<DockingData> queryWrapper = Wrappers.<DockingData>lambdaQuery(); |
| | | queryWrapper.eq(DockingData::getSendFlag,"false"); |
| | | if(type==2){ |
| | | queryWrapper.eq(DockingData::getBtmId,DOCKING_DEFAULT_CLASSIFY.toLowerCase(Locale.ROOT)); |
| | | }else { |
| | | queryWrapper.notIn(DockingData::getBtmId,DOCKING_DEFAULT_CLASSIFY.toLowerCase(Locale.ROOT)); |
| | | } |
| | | List<DockingData> dataList = dockingDataService.list(queryWrapper); |
| | | |
| | | for (DockingData mapi:dataList){ |
| | | WebUtil.setPersistence(false); |
| | | String dataoid = mapi.getOid();//data对象的oid |
| | | String classifyoid = mapi.getClassifyOid(); |
| | | String id = mapi.getId(); |
| | | String uniquecode = mapi.getUniqueCode(); |
| | | String btmid = mapi.getBtmId(); |
| | | String btmoid = mapi.getBtmOid(); |
| | | String sendtype = mapi.getSendType(); |
| | | String classifyid = mapi.getClassifyId(); |
| | | String classifyname = mapi.getClassifyName(); |
| | | String curentClassOid=null; |
| | | if(type==2){ |
| | | curentClassOid=btmoid; |
| | | }else{ |
| | | curentClassOid=classifyoid; |
| | | } |
| | | List<DockingSystemConfig> effectiveSysIntInfoVOs=new ArrayList<>(); |
| | | //根据当前数据的id,查询获取哪些系统需要做集成 |
| | | List<CodeClassify> parentLeveDO= codeClassifyService.selectAllLevelParentByOid(curentClassOid); |
| | | if(CollectionUtils.isEmpty(parentLeveDO)){ |
| | | continue;//说明这个分类被删掉了,不做处理 |
| | | } |
| | | Map<String, CodeClassify> oidCodeclassifyDOMap = parentLeveDO.stream().filter(codeClassifyDO -> codeClassifyDO != null && StringUtils.isNotBlank(codeClassifyDO.getOid())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | |
| | | oidCodeclassifyDOMap.keySet().forEach(oid->{ |
| | | if(sysIntInfoDOMap.containsKey(oid)){ |
| | | List<DockingSystemConfig> sysIntInfoDOS= sysIntInfoDOMap.get(oid); |
| | | effectiveSysIntInfoVOs.addAll(sysIntInfoDOS); |
| | | Map<String, List<DockingSystemConfig>> sysIntInfoDOMap = new HashMap<>();//key=classifyoid,value=list<map> |
| | | for (DockingSystemConfig dockingSystemConfig : dockingSystemConfigList) { |
| | | String classifyOid = dockingSystemConfig.getClassifyOid(); |
| | | String codeclassifOid = codeClassifyService.selectLeafByPid(classifyOid); |
| | | List<String> codeList = VciBaseUtil.str2List(codeclassifOid); |
| | | codeList.stream().forEach(oid -> { |
| | | List<DockingSystemConfig> dockingSystemList = sysIntInfoDOMap.get(oid); |
| | | if (Func.isEmpty(dockingSystemList)) { |
| | | dockingSystemList = new ArrayList<>(); |
| | | } |
| | | dockingSystemList.add(dockingSystemConfig); |
| | | sysIntInfoDOMap.put(oid, dockingSystemList); |
| | | }); |
| | | //如果校验的系统接口信息不存在,则数据不不往信息里推送 |
| | | if(CollectionUtils.isEmpty(effectiveSysIntInfoVOs)){ |
| | | continue; |
| | | } |
| | | sysIntInfoDOMap.forEach((classifyOid, effectiveSysIntInfoVOs) -> { |
| | | //根据类型去查询需要集成的分类或者数据 |
| | | LambdaQueryWrapper<DockingData> queryWrapper = Wrappers.<DockingData>lambdaQuery(); |
| | | queryWrapper.eq(DockingData::getSendFlag, "false"); |
| | | if (type == 2) { |
| | | queryWrapper.eq(DockingData::getBtmId, DOCKING_DEFAULT_CLASSIFY); |
| | | } else { |
| | | queryWrapper.ne(DockingData::getBtmId, DOCKING_DEFAULT_CLASSIFY); |
| | | queryWrapper.eq(DockingData::getClassifyOid, classifyOid); |
| | | } |
| | | List<DockingTask> dockingTask_insert = new ArrayList<>(); |
| | | for (DockingSystemConfig sysIntInfoVOi:effectiveSysIntInfoVOs){ |
| | | DockingTask dockingTask = new DockingTask(); |
| | | dockingTask.setOid(VciBaseUtil.getPk()); |
| | | dockingTask.setSendFlag(SEND_FLAG_FALSE); |
| | | dockingTask.setId(id);//编码 |
| | | dockingTask.setUniqueCode(uniquecode); |
| | | dockingTask.setBtmOid(btmoid);//数据oid |
| | | dockingTask.setBtmId(btmid);//数据业务类型id |
| | | dockingTask.setClassifyId(classifyid);//数据在分类id |
| | | dockingTask.setClassifyOid(classifyoid);//数据所在分类oid |
| | | dockingTask.setClassifyName(classifyname);//数据所在分类名称 |
| | | dockingTask.setSendType(sendtype);//数据推送类型 |
| | | dockingTask.setDataOid(dataoid); |
| | | List<DockingData> dataList = dockingDataService.list(queryWrapper); |
| | | for (DockingData mapi : dataList) { |
| | | WebUtil.setPersistence(false); |
| | | String dataoid = mapi.getOid();//data对象的oid |
| | | String dataClassifyOid = mapi.getClassifyOid(); |
| | | String id = mapi.getId(); |
| | | String uniquecode = mapi.getUniqueCode(); |
| | | String btmid = mapi.getBtmId(); |
| | | String btmoid = mapi.getBtmOid(); |
| | | String sendtype = mapi.getSendType(); |
| | | String classifyid = mapi.getClassifyId(); |
| | | String classifyname = mapi.getClassifyName(); |
| | | String curentClassOid = null; |
| | | if (!dataClassifyOid.equals(classifyOid)) { |
| | | continue; |
| | | } |
| | | /*if(type==2){ |
| | | curentClassOid=btmoid; |
| | | }else{ |
| | | curentClassOid=classifyoid; |
| | | }*/ |
| | | /*//根据当前数据的id,查询获取哪些系统需要做集成 |
| | | List<CodeClassify> parentLeveDO= codeClassifyService.selectAllLevelParentByOid(curentClassOid); |
| | | if(CollectionUtils.isEmpty(parentLeveDO)){ |
| | | continue;//说明这个分类被删掉了,不做处理 |
| | | } |
| | | Map<String, CodeClassify> oidCodeclassifyDOMap = parentLeveDO.stream().filter(codeClassifyDO -> codeClassifyDO != null && StringUtils.isNotBlank(codeClassifyDO.getOid())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | |
| | | //intinfo |
| | | dockingTask.setSysInfoOid(sysIntInfoVOi.getOid());//intinfo的oid |
| | | dockingTask.setSystemOid(sysIntInfoVOi.getSysBaseOid());//系统oid |
| | | dockingTask.setSystemCode(sysIntInfoVOi.getSysBaseId());//系统编码 |
| | | dockingTask.setSystemName(sysIntInfoVOi.getSysBaseName());//系统name |
| | | dockingTask_insert.add(dockingTask); |
| | | } |
| | | oidCodeclassifyDOMap.keySet().forEach(oid->{ |
| | | if(sysIntInfoDOMap.containsKey(oid)){ |
| | | List<DockingSystemConfig> sysIntInfoDOS= sysIntInfoDOMap.get(oid); |
| | | effectiveSysIntInfoVOs.addAll(sysIntInfoDOS); |
| | | } |
| | | }); |
| | | //如果校验的系统接口信息不存在,则数据不不往信息里推送 |
| | | if(CollectionUtils.isEmpty(effectiveSysIntInfoVOs)){ |
| | | continue; |
| | | }*/ |
| | | List<DockingTask> dockingTask_insert = new ArrayList<>(); |
| | | for (DockingSystemConfig sysIntInfoVOi : effectiveSysIntInfoVOs) { |
| | | DockingTask dockingTask = new DockingTask(); |
| | | dockingTask.setOid(VciBaseUtil.getPk()); |
| | | dockingTask.setSendFlag(SEND_FLAG_FALSE); |
| | | dockingTask.setId(id);//编码 |
| | | dockingTask.setUniqueCode(uniquecode); |
| | | dockingTask.setBtmOid(btmoid);//数据oid |
| | | dockingTask.setBtmId(btmid);//数据业务类型id |
| | | dockingTask.setClassifyId(classifyid);//数据在分类id |
| | | dockingTask.setClassifyOid(dataClassifyOid);//数据所在分类oid |
| | | dockingTask.setClassifyName(classifyname);//数据所在分类名称 |
| | | dockingTask.setSendType(sendtype);//数据推送类型 |
| | | dockingTask.setDataOid(dataoid); |
| | | dockingTask.setCreateTime(new Date()); |
| | | dockingTask.setLastModifyTime(new Date()); |
| | | dockingTask.setCreator("sysAdmin"); |
| | | dockingTask.setLastModifier("sysAdmin"); |
| | | //intinfo |
| | | dockingTask.setSysInfoOid(sysIntInfoVOi.getOid());//intinfo的oid |
| | | dockingTask.setSystemOid(sysIntInfoVOi.getSysBaseOid());//系统oid |
| | | dockingTask.setSystemCode(sysIntInfoVOi.getSysBaseId());//系统编码 |
| | | dockingTask.setSystemName(sysIntInfoVOi.getSysBaseName());//系统name |
| | | dockingTask_insert.add(dockingTask); |
| | | } |
| | | |
| | | if(dockingTask_insert.size()!=0) { |
| | | dockingTaskService.saveBatch(dockingTask_insert); |
| | | if (dockingTask_insert.size() != 0) { |
| | | dockingTaskService.saveBatch(dockingTask_insert); |
| | | } |
| | | //dockingTaskDaoI.updateByPrimaryKey方法报错了,所以手写了这个 |
| | | boolean u = updateDockingDatasSendFlag(dataoid, SEND_FLAG_TRUE); |
| | | if (!u) { |
| | | log.error("集成data分解任务失败!dataoid:" + dataoid); |
| | | continue; |
| | | } |
| | | } |
| | | //dockingTaskDaoI.updateByPrimaryKey方法报错了,所以手写了这个 |
| | | boolean u = updateDockingDatasSendFlag(dataoid,SEND_FLAG_TRUE); |
| | | if(!u){ |
| | | log.error("集成data分解任务失败!dataoid:"+dataoid); |
| | | continue; |
| | | }); |
| | | |
| | | } |
| | | |
| | | /*** |
| | | * 发送分类数据 |
| | | */ |
| | | private void sendpushClsfForService(List<DockingTask> dockingTaskList) { |
| | | //每个task依次执行推送 |
| | | for (DockingTask dockingTask : dockingTaskList) { |
| | | //每个task一个事务,开启 |
| | | String paramString = ""; |
| | | Object sendString = ""; |
| | | String backString = ""; |
| | | //查询系统接口信息,ip method,dataType |
| | | String systeminfooid = dockingTask.getSysInfoOid();//sysininfo 的oid |
| | | try { |
| | | //查询要推送的数据 |
| | | String btmoid = dockingTask.getBtmOid();//数据btmid |
| | | JsonRootDataDTO jsonRootDataDTO = new JsonRootDataDTO(); |
| | | CodeClassify codeClassify = codeClassifyService.getById(btmoid); |
| | | List<NodeClassifyDTO> nodeClassifyDTOList = new ArrayList<>(); |
| | | NodeClassifyDTO nodeClassifyDTO = new NodeClassifyDTO(); |
| | | nodeClassifyDTO.setClassCode(codeClassify.getId());//分类代号 |
| | | nodeClassifyDTO.setDescription(codeClassify.getDescription());//分类描述 |
| | | nodeClassifyDTO.setFullPathName(codeClassify.getPath());//全路径 |
| | | nodeClassifyDTO.setLcStatus(codeClassify.getLcStatus());//状态 |
| | | // CodeClassifyDO parentClassDo=codeClassifyDaoI.selectByPrimaryKey(codeClassifyDO.getParentCodeClassifyOid()); |
| | | nodeClassifyDTO.setPid(codeClassify.getParentCodeClassifyOid());//父id节点 |
| | | nodeClassifyDTO.setId(codeClassify.getOid());//分类oid |
| | | nodeClassifyDTO.setName(codeClassify.getName());//分类名称 |
| | | nodeClassifyDTOList.add(nodeClassifyDTO); |
| | | NodeLibraryDTO nodeLibraryDTO = new NodeLibraryDTO(); |
| | | CodeClassifyVO rootClassify = codeClassifyService.getTopClassifyVO(btmoid); |
| | | nodeLibraryDTO.setClassify(nodeClassifyDTOList); |
| | | nodeLibraryDTO.setId(rootClassify.getOid()); |
| | | nodeLibraryDTO.setName(rootClassify.getName()); |
| | | nodeLibraryDTO.setClassCode(rootClassify.getId()); |
| | | NodeDataDTO nodeDataDTO = new NodeDataDTO(); |
| | | nodeDataDTO.setLibrary(nodeLibraryDTO); |
| | | jsonRootDataDTO.setData(nodeDataDTO); |
| | | |
| | | //查询推送接口参数 |
| | | DockingSystemConfig dockingSystemConfig = dockingSystemConfigService.getById(systeminfooid); |
| | | String paramType = dockingSystemConfig.getParamType();//xml/json |
| | | if (paramType.equals(DATATYPE_JSON)) { |
| | | Object object = JSONObject.toJSON(jsonRootDataDTO); |
| | | sendString = object; |
| | | } else { |
| | | //组织返回接口信息 |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(NodeDataDTO.class); |
| | | xStream.autodetectAnnotations(true); |
| | | sendString = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + xStream.toXML(nodeDataDTO); |
| | | } |
| | | //调用接口 |
| | | callInterface(sendString, dockingSystemConfig, dockingTask, "pushClassifyData"); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | //每一个task一个事物 |
| | | } |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * 发送编码主数据 |
| | | */ |
| | | private void sendpushDataForService(List<DockingTask> dockingTaskS) { |
| | | //每个task依次执行推送 |
| | | for (DockingTask dockingTask : dockingTaskS) { |
| | | //每个task一个事务,开启 |
| | | String paramString = ""; |
| | | Object sendString = ""; |
| | | String backString = ""; |
| | | try { |
| | | //查询系统接口信息,ip method,dataType |
| | | String systeminfooid = dockingTask.getSysInfoOid();//sysininfo 的oid |
| | | String classifyoid = dockingTask.getClassifyOid(); |
| | | //查询要推送的数据 |
| | | String btmoid = dockingTask.getBtmOid();//数据btmid |
| | | String code = dockingTask.getId(); |
| | | ; |
| | | //表示是主数据 |
| | | CodeClassifyTemplateVO codeClassifyTemplateVO = mdmEngineServiceI.getUsedTemplateByClassifyOid(classifyoid); |
| | | R<List<Map<String, String>>> r = mdmEngineServiceI.getDataByOid(btmoid, codeClassifyTemplateVO.getOid()); |
| | | log.info("推送人员数据,执行到查询主数据和模板属性阶段!!"); |
| | | 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<>(); |
| | | // TODO: 回收编码的情况,会出现数据已经回收,但是事务还未执行的情况, |
| | | // 导致取不到码值,所以这儿通过查询码值表中存储的已回收的业务数据信息,解析出来 |
| | | if (!r.isSuccess() || Func.isEmpty(r.getData())) { |
| | | List<CodeAllCode> codeAllCodes = codeAllCodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getId, dockingTask.getId())); |
| | | CodeAllCode codeAllCode = codeAllCodes.get(0); |
| | | BaseModel baseModel = JSONObject.parseObject(codeAllCode.getBusinessData(), BaseModel.class); |
| | | Map<String, Object> objectMap = VciBaseUtil.objectToMap(baseModel); |
| | | for (Map.Entry<String, Object> entry : objectMap.entrySet()) { |
| | | if (entry.getKey().equals("data") && Func.isNotEmpty(entry.getValue())) { |
| | | Map<String, Object> dataMap = (Map<String, Object>) ((JSONObject) entry.getValue()); |
| | | for (Map.Entry<String, Object> dataEntry : dataMap.entrySet()) { |
| | | String v = String.valueOf(dataEntry.getValue()); |
| | | data.put(dataEntry.getKey().toLowerCase(Locale.ROOT), v == null ? "" : v); |
| | | } |
| | | } else { |
| | | String key = entry.getKey().toLowerCase(Locale.ROOT); |
| | | String value = String.valueOf(entry.getValue()); |
| | | data.put(key, value == null ? "" : value); |
| | | } |
| | | } |
| | | /*JSONObject josni = bladeRedis.get(DOCKING_CACHE2_DELETE + btmoid); |
| | | data = (Map) josni;*/ |
| | | } else { |
| | | data = r.getData().get(0); |
| | | } |
| | | List<NodeProDTO> nodeProDTOS = new ArrayList<>(); |
| | | final Map<String, String> finalData = data; |
| | | List<String> newItemId = new ArrayList<>(); |
| | | finalData.keySet().forEach(field -> { |
| | | if (field.toLowerCase(Locale.ROOT).equals(itemId.toLowerCase(Locale.ROOT))) { |
| | | String Value = finalData.get(field); |
| | | newItemId.add(Value); |
| | | } |
| | | String outName = attrIdNameMap.get(field); |
| | | if (finalData.containsKey(field)) { |
| | | String Value = finalData.get(field); |
| | | NodeProDTO nodeProDTO = new NodeProDTO(); |
| | | nodeProDTO.setFiledName(field); |
| | | nodeProDTO.setOutname(outName); |
| | | nodeProDTO.setFiledValue(Value); |
| | | nodeProDTOS.add(nodeProDTO); |
| | | } |
| | | }); |
| | | //查询推送接口参数 |
| | | DockingSystemConfig dockingSystemConfig = dockingSystemConfigService.getById(systeminfooid); |
| | | boolean isGroupCodeFlage = false; |
| | | if (dockingSystemConfig != null) { |
| | | isGroupCodeFlage = StringUtils.isBlank(dockingSystemConfig.getIsGroupCodeFlag()) ? false : Boolean.parseBoolean(dockingSystemConfig.getIsGroupCodeFlag()); |
| | | } |
| | | if (isGroupCodeFlage) { |
| | | code = data.getOrDefault("groupcode", ""); |
| | | if (StringUtils.isBlank(code)) { |
| | | //如果是推送集团码,没有领取到集团码则任务不结束等待集团码申请后再通过定时器调用集团码段 |
| | | dockingTask.setDescription("等待集团申请集团码"); |
| | | // TODO:可能会出现未获取到集团码,但是又立马执行了回收,此时这条任务就永远无法结束,所以这儿判断只要是集团码为空,并且是回收的就关闭推送这条任务 |
| | | dockingTask.setSendFlag(MdmDuckingConstant.SEND_FLAG_FALSE); |
| | | dockingTask.setLastModifyTime(new Date()); |
| | | dockingTaskService.updateById(dockingTask); |
| | | continue; |
| | | } |
| | | } |
| | | String[] classCodeLeves = dockingTask.getClassifyId().split(","); |
| | | NodeJosnDTO nodeJosnDTO = new NodeJosnDTO(); |
| | | NodedataDTO nodeDataDTO = new NodedataDTO(); |
| | | NodeObjectDTO nodeObjectDTO = new NodeObjectDTO(); |
| | | nodeObjectDTO.setCode(code);//设置编码 |
| | | nodeObjectDTO.setClassCode(classCodeLeves[0]); |
| | | nodeObjectDTO.setStatus(data.get("lcstatus")); |
| | | nodeObjectDTO.setItemid(newItemId.get(0)); |
| | | nodeObjectDTO.setLibrary(classCodeLeves[classCodeLeves.length - 1]); |
| | | nodeObjectDTO.setPro(nodeProDTOS); |
| | | List<NodeObjectDTO> nodeObjectDTOS = new ArrayList<>(); |
| | | nodeObjectDTOS.add(nodeObjectDTO); |
| | | nodeDataDTO.setObject(nodeObjectDTOS); |
| | | nodeJosnDTO.setData(nodeDataDTO); |
| | | |
| | | String paramType = dockingSystemConfig.getParamType();//xml/json |
| | | if (paramType.equals(DATATYPE_JSON)) { |
| | | Object object = JSONObject.toJSON(nodeJosnDTO); |
| | | //sendString = object.toString(); |
| | | sendString = object; |
| | | } else { |
| | | //组织返回接口信息 |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(NodedataDTO.class); |
| | | xStream.autodetectAnnotations(true); |
| | | sendString = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + xStream.toXML(nodeDataDTO); |
| | | } |
| | | log.info("推送人员数据,执行到调用HR接口了!!"); |
| | | //调用接口 |
| | | callInterface(sendString, dockingSystemConfig, dockingTask, "pushData"); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | } |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * 调用接口,传参为JSON时传object类型,Content-Type改为界面配置的 |
| | | * @param sendObject |
| | | * @param dockingSystemConfig |
| | | * @param dockingTask |
| | | * @throws Throwable |
| | | */ |
| | | private void callInterface(Object sendObject, DockingSystemConfig dockingSystemConfig, DockingTask dockingTask, String operation) throws Throwable { |
| | | String paramString = ""; |
| | | String backString = ""; |
| | | String sendString = sendObject.toString(); |
| | | String msg = ""; |
| | | String url = dockingSystemConfig.getRequestUrl();//url |
| | | List<ResultNodeObjectDTO> resultNodeObjectDTOS = new ArrayList<>(); |
| | | try { |
| | | boolean usedFlag = dockingSystemConfig.getUsedFlag().equals("true") ? true : false; |
| | | if (!usedFlag) { |
| | | throw new Throwable("接口已经停用!"); |
| | | } |
| | | String type = dockingSystemConfig.getInterfaceType().toLowerCase(Locale.ROOT);//get/post/webserver/corba |
| | | String paramType = dockingSystemConfig.getParamType();//xml/json |
| | | String returnType = dockingSystemConfig.getReturnType();//xml/json |
| | | String requestmethod = dockingSystemConfig.getRequestMethod(); |
| | | String interfaceFunction = dockingSystemConfig.getInterfaceFunction();//主要是webservice的方法名 |
| | | String namespace = dockingSystemConfig.getNamespace();//namespace |
| | | String soapaction = dockingSystemConfig.getSoapAction();//soapaction |
| | | String targName = dockingSystemConfig.getTargetName();//targName |
| | | String cxfaxis = dockingSystemConfig.getCxfAxis();//webservice是cxf/axis |
| | | //查询param |
| | | List<DockingSysIntParam> dockingSysIntParamList = dockingSysIntParamService.list(Wrappers.<DockingSysIntParam>query().lambda().eq(DockingSysIntParam::getInfoOid, dockingSystemConfig.getOid())); |
| | | //查询header |
| | | List<DockingSysIntHeader> dockingSysIntHeaderList = dockingSysIntHeaderService.list(Wrappers.<DockingSysIntHeader>query().lambda().eq(DockingSysIntHeader::getInfoOid, dockingSystemConfig.getOid())); |
| | | if (type.equals(URLTYPE_HTTP)) { |
| | | if (requestmethod.equals(URLTYPE_GET)) {//GET请求 |
| | | String sendurl = url + "?" + DATA_PARAM_NAME + "=" + sendString; |
| | | //拼接param |
| | | for (DockingSysIntParam dockingSysIntParam : dockingSysIntParamList) { |
| | | sendurl = sendurl + "&" + dockingSysIntParam.getParamKey() + "=" + dockingSysIntParam.getParamValue(); |
| | | } |
| | | paramString = sendurl; |
| | | backString = HttpUtils.get(sendurl); |
| | | } else if (requestmethod.equals(URLTYPE_POST)) {//POST请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | for (DockingSysIntParam dockingSysIntParam : dockingSysIntParamList) { |
| | | params.add(dockingSysIntParam.getParamKey(), dockingSysIntParam.getParamValue()); |
| | | } |
| | | params.add(DATA_PARAM_NAME, sendObject); |
| | | paramString = params.toString(); |
| | | MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); |
| | | for (DockingSysIntHeader dockingSysIntHeader : dockingSysIntHeaderList) { |
| | | headers.add(dockingSysIntHeader.getHeaderKey(), dockingSysIntHeader.getHeaderValue()); |
| | | } |
| | | log.info("推送人员数据,执行到调用接口了,地址:" + url); |
| | | backString = HttpUtils.postByMediaType( |
| | | url, |
| | | params, |
| | | headers, |
| | | Func.isNotBlank(dockingSystemConfig.getContentType()) ? MediaType.valueOf(dockingSystemConfig.getContentType()) : MediaType.APPLICATION_FORM_URLENCODED |
| | | ); |
| | | } |
| | | if (backString.startsWith("\"")) { |
| | | backString = backString.substring(backString.indexOf("\"") + 1); |
| | | } |
| | | if (backString.endsWith("\"")) { |
| | | backString = backString.substring(0, backString.lastIndexOf("\"")); |
| | | } |
| | | if (backString.contains("\n")) { |
| | | String res = "\n"; |
| | | backString = backString.replaceAll(res, ""); |
| | | } |
| | | if (backString.contains("\\")) { |
| | | String res = "\\\\\""; |
| | | backString = backString.replaceAll(res, "\"").trim(); |
| | | } |
| | | } else if (type.equals(URLTYPE_WEBSERVICE)) {//webserver请求 |
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); |
| | | for (DockingSysIntParam dockingSysIntParam : dockingSysIntParamList) { |
| | | params.add(dockingSysIntParam.getParamKey(), dockingSysIntParam.getParamValue()); |
| | | } |
| | | |
| | | paramString = sendString; |
| | | MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); |
| | | for (DockingSysIntHeader dockingSysIntHeader : dockingSysIntHeaderList) { |
| | | headers.add(dockingSysIntHeader.getHeaderKey(), dockingSysIntHeader.getHeaderValue()); |
| | | } |
| | | backString = WsErpClientUtil.sendMsg(url, namespace, soapaction, interfaceFunction, targName, sendString, 10000); |
| | | |
| | | } else {//corba接口 |
| | | //paramString=sendString; |
| | | // backString = jacorbClient.getBOFactoryService().sendCode(sendString); |
| | | } |
| | | |
| | | ResultJsonDTO resultJsonDTO = new ResultJsonDTO(); |
| | | if (returnType.equals(DATATYPE_JSON)) { |
| | | resultJsonDTO = JSONObject.toJavaObject(JSONObject.parseObject(backString), ResultJsonDTO.class); |
| | | } else { |
| | | //组织返回接口信息 |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(ResultNodeDataDTO.class); |
| | | xStream.autodetectAnnotations(true); |
| | | ResultNodeDataDTO resultNodeDataDTO = (ResultNodeDataDTO) xStream.fromXML(backString); |
| | | resultJsonDTO.setData(resultNodeDataDTO); |
| | | } |
| | | ResultNodeDataDTO resultNodeDataDTO = resultJsonDTO.getData(); |
| | | resultNodeObjectDTOS = resultNodeDataDTO.getObject(); |
| | | } catch (Throwable e) { |
| | | msg = "调用接口失败:" + e.getMessage(); |
| | | e.printStackTrace(); |
| | | log.error("调用接口失败:" + e); |
| | | // throw new Throwable("调用接口失败:"+e); |
| | | ResultNodeObjectDTO resultNodeObjectDTO = new ResultNodeObjectDTO(); |
| | | resultNodeObjectDTO.setErroid("1"); |
| | | resultNodeObjectDTO.setMsg(msg); |
| | | resultNodeObjectDTO.setCode(dockingSystemConfig.getPushType().equalsIgnoreCase("2") ? dockingTask.getClassifyId() : dockingTask.getId()); |
| | | resultNodeObjectDTO.setItemid(dockingTask.getBtmOid()); |
| | | resultNodeObjectDTOS.add(resultNodeObjectDTO); |
| | | } finally { |
| | | boolean isSend = false; |
| | | log.info("推送人员数据,执行到final阶段了"); |
| | | for (ResultNodeObjectDTO resultNodeObjectDTO : resultNodeObjectDTOS) { |
| | | String erroid = resultNodeObjectDTO.getErroid(); |
| | | msg = resultNodeObjectDTO.getMsg(); |
| | | if ("0".equals(erroid)) { |
| | | isSend = true; |
| | | } else if ("1".equals(erroid)) { |
| | | isSend = false; |
| | | } else { |
| | | isSend = false; |
| | | } |
| | | DockingLog dockingLogeDO = new DockingLog(); |
| | | String oid = VciBaseUtil.getPk(); |
| | | dockingLogeDO.setOid(oid); |
| | | dockingLogeDO.setSystemCode(dockingTask.getSystemCode()); |
| | | dockingLogeDO.setSystemName(dockingTask.getSystemName()); |
| | | dockingLogeDO.setSystemOid(dockingTask.getSystemOid()); |
| | | dockingLogeDO.setClassifyOid(dockingTask.getClassifyOid()); |
| | | dockingLogeDO.setClassifyId(dockingTask.getClassifyId()); |
| | | dockingLogeDO.setClassifyName(dockingTask.getClassifyName()); |
| | | dockingLogeDO.setCreateTime(new Date()); |
| | | dockingLogeDO.setId(dockingTask.getId()); |
| | | dockingLogeDO.setUniqueCode(dockingTask.getUniqueCode()); |
| | | dockingLogeDO.setParamString(paramString); |
| | | dockingLogeDO.setReturnString(backString); |
| | | dockingLogeDO.setInterfaceStatus(isSend ? "true" : "false"); |
| | | dockingLogeDO.setType(operation); |
| | | dockingLogeDO.setMsg(msg); |
| | | log.error("集成推送数据,systemcode:" + dockingTask.getSystemCode() + ",systemname:" + dockingTask.getSystemName() + ",url:" + url + ",param:" + paramString + ",e:" + msg); |
| | | dockingLogeService.save(dockingLogeDO); |
| | | } |
| | | //全都接收成功的情况下,修改dockingtask sendflag为已发送 |
| | | if (isSend) { |
| | | dockingTask.setSendFlag(MdmDuckingConstant.SEND_FLAG_TRUE); |
| | | dockingTask.setLastModifyTime(new Date()); |
| | | dockingTaskService.updateById(dockingTask); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * 查询需要集成的业务数据任务 |
| | | */ |
| | | private void sendpushDataForService() { |
| | | initSysadmin(); |
| | | //查询哪些任务还没有执行完成 |
| | | //VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(DockingTaskDO.class); |
| | | //queryWrapper.addQueryMap("sendFlag",MdmDuckingConstant.SEND_FLAG_FALSE); |
| | | // queryWrapper.addQueryMap("btmId", QueryOptionConstant.NOTIN + "(" + VciBaseUtil.toInSql(DOCKING_DEFAULT_CLASSIFY.toUpperCase(Locale.ROOT)) + ")"); |
| | | |
| | | //根据类型去查询需要集成的分类或者数据 |
| | | LambdaQueryWrapper<DockingTask> queryWrapper = Wrappers.<DockingTask>lambdaQuery(); |
| | | queryWrapper.eq(DockingTask::getSendFlag, MdmDuckingConstant.SEND_FLAG_FALSE); |
| | | queryWrapper.notIn(DockingTask::getBtmId, DOCKING_DEFAULT_CLASSIFY.toLowerCase(Locale.ROOT)); |
| | | List<DockingTask> dockingTaskDOS = dockingTaskService.list(queryWrapper); |
| | | sendpushDataForService(dockingTaskDOS); |
| | | } |
| | | |
| | | /*** |
| | | * 查询需要集成的父分类任务 |
| | | */ |
| | | private void sendpushClsfForService() { |
| | | initSysadmin(); |
| | | /* //查询哪些任务还没有执行完成 |
| | | VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(DockingTaskDO.class); |
| | | queryWrapper.addQueryMap("sendFlag",MdmDuckingConstant.SEND_FLAG_FALSE); |
| | | queryWrapper.addQueryMap("btmId",DOCKING_DEFAULT_CLASSIFY.toUpperCase(Locale.ROOT)); |
| | | List<DockingTaskDO> dockingTaskDOS = dockingTaskDaoI.selectByWrapper(queryWrapper);*/ |
| | | |
| | | //根据类型去查询需要集成的分类或者数据 |
| | | LambdaQueryWrapper<DockingTask> queryWrapper = Wrappers.<DockingTask>lambdaQuery(); |
| | | queryWrapper.eq(DockingTask::getSendFlag, MdmDuckingConstant.SEND_FLAG_FALSE); |
| | | queryWrapper.eq(DockingTask::getBtmId, DOCKING_DEFAULT_CLASSIFY.toLowerCase(Locale.ROOT)); |
| | | List<DockingTask> dockingTaskDOS = dockingTaskService.list(queryWrapper); |
| | | sendpushClsfForService(dockingTaskDOS); |
| | | } |
| | | |
| | | public void initSysadmin() { |
| | | SessionInfo sessionInfo = new SessionInfo(); |
| | | sessionInfo.setUserId("sysAdmin"); |
| | | sessionInfo.setUserName("系统管理员"); |
| | | sessionInfo.setIp(WebUtil.getLocalIp()); |
| | | sessionInfo.setUserOid("193C026F-7DB8-27B4-F383-4E8BE083FB07"); |
| | | sessionInfo.setUserSecret(UserSecretEnum.PRIVACY.getValue() + ""); |
| | | WebUtil.setSessionInfo(sessionInfo); |
| | | } |
| | | |
| | | /** |
| | | * dockingdata根据oid修改sendflag |
| | | * |
| | | * @param oid |
| | | * @param sendflag |
| | | * @return |
| | | */ |
| | | public boolean updateDockingDatasSendFlag(String oid,String sendflag){ |
| | | boolean u=false; |
| | | DockingData dockingData=dockingDataService.getById(oid); |
| | | if(dockingData!=null){ |
| | | public boolean updateDockingDatasSendFlag(String oid, String sendflag) { |
| | | boolean u = false; |
| | | DockingData dockingData = dockingDataService.getById(oid); |
| | | if (dockingData != null) { |
| | | dockingData.setSendFlag(sendflag); |
| | | u= dockingDataService.updateById(dockingData); |
| | | u = dockingDataService.updateById(dockingData); |
| | | } |
| | | return u; |
| | | } |
| | | |
| | | } |
| | | |