编辑设备类型和出入库调度
This commit is contained in:
@@ -137,71 +137,71 @@ public class PlcSsjRead implements Runnable {
|
||||
*
|
||||
* @param ssjDevice
|
||||
*/
|
||||
// private void readPlcSmSsj(DeviceSsj ssjDevice) {
|
||||
// OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("30"));
|
||||
// String ddsx1 = "0";
|
||||
// if (read2.IsSuccess) {
|
||||
// ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
// ssjDevice.setDw(ParseUtil.optInt(0, ddsx1));
|
||||
// ssjDevice.setKx(ParseUtil.optInt(2, ddsx1));
|
||||
// ssjDevice.setTaskNo(ParseUtil.optDInt(4, ddsx1));
|
||||
// ssjDevice.setSszt(ParseUtil.optInt(8, ddsx1));
|
||||
// ssjDevice.setRkqq(ParseUtil.optInt(10, ddsx1));
|
||||
// ssjDevice.setTraySize(ParseUtil.optInt(12, ddsx1));
|
||||
// ssjDevice.setInOrOut(ParseUtil.optInt(24, ddsx1));
|
||||
// ssjDevice.setException(ParseUtil.optInt(28, ddsx1));
|
||||
//
|
||||
// String trayCodeReadAddress="";
|
||||
// String allot="";
|
||||
// switch (ssjDevice.getDeviceCode()){
|
||||
// case "G1005":
|
||||
// trayCodeReadAddress = "DB503.0";
|
||||
// allot = "DB802.24";
|
||||
// break;
|
||||
// case "L2004":
|
||||
// trayCodeReadAddress = "DB503.600";
|
||||
// break;
|
||||
// case "L2006":
|
||||
// trayCodeReadAddress = "DB503.800";
|
||||
// break;
|
||||
// case "L1001":
|
||||
// trayCodeReadAddress = "DB503.200";
|
||||
// allot = "DB802.0";
|
||||
// break;
|
||||
// case "L1003":
|
||||
// trayCodeReadAddress = "DB503.400";
|
||||
// allot = "DB802.12";
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// if(!"".equals(allot)){
|
||||
// OperateResultExOne<byte[]> agvSsj = readWriteNet.Read(allot, Short.parseShort("2"));
|
||||
// if (agvSsj.IsSuccess){
|
||||
// //去除bytes中
|
||||
// ddsx1 = SoftBasic.ByteToHexString(agvSsj.Content);
|
||||
// ssjDevice.setAllowPut(ParseUtil.optInt(0, ddsx1));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// OperateResultExOne<byte[]> agvSsjTask = readWriteNet.Read("DB501.280", Short.parseShort("16"));
|
||||
// String ddsx2 = "0";
|
||||
// if (agvSsjTask.IsSuccess) {
|
||||
// ddsx2 = SoftBasic.ByteToHexString(agvSsjTask.Content);
|
||||
// if("L1001".equals(ssjDevice.getDeviceCode())){
|
||||
// ssjDevice.setTaskNo2(ParseUtil.optDInt(0, ddsx2));
|
||||
// }
|
||||
// if("L1003".equals(ssjDevice.getDeviceCode())){
|
||||
// ssjDevice.setTaskNo2(ParseUtil.optDInt(4, ddsx2));
|
||||
// }
|
||||
// if("L2004".equals(ssjDevice.getDeviceCode())){
|
||||
// ssjDevice.setTaskNo2(ParseUtil.optDInt(8, ddsx2));
|
||||
// }
|
||||
// if("L2006".equals(ssjDevice.getDeviceCode())){
|
||||
// ssjDevice.setTaskNo2(ParseUtil.optDInt(12, ddsx2));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
private void readPlcSmSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("30"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setDw(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setKx(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(4, ddsx1));
|
||||
ssjDevice.setSszt(ParseUtil.optInt(8, ddsx1));
|
||||
ssjDevice.setRkqq(ParseUtil.optInt(10, ddsx1));
|
||||
ssjDevice.setTraySize(ParseUtil.optInt(12, ddsx1));
|
||||
ssjDevice.setInOrOut(ParseUtil.optInt(24, ddsx1));
|
||||
ssjDevice.setException(ParseUtil.optInt(28, ddsx1));
|
||||
|
||||
String trayCodeReadAddress="";
|
||||
String allot="";
|
||||
switch (ssjDevice.getDeviceCode()){
|
||||
case "G1005":
|
||||
trayCodeReadAddress = "DB503.0";
|
||||
allot = "DB802.24";
|
||||
break;
|
||||
case "L2004":
|
||||
trayCodeReadAddress = "DB503.600";
|
||||
break;
|
||||
case "L2006":
|
||||
trayCodeReadAddress = "DB503.800";
|
||||
break;
|
||||
case "L1001":
|
||||
trayCodeReadAddress = "DB503.200";
|
||||
allot = "DB802.0";
|
||||
break;
|
||||
case "L1003":
|
||||
trayCodeReadAddress = "DB503.400";
|
||||
allot = "DB802.12";
|
||||
break;
|
||||
}
|
||||
|
||||
if(!"".equals(allot)){
|
||||
OperateResultExOne<byte[]> agvSsj = readWriteNet.Read(allot, Short.parseShort("2"));
|
||||
if (agvSsj.IsSuccess){
|
||||
//去除bytes中
|
||||
ddsx1 = SoftBasic.ByteToHexString(agvSsj.Content);
|
||||
ssjDevice.setAllowPut(ParseUtil.optInt(0, ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
OperateResultExOne<byte[]> agvSsjTask = readWriteNet.Read("DB501.280", Short.parseShort("16"));
|
||||
String ddsx2 = "0";
|
||||
if (agvSsjTask.IsSuccess) {
|
||||
ddsx2 = SoftBasic.ByteToHexString(agvSsjTask.Content);
|
||||
if("L1001".equals(ssjDevice.getDeviceCode())){
|
||||
ssjDevice.setTaskNo2(ParseUtil.optDInt(0, ddsx2));
|
||||
}
|
||||
if("L1003".equals(ssjDevice.getDeviceCode())){
|
||||
ssjDevice.setTaskNo2(ParseUtil.optDInt(4, ddsx2));
|
||||
}
|
||||
if("L2004".equals(ssjDevice.getDeviceCode())){
|
||||
ssjDevice.setTaskNo2(ParseUtil.optDInt(8, ddsx2));
|
||||
}
|
||||
if("L2006".equals(ssjDevice.getDeviceCode())){
|
||||
ssjDevice.setTaskNo2(ParseUtil.optDInt(12, ddsx2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -192,6 +192,9 @@ public class DdjThread implements Runnable {
|
||||
if (ajaxResult.isSuccess()) {
|
||||
//作废作业
|
||||
InvalidMydoJob(rwh, ddj.getId());
|
||||
|
||||
//重置【取货无货】的出库异常货位库存信息
|
||||
basCargoSpaceService.resetCargoSpaceByStockoutException(mydoJob.getCargoSpaceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.bas.cargospace.domain.BasCargoSpace;
|
||||
import com.ruoyi.bas.cargospace.service.IBasCargoSpaceService;
|
||||
import com.ruoyi.common.ConvException;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
@@ -37,6 +40,7 @@ public class PortConvThread implements Runnable {
|
||||
private IAgvQueueService agvQueueService;
|
||||
private IMydoJobService mydoJobService;
|
||||
private IJobCallBackService jobCallBackService;
|
||||
private IBasCargoSpaceService cargoSpaceService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
@@ -92,38 +96,86 @@ public class PortConvThread implements Runnable {
|
||||
//---------------------------入库模式---------------------------
|
||||
case 1:
|
||||
//---------------------------入口取输送机(叉车取放货位置)---------------------------
|
||||
//【不空闲】、【输送到位】、【条码不为空】
|
||||
if (inSsjDevice.getKx() != 1 && inSsjDevice.getDw() == 1 && inSsjDevice.getTrayCode() != "") {
|
||||
|
||||
//todo 外形校验
|
||||
|
||||
|
||||
//todo 称重校验
|
||||
|
||||
|
||||
//todo 条码校验 异常入库退回
|
||||
|
||||
//输送机【非空闲】、【输送到位】、【条码不为空】、有【入库请求】
|
||||
if (inSsjDevice.getKx() != 1 && inSsjDevice.getDw() == 1) {
|
||||
AjaxResult ajaxResult;
|
||||
|
||||
//请求参数
|
||||
//todo 核对请求wms接口参数数量
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
//托盘条码
|
||||
paramMap.put("trayCode", inSsjDevice.getTrayCode());
|
||||
paramMap.put("trayCode", inSsjDevice.getTrayCode());//托盘条码
|
||||
int height = inSsjDevice.getHeight();
|
||||
int weight = inSsjDevice.getWeight();
|
||||
//重量
|
||||
paramMap.put("weight", weight);
|
||||
//高度
|
||||
paramMap.put("height", height);
|
||||
paramMap.put("errorInfo", null);
|
||||
paramMap.put("weight", weight);//重量
|
||||
paramMap.put("height", height);//高度
|
||||
|
||||
//入库口异常校验
|
||||
switch (inSsjDevice.getException()) {
|
||||
|
||||
//外形检测异常
|
||||
case ConvException.CHECK_SIZE_EXCEPTION:
|
||||
paramMap.put("errorInfo", "外形检测异常-货物超高");
|
||||
ajaxResult = apiService.createInMydoJobException(paramMap);
|
||||
if (ajaxResult.isSuccess()) {
|
||||
//向输送机下发退回
|
||||
int i = writeToSsj(inSsjDevice.getPlcDbWriteAddress(), "99", 99, 1);
|
||||
}
|
||||
return;
|
||||
|
||||
//超重检测
|
||||
case ConvException.CHECK_OVERWEIGHT_EXCEPTION:
|
||||
paramMap.put("errorInfo", "外形检测异常-货物超重");
|
||||
ajaxResult = apiService.createInMydoJobException(paramMap);
|
||||
if (ajaxResult.isSuccess()) {
|
||||
//向输送机下发退回
|
||||
int i = writeToSsj(inSsjDevice.getPlcDbWriteAddress(), "99", 99, 1);
|
||||
}
|
||||
return;
|
||||
|
||||
//扫码异常
|
||||
case ConvException.CHECK_BARCODE_EXCEPTION:
|
||||
if (inSsjDevice.getTrayCode() == "") {
|
||||
paramMap.put("errorInfo", "条码扫描失败:扫描结果为空");
|
||||
ajaxResult = apiService.createInMydoJobException(paramMap);
|
||||
}else{
|
||||
//条码格式校验
|
||||
paramMap.put("errorInfo", "条码扫描异常:格式错误");
|
||||
ajaxResult = apiService.createInMydoJobException(paramMap);
|
||||
}
|
||||
if (ajaxResult.isSuccess()) {
|
||||
//向输送机下发退回
|
||||
int i = writeToSsj(inSsjDevice.getPlcDbWriteAddress(), "99", 99, 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//校验:有【入库请求】再请求获取wcs任务
|
||||
if (inSsjDevice.getRkqq() != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
//校验:当前条码任务已存在
|
||||
MydoJob job = new MydoJob();
|
||||
job.setTrayCode(inSsjDevice.getTrayCode());
|
||||
if (mydoJobService.selectMydoJobList(job).size() > 0) {
|
||||
log.warn("【生成wcs任务异常】该托盘号已有作业,托盘条码:{}",inSsjDevice.getTrayCode());
|
||||
return;
|
||||
}
|
||||
|
||||
//校验:当前条码已有库存
|
||||
BasCargoSpace cargoSpace = new BasCargoSpace();
|
||||
cargoSpace.setTrayCode(inSsjDevice.getTrayCode());
|
||||
if (cargoSpaceService.selectBasCargoSpaceList(cargoSpace).size() > 0) {
|
||||
log.warn("【生成wcs任务异常】该托盘号已有库存,托盘条码:{}",inSsjDevice.getTrayCode());
|
||||
return;
|
||||
}
|
||||
|
||||
//请求生成wcs任务
|
||||
AjaxResult ajaxResult = apiService.createInMydoJob(paramMap);
|
||||
ajaxResult = apiService.createInMydoJob(paramMap);
|
||||
if (ajaxResult.isSuccess()) {
|
||||
//获取wms下发的任务号和分配货位
|
||||
MydoJob mydoJob = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class);
|
||||
|
||||
//todo wms分配的货位(排列层)校验
|
||||
//todo 校验wms分配的货位(排列层)是否合法
|
||||
if (mydoJob.getCargoSpaceId() == null) {
|
||||
log.info("【请求参数异常】分配货位:null,托盘条码:{}",inSsjDevice.getTrayCode());
|
||||
return;
|
||||
@@ -140,19 +192,21 @@ public class PortConvThread implements Runnable {
|
||||
mydoJob.setPriority(Long.valueOf(10));
|
||||
|
||||
//拿到正常作业,插到wcs作业表,下发给输送机任务号,覆盖任务号
|
||||
mydoJobService.insertMydoJob(mydoJob);
|
||||
|
||||
log.info("请求生成wcs作业成功,wms下发任务单号:{}, 任务号:{},托盘条码:{},分配货位:{}", mydoJob.getJobId(), mydoJob.getTaskNo(), mydoJob.getTrayCode(), mydoJob.getCargoSpaceId());
|
||||
|
||||
//向输送机下发任务号
|
||||
int i = writeToSsj(inSsjDevice.getPlcDbWriteAddress(), mydoJob.getTaskNo(), Integer.parseInt(mydoJob.getTraySize()), 1);
|
||||
if (i == 1) {
|
||||
//写入成功则更新执行阶段
|
||||
mydoJob.setExecutionPhase(TASK_EP_LINE_SSJ);
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
log.info("G1004入口输送机下发任务号成功:{}", mydoJob.getTaskNo());
|
||||
if (mydoJobService.insertMydoJob(mydoJob) == 1) {
|
||||
log.info("请求生成wcs作业成功,wms下发任务单号:{}, 任务号:{},托盘条码:{},分配货位:{}", mydoJob.getJobId(), mydoJob.getTaskNo(), mydoJob.getTrayCode(), mydoJob.getCargoSpaceId());
|
||||
}else{
|
||||
//向输送机下发任务号
|
||||
int i = writeToSsj(inSsjDevice.getPlcDbWriteAddress(), mydoJob.getTaskNo(), Integer.parseInt(mydoJob.getTraySize()), 1);
|
||||
if (i == 1) {
|
||||
//写入成功则更新执行阶段
|
||||
mydoJob.setExecutionPhase(TASK_EP_LINE_SSJ);
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
log.info("G1004入口输送机下发任务号成功:{}", mydoJob.getTaskNo());
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
//请求生成wcs任务失败
|
||||
//todo 向输送机下发退回
|
||||
int i = writeToSsj(inSsjDevice.getPlcDbWriteAddress(), "99", 99, 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user