@@ -1,5 +1,6 @@
package org.nl.acs.agv.server.impl ;
import cn.hutool.core.util.IdUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.http.HttpRequest ;
@@ -12,6 +13,8 @@ import org.nl.acs.AcsConfig;
import org.nl.acs.agv.AgvUtil ;
import org.nl.acs.agv.server.XianGongAgvService ;
import org.nl.acs.agv.server.dto.AgvDto ;
import org.nl.acs.angle.domain.AcsPointAngle ;
import org.nl.acs.angle.service.IAcsPointAngleService ;
import org.nl.acs.common.base.CommonFinalParam ;
import org.nl.acs.device.domain.Device ;
import org.nl.acs.ext.wms.service.AcsToWmsService ;
@@ -23,8 +26,11 @@ import org.nl.acs.device.enums.DeviceType;
import org.nl.common.exception.BadRequestException ;
import org.nl.config.language.LangProcess ;
import org.nl.system.service.param.ISysParamService ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Value ;
import org.springframework.stereotype.Service ;
import java.math.BigDecimal ;
import java.util.Arrays ;
import java.util.HashMap ;
import java.util.List ;
@@ -40,11 +46,20 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
private final DeviceAppService deviceAppService ;
private final ISysParamService paramService ;
private final AcsToWmsService acsToWmsService ;
@Autowired
private IAcsPointAngleService acsPointAngleService ;
Map < String , AgvDto > AGVDeviceStatus = new HashMap ( ) ;
private static final String JACKLOAD_THREE = " 3 " ;
private static final String FOUR = " 4 " ;
private static final String WAIT_FIVE = " 5 " ;
@Value ( " ${agvToAcs.addr} " )
private String addr ;
@LokiLog ( type = LokiLogType . AGV )
@Override
public String waitPointRequest ( String param ) {
@@ -223,7 +238,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
@LokiLog ( type = LokiLogType . AGV )
@Override
public HttpResponse sendOrderSequencesToXZ ( Instruction inst ) throws Exception {
JSONObject jo = new JSONObject ( ) ;
/* JSONObject jo = new JSONObject();
jo.put("intendedVehicle", "");
jo.put("category", "");
jo.put("failureFatal", false);
@@ -241,7 +256,13 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
jo1.put("value", "");
ja1.add(jo1);
jo.put("properties", ja1);
log.info("任务号:{},指令号{},下发agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo.toString());*/
com . alibaba . fastjson . JSONObject jo = new com . alibaba . fastjson . JSONObject ( ) ;
jo . put ( " id " , inst . getInstruction_code ( ) ) ;
jo . put ( " complete " , true ) ;
jo . put ( " blocks " , createBlocksData ( inst ) ) ;
jo . put ( " priority " , inst . getPriority ( ) ) ;
log . info ( " 任务号:{},指令号{},下发agv订单序列参数:{} " , inst . getTask_code ( ) , inst . getInstruction_code ( ) , jo . toString ( ) ) ;
if ( StrUtil . equals ( paramService . findByCode ( AcsConfig . FORKAGV ) . getValue ( ) , CommonFinalParam . ONE ) ) {
@@ -265,6 +286,121 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
}
}
public com . alibaba . fastjson . JSONArray createBlocksData ( Instruction inst ) {
JSONArray ja = new JSONArray ( ) ;
Device startDevice = deviceAppService . findDeviceByCode ( inst . getStart_device_code ( ) ) ;
if ( " true " . equals ( startDevice . getExtraValue ( ) . get ( " ignore_pickup_check " ) ) ) {
//取货前等待
JSONObject jo = new JSONObject ( ) ;
jo . put ( " blockId " , IdUtil . simpleUUID ( ) ) ;
jo . put ( " location " , inst . getStart_point_code ( ) + " INGET " ) ;
jo . put ( " operation " , " script " ) ;
jo . put ( " id " , inst . getStart_point_code ( ) + " INGET " ) ;
jo . put ( " script_name " , " userpy/interact.py " ) ;
JSONObject script_args = new JSONObject ( ) ;
script_args . put ( " addr " , addr ) ;
JSONObject data = new JSONObject ( ) ;
JSONObject reach = new JSONObject ( ) ;
reach . put ( " task_code " , inst . getInstruction_code ( ) ) ;
reach . put ( " address " , inst . getStart_point_code ( ) + " INGET " ) ;
data . put ( " reach " , reach ) ;
script_args . put ( " data " , data ) ;
script_args . put ( " protocol " , " HTTP " ) ;
jo . put ( " script_args " , script_args ) ;
ja . add ( jo ) ;
}
JSONObject jo1 = new JSONObject ( ) ;
jo1 . put ( " blockId " , IdUtil . simpleUUID ( ) ) ;
jo1 . put ( " location " , inst . getStart_point_code ( ) ) ;
jo1 . put ( " operation " , " JackLoad " ) ;
ja . add ( jo1 ) ;
//取货完成等待
JSONObject jo2 = new JSONObject ( ) ;
jo2 . put ( " blockId " , IdUtil . simpleUUID ( ) ) ;
jo2 . put ( " location " , inst . getStart_point_code ( ) + " OUTGET " ) ;
jo2 . put ( " operation " , " script " ) ;
jo2 . put ( " id " , inst . getStart_point_code ( ) + " OUTGET " ) ;
jo2 . put ( " script_name " , " userpy/interact.py " ) ;
JSONObject script_args2 = new JSONObject ( ) ;
script_args2 . put ( " addr " , addr ) ;
JSONObject data2 = new JSONObject ( ) ;
JSONObject reach2 = new JSONObject ( ) ;
reach2 . put ( " task_code " , inst . getInstruction_code ( ) ) ;
reach2 . put ( " address " , inst . getStart_point_code ( ) + " OUTGET " ) ;
data2 . put ( " reach " , reach2 ) ;
script_args2 . put ( " data " , data2 ) ;
script_args2 . put ( " protocol " , " HTTP " ) ;
jo2 . put ( " script_args " , script_args2 ) ;
ja . add ( jo2 ) ;
Device nextDevice = deviceAppService . findDeviceByCode ( inst . getNext_device_code ( ) ) ;
if ( " true " . equals ( nextDevice . getExtraValue ( ) . get ( " ignore_release_check " ) ) ) {
//放货前等待
JSONObject jo3 = new JSONObject ( ) ;
jo3 . put ( " blockId " , IdUtil . simpleUUID ( ) ) ;
jo3 . put ( " location " , inst . getNext_point_code ( ) + " INPUT " ) ;
jo3 . put ( " operation " , " script " ) ;
jo3 . put ( " id " , inst . getNext_point_code ( ) + " INPUT " ) ;
jo3 . put ( " script_name " , " userpy/interact.py " ) ;
JSONObject script_args3 = new JSONObject ( ) ;
script_args3 . put ( " addr " , addr ) ;
JSONObject data3 = new JSONObject ( ) ;
JSONObject reach3 = new JSONObject ( ) ;
reach3 . put ( " task_code " , inst . getInstruction_code ( ) ) ;
reach3 . put ( " address " , inst . getNext_point_code ( ) + " INPUT " ) ;
data3 . put ( " reach " , reach3 ) ;
script_args3 . put ( " data " , data3 ) ;
script_args3 . put ( " protocol " , " HTTP " ) ;
jo3 . put ( " script_args " , script_args3 ) ;
ja . add ( jo3 ) ;
}
//放货前下发旋转角度
JSONObject json1 = new JSONObject ( ) ;
AcsPointAngle acsPointAngleDto = acsPointAngleService . findByCode ( inst . getStart_device_code ( ) , inst . getNext_device_code ( ) ) ;
if ( ObjectUtil . isNotEmpty ( acsPointAngleDto ) ) {
log . info ( " acsPointAngleDto----參數,{} " , acsPointAngleDto . toString ( ) ) ;
com . alibaba . fastjson . JSONObject operation_args = new com . alibaba . fastjson . JSONObject ( ) ;
BigDecimal next_point_angle = acsPointAngleDto . getNext_point_angle ( ) ;
operation_args . put ( " increase_spin_angle " , next_point_angle ) ; //弧度值, 如3.14
operation_args . put ( " skill_name " , " GoByOdometer " ) ;
json1 . put ( " blockId " , IdUtil . simpleUUID ( ) ) ;
json1 . put ( " location " , inst . getNext_point_code ( ) + " INPUT " ) ;
json1 . put ( " operation_args " , operation_args ) ;
ja . add ( json1 ) ;
}
com . alibaba . fastjson . JSONObject jo4 = new com . alibaba . fastjson . JSONObject ( ) ;
jo4 . put ( " blockId " , IdUtil . simpleUUID ( ) ) ;
jo4 . put ( " location " , inst . getNext_point_code ( ) ) ;
jo4 . put ( " operation " , " JackUnload " ) ;
ja . add ( jo4 ) ;
if ( " true " . equals ( nextDevice . getExtraValue ( ) . get ( " ignore_release_check " ) ) ) {
//放货完成等待
com . alibaba . fastjson . JSONObject jo5 = new com . alibaba . fastjson . JSONObject ( ) ;
jo5 . put ( " blockId " , IdUtil . simpleUUID ( ) ) ;
jo5 . put ( " location " , inst . getNext_point_code ( ) + " OUTPUT " ) ;
jo5 . put ( " operation " , " script " ) ;
jo5 . put ( " id " , inst . getNext_point_code ( ) + " OUTPUT " ) ;
jo5 . put ( " script_name " , " userpy/interact.py " ) ;
com . alibaba . fastjson . JSONObject script_args5 = new com . alibaba . fastjson . JSONObject ( ) ;
script_args5 . put ( " addr " , addr ) ;
com . alibaba . fastjson . JSONObject data5 = new com . alibaba . fastjson . JSONObject ( ) ;
com . alibaba . fastjson . JSONObject reach5 = new com . alibaba . fastjson . JSONObject ( ) ;
reach5 . put ( " task_code " , inst . getInstruction_code ( ) ) ;
reach5 . put ( " address " , inst . getNext_point_code ( ) + " OUTPUT " ) ;
data5 . put ( " reach " , reach5 ) ;
script_args5 . put ( " data " , data5 ) ;
script_args5 . put ( " protocol " , " HTTP " ) ;
jo5 . put ( " script_args " , script_args5 ) ;
ja . add ( jo5 ) ;
}
return ja ;
}
@LokiLog ( type = LokiLogType . AGV )
@Override
public HttpResponse addOrderSequences ( Instruction inst ) throws Exception {