| | |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.json.JSONObject; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | public class RestfulService { |
| | | public static void main(String[] args) { |
| | | String str = "uuuuuu11uuuuuuuuuuuuuuu"; |
| | | System.out.println(str.length()); |
| | | // getWorkReportResultFeedback() |
| | | 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 = "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"; |
| | | |
| | |
| | | //{"code":"success","data":{"productNum":"LCV123456P0600036","stationCode":"1HZ01","resultCode":"S","resultText":"报工成功"},"message":"API调用成功"} |
| | | public static String getWorkReportResultFeedback(String productNum,String stationCode,String confirmTime) |
| | | { |
| | | String url = getRealmName + "/workReportResultFeedback?siteCode="+siteCode+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime; |
| | | HttpResponse response = HttpRequest.get(url).execute(); |
| | | HttpRequest httpRequest = HttpRequest.get(url); |
| | | return response.body(); |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |