一楼入库调度逻辑
This commit is contained in:
@@ -79,4 +79,5 @@ public class DeviceSsj extends BaseEntity
|
|||||||
private int traySize;
|
private int traySize;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,4 +70,6 @@ public interface MydoJobMapper
|
|||||||
void insertHistory(String jobId);
|
void insertHistory(String jobId);
|
||||||
|
|
||||||
List<MydoJob> selectInOrOutMydoJobList(MydoJob mydoJob);
|
List<MydoJob> selectInOrOutMydoJobList(MydoJob mydoJob);
|
||||||
|
|
||||||
|
MydoJob selectMydoJobByEntranceList(@Param("entranceList") List<String> entranceList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,4 +70,6 @@ public interface IMydoJobService
|
|||||||
void insertHistory(String jobId);
|
void insertHistory(String jobId);
|
||||||
|
|
||||||
List<MydoJob> selectInOrOutMydoJobList(MydoJob mydoJob);
|
List<MydoJob> selectInOrOutMydoJobList(MydoJob mydoJob);
|
||||||
|
|
||||||
|
MydoJob selectMydoJobByEntranceList(List<String> entranceList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,4 +141,9 @@ public class MydoJobServiceImpl implements IMydoJobService
|
|||||||
public List<MydoJob> selectInOrOutMydoJobList(MydoJob mydoJob) {
|
public List<MydoJob> selectInOrOutMydoJobList(MydoJob mydoJob) {
|
||||||
return mydoJobMapper.selectInOrOutMydoJobList(mydoJob);
|
return mydoJobMapper.selectInOrOutMydoJobList(mydoJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MydoJob selectMydoJobByEntranceList(List<String> entranceList) {
|
||||||
|
return mydoJobMapper.selectMydoJobByEntranceList(entranceList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ruoyi.queue.ddj.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
|
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 堆垛机执行队列Mapper接口
|
* 堆垛机执行队列Mapper接口
|
||||||
@@ -59,5 +60,5 @@ public interface DdjDeviceExecutionQueueMapper
|
|||||||
*/
|
*/
|
||||||
public int deleteDdjDeviceExecutionQueueByUuids(String[] uuids);
|
public int deleteDdjDeviceExecutionQueueByUuids(String[] uuids);
|
||||||
|
|
||||||
List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(Integer rwlx);
|
List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(@Param("rwlx")Integer rwlx,@Param("devId") Integer devId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,5 +61,5 @@ public interface IDdjDeviceExecutionQueueService
|
|||||||
|
|
||||||
DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwh(Long rwh);
|
DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwh(Long rwh);
|
||||||
|
|
||||||
List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(Integer rwlx);
|
List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(Integer rwlx,Integer devId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class DdjDeviceExecutionQueueServiceImpl implements IDdjDeviceExecutionQu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(Integer rwlx) {
|
public List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(Integer rwlx,Integer devId) {
|
||||||
return ddjDeviceExecutionQueueMapper.selectDdjDeviceExecutionQueueListByRwlx(rwlx);
|
return ddjDeviceExecutionQueueMapper.selectDdjDeviceExecutionQueueListByRwlx(rwlx,devId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,32 @@
|
|||||||
package com.ruoyi.schedule.scheduleTask.ssj.floor1;
|
package com.ruoyi.schedule.scheduleTask.ssj.floor1;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||||
import com.ruoyi.api.service.IApiService;
|
import com.ruoyi.api.service.IApiService;
|
||||||
|
import com.ruoyi.bas.cargospace.domain.BasCargoSpace;
|
||||||
|
import com.ruoyi.bas.cargospace.service.IBasCargoSpaceService;
|
||||||
|
import com.ruoyi.common.domain.SendData;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import com.ruoyi.job.domain.MydoJob;
|
import com.ruoyi.job.domain.MydoJob;
|
||||||
|
import com.ruoyi.job.service.IMydoJobService;
|
||||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||||
|
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
|
||||||
|
import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueService;
|
||||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||||
|
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import static com.ruoyi.common.TaskType.DDJ_RWLX_2;
|
||||||
|
import static com.ruoyi.common.TaskType.DDJ_RWLX_3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一楼双向线体入库线程 条码+到位+无出库作业 下发去向+任务号 有出库作业就下发退回
|
* 一楼双向线体入库线程 条码+到位+无出库作业 下发去向+任务号 有出库作业就下发退回
|
||||||
@@ -24,46 +35,58 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class Floor1BothWayInSsjThread implements Runnable {
|
public class Floor1BothWayInSsjThread implements Runnable {
|
||||||
|
|
||||||
public HashMap<String, List<String>> ssjCodeList;
|
public HashMap<String, DeviceSsj> ssjCodeList;
|
||||||
|
|
||||||
private IApiService apiService;
|
private IApiService apiService;
|
||||||
private IAgvQueueService agvQueueService;
|
private IAgvQueueService agvQueueService;
|
||||||
|
private IMydoJobService mydoJobService;
|
||||||
|
private IBasCargoSpaceService basCargoSpaceService;
|
||||||
|
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||||
|
private final Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||||
|
private final Map<String, String> exitRoadwayMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public boolean isRun = true;
|
public boolean isRun = true;
|
||||||
|
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
ssjCodeList = new HashMap<>();
|
ssjCodeList = new HashMap<>();
|
||||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
ssjCodeList.put("roadway1", PlcSsjRead.deviceSsjMap.get("L2003"));
|
||||||
ssjCodes.add("L1002");
|
ssjCodeList.put("roadway2", PlcSsjRead.deviceSsjMap.get("L2005"));
|
||||||
ssjCodes.add("L1004");
|
ssjCodeList.put("in1", PlcSsjRead.deviceSsjMap.get("L2012"));
|
||||||
ssjCodeList.put("in", ssjCodes);
|
ssjCodeList.put("in2", PlcSsjRead.deviceSsjMap.get("L2005"));
|
||||||
|
|
||||||
|
|
||||||
apiService = SpringUtils.getBean(IApiService.class);
|
apiService = SpringUtils.getBean(IApiService.class);
|
||||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||||
|
basCargoSpaceService = SpringUtils.getBean(IBasCargoSpaceService.class);
|
||||||
|
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||||
|
|
||||||
|
|
||||||
|
//初始化巷道口 排 列 层
|
||||||
|
roadwayMap.put("L2003", Arrays.asList(1, 1, 1));
|
||||||
|
roadwayMap.put("L2005", Arrays.asList(1, 1, 1));
|
||||||
|
|
||||||
|
exitRoadwayMap.put("L2003", "L2012");
|
||||||
|
exitRoadwayMap.put("L2005", "L2013");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
init();
|
init();
|
||||||
while (isRun){
|
while (isRun) {
|
||||||
|
|
||||||
for (String type : ssjCodeList.keySet()) {
|
for (String type : ssjCodeList.keySet()) {
|
||||||
|
switch (type) {
|
||||||
switch ( type){
|
case "roadway1":
|
||||||
case "in":
|
case "roadway2":
|
||||||
//生产线入库
|
dispatch1(ssjCodeList.get(type));
|
||||||
for (String ssjCode : ssjCodeList.get(type)) {
|
break;
|
||||||
try {
|
case "in1":
|
||||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
case "in2":
|
||||||
inDispatch(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
dispatch2(ssjCodeList.get(type));
|
||||||
} else {
|
|
||||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
log.error(e.getMessage(),e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,17 +99,101 @@ public class Floor1BothWayInSsjThread implements Runnable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dispatch1(DeviceSsj ssj) {
|
||||||
|
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0) {
|
||||||
|
int taskNo = ssj.getTaskNo();
|
||||||
|
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(taskNo));
|
||||||
|
if (ObjUtil.isNotNull(mydoJob)) {
|
||||||
|
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueListByRwlx(DDJ_RWLX_3, Convert.toInt(mydoJob.getRoadwayId()));
|
||||||
|
BasCargoSpace basCargoSpace = basCargoSpaceService.selectBasCargoSpaceByWmsCargoSpaceId(mydoJob.getCargoSpaceId());
|
||||||
|
List<Integer> pclList = roadwayMap.get(ssj.getDeviceCode());
|
||||||
|
if (CollUtil.isEmpty(ddjDeviceExecutionQueues) && ObjUtil.isNotNull(basCargoSpace) && CollUtil.isNotEmpty(pclList)) {
|
||||||
|
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||||
|
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
|
||||||
|
ddjDeviceExecutionQueue.setRwh(Convert.toLong(mydoJob.getTaskNo()));
|
||||||
|
ddjDeviceExecutionQueue.setDevName(mydoJob.getRoadwayId());
|
||||||
|
ddjDeviceExecutionQueue.setDevId(Convert.toInt(mydoJob.getRoadwayId()));
|
||||||
|
ddjDeviceExecutionQueue.setRwzt(0);
|
||||||
|
ddjDeviceExecutionQueue.setYph(pclList.get(0));
|
||||||
|
ddjDeviceExecutionQueue.setYlh(pclList.get(1));
|
||||||
|
ddjDeviceExecutionQueue.setYch(pclList.get(2));
|
||||||
|
ddjDeviceExecutionQueue.setMbph(Convert.toInt(basCargoSpace.getThePlatoon()));
|
||||||
|
ddjDeviceExecutionQueue.setMblh(Convert.toInt(basCargoSpace.getTheColumn()));
|
||||||
|
ddjDeviceExecutionQueue.setMbch(Convert.toInt(basCargoSpace.getTheFloor()));
|
||||||
|
ddjDeviceExecutionQueue.setDdjxf("0");
|
||||||
|
ddjDeviceExecutionQueue.setMlfs(5);
|
||||||
|
ddjDeviceExecutionQueue.setScsj(DateUtil.formatDateTime(DateUtil.date()));
|
||||||
|
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_3);
|
||||||
|
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
private void dispatch2(DeviceSsj ssj) {
|
||||||
//如果入库请求1 并且 托盘码不为空
|
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0 && ssj.getRkqq() == 1) {
|
||||||
if (inSsjDevice.getDw() == 1 && inSsjDevice.getTaskNo() > 0 && inSsjDevice.getRkqq() == 1) {
|
//先检测有没有出库作业,有出库作业直接退回
|
||||||
//查询货位 排列层
|
MydoJob outMydoJob = mydoJobService.selectMydoJobByExitList(Collections.singletonList(exitRoadwayMap.get(ssj.getDeviceCode())));
|
||||||
|
if (ObjUtil.isNotNull(outMydoJob)) {
|
||||||
|
//回退
|
||||||
|
SendData qx = new SendData(Tools.INT, 2);
|
||||||
|
byte[] bytes = Tools.sendData(qx);
|
||||||
|
int i = 0;
|
||||||
|
//下发去向 和任务号
|
||||||
|
switch (ssj.getDeviceCode()) {
|
||||||
|
case "L2005":
|
||||||
|
i = PlcSsjRead.WriteToSSJ("DB501.20", bytes);
|
||||||
|
|
||||||
//查询入口 排列层
|
break;
|
||||||
|
case "L2012":
|
||||||
|
i = PlcSsjRead.WriteToSSJ("DB501.30", bytes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == 1) {
|
||||||
|
log.info("未检测到托盘码下发回退 rwh:{},qx:{},trayCode:{}", ssj.getTaskNo(), 1, ssj.getTrayCode());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (StrUtil.isNotEmpty(ssj.getTrayCode())) {
|
||||||
|
SendData qx = new SendData(Tools.INT, 1);
|
||||||
|
SendData rwh = new SendData(Tools.DINT, ssj.getTaskNo());
|
||||||
|
byte[] bytes = Tools.sendData(qx, rwh);
|
||||||
|
int i = 0;
|
||||||
|
//下发去向 和任务号
|
||||||
|
switch (ssj.getDeviceCode()) {
|
||||||
|
case "L2005":
|
||||||
|
i = PlcSsjRead.WriteToSSJ("DB501.20", bytes);
|
||||||
|
|
||||||
//生成堆垛机队列
|
break;
|
||||||
|
case "L2012":
|
||||||
|
i = PlcSsjRead.WriteToSSJ("DB501.30", bytes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == 1) {
|
||||||
|
log.info("入库请求下发任务号加去向 rwh:{},qx:{},trayCode:{}", ssj.getTaskNo(), 1, ssj.getTrayCode());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//回退
|
||||||
|
SendData qx = new SendData(Tools.INT, 2);
|
||||||
|
byte[] bytes = Tools.sendData(qx);
|
||||||
|
int i = 0;
|
||||||
|
//下发去向 和任务号
|
||||||
|
switch (ssj.getDeviceCode()) {
|
||||||
|
case "L2005":
|
||||||
|
i = PlcSsjRead.WriteToSSJ("DB501.20", bytes);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "L2012":
|
||||||
|
i = PlcSsjRead.WriteToSSJ("DB501.30", bytes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == 1) {
|
||||||
|
log.info("未检测到托盘码下发回退 rwh:{},qx:{},trayCode:{}", ssj.getTaskNo(), 1, ssj.getTrayCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package com.ruoyi.schedule.scheduleTask.ssj.floor1;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
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.RequestLog;
|
||||||
|
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||||
|
import com.ruoyi.api.service.IApiService;
|
||||||
|
import com.ruoyi.bas.cargospace.domain.BasCargoSpace;
|
||||||
|
import com.ruoyi.bas.cargospace.service.IBasCargoSpaceService;
|
||||||
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||||
|
import com.ruoyi.job.domain.MydoJob;
|
||||||
|
import com.ruoyi.job.service.IMydoJobService;
|
||||||
|
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||||
|
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||||
|
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
|
||||||
|
import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueService;
|
||||||
|
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.ruoyi.common.TaskType.DDJ_RWLX_2;
|
||||||
|
import static com.ruoyi.common.TaskType.DDJ_RWLX_3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一楼双向线体出库线程 循环盘点出库作业+巷道口空闲+出库线体全部空闲+无入库作业 生成堆垛机出库队列
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class Floor1BothWayOutSsjThread implements Runnable {
|
||||||
|
|
||||||
|
public HashMap<String, List<DeviceSsj>> ssjCodeList;
|
||||||
|
|
||||||
|
private IApiService apiService;
|
||||||
|
private IAgvQueueService agvQueueService;
|
||||||
|
private IMydoJobService mydoJobService;
|
||||||
|
private IBasCargoSpaceService basCargoSpaceService;
|
||||||
|
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||||
|
private final Map<String,List<Integer>> roadwayMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isRun = true;
|
||||||
|
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
ssjCodeList = new HashMap<>();
|
||||||
|
ArrayList<DeviceSsj> roadway1 = new ArrayList<>();
|
||||||
|
roadway1.add(PlcSsjRead.deviceSsjMap.get("L2003"));
|
||||||
|
roadway1.add(PlcSsjRead.deviceSsjMap.get("L2004"));
|
||||||
|
roadway1.add(PlcSsjRead.deviceSsjMap.get("L2012"));
|
||||||
|
ssjCodeList.put("roadway1", roadway1);
|
||||||
|
ArrayList<DeviceSsj> roadway2 = new ArrayList<>();
|
||||||
|
roadway2.add(PlcSsjRead.deviceSsjMap.get("L2005"));
|
||||||
|
roadway2.add(PlcSsjRead.deviceSsjMap.get("L2006"));
|
||||||
|
roadway2.add(PlcSsjRead.deviceSsjMap.get("L2013"));
|
||||||
|
ssjCodeList.put("roadway2", roadway2);
|
||||||
|
ArrayList<DeviceSsj> ou1 = new ArrayList<>();
|
||||||
|
ou1.add(PlcSsjRead.deviceSsjMap.get("L2012"));
|
||||||
|
ssjCodeList.put("ou1", ou1);
|
||||||
|
ArrayList<DeviceSsj> out2 = new ArrayList<>();
|
||||||
|
out2.add(PlcSsjRead.deviceSsjMap.get("L2013"));
|
||||||
|
ssjCodeList.put("out2", out2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
apiService = SpringUtils.getBean(IApiService.class);
|
||||||
|
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||||
|
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||||
|
basCargoSpaceService = SpringUtils.getBean(IBasCargoSpaceService.class);
|
||||||
|
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||||
|
|
||||||
|
|
||||||
|
//初始化巷道口 排 列 层
|
||||||
|
roadwayMap.put("L2003",Arrays.asList(1,1,1));
|
||||||
|
roadwayMap.put("L2005",Arrays.asList(1,1,1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
init();
|
||||||
|
while (isRun){
|
||||||
|
for (String type : ssjCodeList.keySet()) {
|
||||||
|
|
||||||
|
switch (type){
|
||||||
|
case "roadway1":
|
||||||
|
case "roadway2":
|
||||||
|
dispatch(ssjCodeList.get(type));
|
||||||
|
break;
|
||||||
|
case "out1":
|
||||||
|
case "out2":
|
||||||
|
dispatch1(ssjCodeList.get(type));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(1500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dispatch1(List<DeviceSsj> ssjList) {
|
||||||
|
for (DeviceSsj ssj : ssjList) {
|
||||||
|
if (ssj.getDw()==1 && ssj.getTaskNo()>0){
|
||||||
|
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(ssj.getTaskNo()));
|
||||||
|
if (ObjUtil.isNotNull(mydoJob)) {
|
||||||
|
HashMap<String,Object> param = new HashMap<>();
|
||||||
|
param.put("taskNo",mydoJob.getTaskNo());
|
||||||
|
param.put("jobId",mydoJob.getJobId());
|
||||||
|
RequestLog result = apiService.finishMydoJob(param);
|
||||||
|
if ("1".equals(result.getIsSuccessful())){
|
||||||
|
log.info("完成任务 taskNo{} ",mydoJob.getTaskNo());
|
||||||
|
mydoJobService.insertHistory(mydoJob.getJobId());
|
||||||
|
mydoJobService.deleteMydoJobByJobId(mydoJob.getJobId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出库堆垛机队列生成
|
||||||
|
* @param ssjList
|
||||||
|
*/
|
||||||
|
public void dispatch(List<DeviceSsj> ssjList) {
|
||||||
|
DeviceSsj deviceSsj = ssjList.get(ssjList.size() - 1);
|
||||||
|
MydoJob pdOutJob = mydoJobService.selectMydoJobByExitList(Collections.singletonList(deviceSsj.getDeviceCode()));
|
||||||
|
MydoJob inJob = mydoJobService.selectMydoJobByEntranceList(Collections.singletonList(deviceSsj.getDeviceCode()));
|
||||||
|
boolean allKx = ssjList.stream().allMatch(ssj -> ssj.getKx() == 1);
|
||||||
|
if (ObjUtil.isNotNull(pdOutJob) && allKx && ObjUtil.isNull(inJob)) {
|
||||||
|
//所有线体为空闲 并且存在出库作业 并且不存在入库作业
|
||||||
|
BasCargoSpace basCargoSpace = basCargoSpaceService.selectBasCargoSpaceByWmsCargoSpaceId(pdOutJob.getCargoSpaceId());
|
||||||
|
if (ObjUtil.isNull(basCargoSpace)){
|
||||||
|
log.error("货位不存在 cargoSpaceId{}",pdOutJob.getCargoSpaceId());
|
||||||
|
}else {
|
||||||
|
//生成队列
|
||||||
|
List<DdjDeviceExecutionQueue> list = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueListByRwlx(DDJ_RWLX_3,Convert.toInt(pdOutJob.getRoadwayId()));
|
||||||
|
List<Integer> pclList = roadwayMap.get(ssjList.get(0).getDeviceCode());
|
||||||
|
if (CollUtil.isEmpty(list) && CollUtil.isNotEmpty(pclList)){
|
||||||
|
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||||
|
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
|
||||||
|
ddjDeviceExecutionQueue.setRwh(Convert.toLong(pdOutJob.getTaskNo()));
|
||||||
|
ddjDeviceExecutionQueue.setDevName(pdOutJob.getRoadwayId());
|
||||||
|
ddjDeviceExecutionQueue.setDevId(Convert.toInt(pdOutJob.getRoadwayId()));
|
||||||
|
ddjDeviceExecutionQueue.setRwzt(0);
|
||||||
|
ddjDeviceExecutionQueue.setYph(Convert.toInt(basCargoSpace.getThePlatoon()));
|
||||||
|
ddjDeviceExecutionQueue.setYlh(Convert.toInt(basCargoSpace.getTheColumn()));
|
||||||
|
ddjDeviceExecutionQueue.setYch(Convert.toInt(basCargoSpace.getTheFloor()));
|
||||||
|
ddjDeviceExecutionQueue.setMbph(pclList.get(0));
|
||||||
|
ddjDeviceExecutionQueue.setMblh(pclList.get(1));
|
||||||
|
ddjDeviceExecutionQueue.setMbch(pclList.get(2));
|
||||||
|
ddjDeviceExecutionQueue.setDdjxf("0");
|
||||||
|
ddjDeviceExecutionQueue.setMlfs(5);
|
||||||
|
ddjDeviceExecutionQueue.setScsj(DateUtil.formatDateTime(DateUtil.date()));
|
||||||
|
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_3);
|
||||||
|
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
package com.ruoyi.schedule.scheduleTask.ssj.floor1;
|
|
||||||
|
|
||||||
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.device.ssj.domain.DeviceSsj;
|
|
||||||
import com.ruoyi.job.domain.MydoJob;
|
|
||||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
|
||||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
|
||||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 一楼双向线体出库线程 循环盘点出库作业+巷道口空闲+出库线体全部空闲+无入库作业 生成堆垛机出库队列
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class Floor1BothWaySsjOutThread 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 (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
|
||||||
inDispatch(PlcSsjRead.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) {
|
|
||||||
//查询货位 排列层
|
|
||||||
|
|
||||||
//查询入口 排列层
|
|
||||||
|
|
||||||
//生成堆垛机队列
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -37,7 +37,7 @@ public class Floor1SingleSsjThread implements Runnable {
|
|||||||
private final Map<String,String> exitRoadwayMap = new HashMap<>();
|
private final Map<String,String> exitRoadwayMap = new HashMap<>();
|
||||||
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||||
private IBasCargoSpaceService basCargoSpaceService;
|
private IBasCargoSpaceService basCargoSpaceService;
|
||||||
private Map<String,List<Integer>> roadwayMap = new HashMap<>();
|
private final Map<String,List<Integer>> roadwayMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
@@ -150,7 +150,7 @@ public class Floor1SingleSsjThread implements Runnable {
|
|||||||
log.error("货位不存在 cargoSpaceId{}",mydoJob.getCargoSpaceId());
|
log.error("货位不存在 cargoSpaceId{}",mydoJob.getCargoSpaceId());
|
||||||
}else {
|
}else {
|
||||||
//生成队列
|
//生成队列
|
||||||
List<DdjDeviceExecutionQueue> list = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueListByRwlx(DDJ_RWLX_2);
|
List<DdjDeviceExecutionQueue> list = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueListByRwlx(DDJ_RWLX_2,Convert.toInt(mydoJob));
|
||||||
List<Integer> pclList = roadwayMap.get(ssj.getDeviceCode());
|
List<Integer> pclList = roadwayMap.get(ssj.getDeviceCode());
|
||||||
if (CollUtil.isEmpty(list) && CollUtil.isNotEmpty(pclList)){
|
if (CollUtil.isEmpty(list) && CollUtil.isNotEmpty(pclList)){
|
||||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||||
|
|||||||
@@ -35,8 +35,10 @@ public class LineSsjThread implements Runnable {
|
|||||||
ssjCodeList = new HashMap<>();
|
ssjCodeList = new HashMap<>();
|
||||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||||
ssjCodes.add("G1005");
|
ssjCodes.add("G1005");
|
||||||
// ssjCodes.add("L1004");
|
|
||||||
ssjCodeList.put("line", ssjCodes);
|
ssjCodeList.put("line", ssjCodes);
|
||||||
|
ArrayList<String> inSsjList = new ArrayList<>();
|
||||||
|
inSsjList.add("L1011");
|
||||||
|
inSsjList.add("L1012");
|
||||||
apiService = SpringUtils.getBean(IApiService.class);
|
apiService = SpringUtils.getBean(IApiService.class);
|
||||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||||
|
|||||||
@@ -182,4 +182,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="jobId != null and jobId != ''"> and job_id = #{jobId}</if>
|
<if test="jobId != null and jobId != ''"> and job_id = #{jobId}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectMydoJobByEntranceList" resultMap="MydoJobResult">
|
||||||
|
select TOP 1 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
|
||||||
|
where entrance_id in
|
||||||
|
<foreach item="item" index="index" collection="entranceList" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
and in_or_out <= 20 ans status = 3
|
||||||
|
order by priority desc,create_time desc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectDdjDeviceExecutionQueueListByRwlx"
|
<select id="selectDdjDeviceExecutionQueueListByRwlx"
|
||||||
resultMap="DdjDeviceExecutionQueueResult">
|
resultMap="DdjDeviceExecutionQueueResult">
|
||||||
<include refid="selectDdjDeviceExecutionQueueVo"/>
|
<include refid="selectDdjDeviceExecutionQueueVo"/>
|
||||||
where rwlx = #{rwlx}
|
where rwlx = #{rwlx} and dev_id = #{devId}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user