| | |
| | | import com.mes.edgglasstask.entity.EdgGlassTaskInfo; |
| | | import com.mes.edgglasstask.service.EdgGlassTaskInfoService; |
| | | import com.mes.job.PlcStorageCageTask; |
| | | import com.mes.pp.entity.ReportingWork; |
| | | import com.mes.pp.entity.ReportingWorkDetail; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.junit.Test; |
| | |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.test.context.junit4.SpringRunner; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStreamReader; |
| | | import java.io.OutputStream; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | log.info("在尺寸表中获取玻璃信息{}", edgGlassTaskInfoList); |
| | | } |
| | | |
| | | @Test |
| | | public void ca(){ |
| | | try { |
| | | // 目标系统的API URL |
| | | String url = "http://192.168.3.119:8086/reportingWork/mesSave"; |
| | | URL obj = new URL(url); |
| | | HttpURLConnection con = (HttpURLConnection) obj.openConnection(); |
| | | |
| | | // 设置请求方法和请求头 |
| | | con.setRequestMethod("POST"); |
| | | con.setRequestProperty("Content-Type", "application/json; utf-8"); |
| | | con.setRequestProperty("Accept", "application/json"); |
| | | con.setDoOutput(true); |
| | | |
| | | // 创建消息体 |
| | | String jsonInputString = "小廖"; |
| | | ReportingWork reportingWork=new ReportingWork(); |
| | | reportingWork.setOrderId("NG24042301"); |
| | | reportingWork.setProductionId("NG24042301A"); |
| | | reportingWork.setProcessId("NG24042301A001"); |
| | | reportingWork.setDeviceName("磨边机"); |
| | | reportingWork.setThisProcess("切割"); |
| | | reportingWork.setNextProcess("磨边"); |
| | | reportingWork.setThisCompletedQuantity(1); |
| | | reportingWork.setThisWornQuantity(0); |
| | | reportingWork.setClasses("早班"); |
| | | reportingWork.setReportingWorkTime(LocalDateTime.now()); |
| | | reportingWork.setTeamsGroupsName("小廖一号"); |
| | | reportingWork.setCreator("小廖"); |
| | | |
| | | ReportingWorkDetail reportingWorkDetail=new ReportingWorkDetail(); |
| | | reportingWorkDetail.setTechnologyNumber(1); |
| | | reportingWorkDetail.setOrderNumber(1); |
| | | reportingWorkDetail.setCompletedQuantity(1); |
| | | reportingWorkDetail.setBreakageQuantity(0); |
| | | // 发送请求 |
| | | try (OutputStream os = con.getOutputStream()) { |
| | | byte[] input = jsonInputString.getBytes("utf-8"); |
| | | os.write(input, 0, input.length); |
| | | } |
| | | |
| | | // 获取响应码 |
| | | 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(); |
| | | String inputLine; |
| | | while ((inputLine = in.readLine()) != null) { |
| | | response.append(inputLine); |
| | | } |
| | | System.out.println("Response Body: " + response.toString()); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |