|
|
|
|
@ -47,7 +47,7 @@ import javax.annotation.Resource; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.*; |
|
|
|
|
|
|
|
|
|
import com.shkj.plc.sdk.device.PLCReadAndWrite; |
|
|
|
|
import com.shkj.plc.sdk.device.PLCReadAndWrite; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import oshi.jna.platform.mac.SystemB; |
|
|
|
|
@ -83,7 +83,7 @@ public class PlcEventTask { |
|
|
|
|
WcsPlcConnectMapper wcsPlcConnectMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
IBusinOutInPlanService iBusinOutInPlanService; |
|
|
|
|
IBusinOutInPlanService iBusinOutInPlanService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
WmsCallWcsUtil wmsCallWcsUtil; |
|
|
|
|
@ -107,11 +107,11 @@ public class PlcEventTask { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (WcsPlcConnectVo conn : plcList) { |
|
|
|
|
if (conn.getPlcIp().contains("155.180")){ |
|
|
|
|
if (conn.getPlcIp().contains("155.180")) { |
|
|
|
|
plcTask(plcInit.getPlcOperate_stk(), conn, conn.getPointTables()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (conn.getPlcIp().contains("155.170")){ |
|
|
|
|
if (conn.getPlcIp().contains("155.170")) { |
|
|
|
|
plcTask(plcInit.getPlcOperate_dps(), conn, conn.getPointTables()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -120,13 +120,13 @@ public class PlcEventTask { |
|
|
|
|
|
|
|
|
|
//输送线心跳
|
|
|
|
|
@Scheduled(fixedDelay = 4000) |
|
|
|
|
public void writePlcheartbeatDps(){ |
|
|
|
|
public void writePlcheartbeatDps() { |
|
|
|
|
//根据连接的plcId获取属性
|
|
|
|
|
PlcOperate plcOperate = plcInit.getPlcOperate_dps(); |
|
|
|
|
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); |
|
|
|
|
Map<String, Object> readPointMap = new HashMap<>(); |
|
|
|
|
String heartbeat="DB320.0.0"; |
|
|
|
|
readPointMap.put(heartbeat,"Boolean"); |
|
|
|
|
Map<String, Object> readPointMap = new HashMap<>(); |
|
|
|
|
String heartbeat = "DB320.0.0"; |
|
|
|
|
readPointMap.put(heartbeat, "Boolean"); |
|
|
|
|
Map<String, Object> pointMap = plcReadAndWrite.readPlcData(plcOperate, JsonUtil.toJSONString(readPointMap)); |
|
|
|
|
|
|
|
|
|
//读取心跳,并判断是写入true还是false;
|
|
|
|
|
@ -141,20 +141,21 @@ public class PlcEventTask { |
|
|
|
|
Map<String, Object> allHbMap = new HashMap<>(1); |
|
|
|
|
allHbMap.put(heartbeat, writeHbMap); |
|
|
|
|
Boolean heartType = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allHbMap)); |
|
|
|
|
if(!heartType){ |
|
|
|
|
if (!heartType) { |
|
|
|
|
log.info("dps心跳写入失败,重连服务器"); |
|
|
|
|
plcInit.connect(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//堆垛机心跳
|
|
|
|
|
@Scheduled(fixedDelay = 4000) |
|
|
|
|
public void writePlcheartbeatStk(){ |
|
|
|
|
public void writePlcheartbeatStk() { |
|
|
|
|
//根据连接的plcId获取属性
|
|
|
|
|
PlcOperate plcOperate = plcInit.getPlcOperate_stk(); |
|
|
|
|
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); |
|
|
|
|
Map<String, Object> readPointMap = new HashMap<>(); |
|
|
|
|
String heartbeat="DB20.0.4"; |
|
|
|
|
readPointMap.put(heartbeat,"Boolean"); |
|
|
|
|
Map<String, Object> readPointMap = new HashMap<>(); |
|
|
|
|
String heartbeat = "DB20.0.4"; |
|
|
|
|
readPointMap.put(heartbeat, "Boolean"); |
|
|
|
|
Map<String, Object> pointMap = plcReadAndWrite.readPlcData(plcOperate, JsonUtil.toJSONString(readPointMap)); |
|
|
|
|
|
|
|
|
|
//读取心跳,并判断是写入true还是false;
|
|
|
|
|
@ -169,7 +170,7 @@ public class PlcEventTask { |
|
|
|
|
Map<String, Object> allHbMap = new HashMap<>(1); |
|
|
|
|
allHbMap.put(heartbeat, writeHbMap); |
|
|
|
|
Boolean heartType = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allHbMap)); |
|
|
|
|
if(!heartType){ |
|
|
|
|
if (!heartType) { |
|
|
|
|
log.info("stk心跳写入失败,重连服务器"); |
|
|
|
|
plcInit.connect(); |
|
|
|
|
} |
|
|
|
|
@ -177,56 +178,57 @@ public class PlcEventTask { |
|
|
|
|
|
|
|
|
|
public void plcTask(PlcOperate plcOperate, WcsPlcConnectVo conn, String pointTables) { |
|
|
|
|
|
|
|
|
|
Long plcId = conn.getId(); |
|
|
|
|
//根据连接的plcId获取属性
|
|
|
|
|
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); |
|
|
|
|
Map<String, Object> pointMap = plcReadAndWrite.readPlcData(plcOperate, pointTables); |
|
|
|
|
// log.info("连接的IP:"+conn.getPlcIp()+":设备:"+conn.getConnectName()+" 读取的点位内容:"+pointMap);
|
|
|
|
|
Long plcId = conn.getId(); |
|
|
|
|
//根据连接的plcId获取属性
|
|
|
|
|
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); |
|
|
|
|
Map<String, Object> pointMap = plcReadAndWrite.readPlcData(plcOperate, pointTables); |
|
|
|
|
// log.info("连接的IP:"+conn.getPlcIp()+":设备:"+conn.getConnectName()+" 读取的点位内容:"+pointMap);
|
|
|
|
|
|
|
|
|
|
List<WcsPlcProperty> propertyList = (List<WcsPlcProperty>)redisTemplate.opsForValue().get(RedisConstant.redisPlcProperty + plcId); |
|
|
|
|
if(propertyList == null || propertyList.size()==0){ |
|
|
|
|
propertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(plcId); |
|
|
|
|
} |
|
|
|
|
//任务ID
|
|
|
|
|
Long taskId = 0L; |
|
|
|
|
// 设备类型:2输送线 1 堆垛机
|
|
|
|
|
switch (conn.getDevType()) { |
|
|
|
|
//输送线
|
|
|
|
|
case "2": |
|
|
|
|
dpsRealTimeTask(propertyList, pointMap, plcReadAndWrite,plcOperate ); |
|
|
|
|
doExecMsg(propertyList,pointMap,"dps"); |
|
|
|
|
doDevStatus(propertyList,pointMap); |
|
|
|
|
break; |
|
|
|
|
case "1": |
|
|
|
|
//堆垛机
|
|
|
|
|
stkRealTimeTask(propertyList, pointMap, plcReadAndWrite,plcOperate,pointTables ); |
|
|
|
|
doExecMsg(propertyList,pointMap,"stk"); |
|
|
|
|
doDevStatus(propertyList,pointMap); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
log.info("无匹配的设备类型"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
List<WcsPlcProperty> propertyList = (List<WcsPlcProperty>) redisTemplate.opsForValue().get(RedisConstant.redisPlcProperty + plcId); |
|
|
|
|
if (propertyList == null || propertyList.size() == 0) { |
|
|
|
|
propertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(plcId); |
|
|
|
|
} |
|
|
|
|
//任务ID
|
|
|
|
|
Long taskId = 0L; |
|
|
|
|
// 设备类型:2输送线 1 堆垛机
|
|
|
|
|
switch (conn.getDevType()) { |
|
|
|
|
//输送线
|
|
|
|
|
case "2": |
|
|
|
|
dpsRealTimeTask(propertyList, pointMap, plcReadAndWrite, plcOperate); |
|
|
|
|
doExecMsg(propertyList, pointMap, "dps"); |
|
|
|
|
doDevStatus(propertyList, pointMap); |
|
|
|
|
break; |
|
|
|
|
case "1": |
|
|
|
|
//堆垛机
|
|
|
|
|
stkRealTimeTask(propertyList, pointMap, plcReadAndWrite, plcOperate, pointTables); |
|
|
|
|
doExecMsg(propertyList, pointMap, "stk"); |
|
|
|
|
doDevStatus(propertyList, pointMap); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
log.info("无匹配的设备类型"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理设备报警信息 |
|
|
|
|
* |
|
|
|
|
* @param propertyList |
|
|
|
|
* @param pointMap |
|
|
|
|
*/ |
|
|
|
|
private void doExecMsg(List<WcsPlcProperty> propertyList,Map<String, Object> pointMap,String devType){ |
|
|
|
|
private void doExecMsg(List<WcsPlcProperty> propertyList, Map<String, Object> pointMap, String devType) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
BusinPlcException businPlcException=null; |
|
|
|
|
BusinPlcException businPlcException = null; |
|
|
|
|
List<BusinPlcException> execList = new ArrayList<>(); |
|
|
|
|
for (WcsPlcProperty property : propertyList) { |
|
|
|
|
String pointType = property.getPointType(); |
|
|
|
|
String devpName = property.getDevpName(); |
|
|
|
|
String address = property.getAddress(); |
|
|
|
|
businPlcException = new BusinPlcException(); |
|
|
|
|
if (pointType.equals("99")){ |
|
|
|
|
if (pointMap.containsKey(address) && Boolean.valueOf((pointMap.get(address).toString()))){ |
|
|
|
|
if (pointType.equals("99")) { |
|
|
|
|
if (pointMap.containsKey(address) && Boolean.valueOf((pointMap.get(address).toString()))) { |
|
|
|
|
businPlcException.setPlcPoint(address); |
|
|
|
|
businPlcException.setExecMsg(devpName); |
|
|
|
|
businPlcException.setExecDate(DateUtils.getTime()); |
|
|
|
|
@ -234,11 +236,11 @@ public class PlcEventTask { |
|
|
|
|
execList.add(businPlcException); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// iBusinPlcExceptionService.saveBatch(execList);
|
|
|
|
|
// iBusinPlcExceptionService.saveBatch(execList);
|
|
|
|
|
} |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisPlcExecMsg+devType,execList ); |
|
|
|
|
}catch (Exception e ){ |
|
|
|
|
log.error("处理报警信息异常{}"+e.getMessage()); |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisPlcExecMsg + devType, execList); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("处理报警信息异常{}" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -246,17 +248,18 @@ public class PlcEventTask { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理设备状态 |
|
|
|
|
* |
|
|
|
|
* @param propertyList |
|
|
|
|
* @param pointMap |
|
|
|
|
*/ |
|
|
|
|
private void doDevStatus(List<WcsPlcProperty> propertyList,Map<String, Object> pointMap){ |
|
|
|
|
private void doDevStatus(List<WcsPlcProperty> propertyList, Map<String, Object> pointMap) { |
|
|
|
|
try { |
|
|
|
|
/* BusinPlcStatus businPlcStatus =(BusinPlcStatus)redisTemplate.opsForValue().get(RedisConstant.redisPlcStatus); |
|
|
|
|
if (businPlcStatus == null){ |
|
|
|
|
businPlcStatus = new BusinPlcStatus(); |
|
|
|
|
}*/ |
|
|
|
|
Long plcId =0L; |
|
|
|
|
BusinPlcStatus businPlcStatus = new BusinPlcStatus(); |
|
|
|
|
Long plcId = 0L; |
|
|
|
|
BusinPlcStatus businPlcStatus = new BusinPlcStatus(); |
|
|
|
|
for (WcsPlcProperty property : propertyList) { |
|
|
|
|
plcId = property.getPlcId(); |
|
|
|
|
String pointType = property.getPointType(); |
|
|
|
|
@ -309,51 +312,51 @@ public class PlcEventTask { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisPlcStatus,businPlcStatus,30,TimeUnit.SECONDS ); |
|
|
|
|
}catch (Exception e ){ |
|
|
|
|
log.error("处理设备状态{}"+e.getMessage()); |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisPlcStatus, businPlcStatus, 30, TimeUnit.SECONDS); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("处理设备状态{}" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void dpsRealTimeTask(List<WcsPlcProperty> propertyList,Map<String, Object> pointMap, PLCReadAndWrite plcReadAndWrite,PlcOperate plcOperate ) { |
|
|
|
|
public void dpsRealTimeTask(List<WcsPlcProperty> propertyList, Map<String, Object> pointMap, PLCReadAndWrite plcReadAndWrite, PlcOperate plcOperate) { |
|
|
|
|
try { |
|
|
|
|
String oneAllotAddress = "", oneAllotTaskId = "", oneAllotTaskIdVt = ""; |
|
|
|
|
String twoAllotAddress = "", twoAllotTaskId = "", twoAllotTaskIdVt = ""; |
|
|
|
|
|
|
|
|
|
String autoAddress = ""; |
|
|
|
|
String autoAddress = ""; |
|
|
|
|
|
|
|
|
|
//货物高度wms的值
|
|
|
|
|
String cargoHeight =""; |
|
|
|
|
String cargoHeight = ""; |
|
|
|
|
//托盘条码地址
|
|
|
|
|
String onePalletAddress = "",twoPalletAddress=""; |
|
|
|
|
String onePalletAddress = "", twoPalletAddress = ""; |
|
|
|
|
|
|
|
|
|
//请求入库
|
|
|
|
|
String oneReqPutin = "",twoReqPutin = ""; |
|
|
|
|
String oneReqPutin = "", twoReqPutin = ""; |
|
|
|
|
//请求入库任务ID
|
|
|
|
|
String oneReqPutInTaskId = "",twoReqPutInTaskId = ""; |
|
|
|
|
String oneReqPutInTaskId = "", twoReqPutInTaskId = ""; |
|
|
|
|
|
|
|
|
|
//货位高度
|
|
|
|
|
String oneHignType = "",twoHignType = ""; |
|
|
|
|
String oneHignTypeVT = "",twoHignTypeVT = ""; |
|
|
|
|
String oneHignType = "", twoHignType = ""; |
|
|
|
|
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(); |
|
|
|
|
//请求分配
|
|
|
|
|
if (pointType.equals("oneAllot")) { |
|
|
|
|
oneAllotAddress = plcProperty.getAddress(); |
|
|
|
|
}else if (pointType.equals("twoAllot")) { |
|
|
|
|
} else if (pointType.equals("twoAllot")) { |
|
|
|
|
twoAllotAddress = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("oneAllotTask")) { |
|
|
|
|
oneAllotTaskId = plcProperty.getAddress(); |
|
|
|
|
@ -383,28 +386,38 @@ 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(); |
|
|
|
|
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(); |
|
|
|
|
oneRwide = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("oneHigh")) { |
|
|
|
|
oneHigh = 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(); |
|
|
|
|
twoLwide = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("twoRwide")) { |
|
|
|
|
twoRwide =plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("twoHigh")){ |
|
|
|
|
twoHigh =plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("ontExit")){ |
|
|
|
|
oneWcsErrExit =plcProperty.getAddress(); |
|
|
|
|
oneWcsErrExitVT = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("twoExit")){ |
|
|
|
|
twoWcsErrExit =plcProperty.getAddress(); |
|
|
|
|
twoWcsErrExitVT = plcProperty.getValueType(); |
|
|
|
|
twoRwide = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("twoHigh")) { |
|
|
|
|
twoHigh = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("ontExit")) { |
|
|
|
|
oneWcsErrExit = plcProperty.getAddress(); |
|
|
|
|
oneWcsErrExitVt = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("twoExit")) { |
|
|
|
|
twoWcsErrExit = plcProperty.getAddress(); |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -415,43 +428,48 @@ public class PlcEventTask { |
|
|
|
|
if (pointMap.containsKey(oneAllotAddress) && Boolean.valueOf(pointMap.get(oneAllotAddress).toString())) { |
|
|
|
|
//请求入库分配时,判断是否有正在执行的出库任务,如果有则返回
|
|
|
|
|
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); |
|
|
|
|
if (taskOutId !=null){ |
|
|
|
|
if (taskOutId != null) { |
|
|
|
|
log.info("1楼入库分配请求时,有出库任务,不可分配,返回"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//读取托盘条码内容
|
|
|
|
|
String barcodeValueOne = pointMap.get(onePalletAddress).toString(); |
|
|
|
|
log.info("1楼请求入库时,读取的条码内容:"+barcodeValueOne); |
|
|
|
|
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 { |
|
|
|
|
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); |
|
|
|
|
} else { |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisPutInExeMsg + orderResult.getMsg(), orderResult.getMsg()); |
|
|
|
|
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); |
|
|
|
|
}else { |
|
|
|
|
log.info("1楼获取单号入库失败,写入点位失败{}",allMap); |
|
|
|
|
if (errBoolean) { |
|
|
|
|
log.info("1楼获取单号入库失败,写入点位成功{}", allMap); |
|
|
|
|
} else { |
|
|
|
|
log.info("1楼获取单号入库失败,写入点位失败{}", allMap); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
log.info("1楼入库分配任务ID:"+taskIdOne + "条码号:"+ barcodeValueOne); |
|
|
|
|
log.info("1楼入库分配货位类型:"+cargoHeight); |
|
|
|
|
String redisBarcodeOne = String.valueOf(redisTemplate.opsForValue().get(RedisConstant.redisContainer+taskIdOne)); |
|
|
|
|
log.info("1楼入库分配任务ID:" + taskIdOne + "条码号:" + barcodeValueOne); |
|
|
|
|
log.info("1楼入库分配货位类型:" + cargoHeight); |
|
|
|
|
String redisBarcodeOne = String.valueOf(redisTemplate.opsForValue().get(RedisConstant.redisContainer + taskIdOne)); |
|
|
|
|
|
|
|
|
|
//根据扫码的托盘,判断是否已经下任务了
|
|
|
|
|
if (taskIdOne != 0L && redisBarcodeOne !=null && !redisBarcodeOne.equals(barcodeValueOne)) { |
|
|
|
|
if (taskIdOne != 0L && redisBarcodeOne != null && !redisBarcodeOne.equals(barcodeValueOne)) { |
|
|
|
|
//回填任务号
|
|
|
|
|
Map<String, Long> writeMap = new HashMap<>(1); |
|
|
|
|
writeMap.put(oneAllotTaskIdVt, taskIdOne); |
|
|
|
|
@ -463,14 +481,14 @@ public class PlcEventTask { |
|
|
|
|
allMap.put(oneHignType, cargoHeightMap); |
|
|
|
|
|
|
|
|
|
Map<String, Integer> wcsErrwriteMap = new HashMap<>(1); |
|
|
|
|
wcsErrwriteMap.put(oneWcsErrExitVT, 0); |
|
|
|
|
allMap.put(oneWcsErrExit,wcsErrwriteMap); |
|
|
|
|
log.info("1楼按下入库按钮时,给输送线写命令数据:{}"+allMap); |
|
|
|
|
wcsErrwriteMap.put(oneWcsErrExitVt, 0); |
|
|
|
|
allMap.put(oneWcsErrExit, wcsErrwriteMap); |
|
|
|
|
log.info("1楼按下入库按钮时,给输送线写命令数据:{}" + allMap); |
|
|
|
|
|
|
|
|
|
Boolean taskBoolean = plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap)); |
|
|
|
|
if (taskBoolean) { |
|
|
|
|
//分配任务成功时,记录已下发入库任务,不可在下发出库或入库任务
|
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisTaskIn,taskIdOne); |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisTaskIn, taskIdOne); |
|
|
|
|
//更改入库计划为1
|
|
|
|
|
iBusinOutInPlanService.updPlanStatus(taskIdOne, PlanStatusEnum.DOING.getValue()); |
|
|
|
|
} |
|
|
|
|
@ -480,44 +498,49 @@ public class PlcEventTask { |
|
|
|
|
} |
|
|
|
|
//2楼是否请求分配
|
|
|
|
|
if (pointMap.containsKey(twoAllotAddress) && Boolean.valueOf(pointMap.get(twoAllotAddress).toString())) { |
|
|
|
|
Long taskIdTwo=0L; |
|
|
|
|
Long taskIdTwo = 0L; |
|
|
|
|
//请求入库分配时,判断是否有正在执行的出库任务,如果有则返回
|
|
|
|
|
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); |
|
|
|
|
if (taskOutId !=null){ |
|
|
|
|
if (taskOutId != null) { |
|
|
|
|
log.info("2楼入库分配请求时,有出库任务,不可分配,返回"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//读取托盘条码内容
|
|
|
|
|
String barcodeValueTwo = pointMap.get(twoPalletAddress).toString(); |
|
|
|
|
log.info("1楼请求入库时,读取的条码内容:"+barcodeValueTwo); |
|
|
|
|
log.info("1楼请求入库时,读取的条码内容:" + barcodeValueTwo); |
|
|
|
|
//根据托盘条码返回正在执行的任务号
|
|
|
|
|
Result<PlanOrderLocationVo> orderResult = iBusinOutInPlanService.getOrderNoByContainerCode(barcodeValueTwo, "in"); |
|
|
|
|
log.info("2楼根据条码获取的任务信息:"+orderResult.getData()); |
|
|
|
|
log.info("2楼根据条码获取的任务信息:" + orderResult.getData()); |
|
|
|
|
if (Result.isOk(orderResult)) { |
|
|
|
|
PlanOrderLocationVo data = orderResult.getData(); |
|
|
|
|
taskIdTwo = data.getOrderNo(); |
|
|
|
|
cargoHeight = data.getType();//获取托盘或模具类型
|
|
|
|
|
}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); |
|
|
|
|
} else { |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisPutInExeMsg + orderResult.getMsg(), orderResult.getMsg()); |
|
|
|
|
log.info("2楼获取任务信息失败:" + orderResult.getMsg() + "托盘条码:" + barcodeValueTwo); |
|
|
|
|
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); |
|
|
|
|
}else { |
|
|
|
|
log.info("2楼获取单号入库失败,写入点位失败{}",allMap); |
|
|
|
|
if (errBoolean) { |
|
|
|
|
log.info("2楼获取单号入库失败,写入点位成功{}", allMap); |
|
|
|
|
} else { |
|
|
|
|
log.info("2楼获取单号入库失败,写入点位失败{}", allMap); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
log.info("2楼入库分配任务ID:"+taskIdTwo + "条码号:"+ barcodeValueTwo); |
|
|
|
|
log.info("2楼入库分配货位类型:"+cargoHeight); |
|
|
|
|
String redisBarcodeTwo = String.valueOf(redisTemplate.opsForValue().get(RedisConstant.redisContainer+taskIdTwo)); |
|
|
|
|
log.info("2楼入库分配任务ID:" + taskIdTwo + "条码号:" + barcodeValueTwo); |
|
|
|
|
log.info("2楼入库分配货位类型:" + cargoHeight); |
|
|
|
|
String redisBarcodeTwo = String.valueOf(redisTemplate.opsForValue().get(RedisConstant.redisContainer + taskIdTwo)); |
|
|
|
|
|
|
|
|
|
//根据扫码的托盘,判断是否已经下任务了
|
|
|
|
|
if (taskIdTwo != 0L && redisBarcodeTwo!=null && !redisBarcodeTwo.equals(barcodeValueTwo)) { |
|
|
|
|
if (taskIdTwo != 0L && redisBarcodeTwo != null && !redisBarcodeTwo.equals(barcodeValueTwo)) { |
|
|
|
|
//回填任务号
|
|
|
|
|
Map<String, Long> writeMap = new HashMap<>(1); |
|
|
|
|
writeMap.put(twoAllotTaskIdVt, taskIdTwo); |
|
|
|
|
@ -529,15 +552,14 @@ public class PlcEventTask { |
|
|
|
|
allMap.put(twoHignType, cargoHeightMap); |
|
|
|
|
|
|
|
|
|
Map<String, Integer> wcsErrwriteMap = new HashMap<>(1); |
|
|
|
|
wcsErrwriteMap.put(twoWcsErrExitVT, 0); |
|
|
|
|
allMap.put(twoWcsErrExit,wcsErrwriteMap); |
|
|
|
|
log.info("2楼按下入库按钮时,给输送线写命令数据:{}"+allMap); |
|
|
|
|
|
|
|
|
|
wcsErrwriteMap.put(twoWcsErrExitVt, 0); |
|
|
|
|
allMap.put(twoWcsErrExit, wcsErrwriteMap); |
|
|
|
|
log.info("2楼按下入库按钮时,给输送线写命令数据:{}" + allMap); |
|
|
|
|
|
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
@ -545,38 +567,45 @@ 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(oneLwide)){ |
|
|
|
|
|
|
|
|
|
if (pointMap.containsKey(oneAoverlength)) { |
|
|
|
|
oneAoverlengthV = Boolean.valueOf(pointMap.get(oneAoverlength).toString()); |
|
|
|
|
} |
|
|
|
|
if (pointMap.containsKey(oneLwide)) { |
|
|
|
|
oneLwideV = Boolean.valueOf(pointMap.get(oneLwide).toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(pointMap.containsKey(oneRwide)){ |
|
|
|
|
if (pointMap.containsKey(oneRwide)) { |
|
|
|
|
oneRwideV = Boolean.valueOf(pointMap.get(oneRwide).toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(pointMap.containsKey(oneHigh)){ |
|
|
|
|
if (pointMap.containsKey(oneHigh)) { |
|
|
|
|
oneHighV = Boolean.valueOf(pointMap.get(oneHigh).toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oneOverlengthV || oneLwideV || oneRwideV || oneHighV) { |
|
|
|
|
if (oneBoverlengthV || oneAoverlengthV || oneLwideV || oneRwideV || oneHighV) { |
|
|
|
|
//读取失败原因
|
|
|
|
|
String failedReasonValue =""; |
|
|
|
|
if (oneOverlengthV){ |
|
|
|
|
failedReasonValue="超长"; |
|
|
|
|
String failedReasonValue = ""; |
|
|
|
|
if (oneBoverlengthV) { |
|
|
|
|
failedReasonValue = "前超长"; |
|
|
|
|
} |
|
|
|
|
if (oneAoverlengthV) { |
|
|
|
|
failedReasonValue = "后超长"; |
|
|
|
|
} |
|
|
|
|
if (oneLwideV){ |
|
|
|
|
failedReasonValue="左超宽"; |
|
|
|
|
if (oneLwideV) { |
|
|
|
|
failedReasonValue = "左超宽"; |
|
|
|
|
} |
|
|
|
|
if (oneRwideV){ |
|
|
|
|
failedReasonValue="右超宽"; |
|
|
|
|
if (oneRwideV) { |
|
|
|
|
failedReasonValue = "右超宽"; |
|
|
|
|
} |
|
|
|
|
if (oneHighV){ |
|
|
|
|
failedReasonValue="超高"; |
|
|
|
|
if (oneHighV) { |
|
|
|
|
failedReasonValue = "超高"; |
|
|
|
|
} |
|
|
|
|
log.info("1楼入库失败原因:"+failedReasonValue); |
|
|
|
|
log.info("1楼入库失败原因:" + failedReasonValue); |
|
|
|
|
//读取失败任务号
|
|
|
|
|
Long failedTaskIdValueOne = Long.valueOf(pointMap.get(oneAllotTaskId).toString()); |
|
|
|
|
|
|
|
|
|
@ -588,8 +617,8 @@ public class PlcEventTask { |
|
|
|
|
|
|
|
|
|
String redisFailedTaskIdValueOne = String.valueOf(redisTemplate.opsForValue().get(RedisConstant.redisDPSFailedTaskIdOne)); |
|
|
|
|
|
|
|
|
|
log.info("1楼入库失败redis任务ID:"+redisFailedTaskIdValueOne); |
|
|
|
|
log.info("1楼入库失败PLC任务ID:"+failedTaskIdValueOne); |
|
|
|
|
log.info("1楼入库失败redis任务ID:" + redisFailedTaskIdValueOne); |
|
|
|
|
log.info("1楼入库失败PLC任务ID:" + failedTaskIdValueOne); |
|
|
|
|
//入库失败,更改入库状态为0
|
|
|
|
|
if (failedTaskIdValueOne != 0L && !redisFailedTaskIdValueOne.equals(failedTaskIdValueOne)) { |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisDPSFailedTaskIdOne, failedTaskIdValueOne); |
|
|
|
|
@ -602,37 +631,47 @@ 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)){ |
|
|
|
|
|
|
|
|
|
if (pointMap.containsKey(twoLwide)) { |
|
|
|
|
twoLwideV = Boolean.valueOf(pointMap.get(twoLwide).toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(pointMap.containsKey(twoRwide)){ |
|
|
|
|
if (pointMap.containsKey(twoRwide)) { |
|
|
|
|
twoRwideV = Boolean.valueOf(pointMap.get(twoRwide).toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(pointMap.containsKey(twoHigh)){ |
|
|
|
|
if (pointMap.containsKey(twoHigh)) { |
|
|
|
|
twoHighV = Boolean.valueOf(pointMap.get(twoHigh).toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (twoOverlengthV || twoLwideV || twoRwideV || twoHighV) { |
|
|
|
|
if (twoBoverlengthV || twoAoverlengthV || twoLwideV || twoRwideV || twoHighV) { |
|
|
|
|
//读取失败原因
|
|
|
|
|
String failedReasonValue =""; |
|
|
|
|
if (twoOverlengthV){ |
|
|
|
|
failedReasonValue="超长"; |
|
|
|
|
String failedReasonValue = ""; |
|
|
|
|
if (twoBoverlengthV) { |
|
|
|
|
failedReasonValue = "前超长"; |
|
|
|
|
} |
|
|
|
|
if (twoLwideV){ |
|
|
|
|
failedReasonValue="左超宽"; |
|
|
|
|
|
|
|
|
|
if (twoAoverlengthV) { |
|
|
|
|
failedReasonValue = "后超长"; |
|
|
|
|
} |
|
|
|
|
if (twoRwideV){ |
|
|
|
|
failedReasonValue="右超宽"; |
|
|
|
|
|
|
|
|
|
if (twoLwideV) { |
|
|
|
|
failedReasonValue = "左超宽"; |
|
|
|
|
} |
|
|
|
|
if (twoHighV){ |
|
|
|
|
failedReasonValue="超高"; |
|
|
|
|
if (twoRwideV) { |
|
|
|
|
failedReasonValue = "右超宽"; |
|
|
|
|
} |
|
|
|
|
log.info("2楼入库失败原因:"+failedReasonValue); |
|
|
|
|
if (twoHighV) { |
|
|
|
|
failedReasonValue = "超高"; |
|
|
|
|
} |
|
|
|
|
log.info("2楼入库失败原因:" + failedReasonValue); |
|
|
|
|
//读取失败任务号
|
|
|
|
|
Long failedTaskIdValueTwo = Long.valueOf(pointMap.get(twoAllotTaskId).toString()); |
|
|
|
|
|
|
|
|
|
@ -644,8 +683,8 @@ public class PlcEventTask { |
|
|
|
|
|
|
|
|
|
String redisFailedTaskIdValueTwo = String.valueOf(redisTemplate.opsForValue().get(RedisConstant.redisDPSFailedTaskIdTwo)); |
|
|
|
|
|
|
|
|
|
log.info("2楼入库失败redis任务ID:"+redisFailedTaskIdValueTwo); |
|
|
|
|
log.info("2楼入库失败PLC任务ID:"+failedTaskIdValueTwo); |
|
|
|
|
log.info("2楼入库失败redis任务ID:" + redisFailedTaskIdValueTwo); |
|
|
|
|
log.info("2楼入库失败PLC任务ID:" + failedTaskIdValueTwo); |
|
|
|
|
//入库失败,更改入库状态为0
|
|
|
|
|
if (failedTaskIdValueTwo != 0L && !redisFailedTaskIdValueTwo.equals(failedTaskIdValueTwo)) { |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisDPSFailedTaskIdTwo, failedTaskIdValueTwo); |
|
|
|
|
@ -659,14 +698,14 @@ public class PlcEventTask { |
|
|
|
|
//1楼是否请求入库:
|
|
|
|
|
if (pointMap.containsKey(oneReqPutin) && Boolean.valueOf(pointMap.get(oneReqPutin).toString())) { |
|
|
|
|
//请求入库,给堆垛机下发命令
|
|
|
|
|
Long oneTaskId= Long.valueOf((String) pointMap.get(oneReqPutInTaskId)); |
|
|
|
|
Long oneTaskId = Long.valueOf((String) pointMap.get(oneReqPutInTaskId)); |
|
|
|
|
//从redis中验证是否已经下发任务
|
|
|
|
|
Long redisTaskId = (Long) redisTemplate.opsForValue().get(RedisConstant.redisReqWare + oneTaskId); |
|
|
|
|
if (oneTaskId.equals(redisTaskId)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//执行dps任务,给堆垛机下发命令
|
|
|
|
|
dpsTask(oneTaskId,1) ; |
|
|
|
|
dpsTask(oneTaskId, 1); |
|
|
|
|
} |
|
|
|
|
//2楼是否请求入库
|
|
|
|
|
if (pointMap.containsKey(twoReqPutin) && Boolean.valueOf(pointMap.get(twoReqPutin).toString())) { |
|
|
|
|
@ -678,32 +717,33 @@ public class PlcEventTask { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//执行dps任务,给堆垛机下发命令
|
|
|
|
|
dpsTask(twotaskId,2) ; |
|
|
|
|
dpsTask(twotaskId, 2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error("dpsRealTimeTask:"+e.getMessage()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("dpsRealTimeTask:" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 堆垛机的完成状态处理 |
|
|
|
|
* |
|
|
|
|
* @param propertyList |
|
|
|
|
* @param pointMap |
|
|
|
|
* @param plcReadAndWrite |
|
|
|
|
* @param plcOperate |
|
|
|
|
* @param pointTables |
|
|
|
|
*/ |
|
|
|
|
public void stkRealTimeTask(List<WcsPlcProperty> propertyList,Map<String, Object> pointMap, PLCReadAndWrite plcReadAndWrite,PlcOperate plcOperate,String pointTables){ |
|
|
|
|
public void stkRealTimeTask(List<WcsPlcProperty> propertyList, Map<String, Object> pointMap, PLCReadAndWrite plcReadAndWrite, PlcOperate plcOperate, String pointTables) { |
|
|
|
|
try { |
|
|
|
|
if (pointMap.isEmpty()){ |
|
|
|
|
if (pointMap.isEmpty()) { |
|
|
|
|
plcInit.connect(); |
|
|
|
|
pointMap = plcReadAndWrite.readPlcData(plcOperate, pointTables); |
|
|
|
|
log.info("堆垛机为空时,重新读取的属性值{} ",pointMap); |
|
|
|
|
log.info("堆垛机为空时,重新读取的属性值{} ", pointMap); |
|
|
|
|
} |
|
|
|
|
//实时监测堆垛机完成状态,调用库存处理逻辑
|
|
|
|
|
Long taskId=0L; |
|
|
|
|
Long taskId = 0L; |
|
|
|
|
String readTaskPoint = null; |
|
|
|
|
String readfinishPoint = null; |
|
|
|
|
int readValue = 0; |
|
|
|
|
@ -718,21 +758,21 @@ public class PlcEventTask { |
|
|
|
|
readValue = Integer.parseInt(pointMap.get(readfinishPoint).toString()); |
|
|
|
|
} |
|
|
|
|
if (pointMap.containsKey(readTaskPoint)) { |
|
|
|
|
taskId = Long.valueOf((String)pointMap.get(readTaskPoint)); |
|
|
|
|
taskId = Long.valueOf((String) pointMap.get(readTaskPoint)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("堆垛机完成出入库状态:"+readValue+"---taksID="+taskId); |
|
|
|
|
log.info("堆垛机完成出入库状态:" + readValue + "---taksID=" + taskId); |
|
|
|
|
|
|
|
|
|
//判断redis中是否已有此任务号,如果有则不再执行;
|
|
|
|
|
if (readValue == 1) { |
|
|
|
|
Result<Boolean> booleanResult =null; |
|
|
|
|
Result<Boolean> booleanResult = null; |
|
|
|
|
//判断任务号是否是系统编号,或者是否已完成的,则给堆垛机回填完成信号是0
|
|
|
|
|
BusinOutInPlan orderNoByOrderNo = iBusinOutInPlanService.getOrderNoByOrderNo(taskId.toString(), PlanStatusEnum.DOING.getValue()); |
|
|
|
|
if (orderNoByOrderNo ==null || orderNoByOrderNo.getPlanStatus().equals(PlanStatusEnum.FINISH.getValue())){ |
|
|
|
|
if (orderNoByOrderNo == null || orderNoByOrderNo.getPlanStatus().equals(PlanStatusEnum.FINISH.getValue())) { |
|
|
|
|
log.info("根据任务号未查询到任务或者已经完成,不做处理,写入堆垛机完成状态为0"); |
|
|
|
|
booleanResult=Result.ok(); |
|
|
|
|
}else { |
|
|
|
|
log.info("正常执行处理库存业务逻辑"+orderNoByOrderNo); |
|
|
|
|
booleanResult = Result.ok(); |
|
|
|
|
} else { |
|
|
|
|
log.info("正常执行处理库存业务逻辑" + orderNoByOrderNo); |
|
|
|
|
//调用入库完成库存逻辑接口
|
|
|
|
|
WcsAddStockCallbackBo bo = new WcsAddStockCallbackBo(); |
|
|
|
|
bo.setOrderNo(taskId); |
|
|
|
|
@ -740,58 +780,59 @@ public class PlcEventTask { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//处理成功 返回状态,写入状态位为0
|
|
|
|
|
if (Result.isOk(booleanResult)){ |
|
|
|
|
if (Result.isOk(booleanResult)) { |
|
|
|
|
Map<String, Object> writeMap = new HashMap<>(1); |
|
|
|
|
writeMap.put("INTEGER", 0); |
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
allMap.put(readfinishPoint, writeMap); |
|
|
|
|
if (plcReadAndWrite.execWrite(plcOperate, JsonUtil.toJSONString(allMap))) { |
|
|
|
|
//堆垛机完成状态后,把redis中的ID删除,代表此任务已经完成
|
|
|
|
|
Object taskInId =redisTemplate.opsForValue().get(RedisConstant.redisTaskIn); |
|
|
|
|
Object taskInId = redisTemplate.opsForValue().get(RedisConstant.redisTaskIn); |
|
|
|
|
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); |
|
|
|
|
|
|
|
|
|
if (taskOutId !=null && String.valueOf(taskOutId).equals(taskId.toString())){ |
|
|
|
|
if (taskOutId != null && String.valueOf(taskOutId).equals(taskId.toString())) { |
|
|
|
|
log.info("出库完成时,删除redis中的出库任务状态记录"); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisTaskOut); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (taskInId != null && String.valueOf(taskInId).equals(taskId.toString())){ |
|
|
|
|
if (taskInId != null && String.valueOf(taskInId).equals(taskId.toString())) { |
|
|
|
|
log.info("入库完成时,删除redis中的入库任务状态记录"); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisTaskIn); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("给堆垛机下发完成信号为0,成功:"+taskId); |
|
|
|
|
log.info("给堆垛机下发完成信号为0,成功:" + taskId); |
|
|
|
|
//请求成功,记录已下发
|
|
|
|
|
redisTemplate.delete(RedisConstant.redisReqWare+taskId); |
|
|
|
|
}else { |
|
|
|
|
log.info("给堆垛机下发完成信号为0,失败:"+taskId); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisReqWare + taskId); |
|
|
|
|
} else { |
|
|
|
|
log.info("给堆垛机下发完成信号为0,失败:" + taskId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error("stkRealTimeTask:"+e.getMessage()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("stkRealTimeTask:" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 输送线请求入库 |
|
|
|
|
* |
|
|
|
|
* @param taskId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public Boolean dpsTask(Long taskId,Integer reqLayer){ |
|
|
|
|
public Boolean dpsTask(Long taskId, Integer reqLayer) { |
|
|
|
|
|
|
|
|
|
//下发任务时,先查询是否有正在执行的入库任务或出库任务,如果有,则不下发入库任务
|
|
|
|
|
Object taskInId = redisTemplate.opsForValue().get(RedisConstant.redisTaskIn); |
|
|
|
|
if (taskInId !=null ){ |
|
|
|
|
log.info("有入库任务在执行,无法下发入库任务:"+taskInId); |
|
|
|
|
if (taskInId != null) { |
|
|
|
|
log.info("有入库任务在执行,无法下发入库任务:" + taskInId); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); |
|
|
|
|
if (taskOutId !=null ){ |
|
|
|
|
log.info("有出库任务在执行,无法下发入库任务:"+taskOutId); |
|
|
|
|
if (taskOutId != null) { |
|
|
|
|
log.info("有出库任务在执行,无法下发入库任务:" + taskOutId); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -802,7 +843,7 @@ public class PlcEventTask { |
|
|
|
|
String toLayer = baseLocation.getLayer(); |
|
|
|
|
String toColumn = baseLocation.getLocationColumn(); |
|
|
|
|
String toRow = baseLocation.getLocationRow(); |
|
|
|
|
log.info("单号:"+taskId+"--> 请求入库,入库排层列:"+toRow+toLayer+toColumn); |
|
|
|
|
log.info("单号:" + taskId + "--> 请求入库,入库排层列:" + toRow + toLayer + toColumn); |
|
|
|
|
//获取堆垛机
|
|
|
|
|
WcsPlcConnectQueryBo plcConnect = new WcsPlcConnectQueryBo(); |
|
|
|
|
plcConnect.setDevType("1"); |
|
|
|
|
@ -815,28 +856,28 @@ public class PlcEventTask { |
|
|
|
|
|
|
|
|
|
List<WcsPlcProperty> propertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(stkPlcId); |
|
|
|
|
String plcTaskId = ""; |
|
|
|
|
String taskIdvalueType =""; |
|
|
|
|
String taskIdvalueType = ""; |
|
|
|
|
String plcToRow = ""; |
|
|
|
|
String toRowValueType=""; |
|
|
|
|
String toRowValueType = ""; |
|
|
|
|
String plcToColumn = ""; |
|
|
|
|
String toColumnValueType = ""; |
|
|
|
|
String plcToLayer = ""; |
|
|
|
|
String toLayerValueType=""; |
|
|
|
|
String toLayerValueType = ""; |
|
|
|
|
|
|
|
|
|
String plcPlatform=""; |
|
|
|
|
String plcPlatformValueType=""; |
|
|
|
|
String plcPlatform = ""; |
|
|
|
|
String plcPlatformValueType = ""; |
|
|
|
|
|
|
|
|
|
String plcOrderType = ""; |
|
|
|
|
String plcOrderTypeValue = ""; |
|
|
|
|
|
|
|
|
|
//堆垛机完成状态
|
|
|
|
|
String readfinish =""; |
|
|
|
|
String readfinishValueType =""; |
|
|
|
|
String readfinish = ""; |
|
|
|
|
String readfinishValueType = ""; |
|
|
|
|
|
|
|
|
|
String stkAutoManual=""; |
|
|
|
|
String stkGround=""; |
|
|
|
|
String stkidle=""; |
|
|
|
|
String stkRun=""; |
|
|
|
|
String stkAutoManual = ""; |
|
|
|
|
String stkGround = ""; |
|
|
|
|
String stkidle = ""; |
|
|
|
|
String stkRun = ""; |
|
|
|
|
|
|
|
|
|
for (WcsPlcProperty stkProperty : propertyList) { |
|
|
|
|
//获取要堆垛机要写入的点位
|
|
|
|
|
@ -854,24 +895,23 @@ public class PlcEventTask { |
|
|
|
|
toLayerValueType = stkProperty.getValueType(); |
|
|
|
|
} 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")) { |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
else if (stkProperty.getPointType().equals("10")) { |
|
|
|
|
readfinishValueType = stkProperty.getValueType(); |
|
|
|
|
} else if (stkProperty.getPointType().equals("10")) { |
|
|
|
|
//等于1时堆垛机自动,等于0时堆垛机手动
|
|
|
|
|
stkAutoManual = stkProperty.getAddress(); |
|
|
|
|
}else if (stkProperty.getPointType().equals("11")) { |
|
|
|
|
} else if (stkProperty.getPointType().equals("11")) { |
|
|
|
|
//等于1时地面柜自动,等于0时地面柜手动
|
|
|
|
|
stkGround = stkProperty.getAddress(); |
|
|
|
|
}else if (stkProperty.getPointType().equals("12")) { |
|
|
|
|
} else if (stkProperty.getPointType().equals("12")) { |
|
|
|
|
//等于1时堆垛机空闲,等于0时堆垛机正忙
|
|
|
|
|
stkidle = stkProperty.getAddress(); |
|
|
|
|
}else if (stkProperty.getPointType().equals("13")) { |
|
|
|
|
} else if (stkProperty.getPointType().equals("13")) { |
|
|
|
|
//等于1时堆垛机已激活(运行)
|
|
|
|
|
stkRun = stkProperty.getAddress(); |
|
|
|
|
} |
|
|
|
|
@ -881,30 +921,30 @@ public class PlcEventTask { |
|
|
|
|
if (pointMap.containsKey(stkRun)) { |
|
|
|
|
stkRunV = Boolean.valueOf(pointMap.get(stkRun).toString()); |
|
|
|
|
} |
|
|
|
|
log.info("堆垛机运行状态:"+stkRunV); |
|
|
|
|
if (!stkRunV){ |
|
|
|
|
log.info(taskId+"请求入库时,堆垛机尚未运行"); |
|
|
|
|
log.info("堆垛机运行状态:" + stkRunV); |
|
|
|
|
if (!stkRunV) { |
|
|
|
|
log.info(taskId + "请求入库时,堆垛机尚未运行"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Boolean stkAutoManualV=null; |
|
|
|
|
Boolean stkAutoManualV = null; |
|
|
|
|
if (pointMap.containsKey(stkAutoManual)) { |
|
|
|
|
stkAutoManualV = Boolean.valueOf(pointMap.get(stkAutoManual).toString()); |
|
|
|
|
} |
|
|
|
|
log.info(taskId+"堆垛机自动状态:"+stkAutoManualV); |
|
|
|
|
if(!stkAutoManualV ){ |
|
|
|
|
log.info(taskId+"请求入库时,堆垛机手动状态"); |
|
|
|
|
log.info(taskId + "堆垛机自动状态:" + stkAutoManualV); |
|
|
|
|
if (!stkAutoManualV) { |
|
|
|
|
log.info(taskId + "请求入库时,堆垛机手动状态"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Boolean stkGroundV= false; |
|
|
|
|
Boolean stkGroundV = false; |
|
|
|
|
if (pointMap.containsKey(stkGround)) { |
|
|
|
|
stkGroundV = Boolean.valueOf(pointMap.get(stkGround).toString()); |
|
|
|
|
} |
|
|
|
|
log.info(taskId+"地面柜自动状态:"+stkGroundV); |
|
|
|
|
if(!stkGroundV){ |
|
|
|
|
log.info(taskId+"请求入库时,堆垛机地面柜手动状态"); |
|
|
|
|
log.info(taskId + "地面柜自动状态:" + stkGroundV); |
|
|
|
|
if (!stkGroundV) { |
|
|
|
|
log.info(taskId + "请求入库时,堆垛机地面柜手动状态"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -912,14 +952,14 @@ public class PlcEventTask { |
|
|
|
|
if (pointMap.containsKey(stkidle)) { |
|
|
|
|
stkidleV = Boolean.valueOf(pointMap.get(stkidle).toString()); |
|
|
|
|
} |
|
|
|
|
log.info(taskId+"堆垛机是状态:"+stkidleV); |
|
|
|
|
log.info(taskId + "堆垛机是状态:" + stkidleV); |
|
|
|
|
//1空闲 0繁忙
|
|
|
|
|
if(!stkidleV){ |
|
|
|
|
log.info(taskId+"请求入库时,堆垛机繁忙"); |
|
|
|
|
if (!stkidleV) { |
|
|
|
|
log.info(taskId + "请求入库时,堆垛机繁忙"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//给堆垛机写命令
|
|
|
|
|
//给堆垛机写命令
|
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
Map<String, Object> plcTaskIdMap = new HashMap<>(1); |
|
|
|
|
plcTaskIdMap.put(taskIdvalueType, taskId); |
|
|
|
|
@ -940,24 +980,24 @@ public class PlcEventTask { |
|
|
|
|
|
|
|
|
|
//入库起始站台
|
|
|
|
|
Map<String, Object> plcPlatformMap = new HashMap<>(1); |
|
|
|
|
plcPlatformMap.put(plcPlatformValueType,reqLayer); |
|
|
|
|
allMap.put(plcPlatform,plcPlatformMap); |
|
|
|
|
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(taskId+"请求入库:任务下发之前"+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); |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisReqWare + taskId, taskId, 24, TimeUnit.HOURS); |
|
|
|
|
//请求分配任务ID dps
|
|
|
|
|
redisTemplate.delete(RedisConstant.redisContainer+taskId); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisContainer + taskId); |
|
|
|
|
return true; |
|
|
|
|
}else { |
|
|
|
|
log.info(taskId+"请求入库任务下发失败"); |
|
|
|
|
} else { |
|
|
|
|
log.info(taskId + "请求入库任务下发失败"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|