|
|
@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.google.common.util.concurrent.Uninterruptibles; |
|
|
|
import lombok.*; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.nl.acs.device.device.domain.Device; |
|
|
|
import org.nl.acs.device.device.service.DeviceAppService; |
|
|
|
import org.nl.acs.device.driver.*; |
|
|
@ -45,9 +46,7 @@ import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 1、适用于单/双堆垛机; |
|
|
|
* 2、默认优先执行移库任务; |
|
|
|
* 3、其次按照堆垛机设置的策略(入库优先(含拣选出库)策略、出库优先策略、时间顺序策略、一进一出策略)执行; |
|
|
|
* 4、除移库任务是从任务列表中查找,其余任务都是从指令列表中查找就绪状态下的信息 |
|
|
|
* 2、默认优先执行移库任务,其次执行换层任务,再按照堆垛机所在位置执行一进一出的出入库任务; |
|
|
|
* @Author Gengby |
|
|
|
* @Date 2024/6/26 |
|
|
|
*/ |
|
|
@ -360,6 +359,16 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
private List<Integer> HAS_GOODS = Arrays.asList(2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 任务申请失败通知时间 |
|
|
|
*/ |
|
|
|
private long errorRequireTime = System.currentTimeMillis(); |
|
|
|
|
|
|
|
/** |
|
|
|
* 任务申请失败请求间隔时间 |
|
|
|
*/ |
|
|
|
private long errorRequireTimeOut = 60000L; |
|
|
|
|
|
|
|
private Map<String, Map<String, List<String>>> createFloorMappingPoint() { |
|
|
|
List<JSONObject> floorPoint = this.getExtraListValue("floorPoint"); |
|
|
|
Map<String, Map<String, List<String>>> floorMappingPoint = new HashMap<>(); |
|
|
@ -506,7 +515,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) |
|
|
|
.map(notify -> notify.getValue()) |
|
|
|
.orElse("0"); |
|
|
|
if (notifyValue.equals("1")){ |
|
|
|
if (notifyValue.equals("1")) { |
|
|
|
JSONObject dataParam = new JSONObject(); |
|
|
|
dataParam.put("msg", "设备" + this.currentDeviceCode + "报警, 报警信息: 前叉 " + ErrorEnum.getDesc(this.front_Zerror) + ", 后叉 " + ErrorEnum.getDesc(this.back_Zerror)); |
|
|
|
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder() |
|
|
@ -537,11 +546,13 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
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()); |
|
|
@ -551,6 +562,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
this.mR(this.back_task, ForkTypeEnum.BACK.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (this.front_Zerror == ErrorEnum.KC.getCode() && this.back_Zerror == ErrorEnum.KC.getCode()) { |
|
|
|
if (!this.againRequireSuccess) { |
|
|
|
this.kC(this.front_task); |
|
|
@ -573,6 +585,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (this.front_Zerror == ErrorEnum.ZD.getCode() && this.back_Zerror == ErrorEnum.ZD.getCode() |
|
|
|
&& NO_HAS_GOODS.contains(this.front_forkCargo) && NO_HAS_GOODS.contains(this.back_forkCargo) |
|
|
|
) { |
|
|
@ -686,52 +699,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
} |
|
|
|
//出库
|
|
|
|
else if (instanceStorage(back_start_device) && instanceAppearance(back_next_device)) { |
|
|
|
String getLinkDeviceCode = this.handExtraStringValue(back_next_device, "getLinkDeviceCode"); |
|
|
|
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); |
|
|
|
if (ObjectUtil.isEmpty(frontInst)) { |
|
|
|
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); |
|
|
|
if (ObjectUtil.isNotEmpty(frontInst)) { |
|
|
|
String qPoint = getZdPoint(frontInst.getStart_point_code()); |
|
|
|
TaskDto taskDto = taskService.findByStartPointCode(qPoint); |
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
String task_start_device_code = taskDto.getStart_device_code(); |
|
|
|
String task_next_device_code = taskDto.getNext_device_code(); |
|
|
|
Device task_start_device = deviceAppService.findDeviceByCode(task_start_device_code); |
|
|
|
Device task_next_devcice = deviceAppService.findDeviceByCode(task_next_device_code); |
|
|
|
if (task_start_device != null && task_next_devcice != null && instanceStorage(task_start_device) && instanceStorage(task_next_devcice)) { |
|
|
|
Instruction instruction = instructionService.findByTaskCodeFromCache(taskDto.getTask_code()); |
|
|
|
if (ObjectUtil.isEmpty(instruction)) { |
|
|
|
frontInst = new Instruction(); |
|
|
|
setInstruction(frontInst, taskDto); |
|
|
|
try { |
|
|
|
instructionService.create(frontInst); |
|
|
|
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); |
|
|
|
taskService.update(taskDto); |
|
|
|
} catch (Exception e) { |
|
|
|
this.unExecutedMessage = "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage(); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage())); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.frontWrite(frontInst); |
|
|
|
} else { |
|
|
|
if (StrUtil.equals(instruction.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { |
|
|
|
this.frontWrite(instruction); |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.frontWrite(frontInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
} |
|
|
|
} |
|
|
|
//前叉有货,后叉无货,后叉取货完成
|
|
|
|
this.backGetFinish(back_next_device, frontInst, backInst, getFrontDeviceCodeList); |
|
|
|
this.requireSuccess = true; |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
@ -773,52 +742,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
} |
|
|
|
//出库
|
|
|
|
else if (instanceStorage(front_start_device) && instanceAppearance(front_next_device)) { |
|
|
|
String getLinkDeviceCode = this.handExtraStringValue(front_next_device, "getLinkDeviceCode"); |
|
|
|
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); |
|
|
|
if (ObjectUtil.isEmpty(backInst)) { |
|
|
|
backInst = instructionService.findReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList); |
|
|
|
if (ObjectUtil.isNotEmpty(backInst)) { |
|
|
|
String qPoint = getZdPoint(backInst.getStart_point_code()); |
|
|
|
TaskDto taskDto = taskService.findByStartPointCode(qPoint); |
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
String task_start_device_code = taskDto.getStart_device_code(); |
|
|
|
String task_next_device_code = taskDto.getNext_device_code(); |
|
|
|
Device task_start_device = deviceAppService.findDeviceByCode(task_start_device_code); |
|
|
|
Device task_next_devcice = deviceAppService.findDeviceByCode(task_next_device_code); |
|
|
|
if (task_start_device != null && task_next_devcice != null && instanceStorage(task_start_device) && instanceStorage(task_next_devcice)) { |
|
|
|
Instruction instruction = instructionService.findByTaskCodeFromCache(taskDto.getTask_code()); |
|
|
|
if (ObjectUtil.isEmpty(instruction)) { |
|
|
|
backInst = new Instruction(); |
|
|
|
setInstruction(backInst, taskDto); |
|
|
|
try { |
|
|
|
instructionService.create(backInst); |
|
|
|
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); |
|
|
|
taskService.update(taskDto); |
|
|
|
} catch (Exception e) { |
|
|
|
this.unExecutedMessage = "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage(); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage())); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.backWrite(backInst); |
|
|
|
} else { |
|
|
|
if (StrUtil.equals(instruction.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { |
|
|
|
this.backWrite(instruction); |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.backWrite(backInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
} |
|
|
|
} |
|
|
|
//前叉有货,后叉无货,前叉取货完成
|
|
|
|
this.frontGetFinish(front_next_device, frontInst, backInst, getBackDeviceCodeList); |
|
|
|
this.requireSuccess = true; |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
@ -878,60 +803,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
} |
|
|
|
//出库
|
|
|
|
else if (instanceStorage(front_start_device) && instanceAppearance(front_next_device)) { |
|
|
|
String getLinkDeviceCode = this.handExtraStringValue(front_next_device, "getLinkDeviceCode"); |
|
|
|
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); |
|
|
|
if (ObjectUtil.isEmpty(backInst)) { |
|
|
|
backInst = instructionService.findShallowReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList); |
|
|
|
if (ObjectUtil.isNotEmpty(backInst)) { |
|
|
|
this.backWrite(backInst); |
|
|
|
} else { |
|
|
|
backInst = instructionService.findDeepReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList); |
|
|
|
if (ObjectUtil.isNotEmpty(backInst)) { |
|
|
|
String qPoint = getZdPoint(backInst.getStart_point_code()); |
|
|
|
TaskDto taskDto = taskService.findByStartPointCode(qPoint); |
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
String task_start_device_code = taskDto.getStart_device_code(); |
|
|
|
String task_next_device_code = taskDto.getNext_device_code(); |
|
|
|
Device task_start_device = deviceAppService.findDeviceByCode(task_start_device_code); |
|
|
|
Device task_next_devcice = deviceAppService.findDeviceByCode(task_next_device_code); |
|
|
|
if (task_start_device != null && task_next_devcice != null && instanceStorage(task_start_device) && instanceStorage(task_next_devcice)) { |
|
|
|
Instruction instruction = instructionService.findByTaskCodeFromCache(taskDto.getTask_code()); |
|
|
|
if (ObjectUtil.isEmpty(instruction)) { |
|
|
|
backInst = new Instruction(); |
|
|
|
setInstruction(backInst, taskDto); |
|
|
|
try { |
|
|
|
instructionService.create(backInst); |
|
|
|
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); |
|
|
|
taskService.update(taskDto); |
|
|
|
} catch (Exception e) { |
|
|
|
this.unExecutedMessage = "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage(); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage())); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.backWrite(backInst); |
|
|
|
} else { |
|
|
|
if (StrUtil.equals(instruction.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { |
|
|
|
this.backWrite(instruction); |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.backWrite(backInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
//下发前叉放货信息
|
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
|
} |
|
|
|
//前叉取货完成
|
|
|
|
this.frontGetFinish(front_next_device, frontInst, backInst, getBackDeviceCodeList); |
|
|
|
} else if (instanceAppearance(front_start_device) && instanceAppearance(front_next_device)) { |
|
|
|
if (ObjectUtil.isEmpty(backInst)) { |
|
|
|
// List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList");
|
|
|
@ -992,60 +865,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
} |
|
|
|
//出库
|
|
|
|
else if (instanceStorage(back_start_device) && instanceAppearance(back_next_device)) { |
|
|
|
String getLinkDeviceCode = this.handExtraStringValue(back_next_device, "getLinkDeviceCode"); |
|
|
|
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); |
|
|
|
if (ObjectUtil.isEmpty(frontInst)) { |
|
|
|
frontInst = instructionService.findShallowReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); |
|
|
|
if (ObjectUtil.isNotEmpty(frontInst)) { |
|
|
|
this.frontWrite(frontInst); |
|
|
|
} else { |
|
|
|
frontInst = instructionService.findDeepReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); |
|
|
|
if (ObjectUtil.isNotEmpty(frontInst)) { |
|
|
|
String qPoint = getZdPoint(frontInst.getStart_point_code()); |
|
|
|
TaskDto taskDto = taskService.findByStartPointCode(qPoint); |
|
|
|
if (ObjectUtil.isNotEmpty(taskDto)) { |
|
|
|
String task_start_device_code = taskDto.getStart_device_code(); |
|
|
|
String task_next_device_code = taskDto.getNext_device_code(); |
|
|
|
Device task_start_device = deviceAppService.findDeviceByCode(task_start_device_code); |
|
|
|
Device task_next_devcice = deviceAppService.findDeviceByCode(task_next_device_code); |
|
|
|
if (task_start_device != null && task_next_devcice != null && instanceStorage(task_start_device) && instanceStorage(task_next_devcice)) { |
|
|
|
Instruction instruction = instructionService.findByTaskCodeFromCache(taskDto.getTask_code()); |
|
|
|
if (ObjectUtil.isEmpty(instruction)) { |
|
|
|
frontInst = new Instruction(); |
|
|
|
setInstruction(frontInst, taskDto); |
|
|
|
try { |
|
|
|
instructionService.create(frontInst); |
|
|
|
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); |
|
|
|
taskService.update(taskDto); |
|
|
|
} catch (Exception e) { |
|
|
|
this.unExecutedMessage = "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage(); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage())); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.frontWrite(frontInst); |
|
|
|
} else { |
|
|
|
if (StrUtil.equals(instruction.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { |
|
|
|
this.frontWrite(instruction); |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.frontWrite(frontInst); |
|
|
|
} |
|
|
|
} else { |
|
|
|
//下发前叉放货信息
|
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, backInst); |
|
|
|
} |
|
|
|
//后叉取货完成
|
|
|
|
this.backGetFinish(back_next_device, frontInst, backInst, getFrontDeviceCodeList); |
|
|
|
} else if (instanceAppearance(back_start_device) && instanceAppearance(back_next_device)) { |
|
|
|
if (ObjectUtil.isEmpty(frontInst)) { |
|
|
|
//List<String> getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList");
|
|
|
@ -1079,9 +900,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
this.clearInfoToPlc(); |
|
|
|
} else if (this.lastFront_command != CommandEnum.UNLOAD.getStatus() && this.front_command != CommandEnum.STANDY.getStatus()) { |
|
|
|
this.clearInfoToPlc(); |
|
|
|
} else { |
|
|
|
this.requireSuccess = true; |
|
|
|
} |
|
|
|
this.requireSuccess = true; |
|
|
|
} |
|
|
|
//请求卸货
|
|
|
|
else if (mode == ModeEnum.MODE_3.getNum() && this.isUnload() && !requireSuccess) { |
|
|
@ -1274,18 +1094,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
} else { |
|
|
|
String strategyValue = Optional.ofNullable(this.getExtraValue().get("strategyValue")).map(Object::toString).orElse(""); |
|
|
|
switch (strategyValue) { |
|
|
|
case "2": |
|
|
|
this.applyOutTask(); |
|
|
|
break; |
|
|
|
case "3": |
|
|
|
this.applyTaskByTime(); |
|
|
|
break; |
|
|
|
case "4": |
|
|
|
this.applyTaskOneInOneOut(); |
|
|
|
break; |
|
|
|
default: |
|
|
|
this.applyInTask(); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
@ -1304,7 +1115,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 拣选出库 |
|
|
|
* 堆垛机换层任务 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -1360,230 +1171,6 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 入库 |
|
|
|
*/ |
|
|
|
private void applyInTask() { |
|
|
|
boolean flag = this.applySpecialTask(); |
|
|
|
if (flag) { |
|
|
|
this.unExecutedMessage = null; |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!prohibitInWarehouse) { |
|
|
|
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); |
|
|
|
Instruction frontInst = null; |
|
|
|
Instruction backInst = null; |
|
|
|
Device front_start_device = null; |
|
|
|
Device back_start_device = null; |
|
|
|
if (CollectionUtil.isNotEmpty(frontInsts)) { |
|
|
|
frontInst = frontInsts.get(0); |
|
|
|
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, getBackDeviceCodeList); |
|
|
|
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)) { |
|
|
|
backInst = backInsts.get(0); |
|
|
|
} |
|
|
|
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"); |
|
|
|
front_start_device = deviceAppService.findDeviceByCode(getLinkDeviceCode); |
|
|
|
if (front_start_device != null) { |
|
|
|
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); |
|
|
|
if (ObjectUtil.isEmpty(frontInst)) { |
|
|
|
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode); |
|
|
|
if (ObjectUtil.isNotEmpty(inst)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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 { |
|
|
|
String strategyValue = Optional.ofNullable(this.getExtraValue().get("strategyValue")).map(Object::toString).orElse(""); |
|
|
|
if (ObjectUtil.equals(strategyValue, StrategyEnum.IN.getValue())) { |
|
|
|
this.applyOutTask(); |
|
|
|
} else if (ObjectUtil.equals(strategyValue, StrategyEnum.OUT.getValue()) && !ObjectUtil.equals(strategyValue, StrategyEnum.TIME.getValue())) { |
|
|
|
this.unExecutedMessage = "堆垛机未查询到就绪状态下可执行的任务或指令信息"; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (this.prohibitOutWarehouse) { |
|
|
|
this.unExecutedMessage = "堆垛机设置为禁止出库、禁止入库"; |
|
|
|
return; |
|
|
|
} |
|
|
|
this.applyOutTask(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 出库(含拣选) |
|
|
|
*/ |
|
|
|
private void applyOutTask() { |
|
|
|
if (!this.prohibitOutWarehouse) { |
|
|
|
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); |
|
|
|
Instruction frontInst = null; |
|
|
|
Instruction backInst = null; |
|
|
|
if (CollectionUtil.isNotEmpty(frontInsts)) { |
|
|
|
frontInst = frontInsts.get(0); |
|
|
|
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)) { |
|
|
|
backInst = backInsts.get(0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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 { |
|
|
|
String strategyValue = Optional.ofNullable(this.getExtraValue().get("strategyValue")).map(Object::toString).orElse(""); |
|
|
|
if (ObjectUtil.equals(strategyValue, StrategyEnum.OUT.getValue())) { |
|
|
|
this.applyInTask(); |
|
|
|
} else if (ObjectUtil.equals(strategyValue, StrategyEnum.IN.getValue()) && !ObjectUtil.equals(strategyValue, StrategyEnum.TIME.getValue())) { |
|
|
|
this.unExecutedMessage = "堆垛机未查询到就绪状态下可执行的任务或指令信息"; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (this.prohibitInWarehouse) { |
|
|
|
this.unExecutedMessage = "堆垛机设置为禁止出库、禁止入库"; |
|
|
|
return; |
|
|
|
} |
|
|
|
this.applyInTask(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 时间顺序策略 |
|
|
|
*/ |
|
|
|
private void applyTaskByTime() { |
|
|
|
boolean flag = this.applySpecialTask(); |
|
|
|
if (flag) { |
|
|
|
this.unExecutedMessage = null; |
|
|
|
return; |
|
|
|
} |
|
|
|
List<String> getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList"); |
|
|
|
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); |
|
|
|
List<Instruction> frontInsts = instructionService.findReadyInstByDeviceCode(getFrontDeviceCodeList, frontNoY); |
|
|
|
Instruction frontInst = null; |
|
|
|
if (CollectionUtil.isNotEmpty(frontInsts)) { |
|
|
|
frontInst = frontInsts.get(0); |
|
|
|
} |
|
|
|
if (ObjectUtil.isNotEmpty(frontInst)) { |
|
|
|
String front_start_device_code = frontInst.getStart_device_code(); |
|
|
|
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); |
|
|
|
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); |
|
|
|
if (front_start_device != null && front_start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { |
|
|
|
String getLinkDeviceCode = this.handExtraStringValue(front_start_device, "getLinkDeviceCode"); |
|
|
|
Instruction backInst = instructionService.findReadyInstByStartDeviceCode(frontInst, getLinkDeviceCode, backNoY); |
|
|
|
if (ObjectUtil.isNotEmpty(getLinkDeviceCode) && deviceAppService.findDeviceByCode(getLinkDeviceCode) != null && ObjectUtil.isNotEmpty(backInst)) { |
|
|
|
this.FBWrite(front_start_device, frontInst, backInst); |
|
|
|
this.unExecutedMessage = null; |
|
|
|
this.requireSuccess = true; |
|
|
|
} else { |
|
|
|
this.frontWrite(front_start_device, frontInst); |
|
|
|
this.unExecutedMessage = null; |
|
|
|
this.requireSuccess = true; |
|
|
|
} |
|
|
|
} else if (front_start_device != null && front_start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|
|
|
String next_device_code = frontInst.getNext_device_code(); |
|
|
|
Device next_device = deviceAppService.findDeviceByCode(next_device_code); |
|
|
|
if (next_device != null && next_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { |
|
|
|
String getLinkDeviceCode = Optional.ofNullable(next_device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null); |
|
|
|
Instruction backInst = instructionService.findReadyInstByNextDeviceCode(frontInst, getLinkDeviceCode, backNoY); |
|
|
|
if (ObjectUtil.isNotEmpty(getLinkDeviceCode) && deviceAppService.findDeviceByCode(getLinkDeviceCode) != null && ObjectUtil.isNotEmpty(backInst)) { |
|
|
|
this.FBWrite(frontInst, backInst); |
|
|
|
this.unExecutedMessage = null; |
|
|
|
this.requireSuccess = true; |
|
|
|
} else { |
|
|
|
this.frontWrite(frontInst); |
|
|
|
this.unExecutedMessage = null; |
|
|
|
this.requireSuccess = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList"); |
|
|
|
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); |
|
|
|
List<Instruction> backInsts = instructionService.findReadyInstByDeviceCode(getBackDeviceCodeList, backNoY); |
|
|
|
Instruction backInst = null; |
|
|
|
if (CollectionUtil.isNotEmpty(backInsts)) { |
|
|
|
backInst = backInsts.get(0); |
|
|
|
} |
|
|
|
if (ObjectUtil.isNotEmpty(backInst)) { |
|
|
|
String back_start_device_code = backInst.getStart_device_code(); |
|
|
|
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code); |
|
|
|
if (back_start_device != null && back_start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { |
|
|
|
this.backWrite(back_start_device, backInst); |
|
|
|
this.unExecutedMessage = null; |
|
|
|
this.requireSuccess = true; |
|
|
|
} else if (back_start_device != null && back_start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|
|
|
this.backWrite(backInst); |
|
|
|
this.unExecutedMessage = null; |
|
|
|
this.requireSuccess = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.unExecutedMessage = "堆垛机未查询到就绪状态下可执行的任务或指令信息"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 一进一出策略 |
|
|
|
* 根据楼层优先级 |
|
|
@ -1884,9 +1471,34 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList"); |
|
|
|
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); |
|
|
|
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); |
|
|
|
List<Instruction> frontInsts = instructionService.findShallowReadyInstByNextDeviceCode(getFrontDeviceCodeList, frontNoY); |
|
|
|
if (CollectionUtil.isNotEmpty(frontInsts)) { |
|
|
|
frontInst = frontInsts.get(0); |
|
|
|
//先根据优先级和时间顺序查看指令信息
|
|
|
|
List<Instruction> frontInsts = instructionService.findAllInstByPriorityCreateTime(getFrontDeviceCodeList, frontNoY); |
|
|
|
//如果查询到的是浅货位的指令信息,则直接下发
|
|
|
|
if (CollectionUtils.isNotEmpty(frontInsts)) { |
|
|
|
for (Instruction inst : frontInsts) { |
|
|
|
String start_device_code = inst.getStart_device_code(); |
|
|
|
//判断当前库位是深库位还是浅库位
|
|
|
|
int x = Integer.parseInt(getNumericPart(start_device_code)); |
|
|
|
//如果是深库位
|
|
|
|
if (x == 1 || x == 4) { |
|
|
|
//查询对应的浅货位编码
|
|
|
|
String shallStartPointCode = getZdPoint(inst.getStart_point_code()); |
|
|
|
//查询对应的浅库位是否存在就绪的指令信息
|
|
|
|
Instruction shallInst = instructionService.findReadyInstByStartPointCode(shallStartPointCode); |
|
|
|
if (shallInst != null) { |
|
|
|
frontInst = shallInst; |
|
|
|
break; |
|
|
|
} |
|
|
|
//若不存在,则查询是否存在就绪的任务信息
|
|
|
|
TaskDto shallTask = taskService.findReadyByStartPointCode(shallStartPointCode); |
|
|
|
if (shallTask != null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
//如果不存在就绪的指令信息和任务信息,直接结束循环
|
|
|
|
} |
|
|
|
frontInst = inst; |
|
|
|
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); |
|
|
@ -1899,28 +1511,30 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (this.stackerNum == 2) { |
|
|
|
List<Instruction> backInsts = instructionService.findShallowReadyInstByNextDeviceCode(getBackDeviceCodeList, backNoY); |
|
|
|
if (CollectionUtil.isNotEmpty(backInsts)) { |
|
|
|
backInst = backInsts.get(0); |
|
|
|
} else { |
|
|
|
frontInsts = instructionService.findDeepReadyInstByNextDeviceCode(getFrontDeviceCodeList, frontNoY); |
|
|
|
if (CollectionUtil.isNotEmpty(frontInsts)) { |
|
|
|
frontInst = frontInsts.get(0); |
|
|
|
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"); |
|
|
|
if (StrUtil.isNotEmpty(getLinkDeviceCode)) { |
|
|
|
backInst = instructionService.findDeepReadyInstByNextDeviceCode(frontInst, getLinkDeviceCode, backNoY, getBackDeviceCodeList); |
|
|
|
} |
|
|
|
List<Instruction> backInsts = instructionService.findAllInstByPriorityCreateTime(getBackDeviceCodeList, backNoY); |
|
|
|
if (CollectionUtils.isNotEmpty(backInsts)) { |
|
|
|
for (Instruction inst : backInsts) { |
|
|
|
String start_device_code = inst.getStart_device_code(); |
|
|
|
//判断当前库位是深库位还是浅库位
|
|
|
|
int x = Integer.parseInt(getNumericPart(start_device_code)); |
|
|
|
//如果是深库位
|
|
|
|
if (x == 1 || x == 4) { |
|
|
|
//查询对应的浅货位编码
|
|
|
|
String shallStartPointCode = getZdPoint(inst.getStart_point_code()); |
|
|
|
//查询对应的浅库位是否存在就绪的指令信息
|
|
|
|
Instruction shallInst = instructionService.findReadyInstByStartPointCode(shallStartPointCode); |
|
|
|
if (shallInst != null) { |
|
|
|
backInst = shallInst; |
|
|
|
break; |
|
|
|
} |
|
|
|
//若不存在,则查询是否存在就绪的任务信息
|
|
|
|
TaskDto shallTask = taskService.findReadyByStartPointCode(shallStartPointCode); |
|
|
|
if (shallTask != null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
backInsts = instructionService.findDeepReadyInstByNextDeviceCode(getBackDeviceCodeList, backNoY); |
|
|
|
if (CollectionUtil.isNotEmpty(backInsts)) { |
|
|
|
backInst = backInsts.get(0); |
|
|
|
} |
|
|
|
backInst = inst; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2208,7 +1822,6 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
Device front_device = deviceAppService.findDeviceByCode(front_start_device_code); |
|
|
|
Device back_device = deviceAppService.findDeviceByCode(back_start_device_code); |
|
|
|
String back_device_code = this.handExtraStringValue(front_device, "getLinkDeviceCode"); |
|
|
|
|
|
|
|
if (instanceStorage(front_device) && instanceStorage(back_device)) { |
|
|
|
String front_from_x = frontInst.getFrom_x(); |
|
|
|
String front_from_y = frontInst.getFrom_y(); |
|
|
@ -2334,6 +1947,11 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
this.requireSuccess = true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isErrorTimeValid(long errorCurrentTimeMillis) { |
|
|
|
return errorCurrentTimeMillis - this.errorRequireTime >= this.errorRequireTimeOut; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 满入 |
|
|
|
*/ |
|
|
@ -2369,6 +1987,23 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
} |
|
|
|
this.againRequireSuccess = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (isErrorTimeValid(currentTimeMillis)) { |
|
|
|
this.errorRequireTime = currentTimeMillis; |
|
|
|
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) |
|
|
|
.map(notify -> notify.getValue()) |
|
|
|
.orElse("0"); |
|
|
|
if (notifyValue.equals("1")) { |
|
|
|
JSONObject dataParam = new JSONObject(); |
|
|
|
dataParam.put("msg", "堆垛机满入申请重新分配库位失败! 请求参数: " + request + "响应信息: " + response.getMessage()); |
|
|
|
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder() |
|
|
|
.service("ErrorInfo") |
|
|
|
.type("1") |
|
|
|
.data(dataParam) |
|
|
|
.build(); |
|
|
|
acsToWmsService.apply(requestParam); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2400,6 +2035,23 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
instructionService.cancelInstAndTask(inst.getInstruction_id()); |
|
|
|
this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_FIVE.getSignalNum()); |
|
|
|
this.againRequireSuccess = true; |
|
|
|
} else { |
|
|
|
if (isErrorTimeValid(currentTimeMillis)) { |
|
|
|
this.errorRequireTime = currentTimeMillis; |
|
|
|
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) |
|
|
|
.map(notify -> notify.getValue()) |
|
|
|
.orElse("0"); |
|
|
|
if (notifyValue.equals("1")) { |
|
|
|
JSONObject dataParam = new JSONObject(); |
|
|
|
dataParam.put("msg", "堆垛机空出反馈WMS失败! 请求参数: " + request + "响应信息: " + response.getMessage()); |
|
|
|
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder() |
|
|
|
.service("ErrorInfo") |
|
|
|
.type("1") |
|
|
|
.data(dataParam) |
|
|
|
.build(); |
|
|
|
acsToWmsService.apply(requestParam); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2441,6 +2093,23 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
} |
|
|
|
this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_FIVE.getSignalNum()); |
|
|
|
this.againRequireSuccess = true; |
|
|
|
} else { |
|
|
|
if (isErrorTimeValid(currentTimeMillis)) { |
|
|
|
this.errorRequireTime = currentTimeMillis; |
|
|
|
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) |
|
|
|
.map(notify -> notify.getValue()) |
|
|
|
.orElse("0"); |
|
|
|
if (notifyValue.equals("1")) { |
|
|
|
JSONObject dataParam = new JSONObject(); |
|
|
|
dataParam.put("msg", "堆垛机取货时浅货位有货反馈WMS失败! 请求参数: " + request + "响应信息: " + response.getMessage()); |
|
|
|
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder() |
|
|
|
.service("ErrorInfo") |
|
|
|
.type("1") |
|
|
|
.data(dataParam) |
|
|
|
.build(); |
|
|
|
acsToWmsService.apply(requestParam); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2497,6 +2166,23 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
} |
|
|
|
} |
|
|
|
this.againRequireSuccess = true; |
|
|
|
} else { |
|
|
|
if (isErrorTimeValid(currentTimeMillis)) { |
|
|
|
this.errorRequireTime = currentTimeMillis; |
|
|
|
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) |
|
|
|
.map(notify -> notify.getValue()) |
|
|
|
.orElse("0"); |
|
|
|
if (notifyValue.equals("1")) { |
|
|
|
JSONObject dataParam = new JSONObject(); |
|
|
|
dataParam.put("msg", "堆垛机放货时浅货位有货申请重新分配库位失败! 请求参数: " + request + "响应信息: " + response.getMessage()); |
|
|
|
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder() |
|
|
|
.service("ErrorInfo") |
|
|
|
.type("1") |
|
|
|
.data(dataParam) |
|
|
|
.build(); |
|
|
|
acsToWmsService.apply(requestParam); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2603,4 +2289,178 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme |
|
|
|
instdto.setInstruction_type(taskDto.getTask_type()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 出库时,后叉取货完成,下发前叉取/后叉放货信息 |
|
|
|
* |
|
|
|
* @param back_next_device |
|
|
|
* @param frontInst |
|
|
|
* @param getFrontDeviceCodeList |
|
|
|
*/ |
|
|
|
private void backGetFinish(Device back_next_device, Instruction frontInst, Instruction backInst, List<String> getFrontDeviceCodeList) { |
|
|
|
List<String> xDeviceCodeList = this.getExtraDeviceCodes("xDeviceCodeList"); |
|
|
|
String getLinkDeviceCode = this.handExtraStringValue(back_next_device, "getLinkDeviceCode"); |
|
|
|
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); |
|
|
|
if (ObjectUtil.isEmpty(frontInst)) { |
|
|
|
//前叉无货,后叉有货,前叉无指令信息,后叉有指令信息
|
|
|
|
//根据后叉关联点位,按照优先级、创建时间去查询前叉指令信息
|
|
|
|
List<Instruction> frontInsts = instructionService.findAllInstByPriorityCreateTime(getLinkDeviceCode, getFrontDeviceCodeList, frontNoY); |
|
|
|
//遍历前叉指令信息,判断前叉指令起点是深库位还是浅库位
|
|
|
|
if (CollectionUtils.isNotEmpty(frontInsts)) { |
|
|
|
for (Instruction inst : frontInsts) { |
|
|
|
String start_device_code = inst.getStart_device_code(); |
|
|
|
//判断当前库位是深库位还是浅库位
|
|
|
|
int x = Integer.parseInt(getNumericPart(start_device_code)); |
|
|
|
//如果是深库位
|
|
|
|
if (x == 1 || x == 4) { |
|
|
|
//查询对应的浅货位编码
|
|
|
|
String shallStartPointCode = getZdPoint(inst.getStart_point_code()); |
|
|
|
//查询对应的浅库位是否存在就绪的指令信息
|
|
|
|
Instruction shallInst = instructionService.findReadyInstByStartPointCode(shallStartPointCode); |
|
|
|
if (shallInst != null) { |
|
|
|
//判断该就绪的指令信息是否是堆垛机库内移库指令信息
|
|
|
|
String next_device_code = shallInst.getNext_device_code(); |
|
|
|
if (xDeviceCodeList.contains(next_device_code)) { |
|
|
|
Set<String> currentNoY = frontNoY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(frontNoY.split(","))); |
|
|
|
//如果是的话,判断终点是否前叉可达的,
|
|
|
|
if (!currentNoY.contains(String.valueOf(Integer.parseInt(shallInst.getFrom_y())))) { |
|
|
|
// 如果前叉可达,则下发前叉移库指令的取货信息 break;
|
|
|
|
this.frontWrite(shallInst); |
|
|
|
break; |
|
|
|
} |
|
|
|
// 否则直接下发后叉放货信息 break
|
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
break; |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
//若不存在,则查询是否存在就绪的任务信息
|
|
|
|
TaskDto shallTask = taskService.findReadyByStartPointCode(shallStartPointCode); |
|
|
|
if (shallTask != null) { |
|
|
|
//判断该就绪的任务信息是否是堆垛机库内移库任务信息
|
|
|
|
String next_device_code = shallTask.getNext_device_code(); |
|
|
|
if (xDeviceCodeList.contains(next_device_code)) { |
|
|
|
Set<String> currentNoY = frontNoY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(frontNoY.split(","))); |
|
|
|
//如果是的话,判断终点是否前叉可达的,
|
|
|
|
if (!currentNoY.contains(String.valueOf(Integer.parseInt(shallTask.getFrom_y())))) { |
|
|
|
// 如果前叉可达,则创建移库指令,并下发前叉移库指令的取货信息 break;
|
|
|
|
frontInst = new Instruction(); |
|
|
|
setInstruction(frontInst, shallTask); |
|
|
|
try { |
|
|
|
instructionService.create(frontInst); |
|
|
|
shallTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); |
|
|
|
taskService.update(shallTask); |
|
|
|
} catch (Exception e) { |
|
|
|
this.unExecutedMessage = "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage(); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage())); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// 否则直接下发后叉放货信息 break
|
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
break; |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
frontInst = inst; |
|
|
|
this.frontWrite(frontInst); |
|
|
|
//直接下发前叉取货信息
|
|
|
|
break; |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(null, backInst); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 出库时,前叉取货完成,下发后叉取/前叉放货信息 |
|
|
|
* |
|
|
|
* @param front_next_device |
|
|
|
* @param frontInst |
|
|
|
* @param backInst |
|
|
|
* @param getBackDeviceCodeList |
|
|
|
*/ |
|
|
|
private void frontGetFinish(Device front_next_device, Instruction frontInst, Instruction backInst, List<String> getBackDeviceCodeList) { |
|
|
|
List<String> xDeviceCodeList = this.getExtraDeviceCodes("xDeviceCodeList"); |
|
|
|
String getLinkDeviceCode = this.handExtraStringValue(front_next_device, "getLinkDeviceCode"); |
|
|
|
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); |
|
|
|
if (ObjectUtil.isEmpty(backInst)) { |
|
|
|
//根据后叉关联点位,按照优先级、创建时间去查询后叉指令信息
|
|
|
|
List<Instruction> backInsts = instructionService.findAllInstByPriorityCreateTime(getLinkDeviceCode, getBackDeviceCodeList, backNoY); |
|
|
|
//遍历后叉指令信息,判断后叉指令起点是深库位还是浅库位
|
|
|
|
if (CollectionUtils.isNotEmpty(backInsts)) { |
|
|
|
for (Instruction inst : backInsts) { |
|
|
|
String start_device_code = inst.getStart_device_code(); |
|
|
|
//判断当前库位是深库位还是浅库位
|
|
|
|
int x = Integer.parseInt(getNumericPart(start_device_code)); |
|
|
|
//如果是深库位
|
|
|
|
if (x == 1 || x == 4) { |
|
|
|
//查询对应的浅货位编码
|
|
|
|
String shallStartPointCode = getZdPoint(inst.getStart_point_code()); |
|
|
|
//查询对应的浅库位是否存在就绪的指令信息
|
|
|
|
Instruction shallInst = instructionService.findReadyInstByStartPointCode(shallStartPointCode); |
|
|
|
if (shallInst != null) { |
|
|
|
//判断该就绪的指令信息是否是堆垛机库内移库指令信息
|
|
|
|
String next_device_code = shallInst.getNext_device_code(); |
|
|
|
if (xDeviceCodeList.contains(next_device_code)) { |
|
|
|
Set<String> currentNoY = backNoY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(backNoY.split(","))); |
|
|
|
//如果是的话,判断终点是否后叉可达的,
|
|
|
|
if (!currentNoY.contains(String.valueOf(Integer.parseInt(shallInst.getFrom_y())))) { |
|
|
|
// 如果后叉可达,则下发后叉移库指令的取货信息 break;
|
|
|
|
this.backWrite(shallInst); |
|
|
|
break; |
|
|
|
} |
|
|
|
// 否则直接下发前叉放货信息 break
|
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
break; |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
//若不存在,则查询是否存在就绪的任务信息
|
|
|
|
TaskDto shallTask = taskService.findReadyByStartPointCode(shallStartPointCode); |
|
|
|
if (shallTask != null) { |
|
|
|
//判断该就绪的任务信息是否是堆垛机库内移库任务信息
|
|
|
|
String next_device_code = shallTask.getNext_device_code(); |
|
|
|
if (xDeviceCodeList.contains(next_device_code)) { |
|
|
|
Set<String> currentNoY = backNoY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(backNoY.split(","))); |
|
|
|
//如果是的话,判断终点是否后叉可达的,
|
|
|
|
if (!currentNoY.contains(String.valueOf(Integer.parseInt(shallTask.getFrom_y())))) { |
|
|
|
// 如果后叉可达,则创建移库指令,并下发后叉移库指令的取货信息 break;
|
|
|
|
backInst = new Instruction(); |
|
|
|
setInstruction(backInst, shallTask); |
|
|
|
try { |
|
|
|
instructionService.create(backInst); |
|
|
|
shallTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); |
|
|
|
taskService.update(shallTask); |
|
|
|
} catch (Exception e) { |
|
|
|
this.unExecutedMessage = "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage(); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage())); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// 否则直接下发前叉放货信息 break
|
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
break; |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
//直接下发后叉取货信息
|
|
|
|
backInst = inst; |
|
|
|
this.backWrite(backInst); |
|
|
|
break; |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.sendPutInfoToPlc(frontInst, null); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |