2025-07-04 14:57:13 +08:00
|
|
|
|
package com.zhgd.xmgl.task;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
|
import com.zhgd.xmgl.call.api.PoliceCameraManufacturer;
|
|
|
|
|
|
import com.zhgd.xmgl.call.factory.PoliceCameraManufacturerFactory;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.policecamera.service.IProjectPoliceCameraConfigService;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.project.entity.Project;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
2025-10-24 17:56:25 +08:00
|
|
|
|
import com.zhgd.xmgl.util.AsyncTaskUtil;
|
2025-07-04 14:57:13 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2025-07-25 10:35:03 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
2025-07-04 14:57:13 +08:00
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
2025-07-25 10:35:03 +08:00
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
2025-07-04 14:57:13 +08:00
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("xmgl/task")
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
public class Mcs8Task {
|
|
|
|
|
|
@Lazy
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
IProjectService projectService;
|
|
|
|
|
|
@Lazy
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IProjectPoliceCameraConfigService projectPoliceCameraConfigService;
|
|
|
|
|
|
@Lazy
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private PoliceCameraManufacturerFactory policeCameraManufacturerFactory;
|
2025-07-25 10:35:03 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
@Qualifier("doubleCarbonExecutor")
|
|
|
|
|
|
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
2025-07-04 14:57:13 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 定时从Mcs8获取执法记录仪文件
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Scheduled(cron = "0 */5 * * * ?")
|
|
|
|
|
|
@RequestMapping("getPoliceCameraItemFile")
|
|
|
|
|
|
public void getPoliceCameraItemFile() {
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
List<Project> projects = projectService.list();
|
|
|
|
|
|
for (Project project : projects) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
PoliceCameraManufacturer manufacturer = policeCameraManufacturerFactory.getPoliceCameraManufacturer(project.getProjectSn());
|
|
|
|
|
|
if (manufacturer != null) {
|
2025-10-24 17:56:25 +08:00
|
|
|
|
AsyncTaskUtil.runAsync(() -> {
|
2025-07-25 10:35:03 +08:00
|
|
|
|
manufacturer.pullFile(DateUtil.offsetDay(now, -7), now);
|
2025-10-24 17:56:25 +08:00
|
|
|
|
});
|
2025-07-04 14:57:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("定时从Mcs8获取执法记录仪文件err,{}", project.getProjectName(), e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 定时更新执法仪设备状态
|
|
|
|
|
|
*/
|
2025-10-29 16:43:59 +08:00
|
|
|
|
@Scheduled(cron = "*/30 * * * * ?")
|
2025-07-04 14:57:13 +08:00
|
|
|
|
@RequestMapping("updateStatus")
|
|
|
|
|
|
public void updateStatus() {
|
|
|
|
|
|
List<Project> projects = projectService.list();
|
|
|
|
|
|
for (Project project : projects) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
PoliceCameraManufacturer manufacturer = policeCameraManufacturerFactory.getPoliceCameraManufacturer(project.getProjectSn());
|
|
|
|
|
|
if (manufacturer != null) {
|
|
|
|
|
|
manufacturer.updateStatus();
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("定时更新执法仪设备状态err,{}", project.getProjectName(), e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|