堆垛机调度初始化
This commit is contained in:
@@ -0,0 +1,256 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.ruoyi.api.domain.wcs2wms.JobParam;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.job.service.IMydoJobService;
|
||||
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
|
||||
import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueFinishService;
|
||||
import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueService;
|
||||
import com.ruoyi.schedule.plcRead.ddj.IsoTcpClientDDJ1;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj1Thread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ddjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||
private IDdjDeviceExecutionQueueFinishService ddjDeviceExecutionQueueFinishService;
|
||||
private IMydoJobService mydoJobService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ddjCodeList = new HashMap<>();
|
||||
ArrayList<String> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add("ddj1");
|
||||
ddjCodes.add("ddj2");
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||
ddjDeviceExecutionQueueFinishService = SpringUtils.getBean(IDdjDeviceExecutionQueueFinishService.class);
|
||||
log.info("初始化服务 {},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ddjCodeList.keySet()) {
|
||||
|
||||
if ("ddj".equals(type)) {
|
||||
for (String ddjCode : ddjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceDdjMap.containsKey(ddjCode)) {
|
||||
ddjTask(PlcRead.deviceDdjMap.get(ddjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ddjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ddjTask(MsgDdj ddj) {
|
||||
/*
|
||||
第一部分
|
||||
堆垛机线程进来后第一件事先进行堆垛机正执行任务的账务处理
|
||||
以防存在漏处理,没处理的情况发生
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 0 && ddj.getJdbz() == 5) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//完成作业
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
|
||||
if (mydoJob != null && ddjDeviceExecutionQueue != null) {
|
||||
//回传完成信号
|
||||
ddjTaskFinish(rwh, ddj.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第二部分
|
||||
跟踪队列执行阶段
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1 && (ddj.getJdbz() == 2 || ddj.getJdbz() == 3 || ddj.getJdbz() == 4)) {
|
||||
//根据堆垛机上任务号,修改任务执行阶段
|
||||
Long rwh = ddj.getRwh();
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
|
||||
if (ddjDeviceExecutionQueue != null) {
|
||||
//修改队列执行阶段
|
||||
ddjDeviceExecutionQueue.setRwzt(ddj.getJdbz());
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第三部分
|
||||
放货有货,重新分配货位
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1052 && ddj.getJdbz() < 5 && ddj.getYxxf() == 1) {
|
||||
//判断堆垛机上任务是否已重分,若未重分,则调用接口,请求重分货位
|
||||
Long rwh = ddj.getRwh();
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||
if ("0".equals(mydoJob.getFaultFlag())){
|
||||
mydoJob.setStatus("1");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
AjaxResult ajaxResult = apiService.reAssignMydoJob(new JobParam(rwh.toString(), null, null));
|
||||
if (ajaxResult.isSuccess()){
|
||||
mydoJob.setStatus("2");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第四部分
|
||||
取货无货,重新分配单据
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1053 && ddj.getJdbz() < 5) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//无货异常处理
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
|
||||
//找到对应任务 调用api接口 取货无货,重新分配单据
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
AjaxResult ajaxResult = apiService.reAssignMydoJob2(new JobParam(rwh.toString(), null, null));
|
||||
if (ajaxResult.isSuccess()) {
|
||||
//作废作业
|
||||
InvalidMydoJob(rwh, ddj.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第五部分
|
||||
堆垛机任务下发
|
||||
*/
|
||||
if (ddj.getYxxf() == 1 && ddj.getCzfs() == 5 && ddj.getSbzt() == 1052) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//查询作业
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||
if (ObjUtil.isNotNull(mydoJob) && "2".equals(mydoJob.getFaultFlag())) {
|
||||
//判断任务是否重分完成
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
//重新下发堆垛机任务
|
||||
int i = issuedDDJTask(ddj.getId(), ddjDeviceExecutionQueue);
|
||||
if (i == 1) {
|
||||
//更新开始时间,修改ddjxf为已下发1
|
||||
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
|
||||
ddjDeviceExecutionQueue.setDdjxf("1");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
mydoJob.setFaultFlag("0");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
log.info("托盘堆垛机重新下发任务成功 rwh:{}", rwh);
|
||||
} else {
|
||||
log.error("托盘堆垛机重新下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//正常下发
|
||||
if (ddj.getYxxf() == 1 && ddj.getCzfs() == 5 && ddj.getSbzt() == 0) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//对堆垛机执行队列中无已下发队列
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("1");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
//取堆垛机队列中,生成时间最早的执行队列下发
|
||||
if (CollUtil.isEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
if (ddjDeviceExecutionQueue == null) {
|
||||
return;
|
||||
}
|
||||
int i = issuedDDJTask(ddj.getId(), ddjDeviceExecutionQueue);
|
||||
if (i == 1) {
|
||||
//更新开始时间,修改ddjxf为已下发1
|
||||
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
|
||||
ddjDeviceExecutionQueue.setDdjxf("1");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
log.info("托盘堆垛机下发任务成功 rwh:{}", rwh);
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废作业
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void InvalidMydoJob(Long rwh, Long id) {
|
||||
mydoJobService.InvalidMydoJob(rwh, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 堆垛机任务完成
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void ddjTaskFinish(Long rwh, Long id) {
|
||||
mydoJobService.ddjTaskFinish(rwh, id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 给堆垛机下发任务
|
||||
*
|
||||
* @param queue 堆垛机执行的队列
|
||||
*/
|
||||
private int issuedDDJTask(Long devId, DdjDeviceExecutionQueue queue) {
|
||||
int taskNo = Convert.toInt(queue.getRwh());
|
||||
int yph = Convert.toInt(queue.getYph());
|
||||
int ylh = Convert.toInt(queue.getYlh());
|
||||
int ych = Convert.toInt(queue.getYch());
|
||||
int mbph = Convert.toInt(queue.getMbph());
|
||||
int mblh = Convert.toInt(queue.getMblh());
|
||||
int mbch = Convert.toInt(queue.getMbch());
|
||||
int mlfs = 5;
|
||||
int xfwc = 1;
|
||||
int jym = Tools.getJYM(taskNo, yph, ylh, ych, mbph, mblh, mbch, mlfs, xfwc);
|
||||
byte[] sendData = Tools.sendDataToDevice(taskNo, null, yph, ylh, ych, mbph, mblh, mbch, mlfs, xfwc, jym);
|
||||
if (devId==1){
|
||||
return IsoTcpClientDDJ1.WritetoDDJ("DB61.0", sendData);
|
||||
}else {
|
||||
return IsoTcpClientDDJ1.WritetoDDJ("DB61.0", sendData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.js;
|
||||
package com.ruoyi.schedule.scheduleTask.ddj;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.job.domain.MydoJob;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class JsInSsjThread implements Runnable {
|
||||
public class Ddj2Thread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
@@ -58,8 +58,8 @@ public class JsInSsjThread implements Runnable {
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.bas.fluent.domain.BasFluentFrame;
|
||||
import com.ruoyi.bas.fluent.service.IBasFluentFrameService;
|
||||
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;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class BsOutSsjThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
private IBasFluentFrameService basFluentFrameService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1004");
|
||||
ssjCodes.add("G1010");
|
||||
ssjCodeList.put("ssjOut", ssjCodes);
|
||||
ArrayList<String> fluentOut = new ArrayList<>();
|
||||
fluentOut.add("fluent1");
|
||||
fluentOut.add("fluent2");
|
||||
ssjCodeList.put("fluentOut", fluentOut);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
basFluentFrameService = SpringUtils.getBean(IBasFluentFrameService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
switch (type){
|
||||
case "ssjOut":
|
||||
//正常输送线出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
ssjOutDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "fluentOut":
|
||||
//流利架出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
fluentOutDispatch(ssjCode);
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 输送线出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void ssjOutDispatch(DeviceSsj outSsjDevice) {
|
||||
//输送线出库
|
||||
if (outSsjDevice.getKx()==1){
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice.getDeviceCode());
|
||||
agvQueue.setStatus("0");
|
||||
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
if (CollUtil.isNotEmpty(agvQueueList)){
|
||||
for (AgvQueue queue : agvQueueList) {
|
||||
apiService.requestAgvQueue(queue);
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* todo 流利架出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void fluentOutDispatch(String outSsjDevice) {
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice);
|
||||
agvQueue.setStatus("0");
|
||||
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
for (AgvQueue queue : agvQueueList) {
|
||||
//修改实际流利架货位
|
||||
BasFluentFrame basFluentFrame = basFluentFrameService.selectBasFluentFrameOrderByAllotNum(queue.getPositionCode2());
|
||||
if (basFluentFrame != null){
|
||||
queue.setPositionCode2(basFluentFrame.getLocationName());
|
||||
agvQueueService.updateAgvQueue(queue);
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(queue);
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
queue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(queue);
|
||||
log.info("向CTU下入库库作业");
|
||||
//更新流利架
|
||||
basFluentFrame.setTrayCode(queue.getWmsTraycode());
|
||||
basFluentFrame.setAllotNum(1L);
|
||||
basFluentFrameService.updateBasFluentFrame(basFluentFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.api.domain.RequestLog;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.bas.port.domain.WcsPort;
|
||||
import com.ruoyi.bas.port.service.IWcsPortService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.ruoyi.common.Constant.JOB_FINISH_URL;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class BsPickSsjTread implements Runnable{
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
private IWcsPortService wcsPortService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1006");
|
||||
ssjCodes.add("G1012");
|
||||
ssjCodeList.put("pick", ssjCodes);
|
||||
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
wcsPortService = SpringUtils.getBean(IWcsPortService.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("pick".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
pickDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void pickDispatch(DeviceSsj pickSsjDevice) {
|
||||
if (pickSsjDevice.getDw() == 1 && pickSsjDevice.getTaskNo() > 0) {
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("1".equals(wcsPort.getStatus())){
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("taskNo", pickSsjDevice.getTaskNo());
|
||||
param.put("wmsType", "2");
|
||||
param.put("pickSsj", pickSsjDevice.getDeviceCode());
|
||||
RequestLog requestLog = apiService.finishMydoJob(JOB_FINISH_URL, "出库任务到达拣选口", param);
|
||||
if ("1".equals(requestLog.getIsSuccessful())){
|
||||
wcsPort.setStatus("2");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}else {
|
||||
log.error("任务失败{}", requestLog.getErrorDetails());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (pickSsjDevice.getKx() == 1 && pickSsjDevice.getTaskNo() == 0){
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("2".equals(wcsPort.getStatus())){
|
||||
wcsPort.setStatus("1");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,33 +1,25 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.floor1;
|
||||
|
||||
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.job.domain.MydoJob;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class BsInSsjThread implements Runnable {
|
||||
public class Floor1SsjInOutThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
@@ -40,25 +32,15 @@ public class BsInSsjThread implements Runnable {
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ssjCodeList = new HashMap<>();
|
||||
log.info("初始化臂式入库输送机");
|
||||
//入库口
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1003");
|
||||
ssjCodes.add("G1009");
|
||||
ssjCodeList.put("ssjIn", ssjCodes);
|
||||
//流利架
|
||||
ArrayList<String> ssjCodes2 = new ArrayList<>();
|
||||
ssjCodes2.add("fluent1-11");
|
||||
ssjCodes2.add("fluent1-12");
|
||||
ssjCodes2.add("fluent1-13");
|
||||
ssjCodes2.add("fluent1-14");
|
||||
ssjCodes2.add("fluent1-15");
|
||||
ssjCodes2.add("fluent2-11");
|
||||
ssjCodes2.add("fluent2-12");
|
||||
ssjCodes2.add("fluent2-13");
|
||||
ssjCodes2.add("fluent2-14");
|
||||
ssjCodes2.add("fluent2-15");
|
||||
ssjCodeList.put("fluentIn", ssjCodes2);
|
||||
ssjCodes.add("G2012");
|
||||
ssjCodes.add("G3009");
|
||||
ssjCodes.add("G3018");
|
||||
ssjCodes.add("G4009");
|
||||
ssjCodes.add("G4018");
|
||||
ssjCodes.add("G5009");
|
||||
ssjCodes.add("G5018");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
@@ -68,36 +50,24 @@ public class BsInSsjThread implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch (type) {
|
||||
case "ssjIn":
|
||||
//正常入库
|
||||
switch ( type){
|
||||
case "in":
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "fluentIn":
|
||||
//流利架 空料箱入库
|
||||
for (String lljCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
inLljDispatch(lljCode);
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -108,44 +78,9 @@ public class BsInSsjThread implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 流利架空料箱入库
|
||||
*
|
||||
* @param lljCode
|
||||
*/
|
||||
private void inLljDispatch(String lljCode) {
|
||||
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setPositionCode1(lljCode);
|
||||
agvQueueParam.setStatus("0");
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
|
||||
if (CollUtil.isNotEmpty(agvQueues)) {
|
||||
for (AgvQueue agvQueue : agvQueues) {
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 输送线入库
|
||||
*
|
||||
* @param inSsjDevice
|
||||
*/
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw()==1 && inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
@@ -166,7 +101,7 @@ public class BsInSsjThread implements Runnable {
|
||||
//生成agv队列
|
||||
AgvQueue agvQueue = apiService.createAgvQueue(inSsjDevice.getName(), mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo(),"1");
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue( agvQueue);
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
@@ -194,7 +129,4 @@ public class BsInSsjThread implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.floor1;
|
||||
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Floor1SsjRoadWayThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> in = new ArrayList<>();
|
||||
in.add("L2003");
|
||||
in.add("L2005");
|
||||
ssjCodeList.put("in", in);
|
||||
ArrayList<String> out = new ArrayList<>();
|
||||
in.add("L2003");
|
||||
in.add("L2005");
|
||||
ssjCodeList.put("out", out);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch (type) {
|
||||
case "in":
|
||||
//退料入库 其它入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "out":
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
outDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void outDispatch(DeviceSsj outSsjDevice) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw() == 1 && inSsjDevice.getTaskNo() > 0 && inSsjDevice.getRkqq() == 1) {
|
||||
//查询货位 排列层
|
||||
|
||||
//查询入口 排列层
|
||||
|
||||
//生成堆垛机队列
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.floor2;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Floor2SsjInOutThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G2012");
|
||||
ssjCodes.add("G3009");
|
||||
ssjCodes.add("G3018");
|
||||
ssjCodes.add("G4009");
|
||||
ssjCodes.add("G4018");
|
||||
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() {
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
case "in":
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw()==1 && inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setWmsTraycode(inSsjDevice.getTrayCode());
|
||||
//agvQueueParam.setStatus("0");
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
|
||||
if (CollUtil.isEmpty(agvQueues)) {
|
||||
//根据入口,查询对应的入库作业
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setStatus("1");
|
||||
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
|
||||
mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
MydoJob mydoJob = apiService.requestEnterByTrayCode(mydoJobParam);
|
||||
if (ObjUtil.isNotNull(mydoJob)) {
|
||||
|
||||
//生成agv队列
|
||||
AgvQueue agvQueue = apiService.createAgvQueue(inSsjDevice.getName(), mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo(),"1");
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}else {
|
||||
AgvQueue agvQueue = agvQueues.get(0);
|
||||
if ("0".equals(agvQueue.getStatus())){
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.floor2;
|
||||
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Floor2SsjRoadWayThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("L1002");
|
||||
ssjCodes.add("L1004");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
case "in":
|
||||
//生产线入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw() == 1 && inSsjDevice.getTaskNo() > 0 && inSsjDevice.getRkqq() == 1) {
|
||||
//查询货位 排列层
|
||||
|
||||
//查询入口 排列层
|
||||
|
||||
//生成堆垛机队列
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.js;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.api.domain.agv.continueTask.ContinueTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.continueTask.ContinueTaskResponse;
|
||||
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;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class JsOutSsjThread implements Runnable{
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G2001");
|
||||
ssjCodes.add("G3001");
|
||||
ssjCodes.add("G3010");
|
||||
ssjCodes.add("G4001");
|
||||
ssjCodes.add("G4010");
|
||||
ssjCodes.add("G5001");
|
||||
ssjCodes.add("G5010");
|
||||
ssjCodeList.put("ssjOut", ssjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
switch (type){
|
||||
case "ssjOut":
|
||||
try {
|
||||
//正常输送线出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
ssjOutDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
break;
|
||||
case "fluentOut":
|
||||
//流利架出口(剪式没有)
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 输送线出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void ssjOutDispatch(DeviceSsj outSsjDevice) {
|
||||
if (outSsjDevice.getKx()==1){
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice.getDeviceCode());
|
||||
agvQueue.setStatus("0");
|
||||
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
if (CollUtil.isNotEmpty(agvQueueList)){
|
||||
for (AgvQueue queue : agvQueueList) {
|
||||
requestAgvQueue( queue);
|
||||
}
|
||||
}else {
|
||||
log.info("ssjCode:{},没有待下发的出库任务", outSsjDevice.getDeviceCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求海康生成agv任务,并修改wms任务状态
|
||||
* @param agvQueue
|
||||
*/
|
||||
private void requestAgvQueue(AgvQueue agvQueue) {
|
||||
//请求ctu
|
||||
GenAgvSchedulingTaskRequest genAgvSchedulingTaskRequest = new GenAgvSchedulingTaskRequest();
|
||||
genAgvSchedulingTaskRequest.setReqCode(agvQueue.getReqCode());
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setPriority("10");
|
||||
genAgvSchedulingTaskRequest.setTaskTyp("F01");
|
||||
genAgvSchedulingTaskRequest.setCtnrCode("0");
|
||||
genAgvSchedulingTaskRequest.setCtnrNum("0");
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setTaskCode(agvQueue.getTaskCode());
|
||||
genAgvSchedulingTaskRequest.setAgvTyp("CTU");
|
||||
genAgvSchedulingTaskRequest.setPositionSelStrategy("0");
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.genAgvSchedulingTask(genAgvSchedulingTaskRequest);
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0){
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.js;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.api.domain.RequestLog;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.bas.port.domain.WcsPort;
|
||||
import com.ruoyi.bas.port.service.IWcsPortService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.ruoyi.common.Constant.JOB_FINISH_URL;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class JsPickSsjTread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
private IWcsPortService wcsPortService;
|
||||
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G5013");
|
||||
ssjCodes.add("G5014");
|
||||
ssjCodes.add("G5015");
|
||||
ssjCodes.add("G5004");
|
||||
ssjCodes.add("G5005");
|
||||
ssjCodes.add("G5006");
|
||||
ssjCodes.add("G4013");
|
||||
ssjCodes.add("G4014");
|
||||
ssjCodes.add("G4015");
|
||||
ssjCodes.add("G4004");
|
||||
ssjCodes.add("G4005");
|
||||
ssjCodes.add("G4006");
|
||||
ssjCodeList.put("pick", ssjCodes);
|
||||
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
wcsPortService = SpringUtils.getBean(IWcsPortService.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("pick".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
pickDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void pickDispatch(DeviceSsj pickSsjDevice) {
|
||||
if (pickSsjDevice.getDw() == 1 && pickSsjDevice.getTaskNo() > 0) {
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("1".equals(wcsPort.getStatus())){
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("taskNo", pickSsjDevice.getTaskNo());
|
||||
param.put("wmsType", "2");
|
||||
param.put("pickSsj", pickSsjDevice.getDeviceCode());
|
||||
RequestLog requestLog = apiService.finishMydoJob(JOB_FINISH_URL, "出库任务到达拣选口", param);
|
||||
if ("1".equals(requestLog.getIsSuccessful())){
|
||||
wcsPort.setStatus("2");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}else {
|
||||
log.error("任务失败{}", requestLog.getErrorDetails());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (pickSsjDevice.getKx() == 1 && pickSsjDevice.getTaskNo() == 0){
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("2".equals(wcsPort.getStatus())){
|
||||
wcsPort.setStatus("1");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.monitor;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class CarMonitorThread implements Runnable {
|
||||
|
||||
|
||||
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
|
||||
log.info("初始化服务 {}", deviceSsjService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String ssjCode : PlcRead.deviceMap.keySet()) {
|
||||
try {
|
||||
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
|
||||
if (ObjUtil.isNotNull(deviceSsj)){
|
||||
switch (deviceSsj.getType()) {
|
||||
case "1":
|
||||
monitor1(deviceSsj);
|
||||
break;
|
||||
case "2":
|
||||
monitor2(deviceSsj);
|
||||
break;
|
||||
case "3":
|
||||
monitor3(deviceSsj);
|
||||
break;
|
||||
case "4":
|
||||
monitor4(deviceSsj);
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
log.error("设备不存在 {}", ssjCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*其他输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor4(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*入库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor3(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*拣选输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor2(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*出库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor1(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.monitor;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class SsjMonitorThread implements Runnable {
|
||||
|
||||
|
||||
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
|
||||
log.info("初始化服务 {}", deviceSsjService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String ssjCode : PlcRead.deviceMap.keySet()) {
|
||||
try {
|
||||
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
|
||||
if (ObjUtil.isNotNull(deviceSsj)){
|
||||
switch (deviceSsj.getType()) {
|
||||
case "1":
|
||||
monitor1(deviceSsj);
|
||||
break;
|
||||
case "2":
|
||||
monitor2(deviceSsj);
|
||||
break;
|
||||
case "3":
|
||||
monitor3(deviceSsj);
|
||||
break;
|
||||
case "4":
|
||||
monitor4(deviceSsj);
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
log.error("设备不存在 {}", ssjCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(15000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*其他输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor4(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*入库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor3(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*拣选输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor2(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*出库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor1(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user