|
|
@ -5,7 +5,6 @@ import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import net.sf.json.JSONObject; |
|
|
|
import org.nl.acs.device_driver.standard_conveyor_line.StandardConveyorLineDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; |
|
|
|
import org.nl.acs.ext.wms.service.AgvToAcsService; |
|
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
|
import org.nl.acs.instruction.service.dto.Instruction; |
|
|
@ -13,6 +12,7 @@ import org.nl.acs.log.service.LogServer; |
|
|
|
import org.nl.acs.opc.Device; |
|
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
|
import org.nl.acs.task.service.TaskService; |
|
|
|
import org.nl.exception.BadRequestException; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
@ -39,17 +39,18 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { |
|
|
|
String address = param.getString("address"); |
|
|
|
StandardConveyorLineDeviceDriver standardConveyorLineDeviceDriver; |
|
|
|
Instruction instructionDto = instructionService.findByCode(inst_code); |
|
|
|
String task_code = instructionDto.getTask_code(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> feedMap = new HashMap(); |
|
|
|
feedMap.put("taskCode", task_code); |
|
|
|
feedMap.put("taskType", instructionDto.getInstruction_type()); |
|
|
|
if (ObjectUtil.isEmpty(instructionDto)) { |
|
|
|
map.put("status", 400); |
|
|
|
map.put("message", "请求失败,指令为空!"); |
|
|
|
logServer.log(task_code, "waitpointRequest", "erro", param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|
|
|
return map; |
|
|
|
logServer.log("", "waitpointRequest", "erro", param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", ""); |
|
|
|
// return map;
|
|
|
|
throw new BadRequestException("请求失败,指令为空!"); |
|
|
|
} |
|
|
|
String task_code = instructionDto.getTask_code(); |
|
|
|
Map<String, Object> feedMap = new HashMap(); |
|
|
|
feedMap.put("taskCode", task_code); |
|
|
|
feedMap.put("taskType", instructionDto.getInstruction_type()); |
|
|
|
String type = ""; |
|
|
|
String start_device_code = instructionDto.getStart_device_code(); |
|
|
|
String next_device_code = instructionDto.getNext_device_code(); |
|
|
@ -60,28 +61,30 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { |
|
|
|
standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) deviceNow.getDeviceDriver(); |
|
|
|
if (start_device_code.equals(deviceCodeNow)) { |
|
|
|
if (standardConveyorLineDeviceDriver.getMove() == 1) { |
|
|
|
// feedMap.put("feedbackStatus", "applyTake");
|
|
|
|
//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","“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", 400);
|
|
|
|
// map.put("message", "操作失败");
|
|
|
|
// type = "erro";
|
|
|
|
// logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code());
|
|
|
|
//}
|
|
|
|
feedMap.put("feedbackStatus", "applyTake"); |
|
|
|
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", "“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", 400); |
|
|
|
map.put("message", "操作失败"); |
|
|
|
type = "erro"; |
|
|
|
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|
|
|
throw new BadRequestException("请求失败!"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
map.put("status", 400); |
|
|
|
map.put("message", "请求失败,起点位置无货!"); |
|
|
|
type = "erro"; |
|
|
|
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|
|
|
throw new BadRequestException("请求失败,起点位置无货!"); |
|
|
|
} |
|
|
|
} else if (deviceCodeNow.equals(next_device_code)) { |
|
|
|
if (standardConveyorLineDeviceDriver.getMove() != 0) { |
|
|
@ -89,26 +92,26 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { |
|
|
|
map.put("message", "请求失败,终点位置有货!"); |
|
|
|
type = "erro"; |
|
|
|
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|
|
|
throw new BadRequestException("请求失败,终点位置有货!"); |
|
|
|
} else { |
|
|
|
//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 {
|
|
|
|
//logServer.log(task_code, "waitpointRequest", "waitpointRequest", param.toString(), feedback.toString(), responseCode + "", "", "");
|
|
|
|
// map.put("status", 400);
|
|
|
|
// map.put("message", "操作失败");
|
|
|
|
// type = "erro";
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
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 { |
|
|
|
logServer.log(task_code, "waitpointRequest", "waitpointRequest", param.toString(), feedback.toString(), responseCode + "", "", ""); |
|
|
|
map.put("status", 400); |
|
|
|
map.put("message", "操作失败"); |
|
|
|
type = "erro"; |
|
|
|
throw new BadRequestException("请求失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -121,27 +124,29 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { |
|
|
|
standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) deviceNow.getDeviceDriver(); |
|
|
|
if (start_device_code.equals(deviceCodeNow)) { |
|
|
|
if (standardConveyorLineDeviceDriver.getMove() == 0) { |
|
|
|
//standardConveyorLineDeviceDriver.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 {
|
|
|
|
// logServer.log(task_code, "waitpointRequest", "waitpointRequest", param.toString(), feedback.toString(), responseCode + "", "", "");
|
|
|
|
// map.put("status", 400);
|
|
|
|
// map.put("message", "操作失败");
|
|
|
|
// type = "erro";
|
|
|
|
// }
|
|
|
|
standardConveyorLineDeviceDriver.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", 400); |
|
|
|
map.put("message", "操作失败"); |
|
|
|
type = "erro"; |
|
|
|
logServer.log(task_code, "waitpointRequest", type, param.toString(), feedback.toString(), responseCode + "", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|
|
|
throw new BadRequestException("请求失败!"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
map.put("status", 400); |
|
|
|
map.put("message", "请求失败,起点位置有货!"); |
|
|
|
type = "erro"; |
|
|
|
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|
|
|
throw new BadRequestException("请求失败,起点位置有货!"); |
|
|
|
} |
|
|
|
} else if (next_device_code.equals(deviceCodeNow)) { |
|
|
|
if (standardConveyorLineDeviceDriver.getMove() == 0) { |
|
|
@ -149,23 +154,25 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { |
|
|
|
map.put("message", "请求失败,终点位置无货!"); |
|
|
|
type = "erro"; |
|
|
|
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|
|
|
throw new BadRequestException("请求失败,终点位置无货!"); |
|
|
|
} else { |
|
|
|
// standardConveyorLineDeviceDriver.writing(1,2);
|
|
|
|
// 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", 400);
|
|
|
|
// map.put("message", "操作失败");
|
|
|
|
// type = "erro";
|
|
|
|
// logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code());
|
|
|
|
// }
|
|
|
|
standardConveyorLineDeviceDriver.writing(1, 2); |
|
|
|
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", 400); |
|
|
|
map.put("message", "操作失败"); |
|
|
|
type = "erro"; |
|
|
|
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|
|
|
throw new BadRequestException("请求失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -174,6 +181,7 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { |
|
|
|
map.put("status", 400); |
|
|
|
map.put("message", "请求失败,IN OUT 站点错误!"); |
|
|
|
logServer.log(task_code, "waitpointRequest", "erro", param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); |
|
|
|
return map; |
|
|
|
throw new BadRequestException("请求失败,终点位置无货!"); |
|
|
|
//return map;
|
|
|
|
} |
|
|
|
} |
|
|
|