|
|
|
|
@ -97,7 +97,7 @@ public class PlcEventTask { |
|
|
|
|
@Autowired |
|
|
|
|
PlcInit plcInit; |
|
|
|
|
|
|
|
|
|
// @Scheduled(fixedDelay = 8000)
|
|
|
|
|
@Scheduled(fixedDelay = 8000) |
|
|
|
|
public void init() { |
|
|
|
|
//查询需要连接的PLC,初始化连接对象
|
|
|
|
|
List<WcsPlcConnectVo> plcList = iWcsPlcConnectService.selectWcsPlcConnectList(new WcsPlcConnect().setIsActive("1")); |
|
|
|
|
@ -107,11 +107,11 @@ public class PlcEventTask { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (WcsPlcConnectVo conn : plcList) { |
|
|
|
|
if (conn.getPlcIp().contains("150.154")){ |
|
|
|
|
if (conn.getPlcIp().contains("1.20")){ |
|
|
|
|
plcTask(plcInit.getPlcOperate_stk(), conn, conn.getPointTables()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (conn.getPlcIp().contains("150.150")){ |
|
|
|
|
if (conn.getPlcIp().contains("1.10")){ |
|
|
|
|
plcTask(plcInit.getPlcOperate_dps(), conn, conn.getPointTables()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -119,7 +119,7 @@ public class PlcEventTask { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Scheduled(fixedDelay = 4000)
|
|
|
|
|
@Scheduled(fixedDelay = 4000) |
|
|
|
|
public void writePlcheartbeat(){ |
|
|
|
|
//根据连接的plcId获取属性
|
|
|
|
|
PlcOperate plcOperate = plcInit.getPlcOperate_dps(); |
|
|
|
|
@ -350,7 +350,7 @@ public class PlcEventTask { |
|
|
|
|
twoAllotAddress = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("oneAllotTask")) { |
|
|
|
|
oneAllotTaskId = plcProperty.getAddress(); |
|
|
|
|
oneAllotTaskId = plcProperty.getValueType(); |
|
|
|
|
oneAllotTaskIdVt = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("twoAllotTask")) { |
|
|
|
|
twoAllotTaskId = plcProperty.getAddress(); |
|
|
|
|
twoAllotTaskIdVt = plcProperty.getValueType(); |
|
|
|
|
@ -423,7 +423,7 @@ public class PlcEventTask { |
|
|
|
|
cargoHeight = data.getType();//获取托盘或模具类型
|
|
|
|
|
}else { |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisPutInExeMsg+orderResult.getMsg(),orderResult.getMsg()); |
|
|
|
|
log.error("获取任务信息失败:"+orderResult.getMsg()+"托盘条码:"+barcodeValue); |
|
|
|
|
log.info("获取任务信息失败:"+orderResult.getMsg()+"托盘条码:"+barcodeValue); |
|
|
|
|
//回填任务号
|
|
|
|
|
Map<String, Boolean> writeMap = new HashMap<>(1); |
|
|
|
|
writeMap.put(oneEcsErrExitVT, true); |
|
|
|
|
@ -508,7 +508,7 @@ public class PlcEventTask { |
|
|
|
|
Map<String, Long> writeMap = new HashMap<>(1); |
|
|
|
|
writeMap.put(twoAllotTaskIdVt, taskId); |
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
allMap.put(oneAllotTaskId, writeMap); |
|
|
|
|
allMap.put(twoAllotTaskId, writeMap); |
|
|
|
|
|
|
|
|
|
Map<String, String> cargoHeightMap = new HashMap<>(1); |
|
|
|
|
cargoHeightMap.put(twoHignTypeVT, cargoHeight); |
|
|
|
|
@ -649,7 +649,7 @@ public class PlcEventTask { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//执行dps任务,给堆垛机下发命令
|
|
|
|
|
dpsTask(taskId) ; |
|
|
|
|
dpsTask(taskId,1) ; |
|
|
|
|
} |
|
|
|
|
//2楼是否请求入库
|
|
|
|
|
if (pointMap.containsKey(twoReqPutin) && Boolean.valueOf(pointMap.get(twoReqPutin).toString())) { |
|
|
|
|
@ -661,7 +661,7 @@ public class PlcEventTask { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//执行dps任务,给堆垛机下发命令
|
|
|
|
|
dpsTask(taskId) ; |
|
|
|
|
dpsTask(taskId,2) ; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
@ -694,7 +694,7 @@ public class PlcEventTask { |
|
|
|
|
for (WcsPlcProperty wcsPlcProperty : propertyList) { |
|
|
|
|
if (wcsPlcProperty.getPointType().equals("4")) { |
|
|
|
|
readfinishPoint = wcsPlcProperty.getAddress(); |
|
|
|
|
} else if (wcsPlcProperty.getPointType().equals("101")) { |
|
|
|
|
} else if (wcsPlcProperty.getPointType().equals("111")) { |
|
|
|
|
readTaskPoint = wcsPlcProperty.getAddress(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -764,7 +764,7 @@ public class PlcEventTask { |
|
|
|
|
* @param taskId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public Boolean dpsTask(Long taskId){ |
|
|
|
|
public Boolean dpsTask(Long taskId,Integer reqLayer){ |
|
|
|
|
|
|
|
|
|
//下发任务时,先查询是否有正在执行的入库任务或出库任务,如果有,则不下发入库任务
|
|
|
|
|
Object taskInId = redisTemplate.opsForValue().get(RedisConstant.redisTaskIn); |
|
|
|
|
@ -773,6 +773,8 @@ public class PlcEventTask { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); |
|
|
|
|
if (taskOutId !=null ){ |
|
|
|
|
log.info("有出库任务在执行,无法下发入库任务:"+taskOutId); |
|
|
|
|
@ -808,16 +810,17 @@ public class PlcEventTask { |
|
|
|
|
String toLayerValueType=""; |
|
|
|
|
|
|
|
|
|
String plcFromRow = ""; |
|
|
|
|
String FromRowValueType=""; |
|
|
|
|
String fromRowValueType=""; |
|
|
|
|
String plcFromColumn = ""; |
|
|
|
|
String FromColumnValueType = ""; |
|
|
|
|
String fromColumnValueType = ""; |
|
|
|
|
String plcFromLayer = ""; |
|
|
|
|
String FromLayerValueType=""; |
|
|
|
|
String fromLayerValueType=""; |
|
|
|
|
|
|
|
|
|
String plcPlatform=""; |
|
|
|
|
String plcPlatformValueType=""; |
|
|
|
|
|
|
|
|
|
String plcOrderType = ""; |
|
|
|
|
String plcOrderTypeValue = ""; |
|
|
|
|
//启动设备
|
|
|
|
|
String plcStartEq = ""; |
|
|
|
|
String plcStartEqValueType = ""; |
|
|
|
|
|
|
|
|
|
//堆垛机完成状态
|
|
|
|
|
String readfinish =""; |
|
|
|
|
@ -835,13 +838,16 @@ public class PlcEventTask { |
|
|
|
|
taskIdvalueType = stkProperty.getValueType(); |
|
|
|
|
} else if (stkProperty.getPointType().equals("104")) { |
|
|
|
|
plcFromRow = stkProperty.getAddress(); |
|
|
|
|
FromRowValueType = stkProperty.getValueType(); |
|
|
|
|
fromRowValueType = stkProperty.getValueType(); |
|
|
|
|
} else if (stkProperty.getPointType().equals("103")) { |
|
|
|
|
plcPlatform = stkProperty.getAddress(); |
|
|
|
|
plcPlatformValueType = stkProperty.getValueType(); |
|
|
|
|
} else if (stkProperty.getPointType().equals("105")) { |
|
|
|
|
plcFromColumn = stkProperty.getAddress(); |
|
|
|
|
FromColumnValueType=stkProperty.getValueType(); |
|
|
|
|
fromColumnValueType=stkProperty.getValueType(); |
|
|
|
|
} else if (stkProperty.getPointType().equals("106")) { |
|
|
|
|
plcFromLayer = stkProperty.getAddress(); |
|
|
|
|
FromLayerValueType=stkProperty.getValueType(); |
|
|
|
|
fromLayerValueType=stkProperty.getValueType(); |
|
|
|
|
} else if (stkProperty.getPointType().equals("108")) { |
|
|
|
|
plcToRow = stkProperty.getAddress(); |
|
|
|
|
toRowValueType = stkProperty.getValueType(); |
|
|
|
|
@ -854,9 +860,6 @@ public class PlcEventTask { |
|
|
|
|
} else if (stkProperty.getPointType().equals("102")) { |
|
|
|
|
plcOrderType = stkProperty.getAddress(); |
|
|
|
|
plcOrderTypeValue=stkProperty.getValueType(); |
|
|
|
|
}else if (stkProperty.getPointType().equals(PlcPropertyEnum.twentythree.getValue())){ |
|
|
|
|
plcStartEq=stkProperty.getAddress(); |
|
|
|
|
plcStartEqValueType=stkProperty.getValueType(); |
|
|
|
|
}else if (stkProperty.getPointType().equals("4")) { |
|
|
|
|
readfinish = stkProperty.getAddress(); |
|
|
|
|
readfinishValueType=stkProperty.getValueType(); |
|
|
|
|
@ -876,45 +879,45 @@ public class PlcEventTask { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Integer stkRunV = 0; |
|
|
|
|
Boolean stkRunV = false; |
|
|
|
|
if (pointMap.containsKey(stkRun)) { |
|
|
|
|
stkRunV = Integer.valueOf(pointMap.get(stkRun).toString()); |
|
|
|
|
stkRunV = Boolean.valueOf(pointMap.get(stkRun).toString()); |
|
|
|
|
} |
|
|
|
|
log.info("堆垛机运行状态:"+stkRunV); |
|
|
|
|
if (stkRunV!=1){ |
|
|
|
|
log.info("请求入库时,堆垛机尚未运行"); |
|
|
|
|
if (!stkRunV){ |
|
|
|
|
log.info(taskId+"请求入库时,堆垛机尚未运行"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer stkAutoManualV=0; |
|
|
|
|
Boolean stkAutoManualV=null; |
|
|
|
|
if (pointMap.containsKey(stkAutoManual)) { |
|
|
|
|
stkAutoManualV = Integer.valueOf(pointMap.get(stkAutoManual).toString()); |
|
|
|
|
stkAutoManualV = Boolean.valueOf(pointMap.get(stkAutoManual).toString()); |
|
|
|
|
} |
|
|
|
|
log.info("堆垛机自动状态:"+stkAutoManualV); |
|
|
|
|
if(stkAutoManualV ==0 ){ |
|
|
|
|
log.info("请求入库时,堆垛机手动状态"); |
|
|
|
|
log.info(taskId+"堆垛机自动状态:"+stkAutoManualV); |
|
|
|
|
if(!stkAutoManualV ){ |
|
|
|
|
log.info(taskId+"请求入库时,堆垛机手动状态"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Integer stkGroundV= 0; |
|
|
|
|
Boolean stkGroundV= false; |
|
|
|
|
if (pointMap.containsKey(stkGround)) { |
|
|
|
|
stkGroundV = Integer.valueOf(pointMap.get(stkGround).toString()); |
|
|
|
|
stkGroundV = Boolean.valueOf(pointMap.get(stkGround).toString()); |
|
|
|
|
} |
|
|
|
|
log.info("地面柜自动状态:"+stkGroundV); |
|
|
|
|
if(stkGroundV==0){ |
|
|
|
|
log.info("请求入库时,堆垛机地面柜手动状态"); |
|
|
|
|
log.info(taskId+"地面柜自动状态:"+stkGroundV); |
|
|
|
|
if(!stkGroundV){ |
|
|
|
|
log.info(taskId+"请求入库时,堆垛机地面柜手动状态"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Integer stkidleV = 0; |
|
|
|
|
Boolean stkidleV = false; |
|
|
|
|
if (pointMap.containsKey(stkidle)) { |
|
|
|
|
stkidleV = Integer.valueOf(pointMap.get(stkidle).toString()); |
|
|
|
|
stkidleV = Boolean.valueOf(pointMap.get(stkidle).toString()); |
|
|
|
|
} |
|
|
|
|
log.info("堆垛机是状态:"+stkidleV); |
|
|
|
|
log.info(taskId+"堆垛机是状态:"+stkidleV); |
|
|
|
|
//1空闲 0繁忙
|
|
|
|
|
if(stkidleV==0){ |
|
|
|
|
log.info("请求入库时,堆垛机繁忙"); |
|
|
|
|
if(!stkidleV){ |
|
|
|
|
log.info(taskId+"请求入库时,堆垛机繁忙"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -936,37 +939,37 @@ public class PlcEventTask { |
|
|
|
|
Map<String, Object> plcOrderTypeMap = new HashMap<>(1); |
|
|
|
|
plcOrderTypeMap.put(plcOrderTypeValue, 1); |
|
|
|
|
allMap.put(plcOrderType, plcOrderTypeMap); |
|
|
|
|
Map<String, Object> plcFromRowMap = new HashMap<>(1); |
|
|
|
|
plcFromRowMap.put(FromRowValueType, "1"); |
|
|
|
|
/* Map<String, Object> plcFromRowMap = new HashMap<>(1); |
|
|
|
|
plcFromRowMap.put(fromRowValueType, fromRow); |
|
|
|
|
allMap.put(plcFromRow, plcFromRowMap); |
|
|
|
|
Map<String, Object> plcFromColumnMap = new HashMap<>(1); |
|
|
|
|
plcFromColumnMap.put(FromColumnValueType, "22"); |
|
|
|
|
plcFromColumnMap.put(fromColumnValueType, fromColumn); |
|
|
|
|
allMap.put(plcFromColumn, plcFromColumnMap); |
|
|
|
|
Map<String, Object> plcFromLayerMap = new HashMap<>(1); |
|
|
|
|
plcFromLayerMap.put(FromLayerValueType, "1"); |
|
|
|
|
allMap.put(plcFromLayer, plcFromLayerMap); |
|
|
|
|
//启动设备
|
|
|
|
|
Map<String, Object> plcStartEqMap = new HashMap<>(1); |
|
|
|
|
plcStartEqMap.put(plcStartEqValueType, true); |
|
|
|
|
allMap.put(plcStartEq, plcStartEqMap); |
|
|
|
|
plcFromLayerMap.put(fromLayerValueType, fromLayer); |
|
|
|
|
allMap.put(plcFromLayer, plcFromLayerMap);*/ |
|
|
|
|
|
|
|
|
|
//入库起始站台
|
|
|
|
|
Map<String, Object> plcPlatformMap = new HashMap<>(1); |
|
|
|
|
plcPlatformMap.put(plcPlatformValueType,reqLayer); |
|
|
|
|
allMap.put(plcPlatform,plcPlatformMap); |
|
|
|
|
//堆垛机完成状态,下命令时写入0,未完成状态
|
|
|
|
|
Map<String, Object> readfinishMap = new HashMap<>(1); |
|
|
|
|
readfinishMap.put(readfinishValueType, 0); |
|
|
|
|
allMap.put(readfinish, readfinishMap); |
|
|
|
|
|
|
|
|
|
log.info("请求入库:任务下发之前"+JsonUtil.toJSONString(allMap)); |
|
|
|
|
|
|
|
|
|
log.info(taskId+"请求入库:任务下发之前"+JsonUtil.toJSONString(allMap)); |
|
|
|
|
if (plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap))) { |
|
|
|
|
log.info("请求入库,任务下发成功:"+taskId); |
|
|
|
|
log.info(taskId+"请求入库,任务下发成功:"); |
|
|
|
|
//请求成功,记录已下发
|
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisReqWare + taskId, taskId,24,TimeUnit.HOURS); |
|
|
|
|
//请求分配任务ID dps
|
|
|
|
|
redisTemplate.delete(RedisConstant.redisContainer+taskId); |
|
|
|
|
return true; |
|
|
|
|
}else { |
|
|
|
|
log.info("请求入库任务下发失败"); |
|
|
|
|
log.info(taskId+"请求入库任务下发失败"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|