@ -32,14 +32,22 @@ public class AutoCreateInst {
* 根据任务状态创建指令 、 生成下一条指令
* 根据任务状态创建指令 、 生成下一条指令
* /
* /
public void run ( ) throws Exception {
public void run ( ) throws Exception {
// 任务接口
TaskService taskserver = SpringContextHolder . getBean ( TaskService . class ) ;
TaskService taskserver = SpringContextHolder . getBean ( TaskService . class ) ;
// 指令接口
InstructionService instructionService = SpringContextHolder . getBean ( InstructionService . class ) ;
InstructionService instructionService = SpringContextHolder . getBean ( InstructionService . class ) ;
// 路由接口
RouteLineService routeLineService = SpringContextHolder . getBean ( RouteLineService . class ) ;
RouteLineService routeLineService = SpringContextHolder . getBean ( RouteLineService . class ) ;
// 系统参数接口
ParamService acsConfigService = SpringContextHolder . getBean ( ParamService . class ) ;
ParamService acsConfigService = SpringContextHolder . getBean ( ParamService . class ) ;
List < TaskDto > list = taskserver . findReadyTask ( ) ;
// 设备接口
DeviceAppService appService = SpringContextHolder . getBean ( DeviceAppServiceImpl . class ) ;
DeviceAppService appService = SpringContextHolder . getBean ( DeviceAppServiceImpl . class ) ;
// 查询所有就绪的任务
List < TaskDto > list = taskserver . findReadyTask ( ) ;
for ( int i = 0 ; i < list . size ( ) ; i + + ) {
for ( int i = 0 ; i < list . size ( ) ; i + + ) {
TaskDto acsTask = list . get ( i ) ;
TaskDto acsTask = list . get ( i ) ;
// 获取任务对应的字段参数
String taskid = acsTask . getTask_id ( ) ;
String taskid = acsTask . getTask_id ( ) ;
String taskcode = acsTask . getTask_code ( ) ;
String taskcode = acsTask . getTask_code ( ) ;
String vehiclecode = acsTask . getVehicle_code ( ) ;
String vehiclecode = acsTask . getVehicle_code ( ) ;
@ -69,8 +77,12 @@ public class AutoCreateInst {
taskserver . updateByCodeFromCache ( acsTask ) ;
taskserver . updateByCodeFromCache ( acsTask ) ;
continue ;
continue ;
}
}
// 找指令状态 小于 完成(2)的指令
List < Instruction > instructions = instructionService . queryAll ( "instruction_status < 2" ) ;
List < Instruction > instructions = instructionService . queryAll ( "instruction_status < 2" ) ;
// 系统参数maxInstNumber(最大指令数量)
String maxInstnumber = acsConfigService . findByCode ( AcsConfig . MAX_INST_NUMBER ) . getValue ( ) ;
String maxInstnumber = acsConfigService . findByCode ( AcsConfig . MAX_INST_NUMBER ) . getValue ( ) ;
// 不允许超过最大系统指令数量
if ( ObjectUtils . isNotEmpty ( maxInstnumber ) ) {
if ( ObjectUtils . isNotEmpty ( maxInstnumber ) ) {
if ( instructions . size ( ) > = Integer . parseInt ( maxInstnumber ) ) {
if ( instructions . size ( ) > = Integer . parseInt ( maxInstnumber ) ) {
log . info ( "已达到系统参数配置的最大指令数 [" + maxInstnumber + "] ,无法生成指令。" ) ;
log . info ( "已达到系统参数配置的最大指令数 [" + maxInstnumber + "] ,无法生成指令。" ) ;
@ -80,29 +92,13 @@ public class AutoCreateInst {
}
}
}
}
// 获取路由路线并拆分
/ * *
* 开始平均分解校验
* /
String this_device_code = taskserver . queryAssignedByDevice ( acsTask . getStart_device_code ( ) , acsTask . getNext_device_code ( ) ) ;
if ( StrUtil . isEmpty ( this_device_code ) ) {
List < RouteLineDto > shortPathsList = routeLineService . getShortPathLines ( start_device_code , acsTask . getNext_device_code ( ) , route_plan_code ) ;
List < RouteLineDto > shortPathsList = routeLineService . getShortPathLines ( start_device_code , acsTask . getNext_device_code ( ) , route_plan_code ) ;
RouteLineDto routeLineDto = shortPathsList . get ( 0 ) ;
RouteLineDto routeLineDto = shortPathsList . get ( 0 ) ;
String path = routeLineDto . getPath ( ) ;
String path = routeLineDto . getPath ( ) ;
String type = routeLineDto . getType ( ) ;
String type = routeLineDto . getType ( ) ;
String [ ] str = path . split ( "->" ) ;
String [ ] str = path . split ( "->" ) ;
List < String > pathlist = Arrays . asList ( str ) ;
List < String > pathlist = Arrays . asList ( str ) ;
if ( StrUtil . equals ( acsTask . getTask_type ( ) , "2" ) ) {
for ( int j = 0 ; j < pathlist . size ( ) ; j + + ) {
if ( j = = 0 ) {
compound_task_data = pathlist . get ( j ) . trim ( ) ;
} else {
compound_task_data = compound_task_data + "->" + pathlist . get ( j ) . trim ( ) ;
}
}
next_device_code = pathlist . get ( pathlist . size ( ) - 1 ) ;
} else {
int index = 0 ;
int index = 0 ;
for ( int m = 0 ; m < pathlist . size ( ) ; m + + ) {
for ( int m = 0 ; m < pathlist . size ( ) ; m + + ) {
if ( pathlist . get ( m ) . equals ( start_device_code ) ) {
if ( pathlist . get ( m ) . equals ( start_device_code ) ) {
@ -111,13 +107,16 @@ public class AutoCreateInst {
}
}
}
}
next_device_code = pathlist . get ( index ) ;
next_device_code = pathlist . get ( index ) ;
}
if ( StrUtil . equals ( appService . findDeviceTypeByCode ( next_device_code ) , "storage" ) ) {
// next_point_code = next_device_code + CommonFinalParam.HYPHEN_ + acsTask.getTo_y() + CommonFinalParam.HYPHEN_ + acsTask.getTo_z();
} else {
} else {
next_device_code = this_device_code ;
next_point _code = nex t_device_code;
}
}
//校验路由关系
//校验路由关系
List < RouteLineDto > shortPathsList = routeLineService . getShortPathLines ( start_device_code , next_device_code , route_plan_code ) ;
List < RouteLineDto > shortPathsList2 = routeLineService . getShortPathLines ( start_device_code , next_device_code , route_plan_code ) ;
if ( ObjectUtils . isEmpty ( shortPathsList ) ) {
if ( ObjectUtils . isEmpty ( shortPathsList2 ) ) {
log . info ( "任务 [" + taskcode + "] 路由不通无法生成指令。" ) ;
log . info ( "任务 [" + taskcode + "] 路由不通无法生成指令。" ) ;
acsTask . setRemark ( "任务 [" + taskcode + "] 路由不通无法生成指令。" ) ;
acsTask . setRemark ( "任务 [" + taskcode + "] 路由不通无法生成指令。" ) ;
taskserver . updateByCodeFromCache ( acsTask ) ;
taskserver . updateByCodeFromCache ( acsTask ) ;
@ -127,6 +126,7 @@ public class AutoCreateInst {
if ( ! StrUtil . equals ( shortPathsList . get ( 0 ) . getType ( ) , "1" ) ) {
if ( ! StrUtil . equals ( shortPathsList . get ( 0 ) . getType ( ) , "1" ) ) {
continue ;
continue ;
}
}
Device startdevice = appService . findDeviceByCode ( start_device_code ) ;
Device startdevice = appService . findDeviceByCode ( start_device_code ) ;
Device nextdevice = appService . findDeviceByCode ( next_device_code ) ;
Device nextdevice = appService . findDeviceByCode ( next_device_code ) ;
if ( ObjectUtils . isEmpty ( startdevice ) ) {
if ( ObjectUtils . isEmpty ( startdevice ) ) {