fix: 堆垛机异常情况开发

This commit is contained in:
2024-05-07 13:32:29 +08:00
parent d4c9e471ce
commit 1b9d943c1e
3 changed files with 130 additions and 73 deletions

View File

@@ -24,6 +24,7 @@ import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
@@ -323,7 +324,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
storage_cache = this.itemProtocol.getItem_storage_cache();
if (!command.equals(last_command)){
requireSucess=true;
requireSucess=false;
if (command==0){
clearWrite();
}
@@ -362,59 +363,36 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
count = 0;
}
if (mode != 3 && requireSucess) {
message = "one_message7";
} else if (error != 0) {
message = "universal_message3";
//指定库位满入
if (error == 5 && count< WcsConfig.stacker_error_in_count) {
//相同任务时限制加一
if (Objects.equals(task, last_task)){
count++;
}
applyUpdatePointCode(StandarStirageErroEnum.FILL.getType());
}
//空出
if (error == 6) {
applyUpdatePointCode(StandarStirageErroEnum.VOIDANCE.getType());
}
//浅货位有货
if (error == 16) {
//放货
if (cargoMove == 1 && count< WcsConfig.stacker_error_in_count) {
//相同任务时限制加一
if (Objects.equals(task, last_task)){
count++;
}
applyUpdatePointCode(StandarStirageErroEnum.BLOCK_OUT.getType());
} else if (cargoMove == 0) {
//取货
applyUpdatePointCode(StandarStirageErroEnum.BLOCK_IN.getType());
}
}
} else {
if (error != 0) {
//满入空出或者浅货位阻挡
erroBlock();
}
List list = new ArrayList();
switch (command) {
case 0:
if (updateCommand("0")) break;
boolean b = applyTask();
if (b) {
requireSucess = true;
requireSucess = false;
}
break;
case 1:
message = "universal_delivery";
if (updateCommand("1")) break;
break;
case 2:
message = "universal_completed";
Instruction instruction = checkInst();
if (ObjectUtil.isEmpty(instruction)) {
if (updateCommand("2")) break;
Instruction instruction2 = checkInst();
if (ObjectUtil.isEmpty(instruction2)) {
message = "universal_message4";
break;
}
String next_device_code = instruction.getNext_device_code();
String next_device_code = instruction2.getNext_device_code();
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.conveyor.name())) {
if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("z"))) {
@@ -464,13 +442,15 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
map4.put("code", "to_command");
map4.put("value", 2);
list.add(map4);
requireSucess = true;
requireSucess = false;
break;
case 3:
message = "universal_releasing";
if (updateCommand("3")) break;
break;
case 4:
message = "one_message1";
if (updateCommand("4")) break;
Instruction instruction1 = checkInst();
String next_device_code1 = instruction1.getNext_device_code();
Device nextDevice1 = deviceAppService.findDeviceByCode(next_device_code1);
@@ -490,10 +470,11 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
map.put("value", 4);
list.add(map);
}
requireSucess = true;
requireSucess = false;
break;
case 5:
message = "universal_releasing_completed";
if (updateCommand("5")) break;
Map<String, Object> map = new HashMap<>();
map.put("code", "to_command");
map.put("value", 11);
@@ -504,35 +485,38 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
} catch (Exception e) {
e.printStackTrace();
}
requireSucess = true;
requireSucess = false;
break;
case 6:
message = "one_message2";
if (updateCommand("6")) break;
Map<String, Object> map1 = new HashMap<>();
map1.put("code", "to_command");
map1.put("value", 6);
list.add(map1);
requireSucess = true;
requireSucess = false;
break;
case 7:
message = "one_message3";
if (updateCommand("7")) break;
Map<String, Object> map2 = new HashMap<>();
map2.put("code", "to_command");
map2.put("value", 7);
list.add(map2);
requireSucess = true;
requireSucess = false;
break;
case 8:
message = "one_message4";
if (updateCommand("8")) break;
Map<String, Object> map3 = new HashMap<>();
map3.put("code", "to_command");
map3.put("value", 8);
list.add(map3);
requireSucess = true;
requireSucess = false;
break;
default:
message = "one_message5";
requireSucess = true;
requireSucess = false;
break;
}
if (list.size() != 0) {
@@ -576,6 +560,71 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
last_fork_runingTimes = fork_runingTimes;*/
}
private boolean updateCommand(String toCommand) {
Instruction instruction0 = checkInst();
if (ObjectUtil.isEmpty(instruction0)) {
message = "universal_message4";
return true;
}
instruction0.setExecute_code(toCommand);
instructionService.update(instruction0);
return false;
}
private void erroBlock() {
message = "universal_message3";
//指定库位满入
if (error == 5 && count< WcsConfig.stacker_error_in_count) {
//清警
cleanErro();
//相同任务时限制加一
if (Objects.equals(task, last_task)){
count++;
}
applyUpdatePointCode(StandarStirageErroEnum.FILL.getType());
}
//空出直接完结指令
if (error == 6) {
//清警
cleanErro();
Instruction instruction = checkInst();
try {
finish_instruction(instruction);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
//浅货位有货
if (error == 16) {
//清警
cleanErro();
//放货
if (cargoMove == 1 && count< WcsConfig.stacker_error_in_count) {
//相同任务时限制加一
if (Objects.equals(task, last_task)){
count++;
}
applyUpdatePointCode(StandarStirageErroEnum.BLOCK_OUT.getType());
} else if (cargoMove == 0) {
//取货
applyUpdatePointCode(StandarStirageErroEnum.BLOCK_IN.getType());
}
}
}
private void cleanErro() {
List list = new ArrayList();
HashMap map = new HashMap();
map.put("code","to_command");
map.put("value","5");
list.add(map);
writing(list);
}
/**
* 申请更新点位
*
@@ -612,15 +661,15 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (ObjectUtil.isEmpty(point)) {
message = "one_message18";
}
if (type.equals(StandarStirageErroEnum.VOIDANCE.getType())) {
updateData1(poinCode, instruction, point, split);
List list = new ArrayList();
pakageData(list, point, split);
}
if (type.equals(StandarStirageErroEnum.BLOCK_IN.getType()) || type.equals(StandarStirageErroEnum.FILL.getType())) {
updateData2(poinCode, instruction, point, split);
task = task*1000;
updateData2(poinCode, instruction, point, split,task);
List list = new ArrayList();
pakageData(list, point, split);
String x = point.getExtraValue().get("x").toString();
String y = split[1];
String z = split[2];
pakagePLCData(list, x,y,z,"2",task);
}
}
//取货潜货位阻挡做完移库任务
@@ -648,10 +697,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
private void pakageData(List list, Device point, String[] split) {
String x = point.getExtraValue().get("x").toString();
String y = split[1];
String z = split[2];
private void pakagePLCData(List list, String x, String y, String z, String toCommand, Integer task) {
HashMap map1 = new HashMap();
map1.put("code", "to_x");
map1.put("value", y);
@@ -664,11 +710,20 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
map3.put("code", "to_z");
map3.put("value", x);
list.add(map3);
HashMap map4 = new HashMap();
map4.put("code", "to_task");
map4.put("value", task);
list.add(map4);
HashMap map5 = new HashMap();
map5.put("code", "to_command");
map5.put("value", toCommand);
list.add(map5);
if (ObjectUtil.isNotEmpty(list)) {
this.writing(list);
}
}
public void clearWrite() {
List list = new ArrayList<>();
Map map = new HashMap<>();
@@ -696,11 +751,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
message=null;
}
private void updateData2(String poinCode, Instruction instruction, Device point, String[] split) {
private void updateData2(String poinCode, Instruction instruction, Device point, String[] split, Integer task) {
Instruction instructionUpdate = checkInst();
TaskDto taskUpdate = new TaskDto();
instructionUpdate.setNext_point_code(poinCode);
instructionUpdate.setNext_device_code(split[0]);
instructionUpdate.setInstruction_code(String.valueOf(task));
taskUpdate.setNext_point_code(poinCode);
taskUpdate.setNext_device_code(split[0]);
taskUpdate.setTask_id(instructionUpdate.getTask_id());
@@ -709,19 +765,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
taskserver.update(taskUpdate);
}
private void updateData1(String poinCode, Instruction instruction, Device point, String[] split) {
Instruction instructionUpdate = checkInst();
TaskDto taskUpdate = new TaskDto();
instructionUpdate.setStart_point_code(poinCode);
instructionUpdate.setStart_device_code(split[0]);
taskUpdate.setStart_point_code(poinCode);
taskUpdate.setStart_device_code(split[0]);
taskUpdate.setTask_id(instructionUpdate.getTask_id());
pakageData1(instruction, instructionUpdate, point, split, taskUpdate);
//更新缓存数据库
instructionService.update(instructionUpdate);
taskserver.update(taskUpdate);
}
private void pakageData1(Instruction instruction, Instruction instructionUpdate, Device starPoint, String[] split, TaskDto taskUpdate) {
instructionUpdate.setFrom_x(starPoint.getExtraValue().get("x").toString());
@@ -759,6 +803,14 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
//维修解警后重新向堆垛机下发指令
Instruction instructionErro = checkInst();
if (InstructionStatusEnum.BUSY.getIndex().equals(instructionErro.getInstruction_status())){
List list = new ArrayList();
pakagePLCData(list, String.valueOf(x),String.valueOf(y),String.valueOf(z),instructionErro.getExecute_code(),task);
return true;
}
this.instruction_require_time = date;
//输入:指令类型多种\ 指令状态多种\
Instruction instruction1 = new Instruction();
@@ -813,7 +865,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
List list = new ArrayList();
pakageCommand(list, inst.getInstruction_code());
pakageCommand(list,"1", inst.getInstruction_code());
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) {
if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("z"))) {
HashMap map4 = new HashMap();
@@ -869,14 +921,14 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
list.add(map7);
}
private void pakageCommand(List list, String inst) {
private void pakageCommand(List list, String toCommand,String inst) {
HashMap map1 = new HashMap();
map1.put("code", "to_device_code");
map1.put("value", this.getDevice().getAddress());
list.add(map1);
HashMap map2 = new HashMap();
map2.put("code", "to_command");
map2.put("value", 1);
map2.put("value", toCommand);
list.add(map2);
HashMap map3 = new HashMap();
map3.put("code", "to_task");

View File

@@ -364,4 +364,9 @@ public class InstructionDto implements Serializable {
*/
private String to_device_code;
/**
*
*/
// private String to_device_code;
}

View File

@@ -122,7 +122,7 @@ public class CreateDDJInst {
standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver();
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("one_message7");
((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("堆垛机,{}未联机或者在执行中");
return;
}
}
@@ -149,7 +149,7 @@ public class CreateDDJInst {
standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver();
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getForkCargo() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("one_message7");
((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("堆垛机,{}未联机或者在执行中");
return;
}
}