From ac84757be7543e3094f0c4fb882c0ffcbbc2e378 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期二, 07 五月 2024 21:53:22 +0800
Subject: [PATCH] 联调修改
---
hangzhoumesParent/common/servicebase/src/main/java/com/mes/tools/S7control.java | 22 ++++-
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcHomeEdg.java | 199 +++++++++++++++++++++----------------------------
2 files changed, 103 insertions(+), 118 deletions(-)
diff --git a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/tools/S7control.java b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/tools/S7control.java
index c65d8a6..0b206d5 100644
--- a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/tools/S7control.java
+++ b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/tools/S7control.java
@@ -273,21 +273,18 @@
return result;
}
+
//璇诲彇瀛楃涓�
public String readString(String address) {
if (s7PLC == null) {
return null;
}
try {
- byte[] bytes = s7PLC.readByte(address, 14);
- if (bytes != null) {
- return new String(bytes, StandardCharsets.UTF_8);
- }
+ return s7PLC.readString(address);
} catch (Exception e) {
System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
return null;
}
- return null;
}
@@ -346,6 +343,21 @@
return data;
}
+ //璇诲彇鍗曚釜word
+ public Short readWord(String address) {
+ if (s7PLC == null) {
+ return null;
+ }
+ try {
+ // 鍗曚釜鍦板潃
+ return s7PLC.readInt16(address);
+ } catch (Exception e) {
+ System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+
+ }
+ return -1;
+ }
+
//璇诲彇鏃堕棿
public Long readtime(String address) {
if (s7PLC == null) {
diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcHomeEdg.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcHomeEdg.java
index 4251046..5c0a7ab 100644
--- a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcHomeEdg.java
+++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcHomeEdg.java
@@ -1,7 +1,7 @@
package com.mes.common;
+
import cn.hutool.core.date.DateTime;
import cn.hutool.json.JSONObject;
-import com.github.yulichang.query.MPJLambdaQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.mes.edgstoragecage.entity.EdgStorageCage;
import com.mes.edgstoragecage.entity.EdgStorageCageDetails;
@@ -11,7 +11,6 @@
import com.mes.glassinfo.entity.GlassInfo;
import com.mes.glassinfo.service.GlassInfoService;
import com.mes.taskcache.entity.TaskCache;
-import com.mes.taskcache.mapper.TaskCacheMapper;
import com.mes.taskcache.service.TaskCacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +26,6 @@
public class PlcHomeEdg extends Thread {
-
@Autowired
TaskCacheService taskCacheService;
@Autowired
@@ -39,21 +37,28 @@
@Autowired
private EdgStorageCageDetailsMapper edgStorageCageDetailsMapper;
- private Map<String,String> mapParameter=new HashMap<String,String>();
- private Map<String,String> mapValue=new HashMap<String,String>();
- private Map<String,Object> mapSettings=new HashMap<String,Object>();
+ private Map<String, String> mapParameter = new HashMap<String, String>();
+ private Map<String, String> mapValue = new HashMap<String, String>();
+ private Map<String, String> mapType = new HashMap<String, String>();
+ private Map<String, Object> mapSettings = new HashMap<String, Object>();
- private void initialize(){
- mapParameter.put("A06_request_word","DB11.0");
- 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);
-
+ 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","1");//璇锋眰瀛�
// mapValue.put("A05_scanning_ID","7");//璇锋眰ID
// mapValue.put("MES_confirmation_word","0");//MES鍙戦�佸瓧
@@ -61,27 +66,25 @@
// mapValue.put("A10_glass_status","0");//A09鐜荤拑鐘舵��
// mapValue.put("A09_prohibit_film_production","0");//A9绂佹鍑虹墖
// mapValue.put("A10_prohibit_film_production","0");//A10绂佹鍑虹墖
- for (String key:mapParameter.keySet()){
- String value=S7object.getinstance().plccontrol.readString(mapParameter.get(key));
- mapValue.put(key,value);
- }
+
}
- private void inTo(){
- List<GlassInfo> glassInfos=glassInfoService.selectId(mapValue.get("A05_scanning_ID"));
- if(glassInfos.size()<1){
+
+ private void inTo() {
+ List<GlassInfo> glassInfos = glassInfoService.selectId(mapValue.get("A05_scanning_ID"));
+ if (glassInfos.size() < 1) {
log.info("姝ょ幓鐠冪紪鍙蜂笉瀛樺湪");
- }else if(glassInfos.size()==1){
+ } else if (glassInfos.size() == 1) {
//娣诲姞杩涚墖浠诲姟 鏌ユ壘绌烘牸
log.info("姝e父");
- List<EdgStorageCage> list=edgStorageCageService.selectCacheEmpty();
+ List<EdgStorageCage> list = edgStorageCageService.selectCacheEmpty();
- if(list.size()>1){
- EdgStorageCageDetails edgStorageCageDetails=edgStorageCageDetailsMapper.selectOne(new MPJLambdaWrapper<EdgStorageCageDetails>()
- .eq(EdgStorageCageDetails::getGlassId,glassInfos.get(0).getGlassId()));
+ 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 taskCache = new TaskCache();
+ EdgStorageCage edgStorageCage = list.get(0);
taskCache.setGlassId(glassInfos.get(0).getGlassId());
taskCache.setTaskStatus(0);
taskCache.setStartCell(0);
@@ -90,34 +93,35 @@
taskCache.setCreateTime(new DateTime());
edgStorageCageDetailsMapper.updateById(edgStorageCageDetails);
taskCacheService.insertTaskCache(taskCache);
- }else{
+ } else {
log.info("涓嶅瓨鍦ㄧ┖鏍�");
}
- }else{
+ } else {
log.info("姝ょ幓鐠冪紪鍙峰瓨鍦ㄥ涓�");
}
}
- private void outTo(int line){
- int endcell=0;
- EdgStorageCageDetails outEdgStorageCageDetails=new EdgStorageCageDetails();
- TaskCache taskCacheA09=taskCacheService.selectLastOutCacheInfo("");
- TaskCache taskCacheA10=taskCacheService.selectLastOutCacheInfo("");
+
+ 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"));
+ 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 (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();
+ if (outEdgStorageCageDetails != null && endcell > 0) {
+ TaskCache taskCache = new TaskCache();
taskCache.setGlassId(outEdgStorageCageDetails.getGlassId());
taskCache.setTaskStatus(0);
taskCache.setStartCell(outEdgStorageCageDetails.getSlot());
@@ -128,83 +132,52 @@
}
-
-
}
+
@Override
public void run() {
- boolean start=true;
- while (this != null&&start) {
+ boolean start = true;
+ initialize();
+ log.info("褰撳墠鍙傛暟鍊硷細{}", mapValue);
+ while (this != null && start) {
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);
+ }
try {
Thread.sleep(1000);
- taskCacheService = WebSocketServer.applicationContext.getBean(TaskCacheService.class);
- glassInfoService = WebSocketServer.applicationContext.getBean(GlassInfoService.class);
- edgStorageCageService = WebSocketServer.applicationContext.getBean(EdgStorageCageService.class);
- edgStorageCageDetailsMapper = WebSocketServer.applicationContext.getBean(EdgStorageCageDetailsMapper.class);
- initialize();//鍒濆鍖栨暟鎹�
- log.info("褰撳墠鍙傛暟鍊硷細{}",mapValue);
- if("0".equals(mapValue.get("A06_request_word"))){
+ taskCacheService = WebSocketServer.applicationContext.getBean(TaskCacheService.class);
+ glassInfoService = WebSocketServer.applicationContext.getBean(GlassInfoService.class);
+ edgStorageCageService = WebSocketServer.applicationContext.getBean(EdgStorageCageService.class);
+ edgStorageCageDetailsMapper = WebSocketServer.applicationContext.getBean(EdgStorageCageDetailsMapper.class);
+// initialize();//鍒濆鍖栨暟鎹�
+ if ("0".equals(mapValue.get("A06_request_word"))) {
//娓呴櫎
- //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")))
- {
+ 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"))) {
inTo();
- }else if("2".equals(mapValue.get("A06_request_word"))&&
- "0".equals(mapValue.get("MES_confirmation_word"))&&
- (
- "0".equals(mapValue.get("A09_glass_status"))||
- "0".equals(mapValue.get("A10_glass_status"))
- )
- ){
+ } 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
+ outTo(Integer.parseInt(mapValue.get("A09_glass_status")));
+ } else if ("3".equals(mapValue.get("A06_request_word")) &&
+ "0".equals(mapValue.get("MES_confirmation_word"))) {
- outTo(3);
- }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(3);
- }else{
+ 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();
}
}
-
-// List<String> address2=new ArrayList<String>();
-// address.add("");
-// List<String> list2= S7object.getinstance().plccontrol.readStrings(address);
-// PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
-// log.info("plcmes:{}",plcmes);
-// S7object.getinstance().plccontrol.WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1);
-
-// taskCacheMapper = WebSocketServer.applicationContext.getBean(TaskCacheMapper.class);
-// List<TaskCache> list=taskCacheMapper.selectList(null);
-// log.info("鏁版嵁{}",list);
- // 娉ㄥ叆mapper
-// HomeService = WebSocketServer.applicationContext.getBean(HomeService.class);
-// QueueMapper = WebSocketServer.applicationContext.getBean(QueueMapper.class);
-
-
-// //璇诲彇DB105鍖烘枃浠�
-// PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
-//
-// String PlcRequest=plcmes.getPlcParameter("GaToMES").getValue();//璇锋眰
-// String MesSend=plcmes.getPlcParameter("MESToGaStatus").getValue();//鍙戦��
-// double width=Double.valueOf(plcmes.getPlcParameter("width").getValue());//瀹�
-// double height=Double.valueOf(plcmes.getPlcParameter("Height").getValue());//楂�
-
- //鑾峰彇娴嬮噺鐨勯暱锛屽
- boolean istest = true;
- // String PlcRequest = "1";
- // String MesSend = "0";
- // double width = 516;
- // double height = 507;
- //System.out.println(111);
- // //鏌ヨ褰撳墠璁㈠崟浠诲姟
- //List<FlowCard> OrderTask = storageCageService.SelectOrderTask();
- //jsonObject.append("OrderTask", OrderTask);
} catch (InterruptedException e) {
e.printStackTrace();
--
Gitblit v1.8.0