package com.mosty.qwzx.task;

import com.mosty.base.model.dto.qwzx.TbQwSearchJlqdDto;
import com.mosty.base.utils.Constant;
import com.mosty.base.utils.DateUtils;
import com.mosty.common.redis.service.RedisService;
import com.mosty.qwzx.service.TbQwBmjlbbService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 部门警力报备存入redis中（每5分钟执行一次）
 * 然后直接从redis中取数据
 */
@Slf4j
@Component
@AllArgsConstructor
public class TbQwBmjlbbSearchTask {

    private final TbQwBmjlbbService tbQwBmjlbbService;

    @Scheduled(cron = "0 */5 * * * ?")
    @Transactional
    public void run() {
        TbQwSearchJlqdDto dto = new TbQwSearchJlqdDto();
        dto.setBbrq(DateUtils.getQueryDateString(new Date(), "01"));
        // 获取新数据存入redis中
        tbQwBmjlbbService.getJlqdListToRedis(dto);
    }
}
