| | |
| | | WorkAssignmentMapper workAssignmentMapper; |
| | | |
| | | |
| | | private final static String ERP_URL = "http://192.168.2.100:8086"; |
| | | private final static String ERP_URL = "http://192.168.2.100:8086"; |
| | | // private final static String ERP_URL = "http://10.153.19.174:8086"; |
| | | |
| | | |
| | |
| | | log.info("报工数据reportingWork:{},reportingWorkDetails:{}", reportingWork, reportingWorkDetails); |
| | | try { |
| | | // 目标系统的API URL |
| | | |
| | | |
| | | String url1 = ERP_URL + "/reportingWork/mesReportingWork"; |
| | | String url2 = ERP_URL + "/reportingWork/mesSaveReportingWorkWorn"; |
| | | String url; |
| | |
| | | } |
| | | URL obj = new URL(url); |
| | | HttpURLConnection con = (HttpURLConnection) obj.openConnection(); |
| | | |
| | | // 设置请求方法和请求头 |
| | | con.setRequestMethod("POST"); |
| | | con.setRequestProperty("Content-Type", "application/json; utf-8"); |
| | |
| | | |
| | | // 创建 JSON 对象 |
| | | JSONObject result = new JSONObject(); |
| | | |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | // 将 ReportingWork 转换为 JSONObject |
| | | |
| | | // 将 ReportingWorkDetail 列表转换为 JSONArray |
| | |
| | | result.put("qualityInsStatus", 0); |
| | | // 将 result 对象转换为字符串 |
| | | String jsonInputString = result.toString(); |
| | | System.out.println("jsonInputString : " + result); |
| | | log.info("jsonInputString :{} ", result); |
| | | // 发送请求 |
| | | try (OutputStream os = con.getOutputStream()) { |
| | | byte[] input = jsonInputString.getBytes("utf-8"); |
| | |
| | | |
| | | // 获取响应码 |
| | | int responseCode = con.getResponseCode(); |
| | | System.out.println("Response Code : " + responseCode); |
| | | log.info("Response Code :{} ", responseCode); |
| | | |
| | | // 获取响应内容 |
| | | try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))) { |