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 companyList = companyService.getBaseMapper().selectList(null); for (int i = 0 ; i list = companyService.getChildCompanyIds(String.valueOf(companyid)); List 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); } } } }