Compare commits

...

7 Commits

Author SHA1 Message Date
刘汗青
52772494d4 fix(schedule): 修复重量读取逻辑及配置更新
- 更新Redis和数据库地址
- 优化重量秤数据读取与资源关闭
- 使用数据库重量并处理低于40kg的默认值
- 修复调度线程命名及查询返回类型
2026-08-31 10:31:46 +08:00
刘汗青
2272a89b2a 添加现场存活日志校验 2026-05-18 15:21:26 +08:00
刘汗青
b4ed427de9 修改出库任务优先级 2026-05-13 14:30:55 +08:00
liuhanqing
8e60b8e9c1 现场调度修改 2026-04-29 10:42:40 +08:00
liuhanqing
f2e0c086eb 现场调度修改 2026-04-13 16:48:37 +08:00
liuhanqing
c85e53ac1d 现场调度修改 2026-04-02 09:13:03 +08:00
liuhanqing
9938ca3a41 现场调度修改 2026-04-02 09:10:58 +08:00
15 changed files with 416 additions and 256 deletions

View File

@@ -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>

View File

@@ -17,5 +17,6 @@ public class ReceiveJob {
private String jobId; private String jobId;
private String roadwayId; private String roadwayId;
private String warehouseId; private String warehouseId;
private Long priority;
} }

View File

@@ -368,6 +368,7 @@ public class ApiServiceImpl implements IApiService {
mydoJob.setCreateTime(DateUtils.getNowDate()); mydoJob.setCreateTime(DateUtils.getNowDate());
mydoJob.setExecutionPhase("0"); mydoJob.setExecutionPhase("0");
mydoJob.setWarehouseId(receiveOutJob.getWarehouseId()); mydoJob.setWarehouseId(receiveOutJob.getWarehouseId());
mydoJob.setPriority(receiveOutJob.getPriority());
int i = mydoJobService.insertMydoJob(mydoJob); int i = mydoJobService.insertMydoJob(mydoJob);
if (i > 0) { if (i > 0) {
return AjaxResult.success(); return AjaxResult.success();

View File

@@ -182,6 +182,40 @@ public class MydoJobServiceImpl implements IMydoJobService
@Override @Override
public Map<String, List<MydoJobScreen>> selectJobListByWarehouseIdAndType(String warehouseId, String type) { public Map<String, List<MydoJobScreen>> selectJobListByWarehouseIdAndType(String warehouseId, String type) {
Map<String, List<MydoJobScreen>> map = new HashMap<>(); Map<String, List<MydoJobScreen>> map = new HashMap<>();
if ("01".equals(warehouseId)){
map.put("1",new ArrayList<>());
map.put("2",new ArrayList<>());
map.put("3",new ArrayList<>());
MydoJob outParam = new MydoJob();
outParam.setWarehouseId(warehouseId);
outParam.setExitId(type);
List<MydoJobScreen> outMydoJobs = mydoJobMapper.selectJobListByWarehouseIdAndType(outParam);
if (CollUtil.isNotEmpty(outMydoJobs)){
Map<String, List<MydoJobScreen>> collect = outMydoJobs.stream().collect(Collectors.groupingBy(MydoJobScreen::getRoadwayId));
for (String roadwayId : collect.keySet()) {
if (map.containsKey(roadwayId)){
List<MydoJobScreen> mydoJobs = map.get(roadwayId);
mydoJobs.addAll(collect.get(roadwayId));
map.put(roadwayId,mydoJobs);
}
}
}
MydoJob inParam = new MydoJob();
inParam.setWarehouseId(warehouseId);
inParam.setEntranceId(type);
List<MydoJobScreen> inMydoJobs = mydoJobMapper.selectJobListByWarehouseIdAndType(inParam);
if (CollUtil.isNotEmpty(inMydoJobs)) {
Map<String, List<MydoJobScreen>> collect = inMydoJobs.stream().collect(Collectors.groupingBy(MydoJobScreen::getRoadwayId));
for (String roadwayId : collect.keySet()) {
if (map.containsKey(roadwayId)){
List<MydoJobScreen> mydoJobs = map.get(roadwayId);
mydoJobs.addAll(collect.get(roadwayId));
map.put(roadwayId,mydoJobs);
}
}
}
return map;
}else {
map.put("1",new ArrayList<>()); map.put("1",new ArrayList<>());
map.put("2",new ArrayList<>()); map.put("2",new ArrayList<>());
map.put("3",new ArrayList<>()); map.put("3",new ArrayList<>());
@@ -216,8 +250,12 @@ public class MydoJobServiceImpl implements IMydoJobService
} }
} }
} }
map.put("1",map.get("4"));
map.put("2",map.get("5"));
map.put("3",map.get("6"));
return map; return map;
} }
}
@Override @Override
public List<MydoJob> selectOutMydoJobList(MydoJob outJobParam) { public List<MydoJob> selectOutMydoJobList(MydoJob outJobParam) {

View File

@@ -161,28 +161,40 @@ public class ScheduleThread {
* 开始线程 * 开始线程
*/ */
public void startAllThread() { public void startAllThread() {
if (plcSsjReadCustomThread !=null){
plcSsjReadCustomThread.getThread().setName("输送机读取线程");
plcSsjReadCustomThread.getThread().start(); plcSsjReadCustomThread.getThread().start();
}
if (plcDdj1ReadCustomThread!=null){ if (plcDdj1ReadCustomThread!=null){
plcDdj1ReadCustomThread.getThread().setName("ddj1读取线程");
plcDdj1ReadCustomThread.getThread().start(); plcDdj1ReadCustomThread.getThread().start();
} }
if (plcDdj2ReadCustomThread!=null){ if (plcDdj2ReadCustomThread!=null){
plcDdj2ReadCustomThread.getThread().setName("ddj2读取线程");
plcDdj2ReadCustomThread.getThread().start(); plcDdj2ReadCustomThread.getThread().start();
} }
if (plcDdj3ReadCustomThread!=null){ if (plcDdj3ReadCustomThread!=null){
plcDdj3ReadCustomThread.getThread().setName("ddj3读取线程");
plcDdj3ReadCustomThread.getThread().start(); plcDdj3ReadCustomThread.getThread().start();
} }
if (plcDdj4ReadCustomThread!=null){ if (plcDdj4ReadCustomThread!=null){
plcDdj4ReadCustomThread.getThread().setName("ddj4读取线程");
plcDdj4ReadCustomThread.getThread().start(); plcDdj4ReadCustomThread.getThread().start();
} }
/*plcDdj2ReadCustomThread.getThread().start(); if (plcDdj5ReadCustomThread!=null){
plcDdj3ReadCustomThread.getThread().start(); plcDdj5ReadCustomThread.getThread().setName("ddj5读取线程");
plcDdj4ReadCustomThread.getThread().start();
plcDdj5ReadCustomThread.getThread().start(); plcDdj5ReadCustomThread.getThread().start();
plcDdj6ReadCustomThread.getThread().start();*/
}
if (plcDdj6ReadCustomThread!=null){
plcDdj6ReadCustomThread.getThread().setName("ddj6读取线程");
plcDdj6ReadCustomThread.getThread().start();
}
isRun = true; isRun = true;
} }
@@ -190,28 +202,40 @@ public class ScheduleThread {
* 开启线程2 * 开启线程2
*/ */
public void startAllThread2() { public void startAllThread2() {
if (monitoringCustomThread!=null){
monitoringCustomThread.thread.setName("监控线程");
monitoringCustomThread.thread.start(); monitoringCustomThread.thread.start();
}
if (ddj1CustomThread!=null){ if (ddj1CustomThread!=null){
ddj1CustomThread.thread.setName("ddj1调度线程");
ddj1CustomThread.thread.start(); ddj1CustomThread.thread.start();
} }
if (ddj2CustomThread!=null){ if (ddj2CustomThread!=null){
ddj2CustomThread.thread.setName("ddj2调度线程");
ddj2CustomThread.thread.start(); ddj2CustomThread.thread.start();
} }
if (ddj3CustomThread!=null){ if (ddj3CustomThread!=null){
ddj3CustomThread.thread.setName("ddj3调度线程");
ddj3CustomThread.thread.start(); ddj3CustomThread.thread.start();
} }
if (ddj4CustomThread!=null){ if (ddj4CustomThread!=null){
ddj4CustomThread.thread.setName("ddj4调度线程");
ddj4CustomThread.thread.start(); ddj4CustomThread.thread.start();
} }
/*ddj2CustomThread.thread.start(); if (ddj5CustomThread!=null){
ddj3CustomThread.thread.start(); ddj5CustomThread.thread.setName("ddj5调度线程");
ddj4CustomThread.thread.start();
ddj5CustomThread.thread.start(); ddj5CustomThread.thread.start();
ddj6CustomThread.thread.start();*/
}
if (ddj6CustomThread!=null){
ddj6CustomThread.thread.setName("ddj6调度线程");
ddj6CustomThread.thread.start();
}
isRun2 = true; isRun2 = true;
} }
@@ -224,11 +248,15 @@ public class ScheduleThread {
plcDdj1ReadCustomThread.runnable.isRun = false; plcDdj1ReadCustomThread.runnable.isRun = false;
plcDdj1ReadCustomThread.thread.interrupt(); plcDdj1ReadCustomThread.thread.interrupt();
plcDdj2ReadCustomThread.runnable.isRun = false; plcDdj2ReadCustomThread.runnable.isRun = false;
plcDdj2ReadCustomThread.thread.interrupt();
plcDdj3ReadCustomThread.runnable.isRun = false; plcDdj3ReadCustomThread.runnable.isRun = false;
plcDdj3ReadCustomThread.thread.interrupt();
plcDdj4ReadCustomThread.runnable.isRun = false; plcDdj4ReadCustomThread.runnable.isRun = false;
plcDdj4ReadCustomThread.thread.interrupt(); plcDdj4ReadCustomThread.thread.interrupt();
plcDdj5ReadCustomThread.runnable.isRun = false; plcDdj5ReadCustomThread.runnable.isRun = false;
plcDdj5ReadCustomThread.thread.interrupt();
plcDdj6ReadCustomThread.runnable.isRun = false; plcDdj6ReadCustomThread.runnable.isRun = false;
plcDdj6ReadCustomThread.thread.interrupt();
plcReadInit(); plcReadInit();
isRun = false; isRun = false;
} }
@@ -239,8 +267,18 @@ public class ScheduleThread {
public void stopAllThread2() { public void stopAllThread2() {
monitoringCustomThread.runnable.isRun = false; monitoringCustomThread.runnable.isRun = false;
monitoringCustomThread.thread.interrupt(); monitoringCustomThread.thread.interrupt();
ddj1CustomThread.runnable.isRun = false;
ddj1CustomThread.thread.interrupt();
ddj2CustomThread.runnable.isRun = false;
ddj2CustomThread.thread.interrupt();
ddj3CustomThread.runnable.isRun = false;
ddj3CustomThread.thread.interrupt();
ddj4CustomThread.runnable.isRun = false; ddj4CustomThread.runnable.isRun = false;
ddj4CustomThread.thread.interrupt(); ddj4CustomThread.thread.interrupt();
ddj5CustomThread.runnable.isRun = false;
ddj5CustomThread.thread.interrupt();
ddj6CustomThread.runnable.isRun = false;
ddj6CustomThread.thread.interrupt();
scheduleInit(); scheduleInit();
isRun2 = false; isRun2 = false;
} }

View File

@@ -37,6 +37,7 @@ public class PlcDdjRead extends Thread {
@Override @Override
public void run() { public void run() {
int i = 0;
while (isRun) { while (isRun) {
try { try {
if (IsConnect()) { if (IsConnect()) {
@@ -45,9 +46,13 @@ public class PlcDdjRead extends Thread {
} else { } else {
reConnect(); reConnect();
} }
} catch (InterruptedException e) { i++;
Thread.currentThread().interrupt(); if (i==100){
log.info("读取线程执行正常");
i=0;
}
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(),e);
log.info("********IP:" + this.ip + " port:" + this.port + "端口号 " + e.getMessage()); log.info("********IP:" + this.ip + " port:" + this.port + "端口号 " + e.getMessage());
} }

View File

@@ -46,6 +46,7 @@ public class PlcSsjRead implements Runnable {
@Override @Override
public void run() { public void run() {
int i = 0;
while (isRun) { while (isRun) {
try { try {
if (IsConnect()) { if (IsConnect()) {
@@ -72,11 +73,13 @@ public class PlcSsjRead implements Runnable {
} else { } else {
reConnect(); reConnect();
} }
} catch (InterruptedException e) { i++;
// 捕获中断异常,退出循环 if (i==100){
Thread.currentThread().interrupt(); // 重新设置中断标志 log.info("读取线程执行正常");
return; i=0;
}
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(),e);
log.info("********IP:" + this.ip + " port:" + this.port + "读取数据异常 " + e.getMessage()); log.info("********IP:" + this.ip + " port:" + this.port + "读取数据异常 " + e.getMessage());
} }

View File

@@ -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,37 +81,42 @@ 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);
} }
@Override @Override
public void run() { public void run() {
init(); init();
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);
generateOutBoundQueue(msgDdj); generateOutBoundQueue(msgDdj);
setOutSsjStatus(msgDdj); setOutSsjStatus(msgDdj);
ddjTask(msgDdj); ddjTask(msgDdj);
} else { } else {
log.error("堆垛机设备为空"); log.error("堆垛机设备为空");
} }
} catch (RuntimeException e) {
log.error(e.getMessage(), e);
}
} }
} }
try { i++;
if (i == 100) {
log.info("ddj{},循环完成", ddjCodeList);
i = 0;
}
Thread.sleep(1500); Thread.sleep(1500);
} catch (InterruptedException e) { } catch (Exception e) {
throw new RuntimeException(e); log.error(e.getMessage(), e);
} }
} }
@@ -150,14 +158,14 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
switch (exitId) { switch (exitId) {
case "1": case "1":
List<DeviceSsj> outSsj1 = getDeviceSsjs("outSsj1"); List<DeviceSsj> outSsj1 = getDeviceSsjs("outSsj1");
if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 )) { if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getHczt() == 0 && ddj.getYxxf()==1)) {
outSsj = outSsj1.get(0).getDeviceCode(); outSsj = outSsj1.get(0).getDeviceCode();
if (StrUtil.isNotEmpty(outSsj)) { if (StrUtil.isNotEmpty(outSsj)) {
break; break;
} }
} }
List<DeviceSsj> outSsj2 = getDeviceSsjs("outSsj2"); List<DeviceSsj> outSsj2 = getDeviceSsjs("outSsj2");
if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 )) { if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getHczt() == 0 && ddj.getYxxf()==1)) {
outSsj = outSsj2.get(0).getDeviceCode(); outSsj = outSsj2.get(0).getDeviceCode();
if (StrUtil.isNotEmpty(outSsj)) { if (StrUtil.isNotEmpty(outSsj)) {
break; break;
@@ -166,14 +174,14 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
break; break;
case "2": case "2":
List<DeviceSsj> outSsj3 = getDeviceSsjs("outSsj3"); List<DeviceSsj> outSsj3 = getDeviceSsjs("outSsj3");
if (outSsj3.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 )) { if (outSsj3.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getHczt() == 0 && ddj.getYxxf()==1)) {
outSsj = outSsj3.get(0).getDeviceCode(); outSsj = outSsj3.get(0).getDeviceCode();
if (StrUtil.isNotEmpty(outSsj)) { if (StrUtil.isNotEmpty(outSsj)) {
break; break;
} }
} }
List<DeviceSsj> outSsj4 = getDeviceSsjs("outSsj4"); List<DeviceSsj> outSsj4 = getDeviceSsjs("outSsj4");
if (outSsj4.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0)) { if (outSsj4.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getHczt() == 0 && ddj.getYxxf()==1)) {
outSsj = outSsj4.get(0).getDeviceCode(); outSsj = outSsj4.get(0).getDeviceCode();
if (StrUtil.isNotEmpty(outSsj)) { if (StrUtil.isNotEmpty(outSsj)) {
break; break;
@@ -419,13 +427,18 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
int rkqq = ssj.getRkqq(); int rkqq = ssj.getRkqq();
if (taskNo > 0 && rkqq == 1) { if (taskNo > 0 && rkqq == 1) {
//log.info("取货任务 任务号{}",taskNo); //log.info("取货任务 任务号{}",taskNo);
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(taskNo), ddj.getId());
if (ObjUtil.isNull(ddjQueue)) {
//todo 连接称重 并保存数据 //todo 连接称重 并保存数据
String czDeviceIpPort = czRoadwayMap.get(ssj.getDeviceCode()); String czDeviceIpPort = czRoadwayMap.get(ssj.getDeviceCode());
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);
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(taskNo), ddj.getId()); if (aDouble<40){
if (ObjUtil.isNull(ddjQueue)) { 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();
@@ -446,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) {
//写入超重信号 //写入超重信号
@@ -614,11 +627,17 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues1 = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionRunningQueueParam); List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues1 = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionRunningQueueParam);
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues1)) { if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues1)) {
log.info("ddj:{} 正在执行任务 {}",ddj.getId(), ddjDeviceExecutionQueues1.get(0).getRwh()); log.info("ddj:{} 已下发任务号 {} ddj当前任务号 {}",ddj.getId(), ddjDeviceExecutionQueues1.get(0).getRwh(),ddj.getRwh());
if (!ddj.getRwh().equals(ddjDeviceExecutionQueues1.get(0).getRwh())){
int i = issuedDDJTask(ddj, ddjDeviceExecutionQueues1.get(0));
if (i == 1) {
log.info("ddj:{} 重新下发任务 {}",ddj.getId(), ddjDeviceExecutionQueues1.get(0).getRwh());
}
}
return; return;
} }
if (ddj.getSbzt() == 0 && ddj.getHczt() == 0) { if (ddj.getHczt() == 0) {
//无货待机 只查询入库取货扫码或者出库队列 //无货待机 只查询入库取货扫码或者出库队列
ArrayList<Integer> rwlxList = new ArrayList<>(); ArrayList<Integer> rwlxList = new ArrayList<>();
rwlxList.add(DDJ_RWLX_1); rwlxList.add(DDJ_RWLX_1);
@@ -652,7 +671,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
log.error("托盘堆垛机下发任务失败!!!!!!!ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh()); log.error("托盘堆垛机下发任务失败!!!!!!!ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
} }
} }
} else if ((ddj.getSbzt() == 0 || ddj.getSbzt()==1047) && ddj.getHczt() == 1) { } else if (ddj.getHczt() == 1) {
//有货待机 只查询入库放货队列和 无任务 未扫码回滚 队列 //有货待机 只查询入库放货队列和 无任务 未扫码回滚 队列
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue(); DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
ddjDeviceExecutionQueueParam.setDdjxf("0"); ddjDeviceExecutionQueueParam.setDdjxf("0");

View File

@@ -43,20 +43,32 @@ public class Ddj5Thread extends BaseDdjThread {
ssjList.put("outSsj2", outSsj2); ssjList.put("outSsj2", outSsj2);
//初始化巷道口 排 列 层 //初始化巷道口 排 列 层
roadwayMap.put("L1003", Arrays.asList(1, 1, 1)); roadwayMap.put("L1003", Arrays.asList(1, 0, 1));
roadwayMap.put("L1004", Arrays.asList(2, 1, 1)); roadwayMap.put("L1004", Arrays.asList(2, 0, 1));
//未扫码 回退任务号 无入库任务在此基础+100
roadwayRollback.put("L1003", 94); roadwayRollback.put("L1003", 94);
roadwayRollback.put("L1004", 95); roadwayRollback.put("L1004", 95);
//初始化称重设备连接ip port
czRoadwayMap.put("L1003", "172.19.40.216:4001");
czRoadwayMap.put("L1004", "172.19.40.217:4001");
/*czOverMap.put("L1003", "DB502.12");
czOverMap.put("L1004", "DB502.26");*/
outJobMap.put("L1003", "DB502.38");
outJobMap.put("L1004", "DB502.52");
log.info("Ddj5Thread init"); log.info("Ddj5Thread init");
} }
@Override @Override
public HashMap<String, Object> getParamMap(String trayCode,Integer height,double weight) { public HashMap<String, Object> getParamMap(String trayCode,Integer height,double weight) {
HashMap<String, Object> paramMap = new HashMap<>(); HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("trayCode", trayCode); paramMap.put("trayCode", trayCode);
paramMap.put("warehouseId",WAREHOUSE_02); paramMap.put("warehouseId",WAREHOUSE_02);
paramMap.put("roadwayId",ROADWAY_ID_02); paramMap.put("roadwayId",ROADWAY_ID_05);
paramMap.put("height",height); paramMap.put("height",height);
paramMap.put("weight",weight); paramMap.put("weight",weight);
return paramMap; return paramMap;
@@ -66,7 +78,7 @@ public class Ddj5Thread extends BaseDdjThread {
public MydoJob getOutJobParam() { public MydoJob getOutJobParam() {
MydoJob mydoJob = new MydoJob(); MydoJob mydoJob = new MydoJob();
mydoJob.setWarehouseId(WAREHOUSE_02); mydoJob.setWarehouseId(WAREHOUSE_02);
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_02)); mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_05));
mydoJob.setStatus("1"); mydoJob.setStatus("1");
return mydoJob; return mydoJob;

View File

@@ -43,11 +43,22 @@ public class Ddj6Thread extends BaseDdjThread {
ssjList.put("outSsj2", outSsj2); ssjList.put("outSsj2", outSsj2);
//初始化巷道口 排 列 层 //初始化巷道口 排 列 层
roadwayMap.put("L1005", Arrays.asList(1, 1, 1)); roadwayMap.put("L1005", Arrays.asList(1, 0, 1));
roadwayMap.put("L1006", Arrays.asList(2, 1, 1)); roadwayMap.put("L1006", Arrays.asList(2, 0, 1));
//未扫码 回退任务号 无入库任务在此基础+100
roadwayRollback.put("L1005", 96); roadwayRollback.put("L1005", 96);
roadwayRollback.put("L1006", 97); roadwayRollback.put("L1006", 97);
//初始化称重设备连接ip port
czRoadwayMap.put("L1005", "172.19.40.218:4001");
czRoadwayMap.put("L1006", "172.19.40.219:4001");
/*czOverMap.put("L1003", "DB502.12");
czOverMap.put("L1004", "DB502.26");*/
outJobMap.put("L1005", "DB502.66");
outJobMap.put("L1006", "DB502.80");
log.info("Ddj6Thread init"); log.info("Ddj6Thread init");
} }
@@ -57,10 +68,9 @@ public class Ddj6Thread extends BaseDdjThread {
HashMap<String, Object> paramMap = new HashMap<>(); HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("trayCode", trayCode); paramMap.put("trayCode", trayCode);
paramMap.put("warehouseId",WAREHOUSE_02); paramMap.put("warehouseId",WAREHOUSE_02);
paramMap.put("roadwayId",ROADWAY_ID_03); paramMap.put("roadwayId",ROADWAY_ID_06);
paramMap.put("height",height); paramMap.put("height",height);
paramMap.put("weight",weight); paramMap.put("weight",weight);
return paramMap; return paramMap;
} }
@@ -68,7 +78,7 @@ public class Ddj6Thread extends BaseDdjThread {
public MydoJob getOutJobParam() { public MydoJob getOutJobParam() {
MydoJob mydoJob = new MydoJob(); MydoJob mydoJob = new MydoJob();
mydoJob.setWarehouseId(WAREHOUSE_02); mydoJob.setWarehouseId(WAREHOUSE_02);
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_03)); mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_06));
mydoJob.setStatus("1"); mydoJob.setStatus("1");
return mydoJob; return mydoJob;
@@ -86,4 +96,5 @@ public class Ddj6Thread extends BaseDdjThread {
return "1"; return "1";
} }
} }

View File

@@ -45,15 +45,18 @@ public class MonitoringThread implements Runnable {
@Override @Override
public void run() { public void run() {
init(); init();
int i =0;
while (isRun){ while (isRun){
try { try {
for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) { for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) {
try {
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode); DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode);
deviceSsjService.updateDeviceSsj(deviceSsj); deviceSsjService.updateDeviceSsj(deviceSsj);
int taskNo = deviceSsj.getTaskNo(); int taskNo = deviceSsj.getTaskNo();
//输送机外形异常 101-前超长 102-后超长 103-左超宽 104-右超宽 105-超高 106-超重 //输送机外形异常 101-前超长 102-后超长 103-左超宽 104-右超宽 105-超高 106-超重
if (deviceSsj.getException() >= 101 && deviceSsj.getException() <= 106 && deviceSsj.getTaskNo()>0) { if (deviceSsj.getException() >= 101 && deviceSsj.getException() <= 120 && deviceSsj.getTaskNo()>0) {
BasFaultRecord param = new BasFaultRecord(); BasFaultRecord param = new BasFaultRecord();
param.setTaskNo(Convert.toStr(deviceSsj.getTaskNo())); param.setTaskNo(Convert.toStr(deviceSsj.getTaskNo()));
param.setDeviceId(Convert.toStr(deviceSsj.getDeviceCode())); param.setDeviceId(Convert.toStr(deviceSsj.getDeviceCode()));
@@ -150,8 +153,13 @@ public class MonitoringThread implements Runnable {
basFaultRecordService.updateBasFaultRecord(record); basFaultRecordService.updateBasFaultRecord(record);
} }
} }
} catch (Exception e) {
log.error(e.getMessage(),e);
}
} }
for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) { for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) {
try {
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode); MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
msgDdjService.updateMsgDdj(msgDdj); msgDdjService.updateMsgDdj(msgDdj);
//记录异常 //记录异常
@@ -190,8 +198,16 @@ public class MonitoringThread implements Runnable {
basFaultRecordService.updateBasFaultRecord(record); basFaultRecordService.updateBasFaultRecord(record);
} }
} }
} catch (Exception e) {
log.error(e.getMessage(),e);
}
} }
i++;
if (i==100){
log.info("监控线程循环完成");
i=0;
}
Thread.sleep(1500); Thread.sleep(1500);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
@@ -214,6 +230,12 @@ public class MonitoringThread implements Runnable {
return "超高"; return "超高";
} else if (value == 106) { } else if (value == 106) {
return "超重"; return "超重";
} else if (value==112){
return "输送超时";
}else if (value==113){
return "变频器报警";
}else if (value==114){
return "开关异常";
}else { }else {
return "未知"; return "未知";
} }

View File

@@ -1,10 +1,10 @@
package com.ruoyi.schedule.util; package com.ruoyi.schedule.util;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
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;
@@ -13,88 +13,88 @@ 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();
Thread.sleep(1000); socket.connect(new InetSocketAddress(ip, por), 1000);
byte[] bytes = new byte[100]; 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);
} else {
Thread.sleep(50);
}
}
Thread.sleep(200);
byte[] bytes = new byte[256];
int read = is.read(bytes); int read = is.read(bytes);
if (read != -1) { if (read != -1) {
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;
} }
/**
* 用 Hutool 找出数组中出现次数最多的字符串
* @param strArray 目标字符串数组
* @return 出现次数最多的字符串(空数组返回 null,多最大值返回第一个)
*/
/**
* 兼容所有 Hutool 版本:找出数组中出现次数最多的字符串
* @param strArray 目标字符串数组
* @return 出现次数最多的字符串(空数组返回 null,多最大值返回第一个)
*/
public static String getMostFrequentByHutool(String[] strArray) { public static String getMostFrequentByHutool(String[] strArray) {
// 1. 空值校验 + 数组转 List
if (strArray == null || strArray.length == 0) { if (strArray == null || strArray.length == 0) {
return null; return null;
} }
List<String> strList = CollUtil.newArrayList(strArray); List<String> strList = CollUtil.newArrayList(strArray);
// 2. 用 Hutool 统计频次(所有版本都支持)
Map<String, Integer> countMap = CollUtil.countMap(strList); Map<String, Integer> countMap = CollUtil.countMap(strList);
// 3. 手动遍历找最大值(替代不存在的 getMaxKey 方法)
String mostFrequent = null; String mostFrequent = null;
int maxCount = 0; int maxCount = 0;
// 遍历 Map 条目,Hutool 5.x 及以上都支持 entrySet 遍历
for (Map.Entry<String, Integer> entry : countMap.entrySet()) { for (Map.Entry<String, Integer> entry : countMap.entrySet()) {
if (entry.getValue() > maxCount) { if (entry.getValue() > maxCount) {
maxCount = entry.getValue(); maxCount = entry.getValue();
mostFrequent = entry.getKey(); mostFrequent = entry.getKey();
} }
} }
return mostFrequent; return mostFrequent;
} }
/**
* 将byte数组按指定编码转为char数组
* @param byteArr 输入的byte数组
* @param charset 字符编码(如UTF-8、GBK、ASCII)
* @return 转换后的char数组
* @throws UnsupportedEncodingException 编码不支持时抛出
*/
public static String byteArrayToCharArray(byte[] byteArr, String charset) throws UnsupportedEncodingException { public static String byteArrayToCharArray(byte[] byteArr, String charset) throws UnsupportedEncodingException {
if (byteArr == null) { if (byteArr == null) {
return null; return null;
} }
// 核心:先将byte数组按指定编码转为String,再转为char数组
return new String(byteArr, charset); return new String(byteArr, charset);
} }
public static void main(String[] args) { public static void main(String[] args) {
CheckWeight checkWeight = new CheckWeight(); System.out.println(sendWeight("172.19.50.75", 4001));
while (true){
System.out.println(checkWeight.sendWeight("172.19.50.80", 4001));
}
} }
} }

View File

@@ -6,7 +6,8 @@ spring:
druid: druid:
#主数据信息 #主数据信息
master: master:
url: jdbc:sqlserver://172.19.1.119:1433;databaseName=FT541-wcs-2; url: jdbc:sqlserver://172.19.1.119:1433;databaseName=FT541-wcs;
# url: jdbc:sqlserver://172.19.1.119:1433;databaseName=FT541-wcs-2;
username: sa username: sa
password: Flrd0914. password: Flrd0914.
# 从库数据源 # 从库数据源

View File

@@ -249,5 +249,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and status = #{status} and status = #{status}
and roadway_id = #{roadwayId} and roadway_id = #{roadwayId}
and warehouse_id = #{warehouseId} and warehouse_id = #{warehouseId}
order by priority desc,create_time asc
</select> </select>
</mapper> </mapper>

View File

@@ -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>