jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReportingForWork.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
jcdm-quartz/pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
jcdm-quartz/src/main/java/com/jcdm/quartz/task/RyTask.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java
@@ -2,6 +2,9 @@ import cn.hutool.json.JSONObject; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; @@ -40,16 +43,28 @@ // test1(); // String serviceUrl = "http://podqapp.cfmoto.com.cn:50200/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_MES_005_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES"; // // String serviceUrl = "http://podqapp.cfmoto.com.cn:50200/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_BC_001_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES"; //// String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" + //// " <soapenv:Header/>\n" + //// " <soapenv:Body>\n" + //// " <urn:ZPP_CF_MES_005>\n" + //// " <!--Optional:-->\n" + //// " <IV_WERKS>1000</IV_WERKS>\n" + //// " <!--Optional:-->\n" + //// " <IV_ZSCTZD>A0055577</IV_ZSCTZD>\n" + //// " </urn:ZPP_CF_MES_005>\n" + //// " </soapenv:Body>\n" + //// "</soapenv:Envelope>"; // String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" + // " <soapenv:Header/>\n" + // " <soapenv:Body>\n" + // " <urn:ZPP_CF_MES_005>\n" + // " <!--Optional:-->\n" + // " <IV_WERKS>1000</IV_WERKS>\n" + // " <!--Optional:-->\n" + // " <IV_ZSCTZD>A0055577</IV_ZSCTZD>\n" + // " </urn:ZPP_CF_MES_005>\n" + // " <urn:ZPP_BC_001>\n" + // " <IV_AUFNR>000010569212</IV_AUFNR>\n" + // " <IV_VORNR>0010</IV_VORNR>\n" + // " <IV_LMNGA>1</IV_LMNGA>\n" + // " <IV_XMNGA>0</IV_XMNGA> \n" + // " <IV_STATU>1</IV_STATU> \n" + // " </urn:ZPP_BC_001>\n" + // " </soapenv:Body>\n" + // "</soapenv:Envelope>"; // // HttpClientåéSOAPè¯·æ± @@ -79,10 +94,10 @@ // InputStream is = postMethod.getResponseBodyAsStream(); // // è·å请æ±ç»æå符串 // String result = IOUtils.toString(is); // String jsonStr = xmlToJSON2(result); // Gson gson = new Gson(); // // å°jsonå符串转æ¢æ对象 // ItemList itemList = gson.fromJson(jsonStr, ItemList.class); //// String jsonStr = xmlToJSON2(result); //// Gson gson = new Gson(); //// // å°jsonå符串转æ¢æ对象 //// ItemList itemList = gson.fromJson(jsonStr, ItemList.class); // System.out.println("è¿åç»æ:" + result); // } else { // System.out.println("é误代ç ï¼" + status + ":" + postMethod.getResponseBodyAsString()); @@ -195,4 +210,33 @@ return etData.toString(); } /** * æ¹å¼--è´° * 使ç¨hutoolå·¥å ·å ä¸çå·¥å ·è½¬å * @param xmlStr * @return */ public static String xmlToJSON3(String xmlStr){ String status = ""; if(xmlStr.contains("EV_STATUS")){ JSONObject jsonObject1 = cn.hutool.json.XML.toJSONObject(xmlStr, true); ObjectMapper objectMapper = new ObjectMapper(); JsonNode rootNode = null; try { rootNode = objectMapper.readTree(String.valueOf(jsonObject1)); } catch (JsonProcessingException e) { throw new RuntimeException(e); } String evStatus = rootNode .path("SOAP:Envelope") .path("SOAP:Body") .path("n0:ZPP_BC_001.Response") .path("EV_STATUS") .asText(); status = evStatus; } return status; } } jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReportingForWork.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,78 @@ package com.jcdm.main.webservice.service; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.auth.AuthScope; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.RequestEntity; import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; public class ReportingForWork { public static void main(String[] args) throws IOException { String serviceUrl = "http://podqapp.cfmoto.com.cn:50200/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_BC_001_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES"; // String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" + // " <soapenv:Header/>\n" + // " <soapenv:Body>\n" + // " <urn:ZPP_CF_MES_005>\n" + // " <!--Optional:-->\n" + // " <IV_WERKS>1000</IV_WERKS>\n" + // " <!--Optional:-->\n" + // " <IV_ZSCTZD>A0055577</IV_ZSCTZD>\n" + // " </urn:ZPP_CF_MES_005>\n" + // " </soapenv:Body>\n" + // "</soapenv:Envelope>"; String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" + " <soapenv:Header/>\n" + " <soapenv:Body>\n" + " <urn:ZPP_BC_001>\n" + " <IV_AUFNR>000010569212</IV_AUFNR>\n" + " <IV_VORNR>0010</IV_VORNR>\n" + " <IV_LMNGA>1</IV_LMNGA>\n" + " <IV_XMNGA>0</IV_XMNGA> \n" + " <IV_STATU>1</IV_STATU> \n" + " </urn:ZPP_BC_001>\n" + " </soapenv:Body>\n" + "</soapenv:Envelope>"; // HttpClientåéSOAPè¯·æ± int timeout = 10000; HttpClient client = new HttpClient(); //å¦æéè¦ç¨æ·åå¯ç éªè¯ï¼ä¸éè¦éªè¯ç»å½åä¸éè¦ä»¥ä¸4è¡ String username = "POMESUSER"; String password = "12345tgb"; UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password); client.getState().setCredentials(AuthScope.ANY, creds); PostMethod postMethod = new PostMethod(serviceUrl); // 设置è¿æ¥è¶ æ¶ client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout); // 设置读åæ¶é´è¶ æ¶ client.getHttpConnectionManager().getParams().setSoTimeout(timeout); // ç¶åæSoap请æ±æ°æ®æ·»å å°PostMethodä¸ RequestEntity requestEntity = new StringRequestEntity(content, "text/xml", "UTF-8"); // 设置请æ±å¤´é¨ï¼å¦åå¯è½ä¼æ¥ âno SOAPAction headerâ çé误 postMethod.setRequestHeader("SOAPAction", ""); // 设置请æ±ä½ postMethod.setRequestEntity(requestEntity); int status = client.executeMethod(postMethod); if (status == 200) {// æå InputStream is = postMethod.getResponseBodyAsStream(); // è·å请æ±ç»æå符串 String result = IOUtils.toString(is); // String jsonStr = xmlToJSON2(result); // Gson gson = new Gson(); // // å°jsonå符串转æ¢æ对象 // ItemList itemList = gson.fromJson(jsonStr, ItemList.class); System.out.println("è¿åç»æ:" + result); } else { System.out.println("é误代ç ï¼" + status + ":" + postMethod.getResponseBodyAsString()); } } } jcdm-quartz/pom.xml
@@ -35,6 +35,11 @@ <artifactId>jcdm-common</artifactId> </dependency> <dependency> <groupId>com.jcdm</groupId> <artifactId>jcdm-main</artifactId> </dependency> </dependencies> </project> jcdm-quartz/src/main/java/com/jcdm/quartz/task/RyTask.java
@@ -1,7 +1,13 @@ package com.jcdm.quartz.task; import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling; import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService; import com.jcdm.main.webservice.service.ReceivingServices; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.jcdm.common.utils.StringUtils; import java.util.List; /** * å®æ¶ä»»å¡è°åº¦æµè¯ @@ -25,4 +31,58 @@ { System.out.println("æ§è¡æ åæ¹æ³"); } @Autowired private IBsOrderSchedulingService bsOrderSchedulingService; String url = "http://podqapp.cfmoto.com.cn:50200/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_BC_001_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES"; public void workReportingTasks(){ report10(); report20(); } public void report10(){ BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); bsOrderScheduling.setReport10("0"); List<BsOrderScheduling> bsOrderSchedulings = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); for (BsOrderScheduling orderScheduling : bsOrderSchedulings) { String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0010")); String status = ReceivingServices.xmlToJSON3(xmlResult); if(status.equals("1")){ orderScheduling.setReport10("1"); int i = bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling); System.out.println("æ´æ°ç¶ææå"); } } } public void report20(){ BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); bsOrderScheduling.setReport20("0"); List<BsOrderScheduling> bsOrderSchedulings = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); for (BsOrderScheduling orderScheduling : bsOrderSchedulings) { String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0790")); String status = ReceivingServices.xmlToJSON3(xmlResult); if(status.equals("1")){ orderScheduling.setReport10("1"); int i = bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling); System.out.println("æ´æ°ç¶ææå"); } } } public static String getProductionPlanInformationXml(String orderNo,String location){ String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" + " <soapenv:Header/>\n" + " <soapenv:Body>\n" + " <urn:ZPP_BC_001>\n" + " <IV_AUFNR>"+orderNo+"</IV_AUFNR>\n" + " <IV_VORNR>"+location+"</IV_VORNR>\n" + " <IV_LMNGA>1</IV_LMNGA>\n" + " <IV_XMNGA>0</IV_XMNGA> \n" + " <IV_STATU>1</IV_STATU> \n" + " </urn:ZPP_BC_001>\n" + " </soapenv:Body>\n" + "</soapenv:Envelope>"; return content; } }