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