forked from dyf/fys-Multi-tenant
Compare commits
13 Commits
88ac0236bd
...
7b8c626cb6
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b8c626cb6 | |||
| 9642908035 | |||
| 85b2e2b976 | |||
| 609a3e4058 | |||
| 68cf78f3f2 | |||
| c9857a679c | |||
| 6439a96e3d | |||
| 9f0155a6e3 | |||
| 6c99cef65d | |||
| 840c4fd68f | |||
| dc0fe96652 | |||
| cf883bfa00 | |||
| 6a6397da23 |
@ -6,6 +6,7 @@ import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
|
|||||||
import com.fuyuanshen.common.core.domain.R;
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
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.satoken.utils.AppLoginHelper;
|
||||||
import com.fuyuanshen.common.web.core.BaseController;
|
import com.fuyuanshen.common.web.core.BaseController;
|
||||||
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;
|
||||||
@ -53,7 +54,8 @@ public class AppDeviceController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@DeleteMapping("/unBind")
|
@DeleteMapping("/unBind")
|
||||||
public R<Void> unBind(Long id) {
|
public R<Void> unBind(Long id) {
|
||||||
return toAjax(appDeviceService.unBindDevice(id));
|
Long userId = AppLoginHelper.getUserId();
|
||||||
|
return toAjax(appDeviceService.unBindDevice(id,userId,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -57,10 +57,9 @@ public class BjqAlarmRule implements MqttMessageRule {
|
|||||||
if (StringUtils.isNotBlank(convertValue)) {
|
if (StringUtils.isNotBlank(convertValue)) {
|
||||||
// 将设备状态信息存储到Redis中
|
// 将设备状态信息存储到Redis中
|
||||||
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX;
|
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)) {
|
if ("1".equals(convertValue)) {
|
||||||
// 存储到Redis
|
|
||||||
RedisUtils.setCacheObject(deviceRedisKey, convertValue);
|
|
||||||
|
|
||||||
String sendMessageIng = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending";
|
String sendMessageIng = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending";
|
||||||
RedisUtils.setCacheObject(sendMessageIng, "1", Duration.ofDays(1));
|
RedisUtils.setCacheObject(sendMessageIng, "1", Duration.ofDays(1));
|
||||||
}else if ("0".equals(convertValue)){
|
}else if ("0".equals(convertValue)){
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
package com.fuyuanshen.global.mqtt.rule.bjq;
|
package com.fuyuanshen.global.mqtt.rule.bjq;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||||
|
import com.fuyuanshen.common.core.utils.date.DurationUtils;
|
||||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||||
import com.fuyuanshen.equipment.domain.Device;
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
|
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
|
||||||
|
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
|
||||||
import com.fuyuanshen.equipment.service.DeviceService;
|
import com.fuyuanshen.equipment.service.DeviceService;
|
||||||
|
import com.fuyuanshen.equipment.service.IDeviceAlarmService;
|
||||||
import com.fuyuanshen.global.mqtt.base.MqttMessageRule;
|
import com.fuyuanshen.global.mqtt.base.MqttMessageRule;
|
||||||
import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
|
import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
|
||||||
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
|
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
|
||||||
@ -16,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||||
@ -31,6 +37,8 @@ import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
|
|||||||
public class BjqModeRule implements MqttMessageRule {
|
public class BjqModeRule implements MqttMessageRule {
|
||||||
|
|
||||||
private final DeviceService deviceService;
|
private final DeviceService deviceService;
|
||||||
|
private final IDeviceAlarmService deviceAlarmService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCommandType() {
|
public String getCommandType() {
|
||||||
@ -45,18 +53,18 @@ public class BjqModeRule implements MqttMessageRule {
|
|||||||
|
|
||||||
String mainLightMode = convertArr[1].toString();
|
String mainLightMode = convertArr[1].toString();
|
||||||
String batteryRemainingTime = convertArr[2].toString();
|
String batteryRemainingTime = convertArr[2].toString();
|
||||||
if(StringUtils.isNotBlank(mainLightMode)){
|
if (StringUtils.isNotBlank(mainLightMode)) {
|
||||||
log.info("设备离线mainLightMode:{}",mainLightMode);
|
log.info("设备离线mainLightMode:{}", mainLightMode);
|
||||||
if("0".equals(mainLightMode)){
|
if ("0".equals(mainLightMode)) {
|
||||||
|
|
||||||
//设备离线
|
// 设备离线
|
||||||
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ context.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
|
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + context.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX;
|
||||||
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "0");
|
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "0");
|
||||||
|
|
||||||
String sendMessageIng = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending";
|
String sendMessageIng = GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending";
|
||||||
String messageSendingValue = RedisUtils.getCacheObject(sendMessageIng);
|
String messageSendingValue = RedisUtils.getCacheObject(sendMessageIng);
|
||||||
if("1".equals(messageSendingValue)){
|
if ("1".equals(messageSendingValue)) {
|
||||||
//设置为故障状态
|
// 设置为故障状态
|
||||||
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "2");
|
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "2");
|
||||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||||
updateWrapper.eq("device_imei", context.getDeviceImei());
|
updateWrapper.eq("device_imei", context.getDeviceImei());
|
||||||
@ -66,14 +74,15 @@ public class BjqModeRule implements MqttMessageRule {
|
|||||||
|
|
||||||
// 解除告警
|
// 解除告警
|
||||||
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX;
|
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX;
|
||||||
if(RedisUtils.getCacheObject(deviceRedisKey) != null){
|
if (RedisUtils.getCacheObject(deviceRedisKey) != null) {
|
||||||
RedisUtils.deleteObject(deviceRedisKey);
|
RedisUtils.deleteObject(deviceRedisKey);
|
||||||
}
|
}
|
||||||
|
cancelAlarm(context.getDeviceImei());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 发送设备状态和位置信息到Redis
|
// 发送设备状态和位置信息到Redis
|
||||||
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mainLightMode);
|
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(), mainLightMode);
|
||||||
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX;
|
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX;
|
||||||
|
|
||||||
// 存储到Redis
|
// 存储到Redis
|
||||||
RedisUtils.setCacheObject(deviceRedisKey, batteryRemainingTime);
|
RedisUtils.setCacheObject(deviceRedisKey, batteryRemainingTime);
|
||||||
@ -90,13 +99,13 @@ public class BjqModeRule implements MqttMessageRule {
|
|||||||
*
|
*
|
||||||
* @param deviceImei 设备IMEI
|
* @param deviceImei 设备IMEI
|
||||||
*/
|
*/
|
||||||
public void syncSendDeviceDataToRedisWithFuture(String deviceImei,Object convertValue) {
|
public void syncSendDeviceDataToRedisWithFuture(String deviceImei, Object convertValue) {
|
||||||
// CompletableFuture.runAsync(() -> {
|
// CompletableFuture.runAsync(() -> {
|
||||||
//
|
//
|
||||||
// });
|
// });
|
||||||
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_LIGHT_MODE_KEY_PREFIX;
|
||||||
|
|
||||||
// 存储到Redis
|
// 存储到Redis
|
||||||
RedisUtils.setCacheObject(deviceRedisKey, convertValue.toString());
|
RedisUtils.setCacheObject(deviceRedisKey, convertValue.toString());
|
||||||
@ -107,5 +116,29 @@ public class BjqModeRule implements MqttMessageRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解除告警
|
||||||
|
*
|
||||||
|
* @param deviceImei 设备IMEI
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void cancelAlarm(String deviceImei) {
|
||||||
|
DeviceAlarmVo deviceAlarmVo = deviceAlarmService.queryLatestByDeviceImei(deviceImei);
|
||||||
|
DeviceAlarmBo deviceAlarmBo = new DeviceAlarmBo();
|
||||||
|
if (deviceAlarmVo != null) {
|
||||||
|
if (deviceAlarmVo.getFinishTime() == null) {
|
||||||
|
BeanUtil.copyProperties(deviceAlarmVo, deviceAlarmBo);
|
||||||
|
deviceAlarmBo.setFinishTime(new Date());
|
||||||
|
String durationBetween = DurationUtils.getDurationBetween(deviceAlarmVo.getStartTime(), deviceAlarmBo.getFinishTime());
|
||||||
|
deviceAlarmBo.setDurationTime(durationBetween);
|
||||||
|
// 0已处理,1未处理
|
||||||
|
deviceAlarmBo.setTreatmentState(0);
|
||||||
|
// 告警状态,0 解除告警, 1 告警中
|
||||||
|
deviceAlarmBo.setAlarmState(0);
|
||||||
|
deviceAlarmService.updateByBo(deviceAlarmBo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -119,7 +119,7 @@ public class MqttMessageConsumer {
|
|||||||
// }
|
// }
|
||||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||||
updateWrapper.eq("device_imei", message)
|
updateWrapper.eq("device_imei", message)
|
||||||
.eq("online_status", 0)
|
.in("online_status", 0,2)
|
||||||
.set("online_status", 1);
|
.set("online_status", 1);
|
||||||
int update = deviceMapper.update(updateWrapper);
|
int update = deviceMapper.update(updateWrapper);
|
||||||
// 模拟业务处理耗时
|
// 模拟业务处理耗时
|
||||||
|
|||||||
@ -526,10 +526,13 @@ public class DeviceBJQBizService {
|
|||||||
|
|
||||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||||
updateWrapper.eq("id", deviceId)
|
updateWrapper.eq("id", deviceId)
|
||||||
.eq("binding_user_id", AppLoginHelper.getUserId())
|
|
||||||
.set("send_msg", bo.getSendMsg());
|
.set("send_msg", bo.getSendMsg());
|
||||||
deviceMapper.update(updateWrapper);
|
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) {
|
} catch (Exception e) {
|
||||||
log.info("设备发送告警信息信息失败:{}" ,deviceId);
|
log.info("设备发送告警信息信息失败:{}" ,deviceId);
|
||||||
throw new ServiceException("设备发送告警信息信息失败");
|
throw new ServiceException("设备发送告警信息信息失败");
|
||||||
|
|||||||
@ -131,14 +131,14 @@ public class DeviceBizService {
|
|||||||
if(item.getCommunicationMode()!=null && Ints.asList(0, 2).contains(item.getCommunicationMode())){
|
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);
|
// String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||||
if("1".equals(onlineStatus)){
|
// if("1".equals(onlineStatus)){
|
||||||
item.setOnlineStatus(1);
|
// item.setOnlineStatus(1);
|
||||||
}else if("2".equals(onlineStatus)){
|
// }else if("2".equals(onlineStatus)){
|
||||||
item.setOnlineStatus(2);
|
// item.setOnlineStatus(2);
|
||||||
}else{
|
// }else{
|
||||||
item.setOnlineStatus(0);
|
// item.setOnlineStatus(0);
|
||||||
}
|
// }
|
||||||
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX+ item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
|
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX+ item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
|
||||||
// 获取电量
|
// 获取电量
|
||||||
if(StringUtils.isNotBlank(deviceStatus)){
|
if(StringUtils.isNotBlank(deviceStatus)){
|
||||||
@ -265,43 +265,63 @@ public class DeviceBizService {
|
|||||||
if (device == null) {
|
if (device == null) {
|
||||||
throw new RuntimeException("请先将设备入库!!!");
|
throw new RuntimeException("请先将设备入库!!!");
|
||||||
}
|
}
|
||||||
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
|
||||||
deviceUpdateWrapper.eq("id", device.getId())
|
|
||||||
.set("binding_user_id", null)
|
|
||||||
.set("binding_status", BindingStatusEnum.UNBOUND.getCode())
|
|
||||||
.set("binding_time", null);
|
|
||||||
deviceMapper.update(null, deviceUpdateWrapper);
|
|
||||||
|
|
||||||
if (userId == null) {
|
// type: 0 app,1 web
|
||||||
userId = AppLoginHelper.getUserId();
|
if (type == 0) {
|
||||||
}
|
QueryWrapper<AppDeviceBindRecord> bindRecordQueryWrapper = new QueryWrapper<>();
|
||||||
QueryWrapper<AppDeviceBindRecord> bindRecordQueryWrapper = new QueryWrapper<>();
|
bindRecordQueryWrapper.eq("device_id", device.getId());
|
||||||
bindRecordQueryWrapper.eq("device_id", device.getId());
|
|
||||||
// 设备端解绑 0:设备端解绑 1:web端解绑
|
|
||||||
if (type == 1) {
|
|
||||||
bindRecordQueryWrapper.eq("binding_user_id", userId);
|
bindRecordQueryWrapper.eq("binding_user_id", userId);
|
||||||
|
Long count = appDeviceBindRecordMapper.selectCount(bindRecordQueryWrapper);
|
||||||
|
if (count == 0) {
|
||||||
|
throw new RuntimeException("请先绑定设备!!!");
|
||||||
|
}
|
||||||
|
if(count<2){
|
||||||
|
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
||||||
|
deviceUpdateWrapper.eq("id", device.getId())
|
||||||
|
.set("binding_user_id", null)
|
||||||
|
.set("binding_status", BindingStatusEnum.UNBOUND.getCode())
|
||||||
|
.set("binding_time", null);
|
||||||
|
deviceMapper.update(null, deviceUpdateWrapper);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
QueryWrapper<AppDeviceBindRecord> bindRecordQueryWrapper = new QueryWrapper<>();
|
||||||
|
bindRecordQueryWrapper.eq("device_id", device.getId());
|
||||||
|
Long count = appDeviceBindRecordMapper.selectCount(bindRecordQueryWrapper);
|
||||||
|
if (count == 0) {
|
||||||
|
throw new RuntimeException("请先绑定设备!!!");
|
||||||
|
}
|
||||||
|
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
||||||
|
deviceUpdateWrapper.eq("id", device.getId())
|
||||||
|
.set("binding_user_id", null)
|
||||||
|
.set("binding_status", BindingStatusEnum.UNBOUND.getCode())
|
||||||
|
.set("binding_time", null);
|
||||||
|
deviceMapper.update(null, deviceUpdateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppDeviceBindRecord appDeviceBindRecord = appDeviceBindRecordMapper.selectOne(bindRecordQueryWrapper);
|
QueryWrapper<AppDeviceBindRecord> brqWrapper = new QueryWrapper<>();
|
||||||
// if (appDeviceBindRecord != null) {
|
brqWrapper.eq("device_id", device.getId());
|
||||||
// return appDeviceBindRecordMapper.deleteById(appDeviceBindRecord.getId());
|
if(userId != null){
|
||||||
// }
|
brqWrapper.eq("binding_user_id", userId);
|
||||||
|
}
|
||||||
|
|
||||||
List<AppDeviceBindRecord> appDeviceBindRecordList = appDeviceBindRecordMapper.selectList(bindRecordQueryWrapper);
|
List<AppDeviceBindRecord> appDeviceBindRecordList = appDeviceBindRecordMapper.selectList(brqWrapper);
|
||||||
if (CollectionUtil.isNotEmpty(appDeviceBindRecordList)) {
|
if (CollectionUtil.isNotEmpty(appDeviceBindRecordList)) {
|
||||||
appDeviceBindRecordList.forEach(appDeviceBindRecord ->
|
appDeviceBindRecordList.forEach(appDeviceBindRecord ->
|
||||||
appDeviceBindRecordMapper.deleteById(appDeviceBindRecord.getId()));
|
appDeviceBindRecordMapper.deleteById(appDeviceBindRecord.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
AppUserVo appUserVo = appUserMapper.selectVoById(userId);
|
AppUserVo appUserVo = appUserMapper.selectVoById(userId);
|
||||||
QueryWrapper<AppDeviceShare> appDeviceShareQueryWrapper = new QueryWrapper<>();
|
if(appUserVo != null){
|
||||||
appDeviceShareQueryWrapper.eq("device_id", device.getId());
|
QueryWrapper<AppDeviceShare> appDeviceShareQueryWrapper = new QueryWrapper<>();
|
||||||
appDeviceShareQueryWrapper.eq("phonenumber", appUserVo.getPhonenumber());
|
appDeviceShareQueryWrapper.eq("device_id", device.getId());
|
||||||
List<AppDeviceShare> appDeviceShareList = appDeviceShareMapper.selectList(appDeviceShareQueryWrapper);
|
appDeviceShareQueryWrapper.eq("phonenumber", appUserVo.getPhonenumber());
|
||||||
if (CollectionUtil.isNotEmpty(appDeviceShareList)) {
|
List<AppDeviceShare> appDeviceShareList = appDeviceShareMapper.selectList(appDeviceShareQueryWrapper);
|
||||||
appDeviceShareList.forEach(appDeviceShare ->
|
if (CollectionUtil.isNotEmpty(appDeviceShareList)) {
|
||||||
appDeviceShareMapper.deleteById(appDeviceShare.getId()));
|
appDeviceShareList.forEach(appDeviceShare ->
|
||||||
|
appDeviceShareMapper.deleteById(appDeviceShare.getId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -163,6 +163,8 @@ public class Device extends TenantEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线状态(0离线,1在线,2异常)
|
* 在线状态(0离线,1在线,2异常)
|
||||||
|
* online_status
|
||||||
*/
|
*/
|
||||||
private Integer onlineStatus;
|
private Integer onlineStatus;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,7 +117,8 @@ public class DeviceQueryCriteria extends BaseEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备在线状态
|
* 设备在线状态
|
||||||
* 0:离线;1:在线
|
* 0:离线;1:在线;2:故障
|
||||||
|
* online_status
|
||||||
*/
|
*/
|
||||||
private Integer onlineStatus;
|
private Integer onlineStatus;
|
||||||
|
|
||||||
|
|||||||
@ -342,6 +342,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
|
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
DeviceAssignments deviceAssignment = deviceAssignmentsMapper.selectById(id);
|
DeviceAssignments deviceAssignment = deviceAssignmentsMapper.selectById(id);
|
||||||
|
if (deviceAssignment == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Device device = deviceMapper.selectById(deviceAssignment.getDeviceId());
|
Device device = deviceMapper.selectById(deviceAssignment.getDeviceId());
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(deviceAssignment.getAssigneeName())) {
|
if (StringUtils.isNotEmpty(deviceAssignment.getAssigneeName())) {
|
||||||
@ -814,11 +817,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
if (StringUtils.isNotBlank(device.getDeviceImei())) {
|
if (StringUtils.isNotBlank(device.getDeviceImei())) {
|
||||||
DeviceAlarmVo latestAlarm = deviceAlarmMapper.selectLatestByDeviceImei(device.getDeviceImei());
|
DeviceAlarmVo latestAlarm = deviceAlarmMapper.selectLatestByDeviceImei(device.getDeviceImei());
|
||||||
// 判断是否正在告警:未处理的告警(treatmentState=1)且不是电子围栏告警(deviceAction!=3)
|
// 判断是否正在告警:未处理的告警(treatmentState=1)且不是电子围栏告警(deviceAction!=3)
|
||||||
if (latestAlarm != null &&
|
if (latestAlarm != null &&
|
||||||
latestAlarm.getTreatmentState() != null &&
|
latestAlarm.getTreatmentState() != null &&
|
||||||
latestAlarm.getTreatmentState() == 1 &&
|
latestAlarm.getTreatmentState() == 1 &&
|
||||||
latestAlarm.getDeviceAction() != null &&
|
latestAlarm.getDeviceAction() != null &&
|
||||||
latestAlarm.getDeviceAction() != 3) {
|
latestAlarm.getDeviceAction() != 3) {
|
||||||
vo.setIsAlarming(true);
|
vo.setIsAlarming(true);
|
||||||
} else {
|
} else {
|
||||||
vo.setIsAlarming(false);
|
vo.setIsAlarming(false);
|
||||||
@ -834,5 +837,4 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,6 +71,9 @@
|
|||||||
<if test="criteria.deviceStatus != null">
|
<if test="criteria.deviceStatus != null">
|
||||||
and da.active = #{criteria.deviceStatus}
|
and da.active = #{criteria.deviceStatus}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="criteria.onlineStatus != null">
|
||||||
|
and d.online_status = #{criteria.onlineStatus}
|
||||||
|
</if>
|
||||||
<if test="criteria.groupId != null">
|
<if test="criteria.groupId != null">
|
||||||
and d.group_id = #{criteria.groupId}
|
and d.group_id = #{criteria.groupId}
|
||||||
</if>
|
</if>
|
||||||
@ -255,6 +258,7 @@
|
|||||||
d.binding_status,
|
d.binding_status,
|
||||||
d.online_status,
|
d.online_status,
|
||||||
c.binding_time,
|
c.binding_time,
|
||||||
|
d.create_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
|
||||||
@ -268,10 +272,10 @@
|
|||||||
and a.device_name like concat('%', #{criteria.deviceName}, '%')
|
and a.device_name like concat('%', #{criteria.deviceName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.deviceImei != null and criteria.deviceImei != ''">
|
<if test="criteria.deviceImei != null and criteria.deviceImei != ''">
|
||||||
and a.device_imei = #{criteria.deviceImei}
|
and a.device_imei like concat('%',#{criteria.deviceImei}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.content != null and criteria.content != ''">
|
<if test="criteria.content != null and criteria.content != ''">
|
||||||
AND (a.device_imei = #{criteria.content} or a.device_mac = #{criteria.content})
|
AND (a.device_imei like concat('%',#{criteria.content}, '%') or a.device_mac like concat('%',#{criteria.content}, '%') )
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.deviceStatus != null">
|
<if test="criteria.deviceStatus != null">
|
||||||
and a.device_status = #{criteria.deviceStatus}
|
and a.device_status = #{criteria.deviceStatus}
|
||||||
@ -288,7 +292,7 @@
|
|||||||
<if test="criteria.onlineStatus != null">
|
<if test="criteria.onlineStatus != null">
|
||||||
and a.online_status = #{criteria.onlineStatus}
|
and a.online_status = #{criteria.onlineStatus}
|
||||||
</if>
|
</if>
|
||||||
ORDER BY a.binding_time DESC
|
ORDER BY (case when a.online_status = 1 then 2 else 1 end) DESC
|
||||||
</select>
|
</select>
|
||||||
<select id="getLocationHistory" resultType="com.fuyuanshen.equipment.domain.vo.LocationHistoryVo">
|
<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
|
select a.id,a.device_name,a.device_type,b.type_name deviceTypeName,a.device_imei,a.device_mac from device a
|
||||||
@ -304,10 +308,10 @@
|
|||||||
AND a.device_mac = #{bo.deviceMac}
|
AND a.device_mac = #{bo.deviceMac}
|
||||||
</if>
|
</if>
|
||||||
<if test="bo.deviceImei != null and bo.deviceImei != ''">
|
<if test="bo.deviceImei != null and bo.deviceImei != ''">
|
||||||
AND a.device_imei = #{bo.deviceImei}
|
and a.device_imei like concat('%',#{bo.deviceImei}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="bo.content != null and bo.content != ''">
|
<if test="bo.content != null and bo.content != ''">
|
||||||
AND a.device_imei = #{bo.content} or a.device_mac = #{bo.content}
|
AND (a.device_imei like concat('%',#{bo.content}, '%') or a.device_mac like concat('%',#{bo.content}, '%') )
|
||||||
</if>
|
</if>
|
||||||
<if test="bo.startTime != null and bo.startTime != ''">
|
<if test="bo.startTime != null and bo.startTime != ''">
|
||||||
AND a.create_time <![CDATA[>=]]> #{bo.startTime}
|
AND a.create_time <![CDATA[>=]]> #{bo.startTime}
|
||||||
|
|||||||
Reference in New Issue
Block a user