opt:代码优化

This commit is contained in:
2023-11-13 19:35:53 +08:00
parent c74ab66fdd
commit 247457d4a3
11 changed files with 298 additions and 391 deletions

View File

@@ -254,8 +254,7 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
logServer.deviceExecuteLog(this.device_code, "", "", "信号move" + last_move + "->" + move);
}
if (action != last_action) {
this.setRequireSucess(false);
this.setFeedbackSucess(false);
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action" + last_action + "->" + action);
}
@@ -302,14 +301,9 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
logServer.deviceExecuteLog(this.device_code, "", "", "信号inflatable_shaft_size" + last_inflatable_shaft_size + "->" + inflatable_shaft_size);
}
if (task > 0 && getTo_task_type() == 1 && !requireSucess) {
if (task > 0 && !feedbackSucess) {
update_instruction_status();
} else if (task > 0 && getTo_task_type() == 2 && !requireSucess) {
update_instruction_status2();
} else if (task > 0 && getTo_task_type() == 6 && !requireSucess) {
update_instruction_status3();
} else if (task > 0 && getTo_task_type() == 7 && !requireSucess) {
update_instruction_status4();
}
@@ -416,297 +410,6 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
}
private synchronized void update_instruction_status() {
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
ApplyManipulatorActionResponse applyManipulatorActionResponse;
Date date = new Date();
Instruction inst1 = checkInst();
if (inst1 != null) {
if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out);
} else {
this.instruction_update_time = date;
//更改任务状态
if (task > 0) {
//inst_message
if (inst1 != null) {
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
inst1.setInstruction_status("1");
inst1.setExecute_device_code(this.device_code);
instructionService.update(inst1);
}
}
}
//反馈尺寸
if (action == 2) {
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setType("2");
applyManipulatorActionRequest.setTask_code(task_code);
applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size));
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus() == 200) {
requireSucess = true;
message = "反馈LMS成功...";
logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "2");
this.writing(map);
} else {
requireSucess = false;
message = "完成反馈LMS失败" + String.valueOf(applyManipulatorActionResponse);
logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
}
}
//任务完成
if (action == 8) {
try {
finish_instruction(inst1);
this.writing("to_command", "8");
requireSucess = true;
} catch (Exception e) {
e.printStackTrace();
}
feedMessage = "";
} else {
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 8) {
feedMessage = feedMessage + "动作信号(action)不为完成状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
}
}
} else {
feedMessage = "";
}
}
private synchronized void update_instruction_status2() {
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
ApplyManipulatorActionResponse applyManipulatorActionResponse;
Date date = new Date();
Instruction inst1 = checkInst();
if (inst1 != null) {
if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out);
} else {
this.instruction_update_time = date;
//更改任务状态
if (task > 0) {
//inst_message
if (inst1 != null) {
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
inst1.setInstruction_status("1");
inst1.setExecute_device_code(this.device_code);
instructionService.update(inst1);
}
}
}
//反馈气胀轴尺寸
if (action == 2) {
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setType("2");
applyManipulatorActionRequest.setTask_code(task_code);
applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size));
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus() == 200) {
requireSucess = true;
message = "反馈LMS成功...";
logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "2");
map.put("to_task_type", "2");
this.writing(map);
} else {
requireSucess = false;
message = "完成反馈LMS失败" + String.valueOf(applyManipulatorActionResponse);
logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
}
}
//申请放货点
if (action == 3) {
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setType("3");
applyManipulatorActionRequest.setTask_code(task_code);
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
String put_device_code = applyManipulatorActionResponse.getPut_device_code();
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "3");
map.put("to_putpoint", put_device_code);
this.writing(map);
requireSucess = true;
}
//任务完成
if (action == 8) {
if (inst1 != null) {
try {
requireSucess = true;
finish_instruction(inst1);
this.writing("to_command", "8");
} catch (Exception e) {
e.printStackTrace();
}
feedMessage = "";
}
} else {
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 8) {
feedMessage = feedMessage + "动作信号(action)不为完成状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
}
}
} else {
feedMessage = "";
}
}
private synchronized void update_instruction_status3() {
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
ApplyManipulatorActionResponse applyManipulatorActionResponse;
Date date = new Date();
Instruction inst1 = checkInst();
if (inst1 != null) {
if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out);
} else {
this.instruction_update_time = date;
//更改任务状态
if (task > 0) {
//inst_message
if (inst1 != null) {
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
inst1.setInstruction_status("1");
inst1.setExecute_device_code(this.device_code);
instructionService.update(inst1);
}
}
}
//反馈尺寸
if (action == 2) {
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setType("2");
applyManipulatorActionRequest.setTask_code(task_code);
applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size));
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus() == 200) {
requireSucess = true;
message = "反馈LMS成功...";
logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "2");
this.writing(map);
} else {
requireSucess = false;
message = "完成反馈LMS失败" + String.valueOf(applyManipulatorActionResponse);
logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
}
}
//从拔轴机取货的新行架任务
if (mode == 3 && action == 1 && move == 0 && task > 0) {
if (ObjectUtil.isNotEmpty(inst1)) {
String start_device_code = inst1.getStart_device_code();
Device device = deviceAppService.findDeviceByCode(start_device_code);
PluggingUnpluggingMachineDeviceDriver pluggingUnpluggingMachineDeviceDriver;
if (device.getDeviceDriver() instanceof PluggingUnpluggingMachineDeviceDriver) {
pluggingUnpluggingMachineDeviceDriver = (PluggingUnpluggingMachineDeviceDriver) device.getDeviceDriver();
int mode = pluggingUnpluggingMachineDeviceDriver.getMode();
int error1 = pluggingUnpluggingMachineDeviceDriver.getError();
int move = pluggingUnpluggingMachineDeviceDriver.getMove();
if (mode == 2 && error1 == 0 && move == 1) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "1");
this.writing(map);
requireSucess = true;
}
}
}
} else {
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 1) {
feedMessage = feedMessage + "动作信号(action)不为取货中状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
}
//申请放货点
if (action == 3) {
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setType("3");
applyManipulatorActionRequest.setTask_code(task_code);
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
String put_device_code = applyManipulatorActionResponse.getPut_device_code();
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "3");
map.put("to_putpoint", put_device_code);
this.writing(map);
requireSucess = true;
}
//任务完成
if (action == 8) {
try {
requireSucess = true;
finish_instruction(inst1);
this.writing("to_command", "8");
} catch (Exception e) {
e.printStackTrace();
}
feedMessage = "";
} else {
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 8) {
feedMessage = feedMessage + "动作信号(action)不为完成状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
}
}
} else {
feedMessage = "";
}
}
private synchronized void update_instruction_status4() {
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
ApplyManipulatorActionResponse applyManipulatorActionResponse;
Date date = new Date();
@@ -731,106 +434,131 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
//反馈尺寸
if (action == 2) {
if (mode == 3 && action == 2) {
String task_code = inst1.getTask_code();
TaskDto task = taskserver.findByCode(task_code);
applyManipulatorActionRequest.setType("2");
applyManipulatorActionRequest.setTask_code(task_code);
applyManipulatorActionRequest.setTask_code1(task_code);
applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size));
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus() == 200) {
requireSucess = true;
feedbackSucess = true;
message = "反馈LMS成功...";
logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
String is_bushing = task.getIs_bushing();
String version = task.getVersion();
String bushing_num = task.getBushing_num();
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "2");
map.put("inflatableShaftVersion", Integer.parseInt(version));
map.put("tube_num", Integer.parseInt(bushing_num));
map.put("is_wrapped", Integer.parseInt(is_bushing));
map.put("to_command", 2);
this.writing(map);
} else {
requireSucess = false;
feedbackSucess = false;
message = "完成反馈LMS失败" + String.valueOf(applyManipulatorActionResponse);
logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
}
}
//申请放货点
if (action == 3) {
if (mode == 3 && action == 3) {
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setType("3");
applyManipulatorActionRequest.setTask_code(task_code);
applyManipulatorActionRequest.setTask_code1(task_code);
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
String put_device_code = applyManipulatorActionResponse.getPut_device_code();
Device device = deviceAppService.findDeviceByCode(put_device_code);
String to_putpoint = device.getExtraValue().get("address").toString();
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "3");
map.put("to_putpoint", put_device_code);
map.put("to_command", 3);
map.put("to_putpoint", Integer.parseInt(to_putpoint));
this.writing(map);
requireSucess = true;
feedbackSucess = true;
}
//申请新取货点
if (action == 4) {
if (mode == 3 && action == 4) {
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setType("4");
applyManipulatorActionRequest.setTask_code(task_code);
applyManipulatorActionRequest.setTask_code1(task_code);
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus() == 200) {
String get_device_code = applyManipulatorActionResponse.getGet_device_code();
Device device = deviceAppService.findDeviceByCode(get_device_code);
String to_new_getpoint = device.getExtraValue().get("address").toString();
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "4");
map.put("to_new_getpoint", get_device_code);
map.put("to_command", 4);
map.put("to_new_getpoint", Integer.parseInt(to_new_getpoint));
this.writing(map);
requireSucess = true;
feedbackSucess = true;
logServer.deviceExecuteLog(this.device_code, "", "", "申请新取货点,返回参数:" + applyManipulatorActionResponse);
message = "申请新取货点成功";
} else {
requireSucess = false;
feedbackSucess = false;
message = "申请失败";
logServer.deviceExecuteLog(this.device_code, "", "", "申请失败,返回参数:" + applyManipulatorActionResponse);
}
}
//申请二次放货点
if (action == 5) {
if (mode == 3 && action == 5) {
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setType("5");
applyManipulatorActionRequest.setTask_code(task_code);
applyManipulatorActionRequest.setTask_code1(task_code);
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus() == 200) {
String put_device_code2 = applyManipulatorActionResponse.getPut_device_code2();
Device device = deviceAppService.findDeviceByCode(put_device_code2);
String to_two_putpoint = device.getExtraValue().get("address").toString();
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "5");
map.put("to_two_putpoint", put_device_code2);
map.put("to_command", 5);
map.put("to_two_putpoint", Integer.parseInt(to_two_putpoint));
this.writing(map);
requireSucess = true;
feedbackSucess = true;
logServer.deviceExecuteLog(this.device_code, "", "", "申请二次放货点,返回参数:" + applyManipulatorActionResponse);
message = "申请二次放货点成功";
} else {
requireSucess = false;
feedbackSucess = false;
message = "申请失败";
logServer.deviceExecuteLog(this.device_code, "", "", "申请失败,返回参数:" + applyManipulatorActionResponse);
}
}
//缓存库取货完成
if (action == 6) {
if (mode == 3 && action == 6) {
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setAction("1");
applyManipulatorActionRequest.setTask_code1(task_code);
acsToWmsService.actionFinishRequest(applyManipulatorActionRequest);
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "6");
requireSucess = true;
map.put("to_command", 6);
this.writing(map);
feedbackSucess = true;
}
//缓存库放货完成
if (action == 7) {
if (mode == 3 && action == 7) {
String task_code = inst1.getTask_code();
applyManipulatorActionRequest.setAction("2");
applyManipulatorActionRequest.setTask_code1(task_code);
acsToWmsService.actionFinishRequest(applyManipulatorActionRequest);
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "7");
requireSucess = true;
map.put("to_command", 7);
this.writing(map);
feedbackSucess = true;
}
//放货完成
if (action == 8) {
if (mode == 3 && action == 8 && move == 0) {
if (inst1 != null) {
try {
requireSucess = true;
feedbackSucess = true;
finish_instruction(inst1);
this.writing("to_command", "8");
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", 8);
this.writing(map);
} catch (Exception e) {
e.printStackTrace();
}
@@ -996,18 +724,14 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
String bushing_num = taskDto.getBushing_num();
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "1");
if (action == 2) {
map.put("inflatableShaftVersion", version);
map.put("tube_num", bushing_num);
map.put("is_wrapped", is_bushing);
}
if (taskDto.getTruss_type() == "1" || taskDto.getTruss_type() == "5") {
map.put("to_task_type", taskDto.getTruss_type());
}
map.put("to_onset", start_addr);
map.put("to_task", instruction.getInstruction_code());
map.put("to_target", next_addr);
map.put("to_command", 1);
map.put("inflatableShaftVersion", Integer.parseInt(version));
map.put("tube_num", Integer.parseInt(bushing_num));
map.put("is_wrapped", Integer.parseInt(is_bushing));
map.put("to_task_type", Integer.parseInt(taskDto.getTruss_type()));
map.put("to_onset", Integer.parseInt(start_addr));
map.put("to_task", Integer.parseInt(instruction.getInstruction_code()));
map.put("to_target", Integer.parseInt(next_addr));
this.writing(map);
this.setRequireSucess(true);
return true;
@@ -1098,22 +822,12 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
+ ",指令终点:" + instdto.getNext_device_code());
String is_bushing = task.getIs_bushing();
String version = task.getVersion();
String bushing_num = task.getBushing_num();
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "1");
if (action == 2) {
map.put("inflatableShaftVersion", version);
map.put("tube_num", bushing_num);
map.put("is_wrapped", is_bushing);
}
if (task.getTruss_type() == "1" || task.getTruss_type() == "5") {
map.put("to_task_type", task.getTruss_type());
}
map.put("to_onset", start_addr);
map.put("to_task", instdto.getInstruction_code());
map.put("to_target", next_addr);
map.put("to_command", 1);
map.put("to_task_type", Integer.parseInt(task.getTruss_type()));
map.put("to_onset", Integer.parseInt(start_addr));
map.put("to_task", Integer.parseInt(instdto.getInstruction_code()));
map.put("to_target", Integer.parseInt(next_addr));
this.writing(map);
this.setRequireSucess(true);
notCreateInstMessage = "";

View File

@@ -659,9 +659,9 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
map.put("to_material" + status, paper.getMaterial_code());
map.put("to_out_qty" + status, paper.getQty());
map.put("to_seq" + status, status);
Device nextdevice = deviceAppservice.findDeviceByCode(paper.getDevice_code());
String next_addr = nextdevice.getExtraValue().get("address").toString();
map.put("to_position" + status, next_addr);
// Device nextdevice = deviceAppservice.findDeviceByCode(paper.getDevice_code());
// String next_addr = nextdevice.getExtraValue().get("address").toString();
map.put("to_position" + status, paper.getDevice_code());
}
@@ -810,7 +810,7 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
if (item_qty12 != (last_item_qty12)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty12" + last_item_qty12 + "->" + item_qty12);
}
if (item_material1.equals(last_item_material1)) {
if (!item_material1.equals(last_item_material1)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号material1" + last_item_material1 + "->" + item_material1);
}
if (!item_material2.equals(last_item_material2)) {

View File

@@ -15,7 +15,8 @@ public class ItemProtocol {
public static String item_mode = "mode";
public static String item_move = "move";
public static String item_error = "error";
public static String item_task = "task";
public static String item_task1 = "task1";
public static String item_task2 = "task2";
public static String item_to_command = "to_command";
private PluggingUnpluggingMachineDeviceDriver driver;
@@ -40,8 +41,11 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_error);
}
public int getTask() {
return this.getOpcIntegerValue(item_task);
public int getTask1() {
return this.getOpcIntegerValue(item_task1);
}
public int getTask2() {
return this.getOpcIntegerValue(item_task2);
}
public int getToCommand() {
@@ -75,7 +79,9 @@ public class ItemProtocol {
list.add(new ItemDto(item_mode, "工作状态", "DB600.B2"));
list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B5"));
list.add(new ItemDto(item_task, "任务号", "DB600.D6"));
list.add(new ItemDto(item_task1, "任务号1(行架任务号)", "DB600.D6"));
list.add(new ItemDto(item_task2, "任务号2(纸管任务号)", "DB600.D10"));
return list;
}

View File

@@ -2,7 +2,6 @@ package org.nl.acs.device_driver.basedriver.plugging_unplugging_machine;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.ItemProtocol;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
@@ -51,7 +50,7 @@ public class PluggingUnpluggingMachineDefination implements OpcDeviceDriverDefin
@Override
public List<ItemDto> getReadableItemDtos() {
return org.nl.acs.device_driver.basedriver.standard_inspect_site.ItemProtocol.getReadableItemDtos();
return ItemProtocol.getReadableItemDtos();
}
@Override

View File

@@ -1,5 +1,6 @@
package org.nl.acs.device_driver.basedriver.plugging_unplugging_machine;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@@ -60,17 +61,22 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
int mode = 0;
int error = 0;
int move = 0;
int task = 0;
int task1 = 0;
int task2 = 0;
int last_mode = 0;
int last_error = 0;
int last_move = 0;
int last_task = 0;
int last_task1 = 0;
int last_task2 = 0;
Boolean isonline = true;
Boolean iserror = false;
//行架机械手申请任务成功标识
boolean requireSucess = false;
//当前指令
Instruction inst = null;
//1-执行任务2-取货完成3-放货完成;
int flag;
@@ -91,9 +97,11 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
move = this.itemProtocol.getMove();
task = this.itemProtocol.getTask();
task1 = this.itemProtocol.getTask1();
task2 = this.itemProtocol.getTask2();
if (mode != last_mode) {
this.requireSucess=false;
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记");
}
if (move != last_move) {
@@ -129,13 +137,13 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
case 3:
break;
case 4:
if (!requireSucess) {
feedback();
if ((task1 > 0 || task2 > 0) && !requireSucess) {
applyBushing();
}
break;
case 5:
if (!requireSucess) {
feedback1();
if ((task1 > 0 || task2 > 0) && !requireSucess) {
bushingSucess();
}
break;
default:
@@ -147,45 +155,61 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
last_mode = mode;
last_error = error;
last_move = move;
last_task = task;
last_task1 = task1;
last_task2 = task2;
}
private synchronized void feedback1() {
private synchronized void bushingSucess() {
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
ApplyManipulatorActionResponse applyManipulatorActionResponse;
Instruction inst1 = instructionService.findByCode(String.valueOf(task1));
Instruction inst2 = instructionService.findByCode(String.valueOf(task2));
String task_code1 = inst1.getTask_code();
String task_code2 = inst2.getTask_code();
applyManipulatorActionRequest.setDevice_code(device_code);
applyManipulatorActionRequest.setTask_code1(task_code1);
applyManipulatorActionRequest.setTask_code2(task_code2);
applyManipulatorActionRequest.setType("7");
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus() == 200) {
if (applyManipulatorActionResponse.getstatus()==200) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "5");
map.put("to_command", 5);
requireSucess = true;
logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyManipulatorActionResponse);
message = "套轴完成成功";
} else {
}else{
message = applyManipulatorActionResponse.getMessage();
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "99");
map.put("to_command", 99);
requireSucess = true;
message = "套轴失败";
logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyManipulatorActionResponse);
}
}
private synchronized void feedback() {
private synchronized void applyBushing() {
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
ApplyManipulatorActionResponse applyManipulatorActionResponse;
Instruction inst1 = instructionService.findByCode(String.valueOf(task1));
Instruction inst2 = instructionService.findByCode(String.valueOf(task2));
String task_code1 = inst1.getTask_code();
String task_code2 = inst2.getTask_code();
applyManipulatorActionRequest.setDevice_code(device_code);
applyManipulatorActionRequest.setTask_code1(task_code1);
applyManipulatorActionRequest.setTask_code2(task_code2);
applyManipulatorActionRequest.setType("6");
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus() == 200) {
if (applyManipulatorActionResponse.getstatus()==200) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "4");
map.put("to_command", 4);
requireSucess = true;
logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyManipulatorActionResponse);
message = "套轴申请成功";
} else {
}else {
message = applyManipulatorActionResponse.getMessage();
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", "99");
map.put("to_command", 99);
requireSucess = true;
message = "申请失败";
logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyManipulatorActionResponse);

View File

@@ -17,14 +17,23 @@ public class ApplyManipulatorActionRequest extends BaseRequest {
private String type;
/**
* 任务号
* 行架任务号
*/
private String task_code;
private String task_code1;
/**
* 纸管任务号
*/
private String task_code2;
/**
* 气胀轴尺寸 3/6寸
*/
private String size;
/**
* 动作完成
* 取货完成1 放货完成2
*/
private String action;
}

View File

@@ -1,5 +1,6 @@
package org.nl.acs.ext.wms.data;
import com.alibaba.fastjson.JSONArray;
import lombok.Data;
import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper;
@@ -122,6 +123,27 @@ public class CreateTaskRequest extends BaseRequest {
*/
Map<String,String> params;
private List<Paper> paper_array;
/**
* 行架任务类型
*/
private String truss_type;
/**
* 气胀轴代数
*/
private String version;
/**
* 是否套管
*/
private String is_bushing;
/**
* 套管数量
*/
private String bushing_num;
private String paper_array;
}

View File

@@ -107,6 +107,13 @@ public class AcsToWmsController {
return new ResponseEntity<>(acstowmsService.applyManipulatorActionRequest(param), HttpStatus.OK);
}
@PostMapping("/actionFinishRequest")
@Log(value = "动作完成请求",isInterfaceLog = true,interfaceLogType= InterfaceLogType.ACS_TO_LMS)
@ApiOperation("动作完成请求")
public ResponseEntity<Object> actionFinishRequest(@RequestBody ApplyManipulatorActionRequest param) {
return new ResponseEntity<>(acstowmsService.actionFinishRequest(param), HttpStatus.OK);
}
@PostMapping("/liKuApplyTaskRequest")
@Log(value = "立库申请任务",isInterfaceLog = true,interfaceLogType= InterfaceLogType.ACS_TO_LMS)
@ApiOperation("立库申请任务")

View File

@@ -117,4 +117,5 @@ public interface AcsToWmsService {
void sendDeviceStatus(JSONObject param);
ApplyManipulatorActionResponse applyManipulatorActionRequest(ApplyManipulatorActionRequest param);
ApplyManipulatorActionResponse actionFinishRequest(ApplyManipulatorActionRequest param);
}

View File

@@ -444,8 +444,38 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} finally {
MDC.remove(log_file_type);
}
}
@Override
public ApplyManipulatorActionResponse actionFinishRequest(ApplyManipulatorActionRequest param) {
try {
MDC.put(log_file_type, log_type);
ApplyManipulatorActionResponse actionFinishRequestResponse = new ApplyManipulatorActionResponse();
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("actionFinishRequest");
String methods_url = addressDto.getMethods_url();
String url = wmsUrl + methods_url;
log.info("ApplyManipulatorActionRequest----请求参数{}", param);
try {
// String result = "";
String result = HttpRequest.post(url)
.body(JSON.toJSONString(param))
.execute().body();
JSONObject jsonObject = JSONObject.parseObject(result);
log.info("ApplyManipulatorActionResponse----返回参数{}", result);
actionFinishRequestResponse = JSONObject.toJavaObject(jsonObject, ApplyManipulatorActionResponse.class);
} catch (Exception e) {
JSONObject map = new JSONObject();
map.put("status", 400);
map.put("message", e.getMessage());
return JSONObject.toJavaObject(map, ApplyManipulatorActionResponse.class);
}
}
return actionFinishRequestResponse;
} finally {
MDC.remove(log_file_type);
}
}
@Override

View File

@@ -21,15 +21,19 @@ import org.nl.acs.device_driver.FeedLmsRealFailed;
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDeviceDriver;
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.casing_station.CasingStationConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.device_status.DeviceStatusDeviceDriver;
import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_conveyor.HongXiangStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.indoor_manipulator.IndoorManipulatorDeviceDriver;
import org.nl.acs.device_driver.basedriver.lamp_three_color.LampThreecolorDeviceDriver;
import org.nl.acs.device_driver.basedriver.oven_manipulator.OvenGantryManipulatorDeviceDriver;
import org.nl.acs.device_driver.basedriver.paper_tube_device.PaperTubeConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper;
import org.nl.acs.device_driver.basedriver.paper_tube_device2.PaperTubeConveyor2DeviceDriver;
import org.nl.acs.device_driver.basedriver.plug_pull_device_site.PlugPullDeviceSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.plugging_unplugging_machine.PluggingUnpluggingMachineDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk.SiemensConveyorCkkDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor_labeling.SiemensConveyorLabelingDeviceDriver;
@@ -238,8 +242,17 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
//纸管库
PaperTubeConveyorDeviceDriver paperTubeConveyorDeviceDriver;
//纸管库2
PaperTubeConveyor2DeviceDriver paperTubeConveyor2DeviceDriver;
//立库设备
DeviceStatusDeviceDriver deviceStatusDeviceDriver;
//插拔轴机
PlugPullDeviceSiteDeviceDriver plugPullDeviceSiteDeviceDriver;
//内包间行架机械手
IndoorManipulatorDeviceDriver indoorManipulatorDeviceDriver;
//套管工位
CasingStationConveyorDeviceDriver casingStationConveyorDeviceDriver;
if (datas.size() == 0) {
throw new BadRequestException("缺少输入参数!");
}
@@ -291,6 +304,19 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction());
jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError());
} else if (device.getDeviceDriver() instanceof CasingStationConveyorDeviceDriver) {
casingStationConveyorDeviceDriver = (CasingStationConveyorDeviceDriver) device.getDeviceDriver();
jo.put("device_code", parent_device_code);
jo.put("mode", casingStationConveyorDeviceDriver.getMode());
jo.put("move", casingStationConveyorDeviceDriver.getMove());
jo.put("heartbeat", casingStationConveyorDeviceDriver.getHeartbeat());
jo.put("carrier_direction", casingStationConveyorDeviceDriver.getCarrier_direction());
jo.put("error", casingStationConveyorDeviceDriver.getError());
jo.put("task", casingStationConveyorDeviceDriver.getTask());
jo.put("material1", casingStationConveyorDeviceDriver.getMaterial1());
jo.put("material2", casingStationConveyorDeviceDriver.getMaterial2());
} else if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) {
paperTubeConveyorDeviceDriver = (PaperTubeConveyorDeviceDriver) device.getDeviceDriver();
jo.put("device_code", parent_device_code);
@@ -356,6 +382,42 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("y", driver.getY_position());
jo.put("error", driver.getError());
jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("fqhj_error_type", String.valueOf(driver.getError())));
}else if (device.getDeviceDriver() instanceof PaperTubeConveyor2DeviceDriver) {
paperTubeConveyor2DeviceDriver = (PaperTubeConveyor2DeviceDriver) device.getDeviceDriver();
jo.put("device_code", parent_device_code);
jo.put("heartbeat",paperTubeConveyor2DeviceDriver.getHeartbeat());
jo.put("mode",paperTubeConveyor2DeviceDriver.getMode());
jo.put("move",paperTubeConveyor2DeviceDriver.getMove());
jo.put("carrier_direction",paperTubeConveyor2DeviceDriver.getCarrier_direction());
jo.put("error",paperTubeConveyor2DeviceDriver.getError());
jo.put("task",paperTubeConveyor2DeviceDriver.getTask());
jo.put("out_seq_arr",paperTubeConveyor2DeviceDriver.getItem_out_seq_arr());
jo.put("out_qty_arr",paperTubeConveyor2DeviceDriver.getItem_out_qty_arr());
jo.put("material1",paperTubeConveyor2DeviceDriver.getItem_material1());
jo.put("qty1",paperTubeConveyor2DeviceDriver.getItem_qty1());
jo.put("material2",paperTubeConveyor2DeviceDriver.getItem_material2());
jo.put("qty2",paperTubeConveyor2DeviceDriver.getItem_qty2());
jo.put("material3",paperTubeConveyor2DeviceDriver.getItem_material3());
jo.put("qty3",paperTubeConveyor2DeviceDriver.getItem_qty3());
jo.put("material4",paperTubeConveyor2DeviceDriver.getItem_material4());
jo.put("qty4",paperTubeConveyor2DeviceDriver.getItem_qty4());
jo.put("material5",paperTubeConveyor2DeviceDriver.getItem_material5());
jo.put("qty5",paperTubeConveyor2DeviceDriver.getItem_qty5());
jo.put("material6",paperTubeConveyor2DeviceDriver.getItem_material6());
jo.put("qty6",paperTubeConveyor2DeviceDriver.getItem_qty6());
jo.put("material7",paperTubeConveyor2DeviceDriver.getItem_material7());
jo.put("qty7",paperTubeConveyor2DeviceDriver.getItem_qty7());
jo.put("material8",paperTubeConveyor2DeviceDriver.getItem_material8());
jo.put("qty8",paperTubeConveyor2DeviceDriver.getItem_qty8());
jo.put("material9",paperTubeConveyor2DeviceDriver.getItem_material9());
jo.put("qty9",paperTubeConveyor2DeviceDriver.getItem_qty9());
jo.put("material10",paperTubeConveyor2DeviceDriver.getItem_material10());
jo.put("qty10",paperTubeConveyor2DeviceDriver.getItem_qty10());
jo.put("material11",paperTubeConveyor2DeviceDriver.getItem_material11());
jo.put("qty11",paperTubeConveyor2DeviceDriver.getItem_qty11());
jo.put("material12",paperTubeConveyor2DeviceDriver.getItem_material12());
jo.put("qty12",paperTubeConveyor2DeviceDriver.getItem_qty12());
} else if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
SiemensConveyorDeviceDriver driver = (SiemensConveyorDeviceDriver) device.getDeviceDriver();
jo.put("device_code", driver.getDevice().getDevice_code());
@@ -384,6 +446,31 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("status", Math.min(3, driver.getMode()));
jo.put("error", driver.getError());
jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(driver.getError())));
} else if (device.getDeviceDriver() instanceof IndoorManipulatorDeviceDriver) {
IndoorManipulatorDeviceDriver driver = (IndoorManipulatorDeviceDriver) device.getDeviceDriver();
jo.put("device_code", driver.getDevice().getDevice_code());
jo.put("device_name", driver.getDevice().getDevice_name());
jo.put("status", Math.min(3, driver.getMode()));
jo.put("mode", driver.getMode());
jo.put("move", driver.getMove());
jo.put("action", driver.getAction());
jo.put("walk_y", driver.getWalk_y());
jo.put("task", driver.getTask());
jo.put("x_position", driver.getX_position());
jo.put("y_position", driver.getY_position());
jo.put("inflatable_shaft_size", driver.getInflatable_shaft_size());
jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(driver.getError())));
}else if (device.getDeviceDriver() instanceof PluggingUnpluggingMachineDeviceDriver) {
PluggingUnpluggingMachineDeviceDriver driver = (PluggingUnpluggingMachineDeviceDriver) device.getDeviceDriver();
jo.put("device_code", driver.getDevice().getDevice_code());
jo.put("device_name", driver.getDevice().getDevice_name());
jo.put("status", Math.min(3, driver.getMode()));
jo.put("mode", driver.getMode());
jo.put("move", driver.getMove());
jo.put("task1", driver.getTask1());
jo.put("task2", driver.getTask2());
jo.put("error", driver.getError());
jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(driver.getError())));
} else {
jo.put("device_code", parent_device_code);
}
@@ -616,7 +703,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
for (int i = 0; i < datas.size(); i++) {
String data = datas.get(i).toString();
CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class);
List<Paper> paper_array = request.getPaper_array();
String paper_array = request.getPaper_array();
String ext_task_id = request.getExt_task_id();
String task_code = request.getTask_code();
String start_device_code = request.getStart_device_code();
@@ -629,6 +716,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
String vehicle_type = request.getVehicle_type();
String route_plan_code = request.getRoute_plan_code();
String task_type = request.getTask_type();
String truss_type = request.getTruss_type();
String is_bushing = request.getIs_bushing();
String version = request.getVersion();
String bushing_num = request.getBushing_num();
String storage_task_type = request.getDtl_type();
String agv_system_type = request.getAgv_system_type();
String remark = request.getRemark();
@@ -827,6 +918,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("params", params);
jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type));
jo.put("paper_array", JSONUtil.toJsonStr(paper_array));
jo.put("truss_type", JSONUtil.toJsonStr(truss_type));
jo.put("is_bushing", JSONUtil.toJsonStr(is_bushing));
jo.put("version", JSONUtil.toJsonStr(version));
jo.put("bushing_num", JSONUtil.toJsonStr(bushing_num));
if (!StrUtil.isEmpty(ext_task_id)) {