You've already forked FrameTour-BE
refactor(task): 重构任务拍摄时间获取逻辑
- 将 getTaskShotDate 方法从 TaskTaskServiceImpl 移至 VideoTaskRepository - 删除对 TaskService 和 TaskTaskServiceImpl 的依赖注入 - 更新 LyCompatibleController 和 GoodsServiceImpl 中的调用方式 - 简化日期解析逻辑,提高代码可读性 - 移除冗余的 VideoMapper 和 TaskService 接口方法声明 - 统一使用 VideoTaskRepository 处理任务相关数据查询
This commit is contained in:
@@ -58,10 +58,6 @@ public class LyCompatibleController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private VideoRepository videoRepository;
|
private VideoRepository videoRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private VideoMapper videoMapper;
|
|
||||||
@Autowired
|
|
||||||
private TaskTaskServiceImpl taskTaskServiceImpl;
|
|
||||||
@Autowired
|
|
||||||
private RedisTemplate<String, String> redisTemplate;
|
private RedisTemplate<String, String> redisTemplate;
|
||||||
@Autowired
|
@Autowired
|
||||||
private VideoTaskRepository videoTaskRepository;
|
private VideoTaskRepository videoTaskRepository;
|
||||||
@@ -217,7 +213,7 @@ public class LyCompatibleController {
|
|||||||
map.put("face_id", String.valueOf(videoRespVO.getFaceId()));
|
map.put("face_id", String.valueOf(videoRespVO.getFaceId()));
|
||||||
}
|
}
|
||||||
map.put("template_cover_image", contentPageVO.getTemplateCoverUrl());
|
map.put("template_cover_image", contentPageVO.getTemplateCoverUrl());
|
||||||
Date taskShotDate = taskTaskServiceImpl.getTaskShotDate(videoRespVO.getTaskId());
|
Date taskShotDate = videoTaskRepository.getTaskShotDate(videoRespVO.getTaskId());
|
||||||
map.put("shoottime", DateUtil.format(taskShotDate, "yyyy-MM-dd HH:mm"));
|
map.put("shoottime", DateUtil.format(taskShotDate, "yyyy-MM-dd HH:mm"));
|
||||||
map.put("openid", openId);
|
map.put("openid", openId);
|
||||||
map.put("scenicname", contentPageVO.getScenicName());
|
map.put("scenicname", contentPageVO.getScenicName());
|
||||||
|
|||||||
@@ -53,29 +53,6 @@ public class VideoTaskRepository {
|
|||||||
redisTemplate.delete(String.format(TASK_CACHE_KEY, taskId));
|
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) {
|
public Integer getTaskDeviceNum(Long taskId) {
|
||||||
TaskEntity task = getTaskById(taskId);
|
TaskEntity task = getTaskById(taskId);
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
@@ -131,6 +108,32 @@ public class VideoTaskRepository {
|
|||||||
return deviceCount.get();
|
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
|
* @param taskId 任务ID
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ import com.ycwl.basic.service.mobile.GoodsService;
|
|||||||
import com.ycwl.basic.repository.TemplateRepository;
|
import com.ycwl.basic.repository.TemplateRepository;
|
||||||
import com.ycwl.basic.config.VideoUpdateConfig;
|
import com.ycwl.basic.config.VideoUpdateConfig;
|
||||||
import com.ycwl.basic.model.repository.TaskUpdateResult;
|
import com.ycwl.basic.model.repository.TaskUpdateResult;
|
||||||
import com.ycwl.basic.service.task.TaskService;
|
|
||||||
import com.ycwl.basic.storage.StorageFactory;
|
import com.ycwl.basic.storage.StorageFactory;
|
||||||
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
||||||
import com.ycwl.basic.storage.enums.StorageAcl;
|
import com.ycwl.basic.storage.enums.StorageAcl;
|
||||||
@@ -88,8 +87,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private VideoTaskRepository videoTaskRepository;
|
private VideoTaskRepository videoTaskRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TaskService taskTaskService;
|
|
||||||
@Autowired
|
|
||||||
private ScenicRepository scenicRepository;
|
private ScenicRepository scenicRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderBiz orderBiz;
|
private OrderBiz orderBiz;
|
||||||
@@ -244,7 +241,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|||||||
goodsDetailVO.setIsBuy(1);
|
goodsDetailVO.setIsBuy(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goodsDetailVO.setShotTime(taskTaskService.getTaskShotDate(video.getTaskId()));
|
goodsDetailVO.setShotTime(videoTaskRepository.getTaskShotDate(video.getTaskId()));
|
||||||
goodsDetailVO.setLensNum(videoTaskRepository.getTaskLensNum(video.getTaskId()));
|
goodsDetailVO.setLensNum(videoTaskRepository.getTaskLensNum(video.getTaskId()));
|
||||||
goodsDetailVO.setDevicesNum(videoTaskRepository.getTaskDeviceNum(video.getTaskId()));
|
goodsDetailVO.setDevicesNum(videoTaskRepository.getTaskDeviceNum(video.getTaskId()));
|
||||||
CouponRecordQueryResp couponRecord = couponBiz.queryUserCouponRecord(video.getScenicId(), userId, video.getFaceId(), video.getTemplateId().toString());
|
CouponRecordQueryResp couponRecord = couponBiz.queryUserCouponRecord(video.getScenicId(), userId, video.getFaceId(), video.getTemplateId().toString());
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import com.ycwl.basic.model.task.req.TaskSuccessReqVo;
|
|||||||
import com.ycwl.basic.model.task.req.WorkerAuthReqVo;
|
import com.ycwl.basic.model.task.req.WorkerAuthReqVo;
|
||||||
import com.ycwl.basic.model.task.resp.TaskSyncRespVo;
|
import com.ycwl.basic.model.task.resp.TaskSyncRespVo;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public interface TaskService {
|
public interface TaskService {
|
||||||
TaskSyncRespVo handleSyncTask(TaskReqVo req);
|
TaskSyncRespVo handleSyncTask(TaskReqVo req);
|
||||||
|
|
||||||
@@ -28,8 +26,6 @@ public interface TaskService {
|
|||||||
|
|
||||||
void autoCreateTaskByFaceId(Long faceId);
|
void autoCreateTaskByFaceId(Long faceId);
|
||||||
|
|
||||||
Date getTaskShotDate(Long taskId);
|
|
||||||
|
|
||||||
void sendVideoGeneratedServiceNotification(Long taskId, Long memberId);
|
void sendVideoGeneratedServiceNotification(Long taskId, Long memberId);
|
||||||
|
|
||||||
TaskRespVO taskInfo(Long taskId);
|
TaskRespVO taskInfo(Long taskId);
|
||||||
|
|||||||
@@ -591,33 +591,6 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
memberVideo.forEach(item -> sendVideoGeneratedServiceNotification(taskId, item.getMemberId()));
|
memberVideo.forEach(item -> sendVideoGeneratedServiceNotification(taskId, item.getMemberId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getTaskShotDate(Long taskId) {
|
|
||||||
TaskRespVO taskRespVO = taskMapper.getById(taskId);
|
|
||||||
if (taskRespVO == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Date shotTime = taskRespVO.getCreateTime();
|
|
||||||
Map<String, Object> paramJson = JacksonUtil.parseObject(taskRespVO.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendVideoGeneratedServiceNotification(Long taskId, Long memberId) {
|
public void sendVideoGeneratedServiceNotification(Long taskId, Long memberId) {
|
||||||
MemberVideoEntity item = videoMapper.queryRelationByMemberTask(memberId, taskId);
|
MemberVideoEntity item = videoMapper.queryRelationByMemberTask(memberId, taskId);
|
||||||
|
|||||||
Reference in New Issue
Block a user