|
|
|
|
@ -78,7 +78,7 @@ public class PlcEventTask { |
|
|
|
|
@Autowired |
|
|
|
|
PlcInit plcInit; |
|
|
|
|
|
|
|
|
|
@Scheduled(fixedDelay = 4000) |
|
|
|
|
@Scheduled(fixedDelay = 5000) |
|
|
|
|
public void init() { |
|
|
|
|
//查询需要连接的PLC,初始化连接对象
|
|
|
|
|
List<WcsPlcConnectVo> plcList =(List<WcsPlcConnectVo>) redisTemplate.opsForValue().get(RedisConstant.redisPlcListConnect); |
|
|
|
|
@ -407,12 +407,18 @@ public class PlcEventTask { |
|
|
|
|
Long taskIdOne = 0L; |
|
|
|
|
//1楼是否请求分配
|
|
|
|
|
if (pointMap.containsKey(oneAllotAddress) && Boolean.valueOf(pointMap.get(oneAllotAddress).toString())) { |
|
|
|
|
//请求入库分配时,判断是否有正在执行的出库任务,如果有则返回
|
|
|
|
|
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); |
|
|
|
|
if (taskOutId != null) { |
|
|
|
|
log.info("1楼入库分配请求时,有出库任务,不可分配,返回"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// //请求入库分配时,判断是否有正在执行的出库任务,如果有则返回
|
|
|
|
|
// Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne);
|
|
|
|
|
// if (oneTaskOutId != null) {
|
|
|
|
|
// log.info("1楼入库分配请求时,1楼有出库任务,不可分配:"+oneTaskOutId);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo);
|
|
|
|
|
// if (twoTaskOutId != null) {
|
|
|
|
|
// log.info("1楼入库分配请求时,2楼有出库任务,不可分配:"+twoTaskOutId);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//读取托盘条码内容
|
|
|
|
|
String barcodeValueOne = pointMap.get(onePalletAddress).toString(); |
|
|
|
|
@ -467,9 +473,10 @@ public class PlcEventTask { |
|
|
|
|
log.info("1楼按下入库按钮时,给输送线写命令数据:{}" + allMap); |
|
|
|
|
|
|
|
|
|
Boolean taskBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); |
|
|
|
|
log.info("1楼按下入库按钮时,写入的命令返回结果:"+taskBoolean.toString()); |
|
|
|
|
if (taskBoolean) { |
|
|
|
|
//分配任务成功时,记录已下发入库任务,不可在下发出库或入库任务
|
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisTaskIn, taskIdOne); |
|
|
|
|
log.info("分配成功后写入redis的数据:"+taskIdOne); |
|
|
|
|
//更改入库计划为1
|
|
|
|
|
iBusinOutInPlanService.updPlanStatus(taskIdOne, PlanStatusEnum.DOING.getValue()); |
|
|
|
|
} |
|
|
|
|
@ -481,11 +488,17 @@ public class PlcEventTask { |
|
|
|
|
if (pointMap.containsKey(twoAllotAddress) && Boolean.valueOf(pointMap.get(twoAllotAddress).toString())) { |
|
|
|
|
Long taskIdTwo = 0L; |
|
|
|
|
//请求入库分配时,判断是否有正在执行的出库任务,如果有则返回
|
|
|
|
|
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); |
|
|
|
|
if (taskOutId != null) { |
|
|
|
|
log.info("2楼入库分配请求时,有出库任务,不可分配,返回"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne);
|
|
|
|
|
// if (oneTaskOutId != null) {
|
|
|
|
|
// log.info("2F入库分配请求时,1F有出库任务,不可分配,返回");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo);
|
|
|
|
|
// if (twoTaskOutId != null) {
|
|
|
|
|
// log.info("2F入库分配请求时,2F有出库任务,不可分配,返回");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//读取托盘条码内容
|
|
|
|
|
String barcodeValueTwo = pointMap.get(twoPalletAddress).toString(); |
|
|
|
|
log.info("1楼请求入库时,读取的条码内容:" + barcodeValueTwo); |
|
|
|
|
@ -540,7 +553,7 @@ public class PlcEventTask { |
|
|
|
|
Boolean taskBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); |
|
|
|
|
if (taskBoolean) { |
|
|
|
|
//分配任务成功时,记录已下发入库任务,不可在下发出库任务
|
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisTaskIn, taskIdTwo); |
|
|
|
|
//redisTemplate.opsForValue().set(RedisConstant.redisTaskIn, taskIdTwo);
|
|
|
|
|
//更改入库计划为1
|
|
|
|
|
iBusinOutInPlanService.updPlanStatus(taskIdTwo, PlanStatusEnum.DOING.getValue()); |
|
|
|
|
} |
|
|
|
|
@ -769,18 +782,22 @@ public class PlcEventTask { |
|
|
|
|
if (plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap))) { |
|
|
|
|
//堆垛机完成状态后,把redis中的ID删除,代表此任务已经完成
|
|
|
|
|
Object taskInId = redisTemplate.opsForValue().get(RedisConstant.redisTaskIn); |
|
|
|
|
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); |
|
|
|
|
if (taskInId != null && String.valueOf(taskInId).equals(taskId.toString())) { |
|
|
|
|
log.info("入库完成时,删除redis中的入库任务状态记录:"); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisTaskIn); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (taskOutId != null && String.valueOf(taskOutId).equals(taskId.toString())) { |
|
|
|
|
Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne); |
|
|
|
|
if (oneTaskOutId != null && String.valueOf(oneTaskOutId).equals(taskId.toString())) { |
|
|
|
|
log.info("出库完成时,删除redis中的出库任务状态记录"); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisTaskOut); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisTaskOutOne); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (taskInId != null && String.valueOf(taskInId).equals(taskId.toString())) { |
|
|
|
|
log.info("入库完成时,删除redis中的入库任务状态记录"); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisTaskIn); |
|
|
|
|
Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo); |
|
|
|
|
if (twoTaskOutId != null && String.valueOf(twoTaskOutId).equals(taskId.toString())) { |
|
|
|
|
log.info("出库完成时,删除redis中的出库任务状态记录"); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisTaskOutTwo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("给堆垛机下发完成信号为0,成功:" + taskId); |
|
|
|
|
//请求成功,记录已下发
|
|
|
|
|
redisTemplate.delete(RedisConstant.redisReqWare + taskId); |
|
|
|
|
@ -811,9 +828,15 @@ public class PlcEventTask { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); |
|
|
|
|
if (taskOutId != null) { |
|
|
|
|
log.info("有出库任务在执行,无法下发入库任务:" + taskOutId); |
|
|
|
|
Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne); |
|
|
|
|
if (oneTaskOutId != null) { |
|
|
|
|
log.info("1F有出库任务在执行,无法下发入库任务:" + oneTaskOutId); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo); |
|
|
|
|
if (twoTaskOutId != null) { |
|
|
|
|
log.info("2F有出库任务在执行,无法下发入库任务:" + twoTaskOutId); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -972,6 +995,7 @@ public class PlcEventTask { |
|
|
|
|
log.info(taskId + "请求入库:任务下发之前" + JsonUtil.toJSONString(allMap)); |
|
|
|
|
if (plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap))) { |
|
|
|
|
log.info(taskId + "请求入库,任务下发成功:"); |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisTaskIn, taskId); |
|
|
|
|
//请求成功,记录已下发
|
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisReqWare + taskId, taskId, 24, TimeUnit.HOURS); |
|
|
|
|
//请求分配任务ID dps
|
|
|
|
|
|