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.*;
@@ -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"))) {
@@ -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,7 +944,9 @@ 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);
@@ -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>