|
|
|
|
@ -67,17 +67,6 @@ public class StkCallUtil { |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public Result<Boolean> outTask(STKMoveBo stkMoveBo) throws InterruptedException { |
|
|
|
|
|
|
|
|
|
/*//判断是否有出库任务没有执行,如果有先不下发
|
|
|
|
|
Date nowDate = DateUtils.getNowDate(); |
|
|
|
|
LambdaQueryWrapper<SysThirdExceptionRequest> wrapper = new LambdaQueryWrapper<SysThirdExceptionRequest>() |
|
|
|
|
.eq(SysThirdExceptionRequest::getStatus, ThirdApiStatusEnum.fail.getValue()) |
|
|
|
|
.ne(SysThirdExceptionRequest::getCode,stkMoveBo.getTaskId()) |
|
|
|
|
.and(wq->wq.lt(SysThirdExceptionRequest::getPlanTime, nowDate) |
|
|
|
|
.or().isNull(SysThirdExceptionRequest::getPlanTime)) |
|
|
|
|
.orderByAsc(SysThirdExceptionRequest::getCreateTime) |
|
|
|
|
.last("limit 1 "); |
|
|
|
|
SysThirdExceptionRequest one = sysThirdExceptionRequestService.getOne(wrapper);*/ |
|
|
|
|
//下发任务时,先查询是否有正在执行的入库任务,如果有,则不下发出库任务
|
|
|
|
|
Object taskInId = redisTemplate.opsForValue().get(RedisConstant.redisTaskIn); |
|
|
|
|
if (taskInId !=null ){ |
|
|
|
|
@ -127,24 +116,49 @@ public class StkCallUtil { |
|
|
|
|
Map<String, Object> dpsPointMap = plcReadAndWrite.readPlcData(dpsOperate, dpsPointTables); |
|
|
|
|
|
|
|
|
|
List<WcsPlcProperty> dpsPropertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(dpsPlcId); |
|
|
|
|
String dpsidle=""; |
|
|
|
|
String dpsidleV=""; |
|
|
|
|
String oneDpsidle=""; |
|
|
|
|
String twoDpsidle=""; |
|
|
|
|
String oneDpsidleV=""; |
|
|
|
|
String twoDpsidleV=""; |
|
|
|
|
for (WcsPlcProperty dpsProperty : dpsPropertyList) { |
|
|
|
|
//是否允许出库
|
|
|
|
|
if (dpsProperty.getPointType().equals("100")) { |
|
|
|
|
dpsidle = dpsProperty.getAddress(); |
|
|
|
|
//1楼是否允许出库
|
|
|
|
|
if (dpsProperty.getPointType().equals("oneOut")) { |
|
|
|
|
oneDpsidle = dpsProperty.getAddress(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//2楼是否允许出库
|
|
|
|
|
if (dpsProperty.getPointType().equals("twoOut")) { |
|
|
|
|
twoDpsidle = dpsProperty.getAddress(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dpsPointMap.containsKey(dpsidle)){ |
|
|
|
|
dpsidleV = dpsPointMap.get(dpsidle).toString(); |
|
|
|
|
if (dpsPointMap.containsKey(oneDpsidle)){ |
|
|
|
|
oneDpsidleV = dpsPointMap.get(oneDpsidle).toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dpsPointMap.containsKey(twoDpsidle)){ |
|
|
|
|
twoDpsidleV = dpsPointMap.get(twoDpsidle).toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("是否允许出库状态点位:"+dpsidle); |
|
|
|
|
log.info("是否允许出库状态值:"+dpsidleV); |
|
|
|
|
log.info("1楼是否允许出库::"+oneDpsidle+" 出库的值:"+oneDpsidleV); |
|
|
|
|
log.info("2楼是否允许出库::"+twoDpsidle+" 出库的值:"+twoDpsidleV); |
|
|
|
|
Integer layer = one.getLayer(); |
|
|
|
|
if (layer==1){ |
|
|
|
|
//false不允许出库
|
|
|
|
|
if (!Boolean.valueOf(dpsidleV)){ |
|
|
|
|
return Result.err().msg("输送线繁忙,不允许出库"); |
|
|
|
|
if (!Boolean.valueOf(oneDpsidleV)){ |
|
|
|
|
String msg ="出库楼层是1楼,输送线繁忙,不允许出库"; |
|
|
|
|
log.info(msg); |
|
|
|
|
return Result.err().msg(msg); |
|
|
|
|
} |
|
|
|
|
}else if(layer == 2){ |
|
|
|
|
if (!Boolean.valueOf(twoDpsidleV)){ |
|
|
|
|
String msg ="出库楼层是2楼,输送线繁忙,不允许出库"; |
|
|
|
|
log.info(msg); |
|
|
|
|
return Result.err().msg(msg); |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
log.info("未匹配到楼层"); |
|
|
|
|
return Result.err().msg("未匹配到楼层,不允许出库"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String plcTaskId = "",taskIdvalueType = "",plcToRow = "",toRowValueType = "",plcToColumn = "",toColumnValueType = "",plcToLayer = "",toLayerValueType = ""; |
|
|
|
|
@ -215,51 +229,48 @@ public class StkCallUtil { |
|
|
|
|
|
|
|
|
|
Thread.sleep(2000); |
|
|
|
|
|
|
|
|
|
Boolean stkAutoManualV= false; |
|
|
|
|
Integer stkRunV = 0; |
|
|
|
|
if (stkPointMap.containsKey(stkRun)) { |
|
|
|
|
stkRunV = Integer.valueOf(stkPointMap.get(stkRun).toString()); |
|
|
|
|
} |
|
|
|
|
log.info("堆垛机运行状态:"+stkRunV); |
|
|
|
|
if (stkRunV!=1){ |
|
|
|
|
return Result.err().msg("堆垛机尚未运行"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer stkAutoManualV=0; |
|
|
|
|
if (stkPointMap.containsKey(stkAutoManual)) { |
|
|
|
|
stkAutoManualV = Boolean.valueOf(stkPointMap.get(stkAutoManual).toString()); |
|
|
|
|
stkAutoManualV = Integer.valueOf(stkPointMap.get(stkAutoManual).toString()); |
|
|
|
|
} |
|
|
|
|
log.info("堆垛机自动状态:"+stkAutoManualV); |
|
|
|
|
if(stkAutoManualV ==0 ){ |
|
|
|
|
return Result.err().msg("堆垛机手动状态"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Boolean stkGroundV= false; |
|
|
|
|
Integer stkGroundV= 0; |
|
|
|
|
if (stkPointMap.containsKey(stkGround)) { |
|
|
|
|
stkGroundV = Boolean.valueOf(stkPointMap.get(stkGround).toString()); |
|
|
|
|
stkGroundV = Integer.valueOf(stkPointMap.get(stkGround).toString()); |
|
|
|
|
} |
|
|
|
|
log.info("地面柜自动状态:"+stkGroundV); |
|
|
|
|
|
|
|
|
|
Boolean stkidleV = false; |
|
|
|
|
if (stkPointMap.containsKey(stkidle)) { |
|
|
|
|
stkidleV = Boolean.valueOf(stkPointMap.get(stkidle).toString()); |
|
|
|
|
} |
|
|
|
|
log.info("堆垛机是状态:"+stkidleV.toString()); |
|
|
|
|
|
|
|
|
|
Boolean stkRunV = false; |
|
|
|
|
if (stkPointMap.containsKey(stkRun)) { |
|
|
|
|
stkRunV = Boolean.valueOf(stkPointMap.get(stkRun).toString()); |
|
|
|
|
} |
|
|
|
|
log.info("堆垛机运行状态:"+stkRunV); |
|
|
|
|
/* //等于0
|
|
|
|
|
if (!stkRunV){ |
|
|
|
|
return Result.err().msg("堆垛机正在运行中"); |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
if(!stkGroundV){ |
|
|
|
|
if(stkGroundV==0){ |
|
|
|
|
return Result.err().msg("堆垛机地面柜手动状态"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!stkAutoManualV){ |
|
|
|
|
return Result.err().msg("堆垛机手动状态"); |
|
|
|
|
Integer stkidleV = 0; |
|
|
|
|
if (stkPointMap.containsKey(stkidle)) { |
|
|
|
|
stkidleV = Integer.valueOf(stkPointMap.get(stkidle).toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//等于0繁忙 false代表繁忙
|
|
|
|
|
if(!stkidleV){ |
|
|
|
|
log.info("堆垛机是状态:"+stkidleV); |
|
|
|
|
//1空闲 0繁忙
|
|
|
|
|
if(stkidleV==0){ |
|
|
|
|
return Result.err().msg("堆垛机繁忙"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!Boolean.valueOf(dpsidleV) && !stkidleV){ |
|
|
|
|
if((!Boolean.valueOf(oneDpsidleV) || !Boolean.valueOf(twoDpsidleV)) && stkidleV == 0){ |
|
|
|
|
return Result.err().msg("出库状态与堆垛机的状态都不可出库"); |
|
|
|
|
}else{ |
|
|
|
|
log.info("出库状态与堆垛机的状态可出库:"+Boolean.valueOf(dpsidleV)+"--"+stkidleV); |
|
|
|
|
log.info("出库状态与堆垛机的状态可出库one: "+Boolean.valueOf(oneDpsidleV)+" two:"+twoDpsidleV+" --"+stkidleV); |
|
|
|
|
} |
|
|
|
|
//给堆垛机写命令
|
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
@ -302,9 +313,9 @@ public class StkCallUtil { |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisTaskOut,stkMoveBo.getTaskId()); |
|
|
|
|
return Result.ok(); |
|
|
|
|
} else { |
|
|
|
|
log.info("堆垛机下发命令失败:"+one.getTaskId()); |
|
|
|
|
return Result.err(); |
|
|
|
|
} |
|
|
|
|
// return plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap)) ? Result.ok() : Result.err();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|