package com.doumee.api; import com.doumee.dao.admin.request.CollectionMediaSyncRequest; import com.doumee.service.business.CollectionMediaSyncService; import com.doumee.service.business.CollectionStationService; import com.doumee.service.business.third.model.ApiResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Calendar; import java.util.Date; @Api(tags = "海康采集站定时器接口") @Slf4j @RestController @RequestMapping("/timer/collectionStation") public class HkCollectionStationTimerController extends BaseController { @Autowired private CollectionStationService collectionStationService; @Autowired private CollectionMediaSyncService collectionMediaSyncService; @ApiOperation("定时同步采集站在线状态") @PostMapping("/syncStations") public ApiResponse syncStations() { log.info("定时任务:同步采集站状态"); return ApiResponse.success(collectionStationService.syncAllStations()); } @ApiOperation("定时同步采集站媒体索引并批量下载") @PostMapping("/syncMediaAndDownload") public ApiResponse syncMediaAndDownload() { log.info("定时任务:同步采集站媒体索引"); CollectionMediaSyncRequest request = new CollectionMediaSyncRequest(); Calendar cal = Calendar.getInstance(); request.setEndTime(cal.getTime()); cal.add(Calendar.HOUR_OF_DAY, -24); request.setStartTime(cal.getTime()); String syncResult = collectionMediaSyncService.syncMediaList(request); String downloadResult = collectionMediaSyncService.batchDownload(request); return ApiResponse.success(syncResult + ";" + downloadResult); } }