一楼单向出库口-生成堆垛机队列 到达出口完成mydojob任务,并通知wms
This commit is contained in:
@@ -1,19 +1,28 @@
|
||||
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.ArrayUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.ruoyi.api.domain.RequestLog;
|
||||
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.job.domain.MydoJob;
|
||||
import com.ruoyi.job.service.IMydoJobService;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static com.ruoyi.common.TaskType.DDJ_RWLX_2;
|
||||
|
||||
/**
|
||||
* 一楼单向出库线程 循环出库作业+巷道口空闲 生成堆垛机出库队列
|
||||
@@ -22,28 +31,41 @@ import java.util.Map;
|
||||
public class Floor1SingleSsjThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
|
||||
private IMydoJobService mydoJobService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
private Map<String,String> exitRoadwayMap = new HashMap<>();
|
||||
private final Map<String,String> exitRoadwayMap = new HashMap<>();
|
||||
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||
private IBasCargoSpaceService basCargoSpaceService;
|
||||
private Map<String,List<Integer>> roadwayMap = new HashMap<>();
|
||||
|
||||
|
||||
public void init() {
|
||||
//设置要循环的输送机
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("L2001");
|
||||
ssjCodes.add("L2007");
|
||||
ssjCodeList.put("outRoadwaySsj", ssjCodes);
|
||||
ArrayList<String> outRoadwaySsjList = new ArrayList<>();
|
||||
outRoadwaySsjList.add("L2001");
|
||||
outRoadwaySsjList.add("L2007");
|
||||
ssjCodeList.put("outRoadwaySsj", outRoadwaySsjList);
|
||||
ArrayList<String> outSsjList = new ArrayList<>();
|
||||
outSsjList.add("L2002");
|
||||
outSsjList.add("L2008");
|
||||
ssjCodeList.put("outSsj", outSsjList);
|
||||
|
||||
|
||||
//初始化服务
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
exitRoadwayMap.put("L2001","L2011");
|
||||
exitRoadwayMap.put("L2007","L2014");
|
||||
log.info("初始化服务 {},{}", apiService, mydoJobService);
|
||||
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||
basCargoSpaceService = SpringUtils.getBean(IBasCargoSpaceService.class);
|
||||
|
||||
//初始化出口和巷道口映射关系
|
||||
exitRoadwayMap.put("L2001","L2002");
|
||||
exitRoadwayMap.put("L2007","L2008");
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L2001",Arrays.asList(1,1,1));
|
||||
roadwayMap.put("L2007",Arrays.asList(1,1,1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,7 +73,7 @@ public class Floor1SingleSsjThread implements Runnable {
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
//一楼单向出库口
|
||||
//一楼单向巷道口
|
||||
if ("outRoadwaySsj".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
@@ -66,6 +88,19 @@ public class Floor1SingleSsjThread implements Runnable {
|
||||
|
||||
}
|
||||
}
|
||||
if ("outSsj".equals(type)){
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
dispatch2(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
@@ -76,14 +111,67 @@ public class Floor1SingleSsjThread implements Runnable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 一楼单向出库口调度
|
||||
*
|
||||
* @param ssj 输送机
|
||||
*/
|
||||
private void dispatch2(DeviceSsj ssj) {
|
||||
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 ssj 输送机
|
||||
*/
|
||||
public void dispatch(DeviceSsj ssj) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (ssj.getKx()==1){
|
||||
String exitId = exitRoadwayMap.get(ssj.getDeviceCode());
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByExitList(List.of(exitId));
|
||||
List<String> exitList = new ArrayList<>();
|
||||
exitList.add(exitId);
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByExitList(exitList);
|
||||
if (ObjUtil.isNotNull(mydoJob)){
|
||||
//生成队列
|
||||
BasCargoSpace basCargoSpace = basCargoSpaceService.selectBasCargoSpaceByWmsCargoSpaceId(mydoJob.getCargoSpaceId());
|
||||
if (ObjUtil.isNull(basCargoSpace)){
|
||||
log.error("货位不存在 cargoSpaceId{}",mydoJob.getCargoSpaceId());
|
||||
}else {
|
||||
//生成队列
|
||||
List<DdjDeviceExecutionQueue> list = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueListByRwlx(DDJ_RWLX_2);
|
||||
List<Integer> pclList = roadwayMap.get(ssj.getDeviceCode());
|
||||
if (CollUtil.isEmpty(list) && 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(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_2);
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user