From 58d7b0e12ccd92cf3934f6582b51b5fbcecaa39a Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 09 五月 2024 09:42:41 +0800
Subject: [PATCH] 修改注入方式
---
springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java | 91 ++++++++++++++++++++++++++-------------------
1 files changed, 53 insertions(+), 38 deletions(-)
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
index 662b714..1fc3c55 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
@@ -3,17 +3,16 @@
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.List;
+import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import com.example.springboot.service.JdbcConnections;
import com.example.springboot.service.SpianService;
-
+import com.example.springboot.entity.StorageCage;
import com.example.springboot.entity.north_glass_buffer1;
-import com.example.springboot.mapper.AlarmMapper;
import com.example.springboot.mapper.SpianMapper;
public class PlcHold extends Thread {
- private AlarmMapper alarmMapper;
@Autowired
private JdbcConnections jdbcConnections;
@@ -27,14 +26,9 @@
while (this != null) {
try {
-
- Thread.sleep(100);
- } catch (InterruptedException e) {
- // \\ TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- // if (S7control.getinstance().CheckConnected() == false) {
+ spianService.result=new ArrayList<>();
+ Thread.sleep(300);
+ // if (S7control.getinstance().CheckConnected() == false) {
spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
@@ -42,18 +36,15 @@
// 鏍规嵁鐜荤拑id鑾峰彇璁㈠崟鍙�,鍗曠嫭鏁版嵁婧�
// try {
- // spianService.selectAll(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("X12345610102GV","",""));
-
+ // //spianService.selectAll(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("X12345610102GV","",""));
+ // north_glass_buffer1 aa=jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("X12345610102GV","","");
+ // spianMapper.UpdataAddCage2("123", "123", aa, 5, 1, 9, 2,2000.00);
// } catch (SQLException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
- //spianService.selectout2("X12345610102GV");
-
-
- // 鍑虹墖浠诲姟////////////////////////////////
- //spianService.selectout2("X21942613103GV");
-
+ // spianService.selectout2("X21942610602GV");
+
List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 鍑虹墖杞︾姸鎬�
List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.18", 1); // 鍑虹墖浠诲姟鏄惁鍚姩
@@ -89,14 +80,18 @@
// 褰撴湁寰呭嚭鐗囩殑鐜荤拑鏃�
if (outglassid != null) {
// 鑾峰彇璇ョ幓鐠冩槸鍚﹁绂佺敤
- int glassdisabled = spianMapper.SelectCageGlassState(outglassid);
- // 鏈鐢ㄤ笅鍙戜换鍔�
- if (glassdisabled == 0) {
+ StorageCage glassdisabled = spianMapper.SelectCageGlassState(outglassid);
+ if(glassdisabled!=null){
+ // 鏈鐢ㄤ笅鍙戜换鍔�
+ if (glassdisabled.getDisabled() == 0) {
spianService.selectout2(outglassid);
Plchome.isQueueWarning = false;
} else { // 绂佺敤鏇存敼鐘舵�佸脊鍑烘彁绀�
Plchome.isQueueWarning = true;
+ System.out.println("绂佺敤" + outglassid);
}
+ }
+
}
}
@@ -120,12 +115,15 @@
if (HB > 0) {
// 褰揃01灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬� 涓�1
S7control.getinstance().WriteWord("DB105.48", (short) 1);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负1
- boolean yingda = spianService.listbool("DB105.48");// b01姹囨姤
+ boolean yingda = spianService.listbool("DB105.48");// b01搴旂瓟
if (yingda == true) {
spianService.overtask(B01glassid.toString());// 瀹屾垚浠诲姟
}
- System.out.println("姹囨姤鏃禕01|绗�" + aaa + "娆�" + B01glassid + "搴旂瓟" + yingda);
- aaa += 1;
+ System.out.println("姹囨姤鏃禕01|" + B01glassid + "搴旂瓟" + yingda);
+ Plchome.feedglassid=B01glassid;
+ }else{
+ S7control.getinstance().WriteWord("DB105.48", (short) 1);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负1
+ System.out.println("HB:|" + HB+"glassid|"+B01glassid);
}
}else{
@@ -136,17 +134,19 @@
if (B02backs == true) {
// 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d
int HB = spianMapper.SelectHB(B02glassid.toString());
- System.out.println("姹囨姤鏃禕02|" + B02glassid);
+ System.out.println("huibaoshiB02ID|" + B02glassid);
if (HB > 0) {
// 褰揃02灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬佷负0
-
S7control.getinstance().WriteWord("DB105.50", (short) 1);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负1
- System.out.println("姹囨姤鏃禕02ID|" + B02glassid);
boolean yingda = spianService.listbool("DB105.50");// b02姹囨姤
- if (yingda == true) {
+ if (yingda == true) {
spianService.overtask(B02glassid.toString());// 瀹屾垚浠诲姟
}
- System.out.println("姹囨姤鏃禕02|绗�" + aaa + "娆�" + B02glassid + "搴旂瓟" + yingda);
+ System.out.println("姹囨姤鏃禕02|" + B02glassid + "搴旂瓟" + yingda);
+ Plchome.feedglassid=B01glassid;
+ }else{
+ S7control.getinstance().WriteWord("DB105.50", (short) 1);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负1
+ System.out.println("HB:|" + HB+"glassid|"+B02glassid);
}
}else{
S7control.getinstance().WriteWord("DB105.50", (short) 0);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负0
@@ -159,22 +159,30 @@
StringBuilder queueid2 = spianService.queGlassid("DB103.58", 14);
int questate = spianMapper.Selectquecount(queueid1.toString());// 鍒ゆ柇鎵爜浣嶆槸鍚︽湁鐜荤拑宸茬‘璁�
- // queueid1.toString().isEmpty()
+ //queueid1.toString().isEmpty();
// north_glass_buffer1 glass1 = spianMapper.selectGlass(queueid1.toString());// D01鐨勭幓鐠冧俊鎭�
// north_glass_buffer1 glass2 = spianMapper.selectGlass(queueid2.toString());// D02鐜荤拑淇℃伅
- north_glass_buffer1 glass1=null;
- north_glass_buffer1 glass2=null;
+
+ north_glass_buffer1 glass1 =new north_glass_buffer1();
+ north_glass_buffer1 glass2 =new north_glass_buffer1();
+
try {
- glass1 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queueid1.toString(),"","");// D01鐜荤拑淇℃伅
- glass2 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queueid2.toString(),"","");// D02鐜荤拑淇℃伅
+ if(Plchome.dbconnected==true){
+ if(queueid1.toString()!=""){
+ glass1 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameIdplchold(queueid1.toString(),"","");// D01鐜荤拑淇℃伅
+ }
+ if(queueid2.toString()!=""){
+ glass2 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameIdplchold(queueid2.toString(),"","");// D02鐜荤拑淇℃伅
+ }
+ }
} catch (SQLException e) {
e.printStackTrace();
}
-
+
// 褰撴壂鐮佷綅鐜荤拑id涓虹┖鏃� 瀹藉害涓�0
if (queueid1 != null && questate == 0) {
// 鍐欏叆D01鐨勬暟鎹埌涓婄墖闃熷垪琛�
- if (glass1 == null) { // 褰撴病鏈夊�兼椂浼犵┖
+ if (glass1 == null ||glass1.getordernumber()==null) { // 褰撴病鏈夊�兼椂浼犵┖
spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 1);
} else {
@@ -187,7 +195,7 @@
if (queueid2 != null) {
// 鍐欏叆D02鐨勬暟鎹埌涓婄墖闃熷垪琛�
- if (glass2 == null) {
+ if (glass2 == null ||glass2.getordernumber()==null) {
spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 2);
} else {
spianMapper.Updatequeue(queueid2.toString(), glass2.getordernumber(), glass2.getlistnumber(),
@@ -198,11 +206,18 @@
}
}
+ // System.out.println(spianService.result);
// 鏌ヨ鏁版嵁搴�
// 鎺ㄩ�佸埌鍓嶇
// }
+ } catch (InterruptedException e) {
+ // \\ TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
}
}
--
Gitblit v1.8.0