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