mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 08:25:53 +08:00
设备日志改进
This commit is contained in:
@@ -47,9 +47,13 @@ public class DeviceLog extends BaseEntity
|
|||||||
private String identity;
|
private String identity;
|
||||||
|
|
||||||
/** 是否监测数据(1=是,0=否) */
|
/** 是否监测数据(1=是,0=否) */
|
||||||
@Excel(name = "是否监测数据", readConverterExp = "1==是,0=否")
|
@Excel(name = "是否监测数据", readConverterExp = "1=是,0=否")
|
||||||
private Integer isMonitor;
|
private Integer isMonitor;
|
||||||
|
|
||||||
|
/** 模式 */
|
||||||
|
@Excel(name = "模式", readConverterExp = "1=影子模式,2=在线模式,3=其他")
|
||||||
|
private Integer mode;
|
||||||
|
|
||||||
/** 用户ID */
|
/** 用户ID */
|
||||||
@Excel(name = "用户ID")
|
@Excel(name = "用户ID")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
@@ -66,6 +70,14 @@ public class DeviceLog extends BaseEntity
|
|||||||
@Excel(name = "租户名称")
|
@Excel(name = "租户名称")
|
||||||
private String tenantName;
|
private String tenantName;
|
||||||
|
|
||||||
|
public Integer getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMode(Integer mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getUserId() {
|
public Long getUserId() {
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.iot.mqtt;
|
package com.ruoyi.iot.mqtt;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.iot.domain.Device;
|
import com.ruoyi.iot.domain.Device;
|
||||||
import com.ruoyi.iot.domain.DeviceLog;
|
import com.ruoyi.iot.domain.DeviceLog;
|
||||||
import com.ruoyi.iot.model.NtpModel;
|
import com.ruoyi.iot.model.NtpModel;
|
||||||
@@ -203,6 +204,9 @@ public class EmqxService {
|
|||||||
deviceLog.setUserName(device.getUserName());
|
deviceLog.setUserName(device.getUserName());
|
||||||
deviceLog.setTenantId(device.getTenantId());
|
deviceLog.setTenantId(device.getTenantId());
|
||||||
deviceLog.setTenantName(device.getTenantName());
|
deviceLog.setTenantName(device.getTenantName());
|
||||||
|
deviceLog.setCreateTime(DateUtils.getNowDate());
|
||||||
|
// 1=影子模式,2=在线模式,3=其他
|
||||||
|
deviceLog.setMode(2);
|
||||||
logService.saveDeviceLog(deviceLog);
|
logService.saveDeviceLog(deviceLog);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ public class DeviceLogServiceImpl implements IDeviceLogService
|
|||||||
@Override
|
@Override
|
||||||
public int insertDeviceLog(DeviceLog deviceLog)
|
public int insertDeviceLog(DeviceLog deviceLog)
|
||||||
{
|
{
|
||||||
deviceLog.setCreateTime(DateUtils.getNowDate());
|
|
||||||
return logService.saveDeviceLog(deviceLog);
|
return logService.saveDeviceLog(deviceLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -235,14 +235,17 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
deviceLog.setLogValue(input.getThingsModelValueRemarkItem().get(i).getValue());
|
deviceLog.setLogValue(input.getThingsModelValueRemarkItem().get(i).getValue());
|
||||||
deviceLog.setRemark(input.getThingsModelValueRemarkItem().get(i).getRemark());
|
deviceLog.setRemark(input.getThingsModelValueRemarkItem().get(i).getRemark());
|
||||||
deviceLog.setIdentity(input.getThingsModelValueRemarkItem().get(i).getId());
|
deviceLog.setIdentity(input.getThingsModelValueRemarkItem().get(i).getId());
|
||||||
deviceLog.setCreateTime(DateUtils.getNowDate());
|
|
||||||
deviceLog.setIsMonitor(valueList.get(k).getIsMonitor());
|
deviceLog.setIsMonitor(valueList.get(k).getIsMonitor());
|
||||||
deviceLog.setLogType(type);
|
deviceLog.setLogType(type);
|
||||||
deviceLog.setUserId(deviceThings.getUserId());
|
deviceLog.setUserId(deviceThings.getUserId());
|
||||||
deviceLog.setUserName(deviceThings.getUserName());
|
deviceLog.setUserName(deviceThings.getUserName());
|
||||||
deviceLog.setTenantId(deviceThings.getTenantId());
|
deviceLog.setTenantId(deviceThings.getTenantId());
|
||||||
deviceLog.setTenantName(deviceThings.getTenantName());
|
deviceLog.setTenantName(deviceThings.getTenantName());
|
||||||
|
deviceLog.setCreateTime(DateUtils.getNowDate());
|
||||||
|
// 1=影子模式,2=在线模式,3=其他
|
||||||
|
deviceLog.setMode(isShadow?1:2);
|
||||||
logService.saveDeviceLog(deviceLog);
|
logService.saveDeviceLog(deviceLog);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -709,7 +712,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param device 设备
|
* @param device 设备状态和定位更新
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -738,6 +741,9 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
deviceLog.setUserName(device.getUserName());
|
deviceLog.setUserName(device.getUserName());
|
||||||
deviceLog.setTenantId(device.getTenantId());
|
deviceLog.setTenantId(device.getTenantId());
|
||||||
deviceLog.setTenantName(device.getTenantName());
|
deviceLog.setTenantName(device.getTenantName());
|
||||||
|
deviceLog.setCreateTime(DateUtils.getNowDate());
|
||||||
|
// 1=影子模式,2=在线模式,3=其他
|
||||||
|
deviceLog.setMode(3);
|
||||||
if(device.getStatus()==3){
|
if(device.getStatus()==3){
|
||||||
deviceLog.setLogValue("1");
|
deviceLog.setLogValue("1");
|
||||||
deviceLog.setRemark("设备上线");
|
deviceLog.setRemark("设备上线");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.iot.tdengine.service.impl;
|
package com.ruoyi.iot.tdengine.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.iot.domain.Device;
|
import com.ruoyi.iot.domain.Device;
|
||||||
import com.ruoyi.iot.domain.DeviceLog;
|
import com.ruoyi.iot.domain.DeviceLog;
|
||||||
import com.ruoyi.iot.model.DeviceStatistic;
|
import com.ruoyi.iot.model.DeviceStatistic;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="identity" column="identity" />
|
<result property="identity" column="identity" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="isMonitor" column="is_monitor" />
|
<result property="isMonitor" column="is_monitor" />
|
||||||
|
<result property="mode" column="mode" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="userId" column="user_id" />
|
<result property="userId" column="user_id" />
|
||||||
<result property="userName" column="user_name" />
|
<result property="userName" column="user_name" />
|
||||||
@@ -28,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectDeviceLogVo">
|
<sql id="selectDeviceLogVo">
|
||||||
select log_id, log_type, log_value, device_id, device_name,serial_number, identity, create_by, is_monitor, user_id, user_name, tenant_id, tenant_name, create_time, remark from iot_device_log
|
select log_id, log_type, log_value, device_id, device_name,serial_number, identity, create_by, is_monitor,mode, user_id, user_name, tenant_id, tenant_name, create_time, remark from iot_device_log
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectMonitorList" parameterType="com.ruoyi.iot.domain.DeviceLog" resultMap="MonitorResult">
|
<select id="selectMonitorList" parameterType="com.ruoyi.iot.domain.DeviceLog" resultMap="MonitorResult">
|
||||||
@@ -92,7 +93,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||||
</where>
|
</where>
|
||||||
) as monitorCount
|
) as monitorCount
|
||||||
from iot_device_log
|
|
||||||
limit 1
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -107,6 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="identity != null">identity,</if>
|
<if test="identity != null">identity,</if>
|
||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
<if test="isMonitor != null">is_monitor,</if>
|
<if test="isMonitor != null">is_monitor,</if>
|
||||||
|
<if test="mode != null">mode,</if>
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
<if test="remark != null">remark,</if>
|
<if test="remark != null">remark,</if>
|
||||||
<if test="userId != null">user_id,</if>
|
<if test="userId != null">user_id,</if>
|
||||||
@@ -123,6 +124,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="identity != null">#{identity},</if>
|
<if test="identity != null">#{identity},</if>
|
||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
<if test="isMonitor != null">#{isMonitor},</if>
|
<if test="isMonitor != null">#{isMonitor},</if>
|
||||||
|
<if test="mode != null">#{mode},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
<if test="remark != null">#{remark},</if>
|
<if test="remark != null">#{remark},</if>
|
||||||
<if test="userId != null">#{userId},</if>
|
<if test="userId != null">#{userId},</if>
|
||||||
@@ -143,6 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="identity != null">identity = #{identity},</if>
|
<if test="identity != null">identity = #{identity},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
<if test="isMonitor != null">is_monitor = #{isMonitor},</if>
|
<if test="isMonitor != null">is_monitor = #{isMonitor},</if>
|
||||||
|
<if test="mode != null">mode = #{mode},</if>
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
<if test="userId != null">user_id = #{userId},</if>
|
<if test="userId != null">user_id = #{userId},</if>
|
||||||
|
|||||||
@@ -225,36 +225,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDeviceProductAlertCount" parameterType="com.ruoyi.iot.domain.Device" resultType="com.ruoyi.iot.model.DeviceStatistic">
|
<select id="selectDeviceProductAlertCount" parameterType="com.ruoyi.iot.domain.Device" resultType="com.ruoyi.iot.model.DeviceStatistic">
|
||||||
SELECT count(device_id) as deviceCount,
|
select
|
||||||
(
|
<!--设备数量-->
|
||||||
<!--普通用户查询设备中的产品数量-->
|
(select count(distinct d.device_id,d.user_id)
|
||||||
<if test="userId != null and userId != 0">
|
from iot_device d
|
||||||
select count(product_id)
|
inner join iot_device_user u on u.device_id = d.device_id
|
||||||
from iot_device
|
<where>
|
||||||
where user_id = #{userId}
|
<if test="userId != null and userId != 0"> and u.user_id = #{userId}</if>
|
||||||
group by product_id
|
<if test="tenantId != null and tenantId != 0"> and d.tenant_id = #{tenantId}</if>
|
||||||
</if>
|
</where>
|
||||||
<!--管理员和租户直接查询产品的数量-->
|
) as deviceCount,
|
||||||
<if test="userId == null || userId == 0">
|
|
||||||
select count(product_id)
|
(
|
||||||
from iot_product
|
<!--普通用户查询设备中的产品数量-->
|
||||||
<where>
|
<if test="userId != null and userId != 0">
|
||||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId} </if>
|
select count(product_id)
|
||||||
</where>
|
from iot_device
|
||||||
</if>
|
where user_id = #{userId}
|
||||||
) as productCount,
|
group by product_id
|
||||||
(select count(alert_log_id)
|
</if>
|
||||||
from iot_alert_log
|
<!--管理员和租户直接查询产品的数量-->
|
||||||
<where>
|
<if test="userId == null || userId == 0">
|
||||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
select count(product_id)
|
||||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
from iot_product
|
||||||
</where>
|
<where>
|
||||||
) as alertCount
|
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId} </if>
|
||||||
from iot_device
|
</where>
|
||||||
<where>
|
</if>
|
||||||
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
) as productCount,
|
||||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
|
||||||
</where>
|
(select count(alert_log_id)
|
||||||
|
from iot_alert_log
|
||||||
|
<where>
|
||||||
|
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
|
||||||
|
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||||
|
</where>
|
||||||
|
) as alertCount
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectProductAuthenticate" parameterType="com.ruoyi.iot.model.AuthenticateInputModel" resultMap="DeviceAuthenticateResult">
|
<select id="selectProductAuthenticate" parameterType="com.ruoyi.iot.model.AuthenticateInputModel" resultMap="DeviceAuthenticateResult">
|
||||||
|
|||||||
@@ -549,6 +549,7 @@ export default {
|
|||||||
productName: data[i].productName,
|
productName: data[i].productName,
|
||||||
activeTime: data[i].activeTime == null ? '' : data[i].activeTime,
|
activeTime: data[i].activeTime == null ? '' : data[i].activeTime,
|
||||||
deviceId: data[i].deviceId,
|
deviceId: data[i].deviceId,
|
||||||
|
serialNumber:data[i].serialNumber,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -573,6 +574,7 @@ export default {
|
|||||||
formatter: function (params) {
|
formatter: function (params) {
|
||||||
var htmlStr = '<div style="padding:5px;line-height:28px;">';
|
var htmlStr = '<div style="padding:5px;line-height:28px;">';
|
||||||
htmlStr += "设备名称: <span style='color:#409EFF'>" + params.data.name + "</span><br />";
|
htmlStr += "设备名称: <span style='color:#409EFF'>" + params.data.name + "</span><br />";
|
||||||
|
htmlStr += "设备编号: " + params.data.serialNumber + "<br />";
|
||||||
htmlStr += "设备状态: ";
|
htmlStr += "设备状态: ";
|
||||||
if (params.data.status == 1) {
|
if (params.data.status == 1) {
|
||||||
htmlStr += "<span style='color:#E6A23C'>未激活</span>" + "<br />";
|
htmlStr += "<span style='color:#E6A23C'>未激活</span>" + "<br />";
|
||||||
|
|||||||
@@ -16,23 +16,31 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="deviceLogList" size="mini">
|
<el-table v-loading="loading" :data="deviceLogList" size="mini">
|
||||||
<el-table-column label="编号" align="center" prop="logId" width="100" />
|
<el-table-column label="编号" align="center" prop="logId" width="120" />
|
||||||
<el-table-column label="类型" align="center" prop="logType" width="120">
|
<el-table-column label="类型" align="center" prop="logType" width="120">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<dict-tag :options="dict.type.iot_device_log_type" :value="scope.row.logType" />
|
<dict-tag :options="dict.type.iot_device_log_type" :value="scope.row.logType" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="时间" align="center" prop="createTime" width="180">
|
<el-table-column label="模式" align="center" prop="logType" width="120">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag type="primary" v-if="scope.row.mode==1">影子模式</el-tag>
|
||||||
|
<el-tag type="success" v-else-if="scope.row.mode==2">在线模式</el-tag>
|
||||||
|
<el-tag type="info" v-else>其他</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="时间" align="center" prop="createTime" width="150">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{ scope.row.createTime }}</span>
|
<span>{{ scope.row.createTime }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="标识符" align="center" prop="identity" />
|
||||||
<el-table-column label="动作" align="left" header-align="center" prop="logValue">
|
<el-table-column label="动作" align="left" header-align="center" prop="logValue">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<div v-html="formatValueDisplay(scope.row)"></div>
|
<div v-html="formatValueDisplay(scope.row)"></div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="标识符" align="center" prop="identity" />
|
|
||||||
<el-table-column label="备注" header-align="center" align="left" prop="remark">
|
<el-table-column label="备注" header-align="center" align="left" prop="remark">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
{{scope.row.remark==null ?"无":scope.row.remark}}
|
{{scope.row.remark==null ?"无":scope.row.remark}}
|
||||||
|
|||||||
Reference in New Issue
Block a user