长兴特科拉项目

This commit is contained in:
zhang
2025-01-07 14:34:18 +08:00
parent 2f54a1e9b9
commit 3afb1624a1
5 changed files with 133 additions and 108 deletions

View File

@@ -23,10 +23,10 @@ public class XianGongAgvController {
@Autowired @Autowired
private XianGongAgvService xianGongAgentService; private XianGongAgvService xianGongAgentService;
@PostMapping("/api/agv/xg/waitPointRequest") @PostMapping("/api/agv/waitPointRequest")
@Log("仙工AGV请求取放货") @Log("仙工AGV请求取放货")
@SaIgnore @SaIgnore
public ResponseEntity<JSONObject> xgAGVWaitPointRequest(@RequestBody JSONObject requestParam) { public ResponseEntity<JSONObject> xgAGVWaitPointRequest(@RequestBody JSONObject requestParam) throws Exception{
return new ResponseEntity<>(xianGongAgentService.xgAGVWaitPointRequest(requestParam), HttpStatus.OK); return new ResponseEntity<>(xianGongAgentService.xgAGVWaitPointRequest(requestParam), HttpStatus.OK);
} }

View File

@@ -108,7 +108,7 @@ public interface XianGongAgvService {
* @param requestParam * @param requestParam
* @return * @return
*/ */
JSONObject xgAGVWaitPointRequest(JSONObject requestParam); JSONObject xgAGVWaitPointRequest(JSONObject requestParam) throws Exception;
/** /**

View File

@@ -7,10 +7,13 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AGVSchedulingService; import org.nl.acs.agv.server.AGVSchedulingService;
import org.nl.acs.ext.RequestAdapter;
import org.nl.acs.ext.UnifiedResponse; import org.nl.acs.ext.UnifiedResponse;
import org.nl.acs.ext.xg.XgHttpUtil; import org.nl.acs.ext.xg.XgHttpUtil;
import org.nl.acs.ext.xg.XgRequestAdapter;
import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.domain.Instruction;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Slf4j @Slf4j
@@ -21,6 +24,9 @@ public class AGVSchedulingServiceImpl implements AGVSchedulingService {
@Autowired @Autowired
private XgHttpUtil xgHttpUtil; private XgHttpUtil xgHttpUtil;
@Value("${agvToAcs.addr}")
private String addr;
@Override @Override
public <T> UnifiedResponse<T> sendAGVOrderSequences(Instruction inst) { public <T> UnifiedResponse<T> sendAGVOrderSequences(Instruction inst) {
JSONObject reqParam = new JSONObject(); JSONObject reqParam = new JSONObject();
@@ -67,8 +73,20 @@ public class AGVSchedulingServiceImpl implements AGVSchedulingService {
// 起点2 // 起点2
block = new JSONObject(); block = new JSONObject();
block.put("blockId", IdUtil.simpleUUID()); block.put("blockId", IdUtil.simpleUUID());
block.put("location", inst.getStart_point_code2()); block.put("location", inst.getStart_point_code2() + "INGET");
block.put("operation", "JackLoad"); block.put("operation", "script");
block.put("id", inst.getStart_point_code2() + "INGET");
block.put("script_name", "userpy/interact.py");
JSONObject scriptArgs = new JSONObject();
scriptArgs.put("addr", addr);
JSONObject data = new JSONObject();
JSONObject reach = new JSONObject();
reach.put("task_code", inst.getInstruction_code());
reach.put("address", inst.getStart_point_code2() + "INGET");
data.put("reach", reach);
scriptArgs.put("data", data);
scriptArgs.put("protocol", "HTTP");
block.put("script_args", scriptArgs);
blocks.add(block); blocks.add(block);
// 终点2 // 终点2
block = new JSONObject(); block = new JSONObject();

View File

@@ -737,7 +737,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
@Override @Override
public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) { public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) throws Exception{
log.info("仙工AGV请求取放货请求参数 - {}", requestParam); log.info("仙工AGV请求取放货请求参数 - {}", requestParam);
String inst_code = requestParam.getString("task_code"); String inst_code = requestParam.getString("task_code");
Instruction instructionDto = instructionService.findByCodeFromCache(inst_code); Instruction instructionDto = instructionService.findByCodeFromCache(inst_code);
@@ -759,107 +759,114 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
throw new BadRequestException("请求失败,地址为空!"); throw new BadRequestException("请求失败,地址为空!");
} }
if (address.contains("IN") || address.contains("WAIT")) { log.info("AGV取货前等待30s...");
String task_code = instructionDto.getTask_code(); Thread.sleep(30000L);
String deviceCodeNow; log.info("允许取货,点位 - {}", instructionDto.getStart_point_code2());
if (address.contains("WAIT")) { JSONObject map = new JSONObject();
deviceCodeNow = address.substring(0, address.length() - 4); map.put("status", 200);
} else { map.put("message", "允许取货!");
deviceCodeNow = address.substring(0, address.length() - 5); return map;
} // if (address.contains("IN") || address.contains("WAIT")) {
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) { // String task_code = instructionDto.getTask_code();
LuceneLogDto logDto = LuceneLogDto.builder() // String deviceCodeNow;
.device_code(instructionDto.getCarno()) // if (address.contains("WAIT")) {
.content("设备号 " + deviceCodeNow + " 不存在!") // deviceCodeNow = address.substring(0, address.length() - 4);
.build(); // } else {
logDto.setLog_level(4); // deviceCodeNow = address.substring(0, address.length() - 5);
luceneExecuteLogService.deviceExecuteLog(logDto); // }
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!"); // if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
} // LuceneLogDto logDto = LuceneLogDto.builder()
//一楼诺宝agv // .device_code(instructionDto.getCarno())
if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) { // .content("设备号 " + deviceCodeNow + " 不存在!")
// .build();
if (address.contains("GET")) { // logDto.setLog_level(4);
return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto); // luceneExecuteLogService.deviceExecuteLog(logDto);
} else if (address.contains("PUT")) { // throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto); // }
} // //一楼诺宝agv
//如果是取货二次分配,取放货二次分配需要重新追加动作块 // if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) { //
Integer actionType = ActionTypeEnum.IN_STOCK.getCode(); // if (address.contains("GET")) {
String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto); // return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
log.info("取货二次分配追加诺宝成功,新点位 - {}", newPointCode); // } else if (address.contains("PUT")) {
JSONObject map = new JSONObject(); // return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
map.put("status", 200); // }
map.put("message", "取货二次分配追加诺宝成功!"); // //如果是取货二次分配,取放货二次分配需要重新追加动作块
return map; // if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
} // Integer actionType = ActionTypeEnum.IN_STOCK.getCode();
//如果是放货二次分配,取放货二次分配需要重新追加动作块 // String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto);
if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) { // log.info("取货二次分配追加诺宝成功,新点位 - {}", newPointCode);
Integer actionType = ActionTypeEnum.OUT_STOCK.getCode(); // JSONObject map = new JSONObject();
String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto); // map.put("status", 200);
// sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), deviceCodeNow, instructionDto); // map.put("message", "取货二次分配追加诺宝成功!");
log.info("放货二次分配追加诺宝成功,新点位 - {}", newPointCode); // return map;
JSONObject map = new JSONObject(); // }
map.put("status", 200); // //如果是放货二次分配,取放货二次分配需要重新追加动作块
map.put("message", "放货二次分配追加诺宝成功!"); // if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
return map; // Integer actionType = ActionTypeEnum.OUT_STOCK.getCode();
} // String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto);
} //// sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), deviceCodeNow, instructionDto);
//一楼叉车 // log.info("放货二次分配追加诺宝成功,新点位 - {}", newPointCode);
if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) { // JSONObject map = new JSONObject();
if (address.contains("GET")) { // map.put("status", 200);
//取货前等待 // map.put("message", "放货二次分配追加诺宝成功!");
return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto); // return map;
} else { // }
//放货前二次分配 // }
if (address.contains("WAIT")) { // //一楼叉车
String newPointCode = applyCCAgvTask(task_code, instructionDto); // if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
// if (address.contains("GET")) {
JSONObject map = new JSONObject(); // //取货前等待
map.put("status", 200); // return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
map.put("message", "允许叉车放货!" + "点位" + newPointCode); // } else {
log.info("允许仙工AGV放货设备号 - {}", newPointCode); // //放货前二次分配
LuceneLogDto logDto = LuceneLogDto.builder() // if (address.contains("WAIT")) {
.device_code(instructionDto.getCarno()) // String newPointCode = applyCCAgvTask(task_code, instructionDto);
.content("叉车允许放货" + "新点位:" + newPointCode + map ) //
.build(); // JSONObject map = new JSONObject();
logDto.setLog_level(4); // map.put("status", 200);
luceneExecuteLogService.deviceExecuteLog(logDto); // map.put("message", "允许叉车放货!" + "点位" + newPointCode);
return map; // log.info("允许仙工AGV放货设备号 - {}", newPointCode);
} // LuceneLogDto logDto = LuceneLogDto.builder()
//放货前等待 // .device_code(instructionDto.getCarno())
if (address.contains("PUT")) { // .content("叉车允许放货" + "新点位:" + newPointCode + map )
return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto); // .build();
} // logDto.setLog_level(4);
} // luceneExecuteLogService.deviceExecuteLog(logDto);
} // return map;
} // }
if (address.contains("OUT")) { // //放货前等待
String deviceCodeNow = address.substring(0, address.length() - 6); // if (address.contains("PUT")) {
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) { // return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!"); // }
} // }
// }
if (address.contains("GET")) { // }
//取货完成 // if (address.contains("OUT")) {
JSONObject jsonObject = agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto); // String deviceCodeNow = address.substring(0, address.length() - 6);
if (StringUtil.equals("200", jsonObject.getString("status"))) { // if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
log.info("仙工AGV取货完成后离开设备号 - {}", deviceCodeNow); // throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
return jsonObject; // }
} //
} else if (address.contains("PUT")) { // if (address.contains("GET")) {
//货完成 // //货完成
JSONObject jsonObject = agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto); // JSONObject jsonObject = agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto);
if (StringUtil.equals("200", jsonObject.getString("status"))) { // if (StringUtil.equals("200", jsonObject.getString("status"))) {
log.info("仙工AGV货完成后离开,设备号 - {}", deviceCodeNow); // log.info("仙工AGV货完成后离开,设备号 - {}", deviceCodeNow);
return jsonObject; // return jsonObject;
} // }
// } else if (address.contains("PUT")) {
} // //放货完成
} // JSONObject jsonObject = agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto);
// if (StringUtil.equals("200", jsonObject.getString("status"))) {
throw new BadRequestException("请求失败IN OUT 站点错误!"); // log.info("仙工AGV放货完成后离开设备号 - {}", deviceCodeNow);
// return jsonObject;
// }
//
// }
// }
//
// throw new BadRequestException("请求失败IN OUT 站点错误!");
} }
private String applyCCAgvTask(String task_code, Instruction instructionDto) { private String applyCCAgvTask(String task_code, Instruction instructionDto) {

View File

@@ -50,7 +50,7 @@ public class XgHttpUtil {
return new UnifiedResponse<>(false, "未开启连接该系统!"); return new UnifiedResponse<>(false, "未开启连接该系统!");
} }
try { try {
System.out.println(REQUEST_ADAPTER.getUrl()); // System.out.println(REQUEST_ADAPTER.getUrl());
String body = HttpRequest String body = HttpRequest
.post(REQUEST_ADAPTER.getUrl() + path) .post(REQUEST_ADAPTER.getUrl() + path)
.setConnectionTimeout(10000) .setConnectionTimeout(10000)