| | |
| | | String records = httpClientResult.getContent(); |
| | | records = records.replaceAll("\\p{Z}", ""); |
| | | JSONObject jsonObj = JSON.parseObject(records); |
| | | |
| | | records = jsonObj.getString("records"); |
| | | records = records.replaceAll("attri2","unitName"); |
| | | records = records.replaceAll("brand","supplierName"); |
| | | records = records.replaceAll("jzgg","specification"); |
| | | records = records.replaceAll("model","specificationDisplayName"); |
| | | records = records.replaceAll("namecn","code"); |
| | | records = records.replaceAll("hyflmc","typeCode"); |
| | | JSONArray recordArray = JSON.parseArray(records);//物料数据信息 |
| | | //将数据保存至数据库 |
| | | JSONArray newJson = mdmService.saveMdmData(recordArray,name); |
| | | if(newJson.size()!=0){ |
| | | //定义返回json格式 |
| | | returnJson.append("{\n" + |
| | | /*returnJson.append("{\n" + |
| | | " \"current\": 1,\n" + |
| | | " \"orders\": [],\n" + |
| | | " \"pages\": 303,"); |
| | | returnJson.append("\"records\": "+newJson.toJSONString()); |
| | | returnJson.append(",\n" + |
| | | " \"pages\": 303,");*/ |
| | | returnJson.append("{\"records\": "+newJson.toJSONString()+"}"); |
| | | /*returnJson.append(",\n" + |
| | | " \"searchCount\": true,\n" + |
| | | " \"size\": 1,\n" + |
| | | " \"total\": 303\n" + |
| | | "}"); |
| | | "}");*/ |
| | | //返回json格式参数 |
| | | String toString = returnJson.toString(); |
| | | System.out.println(toString); |
| | | System.out.println("响应参数分发:"+toString); |
| | | //分发增量数据至异构系统 |
| | | distributeDataToSys(toString,name); |
| | | } |
| | |
| | | "}"); |
| | | //返回json格式参数 |
| | | String toString = returnJson.toString(); |
| | | System.out.println(toString); |
| | | //分发增量数据至异构系统 |
| | | distributeDataToSys(toString,name); |
| | | } |
| | |
| | | String uuid = UUID.randomUUID().toString(); |
| | | try { |
| | | //数据分发 |
| | | httpClientResult = MdmApiUtils.doPostJson(address, jsonParam); |
| | | if("MES系统".equals(sysName)){ |
| | | //处理json为MES系统想要的格式 |
| | | jsonParam=MdmApiUtils.getMesJson(jsonParam); |
| | | //拼接webservice |
| | | String xmlStr=MdmApiUtils.getMesSoapBody(jsonParam); |
| | | //请求webservice |
| | | httpClientResult = MdmApiUtils.doPostXmlJson(address, xmlStr); |
| | | }else{ |
| | | httpClientResult = MdmApiUtils.doPostJson(address, jsonParam); |
| | | } |
| | | |
| | | //响应结果 |
| | | String content = httpClientResult.getContent(); |
| | | if("MES系统".equals(sysName)){ |
| | | content = MdmApiUtils.getMesResponseJson(content); |
| | | } |
| | | int code = httpClientResult.getCode(); |
| | | if(200 == code){ |
| | | //成功 |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | this.saveInterfaceLog(uuid,interfaceName,address,jsonParam,"{\"batchId\":\""+uuid+"\",\"msg\":\" 接口调用网络异常!!! \"}"); |
| | | this.saveInterfaceLog(uuid,interfaceName,address,jsonParam,"{\"batchId\":\""+uuid+"\",\"msg\":\" 接口调用网络异常!!!/"+e.getMessage()+"/ \"}"); |
| | | } |
| | | |
| | | } |