diff --git a/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java b/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java index 1c3e812..37c9ea3 100644 --- a/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java +++ b/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java @@ -118,14 +118,14 @@ public class PlcEventTask { } - + //输送线心跳 @Scheduled(fixedDelay = 4000) - public void writePlcheartbeat(){ + public void writePlcheartbeatDps(){ //根据连接的plcId获取属性 PlcOperate plcOperate = plcInit.getPlcOperate_dps(); PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); Map readPointMap = new HashMap<>(); - String heartbeat="DB320.0.1"; + String heartbeat="DB320.0.0"; readPointMap.put(heartbeat,"Boolean"); Map pointMap = plcReadAndWrite.readPlcData(plcOperate, JsonUtil.toJSONString(readPointMap)); @@ -142,11 +142,38 @@ public class PlcEventTask { allHbMap.put(heartbeat, writeHbMap); Boolean heartType = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allHbMap)); if(!heartType){ - log.info("心跳写入失败,重连服务器"); + log.info("dps心跳写入失败,重连服务器"); plcInit.connect(); } } + //堆垛机心跳 + @Scheduled(fixedDelay = 4000) + public void writePlcheartbeatStk(){ + //根据连接的plcId获取属性 + PlcOperate plcOperate = plcInit.getPlcOperate_stk(); + PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); + Map readPointMap = new HashMap<>(); + String heartbeat="DB20.0.4"; + readPointMap.put(heartbeat,"Boolean"); + Map pointMap = plcReadAndWrite.readPlcData(plcOperate, JsonUtil.toJSONString(readPointMap)); + //读取心跳,并判断是写入true还是false; + Boolean heartbeatV = false; + + if (pointMap.containsKey(heartbeat)) { + heartbeatV = Boolean.valueOf(pointMap.get(heartbeat).toString()); + } + heartbeatV = (heartbeatV == true) ? false : true; + Map writeHbMap = new HashMap<>(1); + writeHbMap.put("Boolean", heartbeatV); + Map allHbMap = new HashMap<>(1); + allHbMap.put(heartbeat, writeHbMap); + Boolean heartType = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allHbMap)); + if(!heartType){ + log.info("stk心跳写入失败,重连服务器"); + plcInit.connect(); + } + } public void plcTask(PlcOperate plcOperate, WcsPlcConnectVo conn, String pointTables) { @@ -330,7 +357,7 @@ public class PlcEventTask { Boolean twoOverlengthV=false,twoLwideV=false,twoRwideV=false,twoHighV=false; String oneWcsErrExit ="",twoWcsErrExit =""; - String oneEcsErrExitVT ="",twoWcsErrExitVT =""; + String oneWcsErrExitVT="",twoWcsErrExitVT =""; for (WcsPlcProperty plcProperty : propertyList) { String pointType = plcProperty.getPointType(); //请求分配 @@ -384,7 +411,7 @@ public class PlcEventTask { twoHigh =plcProperty.getAddress(); } else if (pointType.equals("ontExit")){ oneWcsErrExit =plcProperty.getAddress(); - oneEcsErrExitVT = plcProperty.getValueType(); + oneWcsErrExitVT = plcProperty.getValueType(); } else if (pointType.equals("twoExit")){ twoWcsErrExit =plcProperty.getAddress(); twoWcsErrExitVT = plcProperty.getValueType(); @@ -411,12 +438,13 @@ public class PlcEventTask { PlanOrderLocationVo data = orderResult.getData(); taskId = data.getOrderNo(); cargoHeight = data.getType();//获取托盘或模具类型 - }else { + } + else { redisTemplate.opsForValue().set(RedisConstant.redisPutInExeMsg+orderResult.getMsg(),orderResult.getMsg()); log.info("获取任务信息失败:"+orderResult.getMsg()+"托盘条码:"+barcodeValue); //回填任务号 - Map writeMap = new HashMap<>(1); - writeMap.put(oneEcsErrExitVT, true); + Map writeMap = new HashMap<>(1); + writeMap.put(oneWcsErrExitVT, 1); Map allMap = new HashMap<>(1); allMap.put(oneWcsErrExit, writeMap); Boolean errBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); @@ -441,6 +469,10 @@ public class PlcEventTask { Map cargoHeightMap = new HashMap<>(1); cargoHeightMap.put(oneHignTypeVT, cargoHeight); allMap.put(oneHignType, cargoHeightMap); + + Map wcsErrwriteMap = new HashMap<>(1); + wcsErrwriteMap.put(oneWcsErrExitVT, 0); + allMap.put(oneWcsErrExit,wcsErrwriteMap); log.info("1楼按下入库按钮时,给输送线写命令数据:{}"+allMap); Boolean taskBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); @@ -476,8 +508,8 @@ public class PlcEventTask { redisTemplate.opsForValue().set(RedisConstant.redisPutInExeMsg+orderResult.getMsg(),orderResult.getMsg()); log.info("2楼获取任务信息失败:"+orderResult.getMsg()+"托盘条码:"+barcodeValue); //回填任务号 - Map writeMap = new HashMap<>(1); - writeMap.put(twoWcsErrExitVT, true); + Map writeMap = new HashMap<>(1); + writeMap.put(twoWcsErrExitVT, 1); Map allMap = new HashMap<>(1); allMap.put(twoWcsErrExit, writeMap); Boolean errBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); @@ -502,6 +534,10 @@ public class PlcEventTask { Map cargoHeightMap = new HashMap<>(1); cargoHeightMap.put(twoHignTypeVT, cargoHeight); allMap.put(twoHignType, cargoHeightMap); + + Map wcsErrwriteMap = new HashMap<>(1); + wcsErrwriteMap.put(twoWcsErrExitVT, 0); + allMap.put(twoWcsErrExit,wcsErrwriteMap); log.info("2楼按下入库按钮时,给输送线写命令数据:{}"+allMap); @@ -670,10 +706,9 @@ public class PlcEventTask { public void stkRealTimeTask(List propertyList,Map pointMap, PLCReadAndWrite plcReadAndWrite,PlcOperate plcOperate,String pointTables){ try { if (pointMap.isEmpty()){ + plcInit.connect(); pointMap = plcReadAndWrite.readPlcData(plcOperate, pointTables); log.info("堆垛机为空时,重新读取的属性值{} ",pointMap); - }else { - plcInit.connect(); } //实时监测堆垛机完成状态,调用库存处理逻辑 Long taskId=0L; @@ -828,6 +863,9 @@ public class PlcEventTask { } else if (stkProperty.getPointType().equals("102")) { plcOrderType = stkProperty.getAddress(); plcOrderTypeValue=stkProperty.getValueType(); + }else if (stkProperty.getPointType().equals("103")) { + plcPlatform =stkProperty.getAddress(); + plcPlatformValueType=stkProperty.getValueType(); }else if (stkProperty.getPointType().equals("4")) { readfinish = stkProperty.getAddress(); readfinishValueType=stkProperty.getValueType(); diff --git a/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcInit.java b/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcInit.java index add7c18..d2e5ae2 100644 --- a/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcInit.java +++ b/shkj-wms/src/main/java/com/shkj/wcs/plc/PlcInit.java @@ -36,7 +36,7 @@ public class PlcInit { public void init(){ log.info("初始化连接对象"); executorService.scheduleWithFixedDelay( - () -> reconnect(), 20, 20, TimeUnit.SECONDS + () -> reconnect(), 200, 200, TimeUnit.SECONDS ); connect(); } @@ -73,10 +73,10 @@ public class PlcInit { } private void reconnect(){ if (!plcOperate_dps.isConnectd()){ - connect(); + // connect(); } if (!plcOperate_stk.isConnectd()){ - connect(); + // connect(); } } diff --git a/shkj-wms/src/main/java/com/shkj/wcs/third/stacker/StkCallUtil.java b/shkj-wms/src/main/java/com/shkj/wcs/third/stacker/StkCallUtil.java index 337c81f..4f1d33a 100644 --- a/shkj-wms/src/main/java/com/shkj/wcs/third/stacker/StkCallUtil.java +++ b/shkj-wms/src/main/java/com/shkj/wcs/third/stacker/StkCallUtil.java @@ -301,7 +301,7 @@ public class StkCallUtil { redisTemplate.opsForValue().set(RedisConstant.redisTaskOut, taskId); return Result.ok(); } else { - log.info("堆垛机下发命令失败:"+one.getTaskId()); + log.info(one.getTaskId()+"堆垛机下发命令失败"); return Result.err(); } } diff --git a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseMoldServiceImpl.java b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseMoldServiceImpl.java index 957a62f..3b1a713 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseMoldServiceImpl.java +++ b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseMoldServiceImpl.java @@ -319,7 +319,6 @@ public class BaseMoldServiceImpl extends ServiceImpl i baseMoldVo.setIsOut("out"); } } - } } return Result.ok().data(moldVoList); diff --git a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinOutInPlanServiceImpl.java b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinOutInPlanServiceImpl.java index 4f56fec..a9378c9 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinOutInPlanServiceImpl.java +++ b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinOutInPlanServiceImpl.java @@ -971,7 +971,8 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl eq = new LambdaQueryWrapper() .eq(BusinOutInPlan::getContainerCode, containerCode) - .eq(BusinOutInPlan::getPlanStatus, PlanStatusEnum.WAIT.getValue()) + .in(BusinOutInPlan::getPlanStatus,PlanStatusEnum.WAIT.getValue(),PlanStatusEnum.DOING.getValue()) + //.eq(BusinOutInPlan::getPlanStatus, PlanStatusEnum.WAIT.getValue()) .in(BusinOutInPlan::getType,PlanTypeEnum.IN.getValue(),PlanTypeEnum.BACK.getValue(),PlanTypeEnum.INV_BACK.getValue(),PlanTypeEnum.EMPTY_IN.getValue()) .orderByDesc(BusinOutInPlan::getCreateTime) // .eq(BusinOutInPlan::getType, planType) @@ -1004,13 +1005,11 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl x.getQty()).reduce(BigDecimal.ZERO, BigDecimal::add); vo.setType(qty.compareTo(BigDecimal.ZERO) == 0 ? LocationPlanTypeEnum.EMPTY.getValue() : location.getType()); } vo.setOrderNo(one.getOrderNo()); - return Result.ok().data(vo); }