From bf512cab01104da0c963a08fc9e12697f5dc55f7 Mon Sep 17 00:00:00 2001 From: HuangXin Date: Tue, 19 Jan 2021 10:43:41 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E5=A2=9E=E5=8A=A0=E5=A4=84?= =?UTF-8?q?=E7=BD=AE=E8=AE=BE=E5=A4=87=E6=B7=BB=E5=8A=A0=E5=A4=84=E7=BD=AE?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=A4=B1=E8=B4=A5=E5=90=8E=E9=87=8D=E8=AF=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dispose/manager/DeviceTaskManager.java | 9 +++++++++ .../manager/impl/DeviceTaskManagerImpl.java | 20 +++++++++++++++---- .../impl/DeviceTaskManagerServiceImpl.java | 9 +++++++-- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/dispose/manager/DeviceTaskManager.java b/src/main/java/com/dispose/manager/DeviceTaskManager.java index 1e9f555b..c247935a 100644 --- a/src/main/java/com/dispose/manager/DeviceTaskManager.java +++ b/src/main/java/com/dispose/manager/DeviceTaskManager.java @@ -136,6 +136,15 @@ public interface DeviceTaskManager { */ DeviceTask getTaskById(Long id); + /** + * Device task created boolean. + * + * @param taskId the task id + * @param devId the dev id + * @return the boolean + */ + boolean deviceTaskCreated(Long taskId, Long devId); + /** * Gets peng xin task. * diff --git a/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java b/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java index 608040c6..0247aae3 100644 --- a/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java +++ b/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java @@ -25,6 +25,18 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { @Resource private DeviceTaskMapper deviceTaskMapper; + /** + * Device task created boolean. + * + * @param taskId the task id + * @param devId the dev id + * @return the boolean + */ + @Override + public boolean deviceTaskCreated(Long taskId, Long devId) { + return deviceTaskMapper.getTaskByDetails(taskId, devId).size() != 0; + } + /** * Add dispose device task info boolean. * @@ -80,11 +92,11 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { } /** - * Change dispose device task info dev status long. + * Change dispose device task info dev status int. * * @param id the id * @param devStatus the dev status - * @return the long + * @return the int */ @Override public int changeDisposeDeviceTaskInfoDevStatus(Long id, Long devStatus) { @@ -297,9 +309,9 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager { } /** - * Gets PengXin device task info. + * Get peng xin task list. * - * @return the minId task info. + * @return the list */ @Override public List getPengXinTask(){ diff --git a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java index f11e1814..0116645f 100644 --- a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java @@ -462,7 +462,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { } // 对新建的任务,创建对应处置设备任务信息 - for (DisposeTask v : disposeTaskManager.getNewDisposeTasks()) { + for (DisposeTask v : disposeTaskManager.getExpiredTasks()) { // 设置任务状态, 开始创建任务 disposeTaskManager.changeDisposeTaskStatus(v.getId(), DisposeTaskStatus.TASK_STARTING); @@ -482,8 +482,13 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { // 判断设备是否就绪 .filter(c -> c.getDb().deviceReady()) .forEach(d -> { - log.info("Add dispose task for device: {}", d.getDev()); + // 检查当前设备是否已经创建了该任务 + if (deviceTaskManager.deviceTaskCreated(v.getId(), + d.getDev().getId())) { + return; + } + log.info("Add dispose task for device: {}", d.getDev()); if (!deviceTaskManager .addDisposeDeviceTaskInfo(v.getId(), d.getDev().getId(),