diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 4e58646..3eceeaa 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -710,6 +710,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu JSONObject json = (JSONObject) JSONObject.toJSON(entity); wo.update(json); + removeByCodeFromCache(entity.getInstruction_code()); JSONObject taskjson = taskwo.query("task_id ='" + insttaskid + "'").uniqueResult(0); TaskDto obj = taskjson.toJavaObject(TaskDto.class); // =0 则不用再次请求 @@ -721,7 +722,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } } - removeByCodeFromCache(entity.getInstruction_code()); // this.reload(); } 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 890278d..b517f08 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 @@ -100,8 +100,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } public synchronized void reload() { - List list = this.queryAll("task_status <2 and is_delete =0 order by create_time"); - +// System.out.println("我点击了同步按钮"); + List list = this.queryAll("task_status < 2 and is_delete =0 order by create_time"); +// for (TaskDto taskDto : list) { +// System.out.println("我点击了同步按钮,更新数据库,查询出未完成的任务为:" + taskDto.getTask_code() + "任务状态为:" + taskDto.getTask_status()); +// } tasks = new CopyOnWriteArrayList<>(list); } @@ -114,7 +117,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } @Override - public List queryAllFromCacheByStatus(String task_status){ + public List queryAllFromCacheByStatus(String task_status) { return Optional.ofNullable(this.tasks) .orElse(new CopyOnWriteArrayList<>()) .stream() @@ -676,7 +679,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } @Override - @Transactional(rollbackFor = Exception.class) +// @Transactional(rollbackFor = Exception.class) public void update(TaskDto dto) { TaskDto entity = this.findById(dto.getTask_id()); @@ -693,8 +696,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { JSONObject json = (JSONObject) JSONObject.toJSON(dto); wo.update(json); +// System.out.println("我点击了....修改数据库的状态为执行中...任务号" + dto.getTask_code()); - Iterator iterator = tasks.iterator(); +// Iterator iterator = tasks.iterator(); // while (iterator.hasNext()) { // TaskDto task = iterator.next(); // if (task.getTask_code().equals(dto.getTask_code())) { @@ -704,6 +708,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { removeByCodeFromCache(entity.getTask_code()); +// System.out.println("我点击了....修改内存中的状态为执行中...任务号" + dto.getTask_code()); + if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) { tasks.add(dto); @@ -759,9 +765,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } else { int status = 0; JSONObject jo = new JSONObject(); - if (body == null){ + if (body == null) { status = 400; - }else { + } else { status = body.getStatus(); jo = JSONObject.parseObject(body.body()); } 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 cb345a8..b5b9a69 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 @@ -43,6 +43,11 @@ public class AutoCreateInst { RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); List list = taskserver.queryAllFromCacheByStatus("0"); +// System.out.println("进来了....我点击了"); +// for (TaskDto taskDto : list2) { +// System.out.println("我点击了 任务号:" + taskDto.getTask_code()); +// } +// System.out.println("进来了....我点击了"); 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() { @@ -95,16 +100,23 @@ public class AutoCreateInst { } } if (flag) { - // acsTask.setRemark("同列终点已存在,创建指令失败"); + // acsTask.setRemark("同列终点已存在,创建指令失败"); //taskserver.updateByCodeFromCache(acsTask); continue; } } } Boolean flag2 = false; + +// if ("3-7".equals(nextDevice.getDevice_code())) { +// Thread.sleep(60000); +// } List list2 = taskserver.queryAllFromCacheByStatus("1"); + if (CollUtil.isNotEmpty(list2)) { + System.out.println("size:" + list2.size()); for (TaskDto taskDto : list2) { + System.out.println(taskDto.getNext_device_code()); if (taskDto.getTask_type().equals(acsTask.getTask_type())) { if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver(); @@ -268,6 +280,8 @@ public class AutoCreateInst { acsTask.setTask_status("1"); acsTask.setRemark(""); taskserver.update(acsTask); + list2.add(acsTask); +// System.out.println("我点击了....往list2中添加任务号为:" + acsTask.getTask_code()); } } } \ No newline at end of file