53 changed files with 3601 additions and 3596 deletions
@ -0,0 +1,2 @@ |
|||
2022-12-04 15:18:25.062 [nl-pool3-thread-9] INFO org.nl.acs.agv.server.impl.AgvServiceImpl - 任务号:-00024,指令号00067,下发agv订单序列参数:{"id":"00067","complete":true,"blocks":[{"blockId":"70e4860e52a74ac5ba66bb47075277b4","location":"1008IN","operation":"script","id":"1008IN","script_name":"userpy/interact.py","script_args":{"addr":"http://127.0.0.1:8010","data":{"reach":{"task_code":"00067","address":"1008IN"}},"protocol":"HTTP"}},{"blockId":"b35e8b1db3d34b0baf8f95c0b16aedd8","location":"1008","operation":"JackLoad"},{"blockId":"99baaed5c81c4c7b823a580817589ecd","location":"1008OUT","operation":"script","id":"1008OUT","script_name":"userpy/interact.py","script_args":{"addr":"http://127.0.0.1:8010","data":{"reach":{"task_code":"00067","address":"1008OUT"}},"protocol":"HTTP"}},{"blockId":"1769a1f2350c4f02b18ce72cc5f1bce0","location":"1005IN","operation":"script","id":"1005IN","script_name":"userpy/interact.py","script_args":{"addr":"http://127.0.0.1:8010","data":{"reach":{"task_code":"00067","address":"1005IN"}},"protocol":"HTTP"}},{"blockId":"0db76fae9e544408851348adb127e5ce","location":"1005","operation":"JackUnload"},{"blockId":"0ef593155f7941eda29cab8be8907425","location":"1005OUT","operation":"script","id":"1005OUT","script_name":"userpy/interact.py","script_args":{"addr":"http://127.0.0.1:8010","data":{"reach":{"task_code":"00067","address":"1005OUT"}},"protocol":"HTTP"}}]} |
|||
2022-12-04 15:19:16.402 [http-nio-8010-exec-5] INFO org.nl.acs.agv.server.impl.AgvServiceImpl - 任务号:-00024,指令号00068,下发agv订单序列参数:{"id":"00068","complete":true,"blocks":[{"blockId":"0ae6f28e54b24ef1a7ab22c6f49313b5","location":"1008IN","operation":"script","id":"1008IN","script_name":"userpy/interact.py","script_args":{"addr":"http://127.0.0.1:8010","data":{"reach":{"task_code":"00068","address":"1008IN"}},"protocol":"HTTP"}},{"blockId":"5915e4a896ef41b495163780ca7e08d1","location":"1008","operation":"JackLoad"},{"blockId":"3c3e7d6d531b44d0a55817efbb3b8434","location":"1008OUT","operation":"script","id":"1008OUT","script_name":"userpy/interact.py","script_args":{"addr":"http://127.0.0.1:8010","data":{"reach":{"task_code":"00068","address":"1008OUT"}},"protocol":"HTTP"}},{"blockId":"af4d3333d2da48518e531eae74461411","location":"1005IN","operation":"script","id":"1005IN","script_name":"userpy/interact.py","script_args":{"addr":"http://127.0.0.1:8010","data":{"reach":{"task_code":"00068","address":"1005IN"}},"protocol":"HTTP"}},{"blockId":"5056dcd431ef4e0bbc20551e6b933b73","location":"1005","operation":"JackUnload"},{"blockId":"242f390e11b1401599ac3d2dcd81644c","location":"1005OUT","operation":"script","id":"1005OUT","script_name":"userpy/interact.py","script_args":{"addr":"http://127.0.0.1:8010","data":{"reach":{"task_code":"00068","address":"1005OUT"}},"protocol":"HTTP"}}]} |
@ -0,0 +1,315 @@ |
|||
package org.nl.acs.ext.wms.service; |
|||
|
|||
import net.sf.json.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; |
|||
import org.nl.acs.device_driver.standard_conveyor_line.StandardConveyorLineDeviceDriver; |
|||
import org.nl.acs.ext.wms.service.impl.AcsToWmsZDServiceImpl; |
|||
import org.nl.acs.instruction.service.InstructionService; |
|||
import org.nl.acs.instruction.service.dto.Instruction; |
|||
import org.nl.acs.log.service.LogServer; |
|||
import org.nl.acs.opc.Device; |
|||
import org.nl.acs.opc.DeviceAppService; |
|||
import org.nl.exception.BadRequestException; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author: geng by |
|||
* @createDate: 2022/12/5 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class AgvWaitUtil { |
|||
private final DeviceAppService deviceAppService; |
|||
private final AcsToWmsZDServiceImpl acsToWmsZDService; |
|||
private final InstructionService instructionService; |
|||
@Autowired |
|||
LogServer logServer; |
|||
|
|||
//取货前等待
|
|||
public Map<String, Object> waitInGet(String device_code, Map<String, Object> feedMap, JSONObject param) { |
|||
String inst_code = param.getString("task_code"); |
|||
Instruction instructionDto = instructionService.findByCode(inst_code); |
|||
String task_code = String.valueOf(feedMap.get("taskCode")); |
|||
StandardConveyorLineDeviceDriver standardConveyorLineDeviceDriver; |
|||
StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver; |
|||
Device device = deviceAppService.findDeviceByCode(device_code); |
|||
JSONObject map = new JSONObject(); |
|||
String type = ""; |
|||
if (device.getDeviceDriver() instanceof StandardConveyorLineDeviceDriver) { |
|||
standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver(); |
|||
if (standardConveyorLineDeviceDriver.getMove() == 1 && standardConveyorLineDeviceDriver.getAction() == 1) { |
|||
feedMap.put("feedbackStatus", "applyTake"); |
|||
Map<String, Object> feedback = acsToWmsZDService.taskFeedback(feedMap); |
|||
int responseCode = Integer.parseInt((String) feedback.get("responseCode")); |
|||
String responseMessage = String.valueOf(feedback.get("responseMessage")); |
|||
if (responseCode == 0) { |
|||
feedback.put("feedbackStatus", "taking"); |
|||
acsToWmsZDService.taskFeedback(feedMap); |
|||
map.put("status", 200); |
|||
map.put("message", "请求成功"); |
|||
type = "info"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
} else { |
|||
map.put("status", responseCode); |
|||
map.put("message", responseMessage); |
|||
type = "erro"; |
|||
logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败!"); |
|||
} |
|||
} else { |
|||
map.put("status", 400); |
|||
map.put("message", "请求失败,起点位置无货!move = " + standardConveyorLineDeviceDriver.getMove() + "action = " + standardConveyorLineDeviceDriver.getAction()); |
|||
type = "erro"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败,起点位置无货!"); |
|||
} |
|||
} |
|||
if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { |
|||
standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); |
|||
if (standardCoveyorControlDeviceDriver.getBySignal() == 1 && standardCoveyorControlDeviceDriver.getByAction() == 0) { |
|||
feedMap.put("feedbackStatus", "applyTake"); |
|||
Map<String, Object> feedback = acsToWmsZDService.taskFeedback(feedMap); |
|||
int responseCode = Integer.parseInt((String) feedback.get("responseCode")); |
|||
String responseMessage = String.valueOf(feedback.get("responseMessage")); |
|||
if (responseCode == 0) { |
|||
feedback.put("feedbackStatus", "taking"); |
|||
acsToWmsZDService.taskFeedback(feedMap); |
|||
map.put("status", 200); |
|||
map.put("message", "请求成功"); |
|||
type = "info"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
} else { |
|||
map.put("status", responseCode); |
|||
map.put("message", responseMessage); |
|||
type = "erro"; |
|||
logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败!"); |
|||
} |
|||
} else { |
|||
map.put("status", 400); |
|||
map.put("message", "请求失败,起点位置无货!move = " + standardCoveyorControlDeviceDriver.getBySignal()); |
|||
type = "erro"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败,起点位置无货!"); |
|||
} |
|||
} |
|||
return map; |
|||
} |
|||
|
|||
//取货完成等待
|
|||
public Map<String, Object> waitOutGet(String device_code, Map<String, Object> feedMap, JSONObject param) { |
|||
String inst_code = param.getString("task_code"); |
|||
Instruction instructionDto = instructionService.findByCode(inst_code); |
|||
String task_code = String.valueOf(feedMap.get("taskCode")); |
|||
StandardConveyorLineDeviceDriver standardConveyorLineDeviceDriver; |
|||
StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver; |
|||
Device device = deviceAppService.findDeviceByCode(device_code); |
|||
JSONObject map = new JSONObject(); |
|||
String type = ""; |
|||
if (device.getDeviceDriver() instanceof StandardConveyorLineDeviceDriver) { |
|||
standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver(); |
|||
if (standardConveyorLineDeviceDriver.getMove() == 0) { |
|||
standardConveyorLineDeviceDriver.writing(2); |
|||
feedMap.put("feedbackStatus", "takeFinish"); |
|||
Map<String, Object> feedback = acsToWmsZDService.taskFeedback(feedMap); |
|||
int responseCode = (int) feedback.get("responseCode"); |
|||
String responseMessage = (String) feedback.get("responseMessage"); |
|||
if (responseCode == 0) { |
|||
map.put("status", 200); |
|||
map.put("message", "请求成功"); |
|||
type = "info"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
} else { |
|||
map.put("status", responseCode); |
|||
map.put("message", responseMessage); |
|||
type = "erro"; |
|||
logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败!"); |
|||
} |
|||
} else { |
|||
map.put("status", 400); |
|||
map.put("message", "请求失败,取货完成后,起点位置仍有货!move=" + standardConveyorLineDeviceDriver.getMove()); |
|||
type = "erro"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败,起点位置有货!"); |
|||
} |
|||
} |
|||
if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { |
|||
standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); |
|||
if (standardCoveyorControlDeviceDriver.getBySignal() == 0) { |
|||
standardCoveyorControlDeviceDriver.writing(1, "2"); |
|||
feedMap.put("feedbackStatus", "takeFinish"); |
|||
Map<String, Object> feedback = acsToWmsZDService.taskFeedback(feedMap); |
|||
int responseCode = (int) feedback.get("responseCode"); |
|||
String responseMessage = (String) feedback.get("responseMessage"); |
|||
if (responseCode == 0) { |
|||
map.put("status", 200); |
|||
map.put("message", "请求成功"); |
|||
type = "info"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
} else { |
|||
map.put("status", responseCode); |
|||
map.put("message", responseMessage); |
|||
type = "erro"; |
|||
logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败!"); |
|||
} |
|||
} else { |
|||
map.put("status", 400); |
|||
map.put("message", "请求失败,取货完成后,起点位置仍有货!move=" + standardCoveyorControlDeviceDriver.getBySignal()); |
|||
type = "erro"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败,起点位置有货!"); |
|||
} |
|||
} |
|||
return map; |
|||
} |
|||
|
|||
//放货前等待
|
|||
public Map<String, Object> waitInPut(String device_code, Map<String, Object> feedMap, JSONObject param) { |
|||
String inst_code = param.getString("task_code"); |
|||
Instruction instructionDto = instructionService.findByCode(inst_code); |
|||
String task_code = String.valueOf(feedMap.get("taskCode")); |
|||
StandardConveyorLineDeviceDriver standardConveyorLineDeviceDriver; |
|||
StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver; |
|||
Device device = deviceAppService.findDeviceByCode(device_code); |
|||
JSONObject map = new JSONObject(); |
|||
String type = ""; |
|||
if (device.getDeviceDriver() instanceof StandardConveyorLineDeviceDriver) { |
|||
standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver(); |
|||
if (standardConveyorLineDeviceDriver.getMove() == 0 && standardConveyorLineDeviceDriver.getAction() == 2) { |
|||
feedMap.put("feedbackStatus", "applyPut"); |
|||
Map<String, Object> feedback = acsToWmsZDService.taskFeedback(feedMap); |
|||
int responseCode = Integer.parseInt((String) feedback.get("responseCode")); |
|||
String responseMessage = (String) feedback.get("responseMessage"); |
|||
if (responseCode == 0) { |
|||
feedback.put("feedbackStatus", "puting"); |
|||
acsToWmsZDService.taskFeedback(feedMap); |
|||
map.put("status", 200); |
|||
map.put("message", "请求成功"); |
|||
type = "info"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
} else { |
|||
map.put("status", responseCode); |
|||
map.put("message", responseMessage); |
|||
type = "erro"; |
|||
logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败!"); |
|||
} |
|||
} else { |
|||
map.put("status", 400); |
|||
map.put("message", "请求失败,终点位置有货!move = " + standardConveyorLineDeviceDriver.getMove() + "action = " + standardConveyorLineDeviceDriver.getAction()); |
|||
type = "erro"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败,终点位置有货!"); |
|||
} |
|||
} |
|||
if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { |
|||
standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); |
|||
if (standardCoveyorControlDeviceDriver.getBySignal() == 0 && standardCoveyorControlDeviceDriver.getByAction() == 0) { |
|||
feedMap.put("feedbackStatus", "applyPut"); |
|||
Map<String, Object> feedback = acsToWmsZDService.taskFeedback(feedMap); |
|||
int responseCode = Integer.parseInt((String) feedback.get("responseCode")); |
|||
String responseMessage = (String) feedback.get("responseMessage"); |
|||
if (responseCode == 0) { |
|||
feedback.put("feedbackStatus", "puting"); |
|||
acsToWmsZDService.taskFeedback(feedMap); |
|||
map.put("status", 200); |
|||
map.put("message", "请求成功"); |
|||
type = "info"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
} else { |
|||
map.put("status", responseCode); |
|||
map.put("message", responseMessage); |
|||
type = "erro"; |
|||
logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败!"); |
|||
} |
|||
} else { |
|||
map.put("status", 400); |
|||
map.put("message", "请求失败,终点位置有货!move = " + standardCoveyorControlDeviceDriver.getBySignal()); |
|||
type = "erro"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败,终点位置有货!"); |
|||
} |
|||
} |
|||
return map; |
|||
} |
|||
|
|||
|
|||
//放货完成等待
|
|||
public Map<String, Object> waitOutPut(String device_code, Map<String, Object> feedMap, JSONObject param) { |
|||
String inst_code = param.getString("task_code"); |
|||
Instruction instructionDto = instructionService.findByCode(inst_code); |
|||
String task_code = String.valueOf(feedMap.get("taskCode")); |
|||
StandardConveyorLineDeviceDriver standardConveyorLineDeviceDriver; |
|||
StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver; |
|||
Device device = deviceAppService.findDeviceByCode(device_code); |
|||
JSONObject map = new JSONObject(); |
|||
String type = ""; |
|||
if (device.getDeviceDriver() instanceof StandardConveyorLineDeviceDriver) { |
|||
standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver(); |
|||
if (standardConveyorLineDeviceDriver.getMove() == 1) { |
|||
standardConveyorLineDeviceDriver.writing(3); |
|||
feedMap.put("feedbackStatus", "putFinish"); |
|||
Map<String, Object> feedback = acsToWmsZDService.taskFeedback(feedMap); |
|||
int responseCode = (int) feedback.get("responseCode"); |
|||
String responseMessage = (String) feedback.get("responseMessage"); |
|||
if (responseCode == 0) { |
|||
map.put("status", 200); |
|||
map.put("message", "请求成功"); |
|||
type = "info"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
} else { |
|||
map.put("status", responseCode); |
|||
map.put("message", responseMessage); |
|||
type = "erro"; |
|||
logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败"); |
|||
} |
|||
} else { |
|||
map.put("status", 400); |
|||
map.put("message", "请求失败,放货货完成后,终点位置仍无货!move=" + standardConveyorLineDeviceDriver.getMove()); |
|||
type = "erro"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败,放货货完成后,终点位置仍无货!"); |
|||
} |
|||
} |
|||
if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { |
|||
standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); |
|||
if (standardCoveyorControlDeviceDriver.getBySignal() == 1) { |
|||
standardCoveyorControlDeviceDriver.writing(1, "3"); |
|||
feedMap.put("feedbackStatus", "putFinish"); |
|||
Map<String, Object> feedback = acsToWmsZDService.taskFeedback(feedMap); |
|||
int responseCode = (int) feedback.get("responseCode"); |
|||
String responseMessage = (String) feedback.get("responseMessage"); |
|||
if (responseCode == 0) { |
|||
map.put("status", 200); |
|||
map.put("message", "请求成功"); |
|||
type = "info"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
} else { |
|||
map.put("status", responseCode); |
|||
map.put("message", responseMessage); |
|||
type = "erro"; |
|||
logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败"); |
|||
} |
|||
} else { |
|||
map.put("status", 400); |
|||
map.put("message", "请求失败,放货货完成后,终点位置仍无货!move=" + standardCoveyorControlDeviceDriver.getBySignal()); |
|||
type = "erro"; |
|||
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|||
throw new BadRequestException("请求失败,放货货完成后,终点位置仍无货!"); |
|||
} |
|||
} |
|||
return map; |
|||
} |
|||
} |
File diff suppressed because it is too large
Loading…
Reference in new issue