@@ -1,5 +1,6 @@
package org.nl.acs.agv.server.impl ;
import cn.dev33.satoken.annotation.SaIgnore ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.http.HttpRequest ;
import cn.hutool.http.HttpResponse ;
@@ -18,6 +19,7 @@ import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDev
import org.nl.acs.device_driver.basedriver.lubei_conveyor.LubeiConveyorDeviceDriver ;
import org.nl.acs.device_driver.basedriver.paint_conveyor.PaintConveyorDeviceDriver ;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver ;
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver ;
import org.nl.acs.ext.wms.service.AcsToWmsService ;
import org.nl.acs.ext.wms.service.AcsToWmsZDService ;
import org.nl.acs.instruction.service.InstructionService ;
@@ -49,6 +51,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
private final ParamService paramService ;
@LokiLog ( type = LokiLogType . AGV )
@Override
@SaIgnore
public HttpResponse sendAgvInstToAgv ( Instruction inst ) throws Exception {
JSONObject jo = new JSONObject ( ) ;
String start_point_code = inst . getStart_point_code ( ) ;
@@ -68,15 +71,18 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
jo . put ( " task_code " , inst . getInstruction_code ( ) ) ;
/ / 根据任务 , 下发指令类型
JSONArray destinations = new JSONArray ( ) ;
if ( task_type . equals ( " 3 " ) ) {
destinations . add ( destination ( start_point_code , " Wait " , " 5 " , " 1 " ) ) ;
} else if ( task_type . equals ( " 4 " ) ) {
destinations . add ( destination ( start_point_code , " Load " , " 1 " , " 1 " ) ) ;
destinations . add ( destination ( next_point_code , " Wait " , " 5 " , " 1 " ) ) ;
} else {
/ / if ( task_type . equals ( " 3 " ) ) {
/ / destinations . add ( destination ( start_point_code , " Wait " , " 5 " , " 1 " ) ) ;
/ / } else if ( task_type . equals ( " 4 " ) ) {
/ / destinations . add ( destination ( start_point_code , " Load " , " 1 " , " 1 " ) ) ;
/ / destinations . add ( destination ( next_point_code , " Wait " , " 5 " , " 1 " ) ) ;
/ / } else {
/ / destinations . add ( destination ( start_point_code , " Load " , " 1 " , " 1 " ) ) ;
/ / destinations . add ( destination ( next_point_code , " Unload " , " 1 " , " 1 " ) ) ;
/ / }
destinations . add ( destination ( start_point_code , " Load " , " 1 " , " 1 " ) ) ;
destinations . add ( destination ( next_point_code , " Unload " , " 1 " , " 1 " ) ) ;
}
jo . put ( " destinations " , destinations ) ;
@@ -86,13 +92,14 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
String agvport = paramService . findByCode ( AcsConfig . AGVPORT ) . getValue ( ) ;
String agvport2 = paramService . findByCode ( AcsConfig . AGVPORT2 ) . getValue ( ) ;
agvurl = agvurl + " : " + agvport + " /v1/transportOrders/ " + inst . getInstruction_code ( ) ;
agvurl = agvurl + " : " + agvport + " /rmds/ v1/transportOrders/ " + inst . getInstruction_code ( ) ;
log . info ( " 下发agv任务请求:{} " , agvurl ) ;
HttpResponse result = HttpRequest . post ( agvurl )
. body ( String . valueOf ( jo ) ) / / 表单内容
. timeout ( 20000 ) / / 超时 , 毫秒
. execute ( ) ;
log . info ( " 下发agv任务请求内容:{} " , jo ) ;
log . info ( " 下发agv任务请求反馈:{} " , result ) ;
return result ;
} else {
@@ -107,11 +114,13 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
if ( StrUtil . equals ( paramService . findByCode ( AcsConfig . FORKAGV ) . getValue ( ) , " 1 " ) ) {
String agvurl = paramService . findByCode ( AcsConfig . AGVURL ) . getValue ( ) ;
String agvport = paramService . findByCode ( AcsConfig . AGVPORT ) . getValue ( ) ;
agvurl = agvurl + " : " + agvport + " /v1/vehicles " ;
HttpResponse result = HttpRequest . ge t( agvurl )
agvurl = agvurl + " : " + agvport + " /rmds/v1/transportOrders/query " ;
HttpResponse result = HttpRequest . pos t( agvurl )
. body ( " {} " )
. timeout ( 20000 ) / / 超时 , 毫秒
. execute ( ) ;
System . out . println ( " 查询agv指令数据: " + result . body ( ) ) ;
log . info ( " 查询agv指令数据:{} " , result . body ( ) ) ;
return result ;
} else {
@@ -138,10 +147,10 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
@LokiLog ( type = LokiLogType . AGV )
@Override
public synchronized String process ( String jobno , String type , String address , String action , String processingVehicle , String feedbackStatus )
public synchronized String process ( String jobno , String type , String address , String action , String processingVehicle )
{
{
log . info ( " 查询到AGV请求参数,jobno:{},address:{} " , jobno + " ,address: " + address + " ,type: " + type + " ,action: " + action + " ,feedbackStatus: " + feedbackStatus ) ;
log . info ( " 查询到AGV请求参数,jobno:{},address:{} " , jobno + " ,address: " + address + " ,type: " + type + " ,action: " + action ) ;
/ / 释放AGV资源 , 继续后续动作
boolean is_feedback = false ;
String str = " " ;
@@ -177,7 +186,8 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , feedbackStatus ) ;
jo . put ( " feedbackStatus " , " applyTake " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
@@ -194,7 +204,8 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , feedbackStatus ) ;
jo . put ( " feedbackStatus " , " applyTake " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
@@ -203,6 +214,22 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
log . info ( " 请求ZDwcs成功, 申请取货 请求结果{} " , responseCode ) ;
}
}
if ( addressdevice . getDeviceDriver ( ) instanceof StandardStorageDeviceDriver ) {
JSONObject jo = new JSONObject ( ) ;
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , " applyTake " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
if ( responseCode = = 0 ) {
is_feedback = true ;
log . info ( " 请求ZDwcs成功, 申请取货 请求结果{} " , responseCode ) ;
}
}
}
if ( " PauseOnStation " . equals ( type ) ) {
if ( addressdevice . getDeviceDriver ( ) instanceof LubeiConveyorDeviceDriver ) {
@@ -212,14 +239,21 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , feedbackStatus ) ;
jo . put ( " feedbackStatus " , " takeFinish " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
if ( responseCode = = 0 ) {
is_feedback = true ;
log . info ( " 请求ZDwcs成功, 取货完成 请求结果{} " , responseCode ) ;
}
lubeiConveyorDeviceDriver . writing ( 2 ) ;
if ( lubeiConveyorDeviceDriver . getTo_command ( ) = = 2 ) {
is_feedback = true ;
} else {
lubeiConveyorDeviceDriver . writing ( 2 ) ;
}
} else {
log . info ( " 设备{} 请求离开,光电信号:{} " , addressdevice , lubeiConveyorDeviceDriver . getMove ( ) ) ;
}
@@ -229,7 +263,8 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , feedbackStatus ) ;
jo . put ( " feedbackStatus " , " takeFinish " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
@@ -238,6 +273,21 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
log . info ( " 请求ZDwcs成功, 取货完成 请求结果{} " , responseCode ) ;
}
}
if ( addressdevice . getDeviceDriver ( ) instanceof StandardStorageDeviceDriver ) {
JSONObject jo = new JSONObject ( ) ;
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , " takeFinish " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
if ( responseCode = = 0 ) {
is_feedback = true ;
log . info ( " 请求ZDwcs成功, 申请取货 请求结果{} " , responseCode ) ;
}
}
}
}
@@ -251,7 +301,8 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , feedbackStatus ) ;
jo . put ( " feedbackStatus " , " applyPut " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
@@ -268,7 +319,8 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , feedbackStatus ) ;
jo . put ( " feedbackStatus " , " applyPut " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
@@ -277,6 +329,21 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
log . info ( " 请求ZDwcs成功, 开始放货 请求结果{} " , responseCode ) ;
}
}
if ( addressdevice . getDeviceDriver ( ) instanceof StandardStorageDeviceDriver ) {
JSONObject jo = new JSONObject ( ) ;
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , " applyPut " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
if ( responseCode = = 0 ) {
is_feedback = true ;
log . info ( " 请求ZDwcs成功, 申请取货 请求结果{} " , responseCode ) ;
}
}
}
if ( " PauseOnStation " . equals ( type ) ) {
if ( addressdevice . getDeviceDriver ( ) instanceof LubeiConveyorDeviceDriver ) {
@@ -286,14 +353,20 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , feedbackStatus ) ;
jo . put ( " feedbackStatus " , " putFinish " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
if ( responseCode = = 0 ) {
is_feedback = true ;
log . info ( " 请求ZDwcs成功, 放货完成 请求结果{} " , responseCode ) ;
}
lubeiConveyorDeviceDriver . writing ( 3 ) ;
if ( lubeiConveyorDeviceDriver . getTo_command ( ) = = 3 ) {
is_feedback = true ;
} else {
lubeiConveyorDeviceDriver . writing ( 3 ) ;
}
} else {
log . info ( " 设备{} 请求离开,光电信号:{} " , addressdevice , lubeiConveyorDeviceDriver . getMove ( ) ) ;
}
@@ -303,7 +376,8 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , feedbackStatus ) ;
jo . put ( " feedbackStatus " , " putFinish " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
@@ -312,6 +386,21 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
log . info ( " 请求ZDwcs成功, 放货完成 请求结果{} " , responseCode ) ;
}
}
if ( addressdevice . getDeviceDriver ( ) instanceof StandardStorageDeviceDriver ) {
JSONObject jo = new JSONObject ( ) ;
jo . put ( " taskCode " , task . getTask_code ( ) ) ;
jo . put ( " carId " , processingVehicle ) ;
jo . put ( " taskType " , type ) ;
jo . put ( " feedbackStatus " , " putFinish " ) ;
log . info ( " 请求参数:{} " , jo ) ;
HttpResponse result = acsToWmsZDService . taskFeedback ( jo ) ;
JSONObject response = JSONObject . parseObject ( result . body ( ) ) ;
int responseCode = response . getInteger ( " responseCode " ) ;
if ( responseCode = = 0 ) {
is_feedback = true ;
log . info ( " 请求ZDwcs成功, 申请取货 请求结果{} " , responseCode ) ;
}
}
}
}
com . alibaba . fastjson . JSONObject requestjo = new com . alibaba . fastjson . JSONObject ( ) ;
@@ -330,7 +419,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
String agvurl = acsConfigService . findConfigFromCache ( ) . get ( AcsConfig . AGVURL ) ;
String agvport = acsConfigService . findConfigFromCache ( ) . get ( AcsConfig . AGVPORT ) ;
agvurl = agvurl + " : " + agvport + " /api/route /transportOrders/ " + jobno + " /interact " ;
agvurl = agvurl + " : " + agvport + " /rmds/v1 /transportOrders/ " + jobno + " /interact " ;
HttpResponse result = HttpRequest . post ( agvurl )
@@ -394,11 +483,11 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
JSONArray properties = new JSONArray ( ) ;
JSONObject pro1 = new JSONObject ( ) ;
pro1 . put ( " key " , " EntryRequired " ) ;
pro1 . put ( " value " , " T rue" ) ;
pro1 . put ( " value " , " t rue" ) ;
properties . add ( pro1 ) ;
JSONObject pro2 = new JSONObject ( ) ;
pro2 . put ( " key " , " PauseOnStation " ) ;
pro2 . put ( " value " , " T rue" ) ;
pro2 . put ( " value " , " t rue" ) ;
properties . add ( pro2 ) ;
destinationOrder . put ( " properties " , properties ) ;
/ / 进入等待 离开不等待
@@ -406,11 +495,11 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
JSONArray properties = new JSONArray ( ) ;
JSONObject pro1 = new JSONObject ( ) ;
pro1 . put ( " key " , " EntryRequired " ) ;
pro1 . put ( " value " , " T rue" ) ;
pro1 . put ( " value " , " t rue" ) ;
properties . add ( pro1 ) ;
JSONObject pro2 = new JSONObject ( ) ;
pro2 . put ( " key " , " PauseOnStation " ) ;
pro2 . put ( " value " , " F alse" ) ;
pro2 . put ( " value " , " f alse" ) ;
properties . add ( pro2 ) ;
destinationOrder . put ( " properties " , properties ) ;
/ / 进入不等待 离开等待
@@ -418,11 +507,11 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
JSONArray properties = new JSONArray ( ) ;
JSONObject pro1 = new JSONObject ( ) ;
pro1 . put ( " key " , " EntryRequired " ) ;
pro1 . put ( " value " , " F alse" ) ;
pro1 . put ( " value " , " f alse" ) ;
properties . add ( pro1 ) ;
JSONObject pro2 = new JSONObject ( ) ;
pro2 . put ( " key " , " PauseOnStation " ) ;
pro2 . put ( " value " , " T rue" ) ;
pro2 . put ( " value " , " t rue" ) ;
properties . add ( pro2 ) ;
destinationOrder . put ( " properties " , properties ) ;
/ / 不等待
@@ -430,11 +519,11 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
JSONArray properties = new JSONArray ( ) ;
JSONObject pro1 = new JSONObject ( ) ;
pro1 . put ( " key " , " EntryRequired " ) ;
pro1 . put ( " value " , " F alse" ) ;
pro1 . put ( " value " , " f alse" ) ;
properties . add ( pro1 ) ;
JSONObject pro2 = new JSONObject ( ) ;
pro2 . put ( " key " , " PauseOnStation " ) ;
pro2 . put ( " value " , " F alse" ) ;
pro2 . put ( " value " , " f alse" ) ;
properties . add ( pro2 ) ;
destinationOrder . put ( " properties " , properties ) ;
}
@@ -472,7 +561,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
JSONArray properties = new JSONArray ( ) ;
JSONObject pro1 = new JSONObject ( ) ;
pro1 . put ( " key " , " Wait " ) ;
pro1 . put ( " value " , " T rue" ) ;
pro1 . put ( " value " , " t rue" ) ;
properties . add ( pro1 ) ;
destinationOrder . put ( " properties " , properties ) ;
}