This commit is contained in:
zj
2026-01-04 08:39:00 +08:00
parent 88d01609d8
commit 2b6065d72f
31 changed files with 592 additions and 225 deletions

View File

@@ -27,7 +27,7 @@ import java.util.List;
@Slf4j
public class Ddj1Thread implements Runnable {
public class DdjThread implements Runnable {
public HashMap<String, List<String>> ddjCodeList;
@@ -133,7 +133,7 @@ public class Ddj1Thread implements Runnable {
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));
AjaxResult ajaxResult = apiService.reAssign(new JobParam(mydoJob.getJobId(), null, null));
if (ajaxResult.isSuccess()){
mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
mydoJob.setFaultFlag("2");

View File

@@ -141,19 +141,23 @@ public class Floor1BothWayInSsjThread implements Runnable {
}
private void dispatch2(DeviceSsj ssj) {
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0 && ssj.getTaskNo() < 1000 && ssj.getTraySize() != 0) {
if (ssj.getRkqq() == 1 && ssj.getTaskNo() > 0 && ssj.getTaskNo() < 1000 ) {
//先检测有没有出库作业,有出库作业直接退回
MydoJob outMydoJob = mydoJobService.selectRunningMydoJobByExitList(Collections.singletonList(ssj.getDeviceCode()));
if (ObjUtil.isNotNull(outMydoJob) || StrUtil.isEmpty(ssj.getTrayCode())) {
// || StrUtil.isEmpty(ssj.getTrayCode())
if (ObjUtil.isNotNull(outMydoJob)) {
//下发去向 和任务号
int i = writeToSsj(ssj.getPlcDbWriteAddress(), "0", 2, 1);
int i = writeToSsj(ssj.getPlcDbWriteAddress(), "99", 2, 2);
if (i == 1) {
log.info("未检测到托盘码下发回退 rwh:{},qx:{},trayCode:{}", ssj.getTaskNo(), 1, ssj.getTrayCode());
log.info("当前输送机有出库任务下发退回 rwh:{},qx:{},trayCode:{}", ssj.getTaskNo(), 2, ssj.getTrayCode());
}
} else {
if (StrUtil.isNotBlank(ssj.getTrayCode())) {
MydoJob param = new MydoJob();
param.setEntranceId(ssj.getDeviceCode());
String[] split = ssj.getTrayCode().split(" ");
String serial = split[2].substring(7);
param.setTrayCode(serial);
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
MydoJob inJob = null;
if (CollUtil.isNotEmpty(mydoJobs)) {
@@ -162,7 +166,7 @@ public class Floor1BothWayInSsjThread implements Runnable {
//根据托盘码请求入库作业
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("trayCode", ssj.getTrayCode());
paramMap.put("size", ssj.getTraySize());
//paramMap.put("size", ssj.getTraySize());
paramMap.put("floor", "1");
paramMap.put("entranceId",ssj.getDeviceCode());
AjaxResult result = apiService.selectMydoJobByTrayCodeAndEntranceId(paramMap);
@@ -170,9 +174,15 @@ public class Floor1BothWayInSsjThread implements Runnable {
inJob = BeanUtil.toBean(result.get("data"), MydoJob.class);
inJob.setStatus(TASK_STATUS_CREATE);
inJob.setExecutionPhase(TASK_EP_CREATE);
inJob.setFaultFlag("0");
mydoJobService.insertMydoJob(inJob);
} else {
log.info("未检测到托盘码请求入库作业 rwh:{},trayCode:{}", ssj.getTaskNo(), ssj.getTrayCode());
log.info("托盘码请求作业成功, rwh:{},trayCode:{}", ssj.getTaskNo(), ssj.getTrayCode());
}else{
//下发去向 和任务号
int i = writeToSsj(ssj.getPlcDbWriteAddress(), "99", 2, 2);
if (i == 1) {
log.info("托盘码请求作业失败, rwh:{},qx:{},trayCode:{}", ssj.getTaskNo(), 2, ssj.getTrayCode());
}
}
}
if (inJob != null) {
@@ -184,7 +194,13 @@ public class Floor1BothWayInSsjThread implements Runnable {
inJob.setStartTime(DateUtil.formatDateTime(DateUtil.date()));
inJob.setTargetRoadwayId(Convert.toStr(1));
mydoJobService.updateMydoJob(inJob);
log.info("入库请求下发任务号加去向 rwh:{},qx:{},trayCode:{}", ssj.getTaskNo(), 1, ssj.getTrayCode());
log.info("托盘码请求作业成功,下发任务号 rwh:{},qx:{},trayCode:{}", ssj.getTaskNo(), 1, ssj.getTrayCode());
}
}else{
//下发去向 和任务号
int i = writeToSsj(ssj.getPlcDbWriteAddress(), "99", 2, 2);
if (i == 1) {
log.info("托盘码请求作业失败,下发回退 rwh:{},qx:{},trayCode:{}", ssj.getTaskNo(), 2, ssj.getTrayCode());
}
}
}else {
@@ -204,42 +220,37 @@ public class Floor1BothWayInSsjThread implements Runnable {
if (i == 1) {
mydoJob.setExecutionPhase(TASK_EP_SSJ);
mydoJobService.updateMydoJob(mydoJob);
log.info("{}已重复下发任务号{}:",ssj.getDeviceCode(),mydoJob.getTaskNo());
log.info("{}无条码请求作业,二次下发任务号{}:",ssj.getDeviceCode(),mydoJob.getTaskNo());
}
}else {
//不存在扫不到托盘码的任务
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("size", ssj.getTraySize());
// paramMap.put("size", ssj.getTraySize());
paramMap.put("entranceId",ssj.getDeviceCode());
AjaxResult ajaxResult = apiService.selectMydoJobByNoTrayCode(paramMap);
if (ajaxResult.isSuccess()) {
MydoJob mydoJob2 = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class);
mydoJob2.setExecutionPhase(TASK_EP_CREATE);
mydoJob2.setFaultFlag("0");
mydoJobService.insertMydoJob(mydoJob2);
int i = writeToSsj(ssj.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
if (i == 1) {
mydoJob2.setExecutionPhase(TASK_EP_SSJ);
mydoJobService.updateMydoJob(mydoJob2);
log.info("{}已下发任务号{}:",ssj.getDeviceCode(),mydoJob2.getTaskNo());
log.info("{}无条码请求作业成功,下发任务号{}:",ssj.getDeviceCode(),mydoJob2.getTaskNo());
}
} else if (ajaxResult.isError()) {
//超大,给plc下发错误信息,等待人工处理
//托盘大小对不上,给plc下发错误信息,等待人工处理
//码不对,给plc下发错误信息,等待人工处理
int i = writeToSsj(ssj.getPlcDbWriteAddress(), "0", Integer.parseInt(ajaxResult.get("code").toString()), 2);
int i = writeToSsj(ssj.getPlcDbWriteAddress(), "99", Integer.parseInt(ajaxResult.get("code").toString()), 2);
if (i == 1) {
log.info("{}下发错误信号{}:",ssj.getDeviceCode(),Integer.parseInt(ajaxResult.get("code").toString()));
log.info("{}无条码请求作业失败,下发退回{}:",ssj.getDeviceCode(),Integer.parseInt(ajaxResult.get("code").toString()));
}
}
}
}
}
}
}
}

View File

@@ -107,6 +107,7 @@ public class Floor1BothWayOutSsjThread implements Runnable {
private void dispatch1(List<DeviceSsj> ssjList) {
for (DeviceSsj ssj : ssjList) {
if (ssj.getDw()==1 && ssj.getTaskNo()>0){
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(ssj.getTaskNo()));
if (ObjUtil.isNotNull(mydoJob) && mydoJob.getExecutionPhase().equals(TASK_EP_ROADWAY_SSJ)) {

View File

@@ -75,10 +75,8 @@ public class Floor2InOutSsjThread implements Runnable {
} catch (RuntimeException e) {
log.error(e.getMessage(), e);
}
}
break;
}
}
try {
@@ -102,15 +100,22 @@ public class Floor2InOutSsjThread implements Runnable {
//不允许放货 等着
if (!agvQueues.isEmpty() && inSsjDevice.getAllowPut() == 0 && "L1001".equals(inSsjDevice.getDeviceCode())) {
//下发输送线切换导向 DB未知
int i = writeToSsjQH("inSsjDevice.getPlcDbWriteAddress()", Integer.parseInt(agvQueues.get(0).getCtnrType()));
int i = writeToSsjQH("DB802.106", Integer.parseInt(agvQueues.get(0).getCtnrType()));
if (i == 1) {
log.info("输送机{}下发切换导向{}成功", inSsjDevice.getDeviceCode(), agvQueues.get(0).getCtnrType());
}
}
if (!agvQueues.isEmpty() && inSsjDevice.getAllowPut() == 0 && "L1003".equals(inSsjDevice.getDeviceCode())) {
//下发输送线切换导向 DB未知
int i = writeToSsjQH("DB802.118", Integer.parseInt(agvQueues.get(0).getCtnrType()));
if (i == 1) {
log.info("输送机{}下发切换导向{}成功", inSsjDevice.getDeviceCode(), agvQueues.get(0).getCtnrType());
}
}
//允许放货
if (!agvQueues.isEmpty() && inSsjDevice.getAllowPut() == 1) {
log.info("设备:{} 位置:{} 任务号:{} 请求放货成功", inSsjDevice.getDeviceCode(), "输送线", agvQueues.get(0).getTaskCode());
if (!agvQueues.isEmpty() && inSsjDevice.getAllowPut() == 2) {
log.info("设备:{} 位置:{} 任务号:{} 请求放货成功", inSsjDevice.getDeviceCode(), "输送线", agvQueues.get(0).getWmsTaskNo());
AjaxResult ajaxResult = apiService.continueTask(agvQueues.get(0));
if (ajaxResult.isSuccess()) {
log.info("下发agv允许放货成功" + agvQueues.get(0).getWmsTaskNo());
@@ -127,25 +132,37 @@ public class Floor2InOutSsjThread implements Runnable {
agvQueue.setPositionCode2(inSsjDevice.getDeviceCode());
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueue);
if (!agvQueues.isEmpty()) {
int i = writeToSsj(inSsjDevice.getPlcDbWriteAddress(), agvQueues.get(0).getWmsTaskNo(), 1,1);
if (i == 1) {
log.info("输送机{}下发任务号{}成功", inSsjDevice.getDeviceCode(), agvQueues.get(0).getWmsTaskNo());
apiService.deleteAgvTray(agvQueues.get(0));
if("L1001".equals(inSsjDevice.getDeviceCode())) {
int i = writeToSsj("DB802.100", agvQueues.get(0).getWmsTaskNo(), 2,Integer.parseInt(agvQueues.get(0).getCtnrType()));
if (i == 1) {
log.info("输送机{}AGV放货完成下发任务号{}成功", inSsjDevice.getDeviceCode(), agvQueues.get(0).getWmsTaskNo());
}
}
if("L1003".equals(inSsjDevice.getDeviceCode())) {
int i = writeToSsj("DB802.112", agvQueues.get(0).getWmsTaskNo(), 2,Integer.parseInt(agvQueues.get(0).getCtnrType()));
if (i == 1) {
log.info("输送机{}AGV放货完成下发任务号{}成功", inSsjDevice.getDeviceCode(), agvQueues.get(0).getWmsTaskNo());
}
}
}
}
if(inSsjDevice.getKx() == 0 && inSsjDevice.getTaskNo() > 0){
if(inSsjDevice.getKx() == 0 && inSsjDevice.getTaskNo2() > 0){
AgvQueue agvQueue = new AgvQueue();
agvQueue.setStatus("7"); //end
//todo 与agv对点
agvQueue.setPositionCode2(inSsjDevice.getDeviceCode());
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueue);
MydoJob mydoJob = mydoJobService.selectMydoJobByJobId(agvQueues.get(0).getTaskCode());
mydoJob.setExecutionPhase(TASK_EP_SSJ);
mydoJobService.updateMydoJob(mydoJob);
agvQueueService.insertHistory(agvQueues.get(0).getReqCode());
agvQueueService.deleteAgvQueueByReqCode(agvQueues.get(0).getReqCode());
if(agvQueues.size() > 0){
MydoJob mydoJob = mydoJobService.selectMydoJobByJobId(agvQueues.get(0).getTaskCode());
mydoJob.setExecutionPhase(TASK_EP_SSJ);
mydoJobService.updateMydoJob(mydoJob);
agvQueueService.insertHistory(agvQueues.get(0).getReqCode());
agvQueueService.deleteAgvQueueByReqCode(agvQueues.get(0).getReqCode());
}
}
//出库到位
if (inSsjDevice.getDw() == 1 && inSsjDevice.getTaskNo() > 0) {
@@ -178,7 +195,7 @@ public class Floor2InOutSsjThread implements Runnable {
List<MydoJob> outMydoJobList = mydoJobService.selectInOrOutMydoJobList(mydoJobParam);
if(!outMydoJobList.isEmpty()){
//todo 去向不明朗
int i = writeToSsj(ssjDevice.getPlcDbWriteAddress(),"0",2,2);
int i = writeToSsj(ssjDevice.getPlcDbWriteAddress(),"99",2,2);
if (i == 1) {
log.info(ssjDevice.getDeviceCode()+"有正执行的出库作业退回" );
}
@@ -214,6 +231,7 @@ public class Floor2InOutSsjThread implements Runnable {
mydoJob2.setStatus("1");
mydoJob2.setExecutionPhase(TASK_EP_CREATE);
mydoJob2.setCreateTime(new Date());
mydoJob2.setFaultFlag("0");
mydoJobService.insertMydoJob(mydoJob2);
int i = writeToSsj(ssjDevice.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
if (i == 1) {
@@ -224,7 +242,7 @@ public class Floor2InOutSsjThread implements Runnable {
}
}else{
//todo 去向不明朗
int i = writeToSsj(ssjDevice.getPlcDbWriteAddress(),"0",2,2);
int i = writeToSsj(ssjDevice.getPlcDbWriteAddress(),"99",2,2);
if (i == 1) {
log.info(ssjDevice.getDeviceCode()+"输送机没取到作业下发输送线" );
}
@@ -263,6 +281,7 @@ public class Floor2InOutSsjThread implements Runnable {
mydoJob2.setStatus("1");
mydoJob2.setExecutionPhase(TASK_EP_CREATE);
mydoJob2.setCreateTime(new Date());
mydoJob2.setFaultFlag("0");
mydoJobService.insertMydoJob(mydoJob2);
int i = writeToSsj(ssjDevice.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
if (i == 1) {
@@ -272,9 +291,9 @@ public class Floor2InOutSsjThread implements Runnable {
log.info(ssjDevice.getDeviceCode()+"输送机下发任务号成功:" + mydoJob2.getTaskNo());
}
}else{
int i = writeToSsj(ssjDevice.getPlcDbWriteAddress(), "0", Integer.parseInt(ajaxResult.get("code").toString()), 2);
int i = writeToSsj(ssjDevice.getPlcDbWriteAddress(), "99", Integer.parseInt(ajaxResult.get("code").toString()), 2);
if (i == 1) {
log.info("G1005产线输送机下发错误信息成功");
log.info(ssjDevice.getDeviceCode()+"输送机下发错误信息成功");
}
}
}

View File

@@ -138,43 +138,49 @@ public class Floor2RoadWaySsjThread implements Runnable {
if("L1004".equals(roadSsjDevice.getDeviceCode())){
exitList.add("l1003");
}
MydoJob mydoJob = mydoJobService.selectMydoJobByExitList(exitList);
if (ObjUtil.isNotNull(mydoJob)) {
BasCargoSpace basCargoSpace = basCargoSpaceService.selectBasCargoSpaceByWmsCargoSpaceId(mydoJob.getCargoSpaceId());
if (ObjUtil.isNull(basCargoSpace)) {
log.error("货位不存在 cargoSpaceId{}", mydoJob.getCargoSpaceId());
} else {
//生成队列
List<DdjDeviceExecutionQueue> list = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueListByRwlx(DDJ_RWLX_2, Convert.toInt(mydoJob.getRoadwayId()));
List<Integer> pclList = roadwayMap.get(roadSsjDevice.getDeviceCode());
if (CollUtil.isEmpty(list) && CollUtil.isNotEmpty(pclList)) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
ddjDeviceExecutionQueue.setRwh(Convert.toLong(mydoJob.getTaskNo()));
ddjDeviceExecutionQueue.setDevName(mydoJob.getRoadwayId());
ddjDeviceExecutionQueue.setDevId(Convert.toInt(mydoJob.getRoadwayId()));
ddjDeviceExecutionQueue.setRwzt(0);
ddjDeviceExecutionQueue.setYph(Convert.toInt(basCargoSpace.getThePlatoon()));
ddjDeviceExecutionQueue.setYlh(Convert.toInt(basCargoSpace.getTheColumn()));
ddjDeviceExecutionQueue.setYch(Convert.toInt(basCargoSpace.getTheFloor()));
ddjDeviceExecutionQueue.setMbph(pclList.get(0));
ddjDeviceExecutionQueue.setMblh(pclList.get(1));
ddjDeviceExecutionQueue.setMbch(pclList.get(2));
ddjDeviceExecutionQueue.setDdjxf("0");
ddjDeviceExecutionQueue.setMlfs(5);
ddjDeviceExecutionQueue.setSpare1(mydoJob.getTraySize());
ddjDeviceExecutionQueue.setScsj(DateUtil.formatDateTime(DateUtil.date()));
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_1);
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
List<MydoJob> inList = mydoJobService.getInJobByEntrance(exitList);
if(inList.size() == 0){
MydoJob mydoJob = mydoJobService.selectMydoJobByExitList(exitList);
if (ObjUtil.isNotNull(mydoJob)) {
BasCargoSpace basCargoSpace = basCargoSpaceService.selectBasCargoSpaceByWmsCargoSpaceId(mydoJob.getCargoSpaceId());
if (ObjUtil.isNull(basCargoSpace)) {
log.error("货位不存在 cargoSpaceId{}", mydoJob.getCargoSpaceId());
} else {
//生成队列
List<DdjDeviceExecutionQueue> list = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueListByRwlx(DDJ_RWLX_2, Convert.toInt(mydoJob.getRoadwayId()));
List<Integer> pclList = roadwayMap.get(roadSsjDevice.getDeviceCode());
if (CollUtil.isEmpty(list) && CollUtil.isNotEmpty(pclList)) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
ddjDeviceExecutionQueue.setRwh(Convert.toLong(mydoJob.getTaskNo()));
ddjDeviceExecutionQueue.setDevName(mydoJob.getRoadwayId());
ddjDeviceExecutionQueue.setDevId(Convert.toInt(mydoJob.getRoadwayId()));
ddjDeviceExecutionQueue.setRwzt(0);
ddjDeviceExecutionQueue.setYph(Convert.toInt(basCargoSpace.getThePlatoon()));
ddjDeviceExecutionQueue.setYlh(Convert.toInt(basCargoSpace.getTheColumn()));
ddjDeviceExecutionQueue.setYch(Convert.toInt(basCargoSpace.getTheFloor()));
ddjDeviceExecutionQueue.setMbph(pclList.get(0));
ddjDeviceExecutionQueue.setMblh(pclList.get(1));
ddjDeviceExecutionQueue.setMbch(pclList.get(2));
ddjDeviceExecutionQueue.setDdjxf("0");
ddjDeviceExecutionQueue.setMlfs(5);
ddjDeviceExecutionQueue.setSpare1(mydoJob.getTraySize());
ddjDeviceExecutionQueue.setScsj(DateUtil.formatDateTime(DateUtil.date()));
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_1);
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
//修改作业状态
mydoJob.setStatus(TASK_STATUS_RUNNING);
mydoJob.setExecutionPhase(TASK_EP_DDJ);
mydoJob.setStartTime(DateUtil.formatDateTime(DateUtil.date()));
mydoJobService.updateMydoJob(mydoJob);
//修改作业状态
mydoJob.setStatus(TASK_STATUS_RUNNING);
mydoJob.setExecutionPhase(TASK_EP_DDJ);
mydoJob.setStartTime(DateUtil.formatDateTime(DateUtil.date()));
mydoJobService.updateMydoJob(mydoJob);
}
}
}
}else{
log.info("当前出口"+ exitList+"存在入库任务,无法出库!");
}
}
}

View File

@@ -24,8 +24,7 @@ import java.util.HashMap;
import java.util.List;
import static com.ruoyi.common.TaskStatusCode.*;
import static com.ruoyi.schedule.plcRead.ssj.PlcSsjRead.deviceSsjMap;
import static com.ruoyi.schedule.plcRead.ssj.PlcSsjRead.writeToSsj;
import static com.ruoyi.schedule.plcRead.ssj.PlcSsjRead.*;
/**
* 生产线输送机
@@ -92,7 +91,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) {
if (SsjDevice.getRkqq() == 1 && StrUtil.isNotBlank(SsjDevice.getTrayCode())
&& SsjDevice.getTraySize() != 0 && SsjDevice.getTaskNo() < 1000) {
log.info("设备:{} 位置:{} 条码:{} 托盘大小:{}", SsjDevice.getDeviceCode(), "产线到位", SsjDevice.getTrayCode(), SsjDevice.getTraySize());
//查作业,入如果已经有了,直接下发输送线
@@ -107,14 +107,14 @@ public class LineSsjThread implements Runnable {
List<MydoJob> mydoJobs = mydoJobService.selectInOrOutMydoJobList(mydoJob);
//有作业,下发输送机任务号,覆盖任务号
if (!mydoJobs.isEmpty()) {
//永远有且只有一条
//永远有且只有一条
mydoJob = mydoJobs.get(0);
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), mydoJob.getTaskNo(), 1, 1);
if (i == 1) {
mydoJob.setExecutionPhase(TASK_EP_LINE_SSJ);
mydoJobService.updateMydoJob(mydoJob);
log.info("G1005产线输送机下发任务号成功:" + mydoJob.getTaskNo());
}
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), mydoJob.getTaskNo(), Integer.parseInt(mydoJob.getTraySize()), 1);
if (i == 1) {
mydoJob.setExecutionPhase(TASK_EP_LINE_SSJ);
mydoJobService.updateMydoJob(mydoJob);
log.info("G1005产线输送机下发任务号成功:" + mydoJob.getTaskNo());
}
} else {
//请求wms生成入库作业
@@ -127,17 +127,18 @@ public class LineSsjThread implements Runnable {
AjaxResult ajaxResult = apiService.createInMydoJob(paramMap);
if (ajaxResult.isSuccess()) {
//拿到正常作业,插到wcs作业表,下发给输送机任务号,覆盖任务号
MydoJob mydoJob2 = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class) ;
MydoJob mydoJob2 = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class);
mydoJob2.setStatus("1");
mydoJob2.setExecutionPhase(TASK_EP_CREATE);
mydoJob2.setCreateTime(new Date());
mydoJob2.setTraySize(Convert.toStr(SsjDevice.getTraySize()));
mydoJob2.setFaultFlag("0");
mydoJobService.insertMydoJob(mydoJob2);
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), mydoJob2.getTaskNo(), Integer.parseInt(mydoJob2.getTraySize()), 1);
if (i == 1) {
mydoJob2.setExecutionPhase(TASK_EP_LINE_SSJ);
mydoJobService.updateMydoJob(mydoJob2);
log.info("G1005产线输送机下发任务号成功:{}" , mydoJob2.getTaskNo());
log.info("G1005产线输送机下发任务号成功:{}", mydoJob2.getTaskNo());
}
} else {
/**
@@ -152,18 +153,24 @@ public class LineSsjThread implements Runnable {
* 9, "创建工艺入库单失败!"
*/
//超大,给plc下发错误信息,AGV搬到缓存区 其余人工处理
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), "0", (Integer) ajaxResult.get("code"), 2);
if (i == 1) {
log.info("G1005产线输送机下发错误信息成功");
}
if((Integer) ajaxResult.get("code") == 5){
if ((Integer) ajaxResult.get("code") == 5) {
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), "2222", 1, 1);
if (i == 1) {
log.info("G1005产线输送机下发错误信息成功");
}
createMoveToPort(SsjDevice);
} else {
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), "99", Integer.parseInt(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.getRkqq() == 1 && StrUtil.isBlank(SsjDevice.getTrayCode()) &&
SsjDevice.getTraySize() != 0 && SsjDevice.getTaskNo() < 1000) {
log.info("设备:{} 位置:{} 条码:{} 托盘大小:{}", SsjDevice.getDeviceCode(), "产线", SsjDevice.getTrayCode(), SsjDevice.getTraySize());
//查wcs有没作业,有下发给输送机任务号,覆盖任务号
@@ -177,11 +184,11 @@ public class LineSsjThread implements Runnable {
if (!mydoJobs.isEmpty()) {
mydoJob = mydoJobs.get(0);
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), mydoJob.getTaskNo(), 1, 1);
if (i == 1) {
mydoJob.setExecutionPhase(TASK_EP_LINE_SSJ);
mydoJobService.updateMydoJob(mydoJob);
log.info("G1005产线输送机下发任务号成功:" + mydoJob.getTaskNo());
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), mydoJob.getTaskNo(), 1, 1);
if (i == 1) {
mydoJob.setExecutionPhase(TASK_EP_LINE_SSJ);
mydoJobService.updateMydoJob(mydoJob);
log.info("G1005产线输送机下发任务号成功:" + mydoJob.getTaskNo());
}
} else {
@@ -196,8 +203,9 @@ public class LineSsjThread implements Runnable {
mydoJob2.setExecutionPhase("0");
mydoJob2.setCreateTime(new Date());
mydoJob2.setTraySize(Convert.toStr(SsjDevice.getTraySize()));
mydoJob2.setFaultFlag("0");
mydoJobService.insertMydoJob(mydoJob2);
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), mydoJob2.getTaskNo(), 1, 1);
if (i == 1) {
mydoJob2.setExecutionPhase(TASK_EP_LINE_SSJ);
mydoJobService.updateMydoJob(mydoJob2);
@@ -207,13 +215,18 @@ public class LineSsjThread implements Runnable {
//超大,给plc下发错误信息,等待人工处理
//托盘大小对不上,给plc下发错误信息,等待人工处理
//码不对,给plc下发错误信息,等待人工处理
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), "0", Integer.parseInt(ajaxResult.get("code").toString()), 2);
if (i == 1) {
log.info("G1005产线输送机下发错误信息成功");
}
//7是报工单失败,不处理
if(!"9".equals(Integer.parseInt(ajaxResult.get("code").toString()))){
if ((Integer) ajaxResult.get("code") == 5) {
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), "2222", 1, 1);
if (i == 1) {
log.info("G1005产线输送机下发错误信息成功");
}
createMoveToPort(SsjDevice);
} else {
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), "99", Integer.parseInt(ajaxResult.get("code").toString()), 2);
if (i == 1) {
log.info("G1005产线输送机下发错误信息成功");
}
}
}
}
@@ -244,24 +257,27 @@ public class LineSsjThread implements Runnable {
if (outMydoJobList.isEmpty() && kx == 1) {
//查是否有队列,如果有了请求放货修改为允许放货
AgvQueue agvQueue = agvQueueService.selectAgvQueueByTaskCode(mydoJob.getJobId());
if (agvQueue != null){
if ("3".equals(mydoJob.getStatus()) && "1".equals(agvQueue.getStatus()) && SsjDevice.getAllowPut() == 1){
if (agvQueue != null) {
if ("3".equals(mydoJob.getStatus()) && "2".equals(agvQueue.getStatus()) && SsjDevice.getAllowPut() == 1) {
AjaxResult ajaxResult = apiService.continueTask(agvQueue);
if (ajaxResult.isSuccess()) {
log.info("给agv下发允许取货继续任务成功"+agvQueue.getWmsTaskNo());
log.info("给agv下发允许取货继续任务成功" + agvQueue.getWmsTaskNo());
agvQueue.setStatus("2");
agvQueueService.updateAgvQueue(agvQueue);
}
}
}else {
if ("1".equals(mydoJob.getStatus())){
if("0".equals(agvQueue.getStatus())){
apiService.requestAgvQueue(agvQueue);
}
} else {
if ("1".equals(mydoJob.getStatus())) {
HashMap<String, String> paramMap = new HashMap<>();
// paramMap.put("trayCode", mydoJob.getTrayCode());
paramMap.put("taskNo", mydoJob.getJobId());
paramMap.put("trayCode", mydoJob.getTrayCode());
paramMap.put("taskCode",mydoJobParam.getJobId());
//todo 与agv对点
paramMap.put("startPoint", "G1005");
paramMap.put("endPoint", deviceCode);
paramMap.put("traySize",mydoJob.getTraySize());
paramMap.put("traySize", mydoJob.getTraySize());
paramMap.put("wmsTaskNo", mydoJob.getTaskNo());
AjaxResult ajaxResult = apiService.receiveAgvMoveJob(paramMap);
if (ajaxResult.isSuccess()) {
@@ -272,17 +288,37 @@ public class LineSsjThread implements Runnable {
}
}
}
}
}
if (SsjDevice.getDw() == 1 && SsjDevice.getTaskNo() == 2222 && SsjDevice.getTraySize() == 4) {
AgvQueue agvQueue = agvQueueService.selectAgvQueueByWmsTask(SsjDevice.getTaskNo());
if (agvQueue != null) {
if ("2".equals(agvQueue.getStatus()) && SsjDevice.getAllowPut() == 1) {
AjaxResult ajaxResult = apiService.continueTask(agvQueue);
if (ajaxResult.isSuccess()) {
log.info("给agv下发允许取货继续任务成功" + agvQueue.getWmsTaskNo());
agvQueue.setStatus("2");
agvQueueService.updateAgvQueue(agvQueue);
}
}
}
}
if (SsjDevice.getDw() == 0 && SsjDevice.getTaskNo() > 1000 && SsjDevice.getTraySize() > 0) {
AgvQueue agvQueue = agvQueueService.selectAgvQueueByWmsTask(SsjDevice.getTaskNo());
if (agvQueue != null) {
if ("4".equals(agvQueue.getStatus())) {
int i = writeToSsjQH("DB802.122", 1);
if (i == 1) {
log.info("G1005产线输送机下发取货完成成功!");
}
}
}
}
}
void createMoveToPort(DeviceSsj SsjDevice){
void createMoveToPort(DeviceSsj SsjDevice) {
WcsPort wcsPort = new WcsPort();
wcsPort.setStatus("1");
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPort);
@@ -294,29 +330,23 @@ public class LineSsjThread implements Runnable {
.map(WcsPort::getPortCode)
.anyMatch(portCode -> portCode.equals(positionCode2)));
if(hasMatchingPort==false){
if (hasMatchingPort == false) {
if(!wcsPorts.isEmpty()){
if (!wcsPorts.isEmpty()) {
HashMap<String, String> map = new HashMap<>();
// map.put("trayCode", mydoJob.getTrayCode());
map.put("taskNo", StrUtil.uuid());
//todo 与agv对点
map.put("startPoint", "G1005");
map.put("endPoint", wcsPorts.get(0).getPortCode());
// map.put("traySize",String.valueOf(SsjDevice.getTraySize()));
map.put("traySize", "5");
// map.put("wmsTaskNo", mydoJob.getTaskNo());
AjaxResult ajaxResult1 = apiService.receiveAgvMoveJob(map);
if(ajaxResult1.isSuccess()){
log.info("G1005产线生成作业失败,AGV下发搬运至缓存点任务成功:{}" , ajaxResult1.get("data"));
if (ajaxResult1.isSuccess()) {
log.info("G1005产线生成作业失败,AGV下发搬运至缓存点任务成功:{}", ajaxResult1.get("data"));
}
}
}
}
}