From 8dfb37b10ffb2fcb41c85b3fa266d1ef2874aebc Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期四, 30 十一月 2023 08:53:27 +0800
Subject: [PATCH] 修改电气管理PLC通讯逻辑
---
springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java | 81 ++++++++++++++++++++++++++++++++--------
1 files changed, 65 insertions(+), 16 deletions(-)
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
index 60f5831..0d53465 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
@@ -1,7 +1,14 @@
package com.example.springboot.component;
import cn.hutool.json.JSONObject;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.example.springboot.entity.Out_slice;
import com.example.springboot.entity.StorageCage;
import com.example.springboot.entity.alarmmg;
import com.example.springboot.entity.north_glass_buffer1;
@@ -11,9 +18,11 @@
public class Plchome extends Thread {
+ @Autowired
private HomeMapper homeMapper;
private SpianMapper spianMapper;
private JdbcConnections dbserve;
+ private JdbcConnections jdbcConnections;
@Override
public void run() {
@@ -28,6 +37,7 @@
// 娉ㄥ叆mapper
homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class);
spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
+ jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
// 绗煎瓙浣跨敤鎯呭喌
List<StorageCage> tableData = homeMapper.selectAll();
jsonObject.append("tableData", tableData);
@@ -44,17 +54,35 @@
List<StorageCage> tasklist1 = homeMapper.selectinout(3);
List<StorageCage> tasklist2 = homeMapper.selectinout(2);
for (StorageCage storageCage : tasklist1) {
- storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
+ // storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
+ try {
+ storageCage.setnorth_glass_buffer1s(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("", "", ""));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ try {
+ storageCage.setnorth_glass_buffer1s(
+ jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(storageCage.getGlassId(), "", ""));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
}
for (StorageCage storageCage : tasklist2) {
- storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
- }
+ // storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
+ try {
+ storageCage.setnorth_glass_buffer1s(
+ jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(storageCage.getGlassId(), "", ""));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
jsonObject.append("tasklist1", tasklist1);
jsonObject.append("tasklist2", tasklist2);
// 鏌ヨ鎶ヨ淇℃伅
List<alarmmg> alarmmg = homeMapper.SelectAlarmmgInfo();
jsonObject.append("alarmmg", alarmmg);
- // // 璇诲幓Plc杩涚墖杞︿笌鍑虹墖杞︿綅缃甒
+ // 璇诲幓Plc杩涚墖杞︿笌鍑虹墖杞︿綅缃甒
// List<String> addressList = new ArrayList<String>();
// addressList.add("DB106.12");
// addressList.add("DB106.0");
@@ -67,7 +95,7 @@
// 1);// 鑾峰彇杩涚墖杞︾姸鎬�
// boolean exist1 = datas1ListState.contains((short) 0);
// jsonObject.append("zhuangtai", exist1);
- // 鑾峰彇杩涚墖鐜荤拑淇℃伅
+ // //鑾峰彇杩涚墖鐜荤拑淇℃伅
// List<Short> inglassInfo = S7control.getinstance().ReadWord("DB106.24", 1);
// if (inglassInfo != null) {
// if (inglassInfo.size() > 0)
@@ -75,22 +103,43 @@
// }
// 浼� 鑾峰彇杩涙槸鍚︽湁寰呯‘璁ょ殑鐜荤拑id
String queid = spianMapper.Selectqueueid();
- String state = spianMapper.Selectqueuestate();
+ int state = spianMapper.Selectqueuestate();
jsonObject.append("queid", queid);
jsonObject.append("state", state);
// 鑾峰彇鎵爜浣嶄笌涓婄墖浣嶇幓鐠冧俊鎭�
String queueglassid2 = homeMapper.GetQueueInfo(2);
String queueglassid1 = homeMapper.GetQueueInfo(1);
- north_glass_buffer1 form2 = homeMapper.SelectGlassByGlassID(queueglassid2);
- north_glass_buffer1 form3 = homeMapper.SelectGlassByGlassID(queueglassid1);
- jsonObject.append("form2", form2);
- jsonObject.append("form3", form3);
- // List<Short> paramlists = new ArrayList<Short>();
- // short para1 = 11111;
- // short para2 = 32000;
- // paramlists.add(para1);
- // paramlists.add(para2);
- // System.out.println(paramlists);
+ // north_glass_buffer1 form2 = homeMapper.SelectGlassByGlassID(queueglassid2);
+ // north_glass_buffer1 form3 = homeMapper.SelectGlassByGlassID(queueglassid1);
+
+ north_glass_buffer1 form2;
+ if(queueglassid2.length()!=0){
+ try {
+ form2 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queueglassid2, "", "");
+ jsonObject.append("form2", form2);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ north_glass_buffer1 form3;
+ if(queueglassid1.length()!=0){
+ try {
+ form3 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queueglassid1, "", "");
+ jsonObject.append("form3", form3);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ // 鑾峰彇鍑虹墖闃熷垪淇℃伅
+ List<Out_slice> listoutslice = homeMapper.SelectProductionqueue();
+ for (Out_slice out_slice : listoutslice) {
+ out_slice.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(out_slice.getGlassId()));
+ out_slice.setstorageCage(homeMapper.SelectStorageGlassById(out_slice.getGlassId()));
+ }
+ jsonObject.append("listoutslice", listoutslice);
dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
boolean dbconnected = false;
--
Gitblit v1.8.0