长兴特科拉项目
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public interface XianGongAgvService {
|
|||||||
* @param requestParam
|
* @param requestParam
|
||||||
* @return
|
* @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.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();
|
||||||
|
|||||||
@@ -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")) {
|
|
||||||
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();
|
JSONObject map = new JSONObject();
|
||||||
map.put("status", 200);
|
map.put("status", 200);
|
||||||
map.put("message", "取货二次分配追加诺宝成功!");
|
map.put("message", "允许取货!");
|
||||||
return map;
|
return map;
|
||||||
}
|
// if (address.contains("IN") || address.contains("WAIT")) {
|
||||||
//如果是放货二次分配,取放货二次分配需要重新追加动作块
|
// String task_code = instructionDto.getTask_code();
|
||||||
if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
|
// String deviceCodeNow;
|
||||||
Integer actionType = ActionTypeEnum.OUT_STOCK.getCode();
|
// if (address.contains("WAIT")) {
|
||||||
String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto);
|
// deviceCodeNow = address.substring(0, address.length() - 4);
|
||||||
// sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), deviceCodeNow, instructionDto);
|
// } else {
|
||||||
log.info("放货二次分配追加诺宝成功,新点位 - {}", newPointCode);
|
// deviceCodeNow = address.substring(0, address.length() - 5);
|
||||||
JSONObject map = new JSONObject();
|
// }
|
||||||
map.put("status", 200);
|
// if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
|
||||||
map.put("message", "放货二次分配追加诺宝成功!");
|
// LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
return map;
|
// .device_code(instructionDto.getCarno())
|
||||||
}
|
// .content("设备号 " + deviceCodeNow + " 不存在!")
|
||||||
}
|
// .build();
|
||||||
//一楼叉车
|
// logDto.setLog_level(4);
|
||||||
if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
|
// luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
if (address.contains("GET")) {
|
// throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
|
||||||
//取货前等待
|
// }
|
||||||
return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
|
// //一楼诺宝agv
|
||||||
} else {
|
// if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
|
||||||
//放货前二次分配
|
//
|
||||||
if (address.contains("WAIT")) {
|
// if (address.contains("GET")) {
|
||||||
String newPointCode = applyCCAgvTask(task_code, instructionDto);
|
// return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
|
||||||
|
// } else if (address.contains("PUT")) {
|
||||||
JSONObject map = new JSONObject();
|
// return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
|
||||||
map.put("status", 200);
|
// }
|
||||||
map.put("message", "允许叉车放货!" + "点位" + newPointCode);
|
// //如果是取货二次分配,取放货二次分配需要重新追加动作块
|
||||||
log.info("允许仙工AGV放货,设备号 - {}", newPointCode);
|
// if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
|
||||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
// Integer actionType = ActionTypeEnum.IN_STOCK.getCode();
|
||||||
.device_code(instructionDto.getCarno())
|
// String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto);
|
||||||
.content("叉车允许放货" + "新点位:" + newPointCode + map )
|
// log.info("取货二次分配追加诺宝成功,新点位 - {}", newPointCode);
|
||||||
.build();
|
// JSONObject map = new JSONObject();
|
||||||
logDto.setLog_level(4);
|
// map.put("status", 200);
|
||||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
// map.put("message", "取货二次分配追加诺宝成功!");
|
||||||
return map;
|
// return map;
|
||||||
}
|
// }
|
||||||
//放货前等待
|
// //如果是放货二次分配,取放货二次分配需要重新追加动作块
|
||||||
if (address.contains("PUT")) {
|
// if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
|
||||||
return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
|
// 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();
|
||||||
if (address.contains("OUT")) {
|
// map.put("status", 200);
|
||||||
String deviceCodeNow = address.substring(0, address.length() - 6);
|
// map.put("message", "放货二次分配追加诺宝成功!");
|
||||||
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
|
// return map;
|
||||||
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
|
// }
|
||||||
}
|
// }
|
||||||
|
// //一楼叉车
|
||||||
if (address.contains("GET")) {
|
// if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
|
||||||
//取货完成
|
// if (address.contains("GET")) {
|
||||||
JSONObject jsonObject = agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto);
|
// //取货前等待
|
||||||
if (StringUtil.equals("200", jsonObject.getString("status"))) {
|
// return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
|
||||||
log.info("仙工AGV取货完成后离开,设备号 - {}", deviceCodeNow);
|
// } else {
|
||||||
return jsonObject;
|
// //放货前二次分配
|
||||||
}
|
// if (address.contains("WAIT")) {
|
||||||
} else if (address.contains("PUT")) {
|
// String newPointCode = applyCCAgvTask(task_code, instructionDto);
|
||||||
//放货完成
|
//
|
||||||
JSONObject jsonObject = agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto);
|
// JSONObject map = new JSONObject();
|
||||||
if (StringUtil.equals("200", jsonObject.getString("status"))) {
|
// map.put("status", 200);
|
||||||
log.info("仙工AGV放货完成后离开,设备号 - {}", deviceCodeNow);
|
// map.put("message", "允许叉车放货!" + "点位" + newPointCode);
|
||||||
return jsonObject;
|
// log.info("允许仙工AGV放货,设备号 - {}", newPointCode);
|
||||||
}
|
// LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
// .device_code(instructionDto.getCarno())
|
||||||
}
|
// .content("叉车允许放货" + "新点位:" + newPointCode + map )
|
||||||
}
|
// .build();
|
||||||
|
// logDto.setLog_level(4);
|
||||||
throw new BadRequestException("请求失败,IN OUT 站点错误!");
|
// 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) {
|
private String applyCCAgvTask(String task_code, Instruction instructionDto) {
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user