各种sql、缓存优化

This commit is contained in:
2025-06-17 14:12:31 +08:00
parent 5895d9c56f
commit fae62ab7c2
11 changed files with 155 additions and 101 deletions

View File

@@ -45,6 +45,7 @@ import com.ycwl.basic.notify.entity.NotifyContent;
import com.ycwl.basic.notify.enums.NotifyType;
import com.ycwl.basic.repository.DeviceRepository;
import com.ycwl.basic.repository.FaceRepository;
import com.ycwl.basic.repository.RenderWorkerRepository;
import com.ycwl.basic.repository.ScenicRepository;
import com.ycwl.basic.repository.VideoRepository;
import com.ycwl.basic.repository.VideoTaskRepository;
@@ -81,14 +82,10 @@ import java.util.stream.Collectors;
@Slf4j
@Service
public class TaskTaskServiceImpl implements TaskService {
@Autowired
private TemplateMapper templateMapper;
@Autowired
private RenderWorkerMapper renderWorkerMapper;
@Autowired
private TaskMapper taskMapper;
@Autowired
private RedisTemplate<String, String> redisTemplate;
private RenderWorkerRepository repository;
@Autowired
private FaceMapper faceMapper;
@Autowired
@@ -124,13 +121,12 @@ public class TaskTaskServiceImpl implements TaskService {
@Autowired
private VideoReUploader videoReUploader;
private RenderWorkerEntity getWorker(@NonNull WorkerAuthReqVo req) {
String accessKey = req.getAccessKey();
if (accessKey == null) {
return null;
}
return renderWorkerMapper.findByAccessKey(accessKey);
return repository.getWorkerByAccessKey(accessKey);
}
@Override
@@ -144,23 +140,7 @@ public class TaskTaskServiceImpl implements TaskService {
worker.setStatus(null);
// get status
ClientStatusReqVo clientStatus = req.getClientStatus();
if (clientStatus != null) {
// 临时这么用下
worker.setCpuCount(clientStatus.getCpu_count());
worker.setCpuUsage(clientStatus.getCpu_usage());
// 上报的是字节,存储的是兆
worker.setMemoryAvailable(clientStatus.getMemory_available().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
worker.setMemoryTotal(clientStatus.getMemory_total().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
worker.setPlatform(clientStatus.getPlatform());
worker.setRuntimeVersion(clientStatus.getRuntime_version());
worker.setSupportFeature(String.join(",", clientStatus.getSupport_feature()));
worker.setVersion(clientStatus.getVersion());
worker.setUpdateAt(new Date());
redisTemplate.opsForValue().set(TaskConstant.TASK_ONLINE_WORKER_KEY_PFX + worker.getId(), JSON.toJSONString(clientStatus), 60, TimeUnit.SECONDS);
}
renderWorkerMapper.update(worker);
repository.setWorkerHostStatus(worker.getId(), clientStatus);
TaskSyncRespVo resp = new TaskSyncRespVo();
// Template
List<TemplateRespVO> updTemplateList;