| | |
| | | import com.vci.ubcs.code.vo.webserviceModel.apply.ApplyDatasVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.apply.ProppertyVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.apply.SectionVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.applybz.ApplyBZDataVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.applybz.ApplyBZDatasVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.attrmap.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultDataObjectDetailDO; |
| | | import com.vci.ubcs.code.webService.config.AttributeMapConfig; |
| | |
| | | import com.vci.ubcs.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.BeanUtil; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.WebUtil; |
| | | import com.vci.ubcs.system.user.entity.User; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.map.CaseInsensitiveMap; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | 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.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.jws.WebMethod; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.xml.ws.WebServiceContext; |
| | | import javax.xml.ws.handler.MessageContext; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | |
| | | @Service |
| | | @Slf4j |
| | | public class CodeDuckingSyncServiceImpl implements ICodeDuckingSyncService { |
| | | |
| | | @Value("${dataSyncPush.dataParamName:xmlData}") |
| | | public String DATA_PARAM_NAME; |
| | | @Value("${dataSyncPush.dataId:itemid}") |
| | |
| | | |
| | | @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; |
| | | |
| | | @Autowired |
| | | HttpServletRequest request; |
| | | |
| | | @Override |
| | | public void DockingDataSyncScheduing() { |
| | | |
| | |
| | | }); |
| | | return R.success("手动推送完成,请核对是否推送成功"); |
| | | } |
| | | |
| | | private SearchItemDataVO initData(String status,String itemCode,String mmCode){ |
| | | SearchItemDataVO searchItemDataVO=new SearchItemDataVO(); |
| | | searchItemDataVO.setLastchangedon(new Date()); |
| | |
| | | ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.currentRequestAttributes(); |
| | | request = servletRequestAttributes.getRequest(); |
| | | } |
| | | org.springblade.core.tool.utils.WebUtil.setRequest(new ServletRequestAttributes(request)); |
| | | } |
| | | |
| | | return request; |
| | | } |
| | | |
| | | /*** |
| | | * 同步型号代号 |
| | | */ |
| | |
| | | Map<String,String>searchDataMap= VciBaseUtil.objectToMapString(searchItemParam); |
| | | try { |
| | | paramString=JSONObject.toJSON(searchItemParam).toString(); |
| | | SearchItemVO searchItemVO = mdmSearchItemCodeProvider.getppModelByElem(searchItemParam); |
| | | /*SearchItemVO searchItemVO=new SearchItemVO(); |
| | | List<SearchItemDataVO> data=new ArrayList<>(); |
| | | SearchItemDataVO searchItemDataVO1=initData("1","","pro-00001"); |
| | | SearchItemDataVO searchItemDataVO2=initData("0","item-00001",""); |
| | | data.add(searchItemDataVO1); |
| | | data.add(searchItemDataVO2); |
| | | searchItemVO.setData(data); |
| | | searchItemVO.setCode("200"); |
| | | searchItemVO.setMsg("");*/ |
| | | String res= mdmSearchItemCodeProvider.getppModelByElem(searchItemParam); |
| | | SearchItemVO searchItemVO = JSONObject.toJavaObject(JSONObject.parseObject(res), SearchItemVO.class); |
| | | /**SearchItemVO searchItemVO=new SearchItemVO(); |
| | | List<SearchItemDataVO> data=new ArrayList<>(); |
| | | SearchItemDataVO searchItemDataVO1=initData("1","","pro-00001"); |
| | | SearchItemDataVO searchItemDataVO2=initData("0","item-00001",""); |
| | | data.add(searchItemDataVO1); |
| | | data.add(searchItemDataVO2); |
| | | //searchItemVO.setData(data); |
| | | searchItemVO.setCode("200");**/ |
| | | //searchItemVO.setMsg(""); |
| | | if (searchItemVO != null) { |
| | | BladeUser finalUser; |
| | | paramString = JSONObject.toJSON(searchItemVO).toString(); |
| | | log.info("型号代号数据值-------》"+paramString); |
| | | HttpServletRequest request=getRequest(); |
| | | try { |
| | | //免密登录申请token,request中添加用户信息 |
| | | try { |
| | | passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(Locale.ROOT), getRequest()); |
| | | 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("用户鉴权失败."); |
| | | } |
| | | final BladeUser user = AuthUtil.getUser(); |
| | | List<CodeClassify> codeClassifyList = codeClassifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().in(CodeClassify::getId, btmName)); |
| | | if (CollectionUtils.isEmpty(codeClassifyList)) { |
| | | throw new Throwable("分类未查询到"); |
| | |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && |
| | | ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | List<SearchItemDataVO> dataList = searchItemVO.getData(); |
| | | Map<String, SearchItemDataVO> dataVOMap = new HashMap<>(); |
| | | List<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 (!CollectionUtils.isEmpty(dataList)) { |
| | | dataList.stream().forEach(searchItemDataVO -> { |
| | | String itemCode = StringUtils.isNotBlank(searchItemDataVO.getProjectitem()) ? searchItemDataVO.getProjectitem() : searchItemDataVO.getMmodelcode();//项目代号 |
| | | String itemCode = StringUtils.isNotBlank(searchItemDataVO.getPROJECTITEM()) ? searchItemDataVO.getPROJECTITEM() : searchItemDataVO.getMMODELCODE();//项目代号 |
| | | dataVOMap.put(itemCode, searchItemDataVO); |
| | | itemCodeList.add(itemCode); |
| | | }); |
| | |
| | | sb.append(" and codeclsfid = '" + codeClassify.getOid() + "' "); |
| | | sb.append(" and " + VciBaseUtil.toInSql(attrKey, itemCodeList.toArray(new String[]{}))); |
| | | List<Map<String, String>> newDataList = commonsMapper.queryByOnlySqlForMap(sb.toString()); |
| | | |
| | | //List<BaseModel> baseModelList=new ArrayList<>(); |
| | | Map<String, BaseModel> baseModelMap = new HashMap<>(); |
| | | newDataList.stream().forEach(dataMap -> { |
| | | BaseModel baseModel = new BaseModel(); |
| | | Map<String, String> newDateMap = new CaseInsensitiveMap<>(dataMap); |
| | | DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(newDateMap, baseModel, true, user); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(baseModel, user); |
| | | //baseModelList.add(baseModel); |
| | | |
| | | String attrKeyValue = newDateMap.getOrDefault(attrKey, ""); |
| | | baseModelMap.put(attrKeyValue, baseModel); |
| | | }); |
| | | |
| | | 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(), user, "editstatus", editObjectList); |
| | | changeObjectToMap(value, baseModel.getId(), finalUser, "editstatus", editObjectList); |
| | | } else { |
| | | changeObjectToMap(value, "", user, "create", addObjectList); |
| | | changeObjectToMap(value, "", finalUser, "create", addObjectList); |
| | | } |
| | | }); |
| | | allObjectList.addAll(addObjectList); |
| | |
| | | paramString = Func.isEmpty(paramObject) ? "" : paramObject.toString(); |
| | | Object backObject = JSONObject.toJSON(allResultDataObjectDetailDOS); |
| | | backString = Func.isEmpty(backObject) ? "" : backObject.toString(); |
| | | }else{ |
| | | throw new Throwable("接口未返回信息"); |
| | | } |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | return codeOrderSecDTOList; |
| | | } |
| | | |
| | | /*** |
| | | * 读取属性映射配置信息 |
| | | * @param systemId |
| | |
| | | throw new Throwable("组织数据映射值失败"); |
| | | } |
| | | } |
| | | private void changeObjectToMap(SearchItemDataVO searchItemDataVO, String code, BladeUser user,String operation,List<ApplyDataVO> object){ |
| | | |
| | | 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();//制造型号代号 |
| | | String mmodelCode=searchItemDataVO.getMMODELCODE();//制造型号代号 |
| | | initProperty("mmodelcode","",mmodelCode,propList); |
| | | String projectCode= searchItemDataVO.getProjectcode();//项目编码 |
| | | String projectCode= searchItemDataVO.getPROJECTCODE();//项目编码 |
| | | initProperty("projectcode","",projectCode,propList); |
| | | String projectItem=searchItemDataVO.getProjectitem();//项目代号 |
| | | String projectItem=searchItemDataVO.getPROJECTITEM();//项目代号 |
| | | initProperty("projectitem","",projectItem,propList); |
| | | String materialCode=searchItemDataVO.getMaterialcode();//产品编码 |
| | | String materialCode=searchItemDataVO.getMATERIALCODE();//产品编码 |
| | | initProperty("materialcode","",materialCode,propList); |
| | | //组合属性的处理 |
| | | initProperty(attrKey,"",StringUtils.isNotBlank(projectItem)?projectItem:mmodelCode,propList); |
| | | String creatBy=searchItemDataVO.getCreatby();//创建者 |
| | | Date cretaeDon= searchItemDataVO.getCreatedon();//创建日期 日期型,如:2023-09-08 19:24:11 |
| | | String lastchangeBy=searchItemDataVO.getLastchangedby();//更改者 |
| | | Date lastchangeDon=searchItemDataVO.getLastchangedon();//更改时间 日期型,如:2023-09-08 19:24:11 |
| | | String isenabled= searchItemDataVO.getIsenabled();//字符型,枚举值;停用:0;启用:1; |
| | | 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.setProp(propList); |
| | | object.add(applyDataVO); |
| | | } |
| | | private void initProperty(String key,String text,String value,List<ProppertyVO> propList){ |
| | | |
| | | private void initProperty(String key,String text,String value,List<ProppertyVO> propList){ |
| | | ProppertyVO vo=new ProppertyVO(); |
| | | vo.setKey(key); |
| | | vo.setText(text); |
| | | vo.setValue(value); |
| | | vo.setText(StringUtils.isBlank(text)?"":text); |
| | | vo.setValue(StringUtils.isBlank(value)?"":value); |
| | | propList.add(vo); |
| | | } |
| | | |
| | | /*** |
| | | * 查询redis中数据,对比后插入dockingtask |
| | | * @param type |
| | |
| | | for (DockingTask dockingTask:dockingTaskList){ |
| | | //每个task一个事务,开启 |
| | | String paramString=""; |
| | | String sendString=""; |
| | | Object sendString=""; |
| | | String backString=""; |
| | | //查询系统接口信息,ip method,dataType |
| | | String systeminfooid = dockingTask.getSysInfoOid();//sysininfo 的oid |
| | |
| | | DockingSystemConfig dockingSystemConfig = dockingSystemConfigService.getById(systeminfooid); |
| | | String paramType = dockingSystemConfig.getParamType();//xml/json |
| | | if(paramType.equals(DATATYPE_JSON)){ |
| | | Object object = JSONObject.toJSON(jsonRootDataDTO); |
| | | sendString = object.toString(); |
| | | // Object object = JSONObject.toJSON(jsonRootDataDTO); |
| | | // sendString = object.toString(); |
| | | sendString = jsonRootDataDTO; |
| | | }else{ |
| | | //组织返回接口信息 |
| | | XStream xStream = new XStream(new DomDriver()); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * 发送编码主数据 |
| | | */ |
| | |
| | | for (DockingTask dockingTask:dockingTaskS){ |
| | | //每个task一个事务,开启 |
| | | String paramString=""; |
| | | String sendString=""; |
| | | String sendObject=""; |
| | | String backString=""; |
| | | try { |
| | | //查询系统接口信息,ip method,dataType |
| | |
| | | List<NodeProDTO> nodeProDTOS = new ArrayList<>(); |
| | | Map<String, String> finalData = data; |
| | | AtomicReference<String> newItemId= new AtomicReference<>(""); |
| | | attrIdNameMap.keySet().forEach(field -> { |
| | | finalData.keySet().forEach(field -> { |
| | | if(field.toLowerCase(Locale.ROOT).equals(itemId.toLowerCase(Locale.ROOT))){ |
| | | String Value = finalData.get(field); |
| | | newItemId.set(Value); |
| | |
| | | DockingSystemConfig dockingSystemConfig = dockingSystemConfigService.getById(systeminfooid); |
| | | boolean isGroupCodeFlage=false; |
| | | if(dockingSystemConfig!=null) { |
| | | isGroupCodeFlage = StringUtils.isBlank(dockingSystemConfig.getIsGroupCodeFlag())?false: Boolean.getBoolean(dockingSystemConfig.getIsGroupCodeFlag()); |
| | | isGroupCodeFlage = StringUtils.isBlank(dockingSystemConfig.getIsGroupCodeFlag())?false: Boolean.parseBoolean(dockingSystemConfig.getIsGroupCodeFlag()); |
| | | } |
| | | if(isGroupCodeFlage){ |
| | | code=data.getOrDefault("groupcode",""); |
| | |
| | | String paramType = dockingSystemConfig.getParamType();//xml/json |
| | | if (paramType.equals(DATATYPE_JSON)) { |
| | | Object object = JSONObject.toJSON(nodeJosnDTO); |
| | | sendString = object.toString(); |
| | | sendObject = object.toString(); |
| | | } 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); |
| | | sendObject = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + xStream.toXML(nodeDataDTO); |
| | | } |
| | | //调用接口 |
| | | callInterface(sendString,dockingSystemConfig, dockingTask,"pushData"); |
| | | callInterface(sendObject,dockingSystemConfig, dockingTask,"pushData"); |
| | | }catch (Throwable e){ |
| | | e.printStackTrace(); |
| | | }finally { |
| | | } |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * 调用接口 |
| | | * @param sendString |
| | | * 调用接口,传参为JSON时传object类型,Content-Type改为界面配置的 |
| | | * @param sendObject |
| | | * @param dockingSystemConfig |
| | | * @param dockingTask |
| | | * @throws Throwable |
| | | */ |
| | | private void callInterface(String sendString , DockingSystemConfig dockingSystemConfig,DockingTask dockingTask,String operation) throws Throwable{ |
| | | private void callInterface(Object sendObject, DockingSystemConfig dockingSystemConfig,DockingTask dockingTask,String operation) throws Throwable{ |
| | | String paramString = ""; |
| | | |
| | | String backString = ""; |
| | | String msg=""; |
| | | String sendString = dockingSystemConfig.getContentType().equals(DATATYPE_JSON) ? JSONObject.toJSON(sendObject).toString():sendObject.toString(); |
| | | String msg= "" ; |
| | | String url = dockingSystemConfig.getRequestUrl();//url |
| | | List<ResultNodeObjectDTO> resultNodeObjectDTOS =new ArrayList<>(); |
| | | try { |
| | |
| | | paramString = sendurl; |
| | | backString = HttpUtils.get(sendurl); |
| | | } else if (requestmethod.equals(URLTYPE_POST)) {//POST请求 |
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | for (DockingSysIntParam dockingSysIntParam : dockingSysIntParamList) { |
| | | params.add(dockingSysIntParam.getParamKey(), dockingSysIntParam.getParamValue()); |
| | | } |
| | | params.add(DATA_PARAM_NAME,sendString); |
| | | 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()); |
| | | } |
| | | backString = HttpUtils.post(url, params, headers); |
| | | backString = HttpUtils.postByMediaType(url, params, headers,new MediaType(dockingSystemConfig.getContentType())); |
| | | } |
| | | if(backString.startsWith("\"")){ |
| | | backString=backString.substring(backString.indexOf("\"")+1); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 调用接口,传参为JSON时传object类型 |
| | | * @param sendObject |
| | | * @param dockingSystemConfig |
| | | * @param dockingTask |
| | | * @param operation |
| | | * @throws Throwable |
| | | */ |
| | | private void callInterfaceByContentType(Object sendObject, DockingSystemConfig dockingSystemConfig,DockingTask dockingTask,String operation,String sendType) throws Throwable{ |
| | | String paramString = ""; |
| | | String sendString = sendType.equals(DATATYPE_JSON) ? JSONObject.toJSON(sendObject).toString():sendObject.toString(); |
| | | String backString = ""; |
| | | 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()); |
| | | } |
| | | // TODO: 2024-02-25改,为了满足HR以及其他情况下根据Content-type的类型来发请求,并且param中的json是最后的时候发送请求再转 |
| | | backString = HttpUtils.postByMediaType(url, params, headers, 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; |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * 查询需要集成的业务数据任务 |
| | | */ |
| | |
| | | List<DockingTask> dockingTaskDOS = dockingTaskService.list(queryWrapper); |
| | | sendpushClsfForService(dockingTaskDOS); |
| | | } |
| | | |
| | | public void initSysadmin(){ |
| | | SessionInfo sessionInfo = new SessionInfo(); |
| | | sessionInfo.setUserId("sysAdmin"); |
| | |
| | | sessionInfo.setUserSecret(UserSecretEnum.PRIVACY.getValue()+""); |
| | | WebUtil.setSessionInfo(sessionInfo); |
| | | } |
| | | |
| | | /** |
| | | * dockingdata根据oid修改sendflag |
| | | * @param oid |
| | |
| | | } |
| | | return u; |
| | | } |
| | | |
| | | } |
| | | |