fix:rgv行架冲突问题

This commit is contained in:
2023-12-26 10:24:22 +08:00
parent 24026c4c2e
commit fc48074907
3 changed files with 132 additions and 62 deletions

View File

@@ -9,18 +9,16 @@ import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jinterop.dcom.common.JIException;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.basedriver.plugging_unplugging_machine.PluggingUnpluggingMachineDeviceDriver;
import org.nl.acs.device_driver.basedriver.rgv.RgvDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.ApplyManipulatorActionRequest;
import org.nl.acs.ext.wms.data.ApplyManipulatorActionResponse;
import org.nl.acs.ext.wms.data.JsonUtl;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.history.service.DeviceErrorLogService;
@@ -37,13 +35,7 @@ import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.exception.WDKException;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.AddFailedException;
import org.openscada.opc.lib.da.Group;
import org.openscada.opc.lib.da.Item;
import org.openscada.opc.lib.da.ItemState;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
@@ -59,7 +51,7 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
protected org.nl.acs.device_driver.basedriver.indoor_manipulator.ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
private OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService .class);
private OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService.class);
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
@@ -464,7 +456,7 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
applyManipulatorActionRequest.setType("3");
applyManipulatorActionRequest.setTask_code1(task_code);
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
if (applyManipulatorActionResponse.getstatus()==200) {
if (applyManipulatorActionResponse.getstatus() == 200) {
logServer.deviceExecuteLog(this.device_code, "", "", "申请放货点请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
String put_device_code = applyManipulatorActionResponse.getDevice_code();
Device device = deviceAppService.findDeviceByCode(put_device_code);
@@ -549,7 +541,7 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
this.writing(map);
message = "缓存库取货完成";
feedbackSucess = true;
}else {
} else {
feedbackSucess = false;
message = "缓存库取货失败";
logServer.deviceExecuteLog(this.device_code, "", "", "缓存库取货失败,返回参数:" + applyManipulatorActionResponse1);
@@ -569,52 +561,52 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
this.writing(map);
feedbackSucess = true;
message = "缓存库放货成功";
}else {
} else {
feedbackSucess = false;
message = "缓存库放货失败";
logServer.deviceExecuteLog(this.device_code, "", "", "缓存库放货完成,返回参数:" + applyManipulatorActionResponse1);
}
}
}
//放货完成
if (mode == 3 && action == 8 && move == 0) {
if (inst1 != null) {
try {
feedbackSucess = true;
finish_instruction(inst1);
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", 8);
this.writing(map);
message = "放货完成";
} catch (Exception e) {
message = "放货失败";
e.printStackTrace();
}
feedMessage = "";
}
//放货完成
if (mode == 3 && action == 8 && move == 0) {
if (inst1 != null) {
try {
feedbackSucess = true;
finish_instruction(inst1);
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", 8);
this.writing(map);
message = "放货完成";
} catch (Exception e) {
message = "放货失败";
e.printStackTrace();
}
feedMessage = "";
}
} else {
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 8) {
feedMessage = feedMessage + "动作信号(action)不为放货完成状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
} else {
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 8) {
feedMessage = feedMessage + "动作信号(action)不为放货完成状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
}
}else {
} else {
feedMessage = "";
}
}
}
public Instruction checkInst() {
@@ -789,7 +781,20 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
if (ObjectUtil.isNotEmpty(taskDtos)) {
//按照优先级排序 优先级相等按照创建时间排序
taskDtos = this.sortTask(taskDtos);
TaskDto taskDto = taskDtos.get(0);
TaskDto taskDto = null;
for (int i1 = 0; i1 < taskDtos.size(); i1++) {
taskDto = taskDtos.get(i1);
Boolean flag;
if ("6".equals(task.getTruss_type())) {
flag = checkAgv(taskDto);
if (flag){
break;
}
}else {
break;
}
}
//存在行架->暂存的AGV任务 需要过滤
// 9 行架任务
@@ -800,13 +805,6 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code());
String start_device_code = instruction.getStart_device_code();
String next_device_code = instruction.getNext_device_code();
Device nextdevice = deviceAppService.findDeviceByCode(next_device_code);
Device startdevice = deviceAppService.findDeviceByCode(start_device_code);
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
/*instruction.setInstruction_status("1");
instruction.setUpdate_time(DateUtil.now());
instructionService.update(instruction);*/
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
@@ -835,9 +833,9 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
map.put("to_target", Integer.parseInt(next_addr));
try {
this.writing(map);
}catch (Exception e) {
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "下发指令:" + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
+ ",指令终点:" + instruction.getNext_device_code() + ",指令执行失败:"+e.getMessage());
+ ",指令终点:" + instruction.getNext_device_code() + ",指令执行失败:" + e.getMessage());
}
this.setRequireSucess(true);
return true;
@@ -847,7 +845,19 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
for (int j = 0; j < taskDtoList.size(); j++) {
//按照优先级排序 优先级相等按照创建时间排序
taskDtoList = this.sortTask(taskDtoList);
task = taskDtoList.get(j);
for (int i1 = 0; i1 < taskDtoList.size(); i1++) {
task = taskDtoList.get(i1);
Boolean flag;
if ("6".equals(task.getTruss_type())) {
flag = checkAgv(task);
if (flag){
break;
}
}else {
break;
}
}
// 9 行架任务
if (!StrUtil.equals(task.getTask_type(), "9")) {
task = null;
@@ -934,13 +944,15 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
map.put("to_onset", Integer.parseInt(start_addr));
map.put("to_task", Integer.parseInt(instdto.getInstruction_code()));
map.put("to_target", Integer.parseInt(next_addr));
if(!StrUtil.isEmpty(task.getVersion())){map.put("inflatableShaftVersion", task.getVersion());}
if (!StrUtil.isEmpty(task.getVersion())) {
map.put("inflatableShaftVersion", task.getVersion());
}
this.writing(map);
try {
this.writing(map);
}catch (Exception e) {
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "下发指令:" + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
+ ",指令终点:" + instdto.getNext_device_code() + ",指令执行失败:"+e.getMessage());
+ ",指令终点:" + instdto.getNext_device_code() + ",指令执行失败:" + e.getMessage());
}
this.setRequireSucess(true);
notCreateInstMessage = "";
@@ -951,5 +963,27 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
return true;
}
}
}
private Boolean checkAgv(TaskDto taskDto) {
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
RgvDeviceDriver rgv1;
RgvDeviceDriver rgv2;
Device deviceByCode = deviceAppService.findDeviceByCode(taskDto.getNext_device_code());
if (deviceByCode.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) deviceByCode.getDeviceDriver();
List<String> linkDeviceCode = standardOrdinarySiteDeviceDriver.getExtraDeviceCodes("link_device_code");
if (linkDeviceCode.size() > 1) {
Device agv1 = deviceAppService.findDeviceByCode(linkDeviceCode.get(0));
Device agv2 = deviceAppService.findDeviceByCode(linkDeviceCode.get(1));
if (agv1.getDeviceDriver() instanceof RgvDeviceDriver && agv2.getDeviceDriver() instanceof RgvDeviceDriver) {
rgv1 = (RgvDeviceDriver) agv1.getDeviceDriver();
rgv2 = (RgvDeviceDriver) agv2.getDeviceDriver();
if ((rgv1.getMode() == 2 && rgv1.getMove1() == 1) || (rgv2.getMode() == 2 && rgv2.getMove1() == 1)) {
return true;
}
}
}
}
return false;
}
}

View File

@@ -25,7 +25,9 @@ import org.nl.acs.task.service.TaskService;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@@ -244,5 +246,20 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
option = Integer.parseInt(flag);
}
}
public List<String> getExtraDeviceCodes(String extraName) {
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
if (StrUtil.isEmpty(extraValue)) {
return new ArrayList<>();
}
String devicesString = extraValue.substring(1, extraValue.length() - 1);
List<String> devicesList = new ArrayList<>();
String[] devices = devicesString.split(",");
for (int i = 0; i < devices.length; i++) {
String s = devices[i].replace("\"", "").replace("\"", "");
devicesList.add(s);
}
return devicesList;
}
}

View File

@@ -98,6 +98,25 @@
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="关联设备" prop="device_code">
<el-select
v-model="form.link_device_code"
filterable
multiple
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>