diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index ae294d5..4c4521c 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -130,6 +130,14 @@
${project.artifactId}
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 9
+ 9
+
+
${project.artifactId}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/schedule/ScheduleThread.java b/ruoyi-admin/src/main/java/com/ruoyi/schedule/ScheduleThread.java
index 28527bb..098ec10 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/schedule/ScheduleThread.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/schedule/ScheduleThread.java
@@ -212,7 +212,7 @@ public class ScheduleThread {
}
if (ddj2CustomThread!=null){
- ddj2CustomThread.thread.setName("ddj5调度线程");
+ ddj2CustomThread.thread.setName("ddj2调度线程");
ddj2CustomThread.thread.start();
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/schedule/scheduleTask/ddj/BaseDdjThread.java b/ruoyi-admin/src/main/java/com/ruoyi/schedule/scheduleTask/ddj/BaseDdjThread.java
index 4f6db19..d09c9e9 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/schedule/scheduleTask/ddj/BaseDdjThread.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/schedule/scheduleTask/ddj/BaseDdjThread.java
@@ -14,6 +14,8 @@ import com.ruoyi.bas.cargospace.service.IBasCargoSpaceService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.domain.SendData;
import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.device.cz.domain.SsjWeightInfo;
+import com.ruoyi.device.cz.service.ISsjWeightInfoService;
import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ddj.service.IMsgDdjService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
@@ -46,6 +48,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
private IMsgDdjService msgDdjService;
private IMydoJobService mydoJobService;
private IBasCargoSpaceService basCargoSpaceService;
+ private ISsjWeightInfoService ssjWeightInfoService;
public Map> roadwayMap = new HashMap<>();
private PlcDdjRead plcDdjRead;
private PlcSsjRead plcSsjRead;
@@ -78,6 +81,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
basCargoSpaceService = SpringUtils.getBean(IBasCargoSpaceService.class);
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
+ ssjWeightInfoService = SpringUtils.getBean(ISsjWeightInfoService.class);
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
}
@@ -86,11 +90,11 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
init();
int i = 0;
while (isRun) {
- for (String type : ddjCodeList.keySet()) {
+ try {
+ for (String type : ddjCodeList.keySet()) {
- for (String ddjCode : ddjCodeList.get(type)) {
- MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
- try {
+ for (String ddjCode : ddjCodeList.get(type)) {
+ MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
if (ObjUtil.isNotNull(msgDdj)) {
generateInBoundPickQueue(msgDdj);
generateInBoundLoadQueue(msgDdj);
@@ -101,21 +105,18 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
} else {
log.error("堆垛机设备为空");
}
- } catch (RuntimeException e) {
- log.error(e.getMessage(), e);
- }
+ }
}
- }
- i++;
- if (i==100){
- log.info("ddj{},循环完成",ddjCodeList);
- i=0;
- }
- try {
+ i++;
+ if (i == 100) {
+ log.info("ddj{},循环完成", ddjCodeList);
+ i = 0;
+ }
+
Thread.sleep(1500);
- } catch (InterruptedException e) {
- log.error(e.getMessage(),e);
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
}
}
@@ -433,6 +434,11 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
String[] split = czDeviceIpPort.split(":");
String weight = CheckWeight.sendWeight(split[0], Convert.toInt(split[1]));
Double aDouble = Convert.toDouble(weight);
+ if (aDouble<40){
+ aDouble = 40d;
+ }
+ SsjWeightInfo ssjWeightInfo = ssjWeightInfoService.selectWeightBySsjCodeAndRwh(taskNo, ssj.getDeviceCode());
+ aDouble = ssjWeightInfo.getWeight().doubleValue();
log.info("取货任务 ddj:{} 任务号:{} 重量:{}",ddj.getId(),taskNo,aDouble);
if (aDouble > 0 && aDouble < 1500) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
@@ -453,7 +459,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
ddjDeviceExecutionQueue.setScsj(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
ddjDeviceExecutionQueue.setMlfs(3);
ddjDeviceExecutionQueue.setSpare1("0");
- ddjDeviceExecutionQueue.setSpare3(Convert.toStr(weight));
+ ddjDeviceExecutionQueue.setSpare3(Convert.toStr(aDouble));
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
} /*else if (aDouble>=1500) {
//写入超重信号
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/schedule/util/CheckWeight.java b/ruoyi-admin/src/main/java/com/ruoyi/schedule/util/CheckWeight.java
index b3d1384..a3cadfb 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/schedule/util/CheckWeight.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/schedule/util/CheckWeight.java
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
+import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Arrays;
import java.util.List;
@@ -12,18 +13,17 @@ import java.util.Map;
public class CheckWeight {
public static String sendWeight(String ip, int por) {
-
String zhi = "0";
- try (
- Socket socket = new Socket(ip, por);
- InputStream is = socket.getInputStream();
- ) {
- // ====================== 【安全清空历史,不会死循环】 ======================
- // 只清空 300ms 内收到的历史数据
- // 时间到立刻停止清空,开始读最新重量
- byte[] clearBuf = new byte[4096];
- long endClearTime = System.currentTimeMillis() + 800; // 最多清300毫秒
+ Socket socket = null;
+ InputStream is = null;
+ try {
+ socket = new Socket();
+ socket.connect(new InetSocketAddress(ip, por), 1000);
+ socket.setSoTimeout(10000);
+ is = socket.getInputStream();
+ byte[] clearBuf = new byte[4096];
+ long endClearTime = System.currentTimeMillis() + 800;
while (System.currentTimeMillis() < endClearTime) {
if (is.available() > 0) {
is.read(clearBuf);
@@ -31,9 +31,7 @@ public class CheckWeight {
Thread.sleep(50);
}
}
- // ========================================================================
- // 清空完成 → 读取最新数据
Thread.sleep(200);
byte[] bytes = new byte[256];
int read = is.read(bytes);
@@ -41,15 +39,31 @@ public class CheckWeight {
String[] weightList = byteArrayToCharArray(bytes, "UTF-8").split("\r\n");
System.out.println(Arrays.toString(weightList));
String weight = getMostFrequentByHutool(weightList);
- weight = weight.replace("=", "").replace("\r", "").replace("\n", "");
-
- if (!weight.equals("0000000")) {
- zhi = weight;
+ if (weight != null) {
+ weight = weight.replace("=", "").replace("\r", "").replace("\n", "");
+ if (!weight.equals("0000000")) {
+ zhi = weight;
+ }
}
}
-
} catch (Exception e) {
e.printStackTrace();
+ } finally {
+ // finally手动关闭流和socket
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (Exception ignored) {
+ ignored.printStackTrace();
+ }
+ try {
+ if (socket != null) {
+ socket.close();
+ }
+ } catch (Exception ignored) {
+ ignored.printStackTrace();
+ }
}
return zhi;
}
diff --git a/ruoyi-admin/src/main/resources/mapper/queue/DdjDeviceExecutionQueueMapper.xml b/ruoyi-admin/src/main/resources/mapper/queue/DdjDeviceExecutionQueueMapper.xml
index e559c72..6d8513f 100644
--- a/ruoyi-admin/src/main/resources/mapper/queue/DdjDeviceExecutionQueueMapper.xml
+++ b/ruoyi-admin/src/main/resources/mapper/queue/DdjDeviceExecutionQueueMapper.xml
@@ -84,10 +84,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where rwh = #{rwh} and dev_id = #{devId}
-
-