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

Loading…
Cancel
Save