Compare commits
8 Commits
9f0155a6e3
...
7b8c626cb6
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b8c626cb6 | |||
| 9642908035 | |||
| 85b2e2b976 | |||
| 88ac0236bd | |||
| 609a3e4058 | |||
| 68cf78f3f2 | |||
| c9857a679c | |||
| 6439a96e3d |
@ -5,6 +5,7 @@ import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fuyuanshen.app.model.AppRegisterBody;
|
||||
import com.fuyuanshen.app.model.AppSmsLoginBody;
|
||||
import com.fuyuanshen.app.service.AppLoginService;
|
||||
@ -32,6 +33,7 @@ import com.fuyuanshen.system.service.ISysClientService;
|
||||
import com.fuyuanshen.system.service.ISysConfigService;
|
||||
import com.fuyuanshen.system.service.ISysDictTypeService;
|
||||
import com.fuyuanshen.system.service.ISysTenantService;
|
||||
import com.fuyuanshen.web.domain.Dto.SystemVersionDto;
|
||||
import com.fuyuanshen.web.domain.vo.LoginTenantVo;
|
||||
import com.fuyuanshen.web.domain.vo.LoginVo;
|
||||
import com.fuyuanshen.web.domain.vo.TenantListVo;
|
||||
@ -54,6 +56,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.DEVICE_SHARE_CODES_KEY;
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
|
||||
|
||||
/**
|
||||
* APP认证
|
||||
@ -261,23 +264,14 @@ public class AppAuthController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/version")
|
||||
public R<List<SysDictDataVo>> getAppVersion() {
|
||||
List<SysDictDataVo> list = dictTypeService.selectDictDataByType("app_version");
|
||||
|
||||
list.forEach(d -> {
|
||||
// 1. 安全拆分
|
||||
String[] arr = d.getRemark() == null ? new String[0] : d.getRemark().split("\\|");
|
||||
if (arr.length < 2) { // 格式不对
|
||||
log.warn("字典数据 app_version 格式非法:dictLabel={}, remark={}", d.getDictLabel(), d.getRemark());
|
||||
d.setDictValue(""); // 或者 d.setDictValue(d.getDictValue());
|
||||
d.setRemark(""); // 下载地址留空
|
||||
return; // 跳过
|
||||
}
|
||||
// 2. 正常赋值
|
||||
d.setDictValue(arr[0].trim()); // 版本号
|
||||
d.setRemark(arr[1].trim()); // 下载地址
|
||||
});
|
||||
|
||||
public R<List<SystemVersionDto>> getAppVersion() {
|
||||
String versionKey = GLOBAL_REDIS_KEY + "System:Version:Xinghan";
|
||||
// 缓存告警消息到Redis
|
||||
String versionJson = RedisUtils.getCacheObject(versionKey);
|
||||
if (StringUtils.isBlank(versionJson)) { // hutool 工具,可用 StringUtils.isBlank 代替
|
||||
return R.fail(versionJson);
|
||||
}
|
||||
List<SystemVersionDto> list = JSON.parseArray(versionJson, SystemVersionDto.class);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
@ -57,10 +57,9 @@ public class BjqAlarmRule implements MqttMessageRule {
|
||||
if (StringUtils.isNotBlank(convertValue)) {
|
||||
// 将设备状态信息存储到Redis中
|
||||
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX;
|
||||
// 存储到Redis
|
||||
RedisUtils.setCacheObject(deviceRedisKey, convertValue);
|
||||
if ("1".equals(convertValue)) {
|
||||
// 存储到Redis
|
||||
RedisUtils.setCacheObject(deviceRedisKey, convertValue);
|
||||
|
||||
String sendMessageIng = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending";
|
||||
RedisUtils.setCacheObject(sendMessageIng, "1", Duration.ofDays(1));
|
||||
}else if ("0".equals(convertValue)){
|
||||
|
||||
@ -1,16 +1,21 @@
|
||||
package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
|
||||
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
|
||||
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
|
||||
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
|
||||
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
||||
import com.fuyuanshen.web.domain.Dto.DeviceXinghanInstructDto;
|
||||
import com.fuyuanshen.web.domain.Dto.SystemVersionDto;
|
||||
import com.fuyuanshen.web.domain.vo.DeviceXinghanDetailVo;
|
||||
import com.fuyuanshen.web.service.device.DeviceXinghanBizService;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@ -19,6 +24,13 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
|
||||
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_ALARM_MESSAGE_KEY_PREFIX;
|
||||
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
|
||||
|
||||
/**
|
||||
* 设备控制类 HBY670
|
||||
*/
|
||||
@ -130,4 +142,22 @@ public class DeviceXinghanController extends BaseController {
|
||||
deviceXinghanBizService.upShakeBitSettings(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 版本更新
|
||||
*/
|
||||
@SaCheckPermission("system:appVersion:up")
|
||||
@PostMapping("/UpVersion")
|
||||
public R<Void> VersionSettings(@RequestBody List<SystemVersionDto> params) {
|
||||
// params 已经是 List<SystemVersionDto>
|
||||
// 2. 转 JSON 并写 Redis,key 自己定,带个过期时间
|
||||
String versionKey = GLOBAL_REDIS_KEY + "System:Version:Xinghan";
|
||||
String json = JSON.toJSONString(params); // fastjson
|
||||
if (StringUtils.isBlank(json)) { // hutool 工具,可用 StringUtils.isBlank 代替
|
||||
return R.fail("信息无效");
|
||||
}
|
||||
// 缓存告警消息到Redis
|
||||
RedisUtils.setCacheObject(versionKey, json, Duration.ofDays(30));
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package com.fuyuanshen.web.domain.Dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SystemVersionDto {
|
||||
private String dictValue;
|
||||
private String dictLabel;
|
||||
private String remark;
|
||||
}
|
||||
@ -526,10 +526,13 @@ public class DeviceBJQBizService {
|
||||
|
||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", deviceId)
|
||||
.eq("binding_user_id", AppLoginHelper.getUserId())
|
||||
.set("send_msg", bo.getSendMsg());
|
||||
deviceMapper.update(updateWrapper);
|
||||
recordDeviceLog(device.getId(), device.getDeviceName(), "发送告警信息", bo.getSendMsg(), AppLoginHelper.getUserId());
|
||||
if("0".equals(bo.getInstructValue())){
|
||||
recordDeviceLog(device.getId(), device.getDeviceName(), "解除告警信息", "关闭设备", AppLoginHelper.getUserId());
|
||||
}else{
|
||||
recordDeviceLog(device.getId(), device.getDeviceName(), "发送告警信息", bo.getSendMsg(), AppLoginHelper.getUserId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("设备发送告警信息信息失败:{}" ,deviceId);
|
||||
throw new ServiceException("设备发送告警信息信息失败");
|
||||
|
||||
@ -131,14 +131,14 @@ public class DeviceBizService {
|
||||
if(item.getCommunicationMode()!=null && Ints.asList(0, 2).contains(item.getCommunicationMode())){
|
||||
|
||||
//设备在线状态
|
||||
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||
if("1".equals(onlineStatus)){
|
||||
item.setOnlineStatus(1);
|
||||
}else if("2".equals(onlineStatus)){
|
||||
item.setOnlineStatus(2);
|
||||
}else{
|
||||
item.setOnlineStatus(0);
|
||||
}
|
||||
// String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||
// if("1".equals(onlineStatus)){
|
||||
// item.setOnlineStatus(1);
|
||||
// }else if("2".equals(onlineStatus)){
|
||||
// item.setOnlineStatus(2);
|
||||
// }else{
|
||||
// item.setOnlineStatus(0);
|
||||
// }
|
||||
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX+ item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
|
||||
// 获取电量
|
||||
if(StringUtils.isNotBlank(deviceStatus)){
|
||||
|
||||
@ -258,6 +258,7 @@
|
||||
d.binding_status,
|
||||
d.online_status,
|
||||
c.binding_time,
|
||||
d.create_time,
|
||||
ROW_NUMBER() OVER (PARTITION BY d.id ORDER BY c.binding_time) AS row_num
|
||||
from device d
|
||||
inner join device_type dt on d.device_type = dt.id
|
||||
@ -291,7 +292,7 @@
|
||||
<if test="criteria.onlineStatus != null">
|
||||
and a.online_status = #{criteria.onlineStatus}
|
||||
</if>
|
||||
ORDER BY a.online_status,a.binding_time DESC
|
||||
ORDER BY (case when a.online_status = 1 then 2 else 1 end) DESC
|
||||
</select>
|
||||
<select id="getLocationHistory" resultType="com.fuyuanshen.equipment.domain.vo.LocationHistoryVo">
|
||||
select a.id,a.device_name,a.device_type,b.type_name deviceTypeName,a.device_imei,a.device_mac from device a
|
||||
|
||||
Reference in New Issue
Block a user