rev:更新
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
package org.nl.acs.device.driver;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.device.device.domain.Device;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface DeviceDriver {
|
||||
/**
|
||||
* getDeviceCode
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String getDeviceCode() {
|
||||
@@ -17,18 +20,21 @@ public interface DeviceDriver {
|
||||
|
||||
/**
|
||||
* getDevice
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Device getDevice();
|
||||
|
||||
/**
|
||||
* getDriverDefination
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
DeviceDriverDefination getDriverDefination();
|
||||
|
||||
/**
|
||||
* setDriverDefination
|
||||
*
|
||||
* @param var1
|
||||
* @return
|
||||
*/
|
||||
@@ -36,6 +42,7 @@ public interface DeviceDriver {
|
||||
|
||||
/**
|
||||
* getDriverDefinationCode
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String getDriverDefinationCode() {
|
||||
@@ -44,6 +51,7 @@ public interface DeviceDriver {
|
||||
|
||||
/**
|
||||
* 将扩展表中的字符串数组数据转换成集合
|
||||
*
|
||||
* @param extraName
|
||||
* @return
|
||||
*/
|
||||
@@ -62,4 +70,22 @@ public interface DeviceDriver {
|
||||
return devicesList;
|
||||
}
|
||||
|
||||
default List<JSONObject> getExtraListValue(String extraName) {
|
||||
String extraListValue = Optional.ofNullable(this.getDevice().getExtraValue().get(extraName)).map(Object::toString).orElse("[]");
|
||||
String stringValue = extraListValue.substring(1, extraListValue.length() - 1);
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
String[] items = stringValue.split("},\\s*\\{");
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (i != 0) {
|
||||
items[i] = "{" + items[i];
|
||||
}
|
||||
if (i != items.length - 1) {
|
||||
items[i] = items[i] + "}";
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(items[i]);
|
||||
result.add(jsonObject);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.nl.acs.device.device.service.dto.DeviceAssignedDto;
|
||||
import org.nl.acs.device.driver.*;
|
||||
import org.nl.acs.device.driver.conveyor.appearance_inspection_scannner_conveyor.enums.*;
|
||||
import org.nl.acs.device.driver.conveyor.strip_conveyor.StripConveyorDeviceDriver;
|
||||
import org.nl.acs.device.driver.storage.standard_storage.StandardStorageDeviceDriver;
|
||||
import org.nl.acs.ext.UnifiedResponse;
|
||||
import org.nl.acs.ext.socket.Online;
|
||||
import org.nl.acs.ext.wms.data.req.CommonRequest;
|
||||
@@ -37,6 +38,8 @@ import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
@@ -144,7 +147,6 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
*/
|
||||
private boolean requireSuccess = false;
|
||||
|
||||
|
||||
/**
|
||||
* 关联站点申请任务请求标记
|
||||
*/
|
||||
@@ -155,7 +157,6 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
*/
|
||||
private long requireTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
/**
|
||||
* 申请入库等待时间
|
||||
*/
|
||||
@@ -191,6 +192,11 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
*/
|
||||
private static final List<String> No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey());
|
||||
|
||||
/**
|
||||
* 记录创建的出库的任务
|
||||
*/
|
||||
private String createTaskCode = null;
|
||||
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
@@ -248,10 +254,18 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (requireSuccess) {
|
||||
// //去查询是否有该点位的执行中的终点任务
|
||||
// //如果没有就复位请求标记
|
||||
// }
|
||||
if (this.requireSuccess && this.createTaskCode != null) {
|
||||
TaskDto taskDto = taskService.findByCodeFromCache(this.createTaskCode);
|
||||
if (ObjectUtil.isEmpty(taskDto)) {
|
||||
this.requireSuccess = false;
|
||||
this.createTaskCode = null;
|
||||
}
|
||||
} else if (!this.requireSuccess && this.createTaskCode != null) {
|
||||
TaskDto taskDto = taskService.findByCodeFromCache(this.createTaskCode);
|
||||
if (ObjectUtil.isEmpty(taskDto)) {
|
||||
this.createTaskCode = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,7 +276,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
} else if (this.mode == 0) {
|
||||
this.message = "设备未联机";
|
||||
} else if (this.error != 0) {
|
||||
this.message = "设备报警";
|
||||
this.message = "设备报警, " + ErrorEnum.getLabel(this.error);
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.isError = false;
|
||||
@@ -327,8 +341,9 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
UnifiedResponse<JSONObject> response = acsToWmsService.apply(request, JSONObject.class);
|
||||
if (response.isSuccess()) {
|
||||
JSONObject data = response.getData();
|
||||
Integer type = data.getInteger("type");
|
||||
Integer type = data.getInteger("height");
|
||||
this.writing("toHeight", type);
|
||||
this.writing("toCommand", this.mode);
|
||||
this.requireSuccess = true;
|
||||
}
|
||||
}
|
||||
@@ -485,9 +500,10 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + next_device_code));
|
||||
return;
|
||||
}
|
||||
if (!taskDto.getTask_code().endsWith("-") && !Online.isOnline) {
|
||||
if (!taskDto.getTask_code().startsWith("-") && !Online.isOnline) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "WMS离线,不生成指令, 在线状态: " + Online.isOnline));
|
||||
this.unExecutedMessage = "WMS离线,不生成指令, 在线状态: " + Online.isOnline;
|
||||
return;
|
||||
}
|
||||
//判断入库任务的起点是否是双向点位,即既是起点又是终点
|
||||
boolean toWayFlag = Optional.ofNullable(this.getExtraValue().get("toWay")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
|
||||
@@ -542,7 +558,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
List<String> targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode");
|
||||
if (targetDeviceCode != null && targetDeviceCode.contains(next_device_code)) {
|
||||
int nextAddress = Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
|
||||
this.writing(Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(nextAddress, instDto.getInstruction_code(), CommandEnum.COMMAND_1.getValue()));
|
||||
this.writing(ItemProtocol.TO_TASK.getKey(), instDto.getInstruction_code());
|
||||
this.writing(Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(nextAddress, CommandEnum.COMMAND_1.getValue()));
|
||||
}
|
||||
}
|
||||
this.handBarcode = null;
|
||||
@@ -560,7 +577,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
List<String> targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode");
|
||||
if (targetDeviceCode != null && targetDeviceCode.contains(next_device_code)) {
|
||||
Integer address = Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
|
||||
this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(instDto.getInstruction_code(), address, CommandEnum.COMMAND_1.getValue()));
|
||||
this.writing(ItemProtocol.TO_TASK.getKey(), instDto.getInstruction_code());
|
||||
this.writing(Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(address, CommandEnum.COMMAND_1.getValue()));
|
||||
this.requireSuccess = true;
|
||||
}
|
||||
}
|
||||
@@ -653,9 +671,10 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + next_device_code));
|
||||
return;
|
||||
}
|
||||
if (!taskDto.getTask_code().endsWith("-") && !Online.isOnline) {
|
||||
if (!taskDto.getTask_code().startsWith("-") && !Online.isOnline) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "WMS离线,不生成指令, 在线状态: " + Online.isOnline));
|
||||
this.unExecutedMessage = "WMS离线,不生成指令, 在线状态: " + Online.isOnline;
|
||||
return;
|
||||
}
|
||||
boolean toWayFlag = Optional.ofNullable(cacheDevice.getExtraValue().get("toWay")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
|
||||
if (toWayFlag) {
|
||||
@@ -703,6 +722,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage()));
|
||||
return;
|
||||
}
|
||||
this.createTaskCode = instDto.getTask_code();
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建出库指令成功,指令号:" + instDto.getInstruction_code() + " , 任务号:" + instDto.getTask_code()));
|
||||
this.unExecutedMessage = "";
|
||||
this.requireSuccess = true;
|
||||
@@ -716,6 +736,58 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isBind(TaskDto link_task, TaskDto taskDto) {
|
||||
List<TaskDto> taskDtos = Arrays.asList(link_task);
|
||||
String from_x = taskDto.getFrom_x();
|
||||
String from_y = taskDto.getFrom_y();
|
||||
String from_z = taskDto.getFrom_z();
|
||||
TaskDto dto = taskDtos.stream()
|
||||
.filter(dto1 -> taskDto.getFrom_x().equals(from_x) && taskDto.getFrom_z().equals(from_z))
|
||||
.filter(dto1 -> {
|
||||
int frontFromY = Integer.parseInt(from_y);
|
||||
int taskDtoFromY = Integer.parseInt(taskDto.getFrom_y());
|
||||
int frontGroup = (frontFromY - 1) / 4;
|
||||
int taskDtoGroup = (taskDtoFromY - 1) / 4;
|
||||
if (frontGroup != taskDtoGroup) {
|
||||
return false;
|
||||
}
|
||||
int frontMod = frontFromY % 4;
|
||||
int taskDtoMod = taskDtoFromY % 4;
|
||||
return (frontMod + taskDtoMod == 2 || frontMod + taskDtoMod == 4);
|
||||
})
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
return dto != null;
|
||||
}
|
||||
|
||||
private boolean isBind(List<TaskDto> taskDtos, TaskDto link_task, String task_code) {
|
||||
String from_x = link_task.getFrom_x();
|
||||
String from_y = link_task.getFrom_y();
|
||||
String from_z = link_task.getFrom_z();
|
||||
TaskDto dto = taskDtos.stream()
|
||||
.filter(taskDto -> !taskDto.getTask_code().equals(task_code))
|
||||
.filter(taskDto -> taskDto.getTask_status().equals(TaskStatusEnum.READY.getIndex()))
|
||||
.filter(taskDto -> taskDto.getFrom_x().equals(from_x) && taskDto.getFrom_z().equals(from_z))
|
||||
.filter(taskDto -> {
|
||||
int frontFromY = Integer.parseInt(from_y);
|
||||
int taskDtoFromY = Integer.parseInt(taskDto.getFrom_y());
|
||||
int frontGroup = (frontFromY - 1) / 4;
|
||||
int taskDtoGroup = (taskDtoFromY - 1) / 4;
|
||||
if (frontGroup != taskDtoGroup) {
|
||||
return false;
|
||||
}
|
||||
int frontMod = frontFromY % 4;
|
||||
int taskDtoMod = taskDtoFromY % 4;
|
||||
return (frontMod + taskDtoMod == 2 || frontMod + taskDtoMod == 4);
|
||||
})
|
||||
.sorted(Comparator.comparing(TaskDto::getPriority)
|
||||
.thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
return dto != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发输送线指令
|
||||
*/
|
||||
|
||||
@@ -8,9 +8,11 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public enum ItemProtocol implements DeviceDriverBaseReader.KeyProvider {
|
||||
HEARTBEAT("heartbeat", "心跳", "DB1001.B0"),
|
||||
IN_OUT_MODE("inOutMode", "出入库模式", "DB1001.B1"),
|
||||
SWITCH_IN_OUT("switchInOut", "允许切换出入库模式", "DB1001.B2"),
|
||||
HEARTBEAT("heartbeat", "心跳", "DB1001.B0"),
|
||||
IN_OUT_MODE("inOutMode", "出入库模式", "DB1001.B1"),
|
||||
SWITCH_IN_OUT("switchInOut", "允许切换出入库模式", "DB1001.B2"),
|
||||
TO_1207("to1207", "下发1207拣选起停", "DB1001.B4"),
|
||||
TO_1210("to1210", "下发1210拣选起停", "DB1001.B5"),
|
||||
TO_COMMAND("toCommand", "下发切换出入库模式", "DB1001.B3");
|
||||
|
||||
private final String key;
|
||||
|
||||
@@ -49,6 +49,18 @@ public class StripConveyorDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
*/
|
||||
private int toCommand = 0;
|
||||
private int lastToCommand = 0;
|
||||
|
||||
/**
|
||||
* 下发1207启停
|
||||
*/
|
||||
private int to1207 = 0;
|
||||
private int lastTo1207 = 0;
|
||||
|
||||
/**
|
||||
* 下发1210启停
|
||||
*/
|
||||
private int to1210 = 0;
|
||||
private int lastTo1210 = 0;
|
||||
/**
|
||||
* 当前设备编号
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -38,9 +39,13 @@ import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description 1、适用于单/双堆垛机;2、默认优先执行移库任务;3、其次按照堆垛机设置的策略(入库优先(含拣选出库)策略、出库优先策略、时间顺序策略)执行;4、除移库任务是从任务列表中查找,其余任务都是从指令列表中查找就绪状态下的信息
|
||||
* @Description 1、适用于单/双堆垛机;
|
||||
* 2、默认优先执行移库任务;
|
||||
* 3、其次按照堆垛机设置的策略(入库优先(含拣选出库)策略、出库优先策略、时间顺序策略、一进一出策略)执行;
|
||||
* 4、除移库任务是从任务列表中查找,其余任务都是从指令列表中查找就绪状态下的信息
|
||||
* @Author Gengby
|
||||
* @Date 2024/6/26
|
||||
*/
|
||||
@@ -249,6 +254,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
*/
|
||||
private int to_back_task = 0;
|
||||
private int lastTo_back_task = 0;
|
||||
|
||||
/**
|
||||
* 当前设备编号
|
||||
*/
|
||||
@@ -320,6 +326,42 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
*/
|
||||
private static final List<String> No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey());
|
||||
|
||||
/**
|
||||
* 默认一楼优先、其次二楼、最后三楼
|
||||
*/
|
||||
private String[] floorPriorities = {"1", "2", "3"};
|
||||
|
||||
/**
|
||||
* 堆垛机在出入库对接点时前叉行走的排列层
|
||||
*/
|
||||
private List<String> originPoint;
|
||||
|
||||
/**
|
||||
* 楼层映射出入库对接点
|
||||
*/
|
||||
private Map<String, Map<String, List<String>>> floorMappingPoint;
|
||||
|
||||
|
||||
private Map<String, Map<String, List<String>>> createFloorMappingPoint() {
|
||||
List<JSONObject> floorPoint = this.getExtraListValue("floorPoint");
|
||||
Map<String, Map<String, List<String>>> floorMappingPoint = new HashMap<>();
|
||||
for (JSONObject jsonObject : floorPoint) {
|
||||
if (jsonObject == null) {
|
||||
continue;
|
||||
}
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
String floor = jsonObject.getString("floor");
|
||||
JSONArray inPoints = jsonObject.getJSONArray("inPoints");
|
||||
List<String> inPointsList = inPoints != null ? inPoints.toJavaList(String.class) : new ArrayList<>();
|
||||
map.put("in", inPointsList);
|
||||
JSONArray outPoints = jsonObject.getJSONArray("outPoints");
|
||||
List<String> outPointsList = outPoints != null ? outPoints.toJavaList(String.class) : new ArrayList<>();
|
||||
map.put("out", outPointsList);
|
||||
floorMappingPoint.put(floor, map);
|
||||
}
|
||||
return floorMappingPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -431,17 +473,18 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
@Override
|
||||
public void executeLogic() {
|
||||
this.stackerNum = Optional.ofNullable(this.getExtraValue().get("stackerNum")).map(Object::toString).map(Integer::parseInt).orElse(1);
|
||||
this.floorPriorities = Optional.ofNullable(this.getExtraValue().get("floorPriority")).map(Object::toString).orElse("1,2,3").split(",");
|
||||
this.originPoint = Arrays.stream(Optional.ofNullable(this.getExtraValue().get("originPoint")).map(Object::toString).orElse("000").split(",")).collect(Collectors.toList());
|
||||
this.floorMappingPoint = this.createFloorMappingPoint();
|
||||
|
||||
if (this.back_command != this.lastBack_command || this.front_command != this.lastFront_command) {
|
||||
this.requireSuccess = false;
|
||||
}
|
||||
|
||||
if (this.front_Zerror != this.lastFront_Zerror || this.back_Zerror != this.lastBack_Zerror) {
|
||||
if (AGAIN_ERROR.contains(this.front_Zerror) || AGAIN_ERROR.contains(this.back_Zerror)) {
|
||||
this.againRequireSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.front_Zerror == ErrorEnum.MR.getCode()) {
|
||||
if (!this.againRequireSuccess) {
|
||||
this.mR(this.front_task, ForkTypeEnum.FRONT.getCode());
|
||||
@@ -453,7 +496,6 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.front_Zerror == ErrorEnum.KC.getCode() && this.back_Zerror == ErrorEnum.KC.getCode()) {
|
||||
if (!this.againRequireSuccess) {
|
||||
this.kC(this.front_task);
|
||||
@@ -479,9 +521,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.front_Zerror == ErrorEnum.ZD.getCode() && this.back_Zerror == ErrorEnum.ZD.getCode()
|
||||
&& this.front_forkCargo == 0 && this.back_forkCargo == 0
|
||||
&& this.front_command == CommandEnum.PICKUP.getStatus() && this.back_command == CommandEnum.PICKUP.getStatus()
|
||||
) {
|
||||
if (!this.againRequireSuccess) {
|
||||
this.getzD(this.front_task);
|
||||
@@ -489,26 +530,26 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
} else if (this.front_Zerror == ErrorEnum.ZD.getCode()) {
|
||||
if (!this.againRequireSuccess) {
|
||||
if (this.front_forkCargo == 0) {
|
||||
if (this.front_command == CommandEnum.PICKUP.getStatus()) {
|
||||
this.getzD(this.front_task);
|
||||
Instruction back_inst = instructionService.findByCodeFromCache(String.valueOf(this.back_task));
|
||||
if (ObjectUtil.isNotEmpty(back_inst)) {
|
||||
this.backWrite(back_inst);
|
||||
}
|
||||
} else if (this.front_forkCargo == 2) {
|
||||
} else if (this.front_command == CommandEnum.RELEASE.getStatus()) {
|
||||
this.putzD(this.front_task, ForkTypeEnum.FRONT.getCode());
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (this.back_Zerror == ErrorEnum.ZD.getCode()) {
|
||||
if (!this.againRequireSuccess) {
|
||||
if (this.back_forkCargo == 0) {
|
||||
if (this.back_command == CommandEnum.PICKUP.getStatus()) {
|
||||
this.getzD(this.back_task);
|
||||
Instruction front_inst = instructionService.findByCodeFromCache(String.valueOf(this.front_task));
|
||||
if (ObjectUtil.isNotEmpty(front_inst)) {
|
||||
this.frontWrite(front_inst);
|
||||
}
|
||||
} else if (this.back_forkCargo == 2) {
|
||||
} else if (this.back_command == CommandEnum.RELEASE.getStatus()) {
|
||||
this.putzD(this.back_task, ForkTypeEnum.BACK.getCode());
|
||||
}
|
||||
}
|
||||
@@ -522,10 +563,10 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
} else if (this.mode != ModeEnum.MODE_3.getNum()) {
|
||||
this.message = "设备未联机";
|
||||
} else if (this.front_Zerror != 0) {
|
||||
this.message = "设备前叉报警";
|
||||
this.message = "设备前叉报警, " + ErrorEnum.getDesc(this.front_Zerror);
|
||||
this.isError = true;
|
||||
} else if (this.back_Zerror != 0) {
|
||||
this.message = "设备后叉报警";
|
||||
this.message = "设备后叉报警," + ErrorEnum.getDesc(this.back_Zerror);
|
||||
this.isError = true;
|
||||
} else {
|
||||
this.message = "";
|
||||
@@ -546,142 +587,181 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
this.applyTask();
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机工作模式:" + this.mode + ", 前叉作业状态:" + this.front_command + ", 前叉任务号:" + this.front_task + "前叉任务是否为空:" + ObjectUtil.isEmpty(frontInst) + ", 前叉探货信号:" + this.front_forkCargo));
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机工作模式:" + this.mode + ", 后叉作业状态:" + this.back_command + ", 后叉任务号:" + this.back_task + "后叉任务是否为空:" + ObjectUtil.isEmpty(backInst) + ", 后叉探货信号:" + this.back_forkCargo));
|
||||
if (this.front_forkCargo == 0 && this.back_forkCargo == 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
|
||||
this.sendGetInfoToPlc(frontInst, backInst);
|
||||
this.requireSuccess = true;
|
||||
} else if (this.front_forkCargo == 0 && this.back_forkCargo == 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isEmpty(backInst)) {
|
||||
this.sendGetInfoToPlc(frontInst, backInst);
|
||||
this.requireSuccess = true;
|
||||
} else if (this.front_forkCargo == 0 && this.back_forkCargo == 0 && ObjectUtil.isEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
|
||||
this.sendGetInfoToPlc(frontInst, backInst);
|
||||
this.requireSuccess = true;
|
||||
} else if (this.front_forkCargo != 0 && this.back_forkCargo == 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
|
||||
this.sendGetInfoToPlc(frontInst, backInst);
|
||||
this.requireSuccess = true;
|
||||
} else if (this.front_forkCargo == 0 && this.back_forkCargo != 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
|
||||
this.sendGetInfoToPlc(frontInst, backInst);
|
||||
this.requireSuccess = true;
|
||||
} else if (this.front_forkCargo != 0 && this.back_forkCargo != 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
this.requireSuccess = true;
|
||||
} else if (this.front_forkCargo == 0 && this.back_forkCargo != 0 && ObjectUtil.isEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
this.requireSuccess = true;
|
||||
} else if (this.front_forkCargo != 0 && this.back_forkCargo == 0 && ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isEmpty(backInst)) {
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
this.requireSuccess = true;
|
||||
}
|
||||
this.requireSuccess = true;
|
||||
|
||||
}
|
||||
}
|
||||
//取货中
|
||||
else if (mode == ModeEnum.MODE_3.getNum() && this.isPickup() && !this.requireSuccess) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货中, 前叉作业状态:" + this.front_command + ", 后叉作业状态:" + this.back_command));
|
||||
this.clearInfoToPlc();
|
||||
}
|
||||
//取货完成
|
||||
else if (mode == ModeEnum.MODE_3.getNum() && this.isPickupComplete() && !requireSuccess) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态:" + this.front_command + ", 后叉作业状态:" + this.back_command));
|
||||
Instruction frontInst = instructionService.findByCodeFromCache(String.valueOf(this.front_task));
|
||||
Instruction backInst = instructionService.findByCodeFromCache(String.valueOf(this.back_task));
|
||||
if (this.front_command == CommandEnum.PICKUP_COMPLETE.getStatus() && this.back_command == CommandEnum.PICKUP_COMPLETE.getStatus()) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉和后叉作业状态都是取货完成,下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
} else if (this.front_command == CommandEnum.PICKUP_COMPLETE.getStatus()) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成"));
|
||||
String front_start_device_code = frontInst.getStart_device_code();
|
||||
String front_next_device_code = frontInst.getNext_device_code();
|
||||
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code);
|
||||
Device front_next_device = deviceAppService.findDeviceByCode(front_next_device_code);
|
||||
//入库
|
||||
if (instanceAppearance(front_start_device) && instanceStorage(front_next_device)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是入库任务"));
|
||||
String getLinkDeviceCode = this.handExtraStringValue(front_start_device, "getLinkDeviceCode");
|
||||
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY");
|
||||
if (ObjectUtil.isEmpty(backInst)) {
|
||||
backInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, backNoY);
|
||||
if (ObjectUtil.isNotEmpty(backInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是入库任务, 查询出后叉任务, 下发后叉取货信息"));
|
||||
String back_start_device_code = backInst.getStart_device_code();
|
||||
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code);
|
||||
this.backWrite(back_start_device, backInst);
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是入库任务, 未查询出后叉任务, 下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是入库任务, 已存在后叉任务, 下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
}
|
||||
//出库
|
||||
else if (instanceStorage(front_start_device) && instanceAppearance(front_next_device)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是出库任务"));
|
||||
String getLinkDeviceCode = this.handExtraStringValue(front_next_device, "getLinkDeviceCode");
|
||||
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY");
|
||||
if (ObjectUtil.isEmpty(backInst)) {
|
||||
backInst = instructionService.findReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, backNoY);
|
||||
if (ObjectUtil.isNotEmpty(backInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是出库任务, 查询出后叉任务, 下发后叉取货信息"));
|
||||
this.backWrite(backInst);
|
||||
} else {
|
||||
//下发前叉放货信息
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是出库任务, 未查询出后叉任务, 下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是出库任务, 已存在后叉任务, 下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
} else if (instanceAppearance(front_start_device) && instanceAppearance(front_next_device)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是特殊任务输送线到输送线"));
|
||||
if (ObjectUtil.isEmpty(backInst)) {
|
||||
List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList");
|
||||
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice");
|
||||
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice");
|
||||
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, front_start_device_code);
|
||||
if (ObjectUtil.isNotEmpty(backInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是特殊任务输送线到输送线,查询到特殊任务后叉任务,下发后叉取货信息"));
|
||||
String back_start_device_code = backInst.getStart_device_code();
|
||||
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code);
|
||||
this.backWrite(back_start_device, backInst);
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是特殊任务输送线到输送线,未查询到特殊任务后叉任务,下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//下发前叉放货信息
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉作业状态是取货完成, 是移库任务, 下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
} else if (this.back_command == CommandEnum.PICKUP_COMPLETE.getStatus()) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成"));
|
||||
String back_start_device_code = backInst.getStart_device_code();
|
||||
String back_next_device_code = backInst.getNext_device_code();
|
||||
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code);
|
||||
Device back_next_device = deviceAppService.findDeviceByCode(back_next_device_code);
|
||||
//入库
|
||||
if (instanceAppearance(back_start_device) && instanceStorage(back_next_device)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是入库任务"));
|
||||
String getLinkDeviceCode = this.handExtraStringValue(back_start_device, "getLinkDeviceCode");
|
||||
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY");
|
||||
if (ObjectUtil.isEmpty(frontInst)) {
|
||||
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY);
|
||||
if (ObjectUtil.isNotEmpty(frontInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是入库任务, 查询出前叉任务, 下发前叉取货信息"));
|
||||
String front_start_device_code = frontInst.getStart_device_code();
|
||||
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code);
|
||||
this.frontWrite(front_start_device, frontInst);
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是入库任务, 未查询出前叉任务, 下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是入库任务, 已存在前叉任务, 下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
}
|
||||
//出库
|
||||
else if (instanceStorage(back_start_device) && instanceAppearance(back_next_device)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是出库任务"));
|
||||
String getLinkDeviceCode = this.handExtraStringValue(back_next_device, "getLinkDeviceCode");
|
||||
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY");
|
||||
if (ObjectUtil.isEmpty(frontInst)) {
|
||||
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, frontNoY);
|
||||
if (ObjectUtil.isNotEmpty(frontInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是出库任务, 查询出前叉任务, 下发前叉取货信息"));
|
||||
this.frontWrite(frontInst);
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是出库任务, 未查询出前叉任务, 下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是出库任务, 已存在前叉任务, 下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
} else if (instanceAppearance(back_start_device) && instanceAppearance(back_next_device)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是特殊任务输送线到输送线"));
|
||||
if (ObjectUtil.isEmpty(backInst)) {
|
||||
List<String> getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList");
|
||||
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice");
|
||||
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice");
|
||||
frontInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getFrontDeviceCodeList, specialGetDevice, specialPutDevice, back_start_device_code);
|
||||
if (ObjectUtil.isNotEmpty(frontInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是特殊任务输送线到输送线,查询到特殊任务前叉任务,下发前叉取货信息"));
|
||||
String front_start_device_code = frontInst.getStart_device_code();
|
||||
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code);
|
||||
this.frontWrite(front_start_device, frontInst);
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是特殊任务输送线到输送线,未查询到特殊任务前叉任务,下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉作业状态是取货完成, 是移库任务, 下发放货信息"));
|
||||
this.sendPutInfoToPlc(frontInst, backInst);
|
||||
}
|
||||
}
|
||||
@@ -689,6 +769,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
//放货中
|
||||
else if (mode == ModeEnum.MODE_3.getNum() && this.isRelease() && !this.requireSuccess) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报放货中, 前叉作业状态:" + this.front_command + ", 后叉作业状态:" + this.back_command));
|
||||
if (this.lastBack_command != CommandEnum.UNLOAD.getStatus() && this.lastFront_command != CommandEnum.UNLOAD.getStatus()) {
|
||||
this.clearInfoToPlc();
|
||||
} else if (this.lastBack_command != CommandEnum.UNLOAD.getStatus() && this.back_command != CommandEnum.STANDY.getStatus()) {
|
||||
@@ -701,25 +782,32 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
//请求卸货
|
||||
else if (mode == ModeEnum.MODE_3.getNum() && this.isUnload() && !requireSuccess) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报请求卸货, 前叉作业状态:" + this.front_command + ", 后叉作业状态:" + this.back_command));
|
||||
this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_THREE.getSignalNum());
|
||||
this.requireSuccess = true;
|
||||
}
|
||||
//卸货完成
|
||||
else if (mode == ModeEnum.MODE_3.getNum() && this.isUnloadComplete() && !requireSuccess) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报卸货完成, 前叉作业状态:" + this.front_command + ", 后叉作业状态:" + this.back_command));
|
||||
if (this.front_command == CommandEnum.UNLOAD_COMPLETE.getStatus() && this.back_command == CommandEnum.UNLOAD_COMPLETE.getStatus()) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报卸货完成, 前叉和后叉作业状态都是卸货完成,反馈确认卸货完成"));
|
||||
this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_ELEVEN.getSignalNum());
|
||||
} else if (this.front_command == CommandEnum.UNLOAD_COMPLETE.getStatus()) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报卸货完成, 前叉作业状态是卸货完成,反馈确认卸货完成"));
|
||||
this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_ELEVEN.getSignalNum());
|
||||
//根据后叉指令号,查询后叉指令,下发后叉放货指令信息
|
||||
Instruction backTask = instructionService.findByCodeFromCache(String.valueOf(back_task));
|
||||
if (ObjectUtil.isNotEmpty(backTask)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报卸货完成, 前叉作业状态是卸货完成,查询到后叉信息还存在, 下发后叉放货信息"));
|
||||
this.sendPutInfoToPlc(null, backTask);
|
||||
}
|
||||
} else if (this.back_command == CommandEnum.UNLOAD_COMPLETE.getStatus()) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报卸货完成, 后叉作业状态是卸货完成,反馈确认卸货完成"));
|
||||
this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_ELEVEN.getSignalNum());
|
||||
//根据前叉指令号,查询前叉指令,下发前叉放货指令信息
|
||||
Instruction frontTask = instructionService.findByCodeFromCache(String.valueOf(front_task));
|
||||
if (ObjectUtil.isNotEmpty(frontTask)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报卸货完成, 后叉作业状态是卸货完成,查询到前叉信息还存在, 下发前叉放货信息"));
|
||||
this.sendPutInfoToPlc(frontTask, null);
|
||||
}
|
||||
}
|
||||
@@ -884,6 +972,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
case "3":
|
||||
this.applyTaskByTime();
|
||||
break;
|
||||
case "4":
|
||||
this.applyTaskOneInOneOut();
|
||||
break;
|
||||
default:
|
||||
this.applyInTask();
|
||||
break;
|
||||
@@ -1167,6 +1258,189 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一进一出策略
|
||||
* 根据楼层优先级
|
||||
*/
|
||||
private void applyTaskOneInOneOut() {
|
||||
if (!prohibitInWarehouse) {
|
||||
String currentXYZ = this.front_z + "" + this.front_x + this.front_y;
|
||||
if (this.originPoint.contains(currentXYZ)) {
|
||||
this.applyTaskOneIn();
|
||||
} else {
|
||||
this.applyTaskOneOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyTaskOneIn() {
|
||||
String currentXYZ = this.front_z + "" + this.front_x + this.front_y;
|
||||
boolean flag = this.applySpecialTask();
|
||||
if (flag) {
|
||||
this.unExecutedMessage = null;
|
||||
return;
|
||||
}
|
||||
Instruction frontInst = null;
|
||||
Instruction backInst = null;
|
||||
Device front_start_device = null;
|
||||
Device back_start_device = null;
|
||||
for (int i = 0; i < this.floorPriorities.length; i++) {
|
||||
String floorPriority = this.floorPriorities[i];
|
||||
Map<String, List<String>> floorPoint = this.floorMappingPoint.get(floorPriority);
|
||||
if (ObjectUtil.isEmpty(floorPoint)) {
|
||||
continue;
|
||||
}
|
||||
List<String> points = floorPoint.get("in");
|
||||
if (CollectionUtil.isEmpty(points)) {
|
||||
continue;
|
||||
}
|
||||
List<String> getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList");
|
||||
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY");
|
||||
List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList");
|
||||
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY");
|
||||
List<Instruction> frontInsts = instructionService.findReadyInstByStartDeviceCode(getFrontDeviceCodeList, frontNoY);
|
||||
if (CollectionUtil.isNotEmpty(frontInsts)) {
|
||||
for (int j = 0; j < frontInsts.size(); j++) {
|
||||
Instruction instruction = frontInsts.get(j);
|
||||
if (points.contains(instruction.getStart_device_code())) {
|
||||
frontInst = instruction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(frontInst)) {
|
||||
String front_start_device_code = frontInst.getStart_device_code();
|
||||
front_start_device = deviceAppService.findDeviceByCode(front_start_device_code);
|
||||
if (front_start_device != null) {
|
||||
String getLinkDeviceCode = this.handExtraStringValue(front_start_device, "getLinkDeviceCode");
|
||||
backInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, backNoY);
|
||||
if (ObjectUtil.isEmpty(backInst)) {
|
||||
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(inst)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.stackerNum == 2) {
|
||||
List<Instruction> backInsts = instructionService.findReadyInstByStartDeviceCode(getBackDeviceCodeList, backNoY);
|
||||
if (CollectionUtil.isNotEmpty(backInsts)) {
|
||||
for (int k = 0; k < backInsts.size(); k++) {
|
||||
Instruction instruction = backInsts.get(k);
|
||||
if (points.contains(instruction.getStart_device_code())) {
|
||||
backInst = instruction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(backInst)) {
|
||||
String back_start_device_code = backInst.getStart_device_code();
|
||||
back_start_device = deviceAppService.findDeviceByCode(back_start_device_code);
|
||||
if (back_start_device != null) {
|
||||
String getLinkDeviceCode = this.handExtraStringValue(back_start_device, "getLinkDeviceCode");
|
||||
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY);
|
||||
if (ObjectUtil.isEmpty(frontInst)) {
|
||||
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(inst)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(frontInst) || ObjectUtil.isNotEmpty(backInst)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
|
||||
this.FBWrite(front_start_device, frontInst, backInst);
|
||||
this.unExecutedMessage = null;
|
||||
this.requireSuccess = true;
|
||||
} else if (ObjectUtil.isNotEmpty(frontInst)) {
|
||||
this.frontWrite(front_start_device, frontInst);
|
||||
this.unExecutedMessage = null;
|
||||
this.requireSuccess = true;
|
||||
} else if (ObjectUtil.isNotEmpty(backInst)) {
|
||||
this.backWrite(back_start_device, backInst);
|
||||
this.unExecutedMessage = null;
|
||||
this.requireSuccess = true;
|
||||
} else {
|
||||
if (this.originPoint.contains(currentXYZ)) {
|
||||
this.applyTaskOneOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyTaskOneOut() {
|
||||
String currentXYZ = this.front_z + "" + this.front_x + this.front_y;
|
||||
Instruction frontInst = null;
|
||||
Instruction backInst = null;
|
||||
for (int i = 0; i < this.floorPriorities.length; i++) {
|
||||
String floorPriority = this.floorPriorities[i];
|
||||
Map<String, List<String>> floorPoint = this.floorMappingPoint.get(floorPriority);
|
||||
if (ObjectUtil.isEmpty(floorPoint)) {
|
||||
continue;
|
||||
}
|
||||
List<String> points = floorPoint.get("out");
|
||||
if (CollectionUtil.isEmpty(points)) {
|
||||
continue;
|
||||
}
|
||||
List<String> getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList");
|
||||
List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList");
|
||||
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY");
|
||||
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY");
|
||||
List<Instruction> frontInsts = instructionService.findReadyInstByNextDeviceCode(getFrontDeviceCodeList, frontNoY);
|
||||
if (CollectionUtil.isNotEmpty(frontInsts)) {
|
||||
for (int j = 0; j < frontInsts.size(); j++) {
|
||||
Instruction instruction = frontInsts.get(j);
|
||||
if (points.contains(instruction.getNext_device_code())) {
|
||||
frontInst = instruction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(frontInst) && this.stackerNum == 2) {
|
||||
String front_next_device_code = frontInst.getNext_device_code();
|
||||
Device front_next_device = deviceAppService.findDeviceByCode(front_next_device_code);
|
||||
if (front_next_device != null) {
|
||||
String getLinkDeviceCode = this.handExtraStringValue(front_next_device, "getLinkDeviceCode");
|
||||
backInst = instructionService.findReadyInstByNextDeviceCode(frontInst, getLinkDeviceCode, backNoY);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.stackerNum == 2) {
|
||||
List<Instruction> backInsts = instructionService.findReadyInstByNextDeviceCode(getBackDeviceCodeList, backNoY);
|
||||
if (CollectionUtil.isNotEmpty(backInsts)) {
|
||||
for (int k = 0; k < backInsts.size(); k++) {
|
||||
Instruction instruction = backInsts.get(k);
|
||||
if (points.contains(instruction.getNext_device_code())) {
|
||||
backInst = instruction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
|
||||
this.FBWrite(frontInst, backInst);
|
||||
this.unExecutedMessage = null;
|
||||
this.requireSuccess = true;
|
||||
} else if (ObjectUtil.isNotEmpty(frontInst)) {
|
||||
this.frontWrite(frontInst);
|
||||
this.unExecutedMessage = null;
|
||||
this.requireSuccess = true;
|
||||
} else if (ObjectUtil.isNotEmpty(backInst)) {
|
||||
this.backWrite(backInst);
|
||||
this.unExecutedMessage = null;
|
||||
this.requireSuccess = true;
|
||||
} else {
|
||||
if (!this.originPoint.contains(currentXYZ)) {
|
||||
this.applyTaskOneIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发前叉取货信息(取货位是输送线)
|
||||
*
|
||||
@@ -1355,6 +1629,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
private void sendGetInfoToPlc(Instruction frontInst, Instruction backInst) {
|
||||
if (ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
|
||||
if (this.front_forkCargo == 0 && this.back_forkCargo == 0 && isBindGet(frontInst, backInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机待机状态下, 前叉和后叉任务都存在,并且前工位和后工位原位都无货, 可以绑定双任务,下发取货信息"));
|
||||
String start_device_code = frontInst.getStart_device_code();
|
||||
Device start_device = deviceAppService.findDeviceByCode(start_device_code);
|
||||
if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
@@ -1366,6 +1641,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
this.writing(this.getFBKeys(), Arrays.asList(x, y, z, frontInst.getInstruction_code(), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_THREE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
|
||||
}
|
||||
} else if (this.front_forkCargo == 0) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机待机状态下, 前叉和后叉任务都存在,并且前工位原位无货,下发取货信息"));
|
||||
String start_device_code = frontInst.getStart_device_code();
|
||||
Device start_device = deviceAppService.findDeviceByCode(start_device_code);
|
||||
if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
@@ -1377,6 +1653,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
this.writing(this.getFBKeys(), Arrays.asList(x, y, z, frontInst.getInstruction_code(), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
|
||||
}
|
||||
} else if (this.back_forkCargo == 0) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机待机状态下, 前叉和后叉任务都存在,并且后工位原位无货,下发取货信息"));
|
||||
String start_device_code = backInst.getStart_device_code();
|
||||
Device start_device = deviceAppService.findDeviceByCode(start_device_code);
|
||||
if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
@@ -1389,6 +1666,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
}
|
||||
} else if (ObjectUtil.isNotEmpty(frontInst) && !isBindGet(frontInst, backInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机待机状态下, 前叉任务存在,下发取货信息"));
|
||||
String start_device_code = frontInst.getStart_device_code();
|
||||
Device start_device = deviceAppService.findDeviceByCode(start_device_code);
|
||||
if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
@@ -1400,6 +1678,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
this.writing(this.getFrontKeys(), Arrays.asList(x, y, z, frontInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
|
||||
}
|
||||
} else if (ObjectUtil.isNotEmpty(backInst) && !isBindGet(frontInst, backInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机待机状态下, 后叉任务存在,下发取货信息"));
|
||||
String start_device_code = backInst.getStart_device_code();
|
||||
Device start_device = deviceAppService.findDeviceByCode(start_device_code);
|
||||
if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
@@ -1411,6 +1690,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
this.writing(this.getBackKeys(), Arrays.asList(x, y, z, backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
|
||||
}
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉和后叉任务都不存在,不下发取货信息"));
|
||||
this.unExecutedMessage = "未执行放货原因, 堆垛机上报任务号不存在";
|
||||
}
|
||||
}
|
||||
@@ -1432,21 +1712,24 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
String back_from_y = backInst.getFrom_y();
|
||||
String back_from_z = backInst.getFrom_z();
|
||||
boolean flagX = StrUtil.equals(front_from_x, back_from_x);
|
||||
// TODO 需要验证规则是否生效
|
||||
boolean flagY = ((Integer.parseInt(front_from_y) - 1) / 4 == (Integer.parseInt(back_from_y) - 1) / 4) && (((Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(back_from_y) % 4) == 2) || (Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(back_from_z) % 4) == 4);
|
||||
boolean flagZ = StrUtil.equals(front_from_z, back_from_z);
|
||||
if (flagX && flagY && flagZ) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上待机状态下,前叉任务号:" + frontInst.getInstruction_code() + ", 后叉任务号:" + backInst.getInstruction_code() + ", 能组成双叉取货任务"));
|
||||
return true;
|
||||
}
|
||||
} else if (StrUtil.equals(back_start_device_code, back_device_code)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上待机状态下,前叉任务号:" + frontInst.getInstruction_code() + ", 后叉任务号:" + backInst.getInstruction_code() + ", 能组成双叉取货任务"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上待机状态下,前叉任务号:" + frontInst.getInstruction_code() + ", 后叉任务号:" + backInst.getInstruction_code() + ", 不能组成双叉取货任务"));
|
||||
return false;
|
||||
}
|
||||
|
||||
private void sendPutInfoToPlc(Instruction frontInst, Instruction backInst) {
|
||||
if (ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst) && isBindPut(frontInst, backInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉和后叉任务都存在,并且可以绑定双任务,下发放货信息"));
|
||||
String next_device_code = frontInst.getNext_device_code();
|
||||
Device next_device = deviceAppService.findDeviceByCode(next_device_code);
|
||||
if (next_device != null && next_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
@@ -1458,6 +1741,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
this.writing(this.getFBKeys(), Arrays.asList(x, y, z, frontInst.getInstruction_code(), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_THREE.getSignalNum(), SendSignalEnum.COMMAND_TWO.getSignalNum()));
|
||||
}
|
||||
} else if (ObjectUtil.isNotEmpty(frontInst) && !isBindPut(frontInst, backInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉任务存在,不可以绑定双任务,下发放货信息"));
|
||||
String next_device_code = frontInst.getNext_device_code();
|
||||
Device next_device = deviceAppService.findDeviceByCode(next_device_code);
|
||||
if (next_device != null && next_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
@@ -1469,6 +1753,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
this.writing(this.getFrontKeys(), Arrays.asList(x, y, z, frontInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_TWO.getSignalNum()));
|
||||
}
|
||||
} else if (ObjectUtil.isNotEmpty(backInst) && !isBindPut(frontInst, backInst)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 后叉任务存在,不可以绑定双任务,下发放货信息"));
|
||||
String next_device_code = backInst.getNext_device_code();
|
||||
Device next_device = deviceAppService.findDeviceByCode(next_device_code);
|
||||
if (next_device != null && next_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
@@ -1480,6 +1765,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
this.writing(this.getBackKeys(), Arrays.asList(x, y, z, backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_TWO.getSignalNum()));
|
||||
}
|
||||
} else {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成, 前叉和后叉任务都不存在,不下发放货信息"));
|
||||
this.unExecutedMessage = "未执行放货原因, 堆垛机上报任务号不存在";
|
||||
}
|
||||
}
|
||||
@@ -1506,12 +1792,15 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
boolean flagY = ((Integer.parseInt(front_to_y) - 1) / 4 == (Integer.parseInt(back_to_y) - 1) / 4) && (((Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(back_to_y) % 4) == 2) || (Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(back_to_z) % 4) == 4);
|
||||
boolean flagZ = StrUtil.equals(front_to_z, back_to_z);
|
||||
if (flagX && flagY && flagZ) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成,前叉任务号:" + frontInst.getInstruction_code() + ", 后叉任务号:" + backInst.getInstruction_code() + ", 能组成双叉放货任务"));
|
||||
return true;
|
||||
}
|
||||
} else if (StrUtil.equals(back_next_device_code, back_device_code)) {
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成,前叉任务号:" + frontInst.getInstruction_code() + ", 后叉任务号:" + backInst.getInstruction_code() + ", 能组成双叉放货任务"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "堆垛机上报取货完成,前叉任务号:" + frontInst.getInstruction_code() + ", 后叉任务号:" + backInst.getInstruction_code() + ", 不能组成双叉放货任务"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ import lombok.Getter;
|
||||
public enum StrategyEnum {
|
||||
IN("1", "入库优先(含拣选出库)策略"),
|
||||
OUT("2", "出库优先策略"),
|
||||
TIME("3", "时间顺序策略");
|
||||
TIME("3", "时间顺序策略"),
|
||||
ONE_IN_ONE_OUT("4", "一进一出策略");
|
||||
|
||||
private final String value;
|
||||
private final String label;
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.nl.acs.ext.wms.IpUtil;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -73,9 +74,24 @@ public class OtherToInterfaceLogAspect {
|
||||
.content("开始请求")
|
||||
.build();
|
||||
logService.interfaceExecuteLog(logDto);
|
||||
|
||||
Object result = joinPoint.proceed();
|
||||
|
||||
Object result = null;
|
||||
try {
|
||||
result = joinPoint.proceed();
|
||||
} catch (Exception e) {
|
||||
logDto =
|
||||
LuceneLogDto.builder()
|
||||
.logType("接口日志")
|
||||
.request_url(IpUtil.localIP() + classUrlValue + methodUrlValue)
|
||||
.request_direction(request_direction)
|
||||
.request_param(JSON.toJSONString(args))
|
||||
.method(methodName)
|
||||
.response_param(e.getMessage())
|
||||
.executeTime(System.currentTimeMillis() - startTime)
|
||||
.content("响应请求")
|
||||
.build();
|
||||
logService.interfaceExecuteLog(logDto);
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
logDto =
|
||||
LuceneLogDto.builder()
|
||||
.logType("接口日志")
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -103,9 +104,24 @@ public class ToOtherInterfaceLogAspect {
|
||||
.content("开始请求")
|
||||
.build();
|
||||
logService.interfaceExecuteLog(logDto);
|
||||
|
||||
Object result = joinPoint.proceed();
|
||||
|
||||
Object result = null;
|
||||
try {
|
||||
result = joinPoint.proceed();
|
||||
} catch (Exception e) {
|
||||
logDto =
|
||||
LuceneLogDto.builder()
|
||||
.logType("接口日志")
|
||||
.request_url(ipPort + String.valueOf(url))
|
||||
.request_direction(request_direction)
|
||||
.request_param(JSON.toJSONString(requesr_param))
|
||||
.method(methodName)
|
||||
.response_param(e.getMessage())
|
||||
.executeTime(System.currentTimeMillis() - startTime)
|
||||
.content("响应请求")
|
||||
.build();
|
||||
logService.interfaceExecuteLog(logDto);
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
logDto =
|
||||
LuceneLogDto.builder()
|
||||
.logType("接口日志")
|
||||
|
||||
@@ -262,7 +262,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
if (stripConveyorDeviceDriver.getInOutMode() == 0) {
|
||||
throw new BadRequestException("已经是入库模式,无法再次切换为入库模式");
|
||||
} else {
|
||||
if (stripConveyorDeviceDriver.getSwitchInOut() == 0) {
|
||||
if (stripConveyorDeviceDriver.getSwitchInOut() == 1) {
|
||||
throw new BadRequestException("输送线不允许切换为入库模式");
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
if (stripConveyorDeviceDriver.getInOutMode() == 1) {
|
||||
throw new BadRequestException("已经是出库模式,无法再次切换为出库模式");
|
||||
} else {
|
||||
if (stripConveyorDeviceDriver.getSwitchInOut() == 0) {
|
||||
if (stripConveyorDeviceDriver.getSwitchInOut() == 1) {
|
||||
throw new BadRequestException("输送线不允许切换为出库模式");
|
||||
}
|
||||
}
|
||||
@@ -306,17 +306,19 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
if (StrUtil.isBlank(device_code)) {
|
||||
throw new BadRequestException("设备号不能为空!");
|
||||
}
|
||||
String type = reqs.getString("status");
|
||||
String type = reqs.getString("type");
|
||||
if (StrUtil.isEmpty(type)) {
|
||||
throw new BadRequestException("启停状态不能为空!");
|
||||
}
|
||||
Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (device != null && device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
|
||||
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) device.getDeviceDriver();
|
||||
Device device = deviceAppService.findDeviceByCode("1001");
|
||||
if (device != null && device.getDeviceDriver() instanceof StripConveyorDeviceDriver) {
|
||||
StripConveyorDeviceDriver stripConveyorDeviceDriver = (StripConveyorDeviceDriver) device.getDeviceDriver();
|
||||
if ("1".equals(type)) {
|
||||
appearanceInspectionScannerConveyorDeviceDriver.writing("mode", 2);
|
||||
stripConveyorDeviceDriver.writing("to" + device_code, 0);
|
||||
stripConveyorDeviceDriver.writing("to" + device_code, 1);
|
||||
} else {
|
||||
appearanceInspectionScannerConveyorDeviceDriver.writing("mode", 0);
|
||||
stripConveyorDeviceDriver.writing("to" + device_code, 0);
|
||||
stripConveyorDeviceDriver.writing("to" + device_code, 1);
|
||||
}
|
||||
} else {
|
||||
throw new BadRequestException("设备不存在");
|
||||
@@ -340,9 +342,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
throw new BadRequestException("下发参数不能为空");
|
||||
}
|
||||
Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
|
||||
Integer toHeight = req.getInteger("toHeight");
|
||||
if (device != null && device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
|
||||
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) device.getDeviceDriver();
|
||||
if (toHeight != null) {
|
||||
appearanceInspectionScannerConveyorDeviceDriver.writing("toHeight", toHeight);
|
||||
}
|
||||
appearanceInspectionScannerConveyorDeviceDriver.writing("toCommand", toCommand);
|
||||
}
|
||||
JSONObject resp = new JSONObject();
|
||||
|
||||
@@ -364,6 +364,8 @@ public interface TaskService extends CommonService<Task> {
|
||||
|
||||
TaskDto findReadyTaskByNextDeviceCode(String next_device_code,List<String> checkoutStartDeviceCode);
|
||||
|
||||
List<TaskDto> findReadyTasksByNextDeviceCode(String next_device_code,List<String> checkoutStartDeviceCode);
|
||||
|
||||
List<TaskDto> findReadyTaskByXDeviceCode(List<String> xDeviceCodeList, String noY);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1310,12 +1310,39 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
.filter(taskDto -> TaskStatusEnum.READY.getIndex().equals(taskDto.getTask_status()))
|
||||
.filter(taskDto -> taskDto.getNext_device_code().equals(next_device_code))
|
||||
.filter(taskDto -> !checkoutStartDeviceCode.contains(taskDto.getStart_device_code()))
|
||||
.sorted(Comparator.comparing(TaskDto::getPriority)
|
||||
.sorted(Comparator.comparingInt((TaskDto taskDto) -> Integer.parseInt(getNumericPart(taskDto.getStart_device_code())) % 4).reversed()
|
||||
.thenComparing(taskDto -> Integer.parseInt(ObjectUtil.isEmpty(taskDto.getFrom_y()) ? "0" : taskDto.getFrom_y()))
|
||||
.thenComparing(TaskDto::getPriority)
|
||||
.thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> findReadyTasksByNextDeviceCode(String next_device_code, List<String> checkoutStartDeviceCode) {
|
||||
return Optional.ofNullable(this.tasks)
|
||||
.orElse(new CopyOnWriteArrayList<>())
|
||||
.stream()
|
||||
.filter(taskDto -> TaskStatusEnum.READY.getIndex().equals(taskDto.getTask_status()))
|
||||
.filter(taskDto -> taskDto.getNext_device_code().equals(next_device_code))
|
||||
.filter(taskDto -> !checkoutStartDeviceCode.contains(taskDto.getStart_device_code()))
|
||||
.sorted(Comparator.comparingInt((TaskDto taskDto) -> Integer.parseInt(getNumericPart(taskDto.getStart_device_code())) % 4).reversed()
|
||||
.thenComparing(taskDto -> Integer.parseInt(ObjectUtil.isEmpty(taskDto.getFrom_z()) ? "0" : taskDto.getFrom_z()))
|
||||
.thenComparing(taskDto -> Integer.parseInt(ObjectUtil.isEmpty(taskDto.getFrom_y()) ? "0" : taskDto.getFrom_y()))
|
||||
.thenComparing(TaskDto::getPriority)
|
||||
.thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private String getNumericPart(String device_c0de) {
|
||||
Pattern pattern = Pattern.compile("\\d+");
|
||||
Matcher matcher = pattern.matcher(device_c0de);
|
||||
if (matcher.find()) {
|
||||
return matcher.group();
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> findReadyTaskByXDeviceCode(List<String> xDeviceCodeList, String noY) {
|
||||
// String currentNoY = noY == null ? "" : noY;
|
||||
|
||||
Reference in New Issue
Block a user