产线输送机
This commit is contained in:
@@ -99,32 +99,32 @@ public class Ddj2Thread implements Runnable {
|
||||
if (ObjUtil.isNotNull(mydoJob)) {
|
||||
|
||||
//生成agv队列
|
||||
AgvQueue agvQueue = apiService.createAgvQueue(inSsjDevice.getName(), mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo(),"1");
|
||||
// AgvQueue agvQueue = apiService.createAgvQueue(inSsjDevice.getName(), mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo(),"1");
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
// GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
// //修改wms任务状态
|
||||
// if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
// //修改ctu执行状态
|
||||
// agvQueue.setStatus("1");
|
||||
// agvQueueService.updateAgvQueue(agvQueue);
|
||||
// log.info("向CTU下入库库作业");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}else {
|
||||
AgvQueue agvQueue = agvQueues.get(0);
|
||||
if ("0".equals(agvQueue.getStatus())){
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
// AgvQueue agvQueue = agvQueues.get(0);
|
||||
// if ("0".equals(agvQueue.getStatus())){
|
||||
// //请求任务生成
|
||||
// GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
// //修改wms任务状态
|
||||
// if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
// //修改ctu执行状态
|
||||
// agvQueue.setStatus("1");
|
||||
// agvQueueService.updateAgvQueue(agvQueue);
|
||||
// log.info("向CTU下入库库作业");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 二楼入口线程 循环agv搬运完成状态的队列,找到作业,下发去向+任务号
|
||||
* 二楼出入口输送线线程
|
||||
*/
|
||||
@Slf4j
|
||||
public class Floor2InSsjThread implements Runnable {
|
||||
@@ -34,9 +34,9 @@ public class Floor2InSsjThread implements Runnable {
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("L1002");
|
||||
ssjCodes.add("L1004");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
ssjCodes.add("L1011");
|
||||
ssjCodes.add("L1012");
|
||||
ssjCodeList.put("inout", ssjCodes);
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
@@ -49,7 +49,7 @@ public class Floor2InSsjThread implements Runnable {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
case "in":
|
||||
case "inout":
|
||||
//生产线入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
@@ -77,13 +77,18 @@ public class Floor2InSsjThread implements Runnable {
|
||||
|
||||
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw() == 1 && inSsjDevice.getTaskNo() > 0 && inSsjDevice.getRkqq() == 1) {
|
||||
//查询货位 排列层
|
||||
//如果输送机空闲
|
||||
if (inSsjDevice.getKx() == 1) {
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setStatus("6");
|
||||
agvQueue.setPositionCode2(inSsjDevice.getDeviceCode());
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
if(agvQueues.size()!=0){
|
||||
//如果有这个输送机口的agv队列并请求放货(状态为6)
|
||||
|
||||
//查询入口 排列层
|
||||
|
||||
//生成堆垛机队列
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Floor2OutSsjThread implements Runnable {
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("L1002");
|
||||
ssjCodes.add("L1004");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
ssjCodeList.put("roadwayssj", ssjCodes);
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
@@ -43,7 +43,7 @@ public class Floor2OutSsjThread implements Runnable {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
case "in":
|
||||
case "roadwayssj":
|
||||
//生产线入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.schedule.scheduleTask.ssj.floor2;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.ruoyi.api.domain.agv.continueTask.ContinueTaskResponse;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.domain.SendData;
|
||||
@@ -9,6 +10,7 @@ import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.job.service.IMydoJobService;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
@@ -18,6 +20,9 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ruoyi.common.TaskStatusCode.TASK_EP_AGV;
|
||||
import static com.ruoyi.schedule.plcRead.ssj.PlcSsjRead.deviceSsjMap;
|
||||
|
||||
/**
|
||||
* 生产线输送机
|
||||
* 生产线线程 检测到位+托盘条码+托盘大小 请求wms生成入库作业 。 循环作业表,检测有没有出库作业 ,生成agv搬运作业。
|
||||
@@ -49,21 +54,21 @@ public class LineSsjThread implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun){
|
||||
while (isRun) {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
switch (type) {
|
||||
case "line":
|
||||
//生产线入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
if (deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -82,8 +87,8 @@ public class LineSsjThread implements Runnable {
|
||||
|
||||
public void inDispatch(DeviceSsj SsjDevice) {
|
||||
//如果到位,扫到条码,托盘大小,执行阶段卡控一下(下发输送机后改执行阶段)
|
||||
if (SsjDevice.getDw() == 1 && StrUtil.isNotBlank(SsjDevice.getTrayCode()) && SsjDevice.getTraySize() !=0 && SsjDevice.getTaskNo()<1000) {
|
||||
log.info("设备:{} 位置:{} 条码:{} 托盘大小:{}",SsjDevice.getDeviceCode(),"产线到位",SsjDevice.getTrayCode(),SsjDevice.getTraySize());
|
||||
if (SsjDevice.getDw() == 1 && StrUtil.isNotBlank(SsjDevice.getTrayCode()) && SsjDevice.getTraySize() != 0 && SsjDevice.getTaskNo() < 1000) {
|
||||
log.info("设备:{} 位置:{} 条码:{} 托盘大小:{}", SsjDevice.getDeviceCode(), "产线到位", SsjDevice.getTrayCode(), SsjDevice.getTraySize());
|
||||
|
||||
//查作业,入如果已经有了,直接下发输送线
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
@@ -93,20 +98,18 @@ public class LineSsjThread implements Runnable {
|
||||
mydoJob.setExecutionPhase("0");
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectInOrOutMydoJobList(mydoJob);
|
||||
//有作业,下发输送机任务号,覆盖任务号
|
||||
if(mydoJobs.size()>0){
|
||||
if (mydoJobs.size() > 0) {
|
||||
|
||||
mydoJob = mydoJobs.get(0);
|
||||
SendData taskNo = new SendData(Tools.INT, mydoJob.getTaskNo());
|
||||
byte[] bytes = Tools.sendData(taskNo);
|
||||
int i = PlcSsjRead.WriteToSSJ(SsjDevice.getPlcDbWriteAddress(), bytes);
|
||||
if (i==1){
|
||||
mydoJob.setExecutionPhase("1");
|
||||
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),mydoJob.getTaskNo(),1,1);
|
||||
if (i == 1) {
|
||||
mydoJob.setExecutionPhase(TASK_EP_AGV);
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
log.info("G1005产线输送机下发任务号成功:"+mydoJob.getTaskNo());
|
||||
log.info("G1005产线输送机下发任务号成功:" + mydoJob.getTaskNo());
|
||||
}
|
||||
|
||||
|
||||
}else {
|
||||
} else {
|
||||
|
||||
//请求wms生成入库作业
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
@@ -117,29 +120,32 @@ public class LineSsjThread implements Runnable {
|
||||
AjaxResult ajaxResult = apiService.createInMydoJob(paramMap);
|
||||
if (ajaxResult.isSuccess()) {
|
||||
//拿到正常作业,插到wcs作业表,下发给输送机任务号,覆盖任务号
|
||||
MydoJob mydoJob2 = (MydoJob) ajaxResult.get("mydoJob");
|
||||
MydoJob mydoJob2 = (MydoJob) ajaxResult.get("data");
|
||||
mydoJobService.insertMydoJob(mydoJob2);
|
||||
SendData taskNo = new SendData(Tools.INT, mydoJob2.getTaskNo());
|
||||
byte[] bytes = Tools.sendData(taskNo);
|
||||
int i = PlcSsjRead.WriteToSSJ(SsjDevice.getPlcDbWriteAddress(), bytes);
|
||||
if (i==1){
|
||||
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
|
||||
if (i == 1) {
|
||||
mydoJob2.setExecutionPhase("1");
|
||||
mydoJobService.updateMydoJob(mydoJob2);
|
||||
log.info("G1005产线输送机下发任务号成功:"+mydoJob2.getTaskNo());
|
||||
log.info("G1005产线输送机下发任务号成功:" + mydoJob2.getTaskNo());
|
||||
}
|
||||
} else if (ajaxResult.isError()) {
|
||||
} else {
|
||||
//超大,给plc下发错误信息,等待人工处理
|
||||
//托盘大小对不上,给plc下发错误信息,等待人工处理
|
||||
//码不对,给plc下发错误信息,等待人工处理
|
||||
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),"0",Integer.valueOf(ajaxResult.get("code").toString()),2);
|
||||
if (i == 1) {
|
||||
log.info("G1005产线输送机下发错误信息成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (SsjDevice.getDw() == 1 && StrUtil.isBlank(SsjDevice.getTrayCode()) && SsjDevice.getTraySize() !=0 && SsjDevice.getTaskNo()<1000) {
|
||||
if (SsjDevice.getDw() == 1 && StrUtil.isBlank(SsjDevice.getTrayCode()) && SsjDevice.getTraySize() != 0 && SsjDevice.getTaskNo() < 1000) {
|
||||
|
||||
log.info("设备:{} 位置:{} 条码:{} 托盘大小:{}",SsjDevice.getDeviceCode(),"产线",SsjDevice.getTrayCode(),SsjDevice.getTraySize());
|
||||
log.info("设备:{} 位置:{} 条码:{} 托盘大小:{}", SsjDevice.getDeviceCode(), "产线", SsjDevice.getTrayCode(), SsjDevice.getTraySize());
|
||||
//查wcs有没作业,有下发给输送机任务号,覆盖任务号
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setInOrOut("1");
|
||||
@@ -147,16 +153,107 @@ public class LineSsjThread implements Runnable {
|
||||
mydoJob.setEntranceId("G1005");
|
||||
mydoJob.setExecutionPhase("0");
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectInOrOutMydoJobList(mydoJob);
|
||||
//没有,请求错误接口,找作业,返回成功,//拿到正常作业,插到wcs作业表,下发给输送机任务号,覆盖任务号,shibai...
|
||||
if (mydoJobs.size() > 0) {
|
||||
mydoJob = mydoJobs.get(0);
|
||||
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),mydoJob.getTaskNo(),1,1);
|
||||
if (i == 1) {
|
||||
mydoJob.setExecutionPhase("1");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
log.info("G1005产线输送机下发任务号成功:" + mydoJob.getTaskNo());
|
||||
}
|
||||
} else {
|
||||
//没有,请求错误接口,找作业,返回成功,//拿到正常作业,插到wcs作业表,下发给输送机任务号,覆盖任务号,shibai...
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("traySize", SsjDevice.getTraySize());
|
||||
AjaxResult ajaxResult = apiService.selectMydoJobByNoTrayCode(paramMap);
|
||||
if (ajaxResult.isSuccess()) {
|
||||
MydoJob mydoJob2 = (MydoJob) ajaxResult.get("mydoJob");
|
||||
mydoJobService.insertMydoJob(mydoJob2);
|
||||
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
|
||||
if (i == 1) {
|
||||
mydoJob2.setExecutionPhase("1");
|
||||
mydoJobService.updateMydoJob(mydoJob2);
|
||||
log.info("G1005产线输送机下发任务号成功:" + mydoJob2.getTaskNo());
|
||||
}
|
||||
} else if (ajaxResult.isError()) {
|
||||
//超大,给plc下发错误信息,等待人工处理
|
||||
//托盘大小对不上,给plc下发错误信息,等待人工处理
|
||||
//码不对,给plc下发错误信息,等待人工处理
|
||||
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),"0",Integer.valueOf(ajaxResult.get("code").toString()),2);
|
||||
if (i == 1) {
|
||||
log.info("G1005产线输送机下发错误信息成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (SsjDevice.getDw() == 1 && SsjDevice.getTraySize() ==0 && SsjDevice.getTaskNo()>1000) {
|
||||
if (SsjDevice.getDw() == 1 && SsjDevice.getTraySize() != 0 && StrUtil.isNotBlank(SsjDevice.getTrayCode()) && SsjDevice.getTaskNo() > 1000) {
|
||||
|
||||
log.info("设备:{} 位置:{} 条码:{} 托盘大小:{}", SsjDevice.getDeviceCode(), "产线", SsjDevice.getTrayCode(), SsjDevice.getTraySize());
|
||||
//任务号查wcs作业,查巷道,看目标输送线是否空闲,查是否有出库作业,生成agv队列
|
||||
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Long.valueOf(SsjDevice.getTaskNo()));
|
||||
String deviceCode = "";
|
||||
if (mydoJob != null) {
|
||||
if ("1".equals(mydoJob.getRoadwayId())) {
|
||||
deviceCode = "L1011";
|
||||
} else {
|
||||
deviceCode = "L1012";
|
||||
}
|
||||
int kx = deviceSsjMap.get(deviceCode).getKx();
|
||||
MydoJob mydoJob1 = new MydoJob();
|
||||
mydoJob1.setInOut("2");
|
||||
mydoJob1.setStatus("3");
|
||||
mydoJob1.setExitId(deviceCode);
|
||||
List<MydoJob> mydoJob2 = mydoJobService.selectInOrOutMydoJobList(mydoJob1);
|
||||
if (mydoJob2.size() == 0 && kx == 1 && "1".equals(mydoJob.getStatus())) {
|
||||
//查是否有队列,如果有了请求放货修改为允许放货
|
||||
AgvQueue agvQueue = agvQueueService.selectAgvQueueByTaskCode(mydoJob.getJobId());
|
||||
if (agvQueue != null && "1".equals(agvQueue.getStatus())) {
|
||||
AjaxResult ajaxResult = apiService.continueTask(agvQueue);
|
||||
if (ajaxResult.isSuccess()) {
|
||||
agvQueue.setStatus("2");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
HashMap<String, String> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", mydoJob.getTrayCode());
|
||||
paramMap.put("taskNo", mydoJob.getJobId());
|
||||
paramMap.put("startPoint", "G1005");
|
||||
paramMap.put("endPoint", deviceCode);
|
||||
paramMap.put("traySize",String.valueOf(SsjDevice.getTraySize()));
|
||||
AjaxResult ajaxResult = apiService.receiveAgvMoveJob(paramMap);
|
||||
if (ajaxResult.isSuccess()) {
|
||||
mydoJob.setStatus("3");
|
||||
mydoJob.setExecutionPhase("2");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
log.info("设备:{} 位置:{} 条码:{} 托盘大小:{}",SsjDevice.getDeviceCode(),"产线",SsjDevice.getTrayCode(),SsjDevice.getTraySize());
|
||||
//任务号查wcs作业,查巷道,看目标输送线是否空闲
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static int writeToSsj(String address,String taskNo,int qx,int completed) {
|
||||
|
||||
int jym = Tools.getJYM(Integer.parseInt(taskNo), qx, 1);
|
||||
SendData taskNoSendData = new SendData(Tools.INT, taskNo);
|
||||
SendData qxSendData = new SendData(Tools.INT,qx);
|
||||
SendData completedSendData = new SendData(Tools.INT, completed);
|
||||
SendData jymSendData = new SendData(Tools.INT, jym);
|
||||
byte[] bytes = Tools.sendData(taskNoSendData, qxSendData, completedSendData, jymSendData);
|
||||
int i = PlcSsjRead.WriteToSSJ(address, bytes);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user