fuliqi
2024-07-31 71e6dc7824780c223e594add97c09773335e8af1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.ycl.task;
 
 
import com.ycl.calculate.CalculationStrategy;
import com.ycl.factory.IndexCalculationFactory;
import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult;
import com.ycl.utils.DateUtils;
import constant.ApiConstants;
import constant.CalculationStrategyConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
 
import java.util.Date;
import java.util.List;
 
/**
 * 车辆计算考核指标任务
 * 凌晨执行计算昨天数据
 */
@Slf4j
@Component("carTask")
public class CarTask {
    @Autowired
    private MongoTemplate mongoTemplate;
 
    public void siteOnlineTask() {
        Date yesterday = DateUtils.addDays(new Date(), -1);
        //点位在线率和视图库对接稳定性
        Query query = new Query();
        query.addCriteria(Criteria
                .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))
                .and("dataType").is(ApiConstants.HK_DATATYPE_CAR));
        List<SnapshotDataMonitorResult> snapshotDataMonitorResults = mongoTemplate.find(query, SnapshotDataMonitorResult.class);
        CalculationStrategy<SnapshotDataMonitorResult> siteOnlineCalculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.CAR_SiteOnline_ViewStability);
        siteOnlineCalculator.calculate(snapshotDataMonitorResults);
    }
 
 
}