输送线
This commit is contained in:
@@ -128,4 +128,6 @@ public interface IApiService
|
||||
AjaxResult receiveInMydoJob(ReceiveJob receiveInJob);
|
||||
|
||||
AjaxResult selectMydoJobByTrayCodeAndEntranceId(HashMap<String, Object> paramMap);
|
||||
|
||||
AjaxResult allotSpace(JobParam jobParam);
|
||||
}
|
||||
|
||||
@@ -391,4 +391,9 @@ public class ApiServiceImpl implements IApiService {
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult allotSpace(JobParam jobParam) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.impl.Ddj1Thread;
|
||||
import com.ruoyi.schedule.scheduleTask.monit.MonitoringThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.SsjThread;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -32,7 +33,8 @@ public class ScheduleThread {
|
||||
public CustomThread<PlcDdjRead> plcDdj6ReadCustomThread;
|
||||
|
||||
public CustomThread<MonitoringThread> monitoringCustomThread;
|
||||
public CustomThread<Ddj1Thread> ddj1CustomThread;
|
||||
public CustomThread<SsjThread> ssjThreadCustomThread;
|
||||
// public CustomThread<Ddj1Thread> ddj1CustomThread;
|
||||
/*public CustomThread<Ddj2Thread> ddj2CustomThread;
|
||||
public CustomThread<Ddj3Thread> ddj3CustomThread;
|
||||
public CustomThread<Ddj4Thread> ddj4CustomThread;
|
||||
@@ -65,8 +67,10 @@ public class ScheduleThread {
|
||||
private void scheduleInit() {
|
||||
MonitoringThread monitoringThread = new MonitoringThread();
|
||||
monitoringCustomThread = new CustomThread<MonitoringThread>(new Thread(monitoringThread), monitoringThread);
|
||||
Ddj1Thread ddj1Thread = new Ddj1Thread();
|
||||
ddj1CustomThread = new CustomThread<>(new Thread(ddj1Thread), ddj1Thread);
|
||||
SsjThread ssjThread=new SsjThread();
|
||||
ssjThreadCustomThread=new CustomThread<SsjThread>(new Thread(ssjThread),ssjThread);
|
||||
// Ddj1Thread ddj1Thread = new Ddj1Thread();
|
||||
// ddj1CustomThread = new CustomThread<>(new Thread(ddj1Thread), ddj1Thread);
|
||||
/*Ddj2Thread ddj2Thread = new Ddj2Thread();
|
||||
ddj2CustomThread = new CustomThread<>(new Thread(ddj2Thread), ddj2Thread);
|
||||
Ddj3Thread ddj3Thread = new Ddj3Thread();
|
||||
@@ -161,7 +165,8 @@ public class ScheduleThread {
|
||||
*/
|
||||
public void startAllThread2() {
|
||||
monitoringCustomThread.thread.start();
|
||||
ddj1CustomThread.thread.start();
|
||||
ssjThreadCustomThread.thread.start();
|
||||
// ddj1CustomThread.thread.start();
|
||||
/*ddj2CustomThread.thread.start();
|
||||
ddj3CustomThread.thread.start();
|
||||
ddj4CustomThread.thread.start();
|
||||
@@ -190,7 +195,7 @@ public class ScheduleThread {
|
||||
*/
|
||||
public void stopAllThread2() {
|
||||
monitoringCustomThread.runnable.isRun = false;
|
||||
ddj1CustomThread.runnable.isRun = false;
|
||||
// ddj1CustomThread.runnable.isRun = false;
|
||||
/*ddj2CustomThread.runnable.isRun = false;
|
||||
ddj3CustomThread.runnable.isRun = false;
|
||||
ddj4CustomThread.runnable.isRun = false;
|
||||
|
||||
@@ -63,9 +63,6 @@ public class PlcSsjRead implements Runnable {
|
||||
case "3":
|
||||
readPlcOtherSsj(ssjDevice);
|
||||
break;
|
||||
case "4":
|
||||
readPlcRoadWaySsj(ssjDevice);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
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.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.job.domain.JobCallBack;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.job.service.IJobCallBackService;
|
||||
import com.ruoyi.job.service.IMydoJobService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ruoyi.schedule.plcRead.ssj.PlcSsjRead.writeToSsj;
|
||||
|
||||
@Slf4j
|
||||
public class SsjThread implements Runnable {
|
||||
|
||||
public boolean isRun = true;
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
private IMydoJobService mydoJobService;
|
||||
private IJobCallBackService jobCallBackService;
|
||||
private IApiService apiService;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("TD1001");
|
||||
ssjCodes.add("TD1008");
|
||||
ssjCodeList.put("out", ssjCodes);
|
||||
ArrayList<String> ssjCodes1 = new ArrayList<>();
|
||||
ssjCodes1.add("GS1002");
|
||||
ssjCodes1.add("GS1007");
|
||||
ssjCodeList.put("in", ssjCodes1);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
jobCallBackService = SpringUtils.getBean(IJobCallBackService.class);
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
switch (type) {
|
||||
case "out":
|
||||
for (String ssjCode : ssjCodeList.get("out")) {
|
||||
try {
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "in":
|
||||
for (String ssjCode : ssjCodeList.get("in")) {
|
||||
try {
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch1(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void inDispatch(DeviceSsj deviceSsj) {
|
||||
//出库到位
|
||||
if (deviceSsj.getDw() == 1 && deviceSsj.getTaskNo() > 0) {
|
||||
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(deviceSsj.getTaskNo()));
|
||||
if (mydoJob != null) {
|
||||
log.info("设备:{} 位置:{} 任务号:{} 出库到位", "输送线", deviceSsj.getDeviceCode(), mydoJob.getTaskNo());
|
||||
mydoJobService.insertHistory(mydoJob.getJobId());
|
||||
mydoJobService.deleteMydoJobByJobId(mydoJob.getJobId());
|
||||
JobCallBack jobCallBack = new JobCallBack();
|
||||
jobCallBack.setType("2");
|
||||
jobCallBack.setMydojobId(mydoJob.getJobId());
|
||||
jobCallBack.setStatus("0");
|
||||
jobCallBack.setTaskNo(Convert.toLong(mydoJob.getTaskNo()));
|
||||
jobCallBack.setCreateTime(new Date());
|
||||
jobCallBackService.insertJobCallBack(jobCallBack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void inDispatch1(DeviceSsj deviceSsj) {
|
||||
if (deviceSsj.getDw() == 1 && StrUtil.isNotBlank(deviceSsj.getTrayCode())) {
|
||||
//todo 查是否为入库模式,不是退回
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("trayCode", deviceSsj.getTrayCode());
|
||||
//拉取
|
||||
AjaxResult ajaxResult = apiService.createInMydoJob(map);
|
||||
if (ajaxResult.isSuccess()) {
|
||||
//拿到正常作业,插到wcs作业表,下发给输送机任务号,覆盖任务号
|
||||
MydoJob mydoJob = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class);
|
||||
mydoJob.setStatus("1");
|
||||
mydoJob.setExecutionPhase("0");
|
||||
mydoJob.setCreateTime(new Date());
|
||||
|
||||
mydoJobService.insertMydoJob(mydoJob);
|
||||
int i = writeToSsj(deviceSsj.getPlcDbWriteAddress(), mydoJob.getTaskNo(), 1, 1);
|
||||
if (i == 1) {
|
||||
log.info(deviceSsj.getDeviceCode()+"输送机下发任务号成功:{}", mydoJob.getTaskNo());
|
||||
}
|
||||
} else {
|
||||
int i = writeToSsj(deviceSsj.getPlcDbWriteAddress(), "0", 2,1);
|
||||
if (i == 1) {
|
||||
log.info(deviceSsj.getDeviceCode()+"未查到该托盘码作业,下发退回,去向2");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user