|
|
|
@ -1,6 +1,8 @@ |
|
|
|
package com.shkj.wcs.plc; |
|
|
|
package com.shkj.wcs.plc; |
|
|
|
|
|
|
|
|
|
|
|
import com.shkj.common.constant.RedisConstant; |
|
|
|
import com.shkj.common.constant.RedisConstant; |
|
|
|
|
|
|
|
import com.shkj.common.core.domain.Result; |
|
|
|
|
|
|
|
import com.shkj.common.enums.BusinessType; |
|
|
|
import com.shkj.plc.sdk.device.PlcOperate; |
|
|
|
import com.shkj.plc.sdk.device.PlcOperate; |
|
|
|
import com.shkj.system.service.ISysParameterService; |
|
|
|
import com.shkj.system.service.ISysParameterService; |
|
|
|
import com.shkj.wcs.bo.WcsPlcConnectQueryBo; |
|
|
|
import com.shkj.wcs.bo.WcsPlcConnectQueryBo; |
|
|
|
@ -10,8 +12,16 @@ import com.shkj.wcs.mapper.WcsPlcConnectMapper; |
|
|
|
import com.shkj.wcs.service.IWcsPlcConnectService; |
|
|
|
import com.shkj.wcs.service.IWcsPlcConnectService; |
|
|
|
import com.shkj.wcs.service.IWcsPlcPropertyService; |
|
|
|
import com.shkj.wcs.service.IWcsPlcPropertyService; |
|
|
|
import com.shkj.wcs.third.rcs.RCSUtil; |
|
|
|
import com.shkj.wcs.third.rcs.RCSUtil; |
|
|
|
|
|
|
|
import com.shkj.wcs.third.workbinWcs.WCSUtil; |
|
|
|
|
|
|
|
import com.shkj.wcs.third.workbinWcs.dto.WCSQueryTaskStatusBody; |
|
|
|
|
|
|
|
import com.shkj.wcs.third.workbinWcs.dto.WcsIncomingTaskRequestBody; |
|
|
|
|
|
|
|
import com.shkj.wcs.vo.TaskStatusBody; |
|
|
|
import com.shkj.wcs.vo.WcsPlcConnectVo; |
|
|
|
import com.shkj.wcs.vo.WcsPlcConnectVo; |
|
|
|
|
|
|
|
import com.shkj.wcs.vo.WcsResponseVo; |
|
|
|
|
|
|
|
import com.shkj.wms.enums.BusinTaskTypeEnum; |
|
|
|
|
|
|
|
import com.shkj.wms.enums.TaskTypeEnum; |
|
|
|
import com.shkj.wms.utils.JsonUtil; |
|
|
|
import com.shkj.wms.utils.JsonUtil; |
|
|
|
|
|
|
|
import com.shkj.wms.vo.PlanOrderLocationVo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
@ -22,6 +32,7 @@ import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
|
|
|
|
|
|
|
|
import com.shkj.plc.sdk.device.PLCReadAndWrite; |
|
|
|
import com.shkj.plc.sdk.device.PLCReadAndWrite; |
|
|
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -52,7 +63,10 @@ public class PlcEventTask { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
PlcInit plcInit; |
|
|
|
PlcInit plcInit; |
|
|
|
|
|
|
|
|
|
|
|
//@Scheduled(fixedDelay = 5000)
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
WCSUtil wcsUtil; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(fixedDelay = 5000) |
|
|
|
public void init() { |
|
|
|
public void init() { |
|
|
|
//查询需要连接的PLC,初始化连接对象
|
|
|
|
//查询需要连接的PLC,初始化连接对象
|
|
|
|
List<WcsPlcConnectVo> plcList =(List<WcsPlcConnectVo>) redisTemplate.opsForValue().get(RedisConstant.redisPlcListConnect); |
|
|
|
List<WcsPlcConnectVo> plcList =(List<WcsPlcConnectVo>) redisTemplate.opsForValue().get(RedisConstant.redisPlcListConnect); |
|
|
|
@ -74,13 +88,13 @@ public class PlcEventTask { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//输送线心跳
|
|
|
|
//输送线心跳
|
|
|
|
//@Scheduled(fixedDelay = 4000)
|
|
|
|
@Scheduled(fixedDelay = 4000) |
|
|
|
public void writePlcheartbeatDps() { |
|
|
|
public void writePlcheartbeatDps() { |
|
|
|
//根据连接的plcId获取属性
|
|
|
|
//根据连接的plcId获取属性
|
|
|
|
PlcOperate plcOperate = plcInit.getPlcOperate_dps(); |
|
|
|
PlcOperate plcOperate = plcInit.getPlcOperate_dps(); |
|
|
|
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); |
|
|
|
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); |
|
|
|
Map<String, Object> readPointMap = new HashMap<>(); |
|
|
|
Map<String, Object> readPointMap = new HashMap<>(); |
|
|
|
String heartbeat = "DB320.0.0"; |
|
|
|
String heartbeat = "DB5100"; |
|
|
|
readPointMap.put(heartbeat, "Boolean"); |
|
|
|
readPointMap.put(heartbeat, "Boolean"); |
|
|
|
Map<String, Object> pointMap = plcReadAndWrite.readPlcData(plcOperate, JsonUtil.toJSONString(readPointMap)); |
|
|
|
Map<String, Object> pointMap = plcReadAndWrite.readPlcData(plcOperate, JsonUtil.toJSONString(readPointMap)); |
|
|
|
|
|
|
|
|
|
|
|
@ -143,8 +157,7 @@ public class PlcEventTask { |
|
|
|
if (propertyList == null || propertyList.size() == 0) { |
|
|
|
if (propertyList == null || propertyList.size() == 0) { |
|
|
|
propertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(plcId); |
|
|
|
propertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(plcId); |
|
|
|
} |
|
|
|
} |
|
|
|
//任务ID
|
|
|
|
|
|
|
|
Long taskId = 0L; |
|
|
|
|
|
|
|
// 设备类型:2输送线 1 堆垛机
|
|
|
|
// 设备类型:2输送线 1 堆垛机
|
|
|
|
switch (conn.getDevType()) { |
|
|
|
switch (conn.getDevType()) { |
|
|
|
//输送线
|
|
|
|
//输送线
|
|
|
|
@ -159,169 +172,269 @@ public class PlcEventTask { |
|
|
|
|
|
|
|
|
|
|
|
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 { |
|
|
|
try { |
|
|
|
} catch (Exception e) { |
|
|
|
/** |
|
|
|
log.error("dpsRealTimeTask:" + e.getMessage()); |
|
|
|
* 请求入库 |
|
|
|
} |
|
|
|
*/ |
|
|
|
} |
|
|
|
//BCR01请求序列号
|
|
|
|
|
|
|
|
String reqInSeria = ""; |
|
|
|
/** |
|
|
|
|
|
|
|
* 输送线请求入库 |
|
|
|
//BCR01条码
|
|
|
|
* |
|
|
|
String reqInBarcod = ""; |
|
|
|
* @param taskId |
|
|
|
//BCR01条码数据类型
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
//BCR01外形检测
|
|
|
|
public Boolean dpsTask(Long taskId, Integer reqLayer) { |
|
|
|
String reqInLength = ""; |
|
|
|
|
|
|
|
|
|
|
|
//下发任务时,先查询是否有正在执行的入库任务或出库任务,如果有,则不下发入库任务
|
|
|
|
//请求入库返回序列号
|
|
|
|
Object taskInId = redisTemplate.opsForValue().get(RedisConstant.redisTaskIn); |
|
|
|
String reqInCfmSeria = ""; |
|
|
|
if (taskInId != null) { |
|
|
|
String reqInCfmSeriaVt = ""; |
|
|
|
log.info("有入库任务在执行,无法下发入库任务:" + taskInId); |
|
|
|
|
|
|
|
return false; |
|
|
|
//请求入库返回条码
|
|
|
|
} |
|
|
|
String reqInCfmBarcod= ""; |
|
|
|
|
|
|
|
String reqInCfmBarcodVt= ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//返回去向
|
|
|
|
|
|
|
|
String reqInDest = ""; |
|
|
|
|
|
|
|
String reqInDestVt= ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 空托 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
//空托申请
|
|
|
|
|
|
|
|
String reqEmpty = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//空托确认
|
|
|
|
|
|
|
|
String reqCfm = ""; |
|
|
|
|
|
|
|
String reqCfmVt = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 出口上报 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
//出口上报请求序列号
|
|
|
|
|
|
|
|
String rptOutSeria = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//出口上报条码
|
|
|
|
|
|
|
|
String rptOutBarcod = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//出口上报确认序列号
|
|
|
|
|
|
|
|
String rptOutCfmSeria = ""; |
|
|
|
|
|
|
|
String rptOutCfmSeriaVt = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//出口上报条码确认
|
|
|
|
|
|
|
|
String rptOutCfmBarcod= ""; |
|
|
|
|
|
|
|
String rptOutCfmBarcodVt= ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//出口上报返回信息
|
|
|
|
|
|
|
|
String retOut = ""; |
|
|
|
|
|
|
|
String retOutVt= ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 出入库切换 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
//出入库切换
|
|
|
|
|
|
|
|
String inOutSwit = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//出入库切换返回
|
|
|
|
|
|
|
|
String retInOutSwit = ""; |
|
|
|
|
|
|
|
String retInOutSwitVt = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 叠盘机 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
//叠盘机完成
|
|
|
|
|
|
|
|
String stk = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//叠盘机返回
|
|
|
|
|
|
|
|
String retStk = ""; |
|
|
|
|
|
|
|
String retStkVt = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (WcsPlcProperty plcProperty : propertyList) { |
|
|
|
|
|
|
|
String pointType = plcProperty.getPointType(); |
|
|
|
|
|
|
|
//请求分配
|
|
|
|
|
|
|
|
if (pointType.equals("reqInSeria")) { |
|
|
|
|
|
|
|
reqInSeria = plcProperty.getAddress(); |
|
|
|
|
|
|
|
} else if (pointType.equals("reqInBarcod")) { |
|
|
|
|
|
|
|
reqInBarcod = plcProperty.getAddress(); |
|
|
|
|
|
|
|
} else if (pointType.equals("reqInLength")) { |
|
|
|
|
|
|
|
reqInLength = plcProperty.getAddress(); |
|
|
|
|
|
|
|
reqInLength = plcProperty.getPointType(); |
|
|
|
|
|
|
|
} else if (pointType.equals("reqInCfmSeria")) { |
|
|
|
|
|
|
|
reqInCfmSeria = plcProperty.getAddress(); |
|
|
|
|
|
|
|
reqInCfmSeriaVt = plcProperty.getPointType(); |
|
|
|
|
|
|
|
} else if (pointType.equals("reqInCfmBarcod")) { |
|
|
|
|
|
|
|
reqInCfmBarcod = plcProperty.getAddress(); |
|
|
|
|
|
|
|
reqInCfmBarcodVt = plcProperty.getPointType(); |
|
|
|
|
|
|
|
} else if (pointType.equals("reqInDest")) { |
|
|
|
|
|
|
|
reqInDest = plcProperty.getAddress(); |
|
|
|
|
|
|
|
reqInDestVt = plcProperty.getPointType(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (pointType.equals("reqEmpty")) { |
|
|
|
|
|
|
|
reqEmpty = plcProperty.getAddress(); |
|
|
|
|
|
|
|
} else if (pointType.equals("reqCfm")) { |
|
|
|
|
|
|
|
reqCfm = plcProperty.getAddress(); |
|
|
|
|
|
|
|
reqCfmVt = plcProperty.getPointType(); |
|
|
|
|
|
|
|
} else if (pointType.equals("rptOutSeria")) { |
|
|
|
|
|
|
|
rptOutSeria = plcProperty.getAddress(); |
|
|
|
|
|
|
|
} else if (pointType.equals("rptOutBarcod")) { |
|
|
|
|
|
|
|
rptOutBarcod = plcProperty.getAddress(); |
|
|
|
|
|
|
|
} else if (pointType.equals("rptOutCfmSeria")) { |
|
|
|
|
|
|
|
rptOutCfmSeria = plcProperty.getAddress(); |
|
|
|
|
|
|
|
rptOutCfmSeriaVt = plcProperty.getPointType(); |
|
|
|
|
|
|
|
} else if (pointType.equals("rptOutCfmBarcod")) { |
|
|
|
|
|
|
|
rptOutCfmBarcod = plcProperty.getAddress(); |
|
|
|
|
|
|
|
rptOutCfmBarcodVt = plcProperty.getPointType(); |
|
|
|
|
|
|
|
} else if (pointType.equals("retOut")) { |
|
|
|
|
|
|
|
retOut = plcProperty.getAddress(); |
|
|
|
|
|
|
|
retOutVt = plcProperty.getPointType(); |
|
|
|
|
|
|
|
} else if (pointType.equals("inOutSwit")) { |
|
|
|
|
|
|
|
inOutSwit = plcProperty.getAddress(); |
|
|
|
|
|
|
|
} else if (pointType.equals("retInOutSwit")) { |
|
|
|
|
|
|
|
retInOutSwit = plcProperty.getAddress(); |
|
|
|
|
|
|
|
retInOutSwitVt = plcProperty.getPointType(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WcsPlcConnectQueryBo plcConnect = new WcsPlcConnectQueryBo(); |
|
|
|
|
|
|
|
plcConnect.setDevType("1"); |
|
|
|
|
|
|
|
WcsPlcConnectVo wcsPlcConnectVo = wcsPlcConnectMapper.selectPlcConnectBydevType(plcConnect); |
|
|
|
|
|
|
|
Long stkPlcId = wcsPlcConnectVo.getId(); |
|
|
|
|
|
|
|
PlcOperate stkOperate = plcInit.getPlcOperateByIp(wcsPlcConnectVo.getPlcIp()); |
|
|
|
|
|
|
|
String pointTables = wcsPlcConnectVo.getPointTables(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> pointMap = plcReadAndWrite.readPlcData(stkOperate, pointTables); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<WcsPlcProperty> propertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(stkPlcId); |
|
|
|
|
|
|
|
String plcTaskId = ""; |
|
|
|
|
|
|
|
String taskIdvalueType = ""; |
|
|
|
|
|
|
|
String plcToRow = ""; |
|
|
|
|
|
|
|
String toRowValueType = ""; |
|
|
|
|
|
|
|
String plcToColumn = ""; |
|
|
|
|
|
|
|
String toColumnValueType = ""; |
|
|
|
|
|
|
|
String plcToLayer = ""; |
|
|
|
|
|
|
|
String toLayerValueType = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String plcPlatform = ""; |
|
|
|
|
|
|
|
String plcPlatformValueType = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String plcOrderType = ""; |
|
|
|
|
|
|
|
String plcOrderTypeValue = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//堆垛机完成状态
|
|
|
|
|
|
|
|
String readfinish = ""; |
|
|
|
|
|
|
|
String readfinishValueType = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String stkAutoManual = ""; |
|
|
|
|
|
|
|
String stkGround = ""; |
|
|
|
|
|
|
|
String stkidle = ""; |
|
|
|
|
|
|
|
String stkRun = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (WcsPlcProperty stkProperty : propertyList) { |
|
|
|
|
|
|
|
//获取要堆垛机要写入的点位
|
|
|
|
|
|
|
|
if (stkProperty.getPointType().equals("101")) { |
|
|
|
|
|
|
|
plcTaskId = stkProperty.getAddress(); |
|
|
|
|
|
|
|
taskIdvalueType = stkProperty.getValueType(); |
|
|
|
|
|
|
|
} else if (stkProperty.getPointType().equals("108")) { |
|
|
|
|
|
|
|
plcToRow = stkProperty.getAddress(); |
|
|
|
|
|
|
|
toRowValueType = stkProperty.getValueType(); |
|
|
|
|
|
|
|
} else if (stkProperty.getPointType().equals("109")) { |
|
|
|
|
|
|
|
plcToColumn = stkProperty.getAddress(); |
|
|
|
|
|
|
|
toColumnValueType = stkProperty.getValueType(); |
|
|
|
|
|
|
|
} else if (stkProperty.getPointType().equals("110")) { |
|
|
|
|
|
|
|
plcToLayer = stkProperty.getAddress(); |
|
|
|
|
|
|
|
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")) { |
|
|
|
|
|
|
|
readfinish = stkProperty.getAddress(); |
|
|
|
|
|
|
|
readfinishValueType = stkProperty.getValueType(); |
|
|
|
|
|
|
|
} else if (stkProperty.getPointType().equals("10")) { |
|
|
|
|
|
|
|
//等于1时堆垛机自动,等于0时堆垛机手动
|
|
|
|
|
|
|
|
stkAutoManual = stkProperty.getAddress(); |
|
|
|
|
|
|
|
} else if (stkProperty.getPointType().equals("11")) { |
|
|
|
|
|
|
|
//等于1时地面柜自动,等于0时地面柜手动
|
|
|
|
|
|
|
|
stkGround = stkProperty.getAddress(); |
|
|
|
|
|
|
|
} else if (stkProperty.getPointType().equals("12")) { |
|
|
|
|
|
|
|
//等于1时堆垛机空闲,等于0时堆垛机正忙
|
|
|
|
|
|
|
|
stkidle = stkProperty.getAddress(); |
|
|
|
|
|
|
|
} else if (stkProperty.getPointType().equals("13")) { |
|
|
|
|
|
|
|
//等于1时堆垛机已激活(运行)
|
|
|
|
|
|
|
|
stkRun = stkProperty.getAddress(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//扫码处入库申请
|
|
|
|
|
|
|
|
if (pointMap.containsKey(reqInSeria) && Boolean.valueOf(pointMap.get(reqInSeria).toString())) { |
|
|
|
Boolean stkRunV = false; |
|
|
|
//读取请求序列号内容
|
|
|
|
if (pointMap.containsKey(stkRun)) { |
|
|
|
Integer bCR01SeriaV = (Integer) pointMap.get(reqInSeria); |
|
|
|
stkRunV = Boolean.valueOf(pointMap.get(stkRun).toString()); |
|
|
|
//读取托盘条码内容
|
|
|
|
} |
|
|
|
String barcodeValueOne = pointMap.get(reqInBarcod).toString(); |
|
|
|
log.info("堆垛机运行状态:" + stkRunV); |
|
|
|
log.info("扫码处入库申请时,读取的条码内容:" + barcodeValueOne); |
|
|
|
if (!stkRunV) { |
|
|
|
//根据托盘条码返回正在执行的任务号
|
|
|
|
log.info(taskId + "请求入库时,堆垛机尚未运行"); |
|
|
|
WcsIncomingTaskRequestBody body = new WcsIncomingTaskRequestBody(); |
|
|
|
return false; |
|
|
|
body.setStation(""); |
|
|
|
} |
|
|
|
body.setTaskType(TaskTypeEnum.In.getValue()); |
|
|
|
|
|
|
|
body.setBussinessType(BusinTaskTypeEnum.stockIn.getValue()); |
|
|
|
|
|
|
|
body.setTrayCode(barcodeValueOne); |
|
|
|
Boolean stkAutoManualV = null; |
|
|
|
body.setCreateDt(new Date().toString()); |
|
|
|
if (pointMap.containsKey(stkAutoManual)) { |
|
|
|
//调用agv接口查询库区状态
|
|
|
|
stkAutoManualV = Boolean.valueOf(pointMap.get(stkAutoManual).toString()); |
|
|
|
Object[] areaStatus = {}; |
|
|
|
} |
|
|
|
body.setAreaStatus(areaStatus); |
|
|
|
log.info(taskId + "堆垛机自动状态:" + stkAutoManualV); |
|
|
|
WcsResponseVo vo = wcsUtil.wcsIncomingTaskRequest(body); |
|
|
|
if (!stkAutoManualV) { |
|
|
|
log.info("扫码处入库申请wz-wcs返回:" + vo.getHeader()); |
|
|
|
log.info(taskId + "请求入库时,堆垛机手动状态"); |
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
return false; |
|
|
|
Map<String, Integer> seriaMap = new HashMap<>(1); |
|
|
|
} |
|
|
|
seriaMap.put(reqInCfmSeriaVt,bCR01SeriaV ); |
|
|
|
|
|
|
|
allMap.put(reqInCfmSeria, seriaMap); |
|
|
|
Boolean stkGroundV = false; |
|
|
|
|
|
|
|
if (pointMap.containsKey(stkGround)) { |
|
|
|
Map<String, String> barcodMap = new HashMap<>(1); |
|
|
|
stkGroundV = Boolean.valueOf(pointMap.get(stkGround).toString()); |
|
|
|
barcodMap.put(reqInCfmBarcodVt, barcodeValueOne); |
|
|
|
} |
|
|
|
allMap.put(reqInCfmBarcod, barcodMap); |
|
|
|
log.info(taskId + "地面柜自动状态:" + stkGroundV); |
|
|
|
//成功直行 失败回退
|
|
|
|
if (!stkGroundV) { |
|
|
|
if (Result.isOk(vo.getHeader().getMsgCode())) { |
|
|
|
log.info(taskId + "请求入库时,堆垛机地面柜手动状态"); |
|
|
|
Map<String, Integer> destMap = new HashMap<>(1); |
|
|
|
return false; |
|
|
|
destMap.put(reqInDestVt, 1); |
|
|
|
} |
|
|
|
allMap.put(reqInDest, destMap); |
|
|
|
|
|
|
|
} else { |
|
|
|
Boolean stkidleV = false; |
|
|
|
Map<String, Integer> destMap = new HashMap<>(1); |
|
|
|
if (pointMap.containsKey(stkidle)) { |
|
|
|
destMap.put(reqInDestVt, 2); |
|
|
|
stkidleV = Boolean.valueOf(pointMap.get(stkidle).toString()); |
|
|
|
allMap.put(reqInDest, destMap); |
|
|
|
} |
|
|
|
} |
|
|
|
log.info(taskId + "堆垛机是状态:" + stkidleV); |
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
//1空闲 0繁忙
|
|
|
|
log.info("扫码处入库申请时,给输送线写命令数据:{}",allMapJson); |
|
|
|
if (!stkidleV) { |
|
|
|
Boolean reqInBoolean = plcReadAndWrite.execWrite(plcOperate, allMapJson); |
|
|
|
log.info(taskId + "请求入库时,堆垛机繁忙"); |
|
|
|
log.info("扫码处入库申请时,写入的命令返回结果:"+reqInBoolean.toString()); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
//空托盘申请
|
|
|
|
|
|
|
|
if (pointMap.containsKey(reqEmpty) && Boolean.valueOf(pointMap.get(reqEmpty).toString())) { |
|
|
|
|
|
|
|
WcsIncomingTaskRequestBody body = new WcsIncomingTaskRequestBody(); |
|
|
|
|
|
|
|
body.setStation("空托处"); |
|
|
|
|
|
|
|
body.setTaskType(TaskTypeEnum.Out.getValue()); |
|
|
|
|
|
|
|
body.setBussinessType(BusinTaskTypeEnum.stockOut.getValue()); |
|
|
|
|
|
|
|
body.setCreateDt(new Date().toString()); |
|
|
|
|
|
|
|
//调用agv接口查询库区状态
|
|
|
|
|
|
|
|
Object[] areaStatus = {}; |
|
|
|
|
|
|
|
body.setAreaStatus(areaStatus); |
|
|
|
|
|
|
|
WcsResponseVo vo = wcsUtil.wcsIncomingTaskRequest(body); |
|
|
|
|
|
|
|
log.info("空托申请wz-wcs返回:" + vo.getHeader()); |
|
|
|
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
|
|
|
Map<String, Integer> reqMap = new HashMap<>(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Result.isOk(vo.getHeader().getMsgCode())) { |
|
|
|
|
|
|
|
reqMap.put(retOutVt,1); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
reqMap.put(retOutVt,0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
allMap.put(retOut, reqMap); |
|
|
|
|
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
|
|
|
|
log.info("空托申请时,给输送线写命令数据:{}",allMapJson); |
|
|
|
|
|
|
|
Boolean bCR01Boolean = plcReadAndWrite.execWrite(plcOperate, allMapJson); |
|
|
|
|
|
|
|
log.info("空托申请时,写入的命令返回结果:"+bCR01Boolean.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//实盘出口上报
|
|
|
|
|
|
|
|
if (pointMap.containsKey(rptOutSeria) && Boolean.valueOf(pointMap.get(rptOutSeria).toString())) { |
|
|
|
|
|
|
|
//读取序列号
|
|
|
|
|
|
|
|
Integer outSeria = (Integer) pointMap.get(rptOutSeria); |
|
|
|
|
|
|
|
//读取托盘条码内容
|
|
|
|
|
|
|
|
String barcodeValueOne = pointMap.get(rptOutBarcod).toString(); |
|
|
|
|
|
|
|
log.info("请求入库时,读取的条码内容:" + barcodeValueOne); |
|
|
|
|
|
|
|
//调用wz-wcs接口
|
|
|
|
|
|
|
|
WcsIncomingTaskRequestBody body = new WcsIncomingTaskRequestBody(); |
|
|
|
|
|
|
|
body.setStation("出口上报处"); |
|
|
|
|
|
|
|
body.setTaskType(TaskTypeEnum.In.getValue()); |
|
|
|
|
|
|
|
body.setBussinessType(BusinTaskTypeEnum.stockIn.getValue()); |
|
|
|
|
|
|
|
body.setTrayCode(barcodeValueOne); |
|
|
|
|
|
|
|
body.setCreateDt(new Date().toString()); |
|
|
|
|
|
|
|
//调用agv接口查询库区状态
|
|
|
|
|
|
|
|
Object[] areaStatus = {}; |
|
|
|
|
|
|
|
body.setAreaStatus(areaStatus); |
|
|
|
|
|
|
|
WcsResponseVo vo = wcsUtil.wcsIncomingTaskRequest(body); |
|
|
|
|
|
|
|
log.info("agv扫码处申请wz-wcs返回:" + vo.getHeader()); |
|
|
|
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
|
|
|
Map<String, Integer> seriaMap = new HashMap<>(1); |
|
|
|
|
|
|
|
seriaMap.put(rptOutCfmSeriaVt,outSeria ); |
|
|
|
|
|
|
|
allMap.put(rptOutCfmSeria, seriaMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> barcodMap = new HashMap<>(1); |
|
|
|
|
|
|
|
barcodMap.put(rptOutCfmBarcodVt, barcodeValueOne); |
|
|
|
|
|
|
|
allMap.put(rptOutCfmBarcod, barcodMap); |
|
|
|
|
|
|
|
Map<String, Integer> reqMap = new HashMap<>(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Result.isOk(vo.getHeader().getMsgCode())) { |
|
|
|
|
|
|
|
reqMap.put(reqCfmVt,1); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
reqMap.put(reqCfmVt,0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
allMap.put(reqCfm, reqMap); |
|
|
|
|
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
|
|
|
|
log.info("出口上报时,给输送线写命令数据:{}",allMapJson); |
|
|
|
|
|
|
|
Boolean rptOutBoolean = plcReadAndWrite.execWrite(plcOperate, allMapJson); |
|
|
|
|
|
|
|
log.info("出口上报时,写入的命令返回结果:"+rptOutBoolean.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//出入库切换
|
|
|
|
|
|
|
|
if (pointMap.containsKey(inOutSwit) && Boolean.valueOf(pointMap.get(inOutSwit).toString())) { |
|
|
|
|
|
|
|
WCSQueryTaskStatusBody body = new WCSQueryTaskStatusBody(); |
|
|
|
|
|
|
|
body.setDestination("叠盘机"); |
|
|
|
|
|
|
|
body.setTaskType("1"); |
|
|
|
|
|
|
|
body.setTrayType("2"); |
|
|
|
|
|
|
|
WcsResponseVo<TaskStatusBody> vo = wcsUtil.queryTaskStatus(body); |
|
|
|
|
|
|
|
log.info("扫码处入库申请wz-wcs返回:" + vo.getHeader()); |
|
|
|
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
|
|
|
Map<String, Integer> reqMap = new HashMap<>(1); |
|
|
|
|
|
|
|
if (Result.isOk(vo.getHeader().getMsgCode())) { |
|
|
|
|
|
|
|
int taskCount = vo.getBody().get(0).getTaskCount(); |
|
|
|
|
|
|
|
if (taskCount == 0){ |
|
|
|
|
|
|
|
reqMap.put(retInOutSwitVt,2); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
reqMap.put(retInOutSwitVt,1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
reqMap.put(retInOutSwitVt,1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
allMap.put(retInOutSwit, reqMap); |
|
|
|
|
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
|
|
|
|
log.info("出入库切换时,给输送线写命令数据:{}",allMapJson); |
|
|
|
|
|
|
|
Boolean inOutSwitBoolean = plcReadAndWrite.execWrite(plcOperate, allMapJson); |
|
|
|
|
|
|
|
log.info("出入库切换时,写入的命令返回结果:"+inOutSwitBoolean.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HashMap allMap = new HashMap(); |
|
|
|
} catch (Exception e) { |
|
|
|
log.info(taskId + "请求入库:任务下发之前" + JsonUtil.toJSONString(allMap)); |
|
|
|
log.error("dpsRealTimeTask:" + e.getMessage()); |
|
|
|
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
|
|
|
|
|
|
|
|
redisTemplate.delete(RedisConstant.redisContainer + taskId); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
log.info(taskId + "请求入库任务下发失败"); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|