提交 659a9301 编写于 作者: xiaonannet's avatar xiaonannet

新增设备监控

上级 bd59d1ae
package com.mqttsnet.thinglinks.link.api.domain.device.entity.model;
import com.mqttsnet.thinglinks.link.api.domain.device.entity.Device;
import java.io.Serializable;
/**
* @Description: Device Entity class model
* @Author: ShiHuan SUN
* @E-mail: 13733918655@163.com
* @Website: http://thinglinks.mqttsnet.com
* @CreateDate: 2022/5/4$ 18:57$
* @UpdateUser: ShiHuan SUN
* @UpdateDate: 2022/5/4$ 18:57$
* @UpdateRemark: 修改内容
* @Version: V1.0
*/
public class DeviceModel extends Device implements Serializable {
private static final long serialVersionUID = 1L;
}
package com.mqttsnet.thinglinks.link.controller.device;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.mqttsnet.thinglinks.common.core.annotation.NoRepeatSubmit;
import com.mqttsnet.thinglinks.common.core.domain.R;
import com.mqttsnet.thinglinks.common.core.enums.DeviceConnectStatus;
import com.mqttsnet.thinglinks.common.core.utils.StringUtils;
import com.mqttsnet.thinglinks.common.core.utils.poi.ExcelUtil;
import com.mqttsnet.thinglinks.common.core.web.controller.BaseController;
......@@ -20,6 +23,7 @@ import com.mqttsnet.thinglinks.link.api.domain.product.entity.Product;
import com.mqttsnet.thinglinks.link.service.product.ProductService;
import com.mqttsnet.thinglinks.system.api.domain.SysUser;
import com.mqttsnet.thinglinks.system.api.model.LoginUser;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.mqttsnet.thinglinks.link.service.device.DeviceService;
......@@ -45,11 +49,20 @@ public class DeviceController extends BaseController {
*/
@PreAuthorize(hasPermi = "link:device:list")
@GetMapping("/list")
public TableDataInfo list(Device device)
public R<Map<String, Object>> list(Device device)
{
startPage();
final Map<String, Object> results = new HashMap<>();
List<Device> list = deviceService.selectDeviceList(device);
return getDataTable(list);
//查询设备数据
results.put("device", getDataTable(list));
//统计设备在线数量
results.put("onlineCount", deviceService.countDistinctClientIdByConnectStatus(DeviceConnectStatus.ONLINE.getValue()));
//统计设备离线数量
results.put("offlineCount", deviceService.countDistinctClientIdByConnectStatus(DeviceConnectStatus.OFFLINE.getValue()));
//统计设备初始化数量
results.put("initCount", deviceService.countDistinctClientIdByConnectStatus(DeviceConnectStatus.INIT.getValue()));
return R.ok(results);
}
/**
......
......@@ -155,6 +155,8 @@ public interface DeviceMapper {
Device findOneByClientIdOrDeviceIdentification(@Param("clientId")String clientId,@Param("deviceIdentification")String deviceIdentification);
Long countDistinctClientIdByConnectStatus(@Param("connectStatus")String connectStatus);
......
......@@ -131,5 +131,10 @@ public interface DeviceService {
* @return
*/
int disconnect(Long[] ids);
Long countDistinctClientIdByConnectStatus(String connectStatus);
}
......@@ -315,5 +315,13 @@ public class DeviceServiceImpl implements DeviceService {
return 0;
}
@Override
public Long countDistinctClientIdByConnectStatus(String connectStatus){
return deviceMapper.countDistinctClientIdByConnectStatus(connectStatus);
}
}
......@@ -1255,4 +1255,15 @@
</if>
</where>
</select>
<!--Author By ShiHuan Sun E-mail: 13733918655@163.com on 2022-05-04-->
<select id="countDistinctClientIdByConnectStatus" resultType="java.lang.Long">
select count(distinct(client_id))
from device
<where>
<if test="connectStatus != null">
and connect_status=#{connectStatus}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/thinglinks";
// 查询设备管理列表
export function listDevice(query) {
return request({
url: '/link/device/list',
method: 'get',
params: query
})
}
// 查询设备管理详细
export function getDevice(id) {
return request({
url: '/link/device/' + praseStrEmpty(id),
method: 'get'
})
}
// 新增设备管理
export function addDevice(data) {
return request({
url: '/link/device',
method: 'post',
data: data
})
}
// 修改设备管理
export function updateDevice(data) {
return request({
url: '/link/device',
method: 'put',
data: data
})
}
// 删除设备管理
export function delDevice(id) {
return request({
url: '/link/device/' + id,
method: 'delete'
})
}
// 断开设备连接
export function disconnectDevice(id) {
return request({
url: '/link/device/disconnect/' + id,
method: 'post'
})
}
......@@ -36,7 +36,7 @@
</div>
</template>
<script>
import { dataList } from "@/api/statistical/target";
import { dataList } from "@/api/tdengine/shadow";
export default {
data() {
return {
......@@ -82,7 +82,7 @@ export default {
},
goBack() {
this.$router.push({
path: "/StatisticalMonitor/Terminal",
path: "/shadow/Terminal",
query: {
activeNameBack: this.$route.query.activeName,
clientIdBack: this.$route.query.clientId,
......@@ -182,7 +182,7 @@ export default {
vertical-align: middle;
width: 24px;
height: 24px;
background: url("../../.././assets/images/Common/green_point.png") no-repeat
background: url("src/assets/images/common/green_point.png") no-repeat
50% 50%;
background-size: 100%;
margin-left: 8px;
......@@ -192,7 +192,7 @@ export default {
vertical-align: middle;
width: 24px;
height: 24px;
background: url("../../.././assets/images/Common/red_point.png") no-repeat 50%
background: url("src/assets/images/common/red_point.png") no-repeat 50%
50%;
background-size: 100%;
margin-left: 8px;
......@@ -205,4 +205,4 @@ export default {
.el-form-item {
margin-bottom: 0px !important;
}
</style>
\ No newline at end of file
</style>
......@@ -261,7 +261,7 @@ export default {
},
gotoDetailGuan(row) {
this.$router.push({
path: "/StatisticalMonitor/Terminal/terminaldetail",
path: "/shadow/StatisticalMonitor/Terminal/terminaldetail",
query: {
activeName: "1",
row: row,
......@@ -361,4 +361,8 @@ export default {
color: #56b4b0;
}
</style>
<style scoped>
\ No newline at end of file
<style scoped>
.el-form-item {
margin-bottom: 0px !important;
}
</style>
......@@ -248,7 +248,7 @@ export default {
},
gotoDetail(row) {
this.$router.push({
path: "/StatisticalMonitor/Terminal/terminaldetail",
path: "/shadow/StatisticalMonitor/Terminal/terminaldetail",
query: {
activeName: "2",
row: row,
......@@ -348,4 +348,3 @@ export default {
color: #56b4b0;
}
</style>
<style scoped>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册