wcs出库未拣货时,写入信息给plc

main
judy 1 year ago
parent f21494a704
commit 357c32e09e
  1. 122
      shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java

@ -146,6 +146,7 @@ public class PlcEventTask {
plcInit.connect(); plcInit.connect();
} }
} }
//堆垛机心跳 //堆垛机心跳
@Scheduled(fixedDelay = 4000) @Scheduled(fixedDelay = 4000)
public void writePlcheartbeatStk() { public void writePlcheartbeatStk() {
@ -212,6 +213,7 @@ public class PlcEventTask {
/** /**
* 处理设备报警信息 * 处理设备报警信息
*
* @param propertyList * @param propertyList
* @param pointMap * @param pointMap
*/ */
@ -246,6 +248,7 @@ public class PlcEventTask {
/** /**
* 处理设备状态 * 处理设备状态
*
* @param propertyList * @param propertyList
* @param pointMap * @param pointMap
*/ */
@ -338,16 +341,16 @@ public class PlcEventTask {
String oneHignTypeVT = "", twoHignTypeVT = ""; String oneHignTypeVT = "", twoHignTypeVT = "";
/** /**
* 失败原因 超长 左超宽 右超宽 超高 * 失败原因 超长 后超长 左超宽 右超宽 超高
*/ */
String oneOverlength="",oneLwide="",oneRwide="",oneHigh=""; String oneBoverlength = "", oneAoverlength="", oneLwide = "", oneRwide = "", oneHigh = "";
String twoOverlength="",twoLwide="",twoRwide="",twoHigh=""; String twoBoverlength = "", twoAoverlength = "", twoLwide = "", twoRwide = "", twoHigh = "";
Boolean oneOverlengthV=false,oneLwideV=false,oneRwideV=false,oneHighV=false; Boolean oneBoverlengthV = false, oneAoverlengthV = false, oneLwideV = false, oneRwideV = false, oneHighV = false;
Boolean twoOverlengthV=false,twoLwideV=false,twoRwideV=false,twoHighV=false; Boolean twoBoverlengthV = false, twoAoverlengthV = false, twoLwideV = false, twoRwideV = false, twoHighV = false;
String oneWcsErrExit ="",twoWcsErrExit =""; String oneWcsErrExit = "", twoWcsErrExit = "",oneWcsExitOutExit="",twoWcsExitOutExit="";
String oneWcsErrExitVT="",twoWcsErrExitVT =""; String oneWcsErrExitVt = "", twoWcsErrExitVt = "",oneWcsExitOutExitVt="",twoWcsExitOutExitVt="";
for (WcsPlcProperty plcProperty : propertyList) { for (WcsPlcProperty plcProperty : propertyList) {
String pointType = plcProperty.getPointType(); String pointType = plcProperty.getPointType();
//请求分配 //请求分配
@ -383,16 +386,20 @@ public class PlcEventTask {
//货物高度 //货物高度
twoHignType = plcProperty.getAddress(); twoHignType = plcProperty.getAddress();
twoHignTypeVT = plcProperty.getValueType(); twoHignTypeVT = plcProperty.getValueType();
} else if (pointType.equals("oneOverlength")) { } else if (pointType.equals("oneBoverlength")) {
oneOverlength =plcProperty.getAddress(); oneBoverlength = plcProperty.getAddress();
} else if (pointType.equals("oneAoverlength")) {
oneAoverlength = plcProperty.getAddress();
} else if (pointType.equals("oneLwide")) { } else if (pointType.equals("oneLwide")) {
oneLwide = plcProperty.getAddress(); oneLwide = plcProperty.getAddress();
} else if (pointType.equals("oneRwide")) { } else if (pointType.equals("oneRwide")) {
oneRwide = plcProperty.getAddress(); oneRwide = plcProperty.getAddress();
} else if (pointType.equals("oneHigh")) { } else if (pointType.equals("oneHigh")) {
oneHigh = plcProperty.getAddress(); oneHigh = plcProperty.getAddress();
} else if (pointType.equals("twoOverlength")) { } else if (pointType.equals("twoBoverlength")) {
twoOverlength =plcProperty.getAddress(); twoBoverlength = plcProperty.getAddress();
} else if (pointType.equals("twoAoverlength")) {
twoAoverlength = plcProperty.getAddress();
} else if (pointType.equals("twoLwide")) { } else if (pointType.equals("twoLwide")) {
twoLwide = plcProperty.getAddress(); twoLwide = plcProperty.getAddress();
} else if (pointType.equals("twoRwide")) { } else if (pointType.equals("twoRwide")) {
@ -401,10 +408,16 @@ public class PlcEventTask {
twoHigh = plcProperty.getAddress(); twoHigh = plcProperty.getAddress();
} else if (pointType.equals("ontExit")) { } else if (pointType.equals("ontExit")) {
oneWcsErrExit = plcProperty.getAddress(); oneWcsErrExit = plcProperty.getAddress();
oneWcsErrExitVT = plcProperty.getValueType(); oneWcsErrExitVt = plcProperty.getValueType();
} else if (pointType.equals("twoExit")) { } else if (pointType.equals("twoExit")) {
twoWcsErrExit = plcProperty.getAddress(); twoWcsErrExit = plcProperty.getAddress();
twoWcsErrExitVT = plcProperty.getValueType(); twoWcsErrExitVt = plcProperty.getValueType();
} else if (pointType.equals("oneExitOut")) {
oneWcsExitOutExit = plcProperty.getAddress();
oneWcsExitOutExitVt= plcProperty.getValueType();
} else if (pointType.equals("twoExitOut")) {
twoWcsExitOutExit = plcProperty.getAddress();
twoWcsExitOutExitVt = plcProperty.getValueType();
} }
} }
@ -425,20 +438,25 @@ public class PlcEventTask {
log.info("1楼请求入库时,读取的条码内容:" + barcodeValueOne); log.info("1楼请求入库时,读取的条码内容:" + barcodeValueOne);
//根据托盘条码返回正在执行的任务号 //根据托盘条码返回正在执行的任务号
Result<PlanOrderLocationVo> orderResult = iBusinOutInPlanService.getOrderNoByContainerCode(barcodeValueOne, "in"); Result<PlanOrderLocationVo> orderResult = iBusinOutInPlanService.getOrderNoByContainerCode(barcodeValueOne, "in");
log.info("1根据条码获取的任务信息:"+orderResult.getData()); log.info("1根据条码获取的任务信息:" + orderResult.getData());
if (Result.isOk(orderResult)) { if (Result.isOk(orderResult)) {
PlanOrderLocationVo data = orderResult.getData(); PlanOrderLocationVo data = orderResult.getData();
taskIdOne = data.getOrderNo(); taskIdOne = data.getOrderNo();
cargoHeight = data.getType();//获取托盘或模具类型 cargoHeight = data.getType();//获取托盘或模具类型
} } else {
else {
redisTemplate.opsForValue().set(RedisConstant.redisPutInExeMsg + orderResult.getMsg(), orderResult.getMsg()); redisTemplate.opsForValue().set(RedisConstant.redisPutInExeMsg + orderResult.getMsg(), orderResult.getMsg());
log.info("获取任务信息失败:"+orderResult.getMsg()+"托盘条码:"+barcodeValueOne); log.info("1楼获取任务信息失败:" + orderResult.getMsg() + "托盘条码:" + barcodeValueOne);
//回填任务号
Map<String, Integer> writeMap = new HashMap<>(1); //出库拣货尚未拣货时写入异常给plc
writeMap.put(oneWcsErrExitVT, 1);
Map<String, Object> allMap = new HashMap<>(1); Map<String, Object> allMap = new HashMap<>(1);
allMap.put(oneWcsErrExit, writeMap); Map<String, Integer> oneWcsErrExitMap = new HashMap<>(1);
oneWcsErrExitMap.put(oneWcsErrExitVt, 1);
allMap.put(oneWcsErrExit, oneWcsErrExitMap);
Map<String, Integer> oneWcsExitOutExitMap = new HashMap<>(1);
oneWcsExitOutExitMap.put(oneWcsExitOutExitVt, 1);
allMap.put(oneWcsExitOutExit, oneWcsExitOutExitMap);
Boolean errBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); Boolean errBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap));
if (errBoolean) { if (errBoolean) {
log.info("1楼获取单号入库失败,写入点位成功{}", allMap); log.info("1楼获取单号入库失败,写入点位成功{}", allMap);
@ -463,7 +481,7 @@ public class PlcEventTask {
allMap.put(oneHignType, cargoHeightMap); allMap.put(oneHignType, cargoHeightMap);
Map<String, Integer> wcsErrwriteMap = new HashMap<>(1); Map<String, Integer> wcsErrwriteMap = new HashMap<>(1);
wcsErrwriteMap.put(oneWcsErrExitVT, 0); wcsErrwriteMap.put(oneWcsErrExitVt, 0);
allMap.put(oneWcsErrExit, wcsErrwriteMap); allMap.put(oneWcsErrExit, wcsErrwriteMap);
log.info("1楼按下入库按钮时,给输送线写命令数据:{}" + allMap); log.info("1楼按下入库按钮时,给输送线写命令数据:{}" + allMap);
@ -500,11 +518,16 @@ public class PlcEventTask {
} else { } else {
redisTemplate.opsForValue().set(RedisConstant.redisPutInExeMsg + orderResult.getMsg(), orderResult.getMsg()); redisTemplate.opsForValue().set(RedisConstant.redisPutInExeMsg + orderResult.getMsg(), orderResult.getMsg());
log.info("2楼获取任务信息失败:" + orderResult.getMsg() + "托盘条码:" + barcodeValueTwo); log.info("2楼获取任务信息失败:" + orderResult.getMsg() + "托盘条码:" + barcodeValueTwo);
//回填任务号
Map<String, Integer> writeMap = new HashMap<>(1);
writeMap.put(twoWcsErrExitVT, 1);
Map<String, Object> allMap = new HashMap<>(1); Map<String, Object> allMap = new HashMap<>(1);
allMap.put(twoWcsErrExit, writeMap); //2楼出库尚未拣货时,写入异常给plc
Map<String, Integer> twoWcsErrExitMap = new HashMap<>(1);
twoWcsErrExitMap.put(twoWcsErrExitVt, 1);
allMap.put(twoWcsErrExit, twoWcsErrExitMap);
Map<String, Integer> twoWcsErrExitOutMap = new HashMap<>(1);
twoWcsErrExitOutMap.put(twoWcsExitOutExitVt, 1);
allMap.put(twoWcsExitOutExit, twoWcsErrExitOutMap);
Boolean errBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); Boolean errBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap));
if (errBoolean) { if (errBoolean) {
log.info("2楼获取单号入库失败,写入点位成功{}", allMap); log.info("2楼获取单号入库失败,写入点位成功{}", allMap);
@ -529,11 +552,10 @@ public class PlcEventTask {
allMap.put(twoHignType, cargoHeightMap); allMap.put(twoHignType, cargoHeightMap);
Map<String, Integer> wcsErrwriteMap = new HashMap<>(1); Map<String, Integer> wcsErrwriteMap = new HashMap<>(1);
wcsErrwriteMap.put(twoWcsErrExitVT, 0); wcsErrwriteMap.put(twoWcsErrExitVt, 0);
allMap.put(twoWcsErrExit, wcsErrwriteMap); allMap.put(twoWcsErrExit, wcsErrwriteMap);
log.info("2楼按下入库按钮时,给输送线写命令数据:{}" + allMap); log.info("2楼按下入库按钮时,给输送线写命令数据:{}" + allMap);
Boolean taskBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); Boolean taskBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap));
if (taskBoolean) { if (taskBoolean) {
//分配任务成功时,记录已下发入库任务,不可在下发出库任务 //分配任务成功时,记录已下发入库任务,不可在下发出库任务
@ -545,9 +567,13 @@ public class PlcEventTask {
redisTemplate.opsForValue().set(RedisConstant.redisContainer, taskIdTwo, 10, TimeUnit.SECONDS); redisTemplate.opsForValue().set(RedisConstant.redisContainer, taskIdTwo, 10, TimeUnit.SECONDS);
} }
} }
//获取1楼入库失败的内容 //获取1楼入库失败的内容 前超长 后超长
if(pointMap.containsKey(oneOverlength)){ if (pointMap.containsKey(oneBoverlength)) {
oneOverlengthV = Boolean.valueOf(pointMap.get(oneOverlength).toString()); oneBoverlengthV = Boolean.valueOf(pointMap.get(oneBoverlength).toString());
}
if (pointMap.containsKey(oneAoverlength)) {
oneAoverlengthV = Boolean.valueOf(pointMap.get(oneAoverlength).toString());
} }
if (pointMap.containsKey(oneLwide)) { if (pointMap.containsKey(oneLwide)) {
oneLwideV = Boolean.valueOf(pointMap.get(oneLwide).toString()); oneLwideV = Boolean.valueOf(pointMap.get(oneLwide).toString());
@ -561,11 +587,14 @@ public class PlcEventTask {
oneHighV = Boolean.valueOf(pointMap.get(oneHigh).toString()); oneHighV = Boolean.valueOf(pointMap.get(oneHigh).toString());
} }
if (oneOverlengthV || oneLwideV || oneRwideV || oneHighV) { if (oneBoverlengthV || oneAoverlengthV || oneLwideV || oneRwideV || oneHighV) {
//读取失败原因 //读取失败原因
String failedReasonValue = ""; String failedReasonValue = "";
if (oneOverlengthV){ if (oneBoverlengthV) {
failedReasonValue="超长"; failedReasonValue = "前超长";
}
if (oneAoverlengthV) {
failedReasonValue = "后超长";
} }
if (oneLwideV) { if (oneLwideV) {
failedReasonValue = "左超宽"; failedReasonValue = "左超宽";
@ -602,9 +631,14 @@ public class PlcEventTask {
//获取2楼入库失败的内容 //获取2楼入库失败的内容
if(pointMap.containsKey(twoOverlength)){ if (pointMap.containsKey(twoBoverlength)) {
twoOverlengthV = Boolean.valueOf(pointMap.get(twoOverlength).toString()); twoBoverlengthV = Boolean.valueOf(pointMap.get(twoBoverlength).toString());
}
if (pointMap.containsKey(twoAoverlength)) {
twoAoverlengthV = Boolean.valueOf(pointMap.get(twoAoverlength).toString());
} }
if (pointMap.containsKey(twoLwide)) { if (pointMap.containsKey(twoLwide)) {
twoLwideV = Boolean.valueOf(pointMap.get(twoLwide).toString()); twoLwideV = Boolean.valueOf(pointMap.get(twoLwide).toString());
} }
@ -617,12 +651,17 @@ public class PlcEventTask {
twoHighV = Boolean.valueOf(pointMap.get(twoHigh).toString()); twoHighV = Boolean.valueOf(pointMap.get(twoHigh).toString());
} }
if (twoOverlengthV || twoLwideV || twoRwideV || twoHighV) { if (twoBoverlengthV || twoAoverlengthV || twoLwideV || twoRwideV || twoHighV) {
//读取失败原因 //读取失败原因
String failedReasonValue = ""; String failedReasonValue = "";
if (twoOverlengthV){ if (twoBoverlengthV) {
failedReasonValue="超长"; failedReasonValue = "前超长";
}
if (twoAoverlengthV) {
failedReasonValue = "后超长";
} }
if (twoLwideV) { if (twoLwideV) {
failedReasonValue = "左超宽"; failedReasonValue = "左超宽";
} }
@ -689,6 +728,7 @@ public class PlcEventTask {
/** /**
* 堆垛机的完成状态处理 * 堆垛机的完成状态处理
*
* @param propertyList * @param propertyList
* @param pointMap * @param pointMap
* @param plcReadAndWrite * @param plcReadAndWrite
@ -777,6 +817,7 @@ public class PlcEventTask {
/** /**
* 输送线请求入库 * 输送线请求入库
*
* @param taskId * @param taskId
* @return * @return
*/ */
@ -861,8 +902,7 @@ public class PlcEventTask {
} else if (stkProperty.getPointType().equals("4")) { } else if (stkProperty.getPointType().equals("4")) {
readfinish = stkProperty.getAddress(); readfinish = stkProperty.getAddress();
readfinishValueType = stkProperty.getValueType(); readfinishValueType = stkProperty.getValueType();
} } else if (stkProperty.getPointType().equals("10")) {
else if (stkProperty.getPointType().equals("10")) {
//等于1时堆垛机自动,等于0时堆垛机手动 //等于1时堆垛机自动,等于0时堆垛机手动
stkAutoManual = stkProperty.getAddress(); stkAutoManual = stkProperty.getAddress();
} else if (stkProperty.getPointType().equals("11")) { } else if (stkProperty.getPointType().equals("11")) {

Loading…
Cancel
Save