| | |
| | | package com.mes; |
| | | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | |
| | | Damage damage=new Damage(); |
| | | damage.setGlassId("P24060403|3|6"); |
| | | damage.setLine(2001); |
| | | damage.setWorkingProcedure("冷加工"); |
| | | damage.setWorkingProcedure("磨边"); |
| | | damage.setRemark(""); |
| | | damage.setStatus(2); |
| | | damageService.insertDamage(damage); |
| | |
| | | public void ca(){ |
| | | try { |
| | | // 目标系统的API URL |
| | | String url = "http://192.168.3.119:8086/reportingWork/mesSave"; |
| | | String url = "http://192.168.3.119:8086/reportingWork/mesSaveReportingWorkWorn"; |
| | | URL obj = new URL(url); |
| | | HttpURLConnection con = (HttpURLConnection) obj.openConnection(); |
| | | |
| | |
| | | con.setRequestProperty("Accept", "application/json"); |
| | | con.setDoOutput(true); |
| | | |
| | | // 创建消息体 |
| | | String jsonInputString = "小廖"; |
| | | ReportingWork reportingWork=new ReportingWork(); |
| | | // 创建 JSON 对象 |
| | | JSONObject result = new JSONObject(); |
| | | |
| | | ReportingWork reportingWork = new ReportingWork(); |
| | | reportingWork.setOrderId("NG24042301"); |
| | | reportingWork.setProductionId("NG24042301A"); |
| | | reportingWork.setProcessId("NG24042301A001"); |
| | |
| | | reportingWork.setTeamsGroupsName("小廖一号"); |
| | | reportingWork.setCreator("小廖"); |
| | | |
| | | ReportingWorkDetail reportingWorkDetail=new ReportingWorkDetail(); |
| | | List<ReportingWorkDetail> reportingWorkDetails = new ArrayList<>(); |
| | | ReportingWorkDetail reportingWorkDetail = new ReportingWorkDetail(); |
| | | reportingWorkDetail.setTechnologyNumber(1); |
| | | reportingWorkDetail.setOrderNumber(1); |
| | | reportingWorkDetail.setCompletedQuantity(1); |
| | | reportingWorkDetail.setBreakageQuantity(0); |
| | | reportingWorkDetails.add(reportingWorkDetail); |
| | | |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | // 将 ReportingWork 转换为 JSONObject |
| | | JSONObject reportingWorkJson = new JSONObject(objectMapper.writeValueAsString(reportingWork)); |
| | | reportingWorkJson.put("reportingWorkTime", reportingWork.getReportingWorkTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); |
| | | // 将 ReportingWorkDetail 列表转换为 JSONArray |
| | | JSONArray detailsJsonArray = new JSONArray(objectMapper.writeValueAsString(reportingWorkDetails)); |
| | | |
| | | // 将 JSON 对象和数组添加到结果对象中 |
| | | result.put("title", reportingWorkJson); |
| | | result.put("detail", detailsJsonArray); |
| | | result.put("type", 0); |
| | | result.put("userId", "admin"); |
| | | result.put("userName", "admin"); |
| | | result.put("qualityInsStatus", 0); |
| | | |
| | | // 将 result 对象转换为字符串 |
| | | String jsonInputString = result.toString(); |
| | | System.out.println("jsonInputString : " + result); |
| | | // 发送请求 |
| | | try (OutputStream os = con.getOutputStream()) { |
| | | byte[] input = jsonInputString.getBytes("utf-8"); |
| | |
| | | // 获取响应码 |
| | | int responseCode = con.getResponseCode(); |
| | | System.out.println("Response Code : " + responseCode); |
| | | |
| | | // 获取响应内容 |
| | | try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))) { |
| | | StringBuilder response = new StringBuilder(); |