ctu入库相关流程修改
This commit is contained in:
@@ -5,6 +5,8 @@ import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.CustomThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.bs.BsInSsjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.js.JsInSsjThread;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -19,6 +21,9 @@ public class ScheduleThread {
|
||||
@Autowired
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
|
||||
public CustomThread bsInSsjThread;
|
||||
public CustomThread jsInSsjThread;
|
||||
|
||||
/**
|
||||
* 项目初始化启动
|
||||
*/
|
||||
@@ -37,6 +42,12 @@ public class ScheduleThread {
|
||||
PlcRead plcRead = new PlcRead(list,ssjPlcConnectInfo);
|
||||
Thread plcReadThread = new Thread(plcRead);
|
||||
customThread = new CustomThread(plcReadThread, plcRead);
|
||||
|
||||
//调度初始化
|
||||
BsInSsjThread bsInSsjThread1 = new BsInSsjThread();
|
||||
bsInSsjThread = new CustomThread(new Thread(bsInSsjThread1),bsInSsjThread1);
|
||||
JsInSsjThread jsInSsjThread1 = new JsInSsjThread();
|
||||
jsInSsjThread = new CustomThread(new Thread(jsInSsjThread1),bsInSsjThread1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,6 +57,11 @@ public class ScheduleThread {
|
||||
customThread.getThread().start();
|
||||
}
|
||||
|
||||
public void startAllThread2() {
|
||||
bsInSsjThread.getThread().start();
|
||||
jsInSsjThread.getThread().start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止线程
|
||||
*/
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
@@ -23,58 +25,143 @@ import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class BsInSsjThread {
|
||||
public class BsInSsjThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ssjCodeList = new HashMap<>();
|
||||
log.info("初始化臂式入库输送机");
|
||||
//入库口
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1003");
|
||||
ssjCodes.add("G1009");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
//流利架
|
||||
ArrayList<String> ssjCodes2 = new ArrayList<>();
|
||||
ssjCodes2.add("LLJ1");
|
||||
ssjCodes2.add("LLJ2");
|
||||
ssjCodes2.add("LLJ3");
|
||||
ssjCodes2.add("LLJ4");
|
||||
ssjCodes2.add("LLJ5");
|
||||
ssjCodeList.put("in2", ssjCodes2);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("in".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
case "in":
|
||||
//正常入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "in2":
|
||||
//流利架 空料箱入库
|
||||
for (String lljCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
inLljDispatch(lljCode);
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 流利架空料箱入库
|
||||
* @param lljCode
|
||||
*/
|
||||
private void inLljDispatch(String lljCode) {
|
||||
//查询流利架未开始的作业
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setStatus("1");
|
||||
mydoJobParam.setEntranceId(lljCode);
|
||||
MydoJob mydoJob = apiService.requestEnter(mydoJobParam);
|
||||
if (ObjUtil.isNotNull(mydoJob) && !"6".equals(mydoJob.getExecutionPhase())) {
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setWmsTaskNo(mydoJob.getTaskNo());
|
||||
agvQueueParam.setPositionCode1(lljCode);
|
||||
agvQueueParam.setStatus("0");
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
|
||||
if (CollUtil.isEmpty(agvQueues)) {
|
||||
//生成agv队列
|
||||
AgvQueue agvQueue = createAgvQueue(lljCode, mydoJob);
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = requestAgvQueue(mydoJob, agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
//修改mydoJob执行阶段
|
||||
mydoJob.setExecutionPhase("6");
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if (ObjUtil.isNull(mydoJob)){
|
||||
log.info("无入库库作业 lljCode:{}", lljCode);
|
||||
}
|
||||
if ("6".equals(mydoJob.getExecutionPhase())) {
|
||||
log.info("入库库作业已下发 taskNo:{}", mydoJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输送线入库
|
||||
* @param inSsjDevice
|
||||
*/
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
//根据入口,查询对应的入库作业
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
//mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
mydoJobParam.setStatus("1");
|
||||
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
|
||||
List<MydoJob> mydoJobs = apiService.getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobs)) {
|
||||
MydoJob mydoJob = mydoJobs.get(0);
|
||||
//修改mydojob入口
|
||||
MydoJob mydoJob = apiService.requestEnter(mydoJobParam);
|
||||
if (ObjUtil.isNotNull(mydoJob) && !"6".equals(mydoJob.getExecutionPhase())){
|
||||
//通知wms 当前料箱的入库口
|
||||
mydoJob.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setWmsTaskNo(mydoJob.getTaskNo());
|
||||
@@ -83,7 +170,7 @@ public class BsInSsjThread {
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
|
||||
if (CollUtil.isEmpty(agvQueues)) {
|
||||
//生成agv队列
|
||||
AgvQueue agvQueue = createAgvQueue(inSsjDevice, mydoJob);
|
||||
AgvQueue agvQueue = createAgvQueue(inSsjDevice.getDeviceCode(), mydoJob);
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = requestAgvQueue(mydoJob, agvQueue);
|
||||
//修改wms任务状态
|
||||
@@ -96,51 +183,28 @@ public class BsInSsjThread {
|
||||
mydoJob.setExecutionPhase("6");
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
}
|
||||
} else {
|
||||
AgvQueue agvQueue = agvQueues.get(0);
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = requestAgvQueue(mydoJob, agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
//修改mydoJob执行阶段
|
||||
mydoJob.setExecutionPhase("6");
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
mydoJobParam.setStatus("3");
|
||||
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
|
||||
mydoJobs = apiService.getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobs)) {
|
||||
log.info("trayCode:{} 入库作业正在执行中", inSsjDevice.getTrayCode());
|
||||
} else {
|
||||
log.info("trayCode:{} 无入库作业", inSsjDevice.getTrayCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成入库AGV队列
|
||||
*
|
||||
* @param ssjDevice
|
||||
* @param positionCode1
|
||||
* @param mydoJob
|
||||
* @return
|
||||
*/
|
||||
private AgvQueue createAgvQueue(DeviceSsj ssjDevice, MydoJob mydoJob) {
|
||||
private AgvQueue createAgvQueue(String positionCode1, MydoJob mydoJob) {
|
||||
//生成ctu执行队列
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
String reqCode = IdUtil.fastSimpleUUID();
|
||||
agvQueue.setReqCode(reqCode);
|
||||
agvQueue.setReqTime(DateUtil.formatDateTime(DateUtil.date()));
|
||||
agvQueue.setAgvType("CTU");
|
||||
agvQueue.setPositionCode1(mydoJob.getCargoSpaceId());
|
||||
agvQueue.setPositionCode2(ssjDevice.getDeviceCode());
|
||||
agvQueue.setPositionCode1(positionCode1);
|
||||
agvQueue.setPositionCode2(mydoJob.getCargoSpaceId());
|
||||
agvQueue.setTaskType("F01");
|
||||
agvQueue.setCtnrType("0");
|
||||
agvQueue.setCtnrCode("0");
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.ruoyi.schedule.scheduleTask.ssj.js;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
@@ -23,18 +25,16 @@ import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JsInSsjThread {
|
||||
public class JsInSsjThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ssjCodeList = new HashMap<>();
|
||||
@@ -47,19 +47,41 @@ public class JsInSsjThread {
|
||||
ssjCodes.add("G5009");
|
||||
ssjCodes.add("G5018");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("in".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
case "in":
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -70,16 +92,13 @@ public class JsInSsjThread {
|
||||
if (inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
//根据入口,查询对应的入库作业
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
//mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
mydoJobParam.setStatus("1");
|
||||
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
|
||||
List<MydoJob> mydoJobs = apiService.getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobs)) {
|
||||
MydoJob mydoJob = mydoJobs.get(0);
|
||||
//修改mydojob入口
|
||||
MydoJob mydoJob = apiService.requestEnter(mydoJobParam);
|
||||
if (ObjUtil.isNotNull(mydoJob) && !"6".equals(mydoJob.getExecutionPhase())){
|
||||
//通知wms 当前料箱的入库口
|
||||
mydoJob.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setWmsTaskNo(mydoJob.getTaskNo());
|
||||
@@ -101,32 +120,9 @@ public class JsInSsjThread {
|
||||
mydoJob.setExecutionPhase("6");
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
}
|
||||
} else {
|
||||
AgvQueue agvQueue = agvQueues.get(0);
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = requestAgvQueue(mydoJob, agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
//修改mydoJob执行阶段
|
||||
mydoJob.setExecutionPhase("6");
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
mydoJobParam.setStatus("3");
|
||||
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
|
||||
mydoJobs = apiService.getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobs)) {
|
||||
log.info("trayCode:{} 入库作业正在执行中", inSsjDevice.getTrayCode());
|
||||
} else {
|
||||
log.info("trayCode:{} 无入库作业", inSsjDevice.getTrayCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ public class JsPickSsjTread {
|
||||
}
|
||||
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void run(){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("pick".equals(type)) {
|
||||
|
||||
Reference in New Issue
Block a user