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