From 9a6fa65287fab1bb45e3bec03c567380f1a880ed Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期三, 08 五月 2024 10:35:06 +0800
Subject: [PATCH] 卧式理片笼线程改造
---
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java | 206 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 206 insertions(+), 0 deletions(-)
diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java
new file mode 100644
index 0000000..cb8a805
--- /dev/null
+++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java
@@ -0,0 +1,206 @@
+package com.mes.job;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.json.JSONObject;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.mes.common.S7object;
+import com.mes.common.WebSocketServer;
+import com.mes.edgstoragecage.entity.EdgStorageCage;
+import com.mes.edgstoragecage.entity.EdgStorageCageDetails;
+import com.mes.edgstoragecage.mapper.EdgStorageCageDetailsMapper;
+import com.mes.edgstoragecage.service.EdgStorageCageDetailsService;
+import com.mes.edgstoragecage.service.EdgStorageCageService;
+import com.mes.glassinfo.entity.GlassInfo;
+import com.mes.glassinfo.service.GlassInfoService;
+import com.mes.taskcache.entity.TaskCache;
+import com.mes.taskcache.service.TaskCacheService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author : zhoush
+ * @Date: 2024/5/8 8:17
+ * @Description:
+ */
+@Component
+@Slf4j
+public class CacheGlassTask {
+
+ @Autowired
+ TaskCacheService taskCacheService;
+ @Autowired
+ GlassInfoService glassInfoService;
+ @Autowired
+ EdgStorageCageService edgStorageCageService;
+ @Autowired
+ EdgStorageCageDetailsService edgStorageCageDetailsService;
+ @Resource
+ private EdgStorageCageDetailsMapper edgStorageCageDetailsMapper;
+
+ private Map<String, String> mapParameter = new HashMap<>();
+ private Map<String, String> mapValue = new HashMap<>();
+ private Map<String, String> mapType = new HashMap<>();
+ private Map<String, Object> mapSettings = new HashMap<>();
+
+ @Scheduled(fixedDelay = 1000)
+ public void plcHomeEdgTask() {
+ initialize();
+ log.info("褰撳墠鍙傛暟鍊硷細{}", mapValue);
+ JSONObject jsonObject = new JSONObject();
+// for (String key : mapParameter.keySet()) {
+// String value = "";
+// if ("String".equals(mapType.get(key))) {
+// value = S7object.getinstance().plccontrol.readString(mapParameter.get(key));
+// } else {
+// value = S7object.getinstance().plccontrol.readWord(mapParameter.get(key)) + "";
+// }
+// mapValue.put(key, value);
+// }
+
+ if ("0".equals(mapValue.get("A06_request_word"))) {
+ log.info("鑾峰彇鍒扮殑璇锋眰瀛椾负0锛屽皢纭瀛楁敼涓�0");
+ //娓呴櫎
+ S7object.getinstance().plccontrol.WriteWord(mapParameter.get("MES_confirmation_word"), (short) 0);
+ } else if ("1".equals(mapValue.get("A06_request_word")) &&
+ "0".equals(mapValue.get("MES_confirmation_word"))) {
+ log.info("杩涚墖璇锋眰锛屼笖纭瀛椾负0锛屾墽琛岃繘鐗囦换鍔�");
+ inTo();
+ } else if ("2".equals(mapValue.get("A06_request_word")) &&
+ "0".equals(mapValue.get("MES_confirmation_word")) && !"0".equals(mapValue.get("A09_glass_status"))) {
+ //09绌洪棽 锛�1 10绌洪棽 锛�2 閮界┖闂诧細3 鍏朵粬0
+ log.info("鍑虹墖璇锋眰锛屼笖纭瀛椾负0锛屾墽琛岃繘鐗囦换鍔�");
+ outTo(Integer.parseInt(mapValue.get("A09_glass_status")));
+ } else if ("3".equals(mapValue.get("A06_request_word")) &&
+ "0".equals(mapValue.get("MES_confirmation_word"))) {
+
+ if ("0".equals(mapValue.get("A09_glass_status")) || "0".equals(mapValue.get("A10_glass_status"))) {
+ outTo(Integer.parseInt(mapValue.get("A09_glass_status")));
+ } else {
+ inTo();
+ }
+ }
+// log.info("鎺ㄦ暟鎹�");
+ // jsonObject.append("params", new short[] { 30, 40, });
+ ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Home");
+ if (sendwServer != null) {
+ for (WebSocketServer webserver : sendwServer) {
+ webserver.sendMessage(jsonObject.toString());
+ if (webserver != null) {
+
+ List<String> messages = webserver.getMessages();
+
+ if (!messages.isEmpty()) {
+ // // 灏嗘渶鍚庝竴涓秷鎭浆鎹负鏁存暟绫诲瀷鐨勫垪琛�
+ webserver.clearMessages();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * 鍒濆鍖杙lc鏁版嵁
+ */
+ private void initialize() {
+// mapParameter.put("A06_request_word", "DB11.0"); //work
+// mapParameter.put("A05_scanning_ID", "DB11.2");
+// mapParameter.put("MES_confirmation_word", "DB11.40");
+// mapParameter.put("A09_glass_status", "DB11.70");
+// //mapParameter.put("A10_glass_status", "DB11.72");
+// mapParameter.put("A09_prohibit_film_production", "DB11.74");
+// mapParameter.put("A10_prohibit_film_production", "DB11.76");
+// mapSettings.put("territoryPoor", 3);
+// mapType.put("A06_request_word", "Word");
+// mapType.put("A05_scanning_ID", "String");
+// mapType.put("MES_confirmation_word", "Word");
+// mapType.put("A09_glass_status", "Word");
+// //mapType.put("A10_glass_status", "Word");
+// mapType.put("A09_prohibit_film_production", "Word");
+// mapType.put("A10_prohibit_film_production", "Word");
+ mapValue.put("A06_request_word", "2");//璇锋眰瀛�
+ mapValue.put("A05_scanning_ID", "11111111111");//璇锋眰ID
+ mapValue.put("MES_confirmation_word", "0");//MES鍙戦�佸瓧
+ mapValue.put("A09_glass_status", "1");//A09鐜荤拑鐘舵��
+ mapValue.put("A10_glass_status", "0");//A09鐜荤拑鐘舵��
+ mapValue.put("A09_prohibit_film_production", "0");//A9绂佹鍑虹墖
+ mapValue.put("A10_prohibit_film_production", "0");//A10绂佹鍑虹墖
+
+ }
+
+ private void inTo() {
+ List<GlassInfo> glassInfos = glassInfoService.selectId(mapValue.get("A05_scanning_ID"));
+ if (glassInfos.size() < 1) {
+ log.info("姝ょ幓鐠冪紪鍙蜂笉瀛樺湪");
+ } else if (glassInfos.size() == 1) {
+ //娣诲姞杩涚墖浠诲姟 鏌ユ壘绌烘牸
+ log.info("姝e父");
+ List<EdgStorageCage> list = edgStorageCageService.selectCacheEmpty();
+
+ if (list.size() > 1) {
+ EdgStorageCageDetails edgStorageCageDetails = edgStorageCageDetailsMapper.selectOne(new MPJLambdaWrapper<EdgStorageCageDetails>()
+ .eq(EdgStorageCageDetails::getGlassId, glassInfos.get(0).getGlassId()));
+ edgStorageCageDetails.setState(200);
+
+ TaskCache taskCache = new TaskCache();
+ EdgStorageCage edgStorageCage = list.get(0);
+ taskCache.setGlassId(glassInfos.get(0).getGlassId());
+ taskCache.setTaskStatus(0);
+ taskCache.setStartCell(0);
+ taskCache.setEndCell(edgStorageCage.getSlot());
+ taskCache.setTaskType(1);
+ taskCache.setCreateTime(new DateTime());
+ edgStorageCageDetailsMapper.updateById(edgStorageCageDetails);
+ taskCacheService.insertTaskCache(taskCache);
+// S7object.getinstance().plccontrol.WriteWord("DB11.40", (short) 1);
+ } else {
+ log.info("涓嶅瓨鍦ㄧ┖鏍�");
+ }
+ } else {
+ log.info("姝ょ幓鐠冪紪鍙峰瓨鍦ㄥ涓�");
+ }
+ }
+
+ private void outTo(int line) {
+ int endcell = 0;
+ EdgStorageCageDetails outEdgStorageCageDetails = new EdgStorageCageDetails();
+ TaskCache taskCacheA09 = taskCacheService.selectLastOutCacheInfo("");
+ TaskCache taskCacheA10 = taskCacheService.selectLastOutCacheInfo("");
+ //涓ょ嚎鍚勮嚜瑕佸嚭鐨勭幓鐠�
+ EdgStorageCageDetails glassInfo09 = edgStorageCageDetailsService.selectConformGlass(taskCacheA09.getGlassId(), (int) mapSettings.get("territoryPoor"));
+ EdgStorageCageDetails glassInfo10 = edgStorageCageDetailsService.selectConformGlass(taskCacheA10.getGlassId(), (int) mapSettings.get("territoryPoor"));
+ //鍐冲畾绾胯矾
+ if (line == 1) {
+ endcell = 9000;
+ outEdgStorageCageDetails = glassInfo09;
+ } else if (line == 2) {
+ endcell = 1000;
+ outEdgStorageCageDetails = glassInfo10;
+ } else if (line == 3) {
+ endcell = 9000;//榛樿璧颁竴鍙风嚎 浼樺寲鏂瑰悜鍙牴鎹� 瀵规瘮涓ょ嚎閫熷害/涓ょ嚎褰撳墠浠诲姟鎯呭喌鍋�
+ outEdgStorageCageDetails = glassInfo09;
+ }
+ if (outEdgStorageCageDetails != null && endcell > 0) {
+ TaskCache taskCache = new TaskCache();
+ taskCache.setGlassId(outEdgStorageCageDetails.getGlassId());
+ taskCache.setTaskStatus(0);
+ taskCache.setStartCell(outEdgStorageCageDetails.getSlot());
+ taskCache.setEndCell(endcell);
+ taskCache.setTaskType(2);
+ taskCache.setCreateTime(new DateTime());
+ taskCacheService.insertTaskCache(taskCache);
+// S7object.getinstance().plccontrol.WriteWord(mapParameter.get("MES_confirmation_word"), (short) 1);
+ }
+
+
+ }
+
+
+}
--
Gitblit v1.8.0