OCT
REM: 1. 修改停止清洗任务接口 2. 修改通过任务Id和设备Id获取的任务信息类型 3. 修改数据库测试用例
This commit is contained in:
parent
82b391b77a
commit
b36835cc48
|
@ -112,11 +112,6 @@ public class HaoHanImpl implements DisposeEntryManager {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_HAOHAN_ERROR, null);
|
return new MulReturnType<>(ErrorCode.ERR_HAOHAN_ERROR, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rsp.getState() != ErrorCode.ERR_OK.getCode()) {
|
|
||||||
log.error("----Error Haohan stop task {} return error: {}, {}", devTaskId, rsp.getState(), rsp.getMsg());
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_HAOHAN_ERROR, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("----Finish Haohan Stop Cleanup Task: {}", devTaskId);
|
log.info("----Finish Haohan Stop Cleanup Task: {}", devTaskId);
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||||
}catch (JsonProcessingException e) {
|
}catch (JsonProcessingException e) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ public interface TaskInfoMapper extends Mapper<TaskInfo>, MySqlMapper<TaskInfo>
|
||||||
* @param deviceId the device id
|
* @param deviceId the device id
|
||||||
* @return the task info
|
* @return the task info
|
||||||
*/
|
*/
|
||||||
List<TaskInfo> getTaskInfo(@Param("taskId") Long taskId,
|
TaskInfo getTaskInfo(@Param("taskId") Long taskId,
|
||||||
@Param("deviceId") Long deviceId);
|
@Param("deviceId") Long deviceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -254,34 +254,28 @@ public class TaskServiceImpl implements TaskService {
|
||||||
dev.forEach(k -> {
|
dev.forEach(k -> {
|
||||||
DisposeEntryManager dp = DeviceRouter.getDeviceRouterFactory(k.getType(), k.getIpAddr());
|
DisposeEntryManager dp = DeviceRouter.getDeviceRouterFactory(k.getType(), k.getIpAddr());
|
||||||
|
|
||||||
List<TaskInfo> taskInfoList = taskInfoMapper.getTaskInfo(taskId, k.getId());
|
TaskInfo taskInfo = taskInfoMapper.getTaskInfo(taskId, k.getId());
|
||||||
|
|
||||||
taskInfoList.forEach(t -> {
|
// 异步启动处置任务
|
||||||
if (t.getExternId() == null) {
|
CompletableFuture.supplyAsync(() -> dp.stopDispose(task.getDisposeIp(), DeviceCapacity.values()[task.getType()], taskInfo.getExternId()))
|
||||||
t.setExternId(-1L);
|
.whenComplete((v, ex) -> {
|
||||||
}
|
if (ex != null) {
|
||||||
|
// 恢复缓存中任务状态到先前状态
|
||||||
// 异步启动处置任务
|
taskCacheManager.upgradeTaskStatus(taskId, prdStatus);
|
||||||
CompletableFuture.supplyAsync(() -> dp.stopDispose(task.getDisposeIp(), DeviceCapacity.values()[task.getType()], t.getExternId()))
|
log.error("Stop task: taskId:{}, error:{}", taskId, ex.getMessage());
|
||||||
.whenComplete((v, ex) -> {
|
} else {
|
||||||
if (ex != null) {
|
if (v.getFirstParam() != ErrorCode.ERR_OK) {
|
||||||
// 恢复缓存中任务状态到先前状态
|
// 恢复缓存中任务状态到先前状态
|
||||||
taskCacheManager.upgradeTaskStatus(taskId, prdStatus);
|
taskCacheManager.upgradeTaskStatus(taskId, prdStatus);
|
||||||
log.error("Stop task: taskId:{}, error:{}", taskId, ex.getMessage());
|
log.error("Stop task: taskId:{}, error:{}", taskId, v.getFirstParam().getMsg());
|
||||||
} else {
|
} else {
|
||||||
if (v.getFirstParam() != ErrorCode.ERR_OK) {
|
// 任务执行完成后更新数据库处置任务状态
|
||||||
// 恢复缓存中任务状态到先前状态
|
finishTask(taskId);
|
||||||
taskCacheManager.upgradeTaskStatus(taskId, prdStatus);
|
log.info("Stop task finished: taskId:{}, disposeId:{}, type:{}",
|
||||||
log.error("Stop task: taskId:{}, error:{}", taskId, v.getFirstParam().getMsg());
|
taskId, task.getDisposeIp(), task.getType());
|
||||||
} else {
|
|
||||||
// 任务执行完成后更新数据库处置任务状态
|
|
||||||
finishTask(taskId);
|
|
||||||
log.info("Stop task finished: taskId:{}, disposeId:{}, type:{}",
|
|
||||||
taskId, task.getDisposeIp(), task.getType());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
log.error("No such task: taskId:{}", taskId);
|
log.error("No such task: taskId:{}", taskId);
|
||||||
|
|
|
@ -133,10 +133,10 @@ public class TaskInfoMapperTest extends InitTestEnvironment {
|
||||||
for (TaskInfoDetail task : taskInfoDetailList
|
for (TaskInfoDetail task : taskInfoDetailList
|
||||||
) {
|
) {
|
||||||
log.info("taskId-->{}, deviceId-->{}", task.getId(), task.getDeviceId());
|
log.info("taskId-->{}, deviceId-->{}", task.getId(), task.getDeviceId());
|
||||||
List<TaskInfo> taskInfoList = taskInfoMapper.getTaskInfo(task.getId(), task.getDeviceId());
|
TaskInfo taskInfo = taskInfoMapper.getTaskInfo(task.getId(), task.getDeviceId());
|
||||||
if (taskInfoList.size() > 0) {
|
if (taskInfo != null) {
|
||||||
Assert.assertNotEquals(taskInfoList.size(), 0);
|
Assert.assertNotNull(taskInfo);
|
||||||
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(taskInfoList));
|
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(taskInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue