add: 仙工AGV
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.acs.agv.server.impl;
|
package org.nl.acs.agv.server.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
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.AgvUtil;
|
||||||
import org.nl.acs.agv.server.XianGongAgvService;
|
import org.nl.acs.agv.server.XianGongAgvService;
|
||||||
import org.nl.acs.agv.server.dto.AgvDto;
|
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.common.base.CommonFinalParam;
|
||||||
import org.nl.acs.device.domain.Device;
|
import org.nl.acs.device.domain.Device;
|
||||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
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.common.exception.BadRequestException;
|
||||||
import org.nl.config.language.LangProcess;
|
import org.nl.config.language.LangProcess;
|
||||||
import org.nl.system.service.param.ISysParamService;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -40,11 +46,20 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
|||||||
private final DeviceAppService deviceAppService;
|
private final DeviceAppService deviceAppService;
|
||||||
private final ISysParamService paramService;
|
private final ISysParamService paramService;
|
||||||
private final AcsToWmsService acsToWmsService;
|
private final AcsToWmsService acsToWmsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAcsPointAngleService acsPointAngleService;
|
||||||
|
|
||||||
|
|
||||||
Map<String, AgvDto> AGVDeviceStatus = new HashMap();
|
Map<String, AgvDto> AGVDeviceStatus = new HashMap();
|
||||||
|
|
||||||
private static final String JACKLOAD_THREE = "3";
|
private static final String JACKLOAD_THREE = "3";
|
||||||
private static final String FOUR = "4";
|
private static final String FOUR = "4";
|
||||||
private static final String WAIT_FIVE = "5";
|
private static final String WAIT_FIVE = "5";
|
||||||
|
|
||||||
|
@Value("${agvToAcs.addr}")
|
||||||
|
private String addr;
|
||||||
|
|
||||||
@LokiLog(type = LokiLogType.AGV)
|
@LokiLog(type = LokiLogType.AGV)
|
||||||
@Override
|
@Override
|
||||||
public String waitPointRequest(String param) {
|
public String waitPointRequest(String param) {
|
||||||
@@ -223,7 +238,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
|||||||
@LokiLog(type = LokiLogType.AGV)
|
@LokiLog(type = LokiLogType.AGV)
|
||||||
@Override
|
@Override
|
||||||
public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception {
|
public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception {
|
||||||
JSONObject jo = new JSONObject();
|
/*JSONObject jo = new JSONObject();
|
||||||
jo.put("intendedVehicle", "");
|
jo.put("intendedVehicle", "");
|
||||||
jo.put("category", "");
|
jo.put("category", "");
|
||||||
jo.put("failureFatal", false);
|
jo.put("failureFatal", false);
|
||||||
@@ -241,7 +256,13 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
|||||||
jo1.put("value", "");
|
jo1.put("value", "");
|
||||||
ja1.add(jo1);
|
ja1.add(jo1);
|
||||||
jo.put("properties", ja1);
|
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());
|
log.info("任务号:{},指令号{},下发agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo.toString());
|
||||||
|
|
||||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
|
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)
|
@LokiLog(type = LokiLogType.AGV)
|
||||||
@Override
|
@Override
|
||||||
public HttpResponse addOrderSequences(Instruction inst) throws Exception {
|
public HttpResponse addOrderSequences(Instruction inst) throws Exception {
|
||||||
|
|||||||
@@ -29,4 +29,14 @@ public interface IAcsPointAngleService extends IService<AcsPointAngle> {
|
|||||||
Map<String, Object> queryAll(Map whereJson, Pageable page);
|
Map<String, Object> queryAll(Map whereJson, Pageable page);
|
||||||
|
|
||||||
void updateOn(Long id, String is_active);
|
void updateOn(Long id, String is_active);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据起点编码和终点编码查询
|
||||||
|
*
|
||||||
|
* @param start_code
|
||||||
|
* @param next_code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AcsPointAngle findByCode(String start_code,String next_code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
import org.nl.acs.angle.domain.AcsPointAngle;
|
import org.nl.acs.angle.domain.AcsPointAngle;
|
||||||
import org.nl.acs.angle.mapper.AcsPointAngleMapper;
|
import org.nl.acs.angle.mapper.AcsPointAngleMapper;
|
||||||
@@ -107,4 +108,11 @@ public class AcsPointAngleServiceImpl extends ServiceImpl<AcsPointAngleMapper, A
|
|||||||
acsPointAngleMapper.updateById(acsPointAngle);
|
acsPointAngleMapper.updateById(acsPointAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AcsPointAngle findByCode(String start_code, String next_code) {
|
||||||
|
return acsPointAngleMapper.selectOne(Wrappers.lambdaQuery(AcsPointAngle.class)
|
||||||
|
.eq(AcsPointAngle::getStart_device_code, start_code).eq(AcsPointAngle::getNext_device_code, next_code));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -101,6 +102,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
private TaskService taskService;
|
private TaskService taskService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AcsToLiKuService acsToLiKuService;
|
private AcsToLiKuService acsToLiKuService;
|
||||||
|
@Autowired
|
||||||
|
private XianGongAgvService xiangGongAgvService;
|
||||||
|
|
||||||
private List<Instruction> instructions = new CopyOnWriteArrayList();
|
private List<Instruction> instructions = new CopyOnWriteArrayList();
|
||||||
|
|
||||||
@@ -433,6 +436,15 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||||
}
|
}
|
||||||
|
//判断是否是仙工AGV
|
||||||
|
if(CommonFinalParam.ONE.equals(route.getType())){
|
||||||
|
HttpResponse response = xiangGongAgvService.sendOrderSequencesToXZ(dto);
|
||||||
|
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
|
||||||
|
dto.setSend_status("2");
|
||||||
|
} else {
|
||||||
|
dto.setSend_status("1");
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
dto.setSend_status("2");
|
dto.setSend_status("2");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ file:
|
|||||||
avatarMaxSize: 5
|
avatarMaxSize: 5
|
||||||
logging:
|
logging:
|
||||||
file:
|
file:
|
||||||
path: /Users/onepiece/myFile/acs_logs
|
path: D:\acs_logs # /Users/onepiece/myFile/acs_logs
|
||||||
config: classpath:logback-spring.xml
|
config: classpath:logback-spring.xml
|
||||||
lucene:
|
lucene:
|
||||||
index:
|
index:
|
||||||
@@ -183,3 +183,6 @@ sa-token:
|
|||||||
password:
|
password:
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
|
|
||||||
|
agvToAcs:
|
||||||
|
addr: http://localhost
|
||||||
|
|||||||
Reference in New Issue
Block a user