1
0

7 Commits

28 changed files with 381 additions and 126 deletions

View File

@ -16,4 +16,5 @@ public class MqttPropertiesConfig {
private String subTopic;
private String pubClientId;
private String pubTopic;
private String enabled;
}

View File

@ -15,8 +15,7 @@ import org.springframework.stereotype.Component;
import java.time.Duration;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
/**
* 灯光模式订阅设备回传消息
@ -37,14 +36,10 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
try {
Object[] convertArr = context.getConvertArr();
String mainLightMode = convertArr[1].toString();
if(StringUtils.isNotBlank(mainLightMode)){
if("0".equals(mainLightMode)){
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ context.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "0", Duration.ofSeconds(60*15));
}
String mode = convertArr[1].toString();
if(StringUtils.isNotBlank(mode)){
// 发送设备状态和位置信息到Redis
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mainLightMode);
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mode);
}
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(30));
@ -65,7 +60,7 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
// });
try {
// 将设备状态信息存储到Redis中
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + deviceImei + DEVICE_LIGHT_MODE_KEY_PREFIX;
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + deviceImei + DEVICE_LASER_MODE_KEY_PREFIX;
// 存储到Redis
RedisUtils.setCacheObject(deviceRedisKey, convertValue.toString());

View File

@ -8,19 +8,17 @@ import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.InstructionRecordVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import com.fuyuanshen.web.service.device.DeviceBizService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -30,7 +28,7 @@ import java.util.Map;
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/device/controlCenter")
@RequestMapping("/api/device")
public class DeviceControlCenterController extends BaseController {
private final DeviceBizService appDeviceService;
@ -95,4 +93,12 @@ public class DeviceControlCenterController extends BaseController {
return R.ok(appDeviceService.getDeviceInfo(deviceMac));
}
/**
* 指令下发记录
*/
@GetMapping("/instructionRecord")
public TableDataInfo<InstructionRecordVo> getInstructionRecord(InstructionRecordDto dto, PageQuery pageQuery) {
return appDeviceService.getInstructionRecord(dto,pageQuery);
}
}

View File

@ -114,4 +114,21 @@ public class DeviceGroupController extends BaseController {
return toAjax(deviceGroupService.deleteWithValidByIds(List.of(ids), true));
}
/**
* 绑定设备分组
*
* @param groupId 分组id
* @param deviceId 设备id
*/
@Operation(summary = "绑定设备分组")
// @SaCheckPermission("fys-equipment:group:remove")
@Log(title = "绑定设备分组", businessType = BusinessType.DELETE)
@GetMapping("/groupId/{deviceId}")
public R<Void> bindingDevice(@NotEmpty(message = "分组id 不能为空") @PathVariable Long groupId,
@NotEmpty(message = "设备id 不能为空") @PathVariable Long[] deviceId) {
return toAjax(deviceGroupService.bindingDevice(groupId, deviceId));
}
}

View File

@ -1,29 +1,18 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.app.domain.dto.APPReNameDTO;
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import com.fuyuanshen.web.service.WEBDeviceService;
import com.fuyuanshen.web.service.device.DeviceBizService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @Description:
@ -68,6 +57,20 @@ public class WEBDeviceController extends BaseController {
}
/**
* 设备用户详情
*
* @param id
* @return
*/
@Operation(summary = "设备详情")
@GetMapping(value = "/getDeviceUser/{id}")
public R<List<AppPersonnelInfoRecords>> getDeviceUser(@PathVariable Long id) {
List<AppPersonnelInfoRecords> device = deviceService.getDeviceUser(id);
return R.ok(device);
}
}

View File

@ -79,7 +79,8 @@ public class AppRegisterService {
boolean exist = TenantHelper.dynamic(tenantId, () -> {
return appUserMapper.exists(new LambdaQueryWrapper<AppUser>()
.eq(AppUser::getUserName, appUser.getUserName()));
.eq(AppUser::getUserName, appUser.getUserName())
.eq(AppUser::getUserType, UserType.APP_USER.getUserType()));
});
if (exist) {
throw new UserException("user.register.save.error", username);

View File

@ -2,6 +2,7 @@ package com.fuyuanshen.web.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.equipment.domain.Device;
@ -38,4 +39,12 @@ public interface WEBDeviceService extends IService<Device> {
*/
WebDeviceVo getDevice(Long id);
/**
* 设备用户详情
*
* @param id
* @return
*/
List<AppPersonnelInfoRecords> getDeviceUser(Long id);
}

View File

@ -190,6 +190,22 @@ public class DeviceBJQBizService {
vo.setBatteryPercentage("0");
}
String lightModeStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX);
// 获取电量
if(StringUtils.isNotBlank(deviceStatus)){
vo.setMainLightMode(lightModeStatus);
}
String lightBrightnessStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
if(StringUtils.isNotBlank(lightBrightnessStatus)){
vo.setLightBrightness(lightBrightnessStatus);
}
String laserLightMode = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LASER_MODE_KEY_PREFIX);
if(StringUtils.isNotBlank(laserLightMode)){
vo.setLaserLightMode(laserLightMode);
}
// 获取经度纬度
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
String locationInfo = RedisUtils.getCacheObject(locationKey);

View File

@ -14,7 +14,6 @@ import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
import com.fuyuanshen.app.domain.vo.AppUserVo;
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.app.mapper.AppUserMapper;
import com.fuyuanshen.app.mapper.equipment.APPDeviceMapper;
import com.fuyuanshen.common.core.exception.ServiceException;
@ -26,15 +25,15 @@ import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.InstructionRecordVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
import com.fuyuanshen.global.mqtt.config.MqttGateway;
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
import com.fuyuanshen.web.service.device.status.base.DeviceStatusRule;
import com.fuyuanshen.web.service.device.status.base.RealTimeStatusEngine;
@ -332,4 +331,9 @@ public class DeviceBizService {
// List<Device> devices = deviceMapper.selectList(queryWrapper);
return deviceMapper.getDeviceInfo(deviceMac);
}
public TableDataInfo<InstructionRecordVo> getInstructionRecord(InstructionRecordDto bo, PageQuery pageQuery) {
Page<InstructionRecordVo> result = deviceLogMapper.getInstructionRecord(pageQuery.build(), bo);
return TableDataInfo.build(result);
}
}

View File

@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
import com.fuyuanshen.app.domain.AppDeviceShare;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceAssignments;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
@ -22,6 +24,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @Description:
* @Author: WY
@ -35,6 +39,7 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
private final AppDeviceBindRecordMapper appDeviceBindRecordMapper;
private final AppPersonnelInfoRecordsMapper infoRecordsMapper;
private final DeviceMapper deviceMapper;
private final AppDeviceShareMapper appDeviceShareMapper;
@ -95,4 +100,19 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
}
/**
* 设备用户详情
*
* @param id
* @return
*/
@Override
public List<AppPersonnelInfoRecords> getDeviceUser(Long id) {
List<AppPersonnelInfoRecords> appPersonnelInfoRecords = infoRecordsMapper.selectList(
new QueryWrapper<AppPersonnelInfoRecords>().eq("device_id", id)
.orderByDesc("create_time"));
return appPersonnelInfoRecords;
}
}

View File

@ -1,3 +1,6 @@
--- # 临时文件存储位置 避免临时文件被系统清理报错
spring.servlet.multipart.location: /fys/server/temp
--- # 监控中心配置
spring.boot.admin.client:
# 增加客户端开关
@ -8,15 +11,15 @@ spring.boot.admin.client:
metadata:
username: ${spring.boot.admin.client.username}
userpassword: ${spring.boot.admin.client.password}
username: ${monitor.username}
password: ${monitor.password}
username: @monitor.username@
password: @monitor.password@
--- # snail-job 配置
snail-job:
enabled: false
# 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
group: "fys_group"
# SnailJob 接入验证令牌 详见 script/sql/ry_job.sql `sj_group_config`
# SnailJob 接入验证令牌 详见 script/sql/ry_job.sql `sj_group_config`表
token: "SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT"
server:
host: 127.0.0.1
@ -37,7 +40,7 @@ spring:
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
dynamic:
# 性能分析插件(有性能损耗 不建议生产环境使用)
p6spy: true
p6spy: false
# 设置默认的数据源或者数据源组,默认值即为 master
primary: master
# 严格模式 匹配不到数据源则报错
@ -49,35 +52,35 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://120.79.224.186:3366/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
url: jdbc:mysql://47.107.152.87:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
password: 1fys@QWER..
# # 从库数据源
# slave:
# lazy: true
# type: ${spring.datasource.type}
# driverClassName: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username:
# password:
# oracle:
# type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT
# password: root
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: root
# sqlserver:
# type: ${spring.datasource.type}
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
# username: SA
# password: root
password: Jz_5623_cl1
# # 从库数据源
# slave:
# lazy: true
# type: ${spring.datasource.type}
# driverClassName: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username:
# password:
# oracle:
# type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT
# password: root
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: root
# sqlserver:
# type: ${spring.datasource.type}
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
# username: SA
# password: root
hikari:
# 最大连接池数量
maxPoolSize: 20
@ -98,13 +101,13 @@ spring:
spring.data:
redis:
# 地址
host: 120.79.224.186
host: 47.107.152.87
# 端口默认为6379
port: 26379
port: 6379
# 数据库索引
database: 2
database: 1
# redis 密码必须配置
password: 1fys@QWER..
password: re_fs_11520631
# 连接超时时间
timeout: 10s
# 是否开启ssl
@ -115,17 +118,17 @@ redisson:
# redis key前缀
keyPrefix:
# 线程池数量
threads: 4
threads: 16
# Netty线程池数量
nettyThreads: 8
nettyThreads: 32
# 单节点配置
singleServerConfig:
# 客户端名称 不能用中文
clientName: fys-Vue-Plus
# 最小空闲连接数
connectionMinimumIdleSize: 8
connectionMinimumIdleSize: 32
# 连接池大小
connectionPoolSize: 32
connectionPoolSize: 64
# 连接空闲超时,单位:毫秒
idleConnectionTimeout: 10000
# 命令等待超时,单位:毫秒
@ -177,12 +180,11 @@ sms:
access-key-id: LTAI5tDGfJd4kMvrGtvyzCHz
# 称为accessSecret有些称之为apiSecret
access-key-secret: a4ZlVHVSYeMQHn0p1R18thA6xCdHQh
#模板ID 非必须配置如果使用sendMessage的快速发送需此配置
#模板ID 非必须配置如果使用sendMessage的快速发送需此配置
template-id: SMS_324526343
#模板变量 上述模板的变量
#模板变量 上述模板的变量
templateName: code
signature: 深圳市富源晟科技
# sdk-app-id: 您的sdkAppId
config2:
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
supplier: tencent
@ -191,7 +193,6 @@ sms:
signature: 您的短信签名
sdk-app-id: 您的sdkAppId
--- # 三方授权
justauth:
# 前端外网访问地址
@ -206,11 +207,11 @@ justauth:
redirect-uri: ${justauth.address}/social-callback?source=maxkey
topiam:
# topiam 服务器地址
server-url: http://127.0.0.1:1898/api/v1/authorize/y0q************spq***********8ol
server-url: http://127.0.0.1:1989/api/v1/authorize/y0q************spq***********8ol
client-id: 449c4*********937************759
client-secret: ac7***********1e0************28d
redirect-uri: ${justauth.address}/social-callback?source=topiam
scopes: [openid, email, phone, profile]
scopes: [ openid, email, phone, profile ]
qq:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
@ -276,6 +277,18 @@ justauth:
redirect-uri: ${justauth.address}/social-callback?source=gitea
# MQTT配置
mqtt:
username: admin
password: fys123456
url: tcp://47.107.152.87:1883
subClientId: fys_subClient
subTopic: worker/location/#
pubTopic: B/#
pubClientId: fys_pubClient
enabled: false
# 文件存储路径
file:
mac:
@ -296,13 +309,4 @@ file:
app_avatar:
pic: C:\eladmin\file\ #设备图片存储路径
#ip: http://fuyuanshen.com:81/ #服务器地址
ip: https://fuyuanshen.com/ #服务器地址
# MQTT配置
mqtt:
username: admin
password: fys123456
url: tcp://47.107.152.87:1883
subClientId: fys_subClient
subTopic: worker/location/#
pubTopic: B/#
pubClientId: fys_pubClient
ip: https://fuyuanshen.com/ #服务器地址

View File

@ -99,6 +99,6 @@ public class AppUser extends TenantEntity {
/**
* 地区
*/
private String region;
// private String region;
}

View File

@ -5,6 +5,8 @@ import java.util.Date;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fuyuanshen.app.domain.AppUser;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
@ -87,6 +89,8 @@ public class AppUserVo implements Serializable {
* 密码
*/
@ExcelProperty(value = "密码")
@JsonIgnore
@JsonProperty
private String password;
/**

View File

@ -177,7 +177,7 @@ public class AppUserServiceImpl implements IAppUserService {
appUserVo.setNickName(user.getNickName());
appUserVo.setGender(user.getSex());
appUserVo.setPhone(user.getPhonenumber());
appUserVo.setRegion(user.getRegion());
// appUserVo.setRegion(user.getRegion());
if(user.getAvatar() != null){
SysOssVo oss = sysOssService.getById(user.getAvatar());
if(oss != null){
@ -203,7 +203,7 @@ public class AppUserServiceImpl implements IAppUserService {
updUser.setAvatar(oss.getOssId());
}
updUser.setRegion(bo.getRegion());
// updUser.setRegion(bo.getRegion());
updUser.setSex(bo.getGender());
return baseMapper.update(updUser, new LambdaQueryWrapper<AppUser>().eq(AppUser::getUserId, appUser.getUserId()));
}

View File

@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select a.id,a.business_id,a.file_id,b.file_name,b.url fileUrl from app_business_file a left join sys_oss b on a.file_id = b.oss_id
where 1=1
<if test="createBy != null">
a.create_by = #{createBy}
and a.create_by = #{createBy}
</if>
<if test="businessId != null">
and a.business_id = #{businessId}
@ -19,9 +19,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fileType != null">
and a.file_type = #{fileType}
</if>
<if test="createBy != null">
and a.create_by = #{createBy}
</if>
order by a.create_time desc
</select>
</mapper>

View File

@ -12,7 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.device_pic,
dt.type_name,
dt.communication_mode,
dt.model_dictionary detailPageUrl,
dt.app_model_dictionary detailPageUrl,
d.bluetooth_name,
c.binding_time,
ad.*,u.user_name otherPhonenumber
@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dt.type_name,
dt.communication_mode,
d.bluetooth_name,
dt.model_dictionary detailPageUrl,
dt.app_model_dictionary detailPageUrl,
c.binding_time,
ad.*,u.user_name otherPhonenumber
from

View File

@ -153,5 +153,8 @@ public class Device extends TenantEntity {
*/
@Schema(title = "出厂日期")
private Date productionDate;
/**
* 在线状态(0离线1在线)
*/
private Integer onlineStatus;
}

View File

@ -0,0 +1,32 @@
package com.fuyuanshen.equipment.domain.dto;
import lombok.Data;
@Data
public class InstructionRecordDto {
/**
* 设备类型
*/
private String deviceType;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备MAC
*/
private String deviceMac;
/**
* 设备IMEI
*/
private String deviceImei;
/**
* 操作时间-开始时间
*/
private String startTime;
/**
* 操作时间-结束时间
*/
private String endTime;
}

View File

@ -18,22 +18,34 @@ import java.util.Set;
@Data
public class DeviceQueryCriteria extends BaseEntity {
@Schema(name = "设备id")
/**
* 设备id
*/
private Long deviceId;
@Schema(name = "设备名称")
/**
* 设备名称
*/
private String deviceName;
@Schema(name = "设备类型")
/**
* 设备类型
*/
private Long deviceType;
@Schema(name = "设备MAC")
/**
* 设备MAC
*/
private String deviceMac;
@Schema(name = "设备IMEI")
/**
* 设备IMEI
*/
private String deviceImei;
@Schema(name = "设备SN")
/**
* 设备SN
*/
private String deviceSn;
/**
@ -41,26 +53,37 @@ public class DeviceQueryCriteria extends BaseEntity {
* 0 失效
* 1 正常
*/
@Schema(name = "设备状态 0 失效 1 正常 ")
private Integer deviceStatus;
@Schema(name = "页码", example = "1")
/**
* 页码
*/
private Integer pageNum = 1;
@Schema(name = "每页数据量", example = "10")
/**
* 每页数据量
*/
private Integer pageSize = 10;
@Schema(name = "客户id")
/**
* 客户id
*/
private Long customerId;
private Set<Long> customerIds;
@Schema(name = "当前所有者")
/**
* 当前所有者
*/
private Long currentOwnerId;
@Schema(name = "租户ID")
/**
* 租户ID
*/
private String tenantId;
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
/**
* 通讯方式 0:4G;1:蓝牙
*/
private Integer communicationMode;
/* app绑定用户id */
@ -72,22 +95,22 @@ public class DeviceQueryCriteria extends BaseEntity {
*/
private String personnelBy;
/**
* 是否为管理员
*/
@Schema(name = "是否为管理员")
private Boolean isAdmin = false;
/**
* 设备所属分组
*/
@Schema(name = "设备所属分组")
private Long groupId;
/**
* 设备地区
*/
@Schema(name = "设备地区")
private String area;
}

View File

@ -57,6 +57,11 @@ public class AppDeviceVo implements Serializable {
*/
private Date bindingTime;
/**
* 绑定人
*/
private Date bindingBy;
/**
* 在线状态(0离线1在线)
*/

View File

@ -0,0 +1,32 @@
package com.fuyuanshen.equipment.domain.vo;
import lombok.Data;
@Data
public class InstructionRecordVo {
private Long id;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备类型
*/
private String deviceType;
/**
* 操作模块
*/
private String deviceAction;
/**
* 操作内容
*/
private String content;
/**
* 操作时间
*/
private String createTime;
}

View File

@ -1,8 +1,12 @@
package com.fuyuanshen.equipment.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.equipment.domain.DeviceLog;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.vo.DeviceLogVo;
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
import com.fuyuanshen.equipment.domain.vo.InstructionRecordVo;
import org.apache.ibatis.annotations.Param;
/**
* 设备日志Mapper接口
@ -12,4 +16,5 @@ import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
*/
public interface DeviceLogMapper extends BaseMapperPlus<DeviceLog, DeviceLogVo> {
Page<InstructionRecordVo> getInstructionRecord(Page<InstructionRecordVo> page,@Param("bo") InstructionRecordDto bo);
}

View File

@ -70,5 +70,5 @@ public interface DeviceMapper extends BaseMapper<Device> {
AppDeviceVo getDeviceInfo(@Param("deviceMac") String deviceMac);
Page<WebDeviceVo> queryWebDeviceList(Page<Object> build, DeviceQueryCriteria bo);
Page<WebDeviceVo> queryWebDeviceList(Page<Object> build,@Param("criteria") DeviceQueryCriteria criteria);
}

View File

@ -3,6 +3,7 @@ package com.fuyuanshen.equipment.service;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
import com.fuyuanshen.equipment.domain.bo.DeviceGroupBo;
import jakarta.validation.constraints.NotEmpty;
import java.util.Collection;
import java.util.List;
@ -56,4 +57,14 @@ public interface IDeviceGroupService {
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 绑定设备分组
*
* @param groupId 分组id
* @param deviceId 设备id
* @return 是否绑定成功
*/
Boolean bindingDevice(@NotEmpty(message = "分组id 不能为空") Long groupId, @NotEmpty(message = "设备id 不能为空") Long[] deviceId);
}

View File

@ -1,6 +1,7 @@
package com.fuyuanshen.equipment.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.common.core.domain.R;
@ -11,6 +12,8 @@ import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.satoken.utils.LoginHelper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceTypeGrants;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -22,6 +25,7 @@ import com.fuyuanshen.equipment.mapper.DeviceGroupMapper;
import com.fuyuanshen.equipment.service.IDeviceGroupService;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Collection;
@ -39,6 +43,7 @@ import java.util.stream.Collectors;
public class DeviceGroupServiceImpl implements IDeviceGroupService {
private final DeviceGroupMapper baseMapper;
private final DeviceMapper deviceMapper;
/**
@ -63,7 +68,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
public List<DeviceGroupVo> queryList(DeviceGroupBo bo) {
Page<Device> page = new Page<>(bo.getPageNum(), bo.getPageSize());
// 1. 查询顶级分组parent_id为null
IPage<DeviceGroup> rootGroups = baseMapper.selectRootGroups(bo, page);
IPage<DeviceGroup> rootGroups = baseMapper.selectRootGroups(bo, page);
List<DeviceGroup> records = rootGroups.getRecords();
// 2. 递归构建树形结构
@ -169,4 +174,29 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
}
return baseMapper.deleteByIds(ids) > 0;
}
/**
* 绑定设备分组
*
* @param groupId 分组id
* @param deviceId 设备id
* @return 是否绑定成功
*/
@Override
public Boolean bindingDevice(Long groupId, Long[] deviceId) {
if (deviceId != null && deviceId.length > 0) {
// 创建更新条件
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
updateWrapper.in("id", Arrays.asList(deviceId));
updateWrapper.set("group_id", groupId);
// 执行批量更新
deviceMapper.update(updateWrapper);
}
return true;
}
}

View File

@ -4,4 +4,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceLogMapper">
<select id="getInstructionRecord" resultType="com.fuyuanshen.equipment.domain.vo.InstructionRecordVo">
SELECT
a.id,
a.device_name AS deviceName,
c.type_name deviceType,
a.device_action AS deviceAction,
a.content,
a.create_time AS createTime
FROM
device_log a left join device b on a.device_id = b.id
left join device_type c on b.device_type = c.id
WHERE 1 = 1
<if test="bo.deviceType != null">
AND c.id = #{bo.deviceType}
</if>
<if test="bo.deviceName != null and bo.deviceName != ''">
AND a.device_name like concat('%',#{bo.deviceName},'%')
</if>
<if test="bo.deviceMac != null and bo.deviceMac != ''">
AND b.device_mac = #{bo.deviceMac}
</if>
<if test="bo.deviceImei != null and bo.deviceImei != ''">
AND b.device_imei = #{bo.deviceImei}
</if>
<if test="bo.startTime != null and bo.startTime != ''">
AND create_time <![CDATA[>=]]> #{bo.startTime}
</if>
<if test="bo.endTime != null and bo.endTime != ''">
AND create_time <![CDATA[<=]]> #{bo.startTime}
</if>
ORDER BY
a.create_time DESC
</select>
</mapper>

View File

@ -151,7 +151,7 @@
dt.type_name,
dt.communication_mode,
d.bluetooth_name,
dt.model_dictionary detailPageUrl,
dt.app_model_dictionary detailPageUrl,
c.binding_time
from device d
inner join device_type dt on d.device_type = dt.id
@ -181,7 +181,7 @@
d.device_pic,
dt.type_name,
dt.communication_mode,
dt.model_dictionary detailPageUrl,
dt.app_model_dictionary detailPageUrl,
d.bluetooth_name
from device d
inner join device_type dt on d.device_type = dt.id
@ -227,7 +227,7 @@
dt.type_name,
dt.communication_mode,
d.bluetooth_name,
dt.model_dictionary detailPageUrl
dt.app_model_dictionary detailPageUrl
from device d
inner join device_type dt on d.device_type = dt.id
where d.device_mac = #{deviceMac}
@ -242,7 +242,7 @@
dt.type_name,
dt.communication_mode,
d.bluetooth_name,
dt.model_dictionary detailPageUrl,
dt.pc_model_dictionary detailPageUrl,
ap.name personnelBy,
d.device_status,
c.binding_time
@ -254,7 +254,7 @@
<if test="criteria.deviceType != null">
and d.device_type = #{criteria.deviceType}
</if>
<if test="criteria.deviceName != null">
<if test="criteria.deviceName != null and criteria.deviceName != ''">
and d.device_name like concat('%', #{criteria.deviceName}, '%')
</if>
<if test="criteria.deviceMac != null">
@ -270,7 +270,10 @@
and ap.name like concat('%', #{criteria.personnelBy}, '%')
</if>
<if test="criteria.communicationMode != null">
and dt.communication_mode, = #{criteria.communicationMode}
and dt.communication_mode = #{criteria.communicationMode}
</if>
<if test="criteria.groupId != null">
and d.group_id = #{criteria.groupId}
</if>
</select>

11
pom.xml
View File

@ -83,6 +83,10 @@
<monitor.username>fys</monitor.username>
<monitor.password>123456</monitor.password>
</properties>
<activation>
<!-- 默认环境 -->
<activeByDefault>true</activeByDefault>
</activation>
<!-- <activation> -->
<!-- &lt;!&ndash; 默认环境 &ndash;&gt; -->
<!-- <activeByDefault>true</activeByDefault> -->
@ -92,14 +96,11 @@
<id>prod</id>
<properties>
<profiles.active>prod</profiles.active>
<logging.level>warn</logging.level>
<logging.level>info</logging.level>
<monitor.username>fys</monitor.username>
<monitor.password>123456</monitor.password>
</properties>
<activation>
<!-- 默认环境 -->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>jingquan</id>