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(),