Commit 4d7339b2 by huangjy

fix: 机构类型区分居家还是养老,告警配置开关,设备同步定时器逻辑修改

parent d765a710
......@@ -69,7 +69,7 @@ public class PlatDeviceController {
@AuthIgnore
@TenantIdIgnore
public ApiResponseEntity<Void> iotSyncTask(@RequestBody BaseIdDTO baseIdDTO) {
iotSyncTask.savePlatDevice();
//iotSyncTask.savePlatDevice();
return ApiResponseUtils.success();
}
......
......@@ -52,6 +52,11 @@ public class PlatAlarmRecordQueryDTO extends BaseTenantDTO {
@ApiModelProperty(value = "告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常")
private String alarmType;
@ApiModelProperty(value = "不同类型的机构集合")
private List<String> orgIdList;
@ApiModelProperty(value = "类型 1-居家 2-机构养老")
private String type;
//告警接收人id
private String notifyUser;
......
......@@ -29,6 +29,9 @@ public class PlatBedPanoramaDTO {
@ApiModelProperty("机构id集合")
private List<String> orgIdList;
@ApiModelProperty(value = "类型 1-居家 2-机构养老")
private String orgType;
@DictEnum(em = PlatBedStatusEnum.BedStatusEnum.class, message = "状态可选值为{m}")
@ApiModelProperty("状态 1-空闲 0-已入住")
private String status;
......
......@@ -64,10 +64,6 @@ public class BehaviorAlarm implements IAlarm {
JSONObject properties = platAlarmCheckDTO.getProperties();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getId();
if (StringUtils.isBlank(ruleConfigStr)) {
log.error("行为告警配置未配置,告警配置id:" + config.getId());
return;
}
String personState = Convert.toStr(properties.get("personState"));
PlatAlarmConfigBehaviorDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigBehaviorDTOVO.class);
Integer duration = ruleConfig.getAverageDuration();//分钟
......@@ -115,8 +111,6 @@ public class BehaviorAlarm implements IAlarm {
alarmRedisDTO.setAlarm(CommonEnum.YES.getValue());
RedisUtil.set(RedisConst.ALARM_DEVICE_BEHAVIOR_ID + deviceId, alarmRedisDTO);
notice(platAlarmCheckDTO);
}else {
return;
}
}
......@@ -136,6 +130,15 @@ public class BehaviorAlarm implements IAlarm {
@Override
public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
log.error("告警配置为禁用,告警配置id:" + config.getId());
return;
}
if (StringUtils.isBlank(config.getRuleConfig())) {
log.error("行为告警配置未配置,告警配置id:" + config.getId());
return;
}
//获取长者 空间信息
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
......@@ -143,6 +146,7 @@ public class BehaviorAlarm implements IAlarm {
log.error("未关联长者,设备id:"+platAlarmCheckDTO.getPlatDevice().getId());
return;
}
PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom();
for (PlatElder platElder : platElderList) {
//判断是否已入住七天
......@@ -161,7 +165,7 @@ public class BehaviorAlarm implements IAlarm {
PlatAlarmRecord platAlarmRecord = platAlarmRecordService.convertToPlatAlarmRecord(platAlarmCheckDTO,platElder);
platAlarmRecord.setElderIds(platElder.getId());
platAlarmRecord.setElderName(platElder.getName());
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(), platAlarmRecord);
platAlarmRecordService.noticeDeviceAlarm(config, platAlarmRecord);
log.error("长者行为异常,发出告警,设备id:"+platDevice.getId()+", 长者名称:"+platElder.getName());
}
}
......
......@@ -61,26 +61,23 @@ public class BreathAlarm implements IAlarm {
log.error("呼吸设备未关联长者,设备plat_id:" + platAlarmCheckDTO.getPlatDevice().getId());
return;
}
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
log.error("呼吸告警配置为禁用,告警配置id:" + config.getId());
return;
}
PlatElder platElder = platElderList.get(0);
PlatHealthConfigDTO platHealthConfigDTO = personalConfigCacheUtil.get(platElder.getId());
PlatAlarmConfigRespiratoryDTOVO ruleConfig;
if(platHealthConfigDTO != null && platHealthConfigDTO.isBreathConfig()){
if (platHealthConfigDTO != null && platHealthConfigDTO.isBreathConfig()) {
ruleConfig = platHealthConfigDTO.getAlarmConfigRespiratoryDTOVO();
}else {
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
} else {
String ruleConfigStr = config.getRuleConfig();
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
log.error("呼吸告警配置为警用,告警配置id:" + config.getId());
return;
}
if (StringUtils.isBlank(ruleConfigStr)) {
log.error("呼吸告警配置未配置,告警配置id:" + config.getId());
return;
}
ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigRespiratoryDTOVO.class);
ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigRespiratoryDTOVO.class);
}
Integer start = ruleConfig.getRespiratoryRateStart();
......@@ -92,7 +89,7 @@ public class BreathAlarm implements IAlarm {
String personState = Convert.toStr(properties.get("personState"));
int hasPerson = (int) properties.get("person");
if ("0".equals(hasPerson)) {
if (0 == hasPerson) {
log.info("当前上报数据无人,不需要告警");
return;
}
......
......@@ -175,6 +175,15 @@ public class FallAlarm implements IAlarm {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
log.error("告警配置为禁用,告警配置id:" + config.getId());
return;
}
if (StringUtils.isBlank(config.getRuleConfig())) {
log.error("行为告警配置未配置,告警配置id:" + config.getId());
return;
}
if (CollectionUtils.isEmpty(platElderList)) {
log.error("跌倒设备未关联长者,设备plat_id:" + platDevice.getId());
return;
......
......@@ -53,13 +53,17 @@ public class HeartAlarm implements IAlarm {
log.error("心率设备未关联长者,设备plat_id:" + platAlarmCheckDTO.getPlatDevice().getId());
return;
}
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
log.error("呼吸告警配置为禁用,告警配置id:" + config.getId());
return;
}
PlatElder platElder = platElderList.get(0);
PlatHealthConfigDTO platHealthConfigDTO = personalConfigCacheUtil.get(platElder.getId());
PlatAlarmConfigHeartDTOVO ruleConfig;
if(platHealthConfigDTO != null && platHealthConfigDTO.isHeartConfig()){
ruleConfig = platHealthConfigDTO.getAlarmConfigHeartDTO();
}else {
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
String ruleConfigStr = config.getRuleConfig();
if (StringUtils.isBlank(ruleConfigStr)) {
log.error("心率告警配置未配置,告警配置id:" + config.getId());
......@@ -88,6 +92,11 @@ public class HeartAlarm implements IAlarm {
return;
}
int hasPerson = (int) properties.get("person");
if (0 == hasPerson) {
log.info("当前上报数据无人,不需要告警");
return;
}
if ((hr > end || hr < start)) {
if(alarmRedisDTO==null){
......
......@@ -2,6 +2,7 @@ package com.makeit.service.platform.alarm.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -16,6 +17,7 @@ import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatUser;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElder;
......@@ -30,6 +32,7 @@ import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.mapper.platform.alarm.PlatAlarmRecordMapper;
import com.makeit.service.platform.alarm.PlatAlarmConfigService;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.service.platform.elder.PlatElderChildrenInfoService;
import com.makeit.service.platform.elder.PlatElderService;
......@@ -39,6 +42,7 @@ import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.msg.MsgSendUtil;
import com.makeit.utils.msg.SendTypeEnum;
import com.makeit.utils.msg.dto.MsgSendDTO;
......@@ -95,6 +99,8 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
private PlatRegionSettingService platRegionSettingService;
@Autowired
private PlatTenantService platTenantService;
@Autowired
private PlatOrgService platOrgService;
@Override
......@@ -137,6 +143,10 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
private LambdaQueryWrapper<PlatAlarmRecord> getLambdaQueryWrapper(PlatAlarmRecordQueryDTO param) {
List<String> orgIdList = Lists.newArrayList();
if (StringUtils.isNotEmpty(param.getType())) {
List<PlatOrg> platOrgList = platOrgService.list(new QueryWrapper<PlatOrg>().lambda().eq(PlatOrg::getType, param.getType()));
orgIdList = StreamUtil.map(platOrgList, BaseEntity::getId);
}
if (StringUtils.isNotEmpty(param.getOrgId())) {
orgIdList = Lists.newArrayList(param.getOrgId().split(","));
}
......
......@@ -47,7 +47,6 @@ implements PlatDayDurationRecordService {
*/
@Override
public void saveDayDurationRecord(PlatAlarmCheckDTO platAlarmCheckDTO, AlarmRedisDTO alarmRedisDTO) {
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
......@@ -62,10 +61,6 @@ implements PlatDayDurationRecordService {
}
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
// if(CollectionUtils.isNotEmpty(platElderList)){
// platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
// platElderList = platAlarmCheckDTO.getPlatElderList();
// }
for (PlatElder platElder : platElderList) {
if(StringUtils.isBlank(platElder.getRegionName())){
continue;
......@@ -78,7 +73,7 @@ implements PlatDayDurationRecordService {
durationRecord.setDay(alarmRedisDTO.getStart());
durationRecord.setStartDate(alarmRedisDTO.getStart());
durationRecord.setEndDate(now);
durationRecord.setTenantId(config.getTenantId());
durationRecord.setTenantId(platDevice.getTenantId());
durationRecord.setRoomId(platElder.getRoomId());
durationRecord.setDeviceId(platDevice.getId());
this.saveOrUpdate(durationRecord);
......
......@@ -66,4 +66,6 @@ public interface PlatDeviceService extends IService<PlatDevice> {
List<PlatDevice> productList(PlatDeviceQueryDTO dto);
Page<PlatDeviceListVO> getDevices(PlatDataScreenQueryDTO dto, Page<PlatDevice> p);
void savePlatDevice();
}
package com.makeit.service.platform.device.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.makeit.common.dto.BaseTenantDTO;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity;
......@@ -23,17 +25,27 @@ import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.device.PlatDeviceOther;
import com.makeit.entity.platform.space.PlatRegionSetting;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.entity.saas.PlatTenant;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.report.DeviceNameEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.device.PlatDeviceMapper;
import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
import com.makeit.module.iot.service.IotOrgService;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.DeviceInstanceEntity;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.module.iot.vo.DeviceState;
import com.makeit.module.system.service.SysDictionaryCategoryService;
import com.makeit.module.system.vo.DictionaryVo;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.device.PlatDeviceOtherService;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.space.PlatRegionSettingService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.utils.DeviceCacheUtil;
......@@ -45,15 +57,16 @@ import com.makeit.utils.old.StringUtils;
import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceViewVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -66,6 +79,7 @@ import java.util.stream.Stream;
* @since 2023-09-05
*/
@Service
@Slf4j
public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDevice> implements PlatDeviceService {
@Autowired
......@@ -86,6 +100,13 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
@Autowired
private PlatSpaceService platSpaceService;
@Autowired
private IotOrgService iotOrgService;
@Autowired
private SysDictionaryCategoryService sysDictionaryCategoryService;
@Autowired
private PlatRoomBedDeviceService platRoomBedDeviceService;
@Override
public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
PlatDeviceQueryDTO dto = pageReqDTO.getData();
......@@ -386,4 +407,94 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
public Page<PlatDeviceListVO> getDevices(PlatDataScreenQueryDTO dto, Page<PlatDevice> page) {
return baseMapper.getDevices(dto,page);
}
@Transactional(rollbackFor = Exception.class)
public void savePlatDevice(){
log.info("开始执行同步设备信息接口");
LambdaQueryWrapper<PlatTenant> tenantLambdaQueryWrapper = new LambdaQueryWrapper<PlatTenant>().eq(PlatTenant::getStatus, CommonEnum.YES.getValue());
List<PlatTenant> platTenants = platTenantService.list(tenantLambdaQueryWrapper);
List<DictionaryVo> dictionaryVos = sysDictionaryCategoryService.getByCategoryCode("device.category");
Map<String, String> dicNameIdMap = dictionaryVos.stream().collect(Collectors.toMap(DictionaryVo::getName, DictionaryVo::getValue, (v1, v2) -> v1));
for (PlatTenant platTenant : platTenants) {
String iotOrgId = platTenant.getIotOrgId();
if (org.apache.commons.lang3.StringUtils.isBlank(iotOrgId)) {
continue;
}
//查询iot设备
List<DeviceInstanceEntity> iotDeviceList = iotOrgService.getOrgDevice(iotOrgId);
//查询平台设备
Set<String> iotDeviceIdSet = iotDeviceList.stream().map(DeviceInstanceEntity::getId).collect(Collectors.toSet());
List<PlatDevice> platDeviceList = list(new QueryWrapper<PlatDevice>().lambda().eq(BaseBusEntity::getTenantId, platTenant.getId()));
Set<String> platformDeviceIdList = platDeviceList.stream().map(PlatDevice::getOriDeviceId).collect(Collectors.toSet());
Set<String> newIotDeviceIdSet = Sets.newHashSet(iotDeviceIdSet);
Set<String> newPlatformDeviceIdSet = Sets.newHashSet(platformDeviceIdList);
newPlatformDeviceIdSet.removeAll(newIotDeviceIdSet);
//iotDeviceIdSet.removeAll(platformDeviceIdList);
if (CollectionUtils.isNotEmpty(newPlatformDeviceIdSet)) {
List<PlatDevice> platDevices = list(new QueryWrapper<PlatDevice>().lambda().eq(BaseBusEntity::getTenantId, platTenant.getId())
.in(PlatDevice::getOriDeviceId, newPlatformDeviceIdSet));
List<String> deviceIdList = StreamUtil.map(platDevices, BaseEntity::getId);
LambdaQueryWrapper<PlatDevice> removeQw = new LambdaQueryWrapper<PlatDevice>()
.in(PlatDevice::getId, deviceIdList)
.eq(BaseBusEntity::getTenantId, platTenant.getId());
remove(removeQw);
// 同时删除关联的设备
platRoomBedDeviceService.remove(new QueryWrapper<PlatRoomBedDevice>().lambda()
.in(PlatRoomBedDevice::getDeviceId,deviceIdList)
.eq(BaseBusEntity::getTenantId, platTenant.getId()));
}
LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<PlatDevice>().eq(BaseBusEntity::getTenantId, platTenant.getId())
.in(PlatDevice::getOriDeviceId, iotDeviceIdSet);
iotDeviceIdSet.add("-1");
List<PlatDevice> deviceList = list(deviceLambdaQueryWrapper);
//更新平台设备
Collection<PlatDevice> platDevices = convertToPlatDevice(iotDeviceList, deviceList, platTenant.getId(), dicNameIdMap);
saveOrUpdateBatch(platDevices);
deviceCacheUtil.putAll(platDevices);
}
log.info("结束执行同步设备信息接口");
}
private Collection<PlatDevice> convertToPlatDevice(List<DeviceInstanceEntity> iotDeviceList, List<PlatDevice> deviceList, String tenantId, Map<String, String> dicNameIdMap) {
Map<String, PlatDevice> deviceMap = deviceList.stream().collect(Collectors.toMap(PlatDevice::getOriDeviceId, v -> v, (a, b) -> a));
iotDeviceList.forEach(iotDevice -> {
PlatDevice platDevice = deviceMap.get(iotDevice.getId());
if (platDevice == null) {
platDevice = new PlatDevice();
platDevice.setTenantId(tenantId);
deviceMap.put(iotDevice.getId(), platDevice);
}
platDevice.setOriDeviceId(iotDevice.getId());
platDevice.setName(iotDevice.getName());
platDevice.setOrgId(tenantId);
String productName = iotDevice.getProductName();
platDevice.setProductName(productName);
platDevice.setProductId(iotDevice.getProductId());
if(iotDevice.getRegistryTime()!=null) {
LocalDateTime registryTime = LocalDateTime.ofEpochSecond(iotDevice.getRegistryTime() / 1000, 0, ZoneOffset.ofHours(8));
platDevice.setRegistrationDate(registryTime);
}
platDevice.setDescription(iotDevice.getDescribe());
String state = iotDevice.getState();
DeviceState deviceState = JSON.parseObject(state, DeviceState.class);
platDevice.setStatus(deviceState.getValue());
String categoryName = DeviceNameEnum.getNameByPrefix(productName);
platDevice.setCategory(dicNameIdMap.get(categoryName));
});
return deviceMap.values();
}
}
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.space.*;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
......@@ -17,15 +20,18 @@ import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.auth.PlatOrgEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.space.PlatBedMapper;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.space.PlatBedVo;
import com.makeit.vo.platform.workstation.WorkStationHomeBedVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO;
import jodd.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -43,6 +49,8 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
@Autowired
private PlatRoomService platRoomService;
@Autowired
private PlatOrgService platOrgService;
@Autowired
private PlatRoomBedDeviceService platRoomBedDeviceService;
......@@ -153,6 +161,10 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
@Override
public Page<PlatBedPanoramaVO> selectBySpaceIdAndStatus(PageReqDTO<PlatBedPanoramaDTO> pageReqDTO, PlatBedPanoramaDTO dto) {
List<String> orgIdList = Lists.newArrayList();
if (StringUtils.isNotEmpty(dto.getOrgType())) {
List<PlatOrg> platOrgList = platOrgService.list(new QueryWrapper<PlatOrg>().lambda().eq(PlatOrg::getType, dto.getOrgType()));
orgIdList = StreamUtil.map(platOrgList, BaseEntity::getId);
}
if (StringUtil.isNotEmpty(dto.getOrgId())) {
orgIdList = Lists.newArrayList(dto.getOrgId().split(","));
}
......
......@@ -39,17 +39,11 @@ public class AlarmConfigCacheUtil implements ApplicationRunner {
public void put(PlatAlarmConfig alarmConfigVO) {
PlatAlarmConfig alarmConfig = platAlarmConfigService.getById(alarmConfigVO.getId());
if (StringUtils.equals(CommonEnum.YES.getValue(),alarmConfig.getStatus())) {
RedisUtil.set(RedisConst.ALARM_CONFIG_ORG_ID+alarmConfig.getOrgId() + ":" + alarmConfig.getAlarmType(),alarmConfig);
} else {
RedisUtil.delete(RedisConst.ALARM_CONFIG_ORG_ID+alarmConfig.getOrgId() + ":" + alarmConfig.getAlarmType());
}
RedisUtil.set(RedisConst.ALARM_CONFIG_ORG_ID+alarmConfig.getOrgId() + ":" + alarmConfig.getAlarmType(),alarmConfig);
}
public void putAll(List<PlatAlarmConfig> alarmConfigs) {
alarmConfigs.forEach(vo -> {
put(vo);
});
alarmConfigs.forEach(this::put);
}
public PlatAlarmConfig get(String orgId,String alarmType) {
......
......@@ -145,10 +145,6 @@ public class PushCallback implements MqttCallback {
return;
}
for (PlatAlarmConfig config : deviceAlarmConfigList) {
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
logger.error("告警配置为禁用,告警配置id:" + config.getId());
continue;
}
String alarmType = config.getAlarmType();
for (IAlarm alarm : alarmList) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment