Commit 2418c3c5 authored by 赵啸非's avatar 赵啸非

添加手动刷新

parent 842a2233
...@@ -10,11 +10,20 @@ ...@@ -10,11 +10,20 @@
<el-button type="text" size="mini" <el-button type="text" size="mini"
>数据更新:{{ formatterDate(statData.updateTime) }}</el-button >数据更新:{{ formatterDate(statData.updateTime) }}</el-button
> >
<el-button icon="el-icon-refresh" size="mini" type="text">手动刷新</el-button> <el-button
icon="el-icon-refresh"
size="mini"
@click="syncDeviceStat"
type="text"
>手动刷新</el-button
>
</el-row> </el-row>
<el-card style="margin-left: 50px; margin-right: 50px; margin-top: 10px"> <el-card style="margin-left: 50px; margin-right: 50px; margin-top: 10px">
<el-row :gutter="20" style="height:80px;align-items: center;margin-top:10px" > <el-row
:gutter="20"
style="height: 80px; align-items: center; margin-top: 10px"
>
<el-col :span="3"> <el-col :span="3">
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
<span style="font-size: 20px" <span style="font-size: 20px"
...@@ -22,8 +31,19 @@ ...@@ -22,8 +31,19 @@
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
<span style="font-size: 12px;" <span style="font-size: 12px"
><span style="color:#6182f6">昨日 </span ><span v-bind:class="{success: statData.deviceAddCount>=0, warn: statData.deviceAddCount<0}">{{ statData.deviceAddCount>=0?'+'+statData.deviceAddCount:"-"+statData.deviceAddCount }}</span></span ><span style="color: #6182f6">昨日 </span
><span
v-bind:class="{
success: statData.deviceAddCount >= 0,
warn: statData.deviceAddCount < 0,
}"
>{{
statData.deviceAddCount >= 0
? "+" + statData.deviceAddCount
: "-" + statData.deviceAddCount
}}</span
></span
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
...@@ -39,8 +59,19 @@ ...@@ -39,8 +59,19 @@
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
<span style="font-size: 12px;" <span style="font-size: 12px"
><span style="color:#6182f6">昨日 </span ><span v-bind:class="{success: statData.siteAddCount>=0, warn: statData.siteAddCount<0}">{{ statData.siteAddCount>=0?'+'+statData.siteAddCount:"-"+statData.siteAddCount }}</span></span ><span style="color: #6182f6">昨日 </span
><span
v-bind:class="{
success: statData.siteAddCount >= 0,
warn: statData.siteAddCount < 0,
}"
>{{
statData.siteAddCount >= 0
? "+" + statData.siteAddCount
: "-" + statData.siteAddCount
}}</span
></span
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
...@@ -57,8 +88,12 @@ ...@@ -57,8 +88,12 @@
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
<span style="font-size: 12px;" <span style="font-size: 12px"
><span style="color:#6182f6">上线率 </span ><span v-bind:class="{success: statData.deviceOnlineRatio>=0}">{{ statData.deviceOnlineRatio* 100 }}%</span></span ><span style="color: #6182f6">上线率 </span
><span
v-bind:class="{ success: statData.deviceOnlineRatio >= 0 }"
>{{ statData.deviceOnlineRatio * 100 }}%</span
></span
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
...@@ -74,8 +109,11 @@ ...@@ -74,8 +109,11 @@
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
<span style="font-size: 12px;" <span style="font-size: 12px"
><span style="color:#6182f6">离线率 </span ><span v-bind:class="{warn: statData.deviceOfflineRatio>=0}">{{ statData.deviceOfflineRatio* 100 }}%</span></span ><span style="color: #6182f6">离线率 </span
><span v-bind:class="{ warn: statData.deviceOfflineRatio >= 0 }"
>{{ statData.deviceOfflineRatio * 100 }}%</span
></span
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
...@@ -91,8 +129,11 @@ ...@@ -91,8 +129,11 @@
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
<span style="font-size: 12px;" <span style="font-size: 12px"
><span style="color:#6182f6">停用率 </span ><span v-bind:class="{warn: statData.deviceStopRatio>=0}">{{ statData.deviceStopRatio* 100 }}%</span></span ><span style="color: #6182f6">停用率 </span
><span v-bind:class="{ warn: statData.deviceStopRatio >= 0 }"
>{{ statData.deviceStopRatio * 100 }}%</span
></span
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
...@@ -108,8 +149,19 @@ ...@@ -108,8 +149,19 @@
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
<span style="font-size: 12px;" <span style="font-size: 12px"
><span style="color:#6182f6">昨日 </span ><span v-bind:class="{success: statData.alarmAddCount>=0, warn: statData.alarmAddCount<0}">{{ statData.alarmAddCount>=0?'+'+statData.alarmAddCount:"-"+statData.alarmAddCount }}</span></span ><span style="color: #6182f6">昨日 </span
><span
v-bind:class="{
success: statData.alarmAddCount >= 0,
warn: statData.alarmAddCount < 0,
}"
>{{
statData.alarmAddCount >= 0
? "+" + statData.alarmAddCount
: "-" + statData.alarmAddCount
}}</span
></span
></el-row ></el-row
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
...@@ -118,7 +170,7 @@ ...@@ -118,7 +170,7 @@
> >
</el-row> </el-row>
</el-col> </el-col>
<el-col :span="3" > <el-col :span="3">
<el-row type="flex" justify="center" <el-row type="flex" justify="center"
><span style="font-size: 20px" ><span style="font-size: 20px"
><b>{{ statData.pushTotalCount }}</b></span ><b>{{ statData.pushTotalCount }}</b></span
...@@ -126,8 +178,19 @@ ...@@ -126,8 +178,19 @@
> >
<el-row type="flex" justify="center"> <el-row type="flex" justify="center">
<span style="font-size: 12px;" <span style="font-size: 12px"
><span style="color:#6182f6">昨日 </span ><span v-bind:class="{success: statData.pushAddCount>=0, warn: statData.pushAddCount<0}">{{ statData.pushAddCount>=0?'+'+statData.pushAddCount:"-"+statData.pushAddCount }}</span></span ><span style="color: #6182f6">昨日 </span
><span
v-bind:class="{
success: statData.pushAddCount >= 0,
warn: statData.pushAddCount < 0,
}"
>{{
statData.pushAddCount >= 0
? "+" + statData.pushAddCount
: "-" + statData.pushAddCount
}}</span
></span
></el-row ></el-row
> >
...@@ -137,16 +200,16 @@ ...@@ -137,16 +200,16 @@
> >
</el-row> </el-row>
</el-col> </el-col>
<el-col :span="3" type="flex" style="height:100%" > <el-col :span="3" type="flex" style="height: 100%">
<el-row type="flex" style="margin-top:6px" justify="center" <el-row type="flex" style="margin-top: 6px" justify="center"
><span style="font-size: 13px" ><span style="font-size: 13px"
><span style="color:#6182f6">今日下发命令 </span> ><span style="color: #6182f6">今日下发命令 </span>
<b>{{ statData.uploadMessageTotalCount }}</b></span <b>{{ statData.uploadMessageTotalCount }}</b></span
></el-row ></el-row
> >
<el-row type="flex" style="margin-top:6px" justify="center" <el-row type="flex" style="margin-top: 6px" justify="center"
><span style="font-size: 13px" ><span style="font-size: 13px"
><span style="color:#6182f6">今日下发命令 </span> ><span style="color: #6182f6">今日下发命令 </span>
<b>{{ statData.downloadMessageTotalCount }}</b></span <b>{{ statData.downloadMessageTotalCount }}</b></span
></el-row ></el-row
> >
...@@ -213,9 +276,7 @@ export default { ...@@ -213,9 +276,7 @@ export default {
this.$post("/device/stat/list", query) this.$post("/device/stat/list", query)
.then((res) => { .then((res) => {
if (res.code == 1) { if (res.code == 1) {
console.log("res", res);
this.statData = res.data.data[0]; this.statData = res.data.data[0];
console.log("statData", this.statData);
} }
this.loading = false; this.loading = false;
}) })
...@@ -237,6 +298,20 @@ export default { ...@@ -237,6 +298,20 @@ export default {
console.log("process", process.env); console.log("process", process.env);
}, },
methods: { methods: {
syncDeviceStat() {
this.$post("/device/stat/syncDeviceStat", {})
.then((res) => {
if (res.code == 1) {
this.statData = res.data.data[0];
} else {
this.$message.error(res.msg);
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
findDeviceTotalStat(beforeday) { findDeviceTotalStat(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) }; let query = { createTimeStart: this.formatterDate(beforeday) };
this.$post("/device/stat/list", query) this.$post("/device/stat/list", query)
...@@ -709,10 +784,10 @@ export default { ...@@ -709,10 +784,10 @@ export default {
</script> </script>
<style scoped> <style scoped>
.success{ .success {
color:green color: green;
} }
.warn{ .warn {
color: rgb(215, 25, 25); color: rgb(215, 25, 25);
} }
...@@ -721,7 +796,7 @@ export default { ...@@ -721,7 +796,7 @@ export default {
position: relative; position: relative;
} }
.homeIndex::before { .homeIndex::before {
content: ''; content: "";
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
...@@ -729,6 +804,5 @@ export default { ...@@ -729,6 +804,5 @@ export default {
height: 35%; height: 35%;
background: #1848c8; background: #1848c8;
} }
</style> </style>
...@@ -62,7 +62,8 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService { ...@@ -62,7 +62,8 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
doDeviceStat(); deviceService.deviceStat(null);
//doDeviceStat();
} }
......
...@@ -53,6 +53,12 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{ ...@@ -53,6 +53,12 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
DeviceDao getDeviceDao(); DeviceDao getDeviceDao();
/**
* 设备统计当天情况
* @param context
*/
void deviceStat(Context context);
......
package com.mortals.xhx.module.device.web; package com.mortals.xhx.module.device.web;
import cn.hutool.core.date.DateUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.device.model.DeviceStatQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.sitestat.model.SitestatQuery;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.device.model.DeviceStatEntity; import com.mortals.xhx.module.device.model.DeviceStatEntity;
import com.mortals.xhx.module.device.service.DeviceStatService; import com.mortals.xhx.module.device.service.DeviceStatService;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*; import static com.mortals.framework.ap.SysConstains.*;
/** /**
* * 设备统计
* 设备统计 *
* * @author zxfei
* @author zxfei * @date 2022-07-05
* @date 2022-07-05 */
*/
@RestController @RestController
@RequestMapping("device/stat") @RequestMapping("device/stat")
public class DeviceStatController extends BaseCRUDJsonBodyMappingController<DeviceStatService,DeviceStatEntity,Long> { public class DeviceStatController extends BaseCRUDJsonBodyMappingController<DeviceStatService, DeviceStatEntity, Long> {
@Autowired @Autowired
private ParamService paramService; private DeviceService deviceService;
public DeviceStatController(){ public DeviceStatController() {
super.setModuleDesc( "设备统计"); super.setModuleDesc("设备统计");
} }
@Override @Override
...@@ -46,4 +55,24 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi ...@@ -46,4 +55,24 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
} }
/**
* 站点信息
*/
@PostMapping(value = "syncDeviceStat")
public Rest<Object> syncDeviceStat() {
try {
//刷新成功,返回列表
deviceService.deviceStat(getContext());
DeviceStatQuery deviceStatQuery = new DeviceStatQuery();
deviceStatQuery.setYear(DateUtil.year(new Date()));
deviceStatQuery.setMonth(DateUtil.month(new Date()) + 1);
deviceStatQuery.setDay(DateUtil.dayOfMonth(new Date()));
Rest<Object> resp = this.list(deviceStatQuery);
return resp;
} catch (Exception e) {
log.error("刷新异常", e);
return Rest.fail(KEY_RESULT_CODE, super.convertException(e));
}
}
} }
\ No newline at end of file
...@@ -14,11 +14,14 @@ import com.mortals.xhx.common.pdu.site.SitePdu; ...@@ -14,11 +14,14 @@ import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.pdu.user.UserPdu; import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.site.ISiteFeign; import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.feign.user.IUserFeign; import com.mortals.xhx.feign.user.IUserFeign;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.sitestat.model.SitestatEntity; import com.mortals.xhx.module.sitestat.model.SitestatEntity;
import com.mortals.xhx.module.sitestat.model.SitestatQuery;
import com.mortals.xhx.module.sitestat.service.SitestatService; import com.mortals.xhx.module.sitestat.service.SitestatService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -39,6 +42,8 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest ...@@ -39,6 +42,8 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
@Autowired @Autowired
private IAuthTokenService authTokenService; private IAuthTokenService authTokenService;
@Autowired
private DeviceService deviceService;
@Autowired @Autowired
...@@ -148,4 +153,7 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest ...@@ -148,4 +153,7 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
return jsonObject.toJSONString(); return jsonObject.toJSONString();
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment