web端控制中心3

This commit is contained in:
2025-08-27 08:59:29 +08:00
parent 74cefe9cc3
commit 364574eeae
13 changed files with 196 additions and 44 deletions

View File

@ -15,8 +15,7 @@ import org.springframework.stereotype.Component;
import java.time.Duration; import java.time.Duration;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY; 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.*;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX;
/** /**
* 灯光模式订阅设备回传消息 * 灯光模式订阅设备回传消息
@ -37,14 +36,10 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
try { try {
Object[] convertArr = context.getConvertArr(); Object[] convertArr = context.getConvertArr();
String mainLightMode = convertArr[1].toString(); String mode = convertArr[1].toString();
if(StringUtils.isNotBlank(mainLightMode)){ if(StringUtils.isNotBlank(mode)){
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));
}
// 发送设备状态和位置信息到Redis // 发送设备状态和位置信息到Redis
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mainLightMode); syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mode);
} }
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(30)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(30));
@ -65,7 +60,7 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
// }); // });
try { try {
// 将设备状态信息存储到Redis中 // 将设备状态信息存储到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 // 存储到Redis
RedisUtils.setCacheObject(deviceRedisKey, convertValue.toString()); 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.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController; import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo; 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.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo; 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.domain.vo.WebDeviceVo;
import com.fuyuanshen.web.service.device.DeviceBizService; import com.fuyuanshen.web.service.device.DeviceBizService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -30,7 +28,7 @@ import java.util.Map;
@Slf4j @Slf4j
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/api/device/controlCenter") @RequestMapping("/api/device")
public class DeviceControlCenterController extends BaseController { public class DeviceControlCenterController extends BaseController {
private final DeviceBizService appDeviceService; private final DeviceBizService appDeviceService;
@ -95,4 +93,12 @@ public class DeviceControlCenterController extends BaseController {
return R.ok(appDeviceService.getDeviceInfo(deviceMac)); return R.ok(appDeviceService.getDeviceInfo(deviceMac));
} }
/**
* 指令下发记录
*/
@GetMapping("/instructionRecord")
public TableDataInfo<InstructionRecordVo> getInstructionRecord(InstructionRecordDto dto, PageQuery pageQuery) {
return appDeviceService.getInstructionRecord(dto,pageQuery);
}
} }

View File

@ -190,6 +190,22 @@ public class DeviceBJQBizService {
vo.setBatteryPercentage("0"); 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 locationKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
String locationInfo = RedisUtils.getCacheObject(locationKey); 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.domain.vo.AppUserVo;
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper; import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
import com.fuyuanshen.app.mapper.AppDeviceShareMapper; import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.app.mapper.AppUserMapper; import com.fuyuanshen.app.mapper.AppUserMapper;
import com.fuyuanshen.app.mapper.equipment.APPDeviceMapper; import com.fuyuanshen.app.mapper.equipment.APPDeviceMapper;
import com.fuyuanshen.common.core.exception.ServiceException; 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.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.equipment.domain.Device; import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo; 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.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo; 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.domain.vo.WebDeviceVo;
import com.fuyuanshen.equipment.enums.BindingStatusEnum; import com.fuyuanshen.equipment.enums.BindingStatusEnum;
import com.fuyuanshen.equipment.enums.CommunicationModeEnum; import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
import com.fuyuanshen.equipment.mapper.DeviceLogMapper; import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
import com.fuyuanshen.equipment.mapper.DeviceMapper; 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.global.mqtt.constants.DeviceRedisKeyConstants;
import com.fuyuanshen.web.service.device.status.base.DeviceStatusRule; import com.fuyuanshen.web.service.device.status.base.DeviceStatusRule;
import com.fuyuanshen.web.service.device.status.base.RealTimeStatusEngine; import com.fuyuanshen.web.service.device.status.base.RealTimeStatusEngine;
@ -332,4 +331,9 @@ public class DeviceBizService {
// List<Device> devices = deviceMapper.selectList(queryWrapper); // List<Device> devices = deviceMapper.selectList(queryWrapper);
return deviceMapper.getDeviceInfo(deviceMac); 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

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

View File

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

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

@ -4,4 +4,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceLogMapper"> <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> </mapper>

View File

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