1、增加最近24小时离线统计
This commit is contained in:
parent
77cc7707ee
commit
d0ae7671d7
@ -16,6 +16,9 @@ public class GnssStatusJoin {
|
||||
@ExcelProperty("租户id")
|
||||
Integer tenantid;
|
||||
|
||||
@ExcelProperty("租户名")
|
||||
String tenantname;
|
||||
|
||||
@ExcelProperty("更新日期时间")
|
||||
LocalDateTime updatetime;
|
||||
|
||||
|
||||
@ -22,23 +22,23 @@ public interface GnssStatusMapper extends MPJBaseMapper<GnssStatus> {
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid from gnssstatus s ,gnssdevices d where s.deviceid=d.deviceid and s.state <> 0"})
|
||||
List<GnssStatusJoin> queryOnline();
|
||||
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid from gnssstatus s ,gnssdevices d where " +
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid,d.tenantname from gnssstatus s ,gnssdevices d where " +
|
||||
"s.deviceid=d.deviceid and d.tenantid<>0 and d.opmode=0"})
|
||||
List<GnssStatusJoin> queryDeployed();
|
||||
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid from gnssstatus s ,gnssdevices d where " +
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid,d.tenantname from gnssstatus s ,gnssdevices d where " +
|
||||
"s.deviceid=d.deviceid and d.tenantid = #{tenantid} and d.opmode=0"})
|
||||
List<GnssStatusJoin> queryDeployedByTenant(int tenantid);
|
||||
|
||||
//多个入参要用Param注解
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid from gnssstatus s ,gnssdevices d where " +
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid,d.tenantname from gnssstatus s ,gnssdevices d where " +
|
||||
"s.deviceid=d.deviceid and d.tenantid = #{tenantid} and d.opmode=0 and d.project_id = #{projectName}"})
|
||||
List<GnssStatusJoin> queryDeployedByProject(@Param("tenantid") int tenantid, @Param("projectName") String projectName);
|
||||
|
||||
// 需要关联设备类型
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid from gnssstatus s ,gnssdevices d where s.deviceid=d.deviceid and s.deviceid = #{deviceId}"})
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid,d.tenantname from gnssstatus s ,gnssdevices d where s.deviceid=d.deviceid and s.deviceid = #{deviceId}"})
|
||||
GnssStatusJoin queryByDeviceId(String deviceId);
|
||||
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid from gnssstatus s ,gnssdevices d where s.deviceid=d.deviceid"})
|
||||
@Select({"select s.*, d.devicetype, d.model, d.group_id, d.name, d.project_id,d.iccid,d.tenantname from gnssstatus s ,gnssdevices d where s.deviceid=d.deviceid"})
|
||||
GnssStatusJoin queryAll();
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ public class GnssStatusController extends BasicController implements CommonExcel
|
||||
public MPJQueryWrapper<GnssStatus> prepareQueryWrapper() {
|
||||
return new MPJQueryWrapper<GnssStatus>()
|
||||
.selectAll(GnssStatus.class)
|
||||
.select("d.devicetype as devicetype,d.remark as remark,d.iccid as iccid")
|
||||
.select("d.devicetype as devicetype,d.remark as remark,d.iccid as iccid,d.tenantname as tenantname")
|
||||
.leftJoin("gnssdevices d on t.deviceid = d.deviceid")
|
||||
.orderByDesc("t.updatetime");
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@ -39,15 +40,16 @@ public class IndexController extends BasicController{
|
||||
@RequestMapping("/page/device_overview")
|
||||
public String deviceOverview(Model m, HttpSession session) {
|
||||
initModel(m, session);
|
||||
int deviceDeployedNum;
|
||||
int deviceDeployedNum = 0;
|
||||
int deviceOfflineNum = 0;
|
||||
int deviceOfflineNumIn24h = 0;
|
||||
int warning1Num=0;//一般告警
|
||||
int warning2Num=0;//严重告警
|
||||
int noGGA = 0;
|
||||
int noFix = 0;
|
||||
long deviceNoFwdNum=0;
|
||||
|
||||
//未推送设备数(同时满足:非SAAS服务商、使用状态正常、fwd_group_id和fwd_group_id2都为"不推送"的设备)
|
||||
Long deviceNoFwdNum;
|
||||
QueryWrapper<GnssDevice> noFwdQueryWrapper = new QueryWrapper<>();
|
||||
if (tenantId != Tenant.SAAS_PROVIDER_ID) {
|
||||
// 非SAAS服务商查询当前租户
|
||||
@ -63,7 +65,7 @@ public class IndexController extends BasicController{
|
||||
// fwd_group_id为"不推送"
|
||||
noFwdQueryWrapper.eq("fwd_group_id", GnssGroupFwd.FWD_TYPE_NONE);
|
||||
// fwd_group_id2为"不推送"或为null
|
||||
noFwdQueryWrapper.and(wrapper -> wrapper.eq("fwd_group_id2", GnssGroupFwd.FWD_TYPE_NONE).or().isNull("fwd_group_id2"));
|
||||
//noFwdQueryWrapper.and(wrapper -> wrapper.eq("fwd_group_id2", GnssGroupFwd.FWD_TYPE_NONE).or().isNull("fwd_group_id2"));
|
||||
deviceNoFwdNum = gnssDeviceMapper.selectCount(noFwdQueryWrapper);
|
||||
|
||||
List<GnssStatusJoin> deviceList;
|
||||
@ -76,11 +78,16 @@ public class IndexController extends BasicController{
|
||||
deviceDeployedNum = deviceList.size();
|
||||
|
||||
//for(GnssStatusJoin status:deviceList){遍历删除异常
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Iterator<GnssStatusJoin> iterator = deviceList.iterator();
|
||||
while(iterator.hasNext()){
|
||||
GnssStatusJoin status=iterator.next();
|
||||
if(status.getState() == GnssStatus.STATE_OFFLINE) {
|
||||
deviceOfflineNum++;
|
||||
if(status.getUpdatetime()!=null &&
|
||||
status.getUpdatetime().isAfter(now.minusHours(24))){
|
||||
deviceOfflineNumIn24h++;
|
||||
}
|
||||
}
|
||||
else if((status.getWarningcode()&WarningCfg.TYPE_CONT_INVALID_RESULT) != 0) {
|
||||
noFix++;
|
||||
@ -115,6 +122,7 @@ public class IndexController extends BasicController{
|
||||
m.addAttribute("deviceDeployedNum", deviceDeployedNum);
|
||||
m.addAttribute("deviceOnlineNum", deviceDeployedNum-deviceOfflineNum);
|
||||
m.addAttribute("deviceOfflineNum", deviceOfflineNum);
|
||||
m.addAttribute("deviceOfflineNumIn24h", deviceOfflineNumIn24h);
|
||||
m.addAttribute("warning1Num", warning1Num);
|
||||
m.addAttribute("warning2Num", warning2Num);
|
||||
m.addAttribute("warningTotalNum", warning1Num+warning2Num);
|
||||
@ -144,7 +152,7 @@ public class IndexController extends BasicController{
|
||||
Integer tenantId = getTenantId(session);
|
||||
if(tenantId == Tenant.SAAS_PROVIDER_ID) {
|
||||
queryWrapper.selectAll(GnssStatus.class)
|
||||
.select("d.name as name", "d.devicetype as devicetype", "d.project_id as project_id")
|
||||
.select("d.name as name", "d.devicetype as devicetype", "d.tenantname as tenantname","d.project_id as project_id")
|
||||
.leftJoin("gnssdevices d on t.deviceid = d.deviceid")
|
||||
.ne("d.tenantid", Tenant.SAAS_PROVIDER_ID)
|
||||
.eq("opmode", GnssDevice.OP_MODE_USE)
|
||||
@ -152,7 +160,7 @@ public class IndexController extends BasicController{
|
||||
}
|
||||
else{
|
||||
queryWrapper.selectAll(GnssStatus.class)
|
||||
.select("d.name as name", "d.devicetype as devicetype", "d.project_id as project_id")
|
||||
.select("d.name as name", "d.devicetype as devicetype", "d.tenantname as tenantname", "d.project_id as project_id")
|
||||
.leftJoin("gnssdevices d on t.deviceid = d.deviceid")
|
||||
.eq("d.tenantid", tenantId)
|
||||
.eq("opmode", GnssDevice.OP_MODE_USE)
|
||||
@ -164,6 +172,10 @@ public class IndexController extends BasicController{
|
||||
if(query.equals("offline")){
|
||||
queryWrapper.eq("state",GnssStatus.STATE_OFFLINE);
|
||||
}
|
||||
else if(query.equals("offline_in24h")){
|
||||
queryWrapper.eq("state",GnssStatus.STATE_OFFLINE);
|
||||
queryWrapper.ge("t.updatetime",LocalDateTime.now().minusHours(24));
|
||||
}
|
||||
else if(query.equals("nofixed")){
|
||||
queryWrapper.eq("warningcode&"+WarningCfg.TYPE_CONT_INVALID_RESULT,WarningCfg.TYPE_CONT_INVALID_RESULT);
|
||||
}
|
||||
|
||||
@ -836,6 +836,11 @@
|
||||
<span>掉线数</span>
|
||||
<span class="stat-number" th:text="${deviceOfflineNum}">22</span>
|
||||
</div>
|
||||
<div class="stat-item" onclick="queryDevices('offline_in24h')" th:if="${deviceOfflineNumIn24h > 0}">
|
||||
<span class="stat-dot dot-gray"></span>
|
||||
<span>24小时掉线数</span>
|
||||
<span class="stat-number" th:text="${deviceOfflineNumIn24h}">22</span>
|
||||
</div>
|
||||
<div class="stat-item" onclick="queryDevices('no_fwd')" th:if="${deviceNoFwdNum > 0}">
|
||||
<span class="stat-dot dot-orange"></span>
|
||||
<span>未推送数</span>
|
||||
|
||||
@ -92,6 +92,7 @@
|
||||
table = layui.table;
|
||||
var cfg_cols = [
|
||||
{field: 'deviceid', title: '设备号', sort: true},
|
||||
{field: 'tenantname', title: '部门', sort: true},
|
||||
{field: 'devicetype', title: '设备类型',templet: '#typeTrans'},
|
||||
{field: 'updatetime', title: '更新时间', templet: "<div>{{layui.util.toDateString(d.updatetime, 'yyyy-MM-dd HH:mm:ss')}}</div>"},
|
||||
{field: 'state', title: '状态',templet: '#stateTrans'},
|
||||
|
||||
@ -94,9 +94,10 @@
|
||||
url: '/gnss/q_status/list',
|
||||
cols: [[
|
||||
{field: 'deviceid', title: '设备号', width: 120, templet: '#deviceIdTpl', align: 'center',sort: true},
|
||||
{field: 'devicetype', title: '设备类型', templet: '#typeTrans', width: 100},
|
||||
{field: 'devicetype', title: '设备类型', templet: '#typeTrans', width: 80},
|
||||
{field: 'tenantname', title: '部门', width: 100},
|
||||
{field: 'project_id', title: '项目号', width: 100},
|
||||
{field: 'name', title: '工点', width: 150},
|
||||
{field: 'name', title: '工点', width: 100},
|
||||
{field: 'updatetime', title: '更新时间', templet: "<div>{{layui.util.toDateString(d.updatetime, 'yyyy-MM-dd HH:mm:ss')}}</div>", width: 170},
|
||||
{field: 'state', title: '状态', templet: '#stateTrans', width: 80, align: 'center'},
|
||||
{field: 'warning', title: '告警', templet: '#warningTrans', width: 80, align: 'center'},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user