fix : 申请任务先找指令
This commit is contained in:
@@ -747,6 +747,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
jo.put("inventory_qty", inventory_qty);
|
||||
jo.put("out_finish", out_finish);
|
||||
jo.put("material", material);
|
||||
jo.put("is_click", true);
|
||||
jo.put("isOnline", this.getIsonline());
|
||||
|
||||
return jo;
|
||||
@@ -822,7 +823,12 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
String requestSucess = data.getString("requireSucess");
|
||||
if (StrUtil.equals(requestSucess, "0")) {
|
||||
this.requireSucess = false;
|
||||
} else if (StrUtil.equals(requestSucess, "1")) {
|
||||
this.requireSucess = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean arrayEquals(int[] a, int[] b) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
@@ -494,7 +495,7 @@ public class DoubleBeltConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
log.error("指令创建失败!", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
taskdto.setTask_status("1");
|
||||
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
@@ -172,8 +173,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
|
||||
|
||||
|
||||
if (move != 0 && task > 0) {
|
||||
if (move != 0 && task > 0) {
|
||||
|
||||
update_instruction_status();
|
||||
}
|
||||
@@ -421,7 +421,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
return false;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
taskdto.setTask_status("1");
|
||||
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
@@ -169,47 +170,12 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
to_task = this.itemProtocol.getTo_task();
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
material_barcode = this.itemProtocol.getMaterialBarCode();
|
||||
|
||||
|
||||
|
||||
if (to_length != last_to_length) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_length:" + last_to_length + "->" + to_length);
|
||||
}
|
||||
if (to_weight != last_to_weight) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_weight:" + last_to_weight + "->" + to_weight);
|
||||
}
|
||||
if (to_height != last_to_height) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_height:" + last_to_height + "->" + to_height);
|
||||
}
|
||||
if (to_command != last_to_command) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command);
|
||||
}
|
||||
if (to_target != last_to_target) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target);
|
||||
}
|
||||
if (to_task != last_to_task) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task);
|
||||
}
|
||||
if (mode != last_mode) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
|
||||
if (carrier_direction != last_carrier_direction) {
|
||||
logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction);
|
||||
}
|
||||
if (error != last_error) {
|
||||
|
||||
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||
}
|
||||
// 更新指令状态
|
||||
|
||||
if (move != 0 && task > 0) {
|
||||
|
||||
update_instruction_status();
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
|
||||
@@ -531,7 +497,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
return false;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
taskdto.setTask_status("1");
|
||||
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.storage_cell.domain.StorageCell;
|
||||
import org.nl.acs.storage_cell.service.mapper.StorageCellMapper;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
@@ -638,7 +639,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
|
||||
return false;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
taskdto.setTask_status("1");
|
||||
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
@@ -409,7 +410,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
Device nextdevice = deviceAppservice.findDeviceByCode(taskdto.getNext_device_code());
|
||||
|
||||
//创建指令后修改任务状态
|
||||
taskdto.setTask_status("1");
|
||||
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskdto);
|
||||
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
@@ -519,7 +520,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
return false;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
taskdto.setTask_status("1");
|
||||
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.box_package_manipulator;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -30,9 +31,11 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
|
||||
import java.util.*;
|
||||
@@ -319,101 +322,103 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
//找终点为入库输送线工位任务类型为行架的任务
|
||||
for (int i = 0; i < getDeviceCodeList.size(); i++) {
|
||||
String startDeviceCode = getDeviceCodeList.get(i);
|
||||
TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||
String interactionJson = taskDto.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDto.getStart_device_code();
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String start_point_code = taskDto.getStart_point_code();
|
||||
String route_plan_code = taskDto.getRoute_plan_code();
|
||||
String next_point_code = taskDto.getNext_point_code();
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(device_code);
|
||||
//先查指令
|
||||
List<TaskDto> taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode);
|
||||
if (CollUtil.isNotEmpty(taskDtoInstruction)){
|
||||
TaskDto taskDtoIns = taskDtoInstruction.get(0);
|
||||
if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code());
|
||||
String interactionJson = taskDtoIns.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDtoIns.getStart_device_code();
|
||||
String next_device_code = taskDtoIns.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
if (ObjectUtil.isEmpty(start_addr)) {
|
||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(next_addr)) {
|
||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
try {
|
||||
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8);
|
||||
} catch (Exception e) {
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
notCreateInstMessage = e.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage());
|
||||
return false;
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
|
||||
+ ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status("1");
|
||||
taskserver.update(taskDto);
|
||||
requireSucess = true;
|
||||
}else {
|
||||
TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||
String interactionJson = taskDto.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDto.getStart_device_code();
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
if (ObjectUtil.isEmpty(start_addr)) {
|
||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(next_addr)) {
|
||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 1);
|
||||
list.add(map1);
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
map2.put("code", "to_target");
|
||||
map2.put("value", next_addr);
|
||||
list.add(map2);
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
map3.put("code", "to_onset");
|
||||
map3.put("value", start_addr);
|
||||
list.add(map3);
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
map4.put("code", "to_task");
|
||||
map4.put("value", instdto.getInstruction_code());
|
||||
list.add(map4);
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getSeq())) {
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
map5.put("code", "to_seq");
|
||||
map5.put("value", interactionJsonDTO.getSeq());
|
||||
list.add(map5);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLastOne())) {
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
map6.put("code", "to_last_one");
|
||||
map6.put("value", interactionJsonDTO.getLastOne());
|
||||
list.add(map6);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getDirection())) {
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
map7.put("code", "to_direction");
|
||||
map7.put("value", interactionJsonDTO.getDirection());
|
||||
list.add(map7);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getMaxNo())) {
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
map8.put("code", "to_max_no");
|
||||
map8.put("value", interactionJsonDTO.getMaxNo());
|
||||
list.add(map8);
|
||||
}
|
||||
}
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String start_point_code = taskDto.getStart_point_code();
|
||||
String route_plan_code = taskDto.getRoute_plan_code();
|
||||
String next_point_code = taskDto.getNext_point_code();
|
||||
Instruction instdto = new Instruction();
|
||||
packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code);
|
||||
|
||||
try {
|
||||
this.writing(list);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
notCreateInstMessage = e.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskDto);
|
||||
requireSucess = true;
|
||||
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
try {
|
||||
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
} else {
|
||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}else{
|
||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -421,6 +426,59 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
}
|
||||
|
||||
private void pushPLC(Map<String, Object> map1, Map<String, Object> map2, String next_addr, Map<String, Object> map3, String start_addr, Map<String, Object> map4, String task, InteractionJsonDTO interactionJsonDTO, Map<String, Object> map5, Map<String, Object> map6, Map<String, Object> map7, Map<String, Object> map8) {
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 1);
|
||||
list.add(map1);
|
||||
map2.put("code", "to_target");
|
||||
map2.put("value", next_addr);
|
||||
list.add(map2);
|
||||
map3.put("code", "to_onset");
|
||||
map3.put("value", start_addr);
|
||||
list.add(map3);
|
||||
map4.put("code", "to_task");
|
||||
map4.put("value", task);
|
||||
list.add(map4);
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getSeq())) {
|
||||
map5.put("code", "to_seq");
|
||||
map5.put("value", interactionJsonDTO.getSeq());
|
||||
list.add(map5);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLastOne())) {
|
||||
map6.put("code", "to_last_one");
|
||||
map6.put("value", interactionJsonDTO.getLastOne());
|
||||
list.add(map6);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getDirection())) {
|
||||
map7.put("code", "to_direction");
|
||||
map7.put("value", interactionJsonDTO.getDirection());
|
||||
list.add(map7);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getMaxNo())) {
|
||||
map8.put("code", "to_max_no");
|
||||
map8.put("value", interactionJsonDTO.getMaxNo());
|
||||
list.add(map8);
|
||||
}
|
||||
}
|
||||
this.writing(list);
|
||||
}
|
||||
|
||||
private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code) {
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(device_code);
|
||||
}
|
||||
|
||||
public synchronized boolean finish_instruction(Instruction inst) throws Exception {
|
||||
instructionService.finish(inst);
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.box_storage_manipulator;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -31,10 +32,14 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -61,37 +66,21 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
|
||||
|
||||
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
|
||||
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
int move = 0;
|
||||
int last_move = 0;
|
||||
int action = 0;
|
||||
int last_action = 0;
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
int task = 0;
|
||||
int last_task = 0;
|
||||
|
||||
|
||||
int heartbeat = 0;
|
||||
int last_heartbeat = 0;
|
||||
int to_command = 0;
|
||||
int last_to_command = 0;
|
||||
|
||||
int to_target = 0;
|
||||
int last_to_target = 0;
|
||||
|
||||
int to_onset = 0;
|
||||
int last_to_onset = 0;
|
||||
|
||||
int to_task = 0;
|
||||
int last_to_task = 0;
|
||||
int to_layer = 0;
|
||||
int last_to_layer = 0;
|
||||
String to_barcode = null;
|
||||
String last_to_barcode = null;
|
||||
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
@@ -161,7 +150,11 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace()));
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("读取信号值时出现异常" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + Arrays.toString(e.getStackTrace()))
|
||||
.build();
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
|
||||
}
|
||||
|
||||
@@ -209,17 +202,6 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
}
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_move = move;
|
||||
last_action = action;
|
||||
last_error = error;
|
||||
last_task = task;
|
||||
last_heartbeat = heartbeat;
|
||||
last_to_task = to_task;
|
||||
last_to_command = to_command;
|
||||
last_to_target = to_target;
|
||||
last_to_layer = to_layer;
|
||||
last_to_barcode = to_barcode;
|
||||
|
||||
}
|
||||
|
||||
@@ -299,110 +281,104 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
//找终点为入库输送线工位任务类型为行架的任务
|
||||
for (int i = 0; i < getDeviceCodeList.size(); i++) {
|
||||
String startDeviceCode = getDeviceCodeList.get(i);
|
||||
TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||
String interactionJson = taskDto.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDto.getStart_device_code();
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String start_point_code = taskDto.getStart_point_code();
|
||||
String route_plan_code = taskDto.getRoute_plan_code();
|
||||
String next_point_code = taskDto.getNext_point_code();
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(device_code);
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
notCreateInstMessage = e.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage());
|
||||
return false;
|
||||
//先查指令
|
||||
List<TaskDto> taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode);
|
||||
if (CollUtil.isNotEmpty(taskDtoInstruction)) {
|
||||
TaskDto taskDtoIns = taskDtoInstruction.get(0);
|
||||
if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code());
|
||||
String interactionJson = taskDtoIns.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDtoIns.getStart_device_code();
|
||||
String next_device_code = taskDtoIns.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
if (ObjectUtil.isEmpty(start_addr)) {
|
||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(next_addr)) {
|
||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
Map<String, Object> map9 = new HashMap<>();
|
||||
try {
|
||||
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
|
||||
+ ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO);
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status("1");
|
||||
taskserver.update(taskDto);
|
||||
requireSucess = true;
|
||||
} else {
|
||||
TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||
String interactionJson = taskDto.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDto.getStart_device_code();
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
if (ObjectUtil.isEmpty(start_addr)) {
|
||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(next_addr)) {
|
||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 1);
|
||||
list.add(map1);
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
map2.put("code", "to_target");
|
||||
map2.put("value", next_addr);
|
||||
list.add(map2);
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
map3.put("code", "to_onset");
|
||||
map3.put("value", start_addr);
|
||||
list.add(map3);
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
map4.put("code", "to_task");
|
||||
map4.put("value", instdto.getInstruction_code());
|
||||
list.add(map4);
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) {
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
map5.put("code", "to_weight");
|
||||
map5.put("value", interactionJsonDTO.getWeight());
|
||||
list.add(map5);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) {
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
map6.put("code", "to_length");
|
||||
map6.put("value", interactionJsonDTO.getLength());
|
||||
list.add(map6);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) {
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
map7.put("code", "to_height");
|
||||
map7.put("value", interactionJsonDTO.getHeight());
|
||||
list.add(map7);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBarcode())) {
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
map8.put("code", "to_barcode");
|
||||
map8.put("value", interactionJsonDTO.getBarcode());
|
||||
list.add(map8);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLayer())) {
|
||||
Map<String, Object> map9 = new HashMap<>();
|
||||
map9.put("code", "to_layer");
|
||||
map9.put("value", interactionJsonDTO.getLayer());
|
||||
list.add(map9);
|
||||
}
|
||||
}
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String start_point_code = taskDto.getStart_point_code();
|
||||
String route_plan_code = taskDto.getRoute_plan_code();
|
||||
String next_point_code = taskDto.getNext_point_code();
|
||||
Instruction instdto = new Instruction();
|
||||
packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code);
|
||||
|
||||
try {
|
||||
this.writing(list);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
notCreateInstMessage = e.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskDto);
|
||||
requireSucess = true;
|
||||
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
Map<String, Object> map9 = new HashMap<>();
|
||||
try {
|
||||
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
} else {
|
||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}else{
|
||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -410,6 +386,64 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
}
|
||||
|
||||
private void pushPLC(Map<String, Object> map1, Map<String, Object> map2, String next_addr, Map<String, Object> map3, String start_addr, Map<String, Object> map4, String task, InteractionJsonDTO interactionJsonDTO, Map<String, Object> map5, Map<String, Object> map6, Map<String, Object> map7, Map<String, Object> map8, Map<String, Object> map9) {
|
||||
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 1);
|
||||
list.add(map1);
|
||||
map2.put("code", "to_target");
|
||||
map2.put("value", next_addr);
|
||||
list.add(map2);
|
||||
map3.put("code", "to_onset");
|
||||
map3.put("value", start_addr);
|
||||
list.add(map3);
|
||||
map4.put("code", "to_task");
|
||||
map4.put("value", task);
|
||||
list.add(map4);
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) {
|
||||
map5.put("code", "to_weight");
|
||||
map5.put("value", interactionJsonDTO.getWeight());
|
||||
list.add(map5);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) {
|
||||
map6.put("code", "to_length");
|
||||
map6.put("value", interactionJsonDTO.getLength());
|
||||
list.add(map6);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) {
|
||||
map7.put("code", "to_height");
|
||||
map7.put("value", interactionJsonDTO.getHeight());
|
||||
list.add(map7);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBarcode())) {
|
||||
map8.put("code", "to_barcode");
|
||||
map8.put("value", interactionJsonDTO.getBarcode());
|
||||
list.add(map8);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLayer())) {
|
||||
map9.put("code", "to_layer");
|
||||
map9.put("value", interactionJsonDTO.getLayer());
|
||||
list.add(map9);
|
||||
}
|
||||
}
|
||||
this.writing(list);
|
||||
}
|
||||
|
||||
private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code) {
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(device_code);
|
||||
}
|
||||
|
||||
|
||||
public void writing(List list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.return_good_manipulator;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -32,9 +33,11 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
|
||||
import java.util.*;
|
||||
@@ -296,116 +299,169 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
//找终点为入库输送线工位任务类型为行架的任务
|
||||
for (int i = 0; i < getDeviceCodeList.size(); i++) {
|
||||
String startDeviceCode = getDeviceCodeList.get(i);
|
||||
TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||
String interactionJson = taskDto.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDto.getStart_device_code();
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String start_point_code = taskDto.getStart_point_code();
|
||||
String route_plan_code = taskDto.getRoute_plan_code();
|
||||
String next_point_code = taskDto.getNext_point_code();
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(device_code);
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
notCreateInstMessage = e.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage());
|
||||
return false;
|
||||
//先查指令
|
||||
List<TaskDto> taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode);
|
||||
if (CollUtil.isNotEmpty(taskDtoInstruction)) {
|
||||
TaskDto taskDtoIns = taskDtoInstruction.get(0);
|
||||
if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code());
|
||||
String interactionJson = taskDtoIns.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDtoIns.getStart_device_code();
|
||||
String next_device_code = taskDtoIns.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
if (ObjectUtil.isEmpty(start_addr)) {
|
||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(next_addr)) {
|
||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
Map<String, Object> map9 = new HashMap<>();
|
||||
try {
|
||||
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
|
||||
+ ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO);
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status("1");
|
||||
taskserver.update(taskDto);
|
||||
requireSucess = true;
|
||||
} else {
|
||||
TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||
String interactionJson = taskDto.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDto.getStart_device_code();
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
if (ObjectUtil.isEmpty(start_addr)) {
|
||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(next_addr)) {
|
||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 1);
|
||||
list.add(map1);
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
map2.put("code", "to_target");
|
||||
map2.put("value", next_addr);
|
||||
list.add(map2);
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
map3.put("code", "to_onset");
|
||||
map3.put("value", start_addr);
|
||||
list.add(map3);
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
map4.put("code", "to_task");
|
||||
map4.put("value", instdto.getInstruction_code());
|
||||
list.add(map4);
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) {
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
map5.put("code", "to_weight");
|
||||
map5.put("value", interactionJsonDTO.getWeight());
|
||||
list.add(map5);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) {
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
map6.put("code", "to_length");
|
||||
map6.put("value", interactionJsonDTO.getLength());
|
||||
list.add(map6);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) {
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
map7.put("code", "to_height");
|
||||
map7.put("value", interactionJsonDTO.getHeight());
|
||||
list.add(map7);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBarcode())) {
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
map8.put("code", "to_barcode");
|
||||
map8.put("value", interactionJsonDTO.getBarcode());
|
||||
list.add(map8);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getContainerType())) {
|
||||
Map<String, Object> map9 = new HashMap<>();
|
||||
map9.put("code", "to_container_type");
|
||||
map9.put("value", interactionJsonDTO.getContainerType());
|
||||
list.add(map9);
|
||||
}
|
||||
}
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String start_point_code = taskDto.getStart_point_code();
|
||||
String route_plan_code = taskDto.getRoute_plan_code();
|
||||
String next_point_code = taskDto.getNext_point_code();
|
||||
Instruction instdto = new Instruction();
|
||||
packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code);
|
||||
|
||||
try {
|
||||
this.writing(list);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
notCreateInstMessage = e.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskDto);
|
||||
requireSucess = true;
|
||||
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
Map<String, Object> map9 = new HashMap<>();
|
||||
try {
|
||||
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
} else {
|
||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}else{
|
||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void pushPLC(Map<String, Object> map1, Map<String, Object> map2, String next_addr, Map<String, Object> map3, String start_addr, Map<String, Object> map4, String task, InteractionJsonDTO interactionJsonDTO, Map<String, Object> map5, Map<String, Object> map6, Map<String, Object> map7, Map<String, Object> map8, Map<String, Object> map9) {
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 1);
|
||||
list.add(map1);
|
||||
map2.put("code", "to_target");
|
||||
map2.put("value", next_addr);
|
||||
list.add(map2);
|
||||
map3.put("code", "to_onset");
|
||||
map3.put("value", start_addr);
|
||||
list.add(map3);
|
||||
map4.put("code", "to_task");
|
||||
map4.put("value", task);
|
||||
list.add(map4);
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) {
|
||||
map5.put("code", "to_weight");
|
||||
map5.put("value", interactionJsonDTO.getWeight());
|
||||
list.add(map5);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) {
|
||||
map6.put("code", "to_length");
|
||||
map6.put("value", interactionJsonDTO.getLength());
|
||||
list.add(map6);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) {
|
||||
map7.put("code", "to_height");
|
||||
map7.put("value", interactionJsonDTO.getHeight());
|
||||
list.add(map7);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBarcode())) {
|
||||
map8.put("code", "to_barcode");
|
||||
map8.put("value", interactionJsonDTO.getBarcode());
|
||||
list.add(map8);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getContainerType())) {
|
||||
map9.put("code", "to_container_type");
|
||||
map9.put("value", interactionJsonDTO.getContainerType());
|
||||
list.add(map9);
|
||||
}
|
||||
}
|
||||
|
||||
this.writing(list);
|
||||
}
|
||||
|
||||
private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code) {
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(device_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发
|
||||
* @param list
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.trapped_manipulator;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -30,9 +31,11 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
|
||||
import java.util.*;
|
||||
@@ -295,116 +298,172 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
|
||||
//找终点为入库输送线工位任务类型为行架的任务
|
||||
for (int i = 0; i < getDeviceCodeList.size(); i++) {
|
||||
String startDeviceCode = getDeviceCodeList.get(i);
|
||||
TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||
String interactionJson = taskDto.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDto.getStart_device_code();
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String start_point_code = taskDto.getStart_point_code();
|
||||
String route_plan_code = taskDto.getRoute_plan_code();
|
||||
String next_point_code = taskDto.getNext_point_code();
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(device_code);
|
||||
//先查指令
|
||||
List<TaskDto> taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode);
|
||||
if (CollUtil.isNotEmpty(taskDtoInstruction)) {
|
||||
TaskDto taskDtoIns = taskDtoInstruction.get(0);
|
||||
if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code());
|
||||
String interactionJson = taskDtoIns.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDtoIns.getStart_device_code();
|
||||
String next_device_code = taskDtoIns.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
if (ObjectUtil.isEmpty(start_addr)) {
|
||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(next_addr)) {
|
||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
Map<String, Object> map9 = new HashMap<>();
|
||||
try {
|
||||
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
|
||||
+ ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||
String interactionJson = taskDto.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDto.getStart_device_code();
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
if (ObjectUtil.isEmpty(start_addr)) {
|
||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(next_addr)) {
|
||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
notCreateInstMessage = e.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO);
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status("1");
|
||||
taskserver.update(taskDto);
|
||||
requireSucess = true;
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String start_point_code = taskDto.getStart_point_code();
|
||||
String route_plan_code = taskDto.getRoute_plan_code();
|
||||
String next_point_code = taskDto.getNext_point_code();
|
||||
Instruction instdto = new Instruction();
|
||||
packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code);
|
||||
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 1);
|
||||
list.add(map1);
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
map2.put("code", "to_target");
|
||||
map2.put("value", next_addr);
|
||||
list.add(map2);
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
map3.put("code", "to_onset");
|
||||
map3.put("value", start_addr);
|
||||
list.add(map3);
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
map4.put("code", "to_task");
|
||||
map4.put("value", instdto.getInstruction_code());
|
||||
list.add(map4);
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) {
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
map5.put("code", "to_weight");
|
||||
map5.put("value", interactionJsonDTO.getWeight());
|
||||
list.add(map5);
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
notCreateInstMessage = e.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) {
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
map6.put("code", "to_length");
|
||||
map6.put("value", interactionJsonDTO.getLength());
|
||||
list.add(map6);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) {
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
map7.put("code", "to_height");
|
||||
map7.put("value", interactionJsonDTO.getHeight());
|
||||
list.add(map7);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getTemplate())) {
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
map8.put("code", "to_template");
|
||||
map8.put("value", interactionJsonDTO.getTemplate());
|
||||
list.add(map8);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getTemplate())) {
|
||||
Map<String, Object> map9 = new HashMap<>();
|
||||
map9.put("code", "to_last_one");
|
||||
map9.put("value", interactionJsonDTO.getIsLastOne());
|
||||
list.add(map9);
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskDto);
|
||||
requireSucess = true;
|
||||
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
Map<String, Object> map8 = new HashMap<>();
|
||||
Map<String, Object> map9 = new HashMap<>();
|
||||
try {
|
||||
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
} else {
|
||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||
}
|
||||
try {
|
||||
this.writing(list);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}else{
|
||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void pushPLC(Map<String, Object> map1, Map<String, Object> map2, String next_addr, Map<String, Object> map3, String start_addr, Map<String, Object> map4, String task, InteractionJsonDTO interactionJsonDTO, Map<String, Object> map5, Map<String, Object> map6, Map<String, Object> map7, Map<String, Object> map8, Map<String, Object> map9) {
|
||||
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 1);
|
||||
list.add(map1);
|
||||
map2.put("code", "to_target");
|
||||
map2.put("value", next_addr);
|
||||
list.add(map2);
|
||||
map3.put("code", "to_onset");
|
||||
map3.put("value", start_addr);
|
||||
list.add(map3);
|
||||
map4.put("code", "to_task");
|
||||
map4.put("value", task);
|
||||
list.add(map4);
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) {
|
||||
map5.put("code", "to_weight");
|
||||
map5.put("value", interactionJsonDTO.getWeight());
|
||||
list.add(map5);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) {
|
||||
map6.put("code", "to_length");
|
||||
map6.put("value", interactionJsonDTO.getLength());
|
||||
list.add(map6);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) {
|
||||
map7.put("code", "to_height");
|
||||
map7.put("value", interactionJsonDTO.getHeight());
|
||||
list.add(map7);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getTemplate())) {
|
||||
map8.put("code", "to_template");
|
||||
map8.put("value", interactionJsonDTO.getTemplate());
|
||||
list.add(map8);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getTemplate())) {
|
||||
map9.put("code", "to_last_one");
|
||||
map9.put("value", interactionJsonDTO.getIsLastOne());
|
||||
list.add(map9);
|
||||
}
|
||||
}
|
||||
|
||||
this.writing(list);
|
||||
}
|
||||
|
||||
private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code) {
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(device_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成指令
|
||||
* @param inst
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.volume_two_manipulator;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -30,9 +31,11 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
|
||||
import java.util.*;
|
||||
@@ -265,10 +268,10 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
|
||||
}
|
||||
|
||||
//放货完成
|
||||
if ( action == 4 && move == 0) {
|
||||
if (action == 4 && move == 0) {
|
||||
if (inst != null) {
|
||||
try {
|
||||
logServer.deviceExecuteLog(this.device_code,"","","放货完成");
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "放货完成");
|
||||
finish_instruction(inst);
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
List list = new ArrayList();
|
||||
@@ -282,7 +285,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
|
||||
e.printStackTrace();
|
||||
}
|
||||
feedMessage = "";
|
||||
}else {
|
||||
} else {
|
||||
feedMessage = "行架机械手:";
|
||||
if (mode != 3) {
|
||||
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
|
||||
@@ -319,104 +322,96 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
|
||||
//找终点为入库输送线工位任务类型为行架的任务
|
||||
for (int i = 0; i < getDeviceCodeList.size(); i++) {
|
||||
String startDeviceCode = getDeviceCodeList.get(i);
|
||||
TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||
String start_device_code = taskDto.getStart_device_code();
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
String start_device_code2 = taskDto.getStart_device_code2();
|
||||
String next_device_code2 = taskDto.getNext_device_code2();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String start_point_code = taskDto.getStart_point_code();
|
||||
String next_point_code = taskDto.getNext_point_code();
|
||||
String start_point_code2 = taskDto.getStart_point_code2();
|
||||
String next_point_code2 = taskDto.getNext_point_code2();
|
||||
String route_plan_code = taskDto.getRoute_plan_code();
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setStart_device_code2(start_device_code2);
|
||||
instdto.setNext_device_code2(next_device_code2);
|
||||
instdto.setStart_point_code2(start_point_code2);
|
||||
instdto.setNext_point_code2(next_point_code2);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(device_code);
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
notCreateInstMessage = e.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() );
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status("1");
|
||||
taskserver.update(taskDto);
|
||||
requireSucess = true;
|
||||
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 1);
|
||||
list.add(map1);
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
map2.put("code", "to_target");
|
||||
map2.put("value", next_addr);
|
||||
list.add(map2);
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
map3.put("code", "to_onset");
|
||||
map3.put("value", start_addr);
|
||||
list.add(map3);
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
map4.put("code", "to_task");
|
||||
map4.put("value", instdto.getInstruction_code());
|
||||
list.add(map4);
|
||||
String toType = VolumeTwoTypeEnum.TOW.getType();
|
||||
if (StrUtil.isNotEmpty(start_device_code2)) {
|
||||
toType = VolumeTwoTypeEnum.FOUR.getType();
|
||||
Device startDevice2 = deviceAppService.findDeviceByCode(start_device_code2);
|
||||
Device nextDevice2 = deviceAppService.findDeviceByCode(next_device_code2);
|
||||
String start_addr2 = startDevice2.getExtraValue().get("address").toString();
|
||||
String next_addr2 = nextDevice2.getExtraValue().get("address").toString();
|
||||
//先查指令
|
||||
List<TaskDto> taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode);
|
||||
if (CollUtil.isNotEmpty(taskDtoInstruction)) {
|
||||
TaskDto taskDtoIns = taskDtoInstruction.get(0);
|
||||
if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code());
|
||||
String interactionJson = taskDtoIns.getInteraction_json();
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String start_device_code = taskDtoIns.getStart_device_code();
|
||||
String next_device_code = taskDtoIns.getNext_device_code();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
if (ObjectUtil.isEmpty(start_addr)) {
|
||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(next_addr)) {
|
||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
map5.put("code", "to_target2");
|
||||
map5.put("value", next_addr2);
|
||||
list.add(map5);
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
map6.put("code", "to_onset2");
|
||||
map6.put("value", start_addr2);
|
||||
list.add(map6);
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
|
||||
try {
|
||||
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), map5, map6,map7,taskDtoIns);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
|
||||
+ ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
map7.put("code", "to_type");
|
||||
map7.put("value", toType);
|
||||
list.add(map7);
|
||||
try {
|
||||
this.writing(list);
|
||||
} catch (Exception e) {
|
||||
}else {
|
||||
TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||
String start_device_code = taskDto.getStart_device_code();
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
String start_device_code2 = taskDto.getStart_device_code2();
|
||||
String next_device_code2 = taskDto.getNext_device_code2();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String start_point_code = taskDto.getStart_point_code();
|
||||
String next_point_code = taskDto.getNext_point_code();
|
||||
String route_plan_code = taskDto.getRoute_plan_code();
|
||||
Instruction instdto = new Instruction();
|
||||
packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code,start_device_code2,next_device_code2);
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
notCreateInstMessage = e.getMessage();
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",指令执行失败:" + e.getMessage());
|
||||
+ ",指令终点:" + instdto.getNext_device_code());
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskDto);
|
||||
requireSucess = true;
|
||||
|
||||
this.setRequireSucess(true);
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
Map<String, Object> map6 = new HashMap<>();
|
||||
Map<String, Object> map7 = new HashMap<>();
|
||||
try {
|
||||
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), map5, map6,map7,taskDto);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code() + ",指令执行失败:" + e.getMessage());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}else{
|
||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -424,8 +419,70 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
|
||||
|
||||
}
|
||||
|
||||
private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code, String start_device_code2, String next_device_code2) {
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setStart_device_code2(start_device_code2);
|
||||
instdto.setNext_device_code2(next_device_code2);
|
||||
instdto.setStart_point_code2(start_device_code2);
|
||||
instdto.setNext_point_code2(next_device_code2);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(device_code);
|
||||
}
|
||||
|
||||
private void pushPLC(Map<String, Object> map1, Map<String, Object> map2, String next_addr, Map<String, Object> map3, String start_addr, Map<String, Object> map4, String task, Map<String, Object> map5, Map<String, Object> map6, Map<String, Object> map7, TaskDto taskDtoIns) {
|
||||
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 1);
|
||||
list.add(map1);
|
||||
map2.put("code", "to_target");
|
||||
map2.put("value", next_addr);
|
||||
list.add(map2);
|
||||
map3.put("code", "to_onset");
|
||||
map3.put("value", start_addr);
|
||||
list.add(map3);
|
||||
map4.put("code", "to_task");
|
||||
map4.put("value", task);
|
||||
list.add(map4);
|
||||
String toType = VolumeTwoTypeEnum.TOW.getType();
|
||||
if (StrUtil.isNotEmpty(taskDtoIns.getStart_device_code2())) {
|
||||
toType = VolumeTwoTypeEnum.FOUR.getType();
|
||||
Device startDevice2 = deviceAppService.findDeviceByCode(taskDtoIns.getStart_device_code2());
|
||||
Device nextDevice2 = deviceAppService.findDeviceByCode(taskDtoIns.getNext_device_code2());
|
||||
String start_addr2 = startDevice2.getExtraValue().get("address").toString();
|
||||
String next_addr2 = nextDevice2.getExtraValue().get("address").toString();
|
||||
if (ObjectUtil.isEmpty(start_addr2)) {
|
||||
throw new BadRequestException("设备:" + startDevice2.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(next_addr2)) {
|
||||
throw new BadRequestException("设备:" + nextDevice2.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
map5.put("code", "to_target2");
|
||||
map5.put("value", next_addr2);
|
||||
list.add(map5);
|
||||
map6.put("code", "to_onset2");
|
||||
map6.put("value", start_addr2);
|
||||
list.add(map6);
|
||||
}
|
||||
|
||||
map7.put("code", "to_type");
|
||||
map7.put("value", toType);
|
||||
list.add(map7);
|
||||
|
||||
this.writing(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成指令
|
||||
*
|
||||
* @param inst
|
||||
* @return
|
||||
* @throws Exception
|
||||
@@ -437,6 +494,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
|
||||
|
||||
/**
|
||||
* 下发信号
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
public void writing(List list) {
|
||||
@@ -473,6 +531,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
|
||||
public String getToParam() {
|
||||
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
|
||||
@@ -592,7 +592,7 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
log.error("指令创建失败!{}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
taskdto.setTask_status("1");
|
||||
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
Map map = new HashMap();
|
||||
|
||||
@@ -66,7 +66,21 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
@Autowired
|
||||
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* 禁止入库
|
||||
*/
|
||||
private boolean prohibitInWarehouse = false;
|
||||
/**
|
||||
* 禁止出库
|
||||
*/
|
||||
private boolean prohibitOutWarehouse = false;
|
||||
/**
|
||||
* 停止接收任务
|
||||
*/
|
||||
private boolean stopReceiveTask = false;
|
||||
|
||||
/**
|
||||
* 心跳
|
||||
*/
|
||||
Integer heartbeat = 0;
|
||||
@@ -76,17 +90,17 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
*/
|
||||
Integer item_deviceCode = 0;
|
||||
Integer last_item_deviceCode = 0;
|
||||
/**
|
||||
/**
|
||||
* 工作模式
|
||||
*/
|
||||
Integer mode = 0;
|
||||
Integer last_mode = 0;
|
||||
/**
|
||||
*作业状态
|
||||
* 作业状态
|
||||
*/
|
||||
Integer command = 0;
|
||||
Integer last_command = 0;
|
||||
/**
|
||||
/**
|
||||
* 任务号
|
||||
*/
|
||||
Integer task = 0;
|
||||
@@ -111,7 +125,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
*/
|
||||
Integer y = 0;
|
||||
Integer last_y = 0;
|
||||
/**
|
||||
/**
|
||||
* 行走开关信号
|
||||
*/
|
||||
Float move = 0F;
|
||||
@@ -121,12 +135,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
*/
|
||||
Float cargoMove = 0F;
|
||||
Float last_cargoMove = 0F;
|
||||
/**
|
||||
/**
|
||||
* 行走动作信号
|
||||
*/
|
||||
Float action = 0F;
|
||||
Float last_action = 0F;
|
||||
/**
|
||||
/**
|
||||
* 行走激光数值
|
||||
*/
|
||||
Integer distancex = 0;
|
||||
@@ -137,41 +151,41 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
Integer distancey = 0;
|
||||
Integer last_distancey = 0;
|
||||
/**
|
||||
*载货台超限信号
|
||||
* 载货台超限信号
|
||||
*/
|
||||
Float cargoError = 0F;
|
||||
Float last_cargoError = 0F;
|
||||
/**
|
||||
*货叉探货信号
|
||||
* 货叉探货信号
|
||||
*/
|
||||
Float forkCargo = 0F;
|
||||
Float last_forkCargo = 0F;
|
||||
/**
|
||||
*货叉位置信号
|
||||
* 货叉位置信号
|
||||
*/
|
||||
Float forkLocation = 0F;
|
||||
Float last_forkLocation = 0F;
|
||||
/**
|
||||
*货叉动作信号
|
||||
* 货叉动作信号
|
||||
*/
|
||||
Float forkAction = 0F;
|
||||
Float last_forkAction = 0F;
|
||||
/**
|
||||
/**
|
||||
* 特殊开关量1
|
||||
*/
|
||||
Float special1 = 0F;
|
||||
Float last_special1 = 0F;
|
||||
/**
|
||||
/**
|
||||
* 特殊开关量2
|
||||
*/
|
||||
Float special2 = 0F;
|
||||
Float last_special2 = 0F;
|
||||
/**
|
||||
*托盘条码
|
||||
* 托盘条码
|
||||
*/
|
||||
int[] trayCode;
|
||||
int[] last_trayCode;
|
||||
/**
|
||||
/**
|
||||
* 水箱和消防缓存位有无货
|
||||
*/
|
||||
Float storage_cache = 0F;
|
||||
@@ -181,58 +195,58 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
*/
|
||||
Integer stacker_rpm = 0;
|
||||
Integer last_stacker_rpm = 0;
|
||||
/**
|
||||
/**
|
||||
* 电流
|
||||
*/
|
||||
Integer stacker_electricCurrent = 0;
|
||||
Integer last_stacker_electricCurrent = 0;
|
||||
/**
|
||||
/**
|
||||
* 轴运行次数
|
||||
*/
|
||||
Integer stacker_runing_time = 0;
|
||||
Integer last_stacker_runing_time = 0;
|
||||
/**
|
||||
/**
|
||||
* 轴工作时间(小时)
|
||||
*/
|
||||
Integer stacker_workingHours = 0;
|
||||
Integer last_stacker_workingHours = 0;
|
||||
/**
|
||||
*载货台速度(转/分钟)
|
||||
* 载货台速度(转/分钟)
|
||||
*/
|
||||
Integer cargo_rpm = 0;
|
||||
Integer last_cargo_rpm = 0;
|
||||
/**
|
||||
*载货台电流
|
||||
* 载货台电流
|
||||
*/
|
||||
Integer cargo_electric_Current = 0;
|
||||
Integer last_cargo_electric_Current = 0;
|
||||
/**
|
||||
*载货台轴工作小时数
|
||||
* 载货台轴工作小时数
|
||||
*/
|
||||
Integer cargo_workingHour = 0;
|
||||
Integer last_cargo_workingHour = 0;
|
||||
/**
|
||||
*载货台轴运行次数
|
||||
* 载货台轴运行次数
|
||||
*/
|
||||
Integer cargo_runingTimes = 0;
|
||||
Integer last_cargo_runingTimes = 0;
|
||||
/**
|
||||
*货叉速度(转/分钟
|
||||
* 货叉速度(转/分钟
|
||||
*/
|
||||
Integer fork_rpm = 0;
|
||||
Integer last_fork_rpm = 0;
|
||||
/**
|
||||
*货叉电流
|
||||
* 货叉电流
|
||||
*/
|
||||
Integer fork_electric_Current = 0;
|
||||
Integer last_fork_electric_Current = 0;
|
||||
/**
|
||||
*货叉轴工作时间(小时
|
||||
* 货叉轴工作时间(小时
|
||||
*/
|
||||
Integer fork_workingHours = 0;
|
||||
Integer last_fork_workingHours = 0;
|
||||
/**
|
||||
*货叉轴运行次数
|
||||
* 货叉轴运行次数
|
||||
*/
|
||||
Integer fork_runingTimes = 0;
|
||||
Integer last_fork_runingTimes = 0;
|
||||
@@ -250,7 +264,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
List<String> getDeviceCodeList = null;
|
||||
List<String> putDeviceCodeList = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* 请求成功标记
|
||||
*/
|
||||
Boolean requireSucess = false;
|
||||
@@ -368,7 +382,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("z"))) {
|
||||
Map map = new HashMap();
|
||||
map.put("code", "to_x");
|
||||
map.put("value", nextDevice.getExtraValue().get("z"));
|
||||
map.put("value", nextDevice.getExtraValue().get("z"));
|
||||
list.add(map);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("x"))) {
|
||||
@@ -616,7 +630,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
map.put("to_x", inst.getFrom_y());
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(map)){
|
||||
if (ObjectUtil.isNotEmpty(map)) {
|
||||
list.add(map);
|
||||
this.writing(list);
|
||||
}
|
||||
@@ -714,7 +728,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
if (command == 8) {
|
||||
map.put("to_command", 8);
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(map)){
|
||||
if (ObjectUtil.isNotEmpty(map)) {
|
||||
list.add(map);
|
||||
this.writing(list);
|
||||
}
|
||||
@@ -725,12 +739,43 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
return null;
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("is_click", true);
|
||||
String requireSucess = "0";
|
||||
if (this.requireSucess) {
|
||||
requireSucess = "1";
|
||||
}
|
||||
jo.put("prohibitInWarehouse", this.prohibitInWarehouse);
|
||||
jo.put("prohibitOutWarehouse", this.prohibitOutWarehouse);
|
||||
jo.put("stopReceiveTask", this.stopReceiveTask);
|
||||
jo.put("requireSucess", requireSucess);
|
||||
jo.put("driver_type", "standard_stacker");
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
String requestSucess = data.getString("requireSucess");
|
||||
if (StrUtil.equals(requestSucess, "0")) {
|
||||
this.requireSucess = false;
|
||||
} else if (StrUtil.equals(requestSucess, CommonFinalParam.ONE)) {
|
||||
this.requireSucess = true;
|
||||
}
|
||||
//监控大屏下发作业命令清警-5、召回-7、急停-8
|
||||
Integer toCommand = data.getInteger("toCommand");
|
||||
if (toCommand != null) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("to_command", toCommand);
|
||||
this.writing(map);
|
||||
}
|
||||
//ACS监控大屏设置禁止入库、禁止出库、停止接收任务
|
||||
Boolean prohibitInWarehouse = data.getBoolean("prohibitInWarehouse");
|
||||
this.prohibitInWarehouse = prohibitInWarehouse;
|
||||
Boolean prohibitOutWarehouse = data.getBoolean("prohibitOutWarehouse");
|
||||
this.prohibitOutWarehouse = prohibitOutWarehouse;
|
||||
Boolean stopReceiveTask = data.getBoolean("stopReceiveTask");
|
||||
this.stopReceiveTask = stopReceiveTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -759,6 +804,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成指令
|
||||
*
|
||||
@@ -812,7 +858,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* 将扩展表中的字符串数据转换成集合
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
@@ -488,7 +489,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
logServer.deviceExecuteLog(device_code, "", instdto.getInstruction_code(), "指令创建失败,原因->" + e.getMessage());
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
taskDto.setTask_status("1");
|
||||
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskDto.setUpdate_time(DateUtil.now());
|
||||
taskserver.update(taskDto);
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.acs.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum RequestSucessEnum {
|
||||
YES("1", "是"),
|
||||
|
||||
NO("0", "否");
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String value;
|
||||
}
|
||||
@@ -48,6 +48,13 @@ public interface TaskService extends CommonService<Task> {
|
||||
*/
|
||||
Task getById(String id);
|
||||
|
||||
/**
|
||||
* 根据设备号和任务状态查询
|
||||
* @param device_code
|
||||
* @return
|
||||
*/
|
||||
List<TaskDto> queryTaskByDeviceCodeAndStatus2(String device_code);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.route.service.mapper.RoutePlanMapper;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.service.TaskFeedbackService;
|
||||
import org.nl.acs.task.service.dto.TaskFeedbackDto;
|
||||
import org.nl.acs.common.base.PageInfo;
|
||||
@@ -133,6 +134,33 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
return taskMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByDeviceCodeAndStatus2(String device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getStart_device_code().equals(device_code)
|
||||
&& StrUtil.equals(task.getTask_status(), TaskStatusEnum.BUSY.getIndex())) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
list.add(task);
|
||||
}
|
||||
} else {
|
||||
if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Inner_Truss_Task.getIndex()) && StrUtil.isNotEmpty(task.getPut_device_code())) {
|
||||
Instruction instruction = instructionService.findByDeviceCodeFromCache(task.getNext_device_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
if (StrUtil.equals(instruction.getStart_device_code(), device_code)) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TaskDto findById(String id) {
|
||||
return ConvertUtil.convert(getById(id), TaskDto.class);
|
||||
|
||||
Reference in New Issue
Block a user