This commit is contained in:
2024-11-04 19:16:48 +08:00
parent 3620f6e20b
commit d93283701b
17 changed files with 280 additions and 208 deletions

View File

@@ -84,6 +84,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
if (!StrUtil.equals(agv_system_type, "1")) {
String instcode = inst.getInstruction_code();
int type = Integer.parseInt(inst.getAgv_inst_type());
int carNo = Integer.parseInt(inst.getCarno());
int priority = Integer.parseInt(inst.getPriority()) + 128;
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
@@ -95,6 +96,8 @@ public class NDCAgvServiceImpl implements NDCAgvService {
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
byte typehigh = (byte) IntToHexHigh(type);
byte typelow = (byte) IntToHexLow(type);
byte agvnohigh = (byte) IntToHexHigh(carNo);
byte agvnolow = (byte) IntToHexLow(carNo);
byte qhdhigh = (byte) IntToHexHigh(startAddress);
byte qhdlow = (byte) IntToHexLow(startAddress);
byte qhdhigh2 = (byte) IntToHexHigh(startAddress2);
@@ -125,6 +128,8 @@ public class NDCAgvServiceImpl implements NDCAgvService {
str += "优先级 /priority:" + (priority);
str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF);
str += "agv车号 /carNo:" + (carNo);
str1 += "agv车号 /carNo:" + hexToString(agvnolow & 0xFF);
byte[] b = new byte[]{};
if (type == 1) {

View File

@@ -9,7 +9,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.agv.server.impl.XianGongAgvServiceImpl;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;

View File

@@ -470,6 +470,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
String bindingTemplate = jo.get("bindingTemplate").toString();
String printDevice = jo.get("printDevice").toString();
String bundleTimes = jo.get("bundleTimes").toString();
String to_case = jo.get("box_structure").toString();
List list = new ArrayList();
@@ -522,6 +523,10 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
map12.put("code", "to_labeling_template");
map12.put("value", labelingTemplate);
list.add(map12);
Map map13 = new HashMap();
map13.put("code", "to_case");
map13.put("value", to_case);
list.add(map13);
}
if (mode == 13) {
Map map = new HashMap();
@@ -544,6 +549,10 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
map11.put("code", "to_binding_times");
map11.put("value", bundleTimes);
list.add(map11);
Map map13 = new HashMap();
map13.put("code", "to_case");
map13.put("value", to_case);
list.add(map13);
}
if (mode == 14) {
Map map4 = new HashMap();
@@ -582,6 +591,10 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
map11.put("code", "to_binding_times");
map11.put("value", bundleTimes);
list.add(map11);
Map map13 = new HashMap();
map13.put("code", "to_case");
map13.put("value", to_case);
list.add(map13);
}
if (mode == 17) {
@@ -607,6 +620,10 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
map11.put("code", "to_binding_times");
map11.put("value", bundleTimes);
list.add(map11);
Map map6 = new HashMap();
map6.put("code", "to_case");
map.put("value", to_case);
list.add(map6);
if (StrUtil.isNotEmpty(case1) && !" ".equals(case1)) {
Map map12 = new HashMap();
map12.put("code", "to_binding_times");

View File

@@ -108,6 +108,11 @@ public class ItemProtocol {
*/
public static String item_to_binding_times = "to_binding_times";
/**
* 下发木箱规格
*/
public static String item_to_case = "to_case";
/**
@@ -239,6 +244,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W24"));
list.add(new ItemDto(item_to_weight, "木箱宽度", "DB601.W26"));
list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W28"));
list.add(new ItemDto(item_to_case, "下发木箱规格", "DB601.W30"));
return list;
}

View File

@@ -497,7 +497,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
notCreateInstMessage = "universal_notCreateInstMessage";
}
}
return true;
return false;
}
}

View File

@@ -1,5 +1,6 @@
package org.nl.acs.device_driver.two_conveyor.pull_head_manipulator;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -363,205 +364,173 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
List<String> putDeviceCodeList = this.getExtraDeviceCodes("put_device_code");
TaskDto task = null;
PlugPullDeviceSiteDeviceDriver plugPullDeviceSiteDeviceDriver;
for (int i = 0; i < getDeviceCodeList.size(); i++) {
String startDeviceCode = getDeviceCodeList.get(i);
//先查指令
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus3(startDeviceCode);
if (ObjectUtil.isNotEmpty(taskDtos)) {
taskDtos = this.sortTask(taskDtos);
TaskDto taskDto = taskDtos.get(0);
if (!StrUtil.equals(taskDto.getTask_type(), "6") && !StrUtil.equals(taskDto.getTask_type(), "8")) {
taskDto = null;
continue;
//先查指令
List<Instruction> instructionList = instructionService.findReadyIns();
if (CollUtil.isNotEmpty(instructionList)) {
List<Instruction> instructionsReady = new ArrayList<>();
Instruction instructionReady = null;
for (Instruction instruction : instructionList) {
if (getDeviceCodeList.contains(instruction.getStart_device_code())) {
instructionsReady.add(instruction);
}
Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code());
if (ObjectUtil.isNotEmpty(instruction)) {
String startCode = instruction.getStart_device_code();
String nextCode = instruction.getNext_device_code();
Device startDevice = deviceAppService.findDeviceByCode(startCode);
Device nextDevice = deviceAppService.findDeviceByCode(nextCode);
if (startDevice.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) {
plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) startDevice.getDeviceDriver();
if (plugPullDeviceSiteDeviceDriver.getAction() != 1) {
notCreateInstMessage = startCode + "工位状态为不允许取,无法生成指令";
return false;
}
}
}
if (CollUtil.isNotEmpty(instructionsReady)) {
List<Instruction> instructions = instructionsReady.stream().sorted(Comparator.comparing(Instruction::getCreate_time)).collect(Collectors.toList());
instructionReady = instructions.get(0);
}
if (ObjectUtil.isNotEmpty(instructionReady)) {
String startCode = instructionReady.getStart_device_code();
String nextCode = instructionReady.getNext_device_code();
Device startDevice = deviceAppService.findDeviceByCode(startCode);
Device nextDevice = deviceAppService.findDeviceByCode(nextCode);
if (nextDevice.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) {
plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) device.getDeviceDriver();
if (plugPullDeviceSiteDeviceDriver.getAction() != 2) {
notCreateInstMessage = nextCode + "工位状态为不允许放,无法生成指令";
return false;
}
}
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
notCreateInstMessage = "未设置电气调度号!";
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
}
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
notCreateInstMessage = "未设置电气调度号!";
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
}
String startAddr = startDevice.getExtraValue().get("address").toString();
String nextAddr = nextDevice.getExtraValue().get("address").toString();
String msg = "当前设备:" + device_code + ",下发指令:"
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
+ ",指令终点:" + instruction.getNext_device_code();
LuceneLogDto logDto1 = LuceneLogDto.builder()
.device_code(device_code)
.content(msg)
.build();
logDto1.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto1);
String interaction_json = taskDto.getInteraction_json();
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
notCreateInstMessage = "未设置电气调度号!";
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
}
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
notCreateInstMessage = "未设置电气调度号!";
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
}
String startAddr = startDevice.getExtraValue().get("address").toString();
String nextAddr = nextDevice.getExtraValue().get("address").toString();
TaskDto byTaskCode = taskserver.findByTaskCode(instructionReady.getTask_code());
String interactionJson = byTaskCode.getInteraction_json();
// Map<String, Object> map = toStringObjectMap(instruction, startAddr, nextAddr, interaction_json);
try {
pushPLC(instruction, startAddr, nextAddr, interaction_json);
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("当前设备:" + device_code + ",下发指令:"
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
+ ",指令终点:" + instruction.getNext_device_code() + ",指令执行失败:" + e.getMessage())
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
instruction.setInstruction_status(InstructionStatusEnum.BUSY.getIndex());
instruction.setUpdate_time(DateUtil.now());
instructionService.update(instruction);
this.setRequireSucess(true);
return true;
try {
pushPLC(instructionReady, startAddr, nextAddr, interactionJson);
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("当前设备:" + device_code + ",下发指令:"
+ instructionReady.getInstruction_code() + ",指令起点:" + instructionReady.getStart_device_code()
+ ",指令终点:" + instructionReady.getNext_device_code() + ",指令执行失败:" + e.getMessage())
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
return false;
}
} else {
List<TaskDto> taskDtoList = taskserver.findByTrappedManipulatorReady();
if (ObjectUtil.isNotEmpty(taskDtoList)) {
List<TaskDto> taskDtosReady = new ArrayList<>();
for (TaskDto taskDto1 : taskDtoList) {
if (getDeviceCodeList.contains(taskDto1.getStart_device_code())) {
taskDtosReady.add(taskDto1);
this.setRequireSucess(true);
return true;
}
} else {
List<TaskDto> taskDtos = taskserver.findByTrappedManipulatorReady();
List<TaskDto> taskDtosReady = new ArrayList<>();
TaskDto taskDto = null;
if (CollUtil.isNotEmpty(taskDtos)) {
for (TaskDto taskDto1 : taskDtos) {
if (getDeviceCodeList.contains(taskDto1.getStart_device_code())) {
taskDtosReady.add(taskDto1);
}
}
}
if (CollUtil.isNotEmpty(taskDtosReady)) {
for (TaskDto dto : taskDtosReady) {
String firstDeviceCode = dto.getStart_device_code();
Device start_device = deviceAppService.findDeviceByCode(firstDeviceCode);
if (start_device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) {
plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) start_device.getDeviceDriver();
if (plugPullDeviceSiteDeviceDriver.getAction() != 1) {
notCreateInstMessage = firstDeviceCode + "工位状态为不允许取,无法生成指令";
continue;
}
}
// task = taskDtosReady.get(0);
List<TaskDto> readyTaskDtos = new ArrayList<>();
for (int j = 0; j < taskDtosReady.size(); j++) {
task = taskDtosReady.get(j);
readyTaskDtos.add(task);
String nextDeviceCode = dto.getNext_device_code();
Device next_device = deviceAppService.findDeviceByCode(nextDeviceCode);
if (next_device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) {
plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) next_device.getDeviceDriver();
if (plugPullDeviceSiteDeviceDriver.getAction() != 2) {
notCreateInstMessage = nextDeviceCode + "工位状态为不允许放,无法生成指令";
continue;
}
}
taskDto = dto;
if (ObjectUtil.isNotEmpty(taskDto)) {
break;
}
//按照优先级排序 优先级相等按照创建时间排序
readyTaskDtos = this.sortTask(readyTaskDtos);
task = readyTaskDtos.get(0);
}
if (ObjectUtil.isNotEmpty(task)) {
break;
}
}
}
if (!ObjectUtil.isEmpty(task)) {
String taskId = task.getTask_id();
String taskCode = task.getTask_code();
String vehicleCode = task.getVehicle_code();
String priority = task.getPriority();
String startPointCode = task.getStart_point_code();
String routePlanCode = task.getRoute_plan_code();
String nextPointCode = task.getNext_point_code();
if (!ObjectUtil.isEmpty(taskDto)) {
String taskId = taskDto.getTask_id();
String taskCode = taskDto.getTask_code();
String vehicleCode = taskDto.getVehicle_code();
String priority = taskDto.getPriority();
String start_device_code = taskDto.getStart_device_code();
String next_device_code = taskDto.getNext_device_code();
String routePlanCode = taskDto.getRoute_plan_code();
String firstDeviceCode = task.getStart_device_code();
Device start_device = deviceAppService.findDeviceByCode(firstDeviceCode);
if (start_device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) {
plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) start_device.getDeviceDriver();
if (plugPullDeviceSiteDeviceDriver.getAction() != 1) {
notCreateInstMessage = firstDeviceCode + "工位状态为不允许取,无法生成指令";
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(routePlanCode);
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(SecurityUtils.getCurrentNickName());
instdto.setStart_device_code(start_device_code);
instdto.setNext_device_code(next_device_code);
instdto.setStart_point_code(start_device_code);
instdto.setNext_point_code(next_device_code);
instdto.setPriority(priority);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(device_code);
Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code());
Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code());
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
notCreateInstMessage = "未设置电气调度号";
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code()));
}
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
notCreateInstMessage = "未设置电气调度号!";
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code()));
}
String startAddr = startDevice.getExtraValue().get("address").toString();
String nextAddr = nextDevice.getExtraValue().get("address").toString();
try {
instructionService.create(instdto);
} catch (Exception e) {
notCreateInstMessage = e.getMessage();
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(device_code + "创建指令时出现异常:" + e.getMessage())
.build();
luceneExecuteLogService.deviceExecuteLog(logDto);
return false;
}
}
String nextDeviceCode = task.getNext_device_code();
Device next_device = deviceAppService.findDeviceByCode(nextDeviceCode);
if (next_device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) {
plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) next_device.getDeviceDriver();
if (plugPullDeviceSiteDeviceDriver.getAction() != 2) {
notCreateInstMessage = nextDeviceCode + "工位状态为不允许放,无法生成指令";
String interaction_json = taskDto.getInteraction_json();
try {
pushPLC(instdto, startAddr, nextAddr, interaction_json);
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("当前设备:" + device_code + ",下发指令:"
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
+ ",指令终点:" + instdto.getNext_device_code() + ",指令执行失败:" + e.getMessage())
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
return false;
}
//创建指令后修改任务状态
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskserver.update(taskDto);
this.setRequireSucess(true);
return true;
} else {
notCreateInstMessage = "找到关联设备的任务,指令无法创建";
}
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(routePlanCode);
instdto.setRemark(task.getRemark());
instdto.setMaterial(task.getMaterial());
instdto.setQuantity(task.getQuantity());
instdto.setTask_id(taskId);
instdto.setTask_code(taskCode);
instdto.setVehicle_code(vehicleCode);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
instdto.setStart_device_code(firstDeviceCode);
instdto.setNext_device_code(nextDeviceCode);
instdto.setStart_point_code(startPointCode);
instdto.setNext_point_code(nextPointCode);
instdto.setPriority(priority);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(startPointCode);
try {
instructionService.create(instdto);
} catch (Exception e) {
notCreateInstMessage = e.getMessage();
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(device_code + "创建指令时出现异常:" + e.getMessage())
.build();
luceneExecuteLogService.deviceExecuteLog(logDto);
return false;
}
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
+ ",指令终点:" + instdto.getNext_device_code());
//创建指令后修改任务状态
task.setTask_status(TaskStatusEnum.BUSY.getIndex());
task.setUpdate_time(DateUtil.now());
taskserver.update(task);
Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code());
Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code());
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
notCreateInstMessage = "未设置电气调度号";
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code()));
}
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
notCreateInstMessage = "未设置电气调度号!";
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code()));
}
String startAddr = startDevice.getExtraValue().get("address").toString();
String nextAddr = nextDevice.getExtraValue().get("address").toString();
String interaction_json = task.getInteraction_json();
// Map<String, Object> map = toStringObjectMap(instdto, startAddr, nextAddr, interaction_json);
try {
pushPLC(instdto, startAddr, nextAddr, interaction_json);
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("当前设备:" + device_code + ",下发指令:"
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
+ ",指令终点:" + instdto.getNext_device_code() + ",指令执行失败:" + e.getMessage())
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
this.setRequireSucess(true);
return true;
} else {
notCreateInstMessage = "找到关联设备的任务,指令无法创建";
}
return true;
return false;
}
}
@@ -643,11 +612,11 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
list.add(map3);
// map.put("to_barcode", jsonObject.getString("qzz_no"));
map4.put("code", "to_barcode");
map4.put("value", jsonObject.getString("qzz_no"));
map4.put("value", jsonObject.getString("qzz_no"));
list.add(map4);
// map.put("to_command", CommonFinalParam.ONE);
map5.put("code", "to_command");
map5.put("value", CommonFinalParam.ONE);
map5.put("value", CommonFinalParam.ONE);
list.add(map5);
// map.put("to_onset", startAddr);
map6.put("code", "to_onset");

View File

@@ -226,4 +226,9 @@ public class CreateTaskRequest extends BaseRequest {
* 17 木箱堆叠行架任务
*/
private String class_type;
/**
* agv编号
*/
private String agv_no;
}

View File

@@ -133,6 +133,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
String route_plan_code = request.getRoute_plan_code();
String task_type = request.getTask_type();
String class_type = request.getClass_type();
String agv_no = request.getAgv_no();
String truss_type = request.getTruss_type();
Integer agv_action_type = request.getAgv_action_type();
String empty_site = request.getEmpty_site();
@@ -354,6 +355,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("next_device_code2", next_device_code2);
jo.put("put_device_code", put_device_code);
jo.put("agv_action_type", agv_action_type);
jo.put("agv_no", agv_no);
jo.put("priority", priority);
jo.put("vehicle_code", vehicle_code);
jo.put("vehicle_code2", vehicle_code2);

View File

@@ -2064,6 +2064,16 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
public List<Instruction> findReadyInstructions() {
//根据时间升序取第一个
List<Instruction> instructionsList = instructions.stream()
.filter(item -> StrUtil.equals(item.getInstruction_type(), TaskTypeEnum.Truss_Task.getIndex())
&& StrUtil.equals(item.getInstruction_status(), TaskStatusEnum.READY.getIndex())).collect(Collectors.toList());
return instructionsList;
}
private boolean regional(String start_device_code, String next_device_code) {
Device startdevice = deviceAppService.findDeviceByCode(start_device_code);
Device nextdevice = deviceAppService.findDeviceByCode(next_device_code);

View File

@@ -247,6 +247,11 @@ public class Task extends CommonModel<Task> implements Serializable {
private Integer agv_action_type;
/**
* agv编号
*/
private String agv_no;
/**
* 任务类型
* 9 子卷下线行架任务

View File

@@ -370,4 +370,9 @@ public class TaskDto implements Serializable {
* 15 RGV输送任务
*/
private String class_type;
/**
* agv编号
*/
private String agv_no;
}

View File

@@ -88,6 +88,7 @@ public class AutoCreateInst {
String route_plan_code = acsTask.getRoute_plan_code();
String vehicleType = acsTask.getVehicle_type();
String agv_system_type = acsTask.getAgv_system_type();
String agv_no = acsTask.getAgv_no();
String start_height = acsTask.getStart_height();
String next_height = acsTask.getNext_height();
@@ -166,6 +167,7 @@ public class AutoCreateInst {
instdto.setStart_height(start_height);
instdto.setNext_height(next_height);
instdto.setAgv_action_type(agvActionType);
instdto.setCarno(agv_no);
//判断agv系统
//1、1楼叉车系统
//2、2楼1区域AGV系统

View File

@@ -10,7 +10,7 @@ spring:
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
# url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.10.67}:${DB_PORT:3306}/${DB_NAME:lzhl_acs2}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
username: ${DB_USER:root}
# password: ${DB_PWD:Root.123456}

View File

@@ -12,7 +12,7 @@ spring:
# url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
username: ${DB_USER:root}
password: ${DB_PWD:NLABC&hl123}
password: ${DB_PWD:123456}
# password: ${DB_PWD:p@ssw0rd}
# 初始连接数
initial-size: 5

View File

@@ -6,7 +6,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: dev
active: prod
jackson:
time-zone: GMT+8
data:

View File

@@ -1,6 +1,13 @@
package org.nl;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.unit.DataUnit;
import cn.hutool.core.util.StrUtil;
import org.junit.jupiter.api.Test;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.system.service.user.ISysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -8,6 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.*;
@@ -23,25 +33,62 @@ public class ApplicationTest {
private Logger logger = LoggerFactory.getLogger(ApplicationTest.class);
private List<Person> persons = new CopyOnWriteArrayList();
@Test
void contextLoads() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入第一个数:");
int a = scanner.nextInt();
System.out.println("请输入第一个数:");
int b = scanner.nextInt();
System.out.println("请输入第一个数:");
int c = scanner.nextInt();
//求最小值
int min = (((a < b) ? a : b) < c) ? ((a < b) ? a : b) : c;
//求最大值
int max = (((a > b) ? a : b) > c) ? ((a > b) ? a : b) : c;
//求中间值
int mid = a + b + c - max - min;
//排序
System.out.println("最小值为:" + min + "中间值为:" + mid + "最大值为:" + max);
Person person1 = new Person();
Person person2 = new Person();
Person person3 = new Person();
String now1 = DateUtil.now();
person1.setCreate_time(now1);
String now2 = DateUtil.now();
String now3 = DateUtil.now();
person2.setCreate_time(now2);
person3.setCreate_time(now3);
person1.setNext_device_code("CK2042");
person2.setNext_device_code("CK2042");
person3.setNext_device_code("CK2042");
person1.setInstruction_status("0");
person2.setInstruction_status("0");
person3.setInstruction_status("0");
person1.setInstruction_type("6");
person2.setInstruction_type("17");
person3.setInstruction_type("7");
persons.add(person1);
persons.add(person2);
persons.add(person3);
Person person = findByNextDeviceCodeFromCache("CK2042");
System.out.println(person);
}
public Person findByNextDeviceCodeFromCache(String devicecode) {
List<Person> personList = persons;
ListUtil.sort(
personList,
new Comparator<Person>() {
@Override
public int compare(Person o1, Person o2) {
return o1.getCreate_time().compareTo(o2.getCreate_time());
}
});
Iterator<Person> it = persons.iterator();
while (it.hasNext()) {
Person person = it.next();
if (StrUtil.equals(devicecode, person.getNext_device_code()) && Integer.parseInt(person.getInstruction_status()) <= Integer.parseInt(InstructionStatusEnum.BUSY.getIndex()) && !person.getInstruction_type().equals(TaskTypeEnum.Mxddhj_Task.getIndex())&& !person.getInstruction_type().equals(TaskTypeEnum.Truss_Task.getIndex())) {
return person;
}
}
return null;
}
@Test
void contextLoads2() {
int time = Integer.parseInt("137341");
int hours = (time / (60 * 60)); // 整数小时
int minutes = (time % (60 * 60)) / 60; // 剩余分钟
System.out.println("hours:" + hours + " minutes:" + minutes);
}
@Test