fix:线程阻塞问题处理
This commit is contained in:
@@ -44,6 +44,7 @@
|
|||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara.dynamictp</groupId>
|
<groupId>org.dromara.dynamictp</groupId>
|
||||||
<artifactId>dynamic-tp-spring-boot-starter-adapter-webserver</artifactId>
|
<artifactId>dynamic-tp-spring-boot-starter-adapter-webserver</artifactId>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.nl.acs.agv;
|
package org.nl.acs.agv;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
@@ -42,7 +41,6 @@ public class QueryAGVStatus {
|
|||||||
private DeviceAppService deviceAppService;
|
private DeviceAppService deviceAppService;
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
log.info("定时查询AGV状态"+ DateUtil.now());
|
|
||||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||||
TaskService taskService = SpringContextHolder.getBean(TaskService.class);
|
TaskService taskService = SpringContextHolder.getBean(TaskService.class);
|
||||||
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
|
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
|
||||||
|
|||||||
@@ -301,7 +301,6 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
|||||||
(byte) nextHighHigh, (byte) nextHighLow
|
(byte) nextHighHigh, (byte) nextHighLow
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
|
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
|
||||||
|
|
||||||
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
|
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOpcStringValue(String protocol) {
|
public String getOpcStringValue(String protocol) {
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
public String getOpcStringValue(String protocol) {
|
public String getOpcStringValue(String protocol) {
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemDto> getReadableItemDtos() {
|
public static List<ItemDto> getReadableItemDtos() {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ ItemProtocol {
|
|||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return "0";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemDto> getReadableItemDtos() {
|
public static List<ItemDto> getReadableItemDtos() {
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getOpcFloatValue(String protocol) {
|
public float getOpcFloatValue(String protocol) {
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ public class ItemProtocol {
|
|||||||
setIsonline(true);
|
setIsonline(true);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getOpcFloatValue(String protocol) {
|
public float getOpcFloatValue(String protocol) {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.nl.acs.monitor.DeviceStageMonitor;
|
|||||||
import org.nl.acs.opc.DeviceAppService;
|
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.task.enums.TaskTypeEnum;
|
||||||
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.common.exception.BadRequestException;
|
||||||
@@ -49,6 +50,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 烘箱-行架机械手
|
* 烘箱-行架机械手
|
||||||
@@ -331,28 +333,21 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
|||||||
TaskDto task = null;
|
TaskDto task = null;
|
||||||
for (int i = 0; i < getDeviceCodeList.size(); i++) {
|
for (int i = 0; i < getDeviceCodeList.size(); i++) {
|
||||||
String startDeviceCode = getDeviceCodeList.get(i);
|
String startDeviceCode = getDeviceCodeList.get(i);
|
||||||
|
//先查指令
|
||||||
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode);
|
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode);
|
||||||
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
List<TaskDto> taskDtoStream = taskDtos.stream().sorted(Comparator.comparing(TaskDto::getCreate_time)).collect(Collectors.toList());
|
||||||
//按照优先级排序 优先级相等按照创建时间排序
|
if (ObjectUtil.isNotEmpty(taskDtoStream)) {
|
||||||
taskDtos = this.sortTask(taskDtos);
|
|
||||||
TaskDto taskDto = taskDtos.get(0);
|
TaskDto taskDto = taskDtos.get(0);
|
||||||
|
if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
|
||||||
//存在行架->暂存的AGV任务 需要过滤
|
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code());
|
||||||
// 6 行架任务 8烘箱任务
|
String start_device_code = instruction.getStart_device_code();
|
||||||
if (!StrUtil.equals(taskDto.getTask_type(), "6") && !StrUtil.equals(taskDto.getTask_type(), "8")) {
|
String next_device_code = instruction.getNext_device_code();
|
||||||
taskDto = null;
|
Device nextdevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||||
continue;
|
Device startdevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||||
}
|
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
|
||||||
|
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code());
|
ManipulatorAgvStationDeviceDriver manipulatorAgvStationDeviceDriver;
|
||||||
String start_device_code = instruction.getStart_device_code();
|
OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver;
|
||||||
String next_device_code = instruction.getNext_device_code();
|
|
||||||
Device nextdevice = deviceAppService.findDeviceByCode(next_device_code);
|
|
||||||
Device startdevice = deviceAppService.findDeviceByCode(start_device_code);
|
|
||||||
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
|
|
||||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
|
||||||
ManipulatorAgvStationDeviceDriver manipulatorAgvStationDeviceDriver;
|
|
||||||
OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver;
|
|
||||||
/*if (startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof RangingStationsDeviceDriver) {
|
/*if (startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof RangingStationsDeviceDriver) {
|
||||||
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||||
standardInspectSiteDeviceDriver = (RangingStationsDeviceDriver) nextdevice.getDeviceDriver();
|
standardInspectSiteDeviceDriver = (RangingStationsDeviceDriver) nextdevice.getDeviceDriver();
|
||||||
@@ -383,104 +378,111 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||||
if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
|
if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
|
||||||
if (standardInspectSiteDeviceDriver.getMove() != 1) {
|
if (standardInspectSiteDeviceDriver.getMove() != 1) {
|
||||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "无货,无法下发指令!指令号:" + instruction.getInstruction_code();
|
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "无货,无法下发指令!指令号:" + instruction.getInstruction_code();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||||
|
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
|
||||||
|
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) {
|
||||||
|
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或无货,无法下发指令!指令号:" + instruction.getInstruction_code();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
|
||||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
|
|
||||||
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) {
|
|
||||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或无货,无法下发指令!指令号:" + instruction.getInstruction_code();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||||
if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
|
if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
|
||||||
if (standardInspectSiteDeviceDriver.getMove() != 0) {
|
if (standardInspectSiteDeviceDriver.getMove() != 0) {
|
||||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!指令号:" + instruction.getInstruction_code();
|
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!指令号:" + instruction.getInstruction_code();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||||
|
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver();
|
||||||
|
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 1) {
|
||||||
|
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或者有货,无法下发指令!指令号:" + instruction.getInstruction_code();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//判断关联的同一列烘箱设备是否都关门 都关门返回false,有一个不关门就返回true
|
||||||
if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
boolean isCloseDoor = this.judgeCloseDoor(start_device_code, next_device_code);
|
||||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver();
|
//未关门结束
|
||||||
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 1) {
|
if (isCloseDoor) {
|
||||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或者有货,无法下发指令!指令号:" + instruction.getInstruction_code();
|
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//判断关联的同一列烘箱设备是否都关门 都关门返回false,有一个不关门就返回true
|
|
||||||
boolean isCloseDoor = this.judgeCloseDoor(start_device_code, next_device_code);
|
|
||||||
//未关门结束
|
|
||||||
if (isCloseDoor) {
|
|
||||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/*instruction.setInstruction_status("1");
|
/*instruction.setInstruction_status("1");
|
||||||
instruction.setUpdate_time(DateUtil.now());
|
instruction.setUpdate_time(DateUtil.now());
|
||||||
instructionService.update(instruction);*/
|
instructionService.update(instruction);*/
|
||||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||||
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
|
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
|
||||||
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
|
||||||
|
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
||||||
|
}
|
||||||
|
String start_addr = startDevice.getExtraValue().get("address").toString();
|
||||||
|
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||||
|
String msg = "当前设备:" + device_code + ",下发指令:"
|
||||||
|
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
|
||||||
|
+ ",指令终点:" + instruction.getNext_device_code();
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code(device_code)
|
||||||
|
.content(msg)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(3);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
List list = new ArrayList<>();
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("code", "to_onset");
|
||||||
|
map.put("value", StrUtil.isNotBlank(start_addr) ? start_addr : "0");
|
||||||
|
Map map1 = new HashMap();
|
||||||
|
map1.put("code", "to_target");
|
||||||
|
map1.put("value", StrUtil.isNotBlank(next_addr) ? next_addr : "0");
|
||||||
|
Map map2 = new HashMap();
|
||||||
|
map2.put("code", "to_task");
|
||||||
|
map2.put("value", instruction.getInstruction_code());
|
||||||
|
Map map3 = new HashMap();
|
||||||
|
map3.put("code", "to_command");
|
||||||
|
map3.put("value", "1");
|
||||||
|
list.add(map);
|
||||||
|
list.add(map1);
|
||||||
|
list.add(map2);
|
||||||
|
list.add(map3);
|
||||||
|
this.writing(list);
|
||||||
|
this.setRequireSucess(true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
|
|
||||||
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
|
|
||||||
}
|
|
||||||
String start_addr = startDevice.getExtraValue().get("address").toString();
|
|
||||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
|
||||||
String msg = "当前设备:" + device_code + ",下发指令:"
|
|
||||||
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
|
|
||||||
+ ",指令终点:" + instruction.getNext_device_code();
|
|
||||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
|
||||||
.device_code(device_code)
|
|
||||||
.content(msg)
|
|
||||||
.build();
|
|
||||||
logDto.setLog_level(3);
|
|
||||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
|
||||||
List list = new ArrayList<>();
|
|
||||||
Map map = new HashMap();
|
|
||||||
map.put("code", "to_onset");
|
|
||||||
map.put("value", StrUtil.isNotBlank(start_addr) ? start_addr : "0");
|
|
||||||
Map map1 = new HashMap();
|
|
||||||
map1.put("code", "to_target");
|
|
||||||
map1.put("value", StrUtil.isNotBlank(next_addr) ? next_addr : "0");
|
|
||||||
Map map2 = new HashMap();
|
|
||||||
map2.put("code", "to_task");
|
|
||||||
map2.put("value", instruction.getInstruction_code());
|
|
||||||
Map map3 = new HashMap();
|
|
||||||
map3.put("code", "to_command");
|
|
||||||
map3.put("value", "1");
|
|
||||||
list.add(map);
|
|
||||||
list.add(map1);
|
|
||||||
list.add(map2);
|
|
||||||
list.add(map3);
|
|
||||||
this.writing(list);
|
|
||||||
this.setRequireSucess(true);
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
List<TaskDto> taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode);
|
List<TaskDto> taskDtoList = taskserver.findByTrappedManipulatorReady();
|
||||||
if (ObjectUtil.isNotEmpty(taskDtoList)) {
|
if (ObjectUtil.isNotEmpty(taskDtoList)) {
|
||||||
for (int j = 0; j < taskDtoList.size(); j++) {
|
List<TaskDto> taskDtosReady = new ArrayList<>();
|
||||||
//按照优先级排序 优先级相等按照创建时间排序
|
for (TaskDto taskDto1 : taskDtoList) {
|
||||||
taskDtoList = this.sortTask(taskDtoList);
|
if (getDeviceCodeList.contains(taskDto1.getStart_device_code())) {
|
||||||
task = taskDtoList.get(j);
|
taskDtosReady.add(taskDto1);
|
||||||
// 6 行架任务 8烘箱任务
|
|
||||||
if (!StrUtil.equals(task.getTask_type(), "6") && !StrUtil.equals(task.getTask_type(), "8")) {
|
|
||||||
task = null;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isNotEmpty(task)) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// task = taskDtosReady.get(0);
|
||||||
|
List<TaskDto> readyTaskDtos = new ArrayList<>();
|
||||||
|
for (int j = 0; j < taskDtosReady.size(); j++) {
|
||||||
|
task = taskDtosReady.get(j);
|
||||||
|
|
||||||
|
readyTaskDtos.add(task);
|
||||||
|
}
|
||||||
|
//按照优先级排序 优先级相等按照创建时间排序
|
||||||
|
readyTaskDtos = this.sortTask(readyTaskDtos);
|
||||||
|
task = readyTaskDtos.get(0);
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(task)) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,11 +664,11 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
|||||||
list.add(map3);
|
list.add(map3);
|
||||||
this.writing(list);
|
this.writing(list);
|
||||||
this.setRequireSucess(true);
|
this.setRequireSucess(true);
|
||||||
notCreateInstMessage = "";
|
return true;
|
||||||
notCreateTaskMessage = "";
|
|
||||||
} else {
|
} else {
|
||||||
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -857,7 +859,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
|||||||
if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
|
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
|
||||||
// EXECUTOR.execute(() -> {
|
// EXECUTOR.execute(() -> {
|
||||||
toOpenDoor(device);
|
toOpenDoor(device);
|
||||||
// });
|
// });
|
||||||
int mode = hongXiangConveyorDeviceDriver.getMode();
|
int mode = hongXiangConveyorDeviceDriver.getMode();
|
||||||
int door = hongXiangConveyorDeviceDriver.getDoor();
|
int door = hongXiangConveyorDeviceDriver.getDoor();
|
||||||
@@ -923,7 +925,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
|||||||
if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
|
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
|
||||||
// EXECUTOR.execute(() -> {
|
// EXECUTOR.execute(() -> {
|
||||||
toCloseDoor(device);
|
toCloseDoor(device);
|
||||||
// });
|
// });
|
||||||
int mode = hongXiangConveyorDeviceDriver.getMode();
|
int mode = hongXiangConveyorDeviceDriver.getMode();
|
||||||
int door = hongXiangConveyorDeviceDriver.getDoor();
|
int door = hongXiangConveyorDeviceDriver.getDoor();
|
||||||
@@ -989,7 +991,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
|||||||
if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver();
|
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver();
|
||||||
// EXECUTOR.submit(() -> {
|
// EXECUTOR.submit(() -> {
|
||||||
toOpenDoor(nextDevice);
|
toOpenDoor(nextDevice);
|
||||||
// });
|
// });
|
||||||
int mode = hongXiangConveyorDeviceDriver.getMode();
|
int mode = hongXiangConveyorDeviceDriver.getMode();
|
||||||
int door = hongXiangConveyorDeviceDriver.getDoor();
|
int door = hongXiangConveyorDeviceDriver.getDoor();
|
||||||
@@ -1059,7 +1061,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
|||||||
if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver();
|
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver();
|
||||||
// EXECUTOR.execute(() -> {
|
// EXECUTOR.execute(() -> {
|
||||||
toCloseDoor(nextDevice);
|
toCloseDoor(nextDevice);
|
||||||
// });
|
// });
|
||||||
if (StrUtil.isNotEmpty(taskDto.getOven_time())) {
|
if (StrUtil.isNotEmpty(taskDto.getOven_time())) {
|
||||||
//下发烘箱时间
|
//下发烘箱时间
|
||||||
@@ -1141,8 +1143,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
feedMessage = "行架机械手:";
|
feedMessage = "行架机械手:";
|
||||||
if (mode != 3) {
|
if (mode != 3) {
|
||||||
@@ -1158,8 +1160,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
|||||||
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
|
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized boolean finish_instruction(Instruction inst) throws Exception {
|
public synchronized boolean finish_instruction(Instruction inst) throws Exception {
|
||||||
instructionService.finish(inst);
|
instructionService.finish(inst);
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
|
|||||||
* @param dto
|
* @param dto
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
boolean create(Instruction dto) throws Exception;
|
void create(Instruction dto) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean create(Instruction dto) throws Exception {
|
public void create(Instruction dto) throws Exception {
|
||||||
dto = foramte(dto);
|
dto = foramte(dto);
|
||||||
String task_code = dto.getTask_code();
|
String task_code = dto.getTask_code();
|
||||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||||
@@ -394,7 +394,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
.eq(InstructionMybatis::getTask_code, dto.getTask_code()));
|
.eq(InstructionMybatis::getTask_code, dto.getTask_code()));
|
||||||
if (CollUtil.isNotEmpty(instructionMybatis) && instructionMybatis.stream().anyMatch(inst -> inst.getStart_device_code()
|
if (CollUtil.isNotEmpty(instructionMybatis) && instructionMybatis.stream().anyMatch(inst -> inst.getStart_device_code()
|
||||||
.equals(start_device_code))) {
|
.equals(start_device_code))) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String currentUsername = SecurityUtils.getCurrentNickName();
|
String currentUsername = SecurityUtils.getCurrentNickName();
|
||||||
@@ -538,7 +538,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
.build();
|
.build();
|
||||||
logDto1.setLog_level(4);
|
logDto1.setLog_level(4);
|
||||||
luceneExecuteLogService.deviceExecuteLog(logDto1);
|
luceneExecuteLogService.deviceExecuteLog(logDto1);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
||||||
@@ -591,7 +590,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class);
|
InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class);
|
||||||
instructionMapper.insert(entity);
|
instructionMapper.insert(entity);
|
||||||
instructions.add(dto);
|
instructions.add(dto);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,22 @@ package org.nl.acs.opc;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.dynamictp.core.DtpRegistry;
|
import org.dromara.dynamictp.core.DtpRegistry;
|
||||||
import org.dromara.dynamictp.core.executor.DtpExecutor;
|
|
||||||
import org.dromara.dynamictp.core.support.ExecutorWrapper;
|
|
||||||
import org.nl.acs.auto.run.AbstractAutoRunnable;
|
import org.nl.acs.auto.run.AbstractAutoRunnable;
|
||||||
import org.nl.acs.auto.run.AutoRunService;
|
import org.nl.acs.auto.run.AutoRunService;
|
||||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||||
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.udw.UnifiedDataAccessor;
|
import org.nl.acs.udw.UnifiedDataAccessor;
|
||||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||||
|
import org.nl.config.SpringContextHolder;
|
||||||
|
import org.nl.config.thread.TheadFactoryName;
|
||||||
import org.nl.config.thread.ThreadPoolExecutorUtil;
|
import org.nl.config.thread.ThreadPoolExecutorUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
@@ -34,7 +38,10 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
|||||||
|
|
||||||
int loop_time_millions = 100;
|
int loop_time_millions = 100;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ThreadPoolExecutor executorService;
|
||||||
|
|
||||||
|
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(30);
|
||||||
|
|
||||||
Map<String, BlockedRunable> runs;
|
Map<String, BlockedRunable> runs;
|
||||||
|
|
||||||
@@ -114,8 +121,33 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
|||||||
BlockedRunable runnable = new BlockedRunable() {
|
BlockedRunable runnable = new BlockedRunable() {
|
||||||
@Override
|
@Override
|
||||||
public void subRun() throws Exception {
|
public void subRun() throws Exception {
|
||||||
// Thread.sleep(6000);
|
|
||||||
deviceDriver.executeAuto();
|
deviceDriver.executeAuto();
|
||||||
|
/* ThreadPoolExecutor executor= DtpRegistry.getDtpExecutor("dtpExecutor1");
|
||||||
|
|
||||||
|
Future<?> submit = executor.submit(() -> {
|
||||||
|
try {
|
||||||
|
deviceDriver.executeAuto();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
// 设置超时时间为 15 秒,如果任务超时,抛出 TimeoutException
|
||||||
|
submit.get(10, TimeUnit.SECONDS);
|
||||||
|
System.out.println();
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
System.out.println("任务超时,取消任务!");
|
||||||
|
// 使用反射获取 FutureTask 中的线程,并使用 Thread.stop() 强制终止
|
||||||
|
Field runnerField = submit.getClass().getDeclaredField("runner");
|
||||||
|
runnerField.setAccessible(true);
|
||||||
|
Thread runnerThread = (Thread) runnerField.get(submit);
|
||||||
|
if (runnerThread != null) {
|
||||||
|
runnerThread.stop(); // 强制终止线程(不推荐)
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -127,16 +159,55 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
|||||||
this.runs.put(deviceDriver.getDeviceCode(), runnable);
|
this.runs.put(deviceDriver.getDeviceCode(), runnable);
|
||||||
}
|
}
|
||||||
runnable.setIndex(this.runs);
|
runnable.setIndex(this.runs);
|
||||||
|
// this.executorService.execute(runnable);
|
||||||
ExecutorService executorService = (ExecutorService) ThreadPoolExecutorUtil.getPoll();
|
Future<?> future = this.executorService.submit(runnable);
|
||||||
Future<?> future = executorService.submit(runnable);
|
/* try {
|
||||||
|
// 设置超时时间为 30 秒,如果任务超时,抛出 TimeoutException
|
||||||
|
future.get(5, TimeUnit.SECONDS);
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
System.out.println("任务超时,取消任务!");
|
||||||
|
// 超时后取消任务,并设置为 true 以中断执行中的线程
|
||||||
|
future.cancel(true);
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
ScheduledExecutorService scheduler= (ScheduledExecutorService) DtpRegistry.getExecutor("scheduled_pool");
|
//plc断连后强制终止线程
|
||||||
|
/* try {
|
||||||
|
// 设置超时时间为 15 秒,如果任务超时,抛出 TimeoutException
|
||||||
|
future.get(15, TimeUnit.SECONDS);
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
System.out.println("任务超时,取消任务!");
|
||||||
|
// 使用反射获取 FutureTask 中的线程,并使用 Thread.stop() 强制终止
|
||||||
|
Field runnerField = future.getClass().getDeclaredField("runner");
|
||||||
|
runnerField.setAccessible(true);
|
||||||
|
Thread runnerThread = (Thread) runnerField.get(future);
|
||||||
|
if (runnerThread != null) {
|
||||||
|
runnerThread.stop(); // 强制终止线程(不推荐)
|
||||||
|
}
|
||||||
|
|
||||||
// 使用调度器在超时后取消任务
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// 使用调度器在超时后取消任务
|
||||||
scheduler.schedule(() -> {
|
scheduler.schedule(() -> {
|
||||||
if (!future.isDone()) {
|
if (!future.isDone()) {
|
||||||
|
|
||||||
|
// future.cancel(true); // 尝试中断任务
|
||||||
|
// Field runnerField = null;
|
||||||
|
// try {
|
||||||
|
// runnerField = future.getClass().getDeclaredField("runner");
|
||||||
|
// runnerField.setAccessible(true);
|
||||||
|
// Thread runnerThread = (Thread) runnerField.get(future);
|
||||||
|
// if (runnerThread != null) {
|
||||||
|
// runnerThread.stop(); // 强制终止线程(不推荐)
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 设置超时时间为 30 秒,如果任务超时,抛出 TimeoutException
|
// 设置超时时间为 30 秒,如果任务超时,抛出 TimeoutException
|
||||||
future.get(5, TimeUnit.SECONDS);
|
future.get(5, TimeUnit.SECONDS);
|
||||||
@@ -147,8 +218,15 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
|||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}, 1, TimeUnit.MILLISECONDS); // 设置超时时间为10秒
|
}, 5, TimeUnit.SECONDS); // 设置超时时间为10秒
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ public class OpcUtl {
|
|||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean is_success = true;
|
boolean is_success = true;
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
Iterator arg4 = e.keySet().iterator();
|
Iterator arg4 = e.keySet().iterator();
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ public class Task extends CommonModel<Task> implements Serializable {
|
|||||||
|
|
||||||
private String vehicle_code;
|
private String vehicle_code;
|
||||||
|
|
||||||
|
private String vehicle_code2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String vehicle_type;
|
private String vehicle_type;
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class ThreadPoolExecutorUtil {
|
|||||||
|
|
||||||
public static Executor getPoll(){
|
public static Executor getPoll(){
|
||||||
|
|
||||||
return DtpRegistry.getExecutor("cool_pool");
|
return DtpRegistry.getExecutor("dtpExecutor1");
|
||||||
|
|
||||||
/* AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
|
/* AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
|
||||||
return new ThreadPoolExecutor(
|
return new ThreadPoolExecutor(
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ public class AutoCreateInst {
|
|||||||
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
|
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
|
||||||
*/
|
*/
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
log.info("自动生成指令"+DateUtil.now());
|
|
||||||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||||
@@ -194,9 +193,8 @@ public class AutoCreateInst {
|
|||||||
} else {
|
} else {
|
||||||
instdto.setAgv_inst_type("4");
|
instdto.setAgv_inst_type("4");
|
||||||
}
|
}
|
||||||
boolean flag;
|
|
||||||
try {
|
try {
|
||||||
flag = instructionService.create(instdto);
|
instructionService.create(instdto);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
acsTask.setRemark(e.getMessage());
|
acsTask.setRemark(e.getMessage());
|
||||||
taskserver.updateByCodeFromCache(acsTask);
|
taskserver.updateByCodeFromCache(acsTask);
|
||||||
@@ -209,11 +207,9 @@ public class AutoCreateInst {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//创建指令后修改任务状态
|
//创建指令后修改任务状态
|
||||||
if (flag) {
|
|
||||||
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||||
acsTask.setUpdate_time(DateUtil.now());
|
acsTask.setUpdate_time(DateUtil.now());
|
||||||
taskserver.update(acsTask);
|
taskserver.update(acsTask);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public class CreateDDJInst {
|
|||||||
* 定时查询堆垛机任务
|
* 定时查询堆垛机任务
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
log.info("定时查询堆垛机任务"+DateUtil.now());
|
|
||||||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.nl.system.service.quartz.task;
|
package org.nl.system.service.quartz.task;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.auto.run.AutoRunService;
|
import org.nl.acs.auto.run.AutoRunService;
|
||||||
import org.nl.system.service.param.ISysParamService;
|
import org.nl.system.service.param.ISysParamService;
|
||||||
@@ -21,7 +20,6 @@ public class NdcAutoReconnection {
|
|||||||
AutoRunService autoRunService;
|
AutoRunService autoRunService;
|
||||||
|
|
||||||
public void run(String threadCode) throws Exception {
|
public void run(String threadCode) throws Exception {
|
||||||
log.info("定时NDC自动重连"+ DateUtil.now());
|
|
||||||
String[] threadCodes = threadCode.split(",");
|
String[] threadCodes = threadCode.split(",");
|
||||||
for (String code : threadCodes) {
|
for (String code : threadCodes) {
|
||||||
if (!autoRunService.getThreadByCode(code).isAlive()) {
|
if (!autoRunService.getThreadByCode(code).isAlive()) {
|
||||||
|
|||||||
@@ -51,40 +51,22 @@ spring:
|
|||||||
monitorInterval: 8
|
monitorInterval: 8
|
||||||
tomcatTp: # tomcat webserver 线程池配置
|
tomcatTp: # tomcat webserver 线程池配置
|
||||||
threadPoolAliasName: tomcat 线程池 # 线程池别名,可选
|
threadPoolAliasName: tomcat 线程池 # 线程池别名,可选
|
||||||
corePoolSize: 30
|
corePoolSize: 10
|
||||||
maximumPoolSize: 50
|
maximumPoolSize: 50
|
||||||
keepAliveTime: 60
|
keepAliveTime: 60
|
||||||
runTimeout: 10000
|
runTimeout: 10000
|
||||||
queueTimeout: 100
|
queueTimeout: 100
|
||||||
executors: # 动态线程池配置,都有默认值,采用默认值的可以不配置该项,减少配置量
|
executors: # 动态线程池配置,都有默认值,采用默认值的可以不配置该项,减少配置量
|
||||||
- threadPoolName: cool_pool # 线程池名称,必填dtpExecutor1
|
- threadPoolName: dtpExecutor1 # 线程池名称,必填
|
||||||
threadPoolAliasName: core_thread # 线程池别名,可选
|
threadPoolAliasName: core_thread # 线程池别名,可选
|
||||||
executorType: common # 线程池类型 common、eager、ordered、scheduled、priority,默认 common
|
executorType: common # 线程池类型 common、eager、ordered、scheduled、priority,默认 common
|
||||||
corePoolSize: 30 # 核心线程数,默认1
|
corePoolSize: 10 # 核心线程数,默认1
|
||||||
maximumPoolSize: 50 # 最大线程数,默认cpu核数
|
maximumPoolSize: 30 # 最大线程数,默认cpu核数
|
||||||
queueCapacity: 1024 # 队列容量,默认1024
|
queueCapacity: 1024 # 队列容量,默认1024
|
||||||
queueType: VariableLinkedBlockingQueue # 任务队列,查看源码QueueTypeEnum枚举类,默认VariableLinkedBlockingQueue
|
queueType: VariableLinkedBlockingQueue # 任务队列,查看源码QueueTypeEnum枚举类,默认VariableLinkedBlockingQueue
|
||||||
rejectedHandlerType: CallerRunsPolicy # 拒绝策略,查看RejectedTypeEnum枚举类,默认AbortPolicy
|
rejectedHandlerType: CallerRunsPolicy # 拒绝策略,查看RejectedTypeEnum枚举类,默认AbortPolicy
|
||||||
keepAliveTime: 30 # 空闲线程等待超时时间,默认60
|
keepAliveTime: 30 # 空闲线程等待超时时间,默认60
|
||||||
threadNamePrefix: core_thread # 线程名前缀,默认dtp
|
threadNamePrefix: core_thread # 线程名前缀,默认dtp
|
||||||
tryInterrupt: true
|
|
||||||
allowCoreThreadTimeOut: true # 是否允许核心线程池超时,默认false
|
|
||||||
waitForTasksToCompleteOnShutdown: true # 参考spring线程池设计,优雅关闭线程池,默认true
|
|
||||||
awaitTerminationSeconds: 5 # 优雅关闭线程池时,阻塞等待线程池中任务执行时间,默认3,单位(s)
|
|
||||||
preStartAllCoreThreads: false # 是否预热所有核心线程,默认false
|
|
||||||
runTimeout: 2000 # 任务执行超时阈值,单位(ms),默认0(不统计)
|
|
||||||
queueTimeout: 1000 # 任务在队列等待超时阈值,单位(ms),默认0(不统计)
|
|
||||||
- threadPoolName: scheduled_pool # 线程池名称,必填
|
|
||||||
threadPoolAliasName: scheduled_thread # 线程池别名,可选
|
|
||||||
executorType: scheduled # 线程池类型 common、eager、ordered、scheduled、priority,默认 common
|
|
||||||
corePoolSize: 30 # 核心线程数,默认1
|
|
||||||
maximumPoolSize: 50 # 最大线程数,默认cpu核数
|
|
||||||
queueCapacity: 1024 # 队列容量,默认1024
|
|
||||||
queueType: VariableLinkedBlockingQueue # 任务队列,查看源码QueueTypeEnum枚举类,默认VariableLinkedBlockingQueue
|
|
||||||
rejectedHandlerType: CallerRunsPolicy # 拒绝策略,查看RejectedTypeEnum枚举类,默认AbortPolicy
|
|
||||||
keepAliveTime: 30 # 空闲线程等待超时时间,默认60
|
|
||||||
threadNamePrefix: scheduled_thread # 线程名前缀,默认dtp
|
|
||||||
tryInterrupt: true
|
|
||||||
allowCoreThreadTimeOut: true # 是否允许核心线程池超时,默认false
|
allowCoreThreadTimeOut: true # 是否允许核心线程池超时,默认false
|
||||||
waitForTasksToCompleteOnShutdown: true # 参考spring线程池设计,优雅关闭线程池,默认true
|
waitForTasksToCompleteOnShutdown: true # 参考spring线程池设计,优雅关闭线程池,默认true
|
||||||
awaitTerminationSeconds: 5 # 优雅关闭线程池时,阻塞等待线程池中任务执行时间,默认3,单位(s)
|
awaitTerminationSeconds: 5 # 优雅关闭线程池时,阻塞等待线程池中任务执行时间,默认3,单位(s)
|
||||||
|
|||||||
Reference in New Issue
Block a user