From ce1b322793619b1630566c59b78ed44401c4cfea Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Thu, 13 Jun 2024 10:04:21 +0800 Subject: [PATCH] =?UTF-8?q?rev:=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/acs/task/service/TaskService.java | 3 ++ .../task/service/impl/TaskServiceImpl.java | 23 +++++++++++++-- .../modules/quartz/task/AutoCreateInst.java | 28 +++++++++---------- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java index 44fbc41..feb3ddd 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java @@ -60,6 +60,9 @@ public interface TaskService { List queryAll(String whereJson); + List queryAllFromCacheByStatus(String task_status); + + /** * 查询所有数据不分页 * diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index acfb2d3..890278d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -113,6 +113,16 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { return list; } + @Override + public List queryAllFromCacheByStatus(String task_status){ + return Optional.ofNullable(this.tasks) + .orElse(new CopyOnWriteArrayList<>()) + .stream() + .filter(taskDto -> taskDto.getTask_status().equals(task_status)) + .sorted(Comparator.comparing(TaskDto::getCreate_time)) + .collect(Collectors.toList()); + } + @Override public Map queryAll(Map whereJson, Pageable page) { @@ -747,8 +757,15 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { taskFeedbackService.update(feefbackdto); } } else { - int status = body.getStatus(); - JSONObject jo = JSONObject.parseObject(body.body()); + int status = 0; + JSONObject jo = new JSONObject(); + if (body == null){ + status = 400; + }else { + status = body.getStatus(); + jo = JSONObject.parseObject(body.body()); + } + if (ObjectUtil.isEmpty(feefbackdto)) { feefbackdto = new TaskFeedbackDto(); feefbackdto.setTask_id(entity.getTask_id()); @@ -756,7 +773,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { feefbackdto.setTask_status(entity.getTask_status()); feefbackdto.setVehicle_type(entity.getVehicle_type()); feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setError_code(String.valueOf(body.getStatus())); + feefbackdto.setError_code(String.valueOf(status)); feefbackdto.setStart_device_code(entity.getStart_device_code()); feefbackdto.setStart_point_code(entity.getNext_point_code()); feefbackdto.setNext_device_code(entity.getNext_device_code()); diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index 772f2c3..cb345a8 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java @@ -42,8 +42,7 @@ public class AutoCreateInst { InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - List list = taskserver.queryAll("task_status = '0' ORDER BY create_time ASC"); - List list2 = taskserver.queryAll("task_status = '1' ORDER BY create_time ASC"); + List list = taskserver.queryAllFromCacheByStatus("0"); Map> collect = list.stream().sorted(Comparator.comparing(TaskDto::getCreate_time).thenComparing(TaskDto::getTask_code)) .collect(Collectors.groupingBy(TaskDto::getPriority)); TreeMap> treeMap = new TreeMap<>(new Comparator() { @@ -80,8 +79,8 @@ public class AutoCreateInst { } } if (flag) { - acsTask.setRemark("同列起点已存在,创建指令失败"); - taskserver.update(acsTask); + //acsTask.setRemark("同列起点已存在,创建指令失败"); + //taskserver.updateByCodeFromCache(acsTask); continue; } } else if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { @@ -96,13 +95,14 @@ public class AutoCreateInst { } } if (flag) { - acsTask.setRemark("同列起点已存在,创建指令失败"); - taskserver.update(acsTask); + // acsTask.setRemark("同列终点已存在,创建指令失败"); + //taskserver.updateByCodeFromCache(acsTask); continue; } } } Boolean flag2 = false; + List list2 = taskserver.queryAllFromCacheByStatus("1"); if (CollUtil.isNotEmpty(list2)) { for (TaskDto taskDto : list2) { if (taskDto.getTask_type().equals(acsTask.getTask_type())) { @@ -122,8 +122,8 @@ public class AutoCreateInst { } } if (flag) { - acsTask.setRemark("同列起点已存在,创建指令失败"); - taskserver.update(acsTask); + //acsTask.setRemark("同列起点已存在,创建指令失败"); + //taskserver.updateByCodeFromCache(acsTask); flag2 = true; break; } @@ -143,8 +143,8 @@ public class AutoCreateInst { } } if (flag) { - acsTask.setRemark("同列起点已存在,创建指令失败"); - taskserver.update(acsTask); + //acsTask.setRemark("同列终点已存在,创建指令失败"); + //taskserver.updateByCodeFromCache(acsTask); flag2 = true; break; } @@ -192,8 +192,8 @@ public class AutoCreateInst { //校验路由关系 List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); if (ObjectUtils.isEmpty(shortPathsList)) { - acsTask.setRemark("路由不通无法生成指令"); - taskserver.updateByCodeFromCache(acsTask); + //acsTask.setRemark("路由不通无法生成指令"); + //taskserver.updateByCodeFromCache(acsTask); continue; } @@ -259,8 +259,8 @@ public class AutoCreateInst { try { instructionService.create(instdto); } catch (Exception e) { - acsTask.setRemark(e.getMessage()); - taskserver.updateByCodeFromCache(acsTask); + //acsTask.setRemark(e.getMessage()); + //taskserver.updateByCodeFromCache(acsTask); log.info("自动创建指令失败{}", e.getMessage()); continue; }