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

添加手动刷新

parent 842a2233
......@@ -10,11 +10,20 @@
<el-button type="text" size="mini"
>数据更新:{{ 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-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-row type="flex" justify="center">
<span style="font-size: 20px"
......@@ -22,8 +31,19 @@
></el-row
>
<el-row type="flex" justify="center">
<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="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
></el-row
>
<el-row type="flex" justify="center">
......@@ -39,8 +59,19 @@
></el-row
>
<el-row type="flex" justify="center">
<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="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
></el-row
>
<el-row type="flex" justify="center">
......@@ -57,8 +88,12 @@
>
<el-row type="flex" justify="center">
<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="font-size: 12px"
><span style="color: #6182f6">上线率 </span
><span
v-bind:class="{ success: statData.deviceOnlineRatio >= 0 }"
>{{ statData.deviceOnlineRatio * 100 }}%</span
></span
></el-row
>
<el-row type="flex" justify="center">
......@@ -74,8 +109,11 @@
></el-row
>
<el-row type="flex" justify="center">
<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="font-size: 12px"
><span style="color: #6182f6">离线率 </span
><span v-bind:class="{ warn: statData.deviceOfflineRatio >= 0 }"
>{{ statData.deviceOfflineRatio * 100 }}%</span
></span
></el-row
>
<el-row type="flex" justify="center">
......@@ -91,8 +129,11 @@
></el-row
>
<el-row type="flex" justify="center">
<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="font-size: 12px"
><span style="color: #6182f6">停用率 </span
><span v-bind:class="{ warn: statData.deviceStopRatio >= 0 }"
>{{ statData.deviceStopRatio * 100 }}%</span
></span
></el-row
>
<el-row type="flex" justify="center">
......@@ -108,8 +149,19 @@
></el-row
>
<el-row type="flex" justify="center">
<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="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
></el-row
>
<el-row type="flex" justify="center">
......@@ -118,7 +170,7 @@
>
</el-row>
</el-col>
<el-col :span="3" >
<el-col :span="3">
<el-row type="flex" justify="center"
><span style="font-size: 20px"
><b>{{ statData.pushTotalCount }}</b></span
......@@ -126,8 +178,19 @@
>
<el-row type="flex" justify="center">
<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="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
></el-row
>
......@@ -137,16 +200,16 @@
>
</el-row>
</el-col>
<el-col :span="3" type="flex" style="height:100%" >
<el-row type="flex" style="margin-top:6px" justify="center"
<el-col :span="3" type="flex" style="height: 100%">
<el-row type="flex" style="margin-top: 6px" justify="center"
><span style="font-size: 13px"
><span style="color:#6182f6">今日下发命令 </span>
><span style="color: #6182f6">今日下发命令 </span>
<b>{{ statData.uploadMessageTotalCount }}</b></span
></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="color:#6182f6">今日下发命令 </span>
><span style="color: #6182f6">今日下发命令 </span>
<b>{{ statData.downloadMessageTotalCount }}</b></span
></el-row
>
......@@ -213,9 +276,7 @@ export default {
this.$post("/device/stat/list", query)
.then((res) => {
if (res.code == 1) {
console.log("res", res);
this.statData = res.data.data[0];
console.log("statData", this.statData);
}
this.loading = false;
})
......@@ -237,6 +298,20 @@ export default {
console.log("process", process.env);
},
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) {
let query = { createTimeStart: this.formatterDate(beforeday) };
this.$post("/device/stat/list", query)
......@@ -709,10 +784,10 @@ export default {
</script>
<style scoped>
.success{
color:green
.success {
color: green;
}
.warn{
.warn {
color: rgb(215, 25, 25);
}
......@@ -721,7 +796,7 @@ export default {
position: relative;
}
.homeIndex::before {
content: '';
content: "";
position: absolute;
top: 0;
left: 0;
......@@ -729,6 +804,5 @@ export default {
height: 35%;
background: #1848c8;
}
</style>
......@@ -62,7 +62,8 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
@Override
public void excuteTask(ITask task) throws AppException {
doDeviceStat();
deviceService.deviceStat(null);
//doDeviceStat();
}
......
......@@ -53,6 +53,12 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
DeviceDao getDeviceDao();
/**
* 设备统计当天情况
* @param context
*/
void deviceStat(Context context);
......
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.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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.device.model.DeviceStatEntity;
import com.mortals.xhx.module.device.service.DeviceStatService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/**
*
* 设备统计
*
* @author zxfei
* @date 2022-07-05
*/
* 设备统计
*
* @author zxfei
* @date 2022-07-05
*/
@RestController
@RequestMapping("device/stat")
public class DeviceStatController extends BaseCRUDJsonBodyMappingController<DeviceStatService,DeviceStatEntity,Long> {
public class DeviceStatController extends BaseCRUDJsonBodyMappingController<DeviceStatService, DeviceStatEntity, Long> {
@Autowired
private ParamService paramService;
private DeviceService deviceService;
public DeviceStatController(){
super.setModuleDesc( "设备统计");
public DeviceStatController() {
super.setModuleDesc("设备统计");
}
@Override
......@@ -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;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.site.ISiteFeign;
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.SitestatQuery;
import com.mortals.xhx.module.sitestat.service.SitestatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
......@@ -39,6 +42,8 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
@Autowired
private IAuthTokenService authTokenService;
@Autowired
private DeviceService deviceService;
@Autowired
......@@ -148,4 +153,7 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
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