zhitong.yu
7 天以前 7fc9c42987a13c1d8d2159591a5803e70518827f
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package com.hxzk.gps.util;
 
import com.hxzk.gps.entity.Company.TbCompany;
import com.hxzk.gps.entity.WarnTongJi.WarnTongjiCompany;
import com.hxzk.gps.service.Company.TbCompanyService;
import com.hxzk.gps.util.GetUser.UserInfoUtil;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
import java.util.List;
 
@Component
public class TongJiCompany implements Runnable {
    private TbCompanyService companyService;
 
    public TongJiCompany(TbCompanyService companyService) {
        this.companyService = companyService;
    }
    private static final int SLEEP_TIME = 10000; // 线程休眠时间,单位:毫秒
 
 
 
    @PostConstruct
    public void init() {
        new Thread(this).start();
    }
    @Override
    public void run() {
        while (true) {
            try {
                List<TbCompany> companyList = companyService.getBaseMapper().selectList(null);
                for (int i = 0 ; i <companyList.size();i++){
                    String companys = companyList.get(i).getCompanyname();
                    Integer companyid = companyList.get(i).getId();
                    List<Long> list = companyService.getChildCompanyIds(String.valueOf(companyid));
                    List<WarnTongjiCompany> warnTongjiCompanyList = companyService.findCompanyWarn(companys);
                    for (WarnTongjiCompany company : warnTongjiCompanyList) {
                        if (company.getIsshow() == 1) {
                            switch (company.getTitle()) {
                                case "静止报警":
                                    Integer count = companyService.FindCompanyWarningCount1(list); // 静止报警条数
                                    if (count > 0 || count == 0){
                                        String title = "静止报警";
                                        companyService.UpCompanyWarnCount(companys,count,title);
                                    }
                                    break;
                                case "SOS报警":
                                    Integer count1 = companyService.FindCompanyWarningCount2(list); // SOS报警条数
                                    if (count1 > 0 || count1== 0){
                                        String title = "SOS报警";
                                        companyService.UpCompanyWarnCount(companys,count1,title);
                                    }
                                    break;
                                case "跌落报警":
                                    Integer count2 = companyService.FindCompanyWarningCount3(list); // 跌落报警条数
                                    if (count2 > 0 || count2 == 0){
                                        String title = "跌落报警";
                                        companyService.UpCompanyWarnCount(companys,count2,title);
                                    }
                                    break;
                                case "缺员报警":
                                    Integer count3 = companyService.FindCompanyWarningCount4(list); // 缺员报警条数
                                    if (count3 > 0 || count3 == 0){
                                        String title = "缺员报警";
                                        companyService.UpCompanyWarnCount(companys,count3,title);
                                    }
                                    break;
                                case "超员报警":
                                    Integer count4 = companyService.FindCompanyWarningCount5(list); // 超员报警条数
                                    if (count4 > 0 || count4 == 0){
                                        String title = "超员报警";
                                        companyService.UpCompanyWarnCount(companys,count4,title);
                                    }
                                    break;
                                case "聚集报警":
                                    Integer count5 = companyService.FindCompanyWarningCount6(list); // 聚集报警条数
                                    if (count5 > 0 || count5 == 0){
                                        String title = "聚集报警";
                                        companyService.UpCompanyWarnCount(companys,count5,title);
                                    }
                                    break;
                                case "越界报警":
                                    Integer count6 = companyService.FindCompanyWarningCount7(list); // 越界报警条数
                                    if (count6 > 0 || count6 == 0){
                                        String title = "越界报警";
                                        companyService.UpCompanyWarnCount(companys,count6,title);
                                    }
                                    break;
                                case "进入报警":
                                    Integer count7 = companyService.FindCompanyWarningCount8(list); // 进入报警条数
                                    if (count7 > 0 || count7 == 0){
                                        String title = "进入报警";
                                        companyService.UpCompanyWarnCount(companys,count7,title);
                                    }
                                    break;
                                case "低电报警":
                                    Integer count8 = companyService.FindCompanyWarningCount9(list); // 低电量报警条数
                                    if (count8 > 0 || count8 == 0){
                                        String title = "低电报警";
                                        companyService.UpCompanyWarnCount(companys,count8,title);
                                    }
                                    break;
                                case "离线基站":
                                    Integer count9 = companyService.FindCompanyNoOnlineAchorCount(companys); // 离线基站条数
                                    if (count9 > 0 || count9 == 0){
                                        String title = "离线基站";
                                        companyService.UpCompanyWarnCount(companys,count9,title);
                                    }
                                    break;
                                case "离线人员":
                                    Integer count10 = companyService.FindCompanyNoOnlineCount(list); // 离线人员条数
                                    if (count10 > 0 || count10 == 0) {
                                        String title = "离线人员";
                                        companyService.UpCompanyWarnCount(companys,count10,title);
                                    }
                                    
                                    break;
                                case "离线车辆":
                                    Integer count11 = companyService.FindCompanyNoOnlineCarCount(list); // 离线车辆条数
                                    if (count11 > 0 || count11 == 0){
                                        String title = "离线车辆";
                                        companyService.UpCompanyWarnCount(companys,count11,title);
                                    }
                                    break;
                                case "在线人员":
                                    Integer count12 = companyService.FindCompanyOnlineCount(list); // 在线人员条数
                                    if (count12 > 0 || count12 == 0){
                                        String title = "在线人员";
                                        companyService.UpCompanyWarnCount(companys,count12,title);
                                    }
                                    break;
                                case "在线基站":
                                    Integer count13 = companyService.FindCompanyOnlineAchorCount(companys); // 在线基站条数
                                    if (count13 > 0 || count13 == 0){
                                        String title = "在线基站";
                                        companyService.UpCompanyWarnCount(companys,count13,title);
                                    }
                                    break;
                                case "在线车辆":
                                    Integer count14 = companyService.FindCompanyOnlineCarCount(list); // 在线车辆条数
                                    if (count14 > 0 || count14 == 0){
                                        String title = "在线车辆";
                                        companyService.UpCompanyWarnCount(companys,count14,title);
                                    }
                                    break;
                            }
                        }
                    }
                }
 
                Thread.sleep(SLEEP_TIME); // 线程休眠5秒
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}