From d5d0d1c7a84b996b9bbcebfaf2c2c95f1a5a3678 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期五, 11 十月 2024 08:39:15 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/test/java/com/mes/CacheVerticalGlassModuleApplicationTest.java | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 111 insertions(+), 3 deletions(-)
diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/test/java/com/mes/CacheVerticalGlassModuleApplicationTest.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/test/java/com/mes/CacheVerticalGlassModuleApplicationTest.java
index d9a451e..dd93257 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/test/java/com/mes/CacheVerticalGlassModuleApplicationTest.java
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/test/java/com/mes/CacheVerticalGlassModuleApplicationTest.java
@@ -1,5 +1,10 @@
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;
@@ -7,7 +12,12 @@
import com.mes.common.config.Const;
import com.mes.damage.entity.Damage;
import com.mes.damage.service.DamageService;
+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.junit.runner.RunWith;
@@ -15,9 +25,14 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+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.time.format.DateTimeFormatter;
+import java.util.*;
/**
* @Author : zhoush
@@ -37,6 +52,8 @@
BigStorageCageDetailsService bigStorageCageDetailsService;
@Autowired
DamageService damageService;
+ @Autowired
+ EdgGlassTaskInfoService edgGlassTaskInfoService;
// @Autowired
// BigStorageCageFeedTaskMapper bigStorageCageFeedTaskMapper;
@@ -167,4 +184,95 @@
plcStorageCageTask.updateOutGlassStateTask();
}
+ @Test
+ public void chaxun(){
+ List<EdgGlassTaskInfo> edgGlassTaskInfoList = edgGlassTaskInfoService.list(new QueryWrapper<EdgGlassTaskInfo>()
+ .select("Top 1 *")
+ .eq("glass_id", "P24072402|1|13")
+ );
+ log.info("鍦ㄥ昂瀵歌〃涓幏鍙栫幓鐠冧俊鎭瘂}", edgGlassTaskInfoList);
+ }
+
+ @Test
+ public void ca(){
+ try {
+ // 鐩爣绯荤粺鐨凙PI URL
+ String url = "http://192.168.3.119:8086/reportingWork/mesSaveReportingWorkWorn";
+ 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);
+
+ // 鍒涘缓 JSON 瀵硅薄
+ JSONObject result = new JSONObject();
+
+ 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("灏忓粬");
+
+ 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");
+ 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();
+ }
+ }
}
--
Gitblit v1.8.0