add:扫码驱动增加换标入库,以及异常取消任务等
This commit is contained in:
@@ -18,6 +18,8 @@ import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.device_driver.lk_conveyor.enums.*;
|
||||
import org.nl.acs.device_driver.lk_manipulator.box_manipulator.BoxManipulatorDeviceDriver;
|
||||
import org.nl.acs.device_driver.lk_manipulator.box_manipulator.InteractionJsonDTO;
|
||||
import org.nl.acs.enums.StorageTypeEnum;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
@@ -39,6 +41,7 @@ import org.nl.config.language.LangProcess;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -64,6 +67,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
|
||||
private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
private final ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
|
||||
private static final List<Integer> CANCEL_TASK_ERROR_CODES = Arrays.asList(52, 53, 54, 55, 56);
|
||||
private static final String CANCEL_TASK_DEVICES_PARAM = "belt_conveyor_error";
|
||||
|
||||
/**
|
||||
* 心跳
|
||||
@@ -150,6 +155,9 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
*/
|
||||
private int to_height_level = 0;
|
||||
private int lastTo_height_level = 0;
|
||||
private int backup1 = 0;
|
||||
private int lastBackup1 = 0;
|
||||
private String lastCancelTaskInstructionCode = null;
|
||||
/**
|
||||
* 手补托盘条码
|
||||
*/
|
||||
@@ -199,6 +207,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
private String led_message;
|
||||
|
||||
private static final Lock LOCK = new ReentrantLock();
|
||||
private static final float PLC_WEIGHT_UNIT_TO_KG = 100.0f;
|
||||
|
||||
public void setLog(String key, Object newValue, Object oldValue) {
|
||||
if (!No_SET_LOG_KEYS.contains(key)) {
|
||||
@@ -211,9 +220,58 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
return this.device;
|
||||
}
|
||||
|
||||
private float getWeightKg() {
|
||||
if (this.weight <= 0 || Float.isNaN(this.weight) || Float.isInfinite(this.weight)) {
|
||||
return 0.0f;
|
||||
}
|
||||
return this.weight / PLC_WEIGHT_UNIT_TO_KG;
|
||||
}
|
||||
|
||||
private boolean cancelTaskAndInstructionWhenError() {
|
||||
if (null == this.barcode || "".equals(this.barcode)){
|
||||
return true;
|
||||
}
|
||||
if (!CANCEL_TASK_ERROR_CODES.contains(this.backup1)) {
|
||||
this.lastCancelTaskInstructionCode = null;
|
||||
return false;
|
||||
}
|
||||
if (this.task <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String instructionCode = String.valueOf(this.task);
|
||||
if (StrUtil.equals(this.lastCancelTaskInstructionCode, instructionCode)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
Instruction inst = instructionService.findByCodeFromCache(instructionCode);
|
||||
if (ObjectUtil.isEmpty(inst) || StrUtil.isBlank(inst.getTask_id())) {
|
||||
return true;
|
||||
}
|
||||
taskService.cancelAndInst(inst.getTask_id(), String.valueOf(this.backup1));
|
||||
this.lastCancelTaskInstructionCode = instructionCode;
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "backup1=" + this.backup1 + ",取消任务和指令,指令号:" + instructionCode + ",任务ID:" + inst.getTask_id()));
|
||||
} catch (Exception e) {
|
||||
log.error("{} backup1={} cancel task and instruction failed, instructionCode={}", this.currentDeviceCode, this.backup1, instructionCode, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isCancelTaskDevice() {
|
||||
Param param = paramService.findByCode(CANCEL_TASK_DEVICES_PARAM);
|
||||
if (ObjectUtil.isEmpty(param) || StrUtil.isBlank(param.getValue())) {
|
||||
return false;
|
||||
}
|
||||
return StrUtil.split(param.getValue(), ',').stream()
|
||||
.map(StrUtil::trim)
|
||||
.anyMatch(deviceCode -> StrUtil.equals(deviceCode, this.currentDeviceCode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
|
||||
this.currentDeviceCode = this.getDevice().getDevice_code();
|
||||
this.heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this);
|
||||
this.mode = ItemProtocol.MODE.getIntegerValue(this);
|
||||
@@ -232,6 +290,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
this.to_task = ItemProtocol.TO_TASK.getIntegerValue(this);
|
||||
this.to_container_type = ItemProtocol.TO_CONTAINER_TYPE.getIntegerValue(this);
|
||||
this.to_height_level = ItemProtocol.TO_HEIGHT_LEVEL.getIntegerValue(this);
|
||||
this.backup1 = ItemProtocol.TO_BACK_UP_2.getIntegerValue(this);
|
||||
if (this.heartbeat != this.lastHeartbeat) {
|
||||
this.setLog(ItemProtocol.HEARTBEAT.getKey(), this.heartbeat, this.lastHeartbeat);
|
||||
}
|
||||
@@ -287,12 +346,16 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
if (this.to_height_level != this.lastTo_height_level) {
|
||||
this.setLog(ItemProtocol.TO_HEIGHT_LEVEL.getKey(), this.to_height_level, this.lastTo_height_level);
|
||||
}
|
||||
if (this.backup1 != this.lastBackup1) {
|
||||
this.setLog(ItemProtocol.TO_BACK_UP_2.getKey(), this.backup1, this.lastBackup1);
|
||||
}
|
||||
|
||||
if (this.move != this.lastMove && this.move == 0 && this.lastMove == 1 && this.mode > 0) {
|
||||
this.requireSuccess = false;
|
||||
clearWrite();
|
||||
}
|
||||
|
||||
Boolean isApplyTask = Optional.ofNullable(this.getExtraValue().get("apply_task")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
|
||||
if (this.move != 0 && this.task > 0) {
|
||||
update_instruction_status();
|
||||
}
|
||||
@@ -309,8 +372,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
this.isError = false;
|
||||
this.message = null;
|
||||
|
||||
Boolean isApplyTask = Optional.ofNullable(this.getExtraValue().get("apply_task")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
|
||||
|
||||
//申请木箱装箱任务
|
||||
if (this.mode == 6 && this.move > 0 && !this.requireSuccess) {
|
||||
if (!isApplyTask) {
|
||||
@@ -327,14 +388,16 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
}
|
||||
|
||||
//子卷入库申请入库任务
|
||||
if (this.mode == 7 && this.move > 0 && !this.requireSuccess) {
|
||||
if (this.mode == 7 && this.move > 0 && !this.requireSuccess)
|
||||
{
|
||||
if (!isApplyTask) {
|
||||
this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode);
|
||||
return;
|
||||
}
|
||||
if (StrUtil.isNotBlank(hand_barcode) && StrUtil.isNotBlank(hand_material_barcode)) {
|
||||
applyInByHand(StorageTypeEnum.STORAGE.getType(), this.mode);
|
||||
} else if (StrUtil.isNotBlank(this.barcode) && StrUtil.isNotBlank(this.material_barcode)) {
|
||||
} else if (StrUtil.isNotBlank(this.barcode) && StrUtil.isNotBlank(this.material_barcode))
|
||||
{
|
||||
applyIn(StorageTypeEnum.STORAGE.getType(), this.mode);
|
||||
} else {
|
||||
this.message = LangProcess.msg("310012");
|
||||
@@ -369,6 +432,26 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
}
|
||||
}
|
||||
|
||||
//申请换标入库
|
||||
if (this.mode == 28 && this.move > 0
|
||||
&& "CK1123".equals(this.currentDeviceCode)
|
||||
&& ObjectUtil.isNotEmpty(this.height)
|
||||
&& !this.requireSuccess) {
|
||||
if (!isApplyTask) {
|
||||
this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode);
|
||||
return;
|
||||
}
|
||||
if (StrUtil.isNotBlank(this.hand_barcode) && StrUtil.isNotBlank(this.hand_material_barcode)) {
|
||||
applyBoxReturnTask(StorageTypeEnum.CHANGE_LABEL_IN.getType(), this.mode);
|
||||
}
|
||||
else if (StrUtil.isNotBlank(this.barcode) && StrUtil.isNotBlank(this.material_barcode))
|
||||
{
|
||||
applyBoxReturnTask(StorageTypeEnum.CHANGE_LABEL_IN.getType(), this.mode);
|
||||
} else {
|
||||
this.message = LangProcess.msg("310012");
|
||||
}
|
||||
}
|
||||
|
||||
//申请高度
|
||||
if (this.mode == 23 && this.move > 0 && !this.requireSuccess) {
|
||||
if (StrUtil.isNotBlank(this.hand_barcode) && StrUtil.isNotBlank(this.hand_material_barcode)) {
|
||||
@@ -379,6 +462,32 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
this.message = LangProcess.msg("310012");
|
||||
}
|
||||
}
|
||||
//退货异常申请桁架任务
|
||||
if (this.mode == 24 && this.move > 0 && !this.requireSuccess) {
|
||||
if (this.container_type == 0) {
|
||||
this.message = LangProcess.msg("310001");
|
||||
} else
|
||||
{
|
||||
if (isApplyTask) {
|
||||
if(cancelTaskAndInstructionWhenError())
|
||||
{
|
||||
Device mxrkhj = deviceAppService.findDeviceByCode("MXRKHJ");
|
||||
BoxManipulatorDeviceDriver deviceDriver = (BoxManipulatorDeviceDriver)mxrkhj.getDeviceDriver();
|
||||
if (ObjectUtil.isNotEmpty(deviceDriver.getPosition_move1()) && 0 == deviceDriver.getPosition_move1())
|
||||
{
|
||||
applyEmptyTask(StorageTypeEnum.BOX_RETURN_HJ.getType(), this.mode);
|
||||
}
|
||||
if (1 == deviceDriver.getPosition_move1())
|
||||
{
|
||||
this.message = "异常位置有货";
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//申请入库指令、异常位指令,指令下发
|
||||
if (this.mode == 2 && this.move > 0 && !this.requireSuccess) {
|
||||
@@ -401,6 +510,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
this.lastTo_target = this.to_target;
|
||||
this.lastTo_task = this.to_task;
|
||||
this.lastTo_container_type = this.to_container_type;
|
||||
this.lastBackup1 = this.backup1;
|
||||
} catch (Exception e) {
|
||||
this.unExecutedMessage = LangProcess.msg("1005");
|
||||
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错, 错误详情: " + e.getMessage() + ", 错误堆栈信息: " + Arrays.toString(e.getStackTrace())));
|
||||
@@ -409,6 +519,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void applyErrorHeight() {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (!isTimeValid(currentTimeMillis)) {
|
||||
@@ -458,7 +569,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
if (StrUtil.isNotEmpty(this.hand_barcode)) {
|
||||
param.put("vehicle_code", this.hand_barcode);
|
||||
} else {
|
||||
if (StrUtil.isNotEmpty(this.barcode) && (this.barcode.startsWith("A") || this.barcode.startsWith("B"))) {
|
||||
if (StrUtil.isNotEmpty(this.barcode) && (this.barcode.startsWith("Y") || this.barcode.startsWith("A") || this.barcode.startsWith("B"))) {
|
||||
param.put("vehicle_code", this.barcode);
|
||||
}
|
||||
}
|
||||
@@ -470,6 +581,9 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
}
|
||||
}
|
||||
param.put("type", type);
|
||||
if (mode == 28){
|
||||
param.put("height_level",this.height);
|
||||
}
|
||||
TaskDto dto = taskService.findByBarcodeFromCache(barcode);
|
||||
if (ObjectUtil.isNotEmpty(dto)) {
|
||||
this.writing(ItemProtocol.TO_COMMAND.getKey(), 1);
|
||||
@@ -509,7 +623,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
if (StrUtil.isNotEmpty(this.hand_barcode)) {
|
||||
param.put("vehicle_code", this.hand_barcode);
|
||||
} else {
|
||||
if (StrUtil.isNotEmpty(this.barcode) && (this.barcode.startsWith("A") || this.barcode.startsWith("B"))) {
|
||||
if (StrUtil.isNotEmpty(this.barcode) && this.barcode.startsWith("Y"))
|
||||
{
|
||||
param.put("vehicle_code", this.barcode);
|
||||
}
|
||||
}
|
||||
@@ -539,12 +654,12 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
this.requireTime = currentTimeMillis;
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("device_code", this.currentDeviceCode);
|
||||
if (this.barcode.startsWith("A") || this.barcode.startsWith("B")) {
|
||||
if (this.barcode.startsWith("Y")) {
|
||||
param.put("vehicle_code", this.barcode);
|
||||
}
|
||||
param.put("material_barcode", this.material_barcode);
|
||||
if (mode == 7 && this.weight != 0) {
|
||||
param.put("weight", this.weight);
|
||||
if (mode == 7) {
|
||||
param.put("weight", this.getWeightKg());
|
||||
}
|
||||
param.put("type", type);
|
||||
HttpResponse httpResponse = acsToWmsService.applyTwo(param);
|
||||
@@ -572,8 +687,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
param.put("device_code", this.currentDeviceCode);
|
||||
param.put("vehicle_code", this.hand_barcode);
|
||||
param.put("material_barcode", this.hand_material_barcode);
|
||||
if (mode == 7 && this.weight != 0) {
|
||||
param.put("weight", this.weight);
|
||||
if (mode == 7) {
|
||||
param.put("weight", this.getWeightKg());
|
||||
}
|
||||
param.put("type", type);
|
||||
HttpResponse httpResponse = acsToWmsService.applyTwo(param);
|
||||
@@ -646,7 +761,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
}
|
||||
return pathlist.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求指令
|
||||
*/
|
||||
@@ -690,10 +804,13 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
return;
|
||||
}
|
||||
TaskDto taskDto = taskService.findByVehicleCodeCodeAndReady(queryBarcode);
|
||||
if (ObjectUtil.isNotEmpty(taskDto)) {
|
||||
if (ObjectUtil.isNotEmpty(taskDto))
|
||||
{
|
||||
String next_device_code = null;
|
||||
String assignedDeviceCode = taskService.queryAssignedByDevice(this.currentDeviceCode, taskDto.getNext_device_code());
|
||||
if (StrUtil.isEmpty(assignedDeviceCode)) {
|
||||
String assignedDeviceCode = null;
|
||||
//String assignedDeviceCode = taskService.queryAssignedByDevice(this.currentDeviceCode, taskDto.getNext_device_code());
|
||||
if (StrUtil.isEmpty(assignedDeviceCode))
|
||||
{
|
||||
next_device_code = this.getNextDeviceCode(taskDto);
|
||||
if (next_device_code == null) {
|
||||
this.unExecutedMessage = taskDto.getStart_device_code() + "->" + next_device_code + LangProcess.msg("1009");
|
||||
@@ -708,7 +825,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
return;
|
||||
}
|
||||
List<String> targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode");
|
||||
if (!targetDeviceCode.contains(inst.getNext_device_code())) {
|
||||
if (!targetDeviceCode.contains(next_device_code)) {
|
||||
this.unExecutedMessage = LangProcess.msg("310006");
|
||||
return;
|
||||
}
|
||||
@@ -718,19 +835,42 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
return;
|
||||
}
|
||||
Instruction instDto = new Instruction();
|
||||
try {
|
||||
try
|
||||
{
|
||||
packageInst(instDto, taskDto, next_device_code);
|
||||
instructionService.create(instDto);
|
||||
} catch (Exception e) {
|
||||
this.unExecutedMessage = LangProcess.msg("1006");
|
||||
return;
|
||||
}
|
||||
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskService.update(taskDto);
|
||||
List<String> keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey());
|
||||
List<Object> values = Arrays.asList(this.getTargetAddress(next_device), Integer.parseInt(inst.getInstruction_code()), 1);
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(taskDto.getInteraction_json(), InteractionJsonDTO.class);
|
||||
List<String> keys = new ArrayList<>(Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()));
|
||||
List<Object> values = new ArrayList<>(Arrays.asList(this.getTargetAddress(next_device), Integer.parseInt(instDto.getInstruction_code()), 1));
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO))
|
||||
{
|
||||
String containerType = interactionJsonDTO.getContainerType();
|
||||
if (StrUtil.isNotBlank(containerType)) {
|
||||
keys.add(ItemProtocol.TO_CONTAINER_TYPE.getKey());
|
||||
values.add(Integer.parseInt(containerType));
|
||||
}
|
||||
String heightLevel = interactionJsonDTO.getHeightLevel();
|
||||
if (StrUtil.isNotBlank(heightLevel)) {
|
||||
keys.add(ItemProtocol.TO_HEIGHT_LEVEL.getKey());
|
||||
values.add(Integer.parseInt(heightLevel));
|
||||
}
|
||||
if ("3".equals(interactionJsonDTO.getType()))
|
||||
{
|
||||
String type = interactionJsonDTO.getType();
|
||||
if (StrUtil.isNotBlank(type)) {
|
||||
keys.add(ItemProtocol.TO_BACK_UP_1.getKey());
|
||||
values.add(Integer.parseInt(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.writing(keys, values);
|
||||
this.requireSuccess = true;
|
||||
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskService.update(taskDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
private String material_barcode = null;
|
||||
private String to_material_barcode = null;
|
||||
private String lastMaterial_barcode = null;
|
||||
/**
|
||||
* 载具类型
|
||||
@@ -204,7 +204,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
this.container_type = ItemProtocol.CONTAINER_TYPE.getIntegerValue(this);
|
||||
this.carrier_direction = ItemProtocol.CARRIER_DIRECTION.getIntegerValue(this);
|
||||
this.task = ItemProtocol.TASK.getIntegerValue(this);
|
||||
this.material_barcode = ItemProtocol.MATERIAL_CODE.getStringValue(this);
|
||||
this.to_material_barcode = ItemProtocol.TO_MATERIAL_CODE.getStringValue(this);
|
||||
this.to_command = ItemProtocol.TO_COMMAND.getIntegerValue(this);
|
||||
this.to_target = ItemProtocol.TO_TARGET.getIntegerValue(this);
|
||||
this.to_task = ItemProtocol.TO_TASK.getIntegerValue(this);
|
||||
@@ -235,8 +235,8 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
if (this.carrier_direction != this.lastCarrier_direction) {
|
||||
this.setLog(ItemProtocol.CARRIER_DIRECTION.getKey(), this.carrier_direction, this.lastCarrier_direction);
|
||||
}
|
||||
if (!StrUtil.equals(this.material_barcode, this.lastMaterial_barcode)) {
|
||||
this.setLog(ItemProtocol.MATERIAL_CODE.getKey(), this.material_barcode, this.lastMaterial_barcode);
|
||||
if (!StrUtil.equals(this.to_material_barcode, this.lastMaterial_barcode)) {
|
||||
this.setLog(ItemProtocol.TO_MATERIAL_CODE.getKey(), this.to_material_barcode, this.lastMaterial_barcode);
|
||||
}
|
||||
if (this.task != this.lastTask) {
|
||||
this.setLog(ItemProtocol.TASK.getKey(), this.task, this.lastTask);
|
||||
@@ -295,7 +295,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
this.lastContainer_type = this.container_type;
|
||||
this.lastCarrier_direction = this.carrier_direction;
|
||||
this.lastTask = this.task;
|
||||
this.lastMaterial_barcode = this.material_barcode;
|
||||
this.lastMaterial_barcode = this.to_material_barcode;
|
||||
this.lastTo_command = this.to_command;
|
||||
this.lastTo_target = this.to_target;
|
||||
this.lastTo_task = this.to_task;
|
||||
@@ -324,13 +324,21 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
String response = acsToWmsService.getIsUncap(param);
|
||||
JSONObject jo = JSON.parseObject(response);
|
||||
if (jo.getIntValue("status") == 200) {
|
||||
String material_code = jo.getString("material_barcode");
|
||||
Integer length = jo.getInteger("boxLength");
|
||||
Integer weight = jo.getInteger("boxWidth");
|
||||
Integer height = jo.getInteger("boxHigh");
|
||||
Integer desiccant = jo.getInteger("desiccantTemplate");
|
||||
Integer type = jo.getInteger("type");
|
||||
List<String> keys = Arrays.asList(ItemProtocol.TO_LENGTH.getKey(), ItemProtocol.TO_WIDTH.getKey(), ItemProtocol.TO_HEIGHT.getKey(), ItemProtocol.TO_DESICCANT.getKey(), ItemProtocol.TO_TYPE.getKey());
|
||||
List<Object> values = Arrays.asList(length, weight, height, desiccant, type);
|
||||
List<String> keys = new ArrayList<>(Arrays.asList(
|
||||
ItemProtocol.TO_LENGTH.getKey(),
|
||||
ItemProtocol.TO_WIDTH.getKey(),
|
||||
ItemProtocol.TO_HEIGHT.getKey(),
|
||||
ItemProtocol.TO_DESICCANT.getKey(),
|
||||
ItemProtocol.TO_TYPE.getKey(),
|
||||
ItemProtocol.TO_MATERIAL_CODE.getKey())
|
||||
);
|
||||
List<Object> values = new ArrayList<>(Arrays.asList(length, weight, height, desiccant, type,material_code));
|
||||
this.writing(keys, values);
|
||||
String isUncap = jo.getString("isUncap");
|
||||
if ("1".equals(isUncap)) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TrappedManipulatorDefination implements OpcDeviceDriverDefination {
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "一楼出库区堆叠桁";
|
||||
return "一楼出库区堆叠桁架";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -350,7 +350,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
this.instruction_update_time = date;
|
||||
//更改指令状态
|
||||
if (task > 0 && !Objects.equals(command, last_command)) {
|
||||
@@ -422,18 +423,10 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
map.put("code", "to_y");
|
||||
map.put("value", inst.getTo_z());
|
||||
list.add(map);
|
||||
if (inst.getTo_x().length() > 1 && !compile.matcher(inst.getTo_x()).matches()) {
|
||||
String substring = inst.getTo_x().substring(1);
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
map1.put("code", "to_z");
|
||||
map1.put("value", substring);
|
||||
list.add(map1);
|
||||
} else {
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
map2.put("code", "to_z");
|
||||
map2.put("value", inst.getTo_x());
|
||||
list.add(map2);
|
||||
}
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
map3.put("code", "to_x");
|
||||
map3.put("value", inst.getTo_y());
|
||||
@@ -641,7 +634,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//空出
|
||||
if (error == 6) {
|
||||
try {
|
||||
updateEXcuteMessage(error.toString());
|
||||
@@ -1089,7 +1082,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
Instruction instruction1 = new Instruction();
|
||||
instruction1.setInstruction_status("0");
|
||||
List<Instruction> instructions = instructionService.findByDeviceCodes(instruction1, false);
|
||||
if (CollUtil.isEmpty(instructions) || instructions.size() < 1) {
|
||||
if (CollUtil.isEmpty(instructions) || instructions.isEmpty()) {
|
||||
this.notCreateInstMessage = "未找到任务";
|
||||
return false;
|
||||
}
|
||||
@@ -1105,7 +1098,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
for (RouteLineDto routeLineDto : routeLineDtos) {
|
||||
if (this.getDeviceCode().equals(routeLineDto.getNext_device_code())) {
|
||||
List<RouteLineDto> routeLineDtoList = routeLineService.selectDeviceCodeList(this.getDeviceCode());
|
||||
if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) {
|
||||
if (CollUtil.isEmpty(routeLineDtoList) || routeLineDtoList.size() < 1) {
|
||||
message = "one_message6";
|
||||
logServer.deviceExecuteLog(this.currentDeviceCode, "", "", "没有" + instruction.getStart_device_code() + "->"
|
||||
+ this.currentDeviceCode + "的路由");
|
||||
@@ -1286,18 +1279,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
map4.put("code", "to_y");
|
||||
map4.put("value", inst.getFrom_z());
|
||||
list.add(map4);
|
||||
if (inst.getFrom_x().length() > 1) {
|
||||
String substring = inst.getFrom_x().substring(1);
|
||||
HashMap map5 = new HashMap();
|
||||
map5.put("code", "to_z");
|
||||
map5.put("value", substring);
|
||||
list.add(map5);
|
||||
} else {
|
||||
|
||||
HashMap map6 = new HashMap();
|
||||
map6.put("code", "to_z");
|
||||
map6.put("value", inst.getFrom_x());
|
||||
list.add(map6);
|
||||
}
|
||||
|
||||
HashMap map7 = new HashMap();
|
||||
map7.put("code", "to_x");
|
||||
map7.put("value", inst.getFrom_y());
|
||||
|
||||
@@ -72,6 +72,7 @@ public class RouteLineServiceImpl extends CommonServiceImpl<RouteLineMapper, Rou
|
||||
Map<String, RoutePlanDto> routePlans = new HashMap<>();
|
||||
Map<Integer, String> routeIndex = new HashMap<>();
|
||||
Map<String, List> routeLines = new HashMap();
|
||||
private volatile Map<String, List<RouteLineDto>> routeLineDeviceCodeCache = new HashMap<>();
|
||||
/**
|
||||
* 用来确定设备在 路由二维数组中的坐标
|
||||
*/
|
||||
@@ -347,7 +348,7 @@ public class RouteLineServiceImpl extends CommonServiceImpl<RouteLineMapper, Rou
|
||||
}
|
||||
}
|
||||
}
|
||||
// reload();
|
||||
reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -539,6 +540,7 @@ public class RouteLineServiceImpl extends CommonServiceImpl<RouteLineMapper, Rou
|
||||
Object[] param = new Object[0];
|
||||
Map map = new HashMap();
|
||||
List<RoutePlanDto> routePlans = this.routePlanService.queryAll(map);
|
||||
refreshRouteLineDeviceCodeCache();
|
||||
Iterator<RoutePlanDto> var2 = routePlans.iterator();
|
||||
while (var2.hasNext()) {
|
||||
RoutePlanDto routePlan = var2.next();
|
||||
@@ -592,6 +594,17 @@ public class RouteLineServiceImpl extends CommonServiceImpl<RouteLineMapper, Rou
|
||||
|
||||
}
|
||||
|
||||
private void refreshRouteLineDeviceCodeCache() {
|
||||
List<RouteLineDto> routeLineDtos = ConvertUtil.convertList(routeLineMapper.selectList(Wrappers.lambdaQuery(RouteLine.class)), RouteLineDto.class);
|
||||
Map<String, List<RouteLineDto>> cache = new HashMap<>();
|
||||
if (ObjectUtil.isNotEmpty(routeLineDtos)) {
|
||||
cache = routeLineDtos.stream()
|
||||
.filter(routeLineDto -> StrUtil.isNotEmpty(routeLineDto.getDevice_code()))
|
||||
.collect(Collectors.groupingBy(RouteLineDto::getDevice_code));
|
||||
}
|
||||
this.routeLineDeviceCodeCache = cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRouteLine(String startDevice, String nextDevice, String plan_code) throws Exception {
|
||||
//判断起点终点设备类型
|
||||
@@ -734,15 +747,8 @@ public class RouteLineServiceImpl extends CommonServiceImpl<RouteLineMapper, Rou
|
||||
@Override
|
||||
public List<RouteLineDto> selectDeviceCodeList(String device_code) {
|
||||
if (StrUtil.isEmpty(device_code)) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<RouteLine> routeLines = routeLineMapper.selectList(Wrappers.lambdaQuery(RouteLine.class).
|
||||
eq(RouteLine::getDevice_code, device_code));
|
||||
List<RouteLineDto> routeLineDtos = new ArrayList<>();
|
||||
for (RouteLine routeLine : routeLines) {
|
||||
RouteLineDto convert = ConvertUtil.convert(routeLine, RouteLineDto.class);
|
||||
routeLineDtos.add(convert);
|
||||
}
|
||||
return routeLineDtos;
|
||||
return Optional.ofNullable(routeLineDeviceCodeCache.get(device_code)).orElse(Collections.emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user