kongdeqiang
2023-06-05 a41b28d983f46f90a41ff7d2aa47179541c1be99
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.boying.job;
 
import com.boying.entity.Statistic;
import com.boying.entity.TicketBlack;
import com.boying.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
 
//大屏页面统计
@Component
public class DaPingScheduled {
 
    @Autowired
    private StatisticService statisticService;
    @Autowired
    private OutParkService outParkService;
    @Autowired
    private EnterParkService enterParkService;
    @Autowired
    private TicketService ticketService;
    @Autowired
    private ParkService parkService;
    @Autowired
    private TicketBlackService ticketBlackService;
 
    @Scheduled(cron = "0 0/40 * * * ?")
    public void execute() throws IOException {
        System.out.println("开始定时任务-------》");
        List<TicketBlack> list = ticketBlackService.updateType();
        if(list.size() > 0){
            for(TicketBlack t:list){
                t.setBlackType(1);
                ticketBlackService.saveOrUpdate(t);
            }
        }
        Statistic statistic = null;
        List<Statistic> all = statisticService.list();
        if(all.size()>0){
            statistic = all.get(0);
        }else {
            System.out.println("创建statistic");
            statistic = new Statistic();
        }
        statistic.setCreateTime(LocalDateTime.now());
        statistic.setData1(outParkService.count1());
        statistic.setData2(outParkService.count2());
        statistic.setData3(outParkService.sumByPrice());
 
        statistic.setData4(enterParkService.count1());
        statistic.setData5(outParkService.count5());
 
        statistic.setData6(ticketService.count2());
        statistic.setData7(ticketService.count1());
        statistic.setData8(ticketService.sumByPrice());
 
        statistic.setData9(outParkService.count3());
        statistic.setData10(outParkService.sumByPrice2());
 
        statistic.setData11(ticketService.count3());
        statistic.setData12(ticketService.sumByPrice2());
 
        int i = parkService.count1();
        if(i > 0){
            statistic.setData13((enterParkService.count1()*100)/parkService.count1());
        }else {
            statistic.setData13(100);
        }
        statistic.setData14(ticketService.count4());
 
        statistic.setData15(ticketService.count5(1));
        statistic.setData16(ticketService.count5(2));
 
        statistic.setData17(ticketService.count6());
        statistic.setData18(ticketService.sumByPrice3());
 
        statistic.setData19(ticketBlackService.count1());
        statistic.setData20(ticketBlackService.count2());
        statisticService.saveOrUpdate(statistic);
        System.out.println("结束定时任务-------》");
    }
}