refactor(scheduling): 重构堆垛机调度任务处理逻辑

- 移除API服务中废弃的入库作业创建和接收方法
- 将设备列表数据结构从DeviceSsj改为String类型并添加称重设备支持
- 添加出库任务计数查询功能和设备执行队列统计
- 优化入库取货队列创建逻辑,集成称重数据处理
- 更新WMS基础URL地址并调整相关接口调用
- 修复设备状态更新中的字段映射错误
- 添加线程安全的任务执行状态检查机制
- 实现出库队列任务优先级规则和防冲突机制
This commit is contained in:
liuhanqing
2026-01-05 09:55:19 +08:00
parent 86673312ed
commit 93bbc9dde3
22 changed files with 223 additions and 158 deletions

View File

@@ -28,19 +28,6 @@ public class Wcs2WmsController {
return apiService.receiveOutMydoJob(receiveOutJob); return apiService.receiveOutMydoJob(receiveOutJob);
} }
/**
* 接收入库任务
*
* @param receiveInJob
* @return
*/
@PostMapping("/receiveInMydoJob")
public AjaxResult receiveInMydoJob(@RequestBody ReceiveJob receiveInJob) {
return apiService.receiveInMydoJob(receiveInJob);
}
/** /**
* wms取消任务 * wms取消任务
* @param jobParam * @param jobParam

View File

@@ -115,17 +115,16 @@ public interface IApiService
* @return * @return
*/ */
AjaxResult reMaterial(JobParam jobParam); AjaxResult reMaterial(JobParam jobParam);
/** /**
* 入库请求生成作业 * 接收出库任务
* @param receiveOutJob
* @return
*/ */
public AjaxResult createInMydoJob(Map<String, Object> param);
public AjaxResult selectMydoJobByNoTrayCode(Map<String, Object> param);
AjaxResult receiveOutMydoJob(ReceiveJob receiveOutJob); AjaxResult receiveOutMydoJob(ReceiveJob receiveOutJob);
/**
AjaxResult receiveInMydoJob(ReceiveJob receiveInJob); * 请求入库,分配货位
* @param paramMap
* @return
*/
AjaxResult selectMydoJobByTrayCodeAndEntranceId(HashMap<String, Object> paramMap); AjaxResult selectMydoJobByTrayCodeAndEntranceId(HashMap<String, Object> paramMap);
} }

View File

@@ -330,16 +330,6 @@ public class ApiServiceImpl implements IApiService {
return genAgvSchedulingTask(genAgvSchedulingTaskRequest); return genAgvSchedulingTask(genAgvSchedulingTaskRequest);
} }
@Override
public AjaxResult createInMydoJob(Map<String, Object> param) {
RequestLog requestLog = requestLogService.getRequestLog(CREATE_IN_MYDO_JOB_URL, "入库请求生成作业", JSONUtil.toJsonStr(param));
if ("1".equals(requestLog.getIsSuccessful())) {
InterfaceReceive bean = JSONUtil.toBean(requestLog.getResponseBody(), InterfaceReceive.class);
return AjaxResult.success(bean.getData());
} else {
return AjaxResult.error();
}
}
@Override @Override
@@ -365,10 +355,6 @@ public class ApiServiceImpl implements IApiService {
} }
@Override
public AjaxResult receiveInMydoJob(ReceiveJob receiveInJob) {
return null;
}
@Override @Override
public AjaxResult selectMydoJobByTrayCodeAndEntranceId(HashMap<String, Object> paramMap) { public AjaxResult selectMydoJobByTrayCodeAndEntranceId(HashMap<String, Object> paramMap) {
@@ -381,15 +367,4 @@ public class ApiServiceImpl implements IApiService {
} }
} }
@Override
public AjaxResult selectMydoJobByNoTrayCode(Map<String, Object> param) {
RequestLog requestLog = requestLogService.getRequestLog(REQUEST_MYDO_JOB_URL, "入库请求补码作业", JSONUtil.toJsonStr(param));
if ("1".equals(requestLog.getIsSuccessful())) {
InterfaceReceive bean = JSONUtil.toBean(requestLog.getResponseBody(), InterfaceReceive.class);
return AjaxResult.success(bean.getData());
} else {
return AjaxResult.error();
}
}
} }

View File

@@ -3,7 +3,7 @@ package com.ruoyi.common;
public class Constant { public class Constant {
public static final String WMS_BASE_URL = "http://localhost:8080/api2wms/"; public static final String WMS_BASE_URL = "http://localhost:8080/api2wcs/";
public static final String RCS_BASE_URL = "http://127.0.0.1:8081/rcms-dps/rest/"; public static final String RCS_BASE_URL = "http://127.0.0.1:8081/rcms-dps/rest/";
@@ -11,8 +11,6 @@ public class Constant {
public static final String CONTINUE_TASK_URL = RCS_BASE_URL+"continueTask"; public static final String CONTINUE_TASK_URL = RCS_BASE_URL+"continueTask";
public static final String CANCEL_TASK_URL = RCS_BASE_URL+"queryAgvStatus";; public static final String CANCEL_TASK_URL = RCS_BASE_URL+"queryAgvStatus";;
public static final String GEN_AGV_SCHEDULING_TASK = RCS_BASE_URL+"genAgvSchedulingTask";; public static final String GEN_AGV_SCHEDULING_TASK = RCS_BASE_URL+"genAgvSchedulingTask";;
public static final String CREATE_IN_MYDO_JOB_URL = WMS_BASE_URL+"requestEnterByTrayCode";
public static final String REQUEST_MYDO_JOB_URL = WMS_BASE_URL+"requestByNoTrayCode";
public static final String RE_ASSIGN_URL = WMS_BASE_URL+"reAssign"; public static final String RE_ASSIGN_URL = WMS_BASE_URL+"reAssign";
public static final String RE_MATERIAL_URL = WMS_BASE_URL+"reMaterial"; public static final String RE_MATERIAL_URL = WMS_BASE_URL+"reMaterial";
public static final String REQUEST_ENTER_URL = WMS_BASE_URL+"requestEnterByTrayCodeAndEntranceId"; public static final String REQUEST_ENTER_URL = WMS_BASE_URL+"requestEnterByTrayCodeAndEntranceId";

View File

@@ -63,4 +63,6 @@ public interface DdjDeviceExecutionQueueMapper
List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(@Param("rwlx")Integer rwlx,@Param("devId") Integer devId); List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(@Param("rwlx")Integer rwlx,@Param("devId") Integer devId);
DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwhAndXd(@Param("rwh") Long rwh, @Param("devId") Integer devId); DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwhAndXd(@Param("rwh") Long rwh, @Param("devId") Integer devId);
int selectOutJobCount(DdjDeviceExecutionQueue ddjDeviceExecutionQueue);
} }

View File

@@ -62,4 +62,6 @@ public interface IDdjDeviceExecutionQueueService
DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwh(Long rwh,Integer devId); DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwh(Long rwh,Integer devId);
List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(Integer rwlx,Integer devId); List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(Integer rwlx,Integer devId);
int selectOutJobCount(DdjDeviceExecutionQueue otherOutDdjQueue);
} }

View File

@@ -1,6 +1,8 @@
package com.ruoyi.queue.ddj.service.impl; package com.ruoyi.queue.ddj.service.impl;
import java.util.List; import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.queue.ddj.mapper.DdjDeviceExecutionQueueMapper; import com.ruoyi.queue.ddj.mapper.DdjDeviceExecutionQueueMapper;
@@ -14,6 +16,7 @@ import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueService;
* @date 2025-09-22 * @date 2025-09-22
*/ */
@Service @Service
@Slf4j
public class DdjDeviceExecutionQueueServiceImpl implements IDdjDeviceExecutionQueueService public class DdjDeviceExecutionQueueServiceImpl implements IDdjDeviceExecutionQueueService
{ {
@Autowired @Autowired
@@ -52,7 +55,12 @@ public class DdjDeviceExecutionQueueServiceImpl implements IDdjDeviceExecutionQu
@Override @Override
public int insertDdjDeviceExecutionQueue(DdjDeviceExecutionQueue ddjDeviceExecutionQueue) public int insertDdjDeviceExecutionQueue(DdjDeviceExecutionQueue ddjDeviceExecutionQueue)
{ {
return ddjDeviceExecutionQueueMapper.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue); if (ddjDeviceExecutionQueue.getRwh()>0){
return ddjDeviceExecutionQueueMapper.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
}else {
log.error("任务号为0");
return 0;
}
} }
/** /**
@@ -100,4 +108,9 @@ public class DdjDeviceExecutionQueueServiceImpl implements IDdjDeviceExecutionQu
public List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(Integer rwlx,Integer devId) { public List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(Integer rwlx,Integer devId) {
return ddjDeviceExecutionQueueMapper.selectDdjDeviceExecutionQueueListByRwlx(rwlx,devId); return ddjDeviceExecutionQueueMapper.selectDdjDeviceExecutionQueueListByRwlx(rwlx,devId);
} }
@Override
public int selectOutJobCount(DdjDeviceExecutionQueue otherOutDdjQueue) {
return ddjDeviceExecutionQueueMapper.selectOutJobCount(otherOutDdjQueue);
}
} }

View File

@@ -105,7 +105,7 @@ public class ScheduleThread {
List<MsgDdj> msgDdjs = msgDdjService.selectMsgDdjList(new MsgDdj()); List<MsgDdj> msgDdjs = msgDdjService.selectMsgDdjList(new MsgDdj());
for (MsgDdj msgDdj : msgDdjs) { for (MsgDdj msgDdj : msgDdjs) {
msgDdj.setPlcDbReadAddress(msgDdj.getPlcDbReadAddress()); msgDdj.setPlcDbReadAddress(msgDdj.getPlcDbReadAddress());
msgDdj.setTrayCode("00000000"); msgDdj.setTrayCode(null);
PlcDdjRead plcDdjRead = new PlcDdjRead(msgDdj, new PlcConnectInfo(msgDdj.getIp(), Convert.toInt(msgDdj.getPort()))); PlcDdjRead plcDdjRead = new PlcDdjRead(msgDdj, new PlcConnectInfo(msgDdj.getIp(), Convert.toInt(msgDdj.getPort())));
switch (msgDdj.getId()){ switch (msgDdj.getId()){
case 1: case 1:

View File

@@ -55,7 +55,7 @@ public class PlcDdjRead extends Thread {
} }
private void readPlcDdj(MsgDdj msgDdj) { private void readPlcDdj(MsgDdj msgDdj) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(msgDdj.getPlcDbReadAddress(), Convert.toShort("40")); OperateResultExOne<byte[]> read2 = readWriteNet.Read(msgDdj.getPlcDbReadAddress(), Convert.toShort("42"));
String ddsx = "0"; String ddsx = "0";
if (read2.IsSuccess) { if (read2.IsSuccess) {
ddsx = SoftBasic.ByteToHexString(read2.Content); ddsx = SoftBasic.ByteToHexString(read2.Content);
@@ -72,8 +72,9 @@ public class PlcDdjRead extends Thread {
msgDdj.setMbch(ParseUtil.optInt(22, ddsx)); msgDdj.setMbch(ParseUtil.optInt(22, ddsx));
msgDdj.setYxxf(ParseUtil.optInt(24, ddsx)); msgDdj.setYxxf(ParseUtil.optInt(24, ddsx));
msgDdj.setXtxh(ParseUtil.optInt(26, ddsx)); msgDdj.setXtxh(ParseUtil.optInt(26, ddsx));
msgDdj.setHeight(ParseUtil.optInt(40, ddsx));
String trayCode = ParseUtil.optString(32, 8, ddsx); String trayCode = ParseUtil.optString(32, 8, ddsx);
if (! "11111111".equals(trayCode) && !"00000000".equals(trayCode)){ if (! "11111111".equals(trayCode) && !"NoRead00".equals(trayCode)){
msgDdj.setTrayCode(trayCode); msgDdj.setTrayCode(trayCode);
} }
} }

View File

@@ -24,7 +24,9 @@ import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueService;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead; import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead; import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.plcRead.util.Tools; import com.ruoyi.schedule.plcRead.util.Tools;
import com.ruoyi.schedule.util.CheckWeight;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.*;
@@ -33,8 +35,8 @@ import static com.ruoyi.common.TaskType.*;
@Slf4j @Slf4j
public abstract class BaseDdjThread implements Runnable, DdjThreadInterface { public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
public HashMap<String, List<MsgDdj>> ddjCodeList; public HashMap<String, List<String>> ddjCodeList;
public HashMap<String, List<DeviceSsj>> ssjList; public HashMap<String, List<String>> ssjList;
private IApiService apiService; private IApiService apiService;
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService; private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
@@ -45,6 +47,8 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
public Map<String, List<Integer>> roadwayMap = new HashMap<>(); public Map<String, List<Integer>> roadwayMap = new HashMap<>();
private PlcDdjRead plcDdjRead; private PlcDdjRead plcDdjRead;
public Map<String,String> czRoadwayMap = new HashMap<>();
public BaseDdjThread(PlcDdjRead plcDdjRead) { public BaseDdjThread(PlcDdjRead plcDdjRead) {
this.plcDdjRead = plcDdjRead; this.plcDdjRead = plcDdjRead;
} }
@@ -74,7 +78,8 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
while (isRun) { while (isRun) {
for (String type : ddjCodeList.keySet()) { for (String type : ddjCodeList.keySet()) {
for (MsgDdj msgDdj : ddjCodeList.get(type)) { for (String ddjCode : ddjCodeList.get(type)) {
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
try { try {
if (ObjUtil.isNotNull(msgDdj)) { if (ObjUtil.isNotNull(msgDdj)) {
MsgDdj currentMsgDdj = msgDdjService.selectMsgDdjById(Convert.toLong(msgDdj.getId())); MsgDdj currentMsgDdj = msgDdjService.selectMsgDdjById(Convert.toLong(msgDdj.getId()));
@@ -114,27 +119,39 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
String outSsj = ""; String outSsj = "";
switch (exitId) { switch (exitId) {
case "1": case "1":
List<DeviceSsj> outSsj1 = ssjList.get("outSsj1"); List<DeviceSsj> outSsj1 = getDeviceSsjs("outSsj1");
if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 )) { if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() ==0 && ddj.getHczt()==0 && ddj.getSbzt()==0)) {
outSsj = outSsj1.get(0).getDeviceCode(); outSsj = outSsj1.get(0).getDeviceCode();
break; int ssjJobCount = ddjDeviceExecutionQueueService.selectOutJobCount(getOtherOutDdjQueue(outSsj));
if (StrUtil.isNotEmpty(outSsj) && ssjJobCount==0){
break;
}
} }
List<DeviceSsj> outSsj2 = ssjList.get("outSsj2"); List<DeviceSsj> outSsj2 = getDeviceSsjs("outSsj2");
if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1)) { if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() ==0&& ddj.getHczt()==0 && ddj.getSbzt()==0)) {
outSsj = outSsj2.get(0).getDeviceCode(); outSsj = outSsj2.get(0).getDeviceCode();
break; int ssjJobCount = ddjDeviceExecutionQueueService.selectOutJobCount(getOtherOutDdjQueue(outSsj));
if (StrUtil.isNotEmpty(outSsj) && ssjJobCount==0){
break;
}
} }
break; break;
case "2": case "2":
List<DeviceSsj> outSsj3 = ssjList.get("outSsj3"); List<DeviceSsj> outSsj3 = getDeviceSsjs("outSsj3");
if (outSsj3.stream().allMatch(ssj -> ssj.getKx() == 1 )) { if (outSsj3.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() ==0&& ddj.getHczt()==0 && ddj.getSbzt()==0)) {
outSsj = outSsj3.get(0).getDeviceCode(); outSsj = outSsj3.get(0).getDeviceCode();
break; int ssjJobCount = ddjDeviceExecutionQueueService.selectOutJobCount(getOtherOutDdjQueue(outSsj));
if (StrUtil.isNotEmpty(outSsj) && ssjJobCount==0){
break;
}
} }
List<DeviceSsj> outSsj4 = ssjList.get("outSsj4"); List<DeviceSsj> outSsj4 = getDeviceSsjs("outSsj4");
if (outSsj4.stream().allMatch(ssj -> ssj.getKx() == 1 )) { if (outSsj4.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() ==0&& ddj.getHczt()==0 && ddj.getSbzt()==0)) {
outSsj = outSsj4.get(0).getDeviceCode(); outSsj = outSsj4.get(0).getDeviceCode();
break; int ssjJobCount = ddjDeviceExecutionQueueService.selectOutJobCount(getOtherOutDdjQueue(outSsj));
if (StrUtil.isNotEmpty(outSsj) && ssjJobCount==0){
break;
}
} }
break; break;
default: default:
@@ -144,7 +161,8 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
if ("0".equals(outJob.getExecutionPhase()) && StrUtil.isNotEmpty(outSsj)) { if ("0".equals(outJob.getExecutionPhase()) && StrUtil.isNotEmpty(outSsj)) {
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(outJob.getTaskNo()), ddj.getId()); DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(outJob.getTaskNo()), ddj.getId());
if (ObjUtil.isNull(ddjQueue)) { //查询这个站点是否存在任务
if (ObjUtil.isNull(ddjQueue) ) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue(); DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID()); ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
ddjDeviceExecutionQueue.setRwh(Convert.toLong(outJob.getTaskNo())); ddjDeviceExecutionQueue.setRwh(Convert.toLong(outJob.getTaskNo()));
@@ -178,6 +196,15 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
} }
@NotNull
private List<DeviceSsj> getDeviceSsjs(String ssjTypeCode) {
List<DeviceSsj> outSsj1 = new ArrayList<>();
for (String ssj : ssjList.get(ssjTypeCode)) {
outSsj1.add(PlcSsjRead.deviceSsjMap.get(ssj));
}
return outSsj1;
}
@Override @Override
public abstract MydoJob getOutJobParam(); public abstract MydoJob getOutJobParam();
@@ -185,19 +212,19 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
* 创建入库放货队列 * 创建入库放货队列
*/ */
private void generateInBoundLoadQueue(MsgDdj ddj) { private void generateInBoundLoadQueue(MsgDdj ddj) {
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 0 && ddj.getHczt()==1 && ddj.getYxxf() == 1) { if (ddj.getCzfs() == 5 && ddj.getSbzt() == 0 && ddj.getHczt()==1 && ddj.getYxxf() == 1 && ddj.getHeight()>0) {
//允许下发 联机 有货待机 //允许下发 联机 有货待机
if (ddj.getTrayCode() != null && StrUtil.isNotEmpty(ddj.getTrayCode().trim())) { if (ddj.getTrayCode() != null && StrUtil.isNotEmpty(ddj.getTrayCode().trim()) && !ddj.getTrayCode().equals("00000000")) {
MydoJob param = new MydoJob(); MydoJob param = new MydoJob();
param.setTrayCode(ddj.getTrayCode()); param.setTrayCode(ddj.getTrayCode());
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param); List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
MydoJob inJob = null; MydoJob inJob = null;
if (CollUtil.isEmpty(mydoJobs)) { if (CollUtil.isEmpty(mydoJobs)) {
//获取高度spare2 和 重量spare3 //获取 重量spare3
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(ddj.getRwh(), ddj.getId()); DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(ddj.getRwh(), ddj.getId());
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)){ if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)){
//请求wms获取任务 并生成队列 //请求wms获取任务 并生成队列
AjaxResult result = apiService.selectMydoJobByTrayCodeAndEntranceId(getParamMap(ddj.getTrayCode(),Convert.toInt(ddjDeviceExecutionQueue.getSpare2()),Convert.toDouble(ddjDeviceExecutionQueue.getSpare3()))); AjaxResult result = apiService.selectMydoJobByTrayCodeAndEntranceId(getParamMap(ddj.getTrayCode(),Convert.toInt(ddj.getHeight()),Convert.toDouble(ddjDeviceExecutionQueue.getSpare3())));
if (result.isSuccess()) { if (result.isSuccess()) {
inJob = BeanUtil.toBean(result.get("data"), MydoJob.class); inJob = BeanUtil.toBean(result.get("data"), MydoJob.class);
inJob.setStatus(TASK_STATUS_CREATE); inJob.setStatus(TASK_STATUS_CREATE);
@@ -319,13 +346,17 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
* 创建入库取货队列 * 创建入库取货队列
*/ */
private void generateInBoundPickQueue(MsgDdj ddj) { private void generateInBoundPickQueue(MsgDdj ddj) {
List<DeviceSsj> roadSsjList = ssjList.get("roadSsjList"); List<DeviceSsj> roadSsjList = getDeviceSsjs("roadSsjList");
for (DeviceSsj ssj : roadSsjList) { for (DeviceSsj ssj : roadSsjList) {
//todo 连接称重 并保存数据 int taskNo = ssj.getTaskNo();
double weight = 0; int rkqq = ssj.getRkqq();
if (ssj.getTaskNo() > 0 && ssj.getHeight() > 0 && ssj.getRkqq() == 1) { if (taskNo > 0 && rkqq == 1) {
//todo 连接称重 并保存数据
String czDeviceIpPort = czRoadwayMap.get(ssj.getDeviceCode());
String[] split = czDeviceIpPort.split(":");
String weight = CheckWeight.sendWeight(split[0], Convert.toInt(split[1]));
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(ssj.getTaskNo()), ddj.getId()); DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(ssj.getTaskNo()), ddj.getId());
if (ObjUtil.isNull(ddjQueue)) { if (ObjUtil.isNull(ddjQueue) ) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue(); DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID()); ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
ddjDeviceExecutionQueue.setRwh(Convert.toLong(ssj.getTaskNo())); ddjDeviceExecutionQueue.setRwh(Convert.toLong(ssj.getTaskNo()));
@@ -344,7 +375,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.setSpare2(Convert.toStr(ssj.getHeight())); //ddjDeviceExecutionQueue.setSpare2(Convert.toStr(ddj.getHeight()));
ddjDeviceExecutionQueue.setSpare3(Convert.toStr(weight)); ddjDeviceExecutionQueue.setSpare3(Convert.toStr(weight));
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue); ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
} }
@@ -369,25 +400,11 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
//回传完成信号 //回传完成信号
ddjTaskFinish(rwh, ddj.getId(),1); ddjTaskFinish(rwh, ddj.getId(),1);
} }
}else if (ddjDeviceExecutionQueue.getRwlx()==1 && ddj.getHczt() == 1){
ddj.setHeight(Convert.toInt(ddjDeviceExecutionQueue.getSpare2()));
}else if (ddjDeviceExecutionQueue.getRwlx() == 4){ }else if (ddjDeviceExecutionQueue.getRwlx() == 4){
ddjTaskFinish(rwh, ddj.getId(),2); ddjTaskFinish(rwh, ddj.getId(),2);
} }
} }
} }
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 3 && ddj.getJdbz() == 5) {
Long rwh = ddj.getRwh();
//完成作业
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)){
if (ddjDeviceExecutionQueue.getRwlx()==1){
//完成队列
ddjTaskFinish(rwh, ddj.getId(),2);
ddj.setHeight(0);
}
}
}
/* /*
第二部分 第二部分
@@ -427,6 +444,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
ddjDeviceExecutionQueue.setMblh(basCargoSpace.getTheColumn()); ddjDeviceExecutionQueue.setMblh(basCargoSpace.getTheColumn());
ddjDeviceExecutionQueue.setMbch(basCargoSpace.getTheFloor()); ddjDeviceExecutionQueue.setMbch(basCargoSpace.getTheFloor());
ddjDeviceExecutionQueue.setSpare1("0"); ddjDeviceExecutionQueue.setSpare1("0");
ddjDeviceExecutionQueue.setDdjxf("0");
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue); ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
} }
} }
@@ -479,7 +497,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
} }
} }
//正常下发 //正常下发
if (ddj.getYxxf() == 1 && ddj.getCzfs() == 5) { if (ddj.getYxxf() == 1 && ddj.getCzfs() == 5 ) {
DdjDeviceExecutionQueue ddjDeviceExecutionRunningQueueParam = new DdjDeviceExecutionQueue(); DdjDeviceExecutionQueue ddjDeviceExecutionRunningQueueParam = new DdjDeviceExecutionQueue();
ddjDeviceExecutionRunningQueueParam.setDdjxf("1"); ddjDeviceExecutionRunningQueueParam.setDdjxf("1");
@@ -500,6 +518,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
ddjDeviceExecutionQueueParam.setRwlxList(rwlxList); ddjDeviceExecutionQueueParam.setRwlxList(rwlxList);
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam); List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) { if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
//todo 任务优先规则
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0); DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
int i = issuedDDJTask(ddj, ddjDeviceExecutionQueue); int i = issuedDDJTask(ddj, ddjDeviceExecutionQueue);
if (i == 1) { if (i == 1) {

View File

@@ -1,6 +1,7 @@
package com.ruoyi.schedule.scheduleTask.ddj; package com.ruoyi.schedule.scheduleTask.ddj;
import com.ruoyi.job.domain.MydoJob; import com.ruoyi.job.domain.MydoJob;
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
import java.util.HashMap; import java.util.HashMap;
@@ -19,6 +20,12 @@ public interface DdjThreadInterface {
*/ */
MydoJob getOutJobParam(); MydoJob getOutJobParam();
/**
* 获取当前出口是否存在任务
* @return
*/
DdjDeviceExecutionQueue getOtherOutDdjQueue(String exitSsj);
/** /**
* 初始化设备 * 初始化设备
*/ */

View File

@@ -3,6 +3,7 @@ package com.ruoyi.schedule.scheduleTask.ddj.impl;
import com.ruoyi.device.ddj.domain.MsgDdj; import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ssj.domain.DeviceSsj; import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.job.domain.MydoJob; import com.ruoyi.job.domain.MydoJob;
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead; import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead; import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread; import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
@@ -28,7 +29,7 @@ public class Ddj1Thread extends BaseDdjThread {
@Override @Override
public void init() { public void init() {
super.init(); /*super.init();
ddjCodeList = new HashMap<>(); ddjCodeList = new HashMap<>();
ssjList = new HashMap<>(); ssjList = new HashMap<>();
ArrayList<MsgDdj> ddjCodes = new ArrayList<>(); ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
@@ -63,7 +64,7 @@ public class Ddj1Thread extends BaseDdjThread {
roadwayRollback.put("L2007", 82); roadwayRollback.put("L2007", 82);
roadwayRollback.put("L2008", 83); roadwayRollback.put("L2008", 83);
log.info("Ddj1Thread init"); log.info("Ddj1Thread init");*/
} }
@@ -87,5 +88,10 @@ public class Ddj1Thread extends BaseDdjThread {
return mydoJob; return mydoJob;
} }
@Override
public DdjDeviceExecutionQueue getOtherOutDdjQueue(String exitSsj) {
return null;
}
} }

View File

@@ -3,6 +3,7 @@ package com.ruoyi.schedule.scheduleTask.ddj.impl;
import com.ruoyi.device.ddj.domain.MsgDdj; import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ssj.domain.DeviceSsj; import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.job.domain.MydoJob; import com.ruoyi.job.domain.MydoJob;
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead; import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead; import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread; import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
@@ -24,7 +25,7 @@ public class Ddj2Thread extends BaseDdjThread {
@Override @Override
public void init() { public void init() {
super.init(); /*super.init();
ddjCodeList = new HashMap<>(); ddjCodeList = new HashMap<>();
ssjList = new HashMap<>(); ssjList = new HashMap<>();
ArrayList<MsgDdj> ddjCodes = new ArrayList<>(); ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
@@ -59,7 +60,7 @@ public class Ddj2Thread extends BaseDdjThread {
roadwayRollback.put("L2009", 86); roadwayRollback.put("L2009", 86);
roadwayRollback.put("L2010", 87); roadwayRollback.put("L2010", 87);
log.info("Ddj2Thread init"); log.info("Ddj2Thread init");*/
} }
@@ -85,4 +86,9 @@ public class Ddj2Thread extends BaseDdjThread {
return mydoJob; return mydoJob;
} }
@Override
public DdjDeviceExecutionQueue getOtherOutDdjQueue(String exitSsj) {
return null;
}
} }

View File

@@ -3,6 +3,7 @@ package com.ruoyi.schedule.scheduleTask.ddj.impl;
import com.ruoyi.device.ddj.domain.MsgDdj; import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ssj.domain.DeviceSsj; import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.job.domain.MydoJob; import com.ruoyi.job.domain.MydoJob;
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead; import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead; import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread; import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
@@ -24,7 +25,7 @@ public class Ddj3Thread extends BaseDdjThread {
@Override @Override
public void init() { public void init() {
super.init(); /*super.init();
ddjCodeList = new HashMap<>(); ddjCodeList = new HashMap<>();
ssjList = new HashMap<>(); ssjList = new HashMap<>();
ArrayList<MsgDdj> ddjCodes = new ArrayList<>(); ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
@@ -60,7 +61,7 @@ public class Ddj3Thread extends BaseDdjThread {
roadwayRollback.put("L2011", 90); roadwayRollback.put("L2011", 90);
roadwayRollback.put("L2012", 91); roadwayRollback.put("L2012", 91);
log.info("Ddj3Thread init"); log.info("Ddj3Thread init");*/
} }
@Override @Override
@@ -85,4 +86,8 @@ public class Ddj3Thread extends BaseDdjThread {
return mydoJob; return mydoJob;
} }
@Override
public DdjDeviceExecutionQueue getOtherOutDdjQueue(String exitSsj) {
return null;
}
} }

View File

@@ -3,6 +3,7 @@ package com.ruoyi.schedule.scheduleTask.ddj.impl;
import com.ruoyi.device.ddj.domain.MsgDdj; import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ssj.domain.DeviceSsj; import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.job.domain.MydoJob; import com.ruoyi.job.domain.MydoJob;
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead; import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead; import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread; import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
@@ -11,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import static com.ruoyi.common.Constant.*; import static com.ruoyi.common.Constant.*;
@@ -27,27 +29,30 @@ public class Ddj4Thread extends BaseDdjThread {
super.init(); super.init();
ddjCodeList = new HashMap<>(); ddjCodeList = new HashMap<>();
ssjList = new HashMap<>(); ssjList = new HashMap<>();
ArrayList<MsgDdj> ddjCodes = new ArrayList<>(); ArrayList<String> ddjCodes = new ArrayList<>();
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj4")); ddjCodes.add("ddj4");
ddjCodeList.put("ddj", ddjCodes); ddjCodeList.put("ddj", ddjCodes);
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>(); ArrayList<String> roadSsjList = new ArrayList<>();
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1001")); roadSsjList.add("L1001");
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1002")); roadSsjList.add("L1002");
ssjList.put("roadSsjList", roadSsjList); ssjList.put("roadSsjList", roadSsjList);
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>(); ArrayList<String> outSsj1 = new ArrayList<>();
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L1001")); outSsj1.add("L1001");
ssjList.put("outSsj1", outSsj1); ssjList.put("outSsj1", outSsj1);
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>(); ArrayList<String> outSsj2 = new ArrayList<>();
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L1002")); outSsj2.add("L1002");
ssjList.put("outSsj2", outSsj2); ssjList.put("outSsj2", outSsj2);
//初始化巷道口 排 列 层 //初始化巷道口 排 列 层
roadwayMap.put("L1001", Arrays.asList(1, 0, 1)); roadwayMap.put("L1001", Arrays.asList(1, 0, 1));
roadwayMap.put("L1002", Arrays.asList(2, 0, 1)); roadwayMap.put("L1002", Arrays.asList(2, 0, 1));
//未扫码 回退任务号 无入库任务在此基础+100
roadwayRollback.put("L1001", 92); roadwayRollback.put("L1001", 92);
roadwayRollback.put("L1002", 93); roadwayRollback.put("L1002", 93);
//初始化称重设备连接ip port
czRoadwayMap.put("L1001", "192.168.57.101:4001");
czRoadwayMap.put("L1002", "192.168.57.101:4001");
log.info("Ddj4Thread init"); log.info("Ddj4Thread init");
} }
@@ -73,5 +78,15 @@ public class Ddj4Thread extends BaseDdjThread {
return mydoJob; return mydoJob;
} }
@Override
public DdjDeviceExecutionQueue getOtherOutDdjQueue(String exitSsj) {
List<Integer> integers = roadwayMap.get(exitSsj);
DdjDeviceExecutionQueue param = new DdjDeviceExecutionQueue();
param.setDevId(4);
param.setMbph(integers.get(0));
param.setMblh(integers.get(1));
param.setMbch(integers.get(2));
return param;
}
} }

View File

@@ -3,6 +3,7 @@ package com.ruoyi.schedule.scheduleTask.ddj.impl;
import com.ruoyi.device.ddj.domain.MsgDdj; import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ssj.domain.DeviceSsj; import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.job.domain.MydoJob; import com.ruoyi.job.domain.MydoJob;
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead; import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead; import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread; import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
@@ -27,18 +28,18 @@ public class Ddj5Thread extends BaseDdjThread {
super.init(); super.init();
ddjCodeList = new HashMap<>(); ddjCodeList = new HashMap<>();
ssjList = new HashMap<>(); ssjList = new HashMap<>();
ArrayList<MsgDdj> ddjCodes = new ArrayList<>(); ArrayList<String> ddjCodes = new ArrayList<>();
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj5")); ddjCodes.add("ddj5");
ddjCodeList.put("ddj", ddjCodes); ddjCodeList.put("ddj", ddjCodes);
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>(); ArrayList<String> roadSsjList = new ArrayList<>();
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1003")); roadSsjList.add("L1003");
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1004")); roadSsjList.add("L1004");
ssjList.put("roadSsjList", roadSsjList); ssjList.put("roadSsjList", roadSsjList);
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>(); ArrayList<String> outSsj1 = new ArrayList<>();
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L1003")); outSsj1.add("L1003");
ssjList.put("outSsj1", outSsj1); ssjList.put("outSsj1", outSsj1);
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>(); ArrayList<String> outSsj2 = new ArrayList<>();
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L1004")); outSsj2.add("L1004");
ssjList.put("outSsj2", outSsj2); ssjList.put("outSsj2", outSsj2);
//初始化巷道口 排 列 层 //初始化巷道口 排 列 层
@@ -71,5 +72,10 @@ public class Ddj5Thread extends BaseDdjThread {
return mydoJob; return mydoJob;
} }
@Override
public DdjDeviceExecutionQueue getOtherOutDdjQueue(String exitSsj) {
return null;
}
} }

View File

@@ -3,6 +3,7 @@ package com.ruoyi.schedule.scheduleTask.ddj.impl;
import com.ruoyi.device.ddj.domain.MsgDdj; import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ssj.domain.DeviceSsj; import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.job.domain.MydoJob; import com.ruoyi.job.domain.MydoJob;
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead; import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead; import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread; import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
@@ -27,18 +28,18 @@ public class Ddj6Thread extends BaseDdjThread {
super.init(); super.init();
ddjCodeList = new HashMap<>(); ddjCodeList = new HashMap<>();
ssjList = new HashMap<>(); ssjList = new HashMap<>();
ArrayList<MsgDdj> ddjCodes = new ArrayList<>(); ArrayList<String> ddjCodes = new ArrayList<>();
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj6")); ddjCodes.add("ddj6");
ddjCodeList.put("ddj", ddjCodes); ddjCodeList.put("ddj", ddjCodes);
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>(); ArrayList<String> roadSsjList = new ArrayList<>();
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1005")); roadSsjList.add("L1005");
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1006")); roadSsjList.add("L1006");
ssjList.put("roadSsjList", roadSsjList); ssjList.put("roadSsjList", roadSsjList);
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>(); ArrayList<String> outSsj1 = new ArrayList<>();
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L1005")); outSsj1.add("L1005");
ssjList.put("outSsj1", outSsj1); ssjList.put("outSsj1", outSsj1);
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>(); ArrayList<String> outSsj2 = new ArrayList<>();
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L1006")); outSsj2.add("L1006");
ssjList.put("outSsj2", outSsj2); ssjList.put("outSsj2", outSsj2);
//初始化巷道口 排 列 层 //初始化巷道口 排 列 层
@@ -73,5 +74,9 @@ public class Ddj6Thread extends BaseDdjThread {
return mydoJob; return mydoJob;
} }
@Override
public DdjDeviceExecutionQueue getOtherOutDdjQueue(String exitSsj) {
return null;
}
} }

View File

@@ -29,19 +29,19 @@ public class MonitoringThread implements Runnable {
public void run() { public void run() {
init(); init();
while (isRun){ while (isRun){
for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) {
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode);
deviceSsj.setTraySize(deviceSsj.getModel());
deviceSsjService.updateDeviceSsj(deviceSsj);
}
for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) {
msgDdjService.updateMsgDdj(PlcDdjRead.deviceDdjMap.get(ddjCode));
}
try { try {
for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) {
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode);
deviceSsjService.updateDeviceSsj(deviceSsj);
}
for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) {
msgDdjService.updateMsgDdj(PlcDdjRead.deviceDdjMap.get(ddjCode));
}
Thread.sleep(1500); Thread.sleep(1500);
} catch (InterruptedException e) { } catch (Exception e) {
throw new RuntimeException(e); log.error(e.getMessage(),e);
} }
} }
} }

View File

@@ -1,40 +1,52 @@
package com.ruoyi.schedule.util; package com.ruoyi.schedule.util;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.UnsupportedEncodingException;
import java.net.Socket; import java.net.Socket;
public class CheckWeight { public class CheckWeight {
public String sendWeight(String ip, int por) { public static String sendWeight(String ip, int por) {
String zhi = "e9"; String zhi = "0";
try ( try (
Socket socket = new Socket(ip, por); Socket socket = new Socket(ip, por);
InputStream is = socket.getInputStream(); InputStream is = socket.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(is);
) { ) {
Thread.sleep(1000); Thread.sleep(300);
char[] charArray = new char[8]; byte[] bytes = new byte[8];
int read = is.read(bytes);
if (read!=-1){
String weight = byteArrayToCharArray(bytes, "UTF-8");
weight = weight.substring(1,8);
weight = weight.replace("=","");
System.out.println("开始读取"); if (weight.length() == 7 && !weight.equals("0000000")) {
int readLength = inputStreamReader.read(charArray); zhi = weight;
System.out.println("readLength:" + readLength);
if (readLength != -1) {
String newString = new String(charArray, 0, readLength);
newString = newString.replaceAll("\r|\n", "");
if (newString.length() == 8 && !newString.equals("=0000000")) {
newString = newString.substring(1, 8);
newString = newString.replaceAll("^(0+)", "");
zhi = newString;
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return zhi; return zhi;
} }
/**
* 将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 {
if (byteArr == null) {
return null;
}
// 核心:先将byte数组按指定编码转为String,再转为char数组
return new String(byteArr, charset);
}
public static void main(String[] args) { public static void main(String[] args) {
CheckWeight checkWeight = new CheckWeight(); CheckWeight checkWeight = new CheckWeight();
System.out.println(checkWeight.sendWeight("192.168.56.101", 4001)); System.out.println(checkWeight.sendWeight("192.168.56.101", 4001));

View File

@@ -109,7 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="traySize != null">tray_size = #{traySize},</if> <if test="traySize != null">tray_size = #{traySize},</if>
<if test="allowPut != null">allow_put = #{allowPut},</if> <if test="allowPut != null">allow_put = #{allowPut},</if>
<if test="height != null">height = #{height},</if> <if test="height != null">height = #{height},</if>
<if test="sbzt != null">status = #{sbzt},</if> <if test="sbzt != null">sbzt = #{sbzt},</if>
<if test="jxdw != null">jxdw = #{jxdw},</if> <if test="jxdw != null">jxdw = #{jxdw},</if>
<if test="spare1 != null">spare1 = #{spare1},</if> <if test="spare1 != null">spare1 = #{spare1},</if>
</trim> </trim>

View File

@@ -22,13 +22,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="exitId" column="exit_id" /> <result property="exitId" column="exit_id" />
<result property="warehouseId" column="warehouse_id" /> <result property="warehouseId" column="warehouse_id" />
<result property="faultFlag" column="fault_flag" /> <result property="faultFlag" column="fault_flag" />
<result property="trayCode" column="tray_code" />
</resultMap> </resultMap>
<sql id="selectMydoJobVo"> <sql id="selectMydoJobVo">
select job_id, status, task_no, roadway_id, cargo_space_id, target_roadway_id, target_cargo_space_id, priority, execution_phase, in_or_out, create_time, start_time, finish_time, entrance_id, exit_id, warehouse_id, fault_flag from mydo_job_wcs select job_id, status, task_no, roadway_id, cargo_space_id, target_roadway_id, target_cargo_space_id, priority, execution_phase, in_or_out, create_time, start_time, finish_time, entrance_id, exit_id, warehouse_id, fault_flag,tray_code from mydo_job_wcs
</sql> </sql>
<sql id="selectMydoJobFinishVo"> <sql id="selectMydoJobFinishVo">
select job_id, status, task_no, roadway_id, cargo_space_id, target_roadway_id, target_cargo_space_id, priority, execution_phase, in_or_out, create_time, start_time, finish_time, entrance_id, exit_id, warehouse_id, fault_flag from mydo_job_wcs_finish select job_id, status, task_no, roadway_id, cargo_space_id, target_roadway_id, target_cargo_space_id, priority, execution_phase, in_or_out, create_time, start_time, finish_time, entrance_id, exit_id, warehouse_id, fault_flag,tray_code from mydo_job_wcs_finish
</sql> </sql>
<select id="selectMydoJobList" parameterType="MydoJob" resultMap="MydoJobResult"> <select id="selectMydoJobList" parameterType="MydoJob" resultMap="MydoJobResult">
@@ -49,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="exitId != null and exitId != ''"> and exit_id = #{exitId}</if> <if test="exitId != null and exitId != ''"> and exit_id = #{exitId}</if>
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if> <if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
<if test="faultFlag != null and faultFlag != ''"> and fault_flag = #{faultFlag}</if> <if test="faultFlag != null and faultFlag != ''"> and fault_flag = #{faultFlag}</if>
<if test="trayCode != null and trayCode != ''"> and tray_code = #{trayCode}</if>
</where> </where>
</select> </select>

View File

@@ -79,6 +79,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where rwh = #{rwh} and dev_id = #{devId} where rwh = #{rwh} and dev_id = #{devId}
</select> </select>
<select id="selectOutJobCount">
select count(*) from ddj_device_execution_queue
where mbph = #{mbph} and mblh=#{mblh} and mbch=#{mbch} and dev_id = #{devId}
</select>
<insert id="insertDdjDeviceExecutionQueue" parameterType="DdjDeviceExecutionQueue"> <insert id="insertDdjDeviceExecutionQueue" parameterType="DdjDeviceExecutionQueue">
insert into ddj_device_execution_queue insert into ddj_device_execution_queue