设备型号版本功能完善

This commit is contained in:
SjS 2025-04-16 15:17:45 +08:00
parent f669751957
commit d525c321a7
11 changed files with 174 additions and 37 deletions

View File

@ -5,6 +5,7 @@ Vue.use(Router)
/* Layout */
import Layout from '@/layout'
import UserDetail from "@/views/user/user/UserDetail.vue";
/**
* Note: 路由配置项
@ -74,6 +75,22 @@ export const constantRoutes = [
}
]
},
/**
* 查看页
*/
{
path: '/view',
component: Layout,
hidden: true,
children: [
{
path: 'user/:userId?',
component: () => import('@/views/user/user/UserDetail.vue'),
name: 'UserView',
meta: { title: '用户详情' }
}
]
},
{
path: '/user',
component: Layout,

View File

@ -0,0 +1,58 @@
<template>
<div class="app-container">
<!-- 详情头部 -->
<el-page-header @back="$router.go(-1)" content="用户详情"></el-page-header>
<!-- 详情内容 -->
<el-descriptions title="基本信息" :column="2" border style="margin-top: 20px">
<el-descriptions-item label="用户ID">{{ user.userId }}</el-descriptions-item>
<el-descriptions-item label="用户名称">{{ user.userName }}</el-descriptions-item>
<el-descriptions-item label="手机号">{{ user.phonenumber }}</el-descriptions-item>
<el-descriptions-item label="状态">
<dict-tag :options="dict.type.sys_normal_disable" :value="user.status"/>
</el-descriptions-item>
<el-descriptions-item label="注册时间">{{ parseTime(user.createTime) }}</el-descriptions-item>
</el-descriptions>
<!-- 扩展信息 -->
<el-descriptions title="扩展信息" :column="2" border style="margin-top: 20px">
<el-descriptions-item label="用户类型">
<dict-tag :options="dict.type.as_role" :value="user.userType"/>
</el-descriptions-item>
<el-descriptions-item label="绑定设备数">{{ user.bindDeviceNum }}</el-descriptions-item>
</el-descriptions>
</div>
</template>
<script>
import { getUser } from "@/api/user/user"
import { parseTime } from '@/utils/index'
export default {
name: "UserDetail",
dicts: ['sys_normal_disable', 'as_role'],
data() {
return {
user: {}, //
loading: false
}
},
created() {
this.loadUserData()
},
methods: {
//
async loadUserData() {
try {
this.loading = true
const userId = this.$route.params.userId
const response = await getUser(userId)
this.user = response.data
} finally {
this.loading = false
}
},
parseTime
}
}
</script>

View File

@ -150,6 +150,14 @@
width="240"
class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-document"
@click="handleDetail(scope.row)">
详情
</el-button>
<!-- v-hasPermi="['system:user:query']"-->
<el-button
size="mini"
type="text"
@ -431,6 +439,9 @@ export default {
});
},
methods: {
handleDetail(row) {
this.$router.push(`/view/user/${row.userId}`)
},
/** 查询用户列表 */
getList() {
this.loading = true;

View File

@ -87,4 +87,6 @@ public interface AsDeviceMapper extends BaseMapper<AsDevice>
* @return 结果
*/
int isBandByMac(String mac);
int selectBindDeviceNumByUserId(Long userId);
}

View File

@ -140,4 +140,5 @@ public interface AsUserMapper
* 更新用户密码
*/
int updateUserPwd(@Param("userId") Long userId, @Param("password") String password);
}

View File

@ -133,6 +133,8 @@ public interface IAsDeviceService
* sn和mac号绑定
*/
int bandSn(AsDevice asDevice);
int selectBindDeviceNumByUserId(Long userId);
// /**
// * 构建命令
// *

View File

@ -356,6 +356,11 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
// return asDeviceMapper.updateAsDevice(vo);
// }
// 否则只修改名称用户还有图片
if (asDevice.getUserId() != null) {
AsUser asUser = asUserService.selectUserById(asDevice.getUserId());
asDevice.setUserName(asUser.getUserName());
asDevice.setNickName(asUser.getNickName());
}
return asDeviceMapper.updateAsDevice(asDevice);
}
@ -696,4 +701,10 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
}
return 1;
}
@Override
public int selectBindDeviceNumByUserId(Long userId) {
return asDeviceMapper.selectBindDeviceNumByUserId(userId);
}
}

View File

@ -1,12 +1,9 @@
package com.ruoyi.device.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.onenet.*;
import com.ruoyi.common.exception.ServiceException;
@ -14,12 +11,9 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanValidators;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.onenet.Token;
import com.ruoyi.device.domain.AsDevice;
import com.ruoyi.common.core.domain.entity.AsUser;
import com.ruoyi.device.domain.AsDeviceQuery;
import com.ruoyi.device.domain.AsWateringRecord;
import com.ruoyi.device.mapper.AsDeviceMapper;
import com.ruoyi.device.mapper.AsUserMapper;
import com.ruoyi.device.service.IAsDeviceService;
@ -150,7 +144,10 @@ public class AsUserServiceImpl implements IAsUserService
@Override
public AsUser selectUserById(Long userId)
{
return asUserMapper.selectUserById(userId);
AsUser asUser = asUserMapper.selectUserById(userId);
int num = asDeviceService.selectBindDeviceNumByUserId(userId);
asUser.setBindDeviceNum(num);
return asUser;
}

View File

@ -44,30 +44,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectAsDeviceVo">
select device_id, picture, device_name, classify_id, classify_name, model_id, model, mac, activation_time, online_status,
user_id, user_name, nick_name, regular_watering, soil_moisture_open, soil_moisture_close, water_intensity, pulse_mode,
pulse_mode_param, screen_rest_time, version, version_id, create_by, create_time, update_by, update_time, remark,
regular_watering_json, soil_moisture, water_intensity_switch,is_network,is_default,mode_str,bluetooth_id,bluetooth_name, pre
from as_device
select ad.device_id,
ad.picture,
ad.device_name,
ad.classify_id,
ad.classify_name,
ad.model_id,
ad.model,
ad.mac,
ad.activation_time,
ad.online_status,
ad.user_id,
ad.user_name,
ad.nick_name,
ad.regular_watering,
ad.soil_moisture_open,
ad.soil_moisture_close,
ad.water_intensity,
ad.pulse_mode,
ad.pulse_mode_param,
ad.screen_rest_time,
ad.version,
ad.version_id,
ad.create_by,
ad.create_time,
ad.update_by,
ad.update_time,
ad.remark,
ad.regular_watering_json,
ad.soil_moisture,
ad.water_intensity_switch,
ad.is_network,
ad.is_default,
ad.mode_str,
ad.bluetooth_id,
ad.bluetooth_name,
ad.pre
from as_device ad
</sql>
<select id="selectAsDeviceList" parameterType="AsDevice" resultMap="AsDeviceResult">
<include refid="selectAsDeviceVo"/>
<where>
status = 0
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="classifyName != null and classifyName != ''"> and classify_name like concat('%', #{classifyName}, '%')</if>
<if test="model != null and model != ''"> and model like concat('%', #{model}, '%')</if>
<if test="mac != null and mac != ''"> and mac like concat('%', #{mac}, '%')</if>
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="modelId != null "> and model_id = #{modelId}</if>
<if test="isDefault != null and isDefault != ''"> and is_default = #{isDefault}</if>
<if test="deviceName != null and deviceName != ''"> and ad.device_name like concat('%', #{deviceName}, '%')</if>
<if test="classifyName != null and classifyName != ''"> and ad.classify_name like concat('%', #{classifyName}, '%')</if>
<if test="model != null and model != ''"> and ad.model like concat('%', #{model}, '%')</if>
<if test="mac != null and mac != ''"> and ad.mac like concat('%', #{mac}, '%')</if>
<if test="onlineStatus != null and onlineStatus != ''"> and ad.online_status = #{onlineStatus}</if>
<if test="nickName != null and nickName != ''"> and ad.nick_name like concat('%', #{nickName}, '%')</if>
<if test="userName != null and userName != ''"> and ad.user_name like concat('%', #{userName}, '%')</if>
<if test="userId != null "> and ad.user_id = #{userId}</if>
<if test="deviceId != null "> and ad.device_id = #{deviceId}</if>
<if test="modelId != null "> and ad.model_id = #{modelId}</if>
<if test="isDefault != null and isDefault != ''"> and ad.is_default = #{isDefault}</if>
<if test="macList != null and macList.size() > 0">
and mac in
and ad.mac in
<foreach collection="macList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
@ -91,6 +123,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where mac = #{mac} and user_id IS NOT NULL and user_id != 0
</select>
<select id="selectBindDeviceNumByUserId" resultType="java.lang.Integer">
select count(1) from as_device ad LEFT JOIN as_user u ON ad.user_id = u.user_id
where ad.user_id = #{userId}
</select>
<insert id="insertAsDevice" parameterType="AsDevice" useGeneratedKeys="true" keyProperty="deviceId">
insert into as_device
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -46,20 +46,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAsModelList" parameterType="AsModel" resultMap="AsModelResult">
<include refid="selectAsModelVo"/>
<where>
<if test="modelName != null and modelName != ''"> and model_name like concat('%', #{modelName}, '%')</if>
<if test="model != null and model != ''"> and model = #{model}</if>
<if test="picture != null and picture != ''"> and picture = #{picture}</if>
<if test="idCode != null and idCode != ''"> and id_code = #{idCode}</if>
<if test="classifyName != null and classifyName != ''"> and classify_name like concat('%', #{classifyName}, '%')</if>
<if test="versionId != null "> and version_id = #{versionId}</if>
<if test="introduce != null and introduce != ''"> and introduce = #{introduce}</if>
<if test="pre != null and introduce != ''"> and pre = #{pre}</if>
<if test="modelName != null and modelName != ''"> and am.model_name like concat('%', #{modelName}, '%')</if>
<if test="model != null and model != ''"> and am.model = #{model}</if>
<if test="picture != null and picture != ''"> and am.picture = #{picture}</if>
<if test="idCode != null and idCode != ''"> and am.id_code = #{idCode}</if>
<if test="classifyName != null and classifyName != ''"> and am.classify_name like concat('%', #{classifyName}, '%')</if>
<if test="versionId != null "> and am.version_id = #{versionId}</if>
<if test="introduce != null and introduce != ''"> and am.introduce = #{introduce}</if>
<if test="pre != null and introduce != ''"> and am.pre = #{pre}</if>
</where>
</select>
<select id="selectAsModelByModelId" parameterType="Long" resultMap="AsModelResult">
<include refid="selectAsModelVo"/>
where model_id = #{modelId}
where am.model_id = #{modelId}
</select>
<select id="checkModelUnique" parameterType="String" resultMap="AsModelResult">
@ -68,13 +68,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAsModelByModel" parameterType="string" resultMap="AsModelResult">
<include refid="selectAsModelVo"/>
where model = #{model}
where am.model = #{model}
</select>
<select id="checkModelByPre" resultType="com.ruoyi.device.domain.vo.AsModelVO">
<include refid="selectAsModelVo"/>
<where>
<if test="pre != null and pre != ''">and FIND_IN_SET (#{pre},am.pre) </if>
<if test="modelId != null and modelId != ''">and model_id != #{modelId}</if>
<if test="modelId != null and modelId != ''">and am.model_id != #{modelId}</if>
</where>
</select>

View File

@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectUserVo">
select u.user_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber,u.birthday, u.password, u.user_type,
u.pay_password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark
from as_user u
from as_user u
</sql>
<select id="selectUserList" parameterType="AsUser" resultMap="AsUserResult">
@ -113,7 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where u.wxopenid = #{openid}
</select>
<insert id="insertUser" parameterType="AsUser" useGeneratedKeys="true" keyProperty="userId">
<insert id="insertUser" parameterType="AsUser" useGeneratedKeys="true" keyProperty="userId">
insert into as_user(
<if test="userId != null and userId != 0">user_id,</if>
<if test="userName != null and userName != ''">user_name,</if>