From b353ca2a8f8a30c48297cbe2502ca52b1a2d3285 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期五, 31 五月 2024 16:43:47 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
---
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java | 125 +++++++++++++++++++++--------------------
1 files changed, 64 insertions(+), 61 deletions(-)
diff --git a/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java
index 4d3f240..a019c7c 100644
--- a/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java
+++ b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/job/PlcLoadGlassTask.java
@@ -1,6 +1,5 @@
package com.mes.job;
-import cn.hutool.json.JSONObject;
import com.mes.common.S7object;
import com.mes.device.PlcParameterObject;
import com.mes.engineering.entity.Engineering;
@@ -24,11 +23,12 @@
@Autowired
private UpWorkstationService upWorkstationService;
@Autowired
- private EngineeringService engineeringService;
+ private EngineeringService engineeringService;
@Autowired
private UpPattenUsageService upPattenUsageService;
PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject;
+
/**
* fixedRate : 涓婁竴涓皟鐢ㄥ紑濮嬪悗鍐嶆璋冪敤鐨勫欢鏃讹紙涓嶇敤绛夊緟涓婁竴娆¤皟鐢ㄥ畬鎴愶級
* fixedDelay : 涓婁竴涓皟鐢ㄧ粨鏉熷悗鍐嶆璋冪敤鐨勫欢鏃�
@@ -37,48 +37,33 @@
@Scheduled(fixedDelay = 300)
public void plcLoadGlassTask() throws InterruptedException {
try {
- log.info("寮�濮嬩笂鐗�");
//鑾峰彇鏄惁鏈変笂鐗囪姹�
String loadRequest = plcParameterObject.getPlcParameter("loadRequest").getValue();
+ String mesToPlc = plcParameterObject.getPlcParameter("MesToPlc").getValue();
//鍒ゆ柇寮�濮嬩笂鐗囩殑宸ョ▼鍙�
- Engineering engineering=engineeringService.selectInitiate(1);
- if("1".equals(loadRequest)&&engineering!=null){
- UpPattenUsage upPattenUsage=upWorkstationService.selectPriority(engineering);
- log.info("褰撴湁璇锋眰鏃舵煡璇㈠綋鍓嶄笂鐗囬『搴忕殑鐜荤拑淇℃伅{}",upPattenUsage);
- UpWorkstation upwork=upWorkstationService.selectworkstation(upPattenUsage);
- log.info("绗﹀悎鐨勫昂瀵哥殑宸ヤ綅鐜荤拑锛歿}",upwork);
- if(upwork!=null){
- int workId=upwork.getWorkstationId();//宸ヤ綅id
- double width=upwork.getPatternWidth();//瀹藉害
- double height=upwork.getPatternHeight();//楂樺害
- S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("WorkId").getAddress(),workId);
- S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("GlassWidth").getAddress(), (long) width);
- S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("GlassHeight").getAddress(), (long) height);
- S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlc").getAddress(),1);
- //鍑忓皯宸ヤ綅鏁伴噺
- upWorkstationService.reduceWorkstationNumber(upwork);
- //瀹屾垚涓婄墖琛ㄧ姸鎬�
- upPattenUsageService.updateupPattenUsageState(upPattenUsage,1);
+ Engineering engineering = engineeringService.selectInitiate(1);
+ if ("1".equals(loadRequest) && engineering != null) {
+ log.info("寮�濮嬩笂鐗囦换鍔�");
+ UpPattenUsage upPattenUsage = upWorkstationService.selectPriority(engineering);
+ log.info("褰撴湁璇锋眰鏃舵煡璇㈠綋鍓嶄笂鐗囬『搴忕殑鐜荤拑淇℃伅{}", upPattenUsage);
+ UpWorkstation upwork = upWorkstationService.selectWorkstation(upPattenUsage);
+ log.info("绗﹀悎鐨勫昂瀵哥殑宸ヤ綅鐜荤拑锛歿}", upwork);
+ if (upwork != null) {
+ int workId = upwork.getWorkstationId();//宸ヤ綅id
+ double width = upwork.getPatternWidth();//瀹藉害
+ double height = upwork.getPatternHeight();//楂樺害
+ S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("WorkId").getAddress(), (short) workId);
+ S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("GlassWidth").getAddress(), (short) width);
+ S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("GlassHeight").getAddress(), (short) height);
+ S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("MesToPlc").getAddress(), (short) 1);
+ //鏇存敼涓婄墖琛ㄧ姸鎬�
+ upPattenUsageService.updateUpPattenUsageState(upPattenUsage, workId);
}
}
- //鑾峰彇鏄惁鏈夋眹鎶�
- String loadStatus = plcParameterObject.getPlcParameter("PlcStatus").getValue();
- if (loadStatus!=null) {
- log.info(loadStatus);
- if ("1".equals(loadStatus)) {
- log.info("鏀跺埌姹囨姤浠诲姟瀹屾垚");
- S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 1);
- } else if ("2".equals(loadStatus)) {
- log.info("鏀跺埌姹囨姤鏈畬鎴愪换鍔�");
- S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 1);
- } else if ("3".equals(loadStatus)) {
- log.info("鏀跺埌姹囨姤鐜荤拑鐮存崯");
- S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 1);
- } else {
- log.info("鏀跺埌姹囨姤娓�0鐘舵��");
- S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 0);
- }
+ if ("1".equals(mesToPlc) && "0".equals(loadRequest)) {
+ //璇锋眰瀛椾负闆舵椂锛屼换鍔″瓧娓呴浂
+ S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlc").getAddress(), 0);
}
//鎵ц鍚庝紤鐪�300姣
//Thread.sleep(300);
@@ -86,28 +71,46 @@
e.printStackTrace();
}
}
-// @Scheduled(fixedDelay = 300)
-// public void plcLoadGlassOver() throws InterruptedException {
-// try {
-// //鑾峰彇鏄惁鏈夋眹鎶�
-// String loadStatus = plcParameterObject.getPlcParameter("PlcStatus").getValue();
-// if ("1".equals(loadStatus)){
-// log.info("鏀跺埌姹囨姤浠诲姟瀹屾垚");
-// S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(),1);
-// }else if ("2".equals(loadStatus)) {
-// log.info("鏀跺埌姹囨姤鏈畬鎴愪换鍔�");
-// S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(),1);
-// }else if("3".equals(loadStatus)){
-// log.info("鏀跺埌姹囨姤鐜荤拑鐮存崯");
-// S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(),1);
-// }else {
-// log.info("鏀跺埌姹囨姤娓�0鐘舵��");
-// S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(),0);
-// }
-//
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// }
+
+ @Scheduled(fixedDelay = 300)
+ public void plcLoadGlassReport() {
+ //鑾峰彇鏄惁鏈夋眹鎶�
+ String loadStatus = plcParameterObject.getPlcParameter("PlcStatus").getValue();
+ if (loadStatus != null) {
+ log.info(loadStatus);
+ switch (loadStatus) {
+ case "1":
+ log.info("鏀跺埌姹囨姤浠诲姟瀹屾垚");
+ S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 1);
+ break;
+ case "2":
+ log.info("鏀跺埌姹囨姤鏈畬鎴愪换鍔�");
+ //鍑忓皯宸ヤ綅鏁伴噺,鎭㈠浠诲姟鐘舵��
+ overTask(loadStatus, 0);
+ break;
+ case "3":
+ log.info("鏀跺埌姹囨姤鐜荤拑鐮存崯");
+ overTask(loadStatus, 0);
+ break;
+ case "0":
+ log.info("鏀跺埌姹囨姤娓�0鐘舵��");
+ //鍑忓皯宸ヤ綅鏁伴噺,瀹屾垚浠诲姟鐘舵��
+ overTask(loadStatus, 100);
+ break;
+ }
+ }
+ }
+
+ public void overTask(String loadStatus, int state) {
+ UpPattenUsage upPattenUsage = upPattenUsageService.selectOverTask();
+ if (upPattenUsage != null) {
+ log.info("鏀跺埌姹囨姤娓厈}鐘舵��", loadStatus);
+ //鍑忓皯宸ヤ綅鏁伴噺
+ upWorkstationService.reduceWorkstationNumber(upPattenUsage.getState());
+ //瀹屾垚涓婄墖琛ㄧ姸鎬�
+ upPattenUsageService.updateUpPattenUsageState(upPattenUsage, state);
+ S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("MesToPlcStatus").getAddress(), 0);
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.8.0