优化代码结构 删除重复代码
This commit is contained in:
@@ -183,7 +183,7 @@ public class ApiServiceImpl implements IApiService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消ctu任务
|
||||
* 取消任务
|
||||
*
|
||||
* @param jobParam
|
||||
* @return
|
||||
|
||||
@@ -21,5 +21,9 @@ public class Constant {
|
||||
public static final String WAREHOUSE_01 = "01";
|
||||
public static final String WAREHOUSE_02 = "02";
|
||||
|
||||
public static final int ROADWAY_ID_01 = 1;
|
||||
public static final int ROADWAY_ID_02 = 2;
|
||||
public static final int ROADWAY_ID_03 = 3;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.*;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.impl.Ddj1Thread;
|
||||
import com.ruoyi.schedule.scheduleTask.monit.MonitoringThread;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -22,21 +22,17 @@ 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.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.ruoyi.common.Constant.WAREHOUSE_01;
|
||||
import static com.ruoyi.common.TaskStatusCode.*;
|
||||
import static com.ruoyi.common.TaskType.DDJ_RWLX_2;
|
||||
import static com.ruoyi.common.TaskType.DDJ_RWLX_3;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj1Thread implements Runnable {
|
||||
|
||||
public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
public HashMap<String, List<MsgDdj>> ddjCodeList;
|
||||
public HashMap<String, List<DeviceSsj>> ssjList;
|
||||
|
||||
@@ -46,43 +42,16 @@ public class Ddj1Thread implements Runnable {
|
||||
private IMsgDdjService msgDdjService;
|
||||
private IMydoJobService mydoJobService;
|
||||
private IBasCargoSpaceService basCargoSpaceService;
|
||||
private final Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||
public Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
@Override
|
||||
public abstract HashMap<String, Object> getParamMap(String trayCode);
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ddjCodeList = new HashMap<>();
|
||||
ssjList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj1"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2001"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2002"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2007"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2008"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L2001"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L2002"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
ArrayList<DeviceSsj> outSsj3 = new ArrayList<>();
|
||||
outSsj3.add(PlcSsjRead.deviceSsjMap.get("L2007"));
|
||||
ssjList.put("outSsj3", outSsj3);
|
||||
ArrayList<DeviceSsj> outSsj4 = new ArrayList<>();
|
||||
outSsj4.add(PlcSsjRead.deviceSsjMap.get("L2008"));
|
||||
ssjList.put("outSsj4", outSsj4);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L2001", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L2002", Arrays.asList(2, 1, 1));
|
||||
roadwayMap.put("L2007", Arrays.asList(1, 22, 1));
|
||||
roadwayMap.put("L2008", Arrays.asList(2, 22, 1));
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||
ddjDeviceExecutionQueueFinishService = SpringUtils.getBean(IDdjDeviceExecutionQueueFinishService.class);
|
||||
@@ -129,11 +98,7 @@ public class Ddj1Thread implements Runnable {
|
||||
* 创建出库队列
|
||||
*/
|
||||
private void generateOutBoundQueue(MsgDdj ddj) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setInOut("2");
|
||||
param.setWarehouseId(WAREHOUSE_01);
|
||||
param.setRoadwayId(Convert.toStr(ddj.getId()));
|
||||
List<MydoJob> outJobList = mydoJobService.selectMydoJobList(param);
|
||||
List<MydoJob> outJobList = mydoJobService.selectMydoJobList(getOutJobParam());
|
||||
if (CollUtil.isNotEmpty(outJobList)) {
|
||||
for (MydoJob outJob : outJobList) {
|
||||
String exitId = outJob.getExitId();
|
||||
@@ -187,24 +152,23 @@ public class Ddj1Thread implements Runnable {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract MydoJob getOutJobParam();
|
||||
|
||||
/**
|
||||
* 创建入库放货队列
|
||||
*/
|
||||
private void generateInBoundLoadQueue(MsgDdj ddj) {
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 3 && ddj.getYxxf() == 1) {
|
||||
//允许下发 联机 有货待机
|
||||
if (StrUtil.isNotEmpty(ddj.getTrayCode().trim())) {
|
||||
if (ddj.getTrayCode() != null && StrUtil.isNotEmpty(ddj.getTrayCode().trim())) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setTrayCode(ddj.getTrayCode());
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
|
||||
MydoJob inJob = null;
|
||||
if (CollUtil.isEmpty(mydoJobs)) {
|
||||
//请求wms获取任务 并生成队列
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", ddj.getTrayCode());
|
||||
paramMap.put("warehouseId",WAREHOUSE_01);
|
||||
|
||||
AjaxResult result = apiService.selectMydoJobByTrayCodeAndEntranceId(paramMap);
|
||||
AjaxResult result = apiService.selectMydoJobByTrayCodeAndEntranceId(getParamMap(ddj.getTrayCode()));
|
||||
if (result.isSuccess()) {
|
||||
inJob = BeanUtil.toBean(result.get("data"), MydoJob.class);
|
||||
inJob.setStatus(TASK_STATUS_CREATE);
|
||||
@@ -282,6 +246,9 @@ public class Ddj1Thread implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建入库取货队列
|
||||
*/
|
||||
@@ -525,6 +492,4 @@ public class Ddj1Thread implements Runnable {
|
||||
return PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,462 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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 cn.hutool.core.util.StrUtil;
|
||||
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.device.ddj.service.IMsgDdjService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
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.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.ruoyi.common.Constant.WAREHOUSE_01;
|
||||
import static com.ruoyi.common.TaskStatusCode.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj2Thread implements Runnable {
|
||||
|
||||
public HashMap<String, List<MsgDdj>> ddjCodeList;
|
||||
public HashMap<String, List<DeviceSsj>> ssjList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||
private IDdjDeviceExecutionQueueFinishService ddjDeviceExecutionQueueFinishService;
|
||||
private IMsgDdjService msgDdjService;
|
||||
private IMydoJobService mydoJobService;
|
||||
private final Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ddjCodeList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj2"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2003"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2004"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2009"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2010"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L2003"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L2004"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
ArrayList<DeviceSsj> outSsj3 = new ArrayList<>();
|
||||
outSsj3.add(PlcSsjRead.deviceSsjMap.get("L2009"));
|
||||
ssjList.put("outSsj3", outSsj3);
|
||||
ArrayList<DeviceSsj> outSsj4 = new ArrayList<>();
|
||||
outSsj4.add(PlcSsjRead.deviceSsjMap.get("L2010"));
|
||||
ssjList.put("outSsj4", outSsj4);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L2001", Arrays.asList(3, 1, 1));
|
||||
roadwayMap.put("L2002", Arrays.asList(4, 1, 1));
|
||||
roadwayMap.put("L2007", Arrays.asList(3, 22, 1));
|
||||
roadwayMap.put("L2008", Arrays.asList(4, 22, 1));
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||
ddjDeviceExecutionQueueFinishService = SpringUtils.getBean(IDdjDeviceExecutionQueueFinishService.class);
|
||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ddjCodeList.keySet()) {
|
||||
|
||||
for (MsgDdj msgDdj : ddjCodeList.get(type)) {
|
||||
try {
|
||||
if (ObjUtil.isNotNull(msgDdj)) {
|
||||
if (0 == msgDdj.getSpare1()) {
|
||||
generateInBoundPickQueue(msgDdj);
|
||||
generateInBoundLoadQueue(msgDdj);
|
||||
generateOutBoundQueue(msgDdj);
|
||||
ddjTask(msgDdj);
|
||||
}
|
||||
} else {
|
||||
log.error("堆垛机设备为空");
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建出库队列
|
||||
*/
|
||||
private void generateOutBoundQueue(MsgDdj ddj) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setInOut("2");
|
||||
param.setWarehouseId(WAREHOUSE_01);
|
||||
param.setRoadwayId(Convert.toStr(ddj.getId()));
|
||||
List<MydoJob> outJobList = mydoJobService.selectMydoJobList(param);
|
||||
if (CollUtil.isNotEmpty(outJobList)) {
|
||||
for (MydoJob outJob : outJobList) {
|
||||
String exitId = outJob.getExitId();
|
||||
|
||||
String outSsj = "";
|
||||
switch (exitId) {
|
||||
case "1":
|
||||
List<DeviceSsj> outSsj1 = ssjList.get("outSsj1");
|
||||
if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj1.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
List<DeviceSsj> outSsj2 = ssjList.get("outSsj2");
|
||||
if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj2.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
List<DeviceSsj> outSsj3 = ssjList.get("outSsj3");
|
||||
if (outSsj3.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj3.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
List<DeviceSsj> outSsj4 = ssjList.get("outSsj4");
|
||||
if (outSsj4.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj4.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log.error("出库任务出口错误");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("0".equals(outJob.getExecutionPhase()) && StrUtil.isNotEmpty(outSsj)) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(outJob.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
outJob.setStatus("3");
|
||||
outJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
outJob.setExecutionPhase(TASK_EP_DDJ);
|
||||
mydoJobService.updateMydoJob(outJob);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", outJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建入库放货队列
|
||||
*/
|
||||
private void generateInBoundLoadQueue(MsgDdj ddj) {
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 3) {
|
||||
//允许下发 联机 有货待机
|
||||
if (StrUtil.isNotEmpty(ddj.getTrayCode())) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setTrayCode(ddj.getTrayCode());
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
|
||||
MydoJob inJob = null;
|
||||
if (CollUtil.isEmpty(mydoJobs)) {
|
||||
//请求wms获取任务 并生成队列
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", ddj.getTrayCode());
|
||||
paramMap.put("warehouseId",WAREHOUSE_01);
|
||||
AjaxResult result = apiService.selectMydoJobByTrayCodeAndEntranceId(paramMap);
|
||||
if (result.isSuccess()) {
|
||||
inJob = BeanUtil.toBean(result.get("data"), MydoJob.class);
|
||||
inJob.setStatus(TASK_STATUS_CREATE);
|
||||
inJob.setExecutionPhase(TASK_EP_ROADWAY_SSJ);
|
||||
mydoJobService.insertMydoJob(inJob);
|
||||
} else {
|
||||
log.error(result.get("msg").toString());
|
||||
}
|
||||
} else {
|
||||
inJob = mydoJobs.get(0);
|
||||
}
|
||||
|
||||
if (ObjUtil.isNotNull(inJob) && inJob.getExecutionPhase().equals(TASK_EP_ROADWAY_SSJ)) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(inJob.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
inJob.setStatus("3");
|
||||
inJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
inJob.setExecutionPhase(TASK_EP_DDJ);
|
||||
mydoJobService.updateMydoJob(inJob);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", inJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Integer mbph = ddj.getMbph();
|
||||
Integer mblh = ddj.getMblh();
|
||||
Integer mbch = ddj.getMbch();
|
||||
long rwh = ddj.getRwh() + 100;
|
||||
log.error("扫码失败,放回原位 排:{} 列:{} 层:{} 任务号:{}", mbph, mblh, mbch, rwh);
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建入库取货队列
|
||||
*/
|
||||
private void generateInBoundPickQueue(MsgDdj ddj) {
|
||||
List<DeviceSsj> roadSsjList = ssjList.get("roadSsjList");
|
||||
for (DeviceSsj ssj : roadSsjList) {
|
||||
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(ssj.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", ssj.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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, ddj.getId());
|
||||
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, ddj.getId());
|
||||
if (ddjDeviceExecutionQueue != null) {
|
||||
//修改队列执行阶段
|
||||
ddjDeviceExecutionQueue.setRwzt(ddj.getJdbz());
|
||||
ddjDeviceExecutionQueue.setSpare1("1");
|
||||
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);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if ("0".equals(mydoJob.getFaultFlag()) && "1".equals(ddjDeviceExecutionQueue.getSpare1())) {
|
||||
mydoJob.setStatus("1");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
AjaxResult ajaxResult = apiService.reAssign(new JobParam(rwh.toString(), null, null));
|
||||
if (ajaxResult.isSuccess()) {
|
||||
mydoJob.setFaultFlag("2");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
ddjDeviceExecutionQueue.setSpare1("0");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第四部分
|
||||
取货无货,重新分配单据
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1053 && ddj.getJdbz() < 5) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//无货异常处理
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
//找到对应任务 调用api接口 取货无货,重新分配单据
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
AjaxResult ajaxResult = apiService.reMaterial(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, ddj.getId());
|
||||
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) {
|
||||
if (ddj.getSbzt() == 0) {
|
||||
//无货待机 只查询入库取货扫码或者出库队列
|
||||
ArrayList<Integer> rwlxList = new ArrayList<>();
|
||||
rwlxList.add(1);
|
||||
rwlxList.add(3);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueueParam.setRwlxList(rwlxList);
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
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:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
} else if (ddj.getSbzt() == 3) {
|
||||
//有货待机 只查询入库放货队列
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueueParam.setRwlx(2);
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
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:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废作业
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void InvalidMydoJob(Long rwh, Integer id) {
|
||||
mydoJobService.InvalidMydoJob(rwh, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 堆垛机任务完成
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void ddjTaskFinish(Long rwh, Integer id) {
|
||||
mydoJobService.ddjTaskFinish(rwh, id,1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 给堆垛机下发任务
|
||||
*
|
||||
* @param queue 堆垛机执行的队列
|
||||
*/
|
||||
private int issuedDDJTask(Integer 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;
|
||||
if (queue.getRwlx() == 1 || queue.getRwlx() == 3) {
|
||||
mlfs = 5;
|
||||
} else if (queue.getRwlx() == 2) {
|
||||
mlfs = 4;
|
||||
} else {
|
||||
throw new RuntimeException("任务类型错误");
|
||||
}
|
||||
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 PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
} else {
|
||||
return PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,462 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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 cn.hutool.core.util.StrUtil;
|
||||
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.device.ddj.service.IMsgDdjService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
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.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.ruoyi.common.Constant.WAREHOUSE_01;
|
||||
import static com.ruoyi.common.TaskStatusCode.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj3Thread implements Runnable {
|
||||
|
||||
public HashMap<String, List<MsgDdj>> ddjCodeList;
|
||||
public HashMap<String, List<DeviceSsj>> ssjList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||
private IDdjDeviceExecutionQueueFinishService ddjDeviceExecutionQueueFinishService;
|
||||
private IMsgDdjService msgDdjService;
|
||||
private IMydoJobService mydoJobService;
|
||||
private final Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ddjCodeList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj3"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2005"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2006"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2011"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2012"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L2005"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L2006"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
ArrayList<DeviceSsj> outSsj3 = new ArrayList<>();
|
||||
outSsj3.add(PlcSsjRead.deviceSsjMap.get("L2011"));
|
||||
ssjList.put("outSsj3", outSsj3);
|
||||
ArrayList<DeviceSsj> outSsj4 = new ArrayList<>();
|
||||
outSsj4.add(PlcSsjRead.deviceSsjMap.get("L2012"));
|
||||
ssjList.put("outSsj4", outSsj4);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L2005", Arrays.asList(5, 1, 1));
|
||||
roadwayMap.put("L2006", Arrays.asList(6, 1, 1));
|
||||
roadwayMap.put("L2011", Arrays.asList(5, 22, 1));
|
||||
roadwayMap.put("L2012", Arrays.asList(6, 22, 1));
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||
ddjDeviceExecutionQueueFinishService = SpringUtils.getBean(IDdjDeviceExecutionQueueFinishService.class);
|
||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ddjCodeList.keySet()) {
|
||||
|
||||
for (MsgDdj msgDdj : ddjCodeList.get(type)) {
|
||||
try {
|
||||
if (ObjUtil.isNotNull(msgDdj)) {
|
||||
if (0 == msgDdj.getSpare1()) {
|
||||
generateInBoundPickQueue(msgDdj);
|
||||
generateInBoundLoadQueue(msgDdj);
|
||||
generateOutBoundQueue(msgDdj);
|
||||
ddjTask(msgDdj);
|
||||
}
|
||||
} else {
|
||||
log.error("堆垛机设备为空");
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建出库队列
|
||||
*/
|
||||
private void generateOutBoundQueue(MsgDdj ddj) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setInOut("2");
|
||||
param.setWarehouseId(WAREHOUSE_01);
|
||||
param.setRoadwayId(Convert.toStr(ddj.getId()));
|
||||
List<MydoJob> outJobList = mydoJobService.selectMydoJobList(param);
|
||||
if (CollUtil.isNotEmpty(outJobList)) {
|
||||
for (MydoJob outJob : outJobList) {
|
||||
String exitId = outJob.getExitId();
|
||||
|
||||
String outSsj = "";
|
||||
switch (exitId) {
|
||||
case "1":
|
||||
List<DeviceSsj> outSsj1 = ssjList.get("outSsj1");
|
||||
if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj1.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
List<DeviceSsj> outSsj2 = ssjList.get("outSsj2");
|
||||
if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj2.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
List<DeviceSsj> outSsj3 = ssjList.get("outSsj3");
|
||||
if (outSsj3.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj3.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
List<DeviceSsj> outSsj4 = ssjList.get("outSsj4");
|
||||
if (outSsj4.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj4.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log.error("出库任务出口错误");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("0".equals(outJob.getExecutionPhase()) && StrUtil.isNotEmpty(outSsj)) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(outJob.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
outJob.setStatus("3");
|
||||
outJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
outJob.setExecutionPhase(TASK_EP_DDJ);
|
||||
mydoJobService.updateMydoJob(outJob);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", outJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建入库放货队列
|
||||
*/
|
||||
private void generateInBoundLoadQueue(MsgDdj ddj) {
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 3) {
|
||||
//允许下发 联机 有货待机
|
||||
if (StrUtil.isNotEmpty(ddj.getTrayCode())) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setTrayCode(ddj.getTrayCode());
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
|
||||
MydoJob inJob = null;
|
||||
if (CollUtil.isEmpty(mydoJobs)) {
|
||||
//请求wms获取任务 并生成队列
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", ddj.getTrayCode());
|
||||
paramMap.put("warehouseId",WAREHOUSE_01);
|
||||
AjaxResult result = apiService.selectMydoJobByTrayCodeAndEntranceId(paramMap);
|
||||
if (result.isSuccess()) {
|
||||
inJob = BeanUtil.toBean(result.get("data"), MydoJob.class);
|
||||
inJob.setStatus(TASK_STATUS_CREATE);
|
||||
inJob.setExecutionPhase(TASK_EP_ROADWAY_SSJ);
|
||||
mydoJobService.insertMydoJob(inJob);
|
||||
} else {
|
||||
log.error(result.get("msg").toString());
|
||||
}
|
||||
} else {
|
||||
inJob = mydoJobs.get(0);
|
||||
}
|
||||
|
||||
if (ObjUtil.isNotNull(inJob) && inJob.getExecutionPhase().equals(TASK_EP_ROADWAY_SSJ)) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(inJob.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
inJob.setStatus("3");
|
||||
inJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
inJob.setExecutionPhase(TASK_EP_DDJ);
|
||||
mydoJobService.updateMydoJob(inJob);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", inJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Integer mbph = ddj.getMbph();
|
||||
Integer mblh = ddj.getMblh();
|
||||
Integer mbch = ddj.getMbch();
|
||||
long rwh = ddj.getRwh() + 100;
|
||||
log.error("扫码失败,放回原位 排:{} 列:{} 层:{} 任务号:{}", mbph, mblh, mbch, rwh);
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建入库取货队列
|
||||
*/
|
||||
private void generateInBoundPickQueue(MsgDdj ddj) {
|
||||
List<DeviceSsj> roadSsjList = ssjList.get("roadSsjList");
|
||||
for (DeviceSsj ssj : roadSsjList) {
|
||||
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(ssj.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", ssj.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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, ddj.getId());
|
||||
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, ddj.getId());
|
||||
if (ddjDeviceExecutionQueue != null) {
|
||||
//修改队列执行阶段
|
||||
ddjDeviceExecutionQueue.setRwzt(ddj.getJdbz());
|
||||
ddjDeviceExecutionQueue.setSpare1("1");
|
||||
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);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if ("0".equals(mydoJob.getFaultFlag()) && "1".equals(ddjDeviceExecutionQueue.getSpare1())) {
|
||||
mydoJob.setStatus("1");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
AjaxResult ajaxResult = apiService.reAssign(new JobParam(rwh.toString(), null, null));
|
||||
if (ajaxResult.isSuccess()) {
|
||||
mydoJob.setFaultFlag("2");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
ddjDeviceExecutionQueue.setSpare1("0");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第四部分
|
||||
取货无货,重新分配单据
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1053 && ddj.getJdbz() < 5) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//无货异常处理
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
//找到对应任务 调用api接口 取货无货,重新分配单据
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
AjaxResult ajaxResult = apiService.reMaterial(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, ddj.getId());
|
||||
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) {
|
||||
if (ddj.getSbzt() == 0) {
|
||||
//无货待机 只查询入库取货扫码或者出库队列
|
||||
ArrayList<Integer> rwlxList = new ArrayList<>();
|
||||
rwlxList.add(1);
|
||||
rwlxList.add(3);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueueParam.setRwlxList(rwlxList);
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
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:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
} else if (ddj.getSbzt() == 3) {
|
||||
//有货待机 只查询入库放货队列
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueueParam.setRwlx(2);
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
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:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废作业
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void InvalidMydoJob(Long rwh, Integer id) {
|
||||
mydoJobService.InvalidMydoJob(rwh, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 堆垛机任务完成
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void ddjTaskFinish(Long rwh, Integer id) {
|
||||
mydoJobService.ddjTaskFinish(rwh, id,1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 给堆垛机下发任务
|
||||
*
|
||||
* @param queue 堆垛机执行的队列
|
||||
*/
|
||||
private int issuedDDJTask(Integer 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;
|
||||
if (queue.getRwlx() == 1 || queue.getRwlx() == 3) {
|
||||
mlfs = 5;
|
||||
} else if (queue.getRwlx() == 2) {
|
||||
mlfs = 4;
|
||||
} else {
|
||||
throw new RuntimeException("任务类型错误");
|
||||
}
|
||||
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 PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
} else {
|
||||
return PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,441 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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 cn.hutool.core.util.StrUtil;
|
||||
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.device.ddj.service.IMsgDdjService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
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.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.ruoyi.common.Constant.WAREHOUSE_02;
|
||||
import static com.ruoyi.common.TaskStatusCode.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj4Thread implements Runnable {
|
||||
|
||||
public HashMap<String, List<MsgDdj>> ddjCodeList;
|
||||
public HashMap<String, List<DeviceSsj>> ssjList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||
private IDdjDeviceExecutionQueueFinishService ddjDeviceExecutionQueueFinishService;
|
||||
private IMsgDdjService msgDdjService;
|
||||
private IMydoJobService mydoJobService;
|
||||
private final Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ddjCodeList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj4"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1001"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1002"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L1001"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L1002"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L1001", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L1002", Arrays.asList(2, 1, 1));
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||
ddjDeviceExecutionQueueFinishService = SpringUtils.getBean(IDdjDeviceExecutionQueueFinishService.class);
|
||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ddjCodeList.keySet()) {
|
||||
|
||||
for (MsgDdj msgDdj : ddjCodeList.get(type)) {
|
||||
try {
|
||||
if (ObjUtil.isNotNull(msgDdj)) {
|
||||
if (0 == msgDdj.getSpare1()) {
|
||||
generateInBoundPickQueue(msgDdj);
|
||||
generateInBoundLoadQueue(msgDdj);
|
||||
generateOutBoundQueue(msgDdj);
|
||||
ddjTask(msgDdj);
|
||||
}
|
||||
} else {
|
||||
log.error("堆垛机设备为空");
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建出库队列
|
||||
*/
|
||||
private void generateOutBoundQueue(MsgDdj ddj) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setInOut("2");
|
||||
param.setWarehouseId(WAREHOUSE_02);
|
||||
param.setRoadwayId(Convert.toStr(ddj.getId()));
|
||||
List<MydoJob> outJobList = mydoJobService.selectMydoJobList(param);
|
||||
if (CollUtil.isNotEmpty(outJobList)) {
|
||||
for (MydoJob outJob : outJobList) {
|
||||
String exitId = outJob.getExitId();
|
||||
|
||||
String outSsj = "";
|
||||
switch (exitId) {
|
||||
case "1":
|
||||
List<DeviceSsj> outSsj1 = ssjList.get("outSsj1");
|
||||
if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj1.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
List<DeviceSsj> outSsj2 = ssjList.get("outSsj2");
|
||||
if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj2.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log.error("出库任务出口错误");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("0".equals(outJob.getExecutionPhase()) && StrUtil.isNotEmpty(outSsj)) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(outJob.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
outJob.setStatus("3");
|
||||
outJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
outJob.setExecutionPhase(TASK_EP_DDJ);
|
||||
mydoJobService.updateMydoJob(outJob);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", outJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建入库放货队列
|
||||
*/
|
||||
private void generateInBoundLoadQueue(MsgDdj ddj) {
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 3) {
|
||||
//允许下发 联机 有货待机
|
||||
if (StrUtil.isNotEmpty(ddj.getTrayCode())) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setTrayCode(ddj.getTrayCode());
|
||||
param.setWarehouseId(WAREHOUSE_02);
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
|
||||
MydoJob inJob = null;
|
||||
if (CollUtil.isEmpty(mydoJobs)) {
|
||||
//请求wms获取任务 并生成队列
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", ddj.getTrayCode());
|
||||
paramMap.put("warehouseId", WAREHOUSE_02);
|
||||
AjaxResult result = apiService.selectMydoJobByTrayCodeAndEntranceId(paramMap);
|
||||
if (result.isSuccess()) {
|
||||
inJob = BeanUtil.toBean(result.get("data"), MydoJob.class);
|
||||
inJob.setStatus(TASK_STATUS_CREATE);
|
||||
inJob.setExecutionPhase(TASK_EP_ROADWAY_SSJ);
|
||||
mydoJobService.insertMydoJob(inJob);
|
||||
} else {
|
||||
log.error(result.get("msg").toString());
|
||||
}
|
||||
} else {
|
||||
inJob = mydoJobs.get(0);
|
||||
}
|
||||
|
||||
if (ObjUtil.isNotNull(inJob) && inJob.getExecutionPhase().equals(TASK_EP_ROADWAY_SSJ)) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(inJob.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
inJob.setStatus("3");
|
||||
inJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
inJob.setExecutionPhase(TASK_EP_DDJ);
|
||||
mydoJobService.updateMydoJob(inJob);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", inJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Integer mbph = ddj.getMbph();
|
||||
Integer mblh = ddj.getMblh();
|
||||
Integer mbch = ddj.getMbch();
|
||||
long rwh = ddj.getRwh() + 100;
|
||||
log.error("扫码失败,放回原位 排:{} 列:{} 层:{} 任务号:{}", mbph, mblh, mbch, rwh);
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建入库取货队列
|
||||
*/
|
||||
private void generateInBoundPickQueue(MsgDdj ddj) {
|
||||
List<DeviceSsj> roadSsjList = ssjList.get("roadSsjList");
|
||||
for (DeviceSsj ssj : roadSsjList) {
|
||||
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(ssj.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", ssj.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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, ddj.getId());
|
||||
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, ddj.getId());
|
||||
if (ddjDeviceExecutionQueue != null) {
|
||||
//修改队列执行阶段
|
||||
ddjDeviceExecutionQueue.setRwzt(ddj.getJdbz());
|
||||
ddjDeviceExecutionQueue.setSpare1("1");
|
||||
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);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if ("0".equals(mydoJob.getFaultFlag()) && "1".equals(ddjDeviceExecutionQueue.getSpare1())) {
|
||||
mydoJob.setStatus("1");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
AjaxResult ajaxResult = apiService.reAssign(new JobParam(rwh.toString(), null, null));
|
||||
if (ajaxResult.isSuccess()) {
|
||||
mydoJob.setFaultFlag("2");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
ddjDeviceExecutionQueue.setSpare1("0");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第四部分
|
||||
取货无货,重新分配单据
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1053 && ddj.getJdbz() < 5) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//无货异常处理
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
//找到对应任务 调用api接口 取货无货,重新分配单据
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
AjaxResult ajaxResult = apiService.reMaterial(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, ddj.getId());
|
||||
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) {
|
||||
if (ddj.getSbzt() == 0) {
|
||||
//无货待机 只查询入库取货扫码或者出库队列
|
||||
ArrayList<Integer> rwlxList = new ArrayList<>();
|
||||
rwlxList.add(1);
|
||||
rwlxList.add(3);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueueParam.setRwlxList(rwlxList);
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
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:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
} else if (ddj.getSbzt() == 3) {
|
||||
//有货待机 只查询入库放货队列
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueueParam.setRwlx(2);
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
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:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废作业
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void InvalidMydoJob(Long rwh, Integer id) {
|
||||
mydoJobService.InvalidMydoJob(rwh, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 堆垛机任务完成
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void ddjTaskFinish(Long rwh, Integer id) {
|
||||
mydoJobService.ddjTaskFinish(rwh, id,1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 给堆垛机下发任务
|
||||
*
|
||||
* @param queue 堆垛机执行的队列
|
||||
*/
|
||||
private int issuedDDJTask(Integer 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;
|
||||
if (queue.getRwlx() == 1 || queue.getRwlx() == 3) {
|
||||
mlfs = 5;
|
||||
} else if (queue.getRwlx() == 2) {
|
||||
mlfs = 4;
|
||||
} else {
|
||||
throw new RuntimeException("任务类型错误");
|
||||
}
|
||||
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 PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
} else {
|
||||
return PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,441 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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 cn.hutool.core.util.StrUtil;
|
||||
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.device.ddj.service.IMsgDdjService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
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.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.ruoyi.common.Constant.WAREHOUSE_02;
|
||||
import static com.ruoyi.common.TaskStatusCode.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj5Thread implements Runnable {
|
||||
|
||||
public HashMap<String, List<MsgDdj>> ddjCodeList;
|
||||
public HashMap<String, List<DeviceSsj>> ssjList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||
private IDdjDeviceExecutionQueueFinishService ddjDeviceExecutionQueueFinishService;
|
||||
private IMsgDdjService msgDdjService;
|
||||
private IMydoJobService mydoJobService;
|
||||
private final Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ddjCodeList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj5"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1003"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1004"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L1003"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L1004"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L1003", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L1004", Arrays.asList(2, 1, 1));
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||
ddjDeviceExecutionQueueFinishService = SpringUtils.getBean(IDdjDeviceExecutionQueueFinishService.class);
|
||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ddjCodeList.keySet()) {
|
||||
|
||||
for (MsgDdj msgDdj : ddjCodeList.get(type)) {
|
||||
try {
|
||||
if (ObjUtil.isNotNull(msgDdj)) {
|
||||
if (0 == msgDdj.getSpare1()) {
|
||||
generateInBoundPickQueue(msgDdj);
|
||||
generateInBoundLoadQueue(msgDdj);
|
||||
generateOutBoundQueue(msgDdj);
|
||||
ddjTask(msgDdj);
|
||||
}
|
||||
} else {
|
||||
log.error("堆垛机设备为空");
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建出库队列
|
||||
*/
|
||||
private void generateOutBoundQueue(MsgDdj ddj) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setInOut("2");
|
||||
param.setWarehouseId(WAREHOUSE_02);
|
||||
param.setRoadwayId(Convert.toStr(ddj.getId()));
|
||||
List<MydoJob> outJobList = mydoJobService.selectMydoJobList(param);
|
||||
if (CollUtil.isNotEmpty(outJobList)) {
|
||||
for (MydoJob outJob : outJobList) {
|
||||
String exitId = outJob.getExitId();
|
||||
|
||||
String outSsj = "";
|
||||
switch (exitId) {
|
||||
case "1":
|
||||
List<DeviceSsj> outSsj1 = ssjList.get("outSsj1");
|
||||
if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj1.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
List<DeviceSsj> outSsj2 = ssjList.get("outSsj2");
|
||||
if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj2.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log.error("出库任务出口错误");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("0".equals(outJob.getExecutionPhase()) && StrUtil.isNotEmpty(outSsj)) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(outJob.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
outJob.setStatus("3");
|
||||
outJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
outJob.setExecutionPhase(TASK_EP_DDJ);
|
||||
mydoJobService.updateMydoJob(outJob);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", outJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建入库放货队列
|
||||
*/
|
||||
private void generateInBoundLoadQueue(MsgDdj ddj) {
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 3) {
|
||||
//允许下发 联机 有货待机
|
||||
if (StrUtil.isNotEmpty(ddj.getTrayCode())) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setTrayCode(ddj.getTrayCode());
|
||||
param.setWarehouseId(WAREHOUSE_02);
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
|
||||
MydoJob inJob = null;
|
||||
if (CollUtil.isEmpty(mydoJobs)) {
|
||||
//请求wms获取任务 并生成队列
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", ddj.getTrayCode());
|
||||
paramMap.put("warehouseId", WAREHOUSE_02);
|
||||
AjaxResult result = apiService.selectMydoJobByTrayCodeAndEntranceId(paramMap);
|
||||
if (result.isSuccess()) {
|
||||
inJob = BeanUtil.toBean(result.get("data"), MydoJob.class);
|
||||
inJob.setStatus(TASK_STATUS_CREATE);
|
||||
inJob.setExecutionPhase(TASK_EP_ROADWAY_SSJ);
|
||||
mydoJobService.insertMydoJob(inJob);
|
||||
} else {
|
||||
log.error(result.get("msg").toString());
|
||||
}
|
||||
} else {
|
||||
inJob = mydoJobs.get(0);
|
||||
}
|
||||
|
||||
if (ObjUtil.isNotNull(inJob) && inJob.getExecutionPhase().equals(TASK_EP_ROADWAY_SSJ)) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(inJob.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
inJob.setStatus("3");
|
||||
inJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
inJob.setExecutionPhase(TASK_EP_DDJ);
|
||||
mydoJobService.updateMydoJob(inJob);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", inJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Integer mbph = ddj.getMbph();
|
||||
Integer mblh = ddj.getMblh();
|
||||
Integer mbch = ddj.getMbch();
|
||||
long rwh = ddj.getRwh() + 100;
|
||||
log.error("扫码失败,放回原位 排:{} 列:{} 层:{} 任务号:{}", mbph, mblh, mbch, rwh);
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建入库取货队列
|
||||
*/
|
||||
private void generateInBoundPickQueue(MsgDdj ddj) {
|
||||
List<DeviceSsj> roadSsjList = ssjList.get("roadSsjList");
|
||||
for (DeviceSsj ssj : roadSsjList) {
|
||||
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(ssj.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", ssj.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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, ddj.getId());
|
||||
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, ddj.getId());
|
||||
if (ddjDeviceExecutionQueue != null) {
|
||||
//修改队列执行阶段
|
||||
ddjDeviceExecutionQueue.setRwzt(ddj.getJdbz());
|
||||
ddjDeviceExecutionQueue.setSpare1("1");
|
||||
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);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if ("0".equals(mydoJob.getFaultFlag()) && "1".equals(ddjDeviceExecutionQueue.getSpare1())) {
|
||||
mydoJob.setStatus("1");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
AjaxResult ajaxResult = apiService.reAssign(new JobParam(rwh.toString(), null, null));
|
||||
if (ajaxResult.isSuccess()) {
|
||||
mydoJob.setFaultFlag("2");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
ddjDeviceExecutionQueue.setSpare1("0");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第四部分
|
||||
取货无货,重新分配单据
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1053 && ddj.getJdbz() < 5) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//无货异常处理
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
//找到对应任务 调用api接口 取货无货,重新分配单据
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
AjaxResult ajaxResult = apiService.reMaterial(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, ddj.getId());
|
||||
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) {
|
||||
if (ddj.getSbzt() == 0) {
|
||||
//无货待机 只查询入库取货扫码或者出库队列
|
||||
ArrayList<Integer> rwlxList = new ArrayList<>();
|
||||
rwlxList.add(1);
|
||||
rwlxList.add(3);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueueParam.setRwlxList(rwlxList);
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
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:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
} else if (ddj.getSbzt() == 3) {
|
||||
//有货待机 只查询入库放货队列
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueueParam.setRwlx(2);
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
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:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废作业
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void InvalidMydoJob(Long rwh, Integer id) {
|
||||
mydoJobService.InvalidMydoJob(rwh, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 堆垛机任务完成
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void ddjTaskFinish(Long rwh, Integer id) {
|
||||
mydoJobService.ddjTaskFinish(rwh, id,1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 给堆垛机下发任务
|
||||
*
|
||||
* @param queue 堆垛机执行的队列
|
||||
*/
|
||||
private int issuedDDJTask(Integer 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;
|
||||
if (queue.getRwlx() == 1 || queue.getRwlx() == 3) {
|
||||
mlfs = 5;
|
||||
} else if (queue.getRwlx() == 2) {
|
||||
mlfs = 4;
|
||||
} else {
|
||||
throw new RuntimeException("任务类型错误");
|
||||
}
|
||||
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 PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
} else {
|
||||
return PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,441 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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 cn.hutool.core.util.StrUtil;
|
||||
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.device.ddj.service.IMsgDdjService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
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.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.ruoyi.common.Constant.WAREHOUSE_02;
|
||||
import static com.ruoyi.common.TaskStatusCode.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj6Thread implements Runnable {
|
||||
|
||||
public HashMap<String, List<MsgDdj>> ddjCodeList;
|
||||
public HashMap<String, List<DeviceSsj>> ssjList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||
private IDdjDeviceExecutionQueueFinishService ddjDeviceExecutionQueueFinishService;
|
||||
private IMsgDdjService msgDdjService;
|
||||
private IMydoJobService mydoJobService;
|
||||
private final Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ddjCodeList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj6"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1005"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1006"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L1005"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L1006"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L1005", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L1006", Arrays.asList(2, 1, 1));
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||
ddjDeviceExecutionQueueFinishService = SpringUtils.getBean(IDdjDeviceExecutionQueueFinishService.class);
|
||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ddjCodeList.keySet()) {
|
||||
|
||||
for (MsgDdj msgDdj : ddjCodeList.get(type)) {
|
||||
try {
|
||||
if (ObjUtil.isNotNull(msgDdj)) {
|
||||
if (0 == msgDdj.getSpare1()) {
|
||||
generateInBoundPickQueue(msgDdj);
|
||||
generateInBoundLoadQueue(msgDdj);
|
||||
generateOutBoundQueue(msgDdj);
|
||||
ddjTask(msgDdj);
|
||||
}
|
||||
} else {
|
||||
log.error("堆垛机设备为空");
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建出库队列
|
||||
*/
|
||||
private void generateOutBoundQueue(MsgDdj ddj) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setInOut("2");
|
||||
param.setWarehouseId(WAREHOUSE_02);
|
||||
param.setRoadwayId(Convert.toStr(ddj.getId()));
|
||||
List<MydoJob> outJobList = mydoJobService.selectMydoJobList(param);
|
||||
if (CollUtil.isNotEmpty(outJobList)) {
|
||||
for (MydoJob outJob : outJobList) {
|
||||
String exitId = outJob.getExitId();
|
||||
|
||||
String outSsj = "";
|
||||
switch (exitId) {
|
||||
case "1":
|
||||
List<DeviceSsj> outSsj1 = ssjList.get("outSsj1");
|
||||
if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj1.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
List<DeviceSsj> outSsj2 = ssjList.get("outSsj2");
|
||||
if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getModel() == 2)) {
|
||||
outSsj = outSsj2.get(0).getDeviceCode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log.error("出库任务出口错误");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("0".equals(outJob.getExecutionPhase()) && StrUtil.isNotEmpty(outSsj)) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(outJob.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
outJob.setStatus("3");
|
||||
outJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
outJob.setExecutionPhase(TASK_EP_DDJ);
|
||||
mydoJobService.updateMydoJob(outJob);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", outJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建入库放货队列
|
||||
*/
|
||||
private void generateInBoundLoadQueue(MsgDdj ddj) {
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 3) {
|
||||
//允许下发 联机 有货待机
|
||||
if (StrUtil.isNotEmpty(ddj.getTrayCode())) {
|
||||
MydoJob param = new MydoJob();
|
||||
param.setTrayCode(ddj.getTrayCode());
|
||||
param.setWarehouseId(WAREHOUSE_02);
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
|
||||
MydoJob inJob = null;
|
||||
if (CollUtil.isEmpty(mydoJobs)) {
|
||||
//请求wms获取任务 并生成队列
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", ddj.getTrayCode());
|
||||
paramMap.put("warehouseId", WAREHOUSE_02);
|
||||
AjaxResult result = apiService.selectMydoJobByTrayCodeAndEntranceId(paramMap);
|
||||
if (result.isSuccess()) {
|
||||
inJob = BeanUtil.toBean(result.get("data"), MydoJob.class);
|
||||
inJob.setStatus(TASK_STATUS_CREATE);
|
||||
inJob.setExecutionPhase(TASK_EP_ROADWAY_SSJ);
|
||||
mydoJobService.insertMydoJob(inJob);
|
||||
} else {
|
||||
log.error(result.get("msg").toString());
|
||||
}
|
||||
} else {
|
||||
inJob = mydoJobs.get(0);
|
||||
}
|
||||
|
||||
if (ObjUtil.isNotNull(inJob) && inJob.getExecutionPhase().equals(TASK_EP_ROADWAY_SSJ)) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(inJob.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
inJob.setStatus("3");
|
||||
inJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
inJob.setExecutionPhase(TASK_EP_DDJ);
|
||||
mydoJobService.updateMydoJob(inJob);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", inJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Integer mbph = ddj.getMbph();
|
||||
Integer mblh = ddj.getMblh();
|
||||
Integer mbch = ddj.getMbch();
|
||||
long rwh = ddj.getRwh() + 100;
|
||||
log.error("扫码失败,放回原位 排:{} 列:{} 层:{} 任务号:{}", mbph, mblh, mbch, rwh);
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建入库取货队列
|
||||
*/
|
||||
private void generateInBoundPickQueue(MsgDdj ddj) {
|
||||
List<DeviceSsj> roadSsjList = ssjList.get("roadSsjList");
|
||||
for (DeviceSsj ssj : roadSsjList) {
|
||||
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(ssj.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
} else {
|
||||
log.info("任务已存在 rwh{}", ssj.getTaskNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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, ddj.getId());
|
||||
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, ddj.getId());
|
||||
if (ddjDeviceExecutionQueue != null) {
|
||||
//修改队列执行阶段
|
||||
ddjDeviceExecutionQueue.setRwzt(ddj.getJdbz());
|
||||
ddjDeviceExecutionQueue.setSpare1("1");
|
||||
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);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if ("0".equals(mydoJob.getFaultFlag()) && "1".equals(ddjDeviceExecutionQueue.getSpare1())) {
|
||||
mydoJob.setStatus("1");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
AjaxResult ajaxResult = apiService.reAssign(new JobParam(rwh.toString(), null, null));
|
||||
if (ajaxResult.isSuccess()) {
|
||||
mydoJob.setFaultFlag("2");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
ddjDeviceExecutionQueue.setSpare1("0");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第四部分
|
||||
取货无货,重新分配单据
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1053 && ddj.getJdbz() < 5) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//无货异常处理
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
//找到对应任务 调用api接口 取货无货,重新分配单据
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
AjaxResult ajaxResult = apiService.reMaterial(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, ddj.getId());
|
||||
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) {
|
||||
if (ddj.getSbzt() == 0) {
|
||||
//无货待机 只查询入库取货扫码或者出库队列
|
||||
ArrayList<Integer> rwlxList = new ArrayList<>();
|
||||
rwlxList.add(1);
|
||||
rwlxList.add(3);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueueParam.setRwlxList(rwlxList);
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
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:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
} else if (ddj.getSbzt() == 3) {
|
||||
//有货待机 只查询入库放货队列
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueueParam.setRwlx(2);
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
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:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废作业
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void InvalidMydoJob(Long rwh, Integer id) {
|
||||
mydoJobService.InvalidMydoJob(rwh, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 堆垛机任务完成
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void ddjTaskFinish(Long rwh, Integer id) {
|
||||
mydoJobService.ddjTaskFinish(rwh, id,1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 给堆垛机下发任务
|
||||
*
|
||||
* @param queue 堆垛机执行的队列
|
||||
*/
|
||||
private int issuedDDJTask(Integer 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;
|
||||
if (queue.getRwlx() == 1 || queue.getRwlx() == 3) {
|
||||
mlfs = 5;
|
||||
} else if (queue.getRwlx() == 2) {
|
||||
mlfs = 4;
|
||||
} else {
|
||||
throw new RuntimeException("任务类型错误");
|
||||
}
|
||||
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 PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
} else {
|
||||
return PlcDdjRead.WriteToDDJ("DB61.0", sendData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj;
|
||||
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 堆垛机线程接口
|
||||
* 定义堆垛机线程必须实现的方法
|
||||
*/
|
||||
public interface DdjThreadInterface {
|
||||
|
||||
/**
|
||||
* 获取参数映射
|
||||
* @param trayCode 托盘代码
|
||||
* @return 参数映射
|
||||
*/
|
||||
HashMap<String, Object> getParamMap(String trayCode);
|
||||
|
||||
/**
|
||||
* 获取出库任务参数
|
||||
* @return 出库任务参数
|
||||
*/
|
||||
MydoJob getOutJobParam();
|
||||
|
||||
/**
|
||||
* 初始化设备
|
||||
*/
|
||||
void init();
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj.impl;
|
||||
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.ruoyi.common.Constant.ROADWAY_ID_01;
|
||||
import static com.ruoyi.common.Constant.WAREHOUSE_01;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj1Thread extends BaseDdjThread {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
ddjCodeList = new HashMap<>();
|
||||
ssjList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj1"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2001"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2002"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2007"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2008"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L2001"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L2002"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
ArrayList<DeviceSsj> outSsj3 = new ArrayList<>();
|
||||
outSsj3.add(PlcSsjRead.deviceSsjMap.get("L2007"));
|
||||
ssjList.put("outSsj3", outSsj3);
|
||||
ArrayList<DeviceSsj> outSsj4 = new ArrayList<>();
|
||||
outSsj4.add(PlcSsjRead.deviceSsjMap.get("L2008"));
|
||||
ssjList.put("outSsj4", outSsj4);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L2001", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L2002", Arrays.asList(2, 1, 1));
|
||||
roadwayMap.put("L2007", Arrays.asList(1, 22, 1));
|
||||
roadwayMap.put("L2008", Arrays.asList(2, 22, 1));
|
||||
|
||||
log.info("Ddj1Thread init");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getParamMap(String trayCode) {
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", trayCode);
|
||||
paramMap.put("warehouseId",WAREHOUSE_01);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_01);
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MydoJob getOutJobParam() {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setWarehouseId(WAREHOUSE_01);
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_01));
|
||||
return mydoJob;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj.impl;
|
||||
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.ruoyi.common.Constant.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj2Thread extends BaseDdjThread {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
ddjCodeList = new HashMap<>();
|
||||
ssjList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj2"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2003"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2004"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2009"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2010"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L2003"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L2004"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
ArrayList<DeviceSsj> outSsj3 = new ArrayList<>();
|
||||
outSsj3.add(PlcSsjRead.deviceSsjMap.get("L2009"));
|
||||
ssjList.put("outSsj3", outSsj3);
|
||||
ArrayList<DeviceSsj> outSsj4 = new ArrayList<>();
|
||||
outSsj4.add(PlcSsjRead.deviceSsjMap.get("L2010"));
|
||||
ssjList.put("outSsj4", outSsj4);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L2001", Arrays.asList(3, 1, 1));
|
||||
roadwayMap.put("L2002", Arrays.asList(4, 1, 1));
|
||||
roadwayMap.put("L2007", Arrays.asList(3, 22, 1));
|
||||
roadwayMap.put("L2008", Arrays.asList(4, 22, 1));
|
||||
|
||||
log.info("Ddj2Thread init");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getParamMap(String trayCode) {
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", trayCode);
|
||||
paramMap.put("warehouseId",WAREHOUSE_01);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_02);
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MydoJob getOutJobParam() {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setWarehouseId(WAREHOUSE_01);
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_02));
|
||||
return mydoJob;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj.impl;
|
||||
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.ruoyi.common.Constant.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj3Thread extends BaseDdjThread {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
ddjCodeList = new HashMap<>();
|
||||
ssjList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj3"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2005"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2006"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2011"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2012"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L2005"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L2006"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
ArrayList<DeviceSsj> outSsj3 = new ArrayList<>();
|
||||
outSsj3.add(PlcSsjRead.deviceSsjMap.get("L2011"));
|
||||
ssjList.put("outSsj3", outSsj3);
|
||||
ArrayList<DeviceSsj> outSsj4 = new ArrayList<>();
|
||||
outSsj4.add(PlcSsjRead.deviceSsjMap.get("L2012"));
|
||||
ssjList.put("outSsj4", outSsj4);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L2005", Arrays.asList(5, 1, 1));
|
||||
roadwayMap.put("L2006", Arrays.asList(6, 1, 1));
|
||||
roadwayMap.put("L2011", Arrays.asList(5, 22, 1));
|
||||
roadwayMap.put("L2012", Arrays.asList(6, 22, 1));
|
||||
|
||||
log.info("Ddj3Thread init");
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getParamMap(String trayCode) {
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", trayCode);
|
||||
paramMap.put("warehouseId",WAREHOUSE_01);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_03);
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MydoJob getOutJobParam() {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setWarehouseId(WAREHOUSE_01);
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_03));
|
||||
return mydoJob;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj.impl;
|
||||
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.ruoyi.common.Constant.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj4Thread extends BaseDdjThread {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
ddjCodeList = new HashMap<>();
|
||||
ssjList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj4"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1001"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1002"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L1001"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L1002"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L1001", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L1002", Arrays.asList(2, 1, 1));
|
||||
|
||||
log.info("Ddj4Thread init");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getParamMap(String trayCode) {
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", trayCode);
|
||||
paramMap.put("warehouseId",WAREHOUSE_02);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_01);
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MydoJob getOutJobParam() {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setWarehouseId(WAREHOUSE_02);
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_01));
|
||||
return mydoJob;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj.impl;
|
||||
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.ruoyi.common.Constant.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj5Thread extends BaseDdjThread {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
ddjCodeList = new HashMap<>();
|
||||
ssjList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj5"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1003"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1004"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L1003"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L1004"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L1003", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L1004", Arrays.asList(2, 1, 1));
|
||||
|
||||
|
||||
log.info("Ddj5Thread init");
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getParamMap(String trayCode) {
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", trayCode);
|
||||
paramMap.put("warehouseId",WAREHOUSE_02);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_02);
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MydoJob getOutJobParam() {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setWarehouseId(WAREHOUSE_02);
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_02));
|
||||
return mydoJob;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj.impl;
|
||||
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.BaseDdjThread;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.ruoyi.common.Constant.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj6Thread extends BaseDdjThread {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
ddjCodeList = new HashMap<>();
|
||||
ssjList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj6"));
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1005"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L1006"));
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L1005"));
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L1006"));
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L1005", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L1006", Arrays.asList(2, 1, 1));
|
||||
|
||||
log.info("Ddj6Thread init");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getParamMap(String trayCode) {
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", trayCode);
|
||||
paramMap.put("warehouseId",WAREHOUSE_02);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_03);
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MydoJob getOutJobParam() {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setWarehouseId(WAREHOUSE_02);
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_03));
|
||||
return mydoJob;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user