@ -50,6 +50,7 @@ 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.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.transaction.annotation.Transactional ;
import oshi.jna.platform.mac.SystemB ;
@Slf4j
@Slf4j
@ -300,19 +301,20 @@ 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 {
String requestAddress = "" , writeTaskId = "" , valueType = "" ;
String oneAllotAddress = "" , oneAllotTaskId = "" , oneAllotTaskIdVt = "" ;
String twoAllotAddress = "" , twoAllotTaskId = "" , twoAllotTaskIdVt = "" ;
String autoAddress = "" ;
String autoAddress = "" ;
Long taskId = 0L ;
Long taskId = 0L ;
//货物高度wms的值
//货物高度wms的值
String cargoHeight = "" ;
String cargoHeight = "" ;
//托盘条码地址
//托盘条码地址
String palletAddress = "" ;
String onePalletAddress = "" , twoPalletAddress = "" ;
//请求入库
//请求入库
String request Putin = "" ;
String oneReqPutin = "" , twoReq Putin = "" ;
//任务ID
//请求入库 任务ID
String read TaskId = "" ;
String oneReqPutInTaskId = "" , twoReqPutIn TaskId = "" ;
//入库失败
//入库失败
String plcFailedWare = "" ;
String plcFailedWare = "" ;
@ -325,62 +327,93 @@ public class PlcEventTask {
String plcFailedTaskIdVT = "" ;
String plcFailedTaskIdVT = "" ;
//货位高度
//货位高度
String plcCargoHeight = "" ;
String oneHignType = "" , twoHignType = "" ;
String plcCargoHeightVT = "" ;
String oneHignTypeVT = "" , twoHignTypeVT = "" ;
String wcsErrExit = "" ;
/ * *
String wcsErrExitVT = "" ;
* 失败原因 超长 左超宽 右超宽 超高
for ( WcsPlcProperty wcsPlcProperty : propertyList ) {
* /
String oneOverlength = "" , oneLwide = "" , oneRwide = "" , oneHigh = "" ;
String twoOverlength = "" , twoLwide = "" , twoRwide = "" , twoHigh = "" ;
Boolean oneOverlengthV = false , oneLwideV = false , oneRwideV = false , oneHighV = false ;
Boolean twoOverlengthV = false , twoLwideV = false , twoRwideV = false , twoHighV = false ;
String oneWcsErrExit = "" , twoWcsErrExit = "" ;
String oneEcsErrExitVT = "" , twoWcsErrExitVT = "" ;
for ( WcsPlcProperty plcProperty : propertyList ) {
String pointType = plcProperty . getPointType ( ) ;
//请求分配
//请求分配
if ( wcsPlcProperty . getPointType ( ) . equals ( "5" ) ) {
if ( pointType . equals ( "oneAllot" ) ) {
requestAddress = wcsPlcProperty . getAddress ( ) ;
oneAllotAddress = plcProperty . getAddress ( ) ;
//任务ID
} else if ( pointType . equals ( "twoAllot" ) ) {
} else if ( wcsPlcProperty . getPointType ( ) . equals ( "6" ) ) {
twoAllotAddress = plcProperty . getAddress ( ) ;
writeTaskId = wcsPlcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "oneAllotTask" ) ) {
valueType = wcsPlcProperty . getValueType ( ) ;
oneAllotTaskId = plcProperty . getAddress ( ) ;
} else if ( wcsPlcProperty . getPointType ( ) . equals ( "10" ) ) {
oneAllotTaskId = plcProperty . getValueType ( ) ;
autoAddress = wcsPlcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "twoAllotTask" ) ) {
} else if ( wcsPlcProperty . getPointType ( ) . equals ( "7" ) ) {
twoAllotTaskId = plcProperty . getAddress ( ) ;
palletAddress = wcsPlcProperty . getAddress ( ) ;
twoAllotTaskIdVt = plcProperty . getValueType ( ) ;
} else if ( wcsPlcProperty . getPointType ( ) . equals ( "2" ) ) {
} else if ( pointType . equals ( "atuo" ) ) {
requestPutin = wcsPlcProperty . getAddress ( ) ;
autoAddress = plcProperty . getAddress ( ) ;
} else if ( wcsPlcProperty . getPointType ( ) . equals ( "21" ) ) {
} else if ( pointType . equals ( "oneInBar" ) ) {
readTaskId = wcsPlcProperty . getAddress ( ) ;
onePalletAddress = plcProperty . getAddress ( ) ;
} else if ( wcsPlcProperty . getPointType ( ) . equals ( "31" ) ) {
} else if ( pointType . equals ( "twoInBar" ) ) {
twoPalletAddress = plcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "oneReqIn" ) ) {
oneReqPutin = plcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "twoReqIn" ) ) {
twoReqPutin = plcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "oneInTaskId" ) ) {
oneReqPutInTaskId = plcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "twoInTaskId" ) ) {
twoReqPutInTaskId = plcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "oneHighType" ) ) {
//货物高度
oneHignType = plcProperty . getAddress ( ) ;
oneHignTypeVT = plcProperty . getValueType ( ) ;
} else if ( pointType . equals ( "twoHighType" ) ) {
//货物高度
//货物高度
plcCargoHeight = wcsPlcProperty . getAddress ( ) ;
twoHignType = plcProperty . getAddress ( ) ;
plcCargoHeightVT = wcsPlcProperty . getValueType ( ) ;
twoHignTypeVT = plcProperty . getValueType ( ) ;
} else if ( wcsPlcProperty . getPointType ( ) . equals ( "51" ) ) {
} else if ( pointType . equals ( "oneOverlength" ) ) {
//入库失败
oneOverlength = plcProperty . getAddress ( ) ;
plcFailedWare = wcsPlcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "oneLwide" ) ) {
plcFailedWareVT = wcsPlcProperty . getValueType ( ) ;
oneLwide = plcProperty . getAddress ( ) ;
} else if ( wcsPlcProperty . getPointType ( ) . equals ( "52" ) ) {
} else if ( pointType . equals ( "oneRwide" ) ) {
//失败原因
oneRwide = plcProperty . getAddress ( ) ;
plcFailedReason = wcsPlcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "oneHigh" ) ) {
plcFailedReasonVT = wcsPlcProperty . getValueType ( ) ;
oneHigh = plcProperty . getAddress ( ) ;
} else if ( wcsPlcProperty . getPointType ( ) . equals ( "53" ) ) {
} else if ( pointType . equals ( "twoOverlength" ) ) {
//失败任务号
twoOverlength = plcProperty . getAddress ( ) ;
plcFailedTaskId = wcsPlcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "twoLwide" ) ) {
plcFailedTaskIdVT = wcsPlcProperty . getValueType ( ) ;
twoLwide = plcProperty . getAddress ( ) ;
} else if ( wcsPlcProperty . getPointType ( ) . equals ( "36" ) ) {
} else if ( pointType . equals ( "twoRwide" ) ) {
wcsErrExit = wcsPlcProperty . getAddress ( ) ;
twoRwide = plcProperty . getAddress ( ) ;
wcsErrExitVT = wcsPlcProperty . getValueType ( ) ;
} else if ( pointType . equals ( "twoHigh" ) ) {
twoHigh = plcProperty . getAddress ( ) ;
} else if ( pointType . equals ( "ontExit" ) ) {
oneWcsErrExit = plcProperty . getAddress ( ) ;
oneEcsErrExitVT = plcProperty . getValueType ( ) ;
} else if ( pointType . equals ( "twoExit" ) ) {
twoWcsErrExit = plcProperty . getAddress ( ) ;
twoWcsErrExitVT = plcProperty . getValueType ( ) ;
}
}
}
}
// 电柜状态是否是自动,如果是自动则继续流程
// 电柜状态是否是自动,如果是自动则继续流程
if ( pointMap . containsKey ( autoAddress ) & & Boolean . valueOf ( pointMap . get ( autoAddress ) . toString ( ) ) ) {
if ( pointMap . containsKey ( autoAddress ) & & Boolean . valueOf ( pointMap . get ( autoAddress ) . toString ( ) ) ) {
//是否请求分配
//1楼 是否请求分配
if ( pointMap . containsKey ( requestAddress ) & & Boolean . valueOf ( pointMap . get ( requestAddress ) . toString ( ) ) ) {
if ( pointMap . containsKey ( oneAllo tAddress) & & Boolean . valueOf ( pointMap . get ( oneAllo tAddress) . toString ( ) ) ) {
//请求入库分配时,判断是否有正在执行的出库任务,如果有则返回
//请求入库分配时,判断是否有正在执行的出库任务,如果有则返回
Object taskOutId = redisTemplate . opsForValue ( ) . get ( RedisConstant . redisTaskOut ) ;
Object taskOutId = redisTemplate . opsForValue ( ) . get ( RedisConstant . redisTaskOut ) ;
if ( taskOutId ! = null ) {
if ( taskOutId ! = null ) {
log . error ( "入库分配请求时,有出库任务,不可分配,返回" ) ;
log . info ( "1楼 入库分配请求时,有出库任务,不可分配,返回" ) ;
return ;
return ;
}
}
//读取托盘条码内容
//读取托盘条码内容
String barcodeValue = pointMap . get ( p alletAddress) . toString ( ) ;
String barcodeValue = pointMap . get ( oneP alletAddress) . toString ( ) ;
//根据托盘条码返回正在执行的任务号
//根据托盘条码返回正在执行的任务号
Result < PlanOrderLocationVo > orderResult = iBusinOutInPlanService . getOrderNoByContainerCode ( barcodeValue , "in" ) ;
Result < PlanOrderLocationVo > orderResult = iBusinOutInPlanService . getOrderNoByContainerCode ( barcodeValue , "in" ) ;
log . info ( "根据条码获取的任务信息:" + orderResult . getData ( ) ) ;
log . info ( "根据条码获取的任务信息:" + orderResult . getData ( ) ) ;
@ -393,67 +426,142 @@ public class PlcEventTask {
log . error ( "获取任务信息失败:" + orderResult . getMsg ( ) + "托盘条码:" + barcodeValue ) ;
log . error ( "获取任务信息失败:" + orderResult . getMsg ( ) + "托盘条码:" + barcodeValue ) ;
//回填任务号
//回填任务号
Map < String , Boolean > writeMap = new HashMap < > ( 1 ) ;
Map < String , Boolean > writeMap = new HashMap < > ( 1 ) ;
writeMap . put ( w csErrExitVT, true ) ;
writeMap . put ( oneE csErrExitVT, true ) ;
Map < String , Object > allMap = new HashMap < > ( 1 ) ;
Map < String , Object > allMap = new HashMap < > ( 1 ) ;
allMap . put ( w csErrExit, writeMap ) ;
allMap . put ( oneW csErrExit, writeMap ) ;
Boolean errBoolean = plcReadAndWrite . execWrite ( plcOperate , JsonUtil . toJSONString ( allMap ) ) ;
Boolean errBoolean = plcReadAndWrite . execWrite ( plcOperate , JsonUtil . toJSONString ( allMap ) ) ;
if ( errBoolean ) {
if ( errBoolean ) {
log . info ( "获取单号入库失败,写入点位成功{}" , allMap ) ;
log . info ( "1楼 获取单号入库失败,写入点位成功{}" , allMap ) ;
} else {
} else {
log . info ( "获取单号入库失败,写入点位失败{}" , allMap ) ;
log . info ( "1楼 获取单号入库失败,写入点位失败{}" , allMap ) ;
}
}
}
}
log . info ( "入库分配任务ID:" + taskId + "条码号:" + barcodeValue ) ;
log . info ( "1楼 入库分配任务ID:" + taskId + "条码号:" + barcodeValue ) ;
log . info ( "入库分配货位类型:" + cargoHeight ) ;
log . info ( "1楼 入库分配货位类型:" + cargoHeight ) ;
String redisBarcode = String . valueOf ( redisTemplate . opsForValue ( ) . get ( RedisConstant . redisContainer + taskId ) ) ;
String redisBarcode = String . valueOf ( redisTemplate . opsForValue ( ) . get ( RedisConstant . redisContainer + taskId ) ) ;
//根据扫码的托盘,判断是否已经下任务了
//根据扫码的托盘,判断是否已经下任务了
if ( taskId ! = 0L & & ! redisBarcode . equals ( barcodeValue ) ) {
if ( taskId ! = 0L & & ! redisBarcode . equals ( barcodeValue ) ) {
//回填任务号
//回填任务号
Map < String , Long > writeMap = new HashMap < > ( 1 ) ;
Map < String , Long > writeMap = new HashMap < > ( 1 ) ;
writeMap . put ( valueType , taskId ) ;
writeMap . put ( oneAllotTaskIdVt , taskId ) ;
Map < String , Object > allMap = new HashMap < > ( 1 ) ;
Map < String , Object > allMap = new HashMap < > ( 1 ) ;
allMap . put ( write TaskId, writeMap ) ;
allMap . put ( oneAllot TaskId, writeMap ) ;
Map < String , String > cargoHeightMap = new HashMap < > ( 1 ) ;
Map < String , String > cargoHeightMap = new HashMap < > ( 1 ) ;
cargoHeightMap . put ( plcCargoHeightVT , cargoHeight ) ;
cargoHeightMap . put ( oneHignTypeVT , cargoHeight ) ;
allMap . put ( plcCargoHeight , cargoHeightMap ) ;
allMap . put ( oneHignType , cargoHeightMap ) ;
log . info ( "按下入库按钮时,给输送线写命令数据:{}" + allMap ) ;
log . info ( "1楼按下入库按钮时,给输送线写命令数据:{}" + allMap ) ;
//获取redis中的出库下发时间,判断请求入库的时间与其之间的时间间隔,如果小于10秒,则不给输送线写命令
Boolean taskBoolean = plcReadAndWrite . execWrite ( plcOperate , JsonUtil . toJSONString ( allMap ) ) ;
long seconds = 15L ;
if ( taskBoolean ) {
Object redisTaskTime = redisTemplate . opsForValue ( ) . get ( RedisConstant . redisTaskTime ) ;
//分配任务成功时,记录已下发入库任务,不可在下发出库或入库任务
if ( redisTaskTime ! = null ) {
redisTemplate . opsForValue ( ) . set ( RedisConstant . redisTaskIn , taskId ) ;
Date dateTask = ( Date ) redisTaskTime ;
//更改入库计划为1
Date nowDate = DateUtils . getNowDate ( ) ;
iBusinOutInPlanService . updPlanStatus ( taskId , PlanStatusEnum . DOING . getValue ( ) ) ;
long diffDate = nowDate . getTime ( ) - dateTask . getTime ( ) ;
seconds = diffDate / 1000 ;
log . info ( "上一个任务下发时间:" + dateTask + " 入库请求下发时间:" + nowDate + "间隔秒数:" + seconds ) ;
}
}
//改为入库ID
redisTemplate . opsForValue ( ) . set ( RedisConstant . redisContainer , taskId , 2 , TimeUnit . SECONDS ) ;
if ( seconds < 10 ) {
}
log . info ( "输送线请求分配任务时,距离出库任务的时间小于10秒:" + redisTaskTime + "--->" + DateUtils . getNowDate ( ) ) ;
}
//2楼是否请求分配
if ( pointMap . containsKey ( twoAllotAddress ) & & Boolean . valueOf ( pointMap . get ( twoAllotAddress ) . toString ( ) ) ) {
//请求入库分配时,判断是否有正在执行的出库任务,如果有则返回
Object taskOutId = redisTemplate . opsForValue ( ) . get ( RedisConstant . redisTaskOut ) ;
if ( taskOutId ! = null ) {
log . info ( "2楼入库分配请求时,有出库任务,不可分配,返回" ) ;
return ;
}
//TODO 需要判断1楼是否有入库任务
//读取托盘条码内容
String barcodeValue = pointMap . get ( twoPalletAddress ) . toString ( ) ;
//根据托盘条码返回正在执行的任务号
Result < PlanOrderLocationVo > orderResult = iBusinOutInPlanService . getOrderNoByContainerCode ( barcodeValue , "in" ) ;
log . info ( "2楼根据条码获取的任务信息:" + orderResult . getData ( ) ) ;
if ( Result . isOk ( orderResult ) ) {
PlanOrderLocationVo data = orderResult . getData ( ) ;
taskId = data . getOrderNo ( ) ;
cargoHeight = data . getType ( ) ; //获取托盘或模具类型
} else {
redisTemplate . opsForValue ( ) . set ( RedisConstant . redisPutInExeMsg + orderResult . getMsg ( ) , orderResult . getMsg ( ) ) ;
log . info ( "2楼获取任务信息失败:" + orderResult . getMsg ( ) + "托盘条码:" + barcodeValue ) ;
//回填任务号
Map < String , Boolean > writeMap = new HashMap < > ( 1 ) ;
writeMap . put ( twoWcsErrExitVT , true ) ;
Map < String , Object > allMap = new HashMap < > ( 1 ) ;
allMap . put ( twoWcsErrExit , writeMap ) ;
Boolean errBoolean = plcReadAndWrite . execWrite ( plcOperate , JsonUtil . toJSONString ( allMap ) ) ;
if ( errBoolean ) {
log . info ( "2楼获取单号入库失败,写入点位成功{}" , allMap ) ;
} else {
} else {
Boolean taskBoolean = plcReadAndWrite . execWrite ( plcOperate , JsonUtil . toJSONString ( allMap ) ) ;
log . info ( "2楼获取单号入库失败,写入点位失败{}" , allMap ) ;
if ( taskBoolean ) {
//分配任务成功时,记录已下发入库任务,不可在下发出库任务
redisTemplate . opsForValue ( ) . set ( RedisConstant . redisTaskIn , taskId ) ;
//更改入库计划为1
iBusinOutInPlanService . updPlanStatus ( taskId , PlanStatusEnum . DOING . getValue ( ) ) ;
}
//改为入库ID
redisTemplate . opsForValue ( ) . set ( RedisConstant . redisContainer , taskId , 2 , TimeUnit . SECONDS ) ;
}
}
}
}
log . info ( "2楼入库分配任务ID:" + taskId + "条码号:" + barcodeValue ) ;
log . info ( "2楼入库分配货位类型:" + cargoHeight ) ;
String redisBarcode = String . valueOf ( redisTemplate . opsForValue ( ) . get ( RedisConstant . redisContainer + taskId ) ) ;
//根据扫码的托盘,判断是否已经下任务了
if ( taskId ! = 0L & & ! redisBarcode . equals ( barcodeValue ) ) {
//回填任务号
Map < String , Long > writeMap = new HashMap < > ( 1 ) ;
writeMap . put ( twoAllotTaskIdVt , taskId ) ;
Map < String , Object > allMap = new HashMap < > ( 1 ) ;
allMap . put ( oneAllotTaskId , writeMap ) ;
Map < String , String > cargoHeightMap = new HashMap < > ( 1 ) ;
cargoHeightMap . put ( twoHignTypeVT , cargoHeight ) ;
allMap . put ( twoHignType , cargoHeightMap ) ;
log . info ( "2楼按下入库按钮时,给输送线写命令数据:{}" + allMap ) ;
Boolean taskBoolean = plcReadAndWrite . execWrite ( plcOperate , JsonUtil . toJSONString ( allMap ) ) ;
if ( taskBoolean ) {
//分配任务成功时,记录已下发入库任务,不可在下发出库任务
redisTemplate . opsForValue ( ) . set ( RedisConstant . redisTaskIn , taskId ) ;
//更改入库计划为1
iBusinOutInPlanService . updPlanStatus ( taskId , PlanStatusEnum . DOING . getValue ( ) ) ;
}
//改为入库ID
redisTemplate . opsForValue ( ) . set ( RedisConstant . redisContainer , taskId , 2 , TimeUnit . SECONDS ) ;
}
}
}
// 入库失败
//获取1楼入库失败的内容
else if ( pointMap . containsKey ( plcFailedWare ) & & Boolean . valueOf ( pointMap . get ( plcFailedWare ) . toString ( ) ) ) {
if ( pointMap . containsKey ( oneOverlength ) ) {
oneOverlengthV = Boolean . valueOf ( pointMap . get ( oneOverlength ) . toString ( ) ) ;
}
if ( pointMap . containsKey ( oneLwide ) ) {
oneLwideV = Boolean . valueOf ( pointMap . get ( oneLwide ) . toString ( ) ) ;
}
if ( pointMap . containsKey ( oneRwide ) ) {
oneRwideV = Boolean . valueOf ( pointMap . get ( oneRwide ) . toString ( ) ) ;
}
if ( pointMap . containsKey ( oneHigh ) ) {
oneHighV = Boolean . valueOf ( pointMap . get ( oneHigh ) . toString ( ) ) ;
}
if ( oneOverlengthV | | oneLwideV | | oneRwideV | | oneHighV ) {
//读取失败原因
//读取失败原因
String failedReasonValue = pointMap . get ( plcFailedReason ) . toString ( ) ;
String failedReasonValue = "" ;
log . info ( "入库失败原因:" + failedReasonValue ) ;
if ( oneOverlengthV ) {
log . info ( "入库失败状态:" + pointMap . get ( plcFailedWare ) . toString ( ) ) ;
failedReasonValue = "超长" ;
}
if ( oneLwideV ) {
failedReasonValue = "左超宽" ;
}
if ( oneRwideV ) {
failedReasonValue = "右超宽" ;
}
if ( oneHighV ) {
failedReasonValue = "超高" ;
}
log . info ( "1楼入库失败原因:" + failedReasonValue ) ;
//读取失败任务号
//读取失败任务号
Long failedTaskIdValue = Long . valueOf ( pointMap . get ( plcFailedTaskId ) . toString ( ) ) ;
Long failedTaskIdValue = Long . valueOf ( pointMap . get ( oneAllot TaskId) . toString ( ) ) ;
//根据回填入库失败原因
//根据回填入库失败原因
UpdPlanErrorBo updPlanErrorBo = new UpdPlanErrorBo ( ) ;
UpdPlanErrorBo updPlanErrorBo = new UpdPlanErrorBo ( ) ;
@ -461,52 +569,92 @@ public class PlcEventTask {
updPlanErrorBo . setOrderNo ( failedTaskIdValue ) ;
updPlanErrorBo . setOrderNo ( failedTaskIdValue ) ;
iBusinOutInPlanService . updErrMsg ( updPlanErrorBo ) ;
iBusinOutInPlanService . updErrMsg ( updPlanErrorBo ) ;
String redisFailedTaskIdValue = String . valueOf ( redisTemplate . opsForValue ( ) . get ( RedisConstant . redisDPSFailedTaskId ) ) ;
String redisFailedTaskIdValue = String . valueOf ( redisTemplate . opsForValue ( ) . get ( RedisConstant . redisDPSFailedTaskIdOne ) ) ;
log . info ( "入库失败redis任务ID:" + redisFailedTaskIdValue ) ;
log . info ( "1楼 入库失败redis任务ID:" + redisFailedTaskIdValue ) ;
log . info ( "入库失败PLC任务ID:" + failedTaskIdValue ) ;
log . info ( "1楼 入库失败PLC任务ID:" + failedTaskIdValue ) ;
//入库失败,更改入库状态为0
//入库失败,更改入库状态为0
if ( failedTaskIdValue ! = 0L & & ! redisFailedTaskIdValue . equals ( failedTaskIdValue ) ) {
if ( failedTaskIdValue ! = 0L & & ! redisFailedTaskIdValue . equals ( failedTaskIdValue ) ) {
//失败任务号
redisTemplate . opsForValue ( ) . set ( RedisConstant . redisDPSFailedTaskIdOne , failedTaskIdValue ) ;
Map < String , Long > failedTaskIdMap = new HashMap < > ( 1 ) ;
//更改入库计划3,取消
failedTaskIdMap . put ( plcFailedTaskIdVT , failedTaskIdValue ) ;
iBusinOutInPlanService . updPlanStatus ( failedTaskIdValue , PlanStatusEnum . CANCEL . getValue ( ) ) ;
Map < String , Object > faildAllMap = new HashMap < > ( 1 ) ;
//清理预占库存
faildAllMap . put ( plcFailedTaskId , failedTaskIdMap ) ;
iBusinOutInPlanService . updateSysStockByPlanOrderNo ( failedTaskIdValue . toString ( ) ) ;
}
Map < String , String > failedWareMap = new HashMap < > ( 1 ) ;
}
failedWareMap . put ( plcFailedWareVT , "FALSE" ) ;
faildAllMap . put ( plcFailedWare , failedWareMap ) ;
//获取2楼入库失败的内容
Map < String , String > reasonMap = new HashMap < > ( 1 ) ;
if ( pointMap . containsKey ( twoOverlength ) ) {
reasonMap . put ( plcFailedReasonVT , "0" ) ;
twoOverlengthV = Boolean . valueOf ( pointMap . get ( twoOverlength ) . toString ( ) ) ;
faildAllMap . put ( plcFailedReason , reasonMap ) ;
}
if ( pointMap . containsKey ( twoLwide ) ) {
Boolean faildTask = plcReadAndWrite . execWrite ( plcOperate , JsonUtil . toJSONString ( faildAllMap ) ) ;
twoLwideV = Boolean . valueOf ( pointMap . get ( twoLwide ) . toString ( ) ) ;
}
if ( faildTask ) {
redisTemplate . opsForValue ( ) . set ( RedisConstant . redisDPSFailedTaskId , failedTaskIdValue ) ;
if ( pointMap . containsKey ( twoRwide ) ) {
//1 空托盘有货报警,需要重新增加托盘的库位信息
twoRwideV = Boolean . valueOf ( pointMap . get ( twoRwide ) . toString ( ) ) ;
if ( failedReasonValue . equals ( "1" ) ) {
}
/ * WcsAddStockCallbackBo bo = new WcsAddStockCallbackBo ( ) ;
bo . setOrderNo ( failedTaskIdValue ) ;
if ( pointMap . containsKey ( twoHigh ) ) {
iBusinOutInPlanService . wcsActualAddStock ( bo ) ; * /
twoHighV = Boolean . valueOf ( pointMap . get ( twoHigh ) . toString ( ) ) ;
} else if ( failedReasonValue . equals ( "2" ) ) {
}
//低货位超高,重新分开新的库位
/ * UpdPlanLocationBo upbo = new UpdPlanLocationBo ( ) ;
if ( twoOverlengthV | | twoLwideV | | twoRwideV | | twoHighV ) {
upbo . setOrderNo ( failedTaskIdValue ) ;
//读取失败原因
iBusinOutInPlanService . repeatFindHighLocation ( upbo ) ; * /
String failedReasonValue = "" ;
}
if ( twoOverlengthV ) {
//更改入库计划3,取消
failedReasonValue = "超长" ;
iBusinOutInPlanService . updPlanStatus ( failedTaskIdValue , PlanStatusEnum . CANCEL . getValue ( ) ) ;
}
//清理预占库存
if ( twoLwideV ) {
iBusinOutInPlanService . updateSysStockByPlanOrderNo ( failedTaskIdValue . toString ( ) ) ;
failedReasonValue = "左超宽" ;
}
}
if ( twoRwideV ) {
failedReasonValue = "右超宽" ;
}
if ( twoHighV ) {
failedReasonValue = "超高" ;
}
log . info ( "2楼入库失败原因:" + failedReasonValue ) ;
//读取失败任务号
Long failedTaskIdValue = Long . valueOf ( pointMap . get ( twoAllotTaskId ) . toString ( ) ) ;
//根据回填入库失败原因
UpdPlanErrorBo updPlanErrorBo = new UpdPlanErrorBo ( ) ;
updPlanErrorBo . setErrorMsg ( failedReasonValue ) ;
updPlanErrorBo . setOrderNo ( failedTaskIdValue ) ;
iBusinOutInPlanService . updErrMsg ( updPlanErrorBo ) ;
String redisFailedTaskIdValue = String . valueOf ( redisTemplate . opsForValue ( ) . get ( RedisConstant . redisDPSFailedTaskIdTwo ) ) ;
log . info ( "2楼入库失败redis任务ID:" + redisFailedTaskIdValue ) ;
log . info ( "2楼入库失败PLC任务ID:" + failedTaskIdValue ) ;
//入库失败,更改入库状态为0
if ( failedTaskIdValue ! = 0L & & ! redisFailedTaskIdValue . equals ( failedTaskIdValue ) ) {
redisTemplate . opsForValue ( ) . set ( RedisConstant . redisDPSFailedTaskIdTwo , failedTaskIdValue ) ;
//更改入库计划3,取消
iBusinOutInPlanService . updPlanStatus ( failedTaskIdValue , PlanStatusEnum . CANCEL . getValue ( ) ) ;
//清理预占库存
iBusinOutInPlanService . updateSysStockByPlanOrderNo ( failedTaskIdValue . toString ( ) ) ;
}
}
}
}
//是否请求入库:
if ( pointMap . containsKey ( requestPutin ) & & Boolean . valueOf ( pointMap . get ( requestPutin ) . toString ( ) ) ) {
//1楼是否请求入库:
if ( pointMap . containsKey ( oneReqPutin ) & & Boolean . valueOf ( pointMap . get ( oneReqPutin ) . toString ( ) ) ) {
//请求入库,给堆垛机下发命令
//请求入库,给堆垛机下发命令
taskId = Long . valueOf ( ( String ) pointMap . get ( readTaskId ) ) ;
taskId = Long . valueOf ( ( String ) pointMap . get ( oneReqPutInTaskId ) ) ;
//从redis中验证是否已经下发任务
Long redisTaskId = ( Long ) redisTemplate . opsForValue ( ) . get ( RedisConstant . redisReqWare + taskId ) ;
if ( taskId . equals ( redisTaskId ) ) {
return ;
}
//执行dps任务,给堆垛机下发命令
dpsTask ( taskId ) ;
}
//2楼是否请求入库
if ( pointMap . containsKey ( twoReqPutin ) & & Boolean . valueOf ( pointMap . get ( twoReqPutin ) . toString ( ) ) ) {
//请求入库,给堆垛机下发命令
taskId = Long . valueOf ( ( String ) pointMap . get ( twoReqPutInTaskId ) ) ;
//从redis中验证是否已经下发任务
//从redis中验证是否已经下发任务
Long redisTaskId = ( Long ) redisTemplate . opsForValue ( ) . get ( RedisConstant . redisReqWare + taskId ) ;
Long redisTaskId = ( Long ) redisTemplate . opsForValue ( ) . get ( RedisConstant . redisReqWare + taskId ) ;
if ( taskId . equals ( redisTaskId ) ) {
if ( taskId . equals ( redisTaskId ) ) {
@ -519,10 +667,17 @@ public class PlcEventTask {
} catch ( Exception e ) {
} catch ( Exception e ) {
log . error ( "dpsRealTimeTask:" + e . getMessage ( ) ) ;
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 {
try {
if ( pointMap . isEmpty ( ) ) {
if ( pointMap . isEmpty ( ) ) {
@ -550,14 +705,10 @@ public class PlcEventTask {
taskId = Long . valueOf ( ( String ) pointMap . get ( readTaskPoint ) ) ;
taskId = Long . valueOf ( ( String ) pointMap . get ( readTaskPoint ) ) ;
}
}
// Long redisTaskId = (Long)redisTemplate.opsForValue().get(RedisConstant.redisStKTaskId + taskId);
//if (readValue !=0 ){
log . info ( "堆垛机完成出入库状态:" + readValue + "---taksID=" + taskId ) ;
log . info ( "堆垛机完成出入库状态:" + readValue + "---taksID=" + taskId ) ;
//}
//判断redis中是否已有此任务号,如果有则不再执行;
//判断redis中是否已有此任务号,如果有则不再执行;
if ( readValue = = 1 ) {
if ( readValue = = 1 ) {
Result < Boolean > booleanResult = null ;
Result < Boolean > booleanResult = null ;
//判断任务号是否是系统编号,或者是否已完成的,则给堆垛机回填完成信号是0
//判断任务号是否是系统编号,或者是否已完成的,则给堆垛机回填完成信号是0
BusinOutInPlan orderNoByOrderNo = iBusinOutInPlanService . getOrderNoByOrderNo ( taskId . toString ( ) , PlanStatusEnum . DOING . getValue ( ) ) ;
BusinOutInPlan orderNoByOrderNo = iBusinOutInPlanService . getOrderNoByOrderNo ( taskId . toString ( ) , PlanStatusEnum . DOING . getValue ( ) ) ;
@ -579,7 +730,6 @@ public class PlcEventTask {
Map < String , Object > allMap = new HashMap < > ( 1 ) ;
Map < String , Object > allMap = new HashMap < > ( 1 ) ;
allMap . put ( readfinishPoint , writeMap ) ;
allMap . put ( readfinishPoint , writeMap ) ;
if ( plcReadAndWrite . execWrite ( plcOperate , JsonUtil . toJSONString ( allMap ) ) ) {
if ( plcReadAndWrite . execWrite ( plcOperate , JsonUtil . toJSONString ( allMap ) ) ) {
//堆垛机完成状态后,把redis中的ID删除,代表此任务已经完成
//堆垛机完成状态后,把redis中的ID删除,代表此任务已经完成
Object taskInId = redisTemplate . opsForValue ( ) . get ( RedisConstant . redisTaskIn ) ;
Object taskInId = redisTemplate . opsForValue ( ) . get ( RedisConstant . redisTaskIn ) ;
Object taskOutId = redisTemplate . opsForValue ( ) . get ( RedisConstant . redisTaskOut ) ;
Object taskOutId = redisTemplate . opsForValue ( ) . get ( RedisConstant . redisTaskOut ) ;
@ -596,7 +746,6 @@ public class PlcEventTask {
log . info ( "给堆垛机下发完成信号为0,成功:" + taskId ) ;
log . info ( "给堆垛机下发完成信号为0,成功:" + taskId ) ;
//请求成功,记录已下发
//请求成功,记录已下发
// redisTemplate.opsForValue().set(RedisConstant.redisStKTaskId + taskId, taskId,24,TimeUnit.HOURS);
redisTemplate . delete ( RedisConstant . redisReqWare + taskId ) ;
redisTemplate . delete ( RedisConstant . redisReqWare + taskId ) ;
} else {
} else {
log . info ( "给堆垛机下发完成信号为0,失败:" + taskId ) ;
log . info ( "给堆垛机下发完成信号为0,失败:" + taskId ) ;
@ -610,7 +759,26 @@ public class PlcEventTask {
}
}
/ * *
* 输送线请求入库
* @param taskId
* @return
* /
public Boolean dpsTask ( Long taskId ) {
public Boolean dpsTask ( Long taskId ) {
//下发任务时,先查询是否有正在执行的入库任务或出库任务,如果有,则不下发入库任务
Object taskInId = redisTemplate . opsForValue ( ) . get ( RedisConstant . redisTaskIn ) ;
if ( taskInId ! = null ) {
log . info ( "有入库任务在执行,无法下发入库任务:" + taskInId ) ;
return false ;
}
Object taskOutId = redisTemplate . opsForValue ( ) . get ( RedisConstant . redisTaskOut ) ;
if ( taskOutId ! = null ) {
log . info ( "有出库任务在执行,无法下发入库任务:" + taskOutId ) ;
return false ;
}
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite ( ) ;
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite ( ) ;
//根据任务ID获取对应的货位信息
//根据任务ID获取对应的货位信息
Result < BaseLocation > baseLocationResult = iBusinOutInPlanService . wcsGetLocationByOrderNo ( taskId . toString ( ) ) ;
Result < BaseLocation > baseLocationResult = iBusinOutInPlanService . wcsGetLocationByOrderNo ( taskId . toString ( ) ) ;
@ -708,53 +876,45 @@ public class PlcEventTask {
}
}
}
}
Boolean stkAutoManualV = false ;
Integer stkRunV = 0 ;
if ( pointMap . containsKey ( stkAutoManual ) ) {
if ( pointMap . containsKey ( stkRun ) ) {
stkAutoManualV = Boolean . valueOf ( pointMap . get ( stkAutoManual ) . toString ( ) ) ;
stkRunV = Integer . valueOf ( pointMap . get ( stkRun ) . toString ( ) ) ;
}
Boolean stkGroundV = false ;
if ( pointMap . containsKey ( stkGround ) ) {
stkGroundV = Boolean . valueOf ( pointMap . get ( stkGround ) . toString ( ) ) ;
}
}
log . info ( "堆垛机运行状态:" + stkRunV ) ;
Boolean stkidleV = false ;
if ( stkRunV ! = 1 ) {
if ( pointMap . containsKey ( stkidle ) ) {
log . info ( "请求入库时,堆垛机尚未运行" ) ;
stkidleV = Boolean . valueOf ( pointMap . get ( stkidle ) . toString ( ) ) ;
return false ;
}
}
Integer intFinish = Integer . valueOf ( pointMap . get ( readfinish ) . toString ( ) ) ;
/ * Boolean stkRunV = false ;
Integer stkAutoManualV = 0 ;
if ( pointMap . containsKey ( stkRun ) ) {
if ( pointMap . containsKey ( stkAutoManual ) ) {
stkRunV = Boolean . valueOf ( pointMap . get ( stkRun ) . toString ( ) ) ;
stkAutoManualV = Integer . valueOf ( pointMap . get ( stkAutoManual ) . toString ( ) ) ;
} * /
}
/ * //等于0
log . info ( "堆垛机自动状态:" + stkAutoManualV ) ;
if ( ! stkRunV ) {
if ( stkAutoManualV = = 0 ) {
return Result . err ( ) . msg ( "堆垛机正在运行中" ) ;
log . info ( "请求入库时,堆垛机手动状态" ) ;
} * /
log . info ( "入库时,堆垛机的状态值:" + intFinish ) ;
if ( intFinish = = 1 ) {
log . info ( "堆垛机的状态值为1,不允许下发入库任务" ) ;
return false ;
return false ;
}
}
//堆垛机地面柜手动状态
Integer stkGroundV = 0 ;
log . info ( "请求入库:堆垛机地面柜手动状态:" + stkGroundV ) ;
if ( pointMap . containsKey ( stkGround ) ) {
if ( ! stkGroundV ) {
stkGroundV = Integer . valueOf ( pointMap . get ( stkGround ) . toString ( ) ) ;
return false ;
}
}
log . info ( "请求入库;堆垛机手动状态:" + stkAutoManual V ) ;
log . info ( "地面柜自动状态:" + stkGround V ) ;
//堆垛机手动状态
if ( stkGroundV = = 0 ) {
if ( ! stkAutoManualV ) {
log . info ( "请求入库时,堆垛机地面柜手动状态" ) ;
return false ;
return false ;
}
}
log . info ( "请求入库:堆垛机是否允许下任务:" + stkidleV ) ;
//等于0繁忙 false代表繁忙
Integer stkidleV = 0 ;
if ( ! stkidleV ) {
if ( pointMap . containsKey ( stkidle ) ) {
log . info ( "是否等于false:堆垛机是否允许下任务:" + stkidleV ) ;
stkidleV = Integer . valueOf ( pointMap . get ( stkidle ) . toString ( ) ) ;
}
log . info ( "堆垛机是状态:" + stkidleV ) ;
//1空闲 0繁忙
if ( stkidleV = = 0 ) {
log . info ( "请求入库时,堆垛机繁忙" ) ;
return false ;
return false ;
}
}
@ -795,16 +955,13 @@ public class PlcEventTask {
readfinishMap . put ( readfinishValueType , 0 ) ;
readfinishMap . put ( readfinishValueType , 0 ) ;
allMap . put ( readfinish , readfinishMap ) ;
allMap . put ( readfinish , readfinishMap ) ;
log . info ( "请求入库:任务下发之前" + JsonUtil . toJSONString ( allMap ) ) ;
log . error ( "请求入库:任务下发之前" + JsonUtil . toJSONString ( allMap ) ) ;
if ( plcReadAndWrite . execWrite ( stkOperate , 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
//请求分配任务ID dps
redisTemplate . delete ( RedisConstant . redisContainer + taskId ) ;
redisTemplate . delete ( RedisConstant . redisContainer + taskId ) ;
//请求入库任务ID stk
// redisTemplate.delete(RedisConstant.redisStKTaskId+taskId);
return true ;
return true ;
} else {
} else {
log . info ( "请求入库任务下发失败" ) ;
log . info ( "请求入库任务下发失败" ) ;