You've already forked FrameTour-BE
refactor(order): 优化订单相关代码
- 修改了多个模块中的方法名称,使其更加准确地反映功能 - 优化了部分代码逻辑,提高了可读性和维护性 - 增加了获取
This commit is contained in:
@@ -3,7 +3,6 @@ package com.ycwl.basic.repository;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ycwl.basic.utils.JacksonUtil;
|
||||
import com.ycwl.basic.mapper.TaskMapper;
|
||||
import com.ycwl.basic.mapper.VideoMapper;
|
||||
import com.ycwl.basic.model.pc.task.entity.TaskEntity;
|
||||
import com.ycwl.basic.model.pc.task.resp.TaskRespVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -11,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -68,7 +68,35 @@ public class VideoTaskRepository {
|
||||
return shotTime;
|
||||
}
|
||||
|
||||
public Integer getTaskDeviceCount(Long taskId) {
|
||||
public Integer getTaskDeviceNum(Long taskId) {
|
||||
TaskEntity task = getTaskById(taskId);
|
||||
if (task == null) {
|
||||
return 1;
|
||||
}
|
||||
Map<String, Object> paramJson = JacksonUtil.parseObject(task.getTaskParams(), Map.class);
|
||||
if (paramJson == null) {
|
||||
return 1;
|
||||
}
|
||||
List<String> deviceIds = new ArrayList<>();
|
||||
List<String> templatePlaceholder = templateRepository.getTemplatePlaceholder(task.getTemplateId());
|
||||
paramJson.entrySet().stream()
|
||||
.filter(entry -> StringUtils.isNumeric(entry.getKey()))
|
||||
.forEach(entry -> {
|
||||
List<Object> jsonArray = JacksonUtil.parseArray(JacksonUtil.toJSONString(entry.getValue()), Object.class);
|
||||
if (jsonArray != null && !jsonArray.isEmpty()) {
|
||||
for (Object ignored : jsonArray) {
|
||||
if (templatePlaceholder.contains(entry.getKey())) {
|
||||
if (!deviceIds.contains(entry.getKey())) {
|
||||
deviceIds.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return deviceIds.size();
|
||||
}
|
||||
|
||||
public Integer getTaskLensNum(Long taskId) {
|
||||
TaskEntity task = getTaskById(taskId);
|
||||
if (task == null) {
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user