fix(schedule): 修复重量读取逻辑及配置更新
- 更新Redis和数据库地址 - 优化重量秤数据读取与资源关闭 - 使用数据库重量并处理低于40kg的默认值 - 修复调度线程命名及查询返回类型
This commit is contained in:
@@ -130,6 +130,14 @@
|
|||||||
<warName>${project.artifactId}</warName>
|
<warName>${project.artifactId}</warName>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>9</source>
|
||||||
|
<target>9</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public class ScheduleThread {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (ddj2CustomThread!=null){
|
if (ddj2CustomThread!=null){
|
||||||
ddj2CustomThread.thread.setName("ddj5调度线程");
|
ddj2CustomThread.thread.setName("ddj2调度线程");
|
||||||
ddj2CustomThread.thread.start();
|
ddj2CustomThread.thread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import com.ruoyi.bas.cargospace.service.IBasCargoSpaceService;
|
|||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.domain.SendData;
|
import com.ruoyi.common.domain.SendData;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
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.domain.MsgDdj;
|
||||||
import com.ruoyi.device.ddj.service.IMsgDdjService;
|
import com.ruoyi.device.ddj.service.IMsgDdjService;
|
||||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||||
@@ -46,6 +48,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
private IMsgDdjService msgDdjService;
|
private IMsgDdjService msgDdjService;
|
||||||
private IMydoJobService mydoJobService;
|
private IMydoJobService mydoJobService;
|
||||||
private IBasCargoSpaceService basCargoSpaceService;
|
private IBasCargoSpaceService basCargoSpaceService;
|
||||||
|
private ISsjWeightInfoService ssjWeightInfoService;
|
||||||
public Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
public Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||||
private PlcDdjRead plcDdjRead;
|
private PlcDdjRead plcDdjRead;
|
||||||
private PlcSsjRead plcSsjRead;
|
private PlcSsjRead plcSsjRead;
|
||||||
@@ -78,6 +81,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
basCargoSpaceService = SpringUtils.getBean(IBasCargoSpaceService.class);
|
basCargoSpaceService = SpringUtils.getBean(IBasCargoSpaceService.class);
|
||||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||||
|
ssjWeightInfoService = SpringUtils.getBean(ISsjWeightInfoService.class);
|
||||||
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
|
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,11 +90,11 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
init();
|
init();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (isRun) {
|
while (isRun) {
|
||||||
|
try {
|
||||||
for (String type : ddjCodeList.keySet()) {
|
for (String type : ddjCodeList.keySet()) {
|
||||||
|
|
||||||
for (String ddjCode : ddjCodeList.get(type)) {
|
for (String ddjCode : ddjCodeList.get(type)) {
|
||||||
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
|
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
|
||||||
try {
|
|
||||||
if (ObjUtil.isNotNull(msgDdj)) {
|
if (ObjUtil.isNotNull(msgDdj)) {
|
||||||
generateInBoundPickQueue(msgDdj);
|
generateInBoundPickQueue(msgDdj);
|
||||||
generateInBoundLoadQueue(msgDdj);
|
generateInBoundLoadQueue(msgDdj);
|
||||||
@@ -101,9 +105,6 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
} else {
|
} else {
|
||||||
log.error("堆垛机设备为空");
|
log.error("堆垛机设备为空");
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,9 +113,9 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
log.info("ddj{},循环完成", ddjCodeList);
|
log.info("ddj{},循环完成", ddjCodeList);
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
Thread.sleep(1500);
|
Thread.sleep(1500);
|
||||||
} catch (InterruptedException e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,6 +434,11 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
String[] split = czDeviceIpPort.split(":");
|
String[] split = czDeviceIpPort.split(":");
|
||||||
String weight = CheckWeight.sendWeight(split[0], Convert.toInt(split[1]));
|
String weight = CheckWeight.sendWeight(split[0], Convert.toInt(split[1]));
|
||||||
Double aDouble = Convert.toDouble(weight);
|
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);
|
log.info("取货任务 ddj:{} 任务号:{} 重量:{}",ddj.getId(),taskNo,aDouble);
|
||||||
if (aDouble > 0 && aDouble < 1500) {
|
if (aDouble > 0 && aDouble < 1500) {
|
||||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
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.setScsj(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||||
ddjDeviceExecutionQueue.setMlfs(3);
|
ddjDeviceExecutionQueue.setMlfs(3);
|
||||||
ddjDeviceExecutionQueue.setSpare1("0");
|
ddjDeviceExecutionQueue.setSpare1("0");
|
||||||
ddjDeviceExecutionQueue.setSpare3(Convert.toStr(weight));
|
ddjDeviceExecutionQueue.setSpare3(Convert.toStr(aDouble));
|
||||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||||
} /*else if (aDouble>=1500) {
|
} /*else if (aDouble>=1500) {
|
||||||
//写入超重信号
|
//写入超重信号
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -12,18 +13,17 @@ import java.util.Map;
|
|||||||
public class CheckWeight {
|
public class CheckWeight {
|
||||||
|
|
||||||
public static String sendWeight(String ip, int por) {
|
public static String sendWeight(String ip, int por) {
|
||||||
|
|
||||||
String zhi = "0";
|
String zhi = "0";
|
||||||
try (
|
Socket socket = null;
|
||||||
Socket socket = new Socket(ip, por);
|
InputStream is = null;
|
||||||
InputStream is = socket.getInputStream();
|
try {
|
||||||
) {
|
socket = new Socket();
|
||||||
// ====================== 【安全清空历史,不会死循环】 ======================
|
socket.connect(new InetSocketAddress(ip, por), 1000);
|
||||||
// 只清空 300ms 内收到的历史数据
|
socket.setSoTimeout(10000);
|
||||||
// 时间到立刻停止清空,开始读最新重量
|
is = socket.getInputStream();
|
||||||
byte[] clearBuf = new byte[4096];
|
|
||||||
long endClearTime = System.currentTimeMillis() + 800; // 最多清300毫秒
|
|
||||||
|
|
||||||
|
byte[] clearBuf = new byte[4096];
|
||||||
|
long endClearTime = System.currentTimeMillis() + 800;
|
||||||
while (System.currentTimeMillis() < endClearTime) {
|
while (System.currentTimeMillis() < endClearTime) {
|
||||||
if (is.available() > 0) {
|
if (is.available() > 0) {
|
||||||
is.read(clearBuf);
|
is.read(clearBuf);
|
||||||
@@ -31,9 +31,7 @@ public class CheckWeight {
|
|||||||
Thread.sleep(50);
|
Thread.sleep(50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ========================================================================
|
|
||||||
|
|
||||||
// 清空完成 → 读取最新数据
|
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
byte[] bytes = new byte[256];
|
byte[] bytes = new byte[256];
|
||||||
int read = is.read(bytes);
|
int read = is.read(bytes);
|
||||||
@@ -41,15 +39,31 @@ public class CheckWeight {
|
|||||||
String[] weightList = byteArrayToCharArray(bytes, "UTF-8").split("\r\n");
|
String[] weightList = byteArrayToCharArray(bytes, "UTF-8").split("\r\n");
|
||||||
System.out.println(Arrays.toString(weightList));
|
System.out.println(Arrays.toString(weightList));
|
||||||
String weight = getMostFrequentByHutool(weightList);
|
String weight = getMostFrequentByHutool(weightList);
|
||||||
|
if (weight != null) {
|
||||||
weight = weight.replace("=", "").replace("\r", "").replace("\n", "");
|
weight = weight.replace("=", "").replace("\r", "").replace("\n", "");
|
||||||
|
|
||||||
if (!weight.equals("0000000")) {
|
if (!weight.equals("0000000")) {
|
||||||
zhi = weight;
|
zhi = weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
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;
|
return zhi;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,9 +84,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<include refid="selectDdjDeviceExecutionQueueVo"/>
|
<include refid="selectDdjDeviceExecutionQueueVo"/>
|
||||||
where rwh = #{rwh} and dev_id = #{devId}
|
where rwh = #{rwh} and dev_id = #{devId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectOutJobCount" resultType="java.lang.Integer">
|
||||||
<select id="selectOutJobCount">
|
select count(*)
|
||||||
select count(*) from ddj_device_execution_queue
|
from ddj_device_execution_queue
|
||||||
where spare2 = #{spare2}
|
where spare2 = #{spare2}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user