7 Commits

Author SHA1 Message Date
d701a834b3 设备IMEI 模糊查询 2025-10-08 09:37:18 +08:00
e1ac87e5f2 在线状态 2025-10-07 16:11:06 +08:00
5c3a35c83e 在线状态 2025-10-07 16:09:59 +08:00
2c0eff2b2c Merge remote-tracking branch 'origin/6170' into 6170 2025-10-07 15:50:26 +08:00
37e07d2706 控制中心优化2 2025-10-07 15:50:16 +08:00
dfa5b446f9 控制中心优化 2025-10-07 09:50:49 +08:00
9afc0222d5 app批量上传logo 2025-09-30 17:53:28 +08:00
9 changed files with 115 additions and 28 deletions

View File

@ -5,6 +5,7 @@ import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto; import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo; import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
import com.fuyuanshen.common.core.domain.R; import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.validate.AddGroup; import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation; import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation; import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
@ -17,6 +18,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/** /**
* BJQ6170设备控制类 * BJQ6170设备控制类
*/ */
@ -82,6 +85,8 @@ public class AppDeviceBJQController extends BaseController {
return R.ok(); return R.ok();
} }
/** /**
* 灯光模式 * 灯光模式
* 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式 * 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式

View File

@ -3,6 +3,8 @@ package com.fuyuanshen.app.domain.dto;
import lombok.Data; import lombok.Data;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Data @Data
public class AppDeviceLogoUploadDto { public class AppDeviceLogoUploadDto {
@ -14,5 +16,13 @@ public class AppDeviceLogoUploadDto {
*/ */
private MultipartFile file; private MultipartFile file;
// /**
// * 文件
// */
// private List<MultipartFile> files;
private List<Long> deviceIds;
private Integer chunkSize; private Integer chunkSize;
} }

View File

@ -65,13 +65,22 @@ public class RedisKeyExpirationListener implements MessageListener {
if (lockInfo != null) { if (lockInfo != null) {
try { try {
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ message + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ; String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ message + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
// String deviceOnlineStatusRedis = RedisUtils.getCacheObject(deviceOnlineStatusRedisKey);
// if(StringUtils.isBlank(deviceOnlineStatusRedis)){
// UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
// deviceUpdateWrapper.eq("device_imei", element);
// deviceUpdateWrapper.set("online_status", 0);
// deviceMapper.update(deviceUpdateWrapper);
// }else{
// RedisUtils.deleteObject(deviceOnlineStatusRedisKey);
// }
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
deviceUpdateWrapper.eq("device_imei", element);
deviceUpdateWrapper.set("online_status", 0);
deviceMapper.update(deviceUpdateWrapper);
String deviceOnlineStatusRedis = RedisUtils.getCacheObject(deviceOnlineStatusRedisKey); String deviceOnlineStatusRedis = RedisUtils.getCacheObject(deviceOnlineStatusRedisKey);
if(StringUtils.isBlank(deviceOnlineStatusRedis)){ if(StringUtils.isNotBlank(deviceOnlineStatusRedis)){
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
deviceUpdateWrapper.eq("device_imei", element);
deviceUpdateWrapper.set("online_status", 0);
deviceMapper.update(deviceUpdateWrapper);
}else{
RedisUtils.deleteObject(deviceOnlineStatusRedisKey); RedisUtils.deleteObject(deviceOnlineStatusRedisKey);
} }
} finally { } finally {

View File

@ -56,7 +56,7 @@ public class ReceiverMessageHandler implements MessageHandler {
RedisUtils.offerDeduplicated(queueKey,dedupKey,deviceImei, Duration.ofHours(24)); RedisUtils.offerDeduplicated(queueKey,dedupKey,deviceImei, Duration.ofHours(24));
//在线状态 //在线状态
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ; String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(303)); RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(360));
} }

View File

@ -106,16 +106,22 @@ public class MqttMessageConsumer {
// .set("online_status", 1); // .set("online_status", 1);
// deviceMapper.update(updateWrapper); // deviceMapper.update(updateWrapper);
// } // }
QueryWrapper<Device> queryWrapper = new QueryWrapper<>(); // QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("device_imei", message); // queryWrapper.eq("device_imei", message);
queryWrapper.eq("online_status", 1); // queryWrapper.eq("online_status", 1);
Long count = deviceMapper.selectCount(queryWrapper); // Long count = deviceMapper.selectCount(queryWrapper);
if(count == 0){ // if(count == 0){
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>(); // UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("device_imei", message) // updateWrapper.eq("device_imei", message)
.set("online_status", 1); // .eq("online_status", 0)
deviceMapper.update(updateWrapper); // .set("online_status", 1);
} // deviceMapper.update(updateWrapper);
// }
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("device_imei", message)
.eq("online_status", 0)
.set("online_status", 1);
int update = deviceMapper.update(updateWrapper);
// 模拟业务处理耗时 // 模拟业务处理耗时
// Thread.sleep(200); // Thread.sleep(200);

View File

@ -82,6 +82,22 @@ public class DeviceBJQController extends BaseController {
return R.ok(); return R.ok();
} }
/**
* 批量上传设备logo图片
*/
@PostMapping("/batchUploadLogo")
@FunctionAccessAnnotation("batchUploadLogo")
public R<Void> batchUploadLogo(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
MultipartFile file = bo.getFile();
if(file.getSize()>1024*1024*2){
return R.warn("图片不能大于2M");
}
appDeviceService.batchUploadLogo(bo);
return R.ok();
}
/** /**
* 灯光模式 * 灯光模式
* 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式 * 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式

View File

@ -15,6 +15,7 @@ import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper; import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper; import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
import com.fuyuanshen.common.core.constant.GlobalConstants; import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.exception.ServiceException; import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.utils.*; import com.fuyuanshen.common.core.utils.*;
import com.fuyuanshen.common.redis.utils.RedisUtils; import com.fuyuanshen.common.redis.utils.RedisUtils;
@ -172,10 +173,13 @@ public class DeviceBJQBizService {
} }
//设备在线状态 //设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei()+ DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX); String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei()+ DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if(StringUtils.isNotBlank(onlineStatus)){ //设备在线状态
vo.setOnlineStatus(1); if("1".equals(onlineStatus)){
vo.setOnlineStatus(1);
}else if("2".equals(onlineStatus)){
vo.setOnlineStatus(2);
}else{ }else{
vo.setOnlineStatus(0); vo.setOnlineStatus(0);
} }
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX); String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX);
// 获取电量 // 获取电量
@ -334,7 +338,10 @@ public class DeviceBJQBizService {
throw new ServiceException("设备不存在"); throw new ServiceException("设备不存在");
} }
if(getDeviceStatus(device.getDeviceImei())){ if(getDeviceStatus(device.getDeviceImei())){
throw new ServiceException(device.getDeviceName()+",设备已断开连接"); // throw new ServiceException(device.getDeviceName()+",设备已断开连接");
log.info(device.getDeviceName()+",设备已断开连接");
recordDeviceLog(device.getId(), device.getDeviceName(), "上传开机画面", device.getDeviceName()+",设备已断开连接", AppLoginHelper.getUserId());
return;
} }
MultipartFile file = bo.getFile(); MultipartFile file = bo.getFile();
@ -546,4 +553,19 @@ public class DeviceBJQBizService {
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ; String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
return RedisUtils.getCacheObject(deviceOnlineStatusRedisKey) == null; return RedisUtils.getCacheObject(deviceOnlineStatusRedisKey) == null;
} }
public void batchUploadLogo(AppDeviceLogoUploadDto bo) {
List<Long> deviceIds = bo.getDeviceIds();
MultipartFile file = bo.getFile();
if (deviceIds == null || deviceIds.isEmpty()) {
throw new ServiceException("请选择设备");
}
for (Long deviceId : deviceIds) {
AppDeviceLogoUploadDto dto = new AppDeviceLogoUploadDto();
dto.setDeviceId(deviceId);
dto.setFile(file);
uploadDeviceLogo(dto);
}
}
} }

View File

@ -58,6 +58,13 @@ public class WebDeviceVo implements Serializable {
*/ */
private Integer deviceStatus; private Integer deviceStatus;
/**绑定状态
* 0 未绑定
* 1 已绑定
*/
private Integer bindingStatus;
/** /**
* 绑定时间 * 绑定时间
*/ */

View File

@ -42,7 +42,7 @@
FROM ( FROM (
SELECT SELECT
da.id AS id, d.id AS deviceId, d.device_name, d.bluetooth_name, d.group_id, da.id AS id, d.id AS deviceId, d.device_name, d.bluetooth_name, d.group_id,
d.pub_topic, d.sub_topic, d.device_pic, d.pub_topic, d.sub_topic, d.device_pic,d.online_status,
d.device_mac, d.device_sn, d.update_by, d.device_mac, d.device_sn, d.update_by,
d.device_imei, d.update_time, dg.id AS device_type, d.device_imei, d.update_time, dg.id AS device_type,
d.remark, d.binding_status, t.type_name AS typeName, d.remark, d.binding_status, t.type_name AS typeName,
@ -59,11 +59,11 @@
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''"> <if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%') and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
</if> </if>
<if test="criteria.deviceMac != null"> <if test="criteria.deviceMac != null and criteria.deviceMac.trim() != ''">
and d.device_mac = #{criteria.deviceMac} and d.device_mac like concat('%', TRIM(#{criteria.deviceMac}), '%')
</if> </if>
<if test="criteria.deviceImei != null"> <if test="criteria.deviceImei != null and criteria.deviceImei.trim() != ''">
and d.device_imei = #{criteria.deviceImei} and d.device_imei like concat('%', TRIM(#{criteria.deviceImei}), '%')
</if> </if>
<if test="criteria.deviceType != null"> <if test="criteria.deviceType != null">
and d.device_type = #{criteria.deviceType} and d.device_type = #{criteria.deviceType}
@ -252,12 +252,13 @@
dt.pc_model_dictionary detailPageUrl, dt.pc_model_dictionary detailPageUrl,
ap.name personnelBy, ap.name personnelBy,
d.device_status, d.device_status,
d.binding_status,
d.online_status, d.online_status,
c.binding_time, c.binding_time,
ROW_NUMBER() OVER (PARTITION BY d.id ORDER BY c.binding_time) AS row_num ROW_NUMBER() OVER (PARTITION BY d.id ORDER BY c.binding_time) AS row_num
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
inner join app_device_bind_record c on d.id = c.device_id left join app_device_bind_record c on d.id = c.device_id
left join app_personnel_info ap on ap.device_id = d.id left join app_personnel_info ap on ap.device_id = d.id
where dt.communication_mode in (0, 2) ) a where a.row_num = 1 where dt.communication_mode in (0, 2) ) a where a.row_num = 1
<if test="criteria.deviceType != null"> <if test="criteria.deviceType != null">
@ -452,7 +453,7 @@
</select> </select>
<!-- 获取设备使用频次统计 --> <!-- 获取设备使用频次统计 -->
<select id="getDeviceUsageFrequency" resultType="com.fuyuanshen.equipment.domain.vo.DeviceUsageFrequencyVo"> <select id="getDeviceUsageFrequency1" resultType="com.fuyuanshen.equipment.domain.vo.DeviceUsageFrequencyVo">
SELECT SELECT
device_name AS deviceName, device_name AS deviceName,
COUNT(*) AS frequency COUNT(*) AS frequency
@ -461,6 +462,17 @@
GROUP BY device_name GROUP BY device_name
ORDER BY frequency DESC ORDER BY frequency DESC
</select> </select>
<!-- 获取设备使用频次统计 (设备类型)-->
<select id="getDeviceUsageFrequency" resultType="com.fuyuanshen.equipment.domain.vo.DeviceUsageFrequencyVo">
SELECT
d.type_name AS deviceName,
COUNT(*) AS frequency
FROM device_log dl
LEFT JOIN device d ON dl.device_id = d.id
WHERE dl.create_time >= DATE_SUB(NOW(), INTERVAL #{days} DAY)
GROUP BY d.device_type, d.type_name
ORDER BY frequency DESC
</select>
<!-- 根据设备IMEI查询设备 --> <!-- 根据设备IMEI查询设备 -->
<select id="selectDeviceByImei" resultType="com.fuyuanshen.equipment.domain.Device"> <select id="selectDeviceByImei" resultType="com.fuyuanshen.equipment.domain.Device">