长兴特科拉项目
This commit is contained in:
@@ -23,10 +23,10 @@ public class XianGongAgvController {
|
||||
@Autowired
|
||||
private XianGongAgvService xianGongAgentService;
|
||||
|
||||
@PostMapping("/api/agv/xg/waitPointRequest")
|
||||
@PostMapping("/api/agv/waitPointRequest")
|
||||
@Log("仙工AGV请求取放货")
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public interface XianGongAgvService {
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
JSONObject xgAGVWaitPointRequest(JSONObject requestParam);
|
||||
JSONObject xgAGVWaitPointRequest(JSONObject requestParam) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,10 +7,13 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.AGVSchedulingService;
|
||||
import org.nl.acs.ext.RequestAdapter;
|
||||
import org.nl.acs.ext.UnifiedResponse;
|
||||
import org.nl.acs.ext.xg.XgHttpUtil;
|
||||
import org.nl.acs.ext.xg.XgRequestAdapter;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@@ -21,6 +24,9 @@ public class AGVSchedulingServiceImpl implements AGVSchedulingService {
|
||||
@Autowired
|
||||
private XgHttpUtil xgHttpUtil;
|
||||
|
||||
@Value("${agvToAcs.addr}")
|
||||
private String addr;
|
||||
|
||||
@Override
|
||||
public <T> UnifiedResponse<T> sendAGVOrderSequences(Instruction inst) {
|
||||
JSONObject reqParam = new JSONObject();
|
||||
@@ -67,8 +73,20 @@ public class AGVSchedulingServiceImpl implements AGVSchedulingService {
|
||||
// 起点2
|
||||
block = new JSONObject();
|
||||
block.put("blockId", IdUtil.simpleUUID());
|
||||
block.put("location", inst.getStart_point_code2());
|
||||
block.put("operation", "JackLoad");
|
||||
block.put("location", inst.getStart_point_code2() + "INGET");
|
||||
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);
|
||||
// 终点2
|
||||
block = new JSONObject();
|
||||
|
||||
@@ -737,7 +737,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) {
|
||||
public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) throws Exception{
|
||||
log.info("仙工AGV请求取放货,请求参数 - {}", requestParam);
|
||||
String inst_code = requestParam.getString("task_code");
|
||||
Instruction instructionDto = instructionService.findByCodeFromCache(inst_code);
|
||||
@@ -759,107 +759,114 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
throw new BadRequestException("请求失败,地址为空!");
|
||||
}
|
||||
if (address.contains("IN") || address.contains("WAIT")) {
|
||||
String task_code = instructionDto.getTask_code();
|
||||
String deviceCodeNow;
|
||||
if (address.contains("WAIT")) {
|
||||
deviceCodeNow = address.substring(0, address.length() - 4);
|
||||
} else {
|
||||
deviceCodeNow = address.substring(0, address.length() - 5);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(instructionDto.getCarno())
|
||||
.content("设备号 " + deviceCodeNow + " 不存在!")
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
|
||||
}
|
||||
//一楼诺宝agv
|
||||
if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
|
||||
|
||||
if (address.contains("GET")) {
|
||||
return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
|
||||
} else if (address.contains("PUT")) {
|
||||
return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
|
||||
}
|
||||
//如果是取货二次分配,取放货二次分配需要重新追加动作块
|
||||
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);
|
||||
log.info("取货二次分配追加诺宝成功,新点位 - {}", newPointCode);
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "取货二次分配追加诺宝成功!");
|
||||
return map;
|
||||
}
|
||||
//如果是放货二次分配,取放货二次分配需要重新追加动作块
|
||||
if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
|
||||
Integer actionType = ActionTypeEnum.OUT_STOCK.getCode();
|
||||
String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto);
|
||||
// sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), deviceCodeNow, instructionDto);
|
||||
log.info("放货二次分配追加诺宝成功,新点位 - {}", newPointCode);
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "放货二次分配追加诺宝成功!");
|
||||
return map;
|
||||
}
|
||||
}
|
||||
//一楼叉车
|
||||
if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
|
||||
if (address.contains("GET")) {
|
||||
//取货前等待
|
||||
return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
|
||||
} else {
|
||||
//放货前二次分配
|
||||
if (address.contains("WAIT")) {
|
||||
String newPointCode = applyCCAgvTask(task_code, instructionDto);
|
||||
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "允许叉车放货!" + "点位" + newPointCode);
|
||||
log.info("允许仙工AGV放货,设备号 - {}", newPointCode);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(instructionDto.getCarno())
|
||||
.content("叉车允许放货" + "新点位:" + newPointCode + map )
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
return map;
|
||||
}
|
||||
//放货前等待
|
||||
if (address.contains("PUT")) {
|
||||
return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (address.contains("OUT")) {
|
||||
String deviceCodeNow = address.substring(0, address.length() - 6);
|
||||
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
|
||||
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
|
||||
}
|
||||
|
||||
if (address.contains("GET")) {
|
||||
//取货完成
|
||||
JSONObject jsonObject = agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto);
|
||||
if (StringUtil.equals("200", jsonObject.getString("status"))) {
|
||||
log.info("仙工AGV取货完成后离开,设备号 - {}", deviceCodeNow);
|
||||
return jsonObject;
|
||||
}
|
||||
} else if (address.contains("PUT")) {
|
||||
//放货完成
|
||||
JSONObject jsonObject = agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto);
|
||||
if (StringUtil.equals("200", jsonObject.getString("status"))) {
|
||||
log.info("仙工AGV放货完成后离开,设备号 - {}", deviceCodeNow);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
throw new BadRequestException("请求失败,IN OUT 站点错误!");
|
||||
log.info("AGV取货前等待30s...");
|
||||
Thread.sleep(30000L);
|
||||
log.info("允许取货,点位 - {}", instructionDto.getStart_point_code2());
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "允许取货!");
|
||||
return map;
|
||||
// if (address.contains("IN") || address.contains("WAIT")) {
|
||||
// String task_code = instructionDto.getTask_code();
|
||||
// String deviceCodeNow;
|
||||
// if (address.contains("WAIT")) {
|
||||
// deviceCodeNow = address.substring(0, address.length() - 4);
|
||||
// } else {
|
||||
// deviceCodeNow = address.substring(0, address.length() - 5);
|
||||
// }
|
||||
// if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
|
||||
// LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
// .device_code(instructionDto.getCarno())
|
||||
// .content("设备号 " + deviceCodeNow + " 不存在!")
|
||||
// .build();
|
||||
// logDto.setLog_level(4);
|
||||
// luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
// throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
|
||||
// }
|
||||
// //一楼诺宝agv
|
||||
// if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
|
||||
//
|
||||
// if (address.contains("GET")) {
|
||||
// return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
|
||||
// } else if (address.contains("PUT")) {
|
||||
// return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
|
||||
// }
|
||||
// //如果是取货二次分配,取放货二次分配需要重新追加动作块
|
||||
// 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);
|
||||
// log.info("取货二次分配追加诺宝成功,新点位 - {}", newPointCode);
|
||||
// JSONObject map = new JSONObject();
|
||||
// map.put("status", 200);
|
||||
// map.put("message", "取货二次分配追加诺宝成功!");
|
||||
// return map;
|
||||
// }
|
||||
// //如果是放货二次分配,取放货二次分配需要重新追加动作块
|
||||
// if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
|
||||
// Integer actionType = ActionTypeEnum.OUT_STOCK.getCode();
|
||||
// String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto);
|
||||
//// sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), deviceCodeNow, instructionDto);
|
||||
// log.info("放货二次分配追加诺宝成功,新点位 - {}", newPointCode);
|
||||
// JSONObject map = new JSONObject();
|
||||
// map.put("status", 200);
|
||||
// map.put("message", "放货二次分配追加诺宝成功!");
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
// //一楼叉车
|
||||
// if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
|
||||
// if (address.contains("GET")) {
|
||||
// //取货前等待
|
||||
// return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
|
||||
// } else {
|
||||
// //放货前二次分配
|
||||
// if (address.contains("WAIT")) {
|
||||
// String newPointCode = applyCCAgvTask(task_code, instructionDto);
|
||||
//
|
||||
// JSONObject map = new JSONObject();
|
||||
// map.put("status", 200);
|
||||
// map.put("message", "允许叉车放货!" + "点位" + newPointCode);
|
||||
// log.info("允许仙工AGV放货,设备号 - {}", newPointCode);
|
||||
// LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
// .device_code(instructionDto.getCarno())
|
||||
// .content("叉车允许放货" + "新点位:" + newPointCode + map )
|
||||
// .build();
|
||||
// logDto.setLog_level(4);
|
||||
// luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
// return map;
|
||||
// }
|
||||
// //放货前等待
|
||||
// if (address.contains("PUT")) {
|
||||
// return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (address.contains("OUT")) {
|
||||
// String deviceCodeNow = address.substring(0, address.length() - 6);
|
||||
// if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
|
||||
// throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
|
||||
// }
|
||||
//
|
||||
// if (address.contains("GET")) {
|
||||
// //取货完成
|
||||
// JSONObject jsonObject = agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto);
|
||||
// if (StringUtil.equals("200", jsonObject.getString("status"))) {
|
||||
// log.info("仙工AGV取货完成后离开,设备号 - {}", deviceCodeNow);
|
||||
// return jsonObject;
|
||||
// }
|
||||
// } else if (address.contains("PUT")) {
|
||||
// //放货完成
|
||||
// JSONObject jsonObject = agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto);
|
||||
// if (StringUtil.equals("200", jsonObject.getString("status"))) {
|
||||
// log.info("仙工AGV放货完成后离开,设备号 - {}", deviceCodeNow);
|
||||
// return jsonObject;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// throw new BadRequestException("请求失败,IN OUT 站点错误!");
|
||||
}
|
||||
|
||||
private String applyCCAgvTask(String task_code, Instruction instructionDto) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class XgHttpUtil {
|
||||
return new UnifiedResponse<>(false, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
System.out.println(REQUEST_ADAPTER.getUrl());
|
||||
// System.out.println(REQUEST_ADAPTER.getUrl());
|
||||
String body = HttpRequest
|
||||
.post(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(10000)
|
||||
|
||||
Reference in New Issue
Block a user