opt: 优化定时任务创建堆垛机出库指令
This commit is contained in:
@@ -416,9 +416,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
HashMap map = new HashMap();
|
HashMap map = new HashMap();
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 0:
|
case 0:
|
||||||
if (task == 0) {
|
|
||||||
applyTask();
|
applyTask();
|
||||||
}
|
|
||||||
requireSucess = true;
|
requireSucess = true;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -568,7 +566,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
//输入:指令类型多种\ 指令状态多种\
|
//输入:指令类型多种\ 指令状态多种\
|
||||||
Instruction instruction1 = new Instruction();
|
Instruction instruction1 = new Instruction();
|
||||||
instruction1.setInstruction_status("0");
|
instruction1.setInstruction_status("0");
|
||||||
List<Instruction> instructions = instructionService.findByDeviceCodes(instruction1);
|
List<Instruction> instructions = instructionService.findByDeviceCodes(instruction1, false);
|
||||||
if (CollUtil.isEmpty(instructions) || instructions.size() < 1) {
|
if (CollUtil.isEmpty(instructions) || instructions.size() < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -637,14 +635,14 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) {
|
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) {
|
||||||
map.put("to_z", inst.getFrom_z());
|
map.put("to_y", inst.getFrom_z());
|
||||||
if (inst.getFrom_x().length() > 1) {
|
if (inst.getFrom_x().length() > 1) {
|
||||||
String substring = inst.getFrom_x().substring(1);
|
String substring = inst.getFrom_x().substring(1);
|
||||||
map.put("to_x", substring);
|
map.put("to_z", substring);
|
||||||
} else {
|
} else {
|
||||||
map.put("to_x", inst.getFrom_x());
|
map.put("to_z", inst.getFrom_x());
|
||||||
}
|
}
|
||||||
map.put("to_y", inst.getFrom_y());
|
map.put("to_x", inst.getFrom_y());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.writing(map);
|
this.writing(map);
|
||||||
|
|||||||
@@ -321,5 +321,5 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
|
|||||||
* @param instruction1
|
* @param instruction1
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Instruction> findByDeviceCodes(Instruction instruction1);
|
List<Instruction> findByDeviceCodes(Instruction instruction1,Boolean flay);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1569,12 +1569,16 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instruction> findByDeviceCodes(Instruction instruction1) {
|
public List<Instruction> findByDeviceCodes(Instruction instruction1, Boolean flay) {
|
||||||
if (ObjectUtil.isNull(instruction1)) {
|
if (ObjectUtil.isNull(instruction1)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<InstructionMybatis> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<InstructionMybatis> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (flay) {
|
||||||
|
wrapper.le(StrUtil.isNotBlank(instruction1.getInstruction_status()), InstructionMybatis::getInstruction_status, instruction1.getInstruction_status());
|
||||||
|
} else {
|
||||||
wrapper.eq(StrUtil.isNotBlank(instruction1.getInstruction_status()), InstructionMybatis::getInstruction_status, instruction1.getInstruction_status());
|
wrapper.eq(StrUtil.isNotBlank(instruction1.getInstruction_status()), InstructionMybatis::getInstruction_status, instruction1.getInstruction_status());
|
||||||
|
}
|
||||||
wrapper.eq(StrUtil.isNotBlank(instruction1.getStart_device_code()), InstructionMybatis::getStart_device_code, instruction1.getStart_device_code());
|
wrapper.eq(StrUtil.isNotBlank(instruction1.getStart_device_code()), InstructionMybatis::getStart_device_code, instruction1.getStart_device_code());
|
||||||
wrapper.eq(StrUtil.isNotBlank(instruction1.getNext_device_code()), InstructionMybatis::getNext_device_code, instruction1.getNext_device_code());
|
wrapper.eq(StrUtil.isNotBlank(instruction1.getNext_device_code()), InstructionMybatis::getNext_device_code, instruction1.getNext_device_code());
|
||||||
List<InstructionMybatis> instructionMybatis = instructionMapper.selectList(wrapper);
|
List<InstructionMybatis> instructionMybatis = instructionMapper.selectList(wrapper);
|
||||||
|
|||||||
@@ -225,5 +225,10 @@ public interface RouteLineService extends CommonService<RouteLine> {
|
|||||||
|
|
||||||
public JSONArray getActivePathLine(String device_code, String next_device_code, String plan_code);
|
public JSONArray getActivePathLine(String device_code, String next_device_code, String plan_code);
|
||||||
|
|
||||||
List<RouteLineDto> selectDeviceCodeList(String start_device_code);
|
/**
|
||||||
|
* 根据设备编码查询路由
|
||||||
|
* @param device_code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<RouteLineDto> selectDeviceCodeList(String device_code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取未完成任务
|
* 获取未完成任务
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -664,9 +665,18 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
|||||||
Device nextdevice = appService.findDeviceByCode(next_device_code);
|
Device nextdevice = appService.findDeviceByCode(next_device_code);
|
||||||
Device startdevice = appService.findDeviceByCode(start_device_code);
|
Device startdevice = appService.findDeviceByCode(start_device_code);
|
||||||
dto.setMaterial(startdevice.getMaterial_type());
|
dto.setMaterial(startdevice.getMaterial_type());
|
||||||
|
if (StrUtil.equals(DeviceType.storage.toString(), startDeviceType)) {
|
||||||
|
start_point_code = start_device_code + "-" + dto.getFrom_y() + "-" + dto.getFrom_z();
|
||||||
|
dto.setStart_point_code(start_point_code);
|
||||||
|
}
|
||||||
|
if (StrUtil.equals(DeviceType.storage.toString(), nextDeviceType)) {
|
||||||
|
next_point_code = next_device_code + "-" + dto.getTo_y() + "-" + dto.getTo_z();
|
||||||
|
dto.setNext_point_code(next_point_code);
|
||||||
|
}
|
||||||
if (StrUtil.equals(createTaskCheck, "1")) {
|
if (StrUtil.equals(createTaskCheck, "1")) {
|
||||||
// 判断起点为输送设备
|
// 判断起点为输送设备
|
||||||
if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {
|
if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) {
|
if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) {
|
||||||
@@ -1527,8 +1537,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
|||||||
task.setStart_point_code(start_point_code + "-" + from_y + "-" + from_z);
|
task.setStart_point_code(start_point_code + "-" + from_y + "-" + from_z);
|
||||||
task.setStart_device_code(start_point_code);
|
task.setStart_device_code(start_point_code);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
task.setStart_device_code(start_point_code);
|
task.setStart_device_code(start_point_code);
|
||||||
task.setStart_device_code(start_point_code);
|
task.setStart_device_code(start_point_code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
package org.nl.system.service.quartz.task;
|
package org.nl.system.service.quartz.task;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.nl.acs.device.domain.Device;
|
||||||
|
import org.nl.acs.device.domain.DeviceExtra;
|
||||||
|
import org.nl.acs.device.enums.DeviceType;
|
||||||
|
import org.nl.acs.device.service.DeviceExtraService;
|
||||||
|
import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
|
||||||
|
import org.nl.acs.device_driver.basedriver.belt_conveyor.BeltConveyorDeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.basedriver.standard_stacker.StandardStackerDeviceDriver;
|
||||||
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.instruction.domain.Instruction;
|
import org.nl.acs.instruction.domain.Instruction;
|
||||||
@@ -12,13 +21,17 @@ import org.nl.acs.opc.DeviceAppService;
|
|||||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||||
import org.nl.acs.route.service.RouteLineService;
|
import org.nl.acs.route.service.RouteLineService;
|
||||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||||
|
import org.nl.acs.task.domain.Task;
|
||||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||||
import org.nl.acs.task.service.TaskService;
|
import org.nl.acs.task.service.TaskService;
|
||||||
import org.nl.acs.task.service.dto.TaskDto;
|
import org.nl.acs.task.service.dto.TaskDto;
|
||||||
|
import org.nl.common.exception.BadRequestException;
|
||||||
import org.nl.config.SpringContextHolder;
|
import org.nl.config.SpringContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,352 @@
|
|||||||
|
package org.nl.system.service.quartz.task;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.nl.acs.device.domain.Device;
|
||||||
|
import org.nl.acs.device.domain.DeviceExtra;
|
||||||
|
import org.nl.acs.device.enums.DeviceType;
|
||||||
|
import org.nl.acs.device.service.DeviceExtraService;
|
||||||
|
import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
|
||||||
|
import org.nl.acs.device_driver.basedriver.belt_conveyor.BeltConveyorDeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.basedriver.standard_stacker.StandardStackerDeviceDriver;
|
||||||
|
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.opc.DeviceAppService;
|
||||||
|
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||||
|
import org.nl.acs.route.service.RouteLineService;
|
||||||
|
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||||
|
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||||
|
import org.nl.acs.task.service.TaskService;
|
||||||
|
import org.nl.acs.task.service.dto.TaskDto;
|
||||||
|
import org.nl.common.exception.BadRequestException;
|
||||||
|
import org.nl.config.SpringContextHolder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class CreateDDJInst {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时查询堆垛机任务
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
|
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||||
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||||
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||||
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||||
|
DeviceExtraService deviceExtra = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
|
||||||
|
List<TaskDto> taskDtos = taskserver.queryByStauts("0");
|
||||||
|
List<TaskDto> taskDtoList = new ArrayList<>();
|
||||||
|
if (CollUtil.isEmpty(taskDtos) || taskDtos.size() < 1) {
|
||||||
|
} else {
|
||||||
|
for (TaskDto taskDto : taskDtos) {
|
||||||
|
String start_device_code = taskDto.getStart_device_code();
|
||||||
|
Device startDevice = appService.findDeviceByCode(start_device_code);
|
||||||
|
String next_device_code = taskDto.getNext_device_code();
|
||||||
|
Device nextDevice = appService.findDeviceByCode(next_device_code);
|
||||||
|
if (startDevice.getDevice_type().equals(DeviceType.storage.name()) &&
|
||||||
|
(nextDevice.getDevice_type().equals(DeviceType.conveyor.name()) || nextDevice.getDevice_type().equals(DeviceType.storage.name()))) {
|
||||||
|
taskDtoList.add(taskDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(taskDtoList)) {
|
||||||
|
taskDtoList = sortInst(taskDtoList);
|
||||||
|
for (TaskDto taskDto : taskDtoList) {
|
||||||
|
List<RouteLineDto> list =
|
||||||
|
routeLineService.getShortPathLines(
|
||||||
|
taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code());
|
||||||
|
if (ObjectUtils.isEmpty(list)) {
|
||||||
|
throw new BadRequestException("路由不通");
|
||||||
|
}
|
||||||
|
RouteLineDto routeLineDto = (RouteLineDto) list.get(0);
|
||||||
|
String[] path = routeLineDto.getPath().split("->");
|
||||||
|
List<String> pathlist = Arrays.asList(path);
|
||||||
|
if (pathlist.size() < 3 || pathlist.get(1).equals(DeviceType.stacker.name())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Device deviceByCode = appService.findDeviceByCode(pathlist.get(1));
|
||||||
|
if (ObjectUtils.isEmpty(deviceByCode)) {
|
||||||
|
log.error("没有找到DDJ设备");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StandardStackerDeviceDriver standardStackerDeviceDriver;
|
||||||
|
if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) {
|
||||||
|
standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver();
|
||||||
|
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
|
||||||
|
log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String next_device_code = taskDto.getNext_device_code();
|
||||||
|
Device nextDevice = appService.findDeviceByCode(next_device_code);
|
||||||
|
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
|
||||||
|
if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||||
|
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
|
||||||
|
if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
|
||||||
|
log.error("输送机,{}未联机或执行中", next_device_code);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String taskid = taskDto.getTask_id();
|
||||||
|
String taskcode = taskDto.getTask_code();
|
||||||
|
String task_type = taskDto.getTask_type();
|
||||||
|
String vehiclecode = taskDto.getVehicle_code();
|
||||||
|
String storage_task_type = taskDto.getStorage_task_type();
|
||||||
|
String priority = taskDto.getPriority();
|
||||||
|
String is_send = taskDto.getIs_send();
|
||||||
|
|
||||||
|
String start_device_code = taskDto.getStart_device_code();
|
||||||
|
Device startDevice = appService.findDeviceByCode(start_device_code);
|
||||||
|
String start_point_code = taskDto.getStart_point_code();
|
||||||
|
|
||||||
|
String put_device_code = taskDto.getPut_device_code();
|
||||||
|
String put_point_code = taskDto.getPut_point_code();
|
||||||
|
|
||||||
|
String next_point_code = taskDto.getNext_point_code();
|
||||||
|
|
||||||
|
String start_point_code2 = taskDto.getStart_point_code2();
|
||||||
|
String start_device_code2 = taskDto.getStart_device_code2();
|
||||||
|
|
||||||
|
String next_point_code2 = taskDto.getNext_point_code2();
|
||||||
|
String next_device_code2 = taskDto.getNext_device_code2();
|
||||||
|
|
||||||
|
String route_plan_code = taskDto.getRoute_plan_code();
|
||||||
|
String vehicleType = taskDto.getVehicle_type();
|
||||||
|
String agv_system_type = taskDto.getAgv_system_type();
|
||||||
|
|
||||||
|
String start_height = taskDto.getStart_height();
|
||||||
|
String next_height = taskDto.getNext_height();
|
||||||
|
//单台堆垛机最多只能创建固定数量指令
|
||||||
|
Instruction instruction = new Instruction();
|
||||||
|
instruction.setInstruction_status("1");
|
||||||
|
List<Instruction> byDeviceCodes = instructionService.findByDeviceCodes(instruction, true);
|
||||||
|
Instruction instdto = new Instruction();
|
||||||
|
if (CollUtil.isEmpty(byDeviceCodes)) {
|
||||||
|
instdto.setInstruction_type(task_type);
|
||||||
|
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||||
|
instdto.setRoute_plan_code(route_plan_code);
|
||||||
|
instdto.setRemark(taskDto.getRemark());
|
||||||
|
instdto.setMaterial(taskDto.getMaterial());
|
||||||
|
instdto.setQuantity(taskDto.getQuantity());
|
||||||
|
instdto.setTask_id(taskid);
|
||||||
|
instdto.setTask_code(taskcode);
|
||||||
|
instdto.setVehicle_code(vehiclecode);
|
||||||
|
String now = DateUtil.now();
|
||||||
|
instdto.setCreate_time(now);
|
||||||
|
instdto.setCreate_by("auto");
|
||||||
|
|
||||||
|
instdto.setStart_device_code(start_device_code);
|
||||||
|
instdto.setStart_point_code(start_point_code);
|
||||||
|
instdto.setPut_device_code(put_device_code);
|
||||||
|
instdto.setPut_point_code(put_point_code);
|
||||||
|
instdto.setNext_device_code(next_device_code);
|
||||||
|
instdto.setNext_point_code(next_point_code);
|
||||||
|
|
||||||
|
instdto.setStart_point_code2(start_point_code2);
|
||||||
|
instdto.setStart_device_code2(start_device_code2);
|
||||||
|
instdto.setNext_point_code2(next_point_code2);
|
||||||
|
instdto.setNext_device_code2(next_device_code2);
|
||||||
|
|
||||||
|
instdto.setPriority(priority);
|
||||||
|
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
|
||||||
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
instdto.setVehicle_type(vehicleType);
|
||||||
|
instdto.setAgv_system_type(agv_system_type);
|
||||||
|
instdto.setStart_height(start_height);
|
||||||
|
instdto.setNext_height(next_height);
|
||||||
|
if (startDevice.getDevice_type().equals(DeviceType.storage.name())) {
|
||||||
|
instdto.setFrom_x(taskDto.getFrom_x());
|
||||||
|
instdto.setFrom_z(taskDto.getFrom_z());
|
||||||
|
instdto.setFrom_y(taskDto.getFrom_y());
|
||||||
|
}
|
||||||
|
if (nextDevice.getDevice_type().equals(DeviceType.storage.name())) {
|
||||||
|
instdto.setTo_x(taskDto.getTo_x());
|
||||||
|
instdto.setTo_z(taskDto.getTo_z());
|
||||||
|
instdto.setTo_y(taskDto.getTo_y());
|
||||||
|
}
|
||||||
|
//判断agv系统
|
||||||
|
//1、1楼叉车系统
|
||||||
|
//2、2楼1区域AGV系统
|
||||||
|
//3、2楼2区域AGV系统 -已废弃
|
||||||
|
if (!StrUtil.equals(agv_system_type, "1")) {
|
||||||
|
// task_type
|
||||||
|
//1、生箔; Itype=1:取空,取满,放空,放满;
|
||||||
|
//2、分切 Itype=3取满、取空、放满、放空;
|
||||||
|
//3、普通任务 Itype=2:取货、放货;
|
||||||
|
//4、叉车任务
|
||||||
|
//5、输送任务
|
||||||
|
//6、行架
|
||||||
|
//7、立库
|
||||||
|
if (StrUtil.equals(task_type, "1")) {
|
||||||
|
instdto.setAgv_inst_type("1");
|
||||||
|
} else if (StrUtil.equals(task_type, "3")) {
|
||||||
|
instdto.setAgv_inst_type("2");
|
||||||
|
} else if (StrUtil.equals(task_type, "2")) {
|
||||||
|
instdto.setAgv_inst_type("3");
|
||||||
|
} else if (StrUtil.equals(task_type, "8")) {
|
||||||
|
instdto.setAgv_inst_type("2");
|
||||||
|
} else {
|
||||||
|
log.info("未找到对应的AGV指令类型,任务号:" + taskDto.getTask_code() + ",task_type:" + taskDto.getTask_type());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
instdto.setAgv_inst_type("4");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
instructionService.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
taskDto.setRemark(e.getMessage());
|
||||||
|
taskserver.updateByCodeFromCache(taskDto);
|
||||||
|
}
|
||||||
|
//创建指令后修改任务状态
|
||||||
|
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||||
|
taskserver.update(taskDto);
|
||||||
|
} else {
|
||||||
|
List<Instruction> insts = new ArrayList<>();
|
||||||
|
for (Instruction byDeviceCode : byDeviceCodes) {
|
||||||
|
String nextDeviceCode = byDeviceCode.getNext_device_code();
|
||||||
|
Device nextdevice = appService.findDeviceByCode(nextDeviceCode);
|
||||||
|
if (startDevice.getDevice_type().equals(DeviceType.storage.name()) &&
|
||||||
|
(nextdevice.getDevice_type().equals(DeviceType.conveyor.name()) || nextdevice.getDevice_type().equals(DeviceType.storage.name()))) {
|
||||||
|
insts.add(byDeviceCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int max = 0;
|
||||||
|
for (Instruction inst : insts) {
|
||||||
|
List<RouteLineDto> shortPathLines = routeLineService.getShortPathLines(inst.getStart_device_code(), inst.getNext_device_code(),
|
||||||
|
inst.getRoute_plan_code());
|
||||||
|
if (CollUtil.isEmpty(shortPathLines) || shortPathLines.size() < 1) {
|
||||||
|
log.error("没有此路由");
|
||||||
|
throw new BadRequestException("路由不通");
|
||||||
|
}
|
||||||
|
RouteLineDto routeLineDto1 = (RouteLineDto) shortPathLines.get(0);
|
||||||
|
String[] path1 = routeLineDto1.getPath().split("->");
|
||||||
|
List<String> pathlist1 = Arrays.asList(path1);
|
||||||
|
if (pathlist1.size() < 3 || pathlist1.get(1).equals(DeviceType.stacker.name())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pathlist1.get(1).equals(pathlist.get(1))) {
|
||||||
|
max++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<DeviceExtra> deviceExtras = deviceExtra.list(Wrappers.lambdaQuery(DeviceExtra.class).
|
||||||
|
eq(DeviceExtra::getDevice_code, pathlist.get(1)).orderByDesc(DeviceExtra::getCreate_time));
|
||||||
|
for (DeviceExtra extra : deviceExtras) {
|
||||||
|
if (extra.getExtra_code().equals("count")) {
|
||||||
|
if (max <= Integer.parseInt(extra.getExtra_value())) {
|
||||||
|
instdto.setInstruction_type(task_type);
|
||||||
|
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||||
|
instdto.setRoute_plan_code(route_plan_code);
|
||||||
|
instdto.setRemark(taskDto.getRemark());
|
||||||
|
instdto.setMaterial(taskDto.getMaterial());
|
||||||
|
instdto.setQuantity(taskDto.getQuantity());
|
||||||
|
instdto.setTask_id(taskid);
|
||||||
|
instdto.setTask_code(taskcode);
|
||||||
|
instdto.setVehicle_code(vehiclecode);
|
||||||
|
String now = DateUtil.now();
|
||||||
|
instdto.setCreate_time(now);
|
||||||
|
instdto.setCreate_by("auto");
|
||||||
|
|
||||||
|
instdto.setStart_device_code(start_device_code);
|
||||||
|
instdto.setStart_point_code(start_point_code);
|
||||||
|
instdto.setPut_device_code(put_device_code);
|
||||||
|
instdto.setPut_point_code(put_point_code);
|
||||||
|
instdto.setNext_device_code(next_device_code);
|
||||||
|
instdto.setNext_point_code(next_point_code);
|
||||||
|
|
||||||
|
instdto.setStart_point_code2(start_point_code2);
|
||||||
|
instdto.setStart_device_code2(start_device_code2);
|
||||||
|
instdto.setNext_point_code2(next_point_code2);
|
||||||
|
instdto.setNext_device_code2(next_device_code2);
|
||||||
|
|
||||||
|
instdto.setPriority(priority);
|
||||||
|
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
|
||||||
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
instdto.setVehicle_type(vehicleType);
|
||||||
|
instdto.setAgv_system_type(agv_system_type);
|
||||||
|
instdto.setStart_height(start_height);
|
||||||
|
instdto.setNext_height(next_height);
|
||||||
|
if (startDevice.getDevice_type().equals(DeviceType.storage.name())) {
|
||||||
|
instdto.setFrom_x(taskDto.getFrom_x());
|
||||||
|
instdto.setFrom_z(taskDto.getFrom_z());
|
||||||
|
instdto.setFrom_y(taskDto.getFrom_y());
|
||||||
|
}
|
||||||
|
if (nextDevice.getDevice_type().equals(DeviceType.storage.name())) {
|
||||||
|
instdto.setTo_x(taskDto.getTo_x());
|
||||||
|
instdto.setTo_z(taskDto.getTo_z());
|
||||||
|
instdto.setTo_y(taskDto.getTo_y());
|
||||||
|
}
|
||||||
|
//判断agv系统
|
||||||
|
//1、1楼叉车系统
|
||||||
|
//2、2楼1区域AGV系统
|
||||||
|
//3、2楼2区域AGV系统 -已废弃
|
||||||
|
if (!StrUtil.equals(agv_system_type, "1")) {
|
||||||
|
// task_type
|
||||||
|
//1、生箔; Itype=1:取空,取满,放空,放满;
|
||||||
|
//2、分切 Itype=3取满、取空、放满、放空;
|
||||||
|
//3、普通任务 Itype=2:取货、放货;
|
||||||
|
//4、叉车任务
|
||||||
|
//5、输送任务
|
||||||
|
//6、行架
|
||||||
|
//7、立库
|
||||||
|
if (StrUtil.equals(task_type, "1")) {
|
||||||
|
instdto.setAgv_inst_type("1");
|
||||||
|
} else if (StrUtil.equals(task_type, "3")) {
|
||||||
|
instdto.setAgv_inst_type("2");
|
||||||
|
} else if (StrUtil.equals(task_type, "2")) {
|
||||||
|
instdto.setAgv_inst_type("3");
|
||||||
|
} else if (StrUtil.equals(task_type, "8")) {
|
||||||
|
instdto.setAgv_inst_type("2");
|
||||||
|
} else {
|
||||||
|
log.info("未找到对应的AGV指令类型,任务号:" + taskDto.getTask_code() + ",task_type:" + taskDto.getTask_type());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
instdto.setAgv_inst_type("4");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
instructionService.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
taskDto.setRemark(e.getMessage());
|
||||||
|
taskserver.updateByCodeFromCache(taskDto);
|
||||||
|
}
|
||||||
|
//创建指令后修改任务状态
|
||||||
|
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||||
|
taskserver.update(taskDto);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//单台堆垛机只能出四五
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<TaskDto> sortInst(List<TaskDto> taskDtos) {
|
||||||
|
Collections.sort(taskDtos, (t1, t2) -> {
|
||||||
|
//优先级从大到小
|
||||||
|
int i = t2.getPriority().compareTo(t1.getPriority());
|
||||||
|
//如果优先级相等
|
||||||
|
if (i == 0) {
|
||||||
|
//时间从早到晚
|
||||||
|
i = t1.getCreate_time().compareTo(t2.getCreate_time());
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
});
|
||||||
|
return taskDtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -96,6 +96,11 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="指令上限:" label-width="150px" prop="count">
|
||||||
|
<el-input v-model.number="form.count" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|||||||
Reference in New Issue
Block a user