refactor(task): 重构任务拍摄时间获取逻辑

- 将 getTaskShotDate 方法从 TaskTaskServiceImpl 移至 VideoTaskRepository
- 删除对 TaskService 和 TaskTaskServiceImpl 的依赖注入
- 更新 LyCompatibleController 和 GoodsServiceImpl 中的调用方式
- 简化日期解析逻辑,提高代码可读性
- 移除冗余的 VideoMapper 和 TaskService 接口方法声明
- 统一使用 VideoTaskRepository 处理任务相关数据查询
This commit is contained in:
2025-12-15 17:33:40 +08:00
parent 832f6a2339
commit c0f07ee9f4
5 changed files with 28 additions and 63 deletions

View File

@@ -53,29 +53,6 @@ public class VideoTaskRepository {
redisTemplate.delete(String.format(TASK_CACHE_KEY, taskId));
}
public Date getTaskShotDate(Long taskId) {
TaskRespVO taskRespVO = taskMapper.getById(taskId);
if (taskRespVO == null) {
return null;
}
Date shotTime = taskRespVO.getCreateTime();
JacksonUtil.JSONObjectCompat paramJson = JacksonUtil.JSONObjectCompat.parseObject(taskRespVO.getTaskParams());
if (paramJson != null) {
Optional<String> any = paramJson.keySet().stream().filter(StringUtils::isNumeric).findAny();
if (any.isPresent()) {
var jsonArray = paramJson.getJSONArray(any.get());
if (jsonArray != null && !jsonArray.isEmpty()) {
JacksonUtil.JSONObjectCompat jsonObject = jsonArray.get(0);
if (jsonObject.getString("createTime") != null) {
shotTime = DateUtil.parse(jsonObject.getString("createTime"));
}
}
}
}
return shotTime;
}
public Integer getTaskDeviceNum(Long taskId) {
TaskEntity task = getTaskById(taskId);
if (task == null) {
@@ -131,6 +108,32 @@ public class VideoTaskRepository {
return deviceCount.get();
}
public Date getTaskShotDate(Long taskId) {
TaskEntity task = getTaskById(taskId);
if (task == null) {
return null;
}
Date shotTime = task.getCreateTime();
Map<String, Object> paramJson = JacksonUtil.parseObject(task.getTaskParams(), Map.class);
if (paramJson != null) {
Optional<String> any = paramJson.keySet().stream().filter(StringUtils::isNumeric).findAny();
if (any.isPresent()) {
@SuppressWarnings("unchecked")
List<Map<String, Object>> jsonArray = (List<Map<String, Object>>) paramJson.get(any.get());
if (jsonArray != null && !jsonArray.isEmpty()) {
Map<String, Object> jsonObject = jsonArray.get(0);
if (jsonObject.containsKey("createTime")) {
Object createTimeObj = jsonObject.get("createTime");
if (createTimeObj instanceof Number) {
shotTime = new Date(((Number) createTimeObj).longValue());
}
}
}
}
}
return shotTime;
}
/**
* 检查任务是否可以更新
* @param taskId 任务ID