package com.tofly.xrtygis.handle.abnormal;

import com.tofly.xrtygis.custom.util.DateTimeUtil;
import com.tofly.xrtygis.service.AbnormalWaterUseService;
import com.tofly.xrtygis.service.DmanightflowService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Component
@Slf4j
public class AbnormalWaterUserHandler {
    @Autowired
    private AbnormalWaterUseService waterUseService;

    /**
     * 每日计算用户抄表用水量分析(异常,发送消息)
     * @param param
     * @return
     */
    @XxlJob("abnormalWaterUserHandler")
    public ReturnT<String> abnormalWaterUserHandler(String param) {
        long l = System.currentTimeMillis();
        LocalDateTime todayBeginTime = DateTimeUtil.getTodayBeginTime();
        Date date = DateTimeUtil.convertLDTToDate(todayBeginTime);
        log.info("开始每日计算用户抄表用水量分析,日期{}",date);
        List<Date> dateList = new ArrayList<>();
        dateList.add(date);
        waterUseService.send(dateList);
        long l1 = System.currentTimeMillis();
        log.info("结束每日计算用户抄表用水量分析,用时{}mm",l1-l);
        return ReturnT.SUCCESS;
    }
}
