提交 | 用户 | 时间
|
0ca254
|
1 |
package com.jcdm.main.restful.factoryMes.service; |
A |
2 |
|
|
3 |
import cn.hutool.http.HttpRequest; |
|
4 |
import cn.hutool.http.HttpResponse; |
|
5 |
import cn.hutool.json.JSONObject; |
20635f
|
6 |
import com.jcdm.main.constant.Constants; |
0ca254
|
7 |
import org.springframework.web.bind.annotation.RequestMapping; |
A |
8 |
import org.springframework.web.bind.annotation.RequestParam; |
|
9 |
|
|
10 |
public class RestfulService { |
|
11 |
public static void main(String[] args) { |
|
12 |
String json = "{\"code\":\"success\",\"data\":{\"productNum\":\"LCV123456P0600036\",\"stationCode\":\"1HZ01\",\"resultCode\":\"S\",\"resultText\":\"报工成功\"},\"message\":\"API 调用成功\"}"; |
|
13 |
JSONObject jsonObject = new JSONObject(json); |
|
14 |
String code = jsonObject.getStr("code"); |
|
15 |
String resultCode = jsonObject.getJSONObject("data").getStr("resultCode"); |
|
16 |
System.out.println("code: " + code); |
|
17 |
System.out.println("resultCode: " + resultCode); |
|
18 |
} |
|
19 |
|
20635f
|
20 |
public static final String getRealmName = Constants.FACTORY_EMS_UAT_RUL; |
A |
21 |
|
|
22 |
// public static final String getRealmName = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration"; |
0ca254
|
23 |
// |
A |
24 |
public static final String postRealmName = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/interface"; |
|
25 |
|
|
26 |
// public static final String getRealmName = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration"; |
|
27 |
|
|
28 |
// public static final String postRealmName = "https://imes-group.geelycv.com/api/mom-open/restful/interface"; |
|
29 |
|
|
30 |
public static final String siteCode = "3983"; |
|
31 |
|
|
32 |
/** |
|
33 |
* 生产工单请求接口 |
|
34 |
* @param productNum |
|
35 |
* @param stationCode |
|
36 |
* @return |
|
37 |
*/ |
|
38 |
//{"code":"success","data":{"productNum":"LCV123456P0600036","stationCode":"1HZ01","materialCode":"LCV001_3","productionOrderNum":"500000258"},"message":"API调用成功"} |
35c489
|
39 |
public static String getProductionWorkOrderRequest(String productNum,String stationCode,String materialCode) |
0ca254
|
40 |
{ |
35c489
|
41 |
String url = getRealmName + "/productionWorkOrderRequest?siteCode="+siteCode+"&stationCode="+stationCode+"&productNum="+productNum+"&materialCode="+materialCode; |
0ca254
|
42 |
HttpResponse response = HttpRequest.get(url).execute(); |
A |
43 |
HttpRequest httpRequest = HttpRequest.get(url); |
|
44 |
return response.body(); |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* AMES报工结果回传 |
|
49 |
* @param productNum |
|
50 |
* @param stationCode |
|
51 |
* @param confirmTime |
|
52 |
* @return |
|
53 |
*/ |
|
54 |
//{"code":"success","data":{"productNum":"LCV123456P0600036","stationCode":"1HZ01","resultCode":"S","resultText":"报工成功"},"message":"API调用成功"} |
|
55 |
public static String getWorkReportResultFeedback(String productNum,String stationCode,String confirmTime) |
|
56 |
{ |
|
57 |
String result = ""; |
|
58 |
try { |
|
59 |
String url = getRealmName + "/workReportResultFeedback?siteCode="+siteCode+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime; |
|
60 |
HttpResponse response = HttpRequest.get(url).execute(); |
|
61 |
HttpRequest httpRequest = HttpRequest.get(url); |
|
62 |
result = response.body(); |
|
63 |
}catch (Exception e){ |
|
64 |
e.printStackTrace(); |
|
65 |
}finally { |
|
66 |
return result; |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* 生产工单组件请求接口 |
|
74 |
* @param productionOrderNum |
|
75 |
* @return |
|
76 |
* |
|
77 |
*/ |
|
78 |
//{"code":"success","data":[{"productionOrderNum":"500000258","componentCode":"LCV_TZ_002","quantity":"1.0","stationCode":"C01"},{"productionOrderNum":"500000258","componentCode":"LCV_CG_001","quantity":"1.0","stationCode":"C01"},{"productionOrderNum":"500000258","componentCode":"LCV_CG_002","quantity":"1.0","stationCode":"C01"},{"productionOrderNum":"500000258","componentCode":"LCV_CG_003","quantity":"1.0","stationCode":"C01"},{"productionOrderNum":"500000258","componentCode":"LCV_CG_004","quantity":"1.0","stationCode":"C01"},{"productionOrderNum":"500000258","componentCode":"LCV_CG_005","quantity":"1.0","stationCode":"C02"},{"productionOrderNum":"500000258","componentCode":"LCV_CG_006","quantity":"1.0","stationCode":"C03"},{"productionOrderNum":"500000258","componentCode":"LCV_CG_007","quantity":"1.0","stationCode":"C04"},{"productionOrderNum":"500000258","componentCode":"LCV_CG_009","quantity":"2.0","stationCode":"C05"}],"message":"API调用成功"} |
|
79 |
public static String getProductionOrderComponentRequest(String productionOrderNum) |
|
80 |
{ |
|
81 |
String url = getRealmName + "/productionOrderComponentRequest?siteCode="+siteCode+"&productionOrderNum="+productionOrderNum; |
|
82 |
HttpResponse response = HttpRequest.get(url).execute(); |
|
83 |
HttpRequest httpRequest = HttpRequest.get(url); |
|
84 |
return response.body(); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* 产品队列请求 |
|
89 |
* @param productNum |
|
90 |
* @param stationCode |
|
91 |
* @return |
|
92 |
*/ |
|
93 |
//{"code":"success","data":[{"configValues":{"FXPTX":"","ZJTX":"","JSYZYZC":"","CDGDTX":"","CHLXTX":""},"productTrackInfo":{"ProductNum":"LCVLCVTS3P0600388","StationCode":"1A03"}}],"message":"API调用成功"} |
|
94 |
public static String postPRODUCTION_QUEUE(String productNum,String stationCode) |
|
95 |
{ |
|
96 |
String url = postRealmName + "/PRODUCTION_QUEUE"; |
|
97 |
HttpResponse response = HttpRequest.post(url) |
|
98 |
// 表单参数,可以通过多次调用 form 方法添加多个参数 |
|
99 |
.form("siteCode", siteCode) |
|
100 |
.form("interfaceCode", "PRODUCTION_QUEUE") |
|
101 |
.form("parameter", "{\"productNum\":\""+productNum+"\",\"stationCode\":\""+stationCode+"\",\"requestQty\":1}") |
|
102 |
// 执行请求 |
|
103 |
.execute(); |
|
104 |
return response.body(); |
|
105 |
} |
|
106 |
//HttpResponse response = HttpRequest.post(url).body(JSONUtil.toJsonStr(vo)).execute(); |
|
107 |
} |