1、修改停用设备显示在首页的bug

This commit is contained in:
weidong 2024-04-02 08:02:41 +08:00
parent 1810f41f3c
commit de0d30ce02

View File

@ -1,6 +1,7 @@
package com.imdroid.beidou.controller; package com.imdroid.beidou.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.query.MPJQueryWrapper;
import com.imdroid.beidou.entity.Tenant; import com.imdroid.beidou.entity.Tenant;
import com.imdroid.secapi.dto.*; import com.imdroid.secapi.dto.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -34,12 +35,11 @@ public class IndexController extends BasicController{
public String deviceOverview(Model m, HttpSession session) { public String deviceOverview(Model m, HttpSession session) {
initModel(m, session); initModel(m, session);
Long deviceDeployedNum; Long deviceDeployedNum;
Long deviceOnlineNum; int deviceOnlineNum=0;
Long warning1Num;//一般告警 int warning1Num=0;//一般告警
Long warning2Num;//严重告警 int warning2Num=0;//严重告警
QueryWrapper<GnssDevice> deviceQueryWrapper = new QueryWrapper<>(); QueryWrapper<GnssDevice> deviceQueryWrapper = new QueryWrapper<>();
QueryWrapper<GnssStatus> statusQueryWrapper;
List<GnssStatus> deviceList; List<GnssStatus> deviceList;
if(tenantId == Tenant.SAAS_PROVIDER_ID){ if(tenantId == Tenant.SAAS_PROVIDER_ID){
// 统计所有企业设备 // 统计所有企业设备
@ -48,28 +48,16 @@ public class IndexController extends BasicController{
// 设备数量 // 设备数量
deviceDeployedNum = gnssDeviceMapper.selectCount(deviceQueryWrapper); deviceDeployedNum = gnssDeviceMapper.selectCount(deviceQueryWrapper);
statusQueryWrapper = new QueryWrapper<>(); MPJQueryWrapper<GnssStatus> query = new MPJQueryWrapper<GnssStatus>()
statusQueryWrapper.ne("tenantid", tenantId); .selectAll(GnssStatus.class)
statusQueryWrapper.isNotNull("latitude"); .leftJoin("gnssdevices d on t.deviceid = d.deviceid")
statusQueryWrapper.isNotNull("longitude"); .ne("t.tenantid", tenantId)
statusQueryWrapper.orderByAsc("warning"); .ne("d.opmode", GnssDevice.OP_MODE_UNUSE)
deviceList = statusMapper.selectList(statusQueryWrapper); .isNotNull("t.latitude")
.isNotNull("t.longitude")
.orderByDesc("t.warning");
statusQueryWrapper = new QueryWrapper<>(); deviceList = statusMapper.selectList(query);
statusQueryWrapper.ne("tenantid", tenantId);
statusQueryWrapper.ne("state", GnssStatus.STATE_OFFLINE);
deviceOnlineNum = statusMapper.selectCount(statusQueryWrapper);
// 告警统计
statusQueryWrapper = new QueryWrapper<>();
statusQueryWrapper.ne("tenantid", tenantId);
statusQueryWrapper.eq("warning", WarningCfg.LEVEL_1);
warning1Num = statusMapper.selectCount(statusQueryWrapper);
statusQueryWrapper = new QueryWrapper<>();
statusQueryWrapper.ne("tenantid", tenantId);
statusQueryWrapper.eq("warning", WarningCfg.LEVEL_2);
warning2Num = statusMapper.selectCount(statusQueryWrapper);
} }
else{ else{
// 统计本企业设备 // 统计本企业设备
@ -79,27 +67,21 @@ public class IndexController extends BasicController{
// 设备数量 // 设备数量
deviceDeployedNum = gnssDeviceMapper.selectCount(deviceQueryWrapper); deviceDeployedNum = gnssDeviceMapper.selectCount(deviceQueryWrapper);
statusQueryWrapper = new QueryWrapper<>(); MPJQueryWrapper<GnssStatus> query = new MPJQueryWrapper<GnssStatus>()
statusQueryWrapper.eq("tenantid", tenantId); .selectAll(GnssStatus.class)
statusQueryWrapper.isNotNull("latitude"); .leftJoin("gnssdevices d on t.deviceid = d.deviceid")
statusQueryWrapper.isNotNull("longitude"); .eq("t.tenantid", tenantId)
deviceList = statusMapper.selectList(statusQueryWrapper); .ne("d.opmode", GnssDevice.OP_MODE_UNUSE)
.isNotNull("t.latitude")
.isNotNull("t.longitude")
.orderByDesc("t.warning");
deviceList = statusMapper.selectList(query);
}
statusQueryWrapper = new QueryWrapper<>(); for(GnssStatus status:deviceList){
statusQueryWrapper.eq("tenantid", tenantId); if(status.getState() == GnssStatus.STATE_OFFLINE) deviceOnlineNum++;
statusQueryWrapper.ne("state", GnssStatus.STATE_OFFLINE); if(status.getWarning() == WarningCfg.LEVEL_1) warning1Num++;
deviceOnlineNum = statusMapper.selectCount(statusQueryWrapper); else if(status.getWarning() == WarningCfg.LEVEL_2) warning2Num++;
// 告警统计
statusQueryWrapper = new QueryWrapper<>();
statusQueryWrapper.eq("tenantid", tenantId);
statusQueryWrapper.eq("warning", WarningCfg.LEVEL_1);
warning1Num = statusMapper.selectCount(statusQueryWrapper);
statusQueryWrapper = new QueryWrapper<>();
statusQueryWrapper.eq("tenantid", tenantId);
statusQueryWrapper.eq("warning", WarningCfg.LEVEL_2);
warning2Num = statusMapper.selectCount(statusQueryWrapper);
} }
m.addAttribute("deviceDeployedNum", deviceDeployedNum); m.addAttribute("deviceDeployedNum", deviceDeployedNum);