@@ -1,14 +1,18 @@
package com.ruoyi.schedule.scheduleTask.ddj ;
package com.ruoyi.schedule.scheduleTask.ddj ;
import cn.hutool.core.bean.BeanUtil ;
import cn.hutool.core.collection.CollUtil ;
import cn.hutool.core.collection.CollUtil ;
import cn.hutool.core.convert.Convert ;
import cn.hutool.core.convert.Convert ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.util.ObjUtil ;
import cn.hutool.core.util.ObjUtil ;
import cn.hutool.core.util.StrUtil ;
import com.ruoyi.api.domain.wcs2wms.JobParam ;
import com.ruoyi.api.domain.wcs2wms.JobParam ;
import com.ruoyi.api.service.IApiService ;
import com.ruoyi.api.service.IApiService ;
import com.ruoyi.common.core.domain.AjaxResult ;
import com.ruoyi.common.core.domain.AjaxResult ;
import com.ruoyi.common.utils.spring.SpringUtils ;
import com.ruoyi.common.utils.spring.SpringUtils ;
import com.ruoyi.device.ddj.domain.MsgDdj ;
import com.ruoyi.device.ddj.domain.MsgDdj ;
import com.ruoyi.device.ddj.service.IMsgDdjService ;
import com.ruoyi.device.ssj.domain.DeviceSsj ;
import com.ruoyi.job.domain.MydoJob ;
import com.ruoyi.job.domain.MydoJob ;
import com.ruoyi.job.service.IMydoJobService ;
import com.ruoyi.job.service.IMydoJobService ;
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue ;
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue ;
@@ -19,20 +23,23 @@ import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.plcRead.util.Tools ;
import com.ruoyi.schedule.plcRead.util.Tools ;
import lombok.extern.slf4j.Slf4j ;
import lombok.extern.slf4j.Slf4j ;
import java.util.ArrayList ;
import java.util.* ;
import java.util.HashMap ;
import java.util.List ;
import static com.ruoyi.common.TaskStatusCode.* ;
@Slf4j
@Slf4j
public class Ddj1Thread implements Runnable {
public class Ddj1Thread implements Runnable {
public HashMap < String , List < String > > ddjCodeList ;
public HashMap < String , List < MsgDdj > > ddjCodeList ;
public HashMap < String , List < DeviceSsj > > ssjList ;
private IApiService apiService ;
private IApiService apiService ;
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService ;
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService ;
private IDdjDeviceExecutionQueueFinishService ddjDeviceExecutionQueueFinishService ;
private IDdjDeviceExecutionQueueFinishService ddjDeviceExecutionQueueFinishService ;
private IMsgDdjService msgDdjService ;
private IMydoJobService mydoJobService ;
private IMydoJobService mydoJobService ;
private final Map < String , List < Integer > > roadwayMap = new HashMap < > ( ) ;
public boolean isRun = true ;
public boolean isRun = true ;
@@ -40,16 +47,44 @@ public class Ddj1Thread implements Runnable {
public void init ( ) {
public void init ( ) {
//todo 获取设备编码列表
//todo 获取设备编码列表
ddjCodeList = new HashMap < > ( ) ;
ddjCodeList = new HashMap < > ( ) ;
ArrayList < String > ddjCodes = new ArrayList < > ( ) ;
ArrayList < MsgDdj > ddjCodes = new ArrayList < > ( ) ;
ddjCodes . add ( " ddj1 " ) ;
ddjCodes . add ( PlcDdjRead . deviceDdjMap . get ( " ddj1 " ) ) ;
ddjCodes . add ( " ddj2 " ) ;
ddjCodeList . put ( " ddj " , ddjCodes ) ;
ddjCodeList . put ( " ddj " , ddjCodes ) ;
ArrayList < DeviceSsj > roadSsjList = new ArrayList < > ( ) ;
roadSsjList . add ( PlcSsjRead . deviceSsjMap . get ( " L1001 " ) ) ;
roadSsjList . add ( PlcSsjRead . deviceSsjMap . get ( " L1002 " ) ) ;
roadSsjList . add ( PlcSsjRead . deviceSsjMap . get ( " L1003 " ) ) ;
roadSsjList . add ( PlcSsjRead . deviceSsjMap . get ( " L1004 " ) ) ;
ssjList . put ( " roadSsjList " , roadSsjList ) ;
ArrayList < DeviceSsj > outSsj1 = new ArrayList < > ( ) ;
outSsj1 . add ( PlcSsjRead . deviceSsjMap . get ( " L1003 " ) ) ;
outSsj1 . add ( PlcSsjRead . deviceSsjMap . get ( " L1004 " ) ) ;
ssjList . put ( " outSsj1 " , outSsj1 ) ;
ArrayList < DeviceSsj > outSsj2 = new ArrayList < > ( ) ;
outSsj2 . add ( PlcSsjRead . deviceSsjMap . get ( " L1003 " ) ) ;
outSsj2 . add ( PlcSsjRead . deviceSsjMap . get ( " L1004 " ) ) ;
ssjList . put ( " outSsj2 " , outSsj2 ) ;
ArrayList < DeviceSsj > outSsj3 = new ArrayList < > ( ) ;
outSsj3 . add ( PlcSsjRead . deviceSsjMap . get ( " L1003 " ) ) ;
outSsj3 . add ( PlcSsjRead . deviceSsjMap . get ( " L1004 " ) ) ;
ssjList . put ( " outSsj3 " , outSsj3 ) ;
ArrayList < DeviceSsj > outSsj4 = new ArrayList < > ( ) ;
outSsj4 . add ( PlcSsjRead . deviceSsjMap . get ( " L1003 " ) ) ;
outSsj4 . add ( PlcSsjRead . deviceSsjMap . get ( " L1004 " ) ) ;
ssjList . put ( " outSsj4 " , outSsj4 ) ;
//初始化巷道口 排 列 层
roadwayMap . put ( " L1001 " , Arrays . asList ( 1 , 1 , 1 ) ) ;
roadwayMap . put ( " L1002 " , Arrays . asList ( 2 , 1 , 1 ) ) ;
roadwayMap . put ( " L1003 " , Arrays . asList ( 1 , 58 , 1 ) ) ;
roadwayMap . put ( " L1004 " , Arrays . asList ( 2 , 58 , 1 ) ) ;
apiService = SpringUtils . getBean ( IApiService . class ) ;
apiService = SpringUtils . getBean ( IApiService . class ) ;
ddjDeviceExecutionQueueService = SpringUtils . getBean ( IDdjDeviceExecutionQueueService . class ) ;
ddjDeviceExecutionQueueService = SpringUtils . getBean ( IDdjDeviceExecutionQueueService . class ) ;
ddjDeviceExecutionQueueFinishService = SpringUtils . getBean ( IDdjDeviceExecutionQueueFinishService . class ) ;
ddjDeviceExecutionQueueFinishService = SpringUtils . getBean ( IDdjDeviceExecutionQueueFinishService . class ) ;
msgDdjService = SpringUtils . getBean ( IMsgDdjService . class ) ;
mydoJobService = SpringUtils . getBean ( IMydoJobService . class ) ;
mydoJobService = SpringUtils . getBean ( IMydoJobService . class ) ;
log . info ( " 初始化服务 {}, {},{},{} " , apiService , ddjDeviceExecutionQueueService , ddjDeviceExecutionQueueFinishService , mydoJobService ) ;
log . info ( " 初始化服务 {}, {},{},{} " , apiService , ddjDeviceExecutionQueueService , ddjDeviceExecutionQueueFinishService , mydoJobService ) ;
}
}
@Override
@Override
@@ -58,19 +93,22 @@ public class Ddj1Thread implements Runnable {
while ( isRun ) {
while ( isRun ) {
for ( String type : ddjCodeList . keySet ( ) ) {
for ( String type : ddjCodeList . keySet ( ) ) {
i f ( " ddj " . equals ( type ) ) {
for ( MsgDdj msgDdj : ddjCodeList . get ( type ) ) {
for ( String ddjCode : ddjCodeList . get ( type ) ) {
try {
try {
if ( ObjUtil . isNotNull ( msgDdj ) ) {
if ( PlcDdjRead . deviceDdjMap . containsKey ( ddjCode ) ) {
if ( 0 = = msgDdj . getSpare1 ( ) ) {
ddjTask ( PlcDdjRead . deviceDdjMap . get ( ddjCode ) ) ;
generateInBoundPickQueue ( msgDdj ) ;
} else {
generateInBoundLoadQueue ( msgDdj ) ;
log . error ( " 设备不存在 ssjCode{} " , ddjCode ) ;
generateOutBoundQueue ( msgDdj ) ;
ddjTask ( msgDdj ) ;
}
}
} catch ( RuntimeException e ) {
} else {
log . error ( e . getMessage ( ) , e ) ;
log . error ( " 堆垛机设备为空 " ) ;
}
}
} catch ( RuntimeException e ) {
log . error ( e . getMessage ( ) , e ) ;
}
}
}
}
}
}
try {
try {
@@ -82,6 +120,142 @@ public class Ddj1Thread implements Runnable {
}
}
/**
* 创建出库队列
*/
private void generateOutBoundQueue ( MsgDdj ddj ) {
MydoJob param = new MydoJob ( ) ;
param . setInOut ( " 2 " ) ;
param . setWarehouseId ( " 01 " ) ;
param . setRoadwayId ( Convert . toStr ( ddj . getId ( ) ) ) ;
List < MydoJob > outJobList = mydoJobService . selectMydoJobList ( param ) ;
if ( CollUtil . isNotEmpty ( outJobList ) ) {
for ( MydoJob outJob : outJobList ) {
String exitId = outJob . getExitId ( ) ;
String outSsj = " " ;
switch ( exitId ) {
case " 1 " :
List < DeviceSsj > outSsj1 = ssjList . get ( " outSsj1 " ) ;
if ( outSsj1 . stream ( ) . allMatch ( ssj - > ssj . getKx ( ) = = 1 & & ssj . getModel ( ) = = 2 ) ) {
outSsj = outSsj1 . get ( 0 ) . getDeviceCode ( ) ;
break ;
}
List < DeviceSsj > outSsj2 = ssjList . get ( " outSsj2 " ) ;
if ( outSsj2 . stream ( ) . allMatch ( ssj - > ssj . getKx ( ) = = 1 & & ssj . getModel ( ) = = 2 ) ) {
outSsj = outSsj2 . get ( 0 ) . getDeviceCode ( ) ;
break ;
}
break ;
case " 2 " :
List < DeviceSsj > outSsj3 = ssjList . get ( " outSsj3 " ) ;
if ( outSsj3 . stream ( ) . allMatch ( ssj - > ssj . getKx ( ) = = 1 & & ssj . getModel ( ) = = 2 ) ) {
outSsj = outSsj3 . get ( 0 ) . getDeviceCode ( ) ;
break ;
}
List < DeviceSsj > outSsj4 = ssjList . get ( " outSsj4 " ) ;
if ( outSsj4 . stream ( ) . allMatch ( ssj - > ssj . getKx ( ) = = 1 & & ssj . getModel ( ) = = 2 ) ) {
outSsj = outSsj4 . get ( 0 ) . getDeviceCode ( ) ;
break ;
}
break ;
default :
log . error ( " 出库任务出口错误 " ) ;
continue ;
}
if ( " 0 " . equals ( outJob . getExecutionPhase ( ) ) & & StrUtil . isNotEmpty ( outSsj ) ) {
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( Convert . toLong ( outJob . getTaskNo ( ) ) , ddj . getId ( ) ) ;
if ( ObjUtil . isNull ( ddjQueue ) ) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue ( ) ;
ddjDeviceExecutionQueueService . insertDdjDeviceExecutionQueue ( ddjDeviceExecutionQueue ) ;
outJob . setStatus ( " 3 " ) ;
outJob . setStartTime ( DateUtil . format ( new Date ( ) , " yyyy-MM-dd HH:mm:ss " ) ) ;
outJob . setExecutionPhase ( TASK_EP_DDJ ) ;
mydoJobService . updateMydoJob ( outJob ) ;
} else {
log . info ( " 任务已存在 rwh{} " , outJob . getTaskNo ( ) ) ;
}
}
}
}
}
/**
* 创建入库放货队列
*/
private void generateInBoundLoadQueue ( MsgDdj ddj ) {
if ( ddj . getCzfs ( ) = = 5 & & ddj . getSbzt ( ) = = 3 ) {
//允许下发 联机 有货待机
if ( StrUtil . isNotEmpty ( ddj . getTrayCode ( ) ) ) {
MydoJob param = new MydoJob ( ) ;
param . setTrayCode ( ddj . getTrayCode ( ) ) ;
List < MydoJob > mydoJobs = mydoJobService . selectMydoJobList ( param ) ;
MydoJob inJob = null ;
if ( CollUtil . isEmpty ( mydoJobs ) ) {
//请求wms获取任务 并生成队列
HashMap < String , Object > paramMap = new HashMap < > ( ) ;
paramMap . put ( " trayCode " , ddj . getTrayCode ( ) ) ;
AjaxResult result = apiService . selectMydoJobByTrayCodeAndEntranceId ( paramMap ) ;
if ( result . isSuccess ( ) ) {
inJob = BeanUtil . toBean ( result . get ( " data " ) , MydoJob . class ) ;
inJob . setStatus ( TASK_STATUS_CREATE ) ;
inJob . setExecutionPhase ( TASK_EP_ROADWAY_SSJ ) ;
mydoJobService . insertMydoJob ( inJob ) ;
} else {
log . error ( result . get ( " msg " ) . toString ( ) ) ;
}
} else {
inJob = mydoJobs . get ( 0 ) ;
}
if ( ObjUtil . isNotNull ( inJob ) & & inJob . getExecutionPhase ( ) . equals ( TASK_EP_ROADWAY_SSJ ) ) {
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( Convert . toLong ( inJob . getTaskNo ( ) ) , ddj . getId ( ) ) ;
if ( ObjUtil . isNull ( ddjQueue ) ) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue ( ) ;
ddjDeviceExecutionQueueService . insertDdjDeviceExecutionQueue ( ddjDeviceExecutionQueue ) ;
inJob . setStatus ( " 3 " ) ;
inJob . setStartTime ( DateUtil . format ( new Date ( ) , " yyyy-MM-dd HH:mm:ss " ) ) ;
inJob . setExecutionPhase ( TASK_EP_DDJ ) ;
mydoJobService . updateMydoJob ( inJob ) ;
} else {
log . info ( " 任务已存在 rwh{} " , inJob . getTaskNo ( ) ) ;
}
}
} else {
Integer mbph = ddj . getMbph ( ) ;
Integer mblh = ddj . getMblh ( ) ;
Integer mbch = ddj . getMbch ( ) ;
long rwh = ddj . getRwh ( ) + 100 ;
log . error ( " 扫码失败,放回原位 排:{} 列:{} 层:{} 任务号:{} " , mbph , mblh , mbch , rwh ) ;
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( rwh , ddj . getId ( ) ) ;
if ( ObjUtil . isNull ( ddjQueue ) ) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue ( ) ;
ddjDeviceExecutionQueueService . insertDdjDeviceExecutionQueue ( ddjDeviceExecutionQueue ) ;
}
}
}
}
/**
* 创建入库取货队列
*/
private void generateInBoundPickQueue ( MsgDdj ddj ) {
List < DeviceSsj > roadSsjList = ssjList . get ( " roadSsjList " ) ;
for ( DeviceSsj ssj : roadSsjList ) {
if ( ssj . getDw ( ) = = 1 & & ssj . getTaskNo ( ) > 0 ) {
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( Convert . toLong ( ssj . getTaskNo ( ) ) , ddj . getId ( ) ) ;
if ( ObjUtil . isNull ( ddjQueue ) ) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue ( ) ;
ddjDeviceExecutionQueueService . insertDdjDeviceExecutionQueue ( ddjDeviceExecutionQueue ) ;
} else {
log . info ( " 任务已存在 rwh{} " , ssj . getTaskNo ( ) ) ;
}
}
}
}
private void ddjTask ( MsgDdj ddj ) {
private void ddjTask ( MsgDdj ddj ) {
/*
/*
第一部分
第一部分
@@ -92,7 +266,7 @@ public class Ddj1Thread implements Runnable {
Long rwh = ddj . getRwh ( ) ;
Long rwh = ddj . getRwh ( ) ;
//完成作业
//完成作业
MydoJob mydoJob = mydoJobService . selectMydoJobByTaskNo ( rwh ) ;
MydoJob mydoJob = mydoJobService . selectMydoJobByTaskNo ( rwh ) ;
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( rwh , ddj . getId ( ) ) ;
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( rwh , ddj . getId ( ) ) ;
if ( mydoJob ! = null & & ddjDeviceExecutionQueue ! = null ) {
if ( mydoJob ! = null & & ddjDeviceExecutionQueue ! = null ) {
//回传完成信号
//回传完成信号
ddjTaskFinish ( rwh , ddj . getId ( ) ) ;
ddjTaskFinish ( rwh , ddj . getId ( ) ) ;
@@ -110,6 +284,7 @@ public class Ddj1Thread implements Runnable {
if ( ddjDeviceExecutionQueue ! = null ) {
if ( ddjDeviceExecutionQueue ! = null ) {
//修改队列执行阶段
//修改队列执行阶段
ddjDeviceExecutionQueue . setRwzt ( ddj . getJdbz ( ) ) ;
ddjDeviceExecutionQueue . setRwzt ( ddj . getJdbz ( ) ) ;
ddjDeviceExecutionQueue . setSpare1 ( " 1 " ) ;
ddjDeviceExecutionQueueService . updateDdjDeviceExecutionQueue ( ddjDeviceExecutionQueue ) ;
ddjDeviceExecutionQueueService . updateDdjDeviceExecutionQueue ( ddjDeviceExecutionQueue ) ;
}
}
}
}
@@ -122,13 +297,16 @@ public class Ddj1Thread implements Runnable {
//判断堆垛机上任务是否已重分,若未重分,则调用接口,请求重分货位
//判断堆垛机上任务是否已重分,若未重分,则调用接口,请求重分货位
Long rwh = ddj . getRwh ( ) ;
Long rwh = ddj . getRwh ( ) ;
MydoJob mydoJob = mydoJobService . selectMydoJobByTaskNo ( rwh ) ;
MydoJob mydoJob = mydoJobService . selectMydoJobByTaskNo ( rwh ) ;
if ( " 0 " . equals ( mydoJob . getFaultFlag ( ) ) ) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( rwh , ddj . getId ( ) ) ;
if ( " 0 " . equals ( mydoJob . getFaultFlag ( ) ) & & " 1 " . equals ( ddjDeviceExecutionQueue . getSpare1 ( ) ) ) {
mydoJob . setStatus ( " 1 " ) ;
mydoJob . setStatus ( " 1 " ) ;
mydoJobService . updateMydoJob ( mydoJob ) ;
mydoJobService . updateMydoJob ( mydoJob ) ;
AjaxResult ajaxResult = apiService . reAssign ( new JobParam ( rwh . toString ( ) , null , null ) ) ;
AjaxResult ajaxResult = apiService . reAssign ( new JobParam ( rwh . toString ( ) , null , null ) ) ;
if ( ajaxResult . isSuccess ( ) ) {
if ( ajaxResult . isSuccess ( ) ) {
mydoJob . setFaultFlag ( " 2 " ) ;
mydoJob . setFaultFlag ( " 2 " ) ;
mydoJobService . updateMydoJob ( mydoJob ) ;
mydoJobService . updateMydoJob ( mydoJob ) ;
ddjDeviceExecutionQueue . setSpare1 ( " 0 " ) ;
ddjDeviceExecutionQueueService . updateDdjDeviceExecutionQueue ( ddjDeviceExecutionQueue ) ;
}
}
}
}
}
}
@@ -140,7 +318,7 @@ public class Ddj1Thread implements Runnable {
if ( ddj . getCzfs ( ) = = 5 & & ddj . getSbzt ( ) = = 1053 & & ddj . getJdbz ( ) < 5 ) {
if ( ddj . getCzfs ( ) = = 5 & & ddj . getSbzt ( ) = = 1053 & & ddj . getJdbz ( ) < 5 ) {
Long rwh = ddj . getRwh ( ) ;
Long rwh = ddj . getRwh ( ) ;
//无货异常处理
//无货异常处理
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( rwh , ddj . getId ( ) ) ;
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( rwh , ddj . getId ( ) ) ;
//找到对应任务 调用api接口 取货无货,重新分配单据
//找到对应任务 调用api接口 取货无货,重新分配单据
if ( ObjUtil . isNotNull ( ddjDeviceExecutionQueue ) ) {
if ( ObjUtil . isNotNull ( ddjDeviceExecutionQueue ) ) {
AjaxResult ajaxResult = apiService . reMaterial ( new JobParam ( rwh . toString ( ) , null , null ) ) ;
AjaxResult ajaxResult = apiService . reMaterial ( new JobParam ( rwh . toString ( ) , null , null ) ) ;
@@ -161,7 +339,7 @@ public class Ddj1Thread implements Runnable {
MydoJob mydoJob = mydoJobService . selectMydoJobByTaskNo ( rwh ) ;
MydoJob mydoJob = mydoJobService . selectMydoJobByTaskNo ( rwh ) ;
if ( ObjUtil . isNotNull ( mydoJob ) & & " 2 " . equals ( mydoJob . getFaultFlag ( ) ) ) {
if ( ObjUtil . isNotNull ( mydoJob ) & & " 2 " . equals ( mydoJob . getFaultFlag ( ) ) ) {
//判断任务是否重分完成
//判断任务是否重分完成
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( rwh , ddj . getId ( ) ) ;
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueByRwh ( rwh , ddj . getId ( ) ) ;
if ( ObjUtil . isNotNull ( ddjDeviceExecutionQueue ) ) {
if ( ObjUtil . isNotNull ( ddjDeviceExecutionQueue ) ) {
//重新下发堆垛机任务
//重新下发堆垛机任务
int i = issuedDDJTask ( ddj . getId ( ) , ddjDeviceExecutionQueue ) ;
int i = issuedDDJTask ( ddj . getId ( ) , ddjDeviceExecutionQueue ) ;
@@ -180,32 +358,54 @@ public class Ddj1Thread implements Runnable {
}
}
}
}
//正常下发
//正常下发
if ( ddj . getYxxf ( ) = = 1 & & ddj . getCzfs ( ) = = 5 & & ddj . getSbzt ( ) = = 0 ) {
if ( ddj . getYxxf ( ) = = 1 & & ddj . getCzfs ( ) = = 5 ) {
Long rwh = ddj . getRwh ( ) ;
if ( ddj . getSbzt ( ) = = 0 ) {
//对堆垛机执行队列中无已下发 队列
//无货待机 只查询入库取货扫码或者出库 队列
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue ( ) ;
ArrayList < Integer > rwlxList = new ArrayList < > ( ) ;
ddjDeviceExecutionQueueParam . setDdjxf ( " 1 " ) ;
rwlxList . add ( 1 ) ;
ddjDeviceExecutionQueueParam . setDevId ( ddj . getI d( ) ) ;
rwlxList . ad d( 3 ) ;
List < DdjDeviceExecutionQueue > ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueList ( ddjDeviceExecutionQueueParam ) ;
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue ( ) ;
//取堆垛机队列中,生成时间最早的执行队列下发
ddjDeviceExecutionQueueParam . setDdjxf ( " 0 " ) ;
if ( CollUtil . isEmpty ( ddjDeviceExecutionQueues ) ) {
ddjDeviceExecutionQueueParam . setDevId ( ddj . getId ( ) ) ;
D djDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues . get ( 0 ) ;
d djDeviceExecutionQueueParam . setRwlxList ( rwlxList ) ;
if ( ddjDeviceExecutionQueue = = null ) {
List < DdjDeviceExecutionQueue > ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueList ( ddjDeviceExecutionQueueParam ) ;
return ;
if ( CollUtil . isNotEmpty ( ddjDeviceExecutionQueues ) ) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues . get ( 0 ) ;
int i = issuedDDJTask ( ddj . getId ( ) , ddjDeviceExecutionQueue ) ;
if ( i = = 1 ) {
//更新开始时间, 修改ddjxf为已下发1
ddjDeviceExecutionQueue . setXfsj ( DateUtil . formatDateTime ( DateUtil . date ( ) ) ) ;
ddjDeviceExecutionQueue . setDdjxf ( " 1 " ) ;
ddjDeviceExecutionQueueService . updateDdjDeviceExecutionQueue ( ddjDeviceExecutionQueue ) ;
log . info ( " 托盘堆垛机下发任务成功 rwh:{} " , ddjDeviceExecutionQueue . getRwh ( ) ) ;
} else {
log . error ( " 托盘堆垛机下发任务失败!!!!!!! " ) ;
}
}
}
int i = issuedDDJTask ( ddj . getId ( ) , ddjDeviceExecutionQueue ) ;
} else if ( ddj . getSbzt ( ) = = 3 ) {
if ( i = = 1 ) {
//有货待机 只查询入库放货队列
//更新开始时间, 修改ddjxf为已下发1
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue ( ) ;
ddjDeviceExecutionQueue . setXfsj ( DateUtil . formatDateTime ( DateUtil . date ( ) ) ) ;
ddjDeviceExecutionQueueParam . setDdjxf ( " 0 " ) ;
ddjDeviceExecutionQueue . setDdjxf ( " 1 " ) ;
ddjDeviceExecutionQueueParam . setDevId ( ddj . getId ( ) ) ;
ddjDeviceExecutionQueueService . updateDdjDeviceExecutionQueue ( ddjDeviceExecutionQueue ) ;
ddjDeviceExecutionQueueParam . setRwlx ( 2 ) ;
log . info ( " 托盘堆垛机下发任务成功 rwh:{} " , rwh ) ;
List < DdjDeviceExecutionQueue > ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService . selectDdjDeviceExecutionQueueList ( ddjDeviceExecutionQueueParam ) ;
} else {
if ( CollUtil . isNotEmpty ( ddjDeviceExecutionQueues ) ) {
log . error ( " 托盘堆垛机下发任务失败!!!!!!! " ) ;
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues . get ( 0 ) ;
int i = issuedDDJTask ( ddj . getId ( ) , ddjDeviceExecutionQueue ) ;
if ( i = = 1 ) {
//更新开始时间, 修改ddjxf为已下发1
ddjDeviceExecutionQueue . setXfsj ( DateUtil . formatDateTime ( DateUtil . date ( ) ) ) ;
ddjDeviceExecutionQueue . setDdjxf ( " 1 " ) ;
ddjDeviceExecutionQueueService . updateDdjDeviceExecutionQueue ( ddjDeviceExecutionQueue ) ;
log . info ( " 托盘堆垛机下发任务成功 rwh:{} " , ddjDeviceExecutionQueue . getRwh ( ) ) ;
} else {
log . error ( " 托盘堆垛机下发任务失败!!!!!!! " ) ;
}
}
}
}
}
}
}
}
}
/**
/**
@@ -242,13 +442,20 @@ public class Ddj1Thread implements Runnable {
int mbph = Convert . toInt ( queue . getMbph ( ) ) ;
int mbph = Convert . toInt ( queue . getMbph ( ) ) ;
int mblh = Convert . toInt ( queue . getMblh ( ) ) ;
int mblh = Convert . toInt ( queue . getMblh ( ) ) ;
int mbch = Convert . toInt ( queue . getMbch ( ) ) ;
int mbch = Convert . toInt ( queue . getMbch ( ) ) ;
int mlfs = 5 ;
int mlfs ;
if ( queue . getRwlx ( ) = = 1 | | queue . getRwlx ( ) = = 3 ) {
mlfs = 5 ;
} else if ( queue . getRwlx ( ) = = 2 ) {
mlfs = 4 ;
} else {
throw new RuntimeException ( " 任务类型错误 " ) ;
}
int xfwc = 1 ;
int xfwc = 1 ;
int jym = Tools . getJYM ( taskNo , yph , ylh , ych , mbph , mblh , mbch , mlfs , xfwc ) ;
int jym = Tools . getJYM ( taskNo , yph , ylh , ych , mbph , mblh , mbch , mlfs , xfwc ) ;
byte [ ] sendData = Tools . sendDataToDevice ( taskNo , null , yph , ylh , ych , mbph , mblh , mbch , mlfs , xfwc , jym ) ;
byte [ ] sendData = Tools . sendDataToDevice ( taskNo , null , yph , ylh , ych , mbph , mblh , mbch , mlfs , xfwc , jym ) ;
if ( devId = = 1 ) {
if ( devId = = 1 ) {
return PlcDdjRead . WriteToDDJ ( " DB61.0 " , sendData ) ;
return PlcDdjRead . WriteToDDJ ( " DB61.0 " , sendData ) ;
} else {
} else {
return PlcDdjRead . WriteToDDJ ( " DB61.0 " , sendData ) ;
return PlcDdjRead . WriteToDDJ ( " DB61.0 " , sendData ) ;
}
}
}
}