Commit e4ffd88c by 李小龙

fixBug:跌倒告警发送消息

parent ab080c56
...@@ -99,7 +99,7 @@ public interface BaseEnum { ...@@ -99,7 +99,7 @@ public interface BaseEnum {
static BaseEnum getByValue(Class<? extends BaseEnum> emClazz, String value) { static BaseEnum getByValue(Class<? extends BaseEnum> emClazz, String value) {
BaseEnum[] em = emClazz.getEnumConstants(); BaseEnum[] em = emClazz.getEnumConstants();
for (BaseEnum e : em) { for (BaseEnum e : em) {
if (e.getValue().equals(value)) { if (StringUtils.equals(e.getValue(),value)) {
return e; return e;
} }
} }
......
...@@ -9,9 +9,10 @@ import lombok.Getter; ...@@ -9,9 +9,10 @@ import lombok.Getter;
@Getter @Getter
public enum SendTypeEnum implements BaseEnum { public enum SendTypeEnum implements BaseEnum {
//1-短信 2-邮件 3-语音短信 4-云龄工单 5-晶奇工单 6-子女端小程序 //1-短信 2-邮件 3-语音短信 4-云龄工单 5-晶奇工单 6-子女端小程序
SMS("alarm.sendType.sms"), SMS("alarm.notifyChannel.sms"),
MAIL("alarm.sendType.mail"), MAIL("alarm.notifyChannel.mail"),
VOICE_SMS("alarm.sendType.voiceSms"), VOICE_SMS("alarm.notifyChannel.voiceMessage"),
//todo 加字典
YUNLING("alarm.sendType.yunling"), YUNLING("alarm.sendType.yunling"),
JINGQI("alarm.sendType.jingqi"), JINGQI("alarm.sendType.jingqi"),
CHILD_WECHAT("alarm.sendType.childWechat") CHILD_WECHAT("alarm.sendType.childWechat")
......
...@@ -5,11 +5,8 @@ import lombok.AllArgsConstructor; ...@@ -5,11 +5,8 @@ import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import java.util.Collection; import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Data @Data
@Builder @Builder
...@@ -30,8 +27,6 @@ public class MsgSendDTO { ...@@ -30,8 +27,6 @@ public class MsgSendDTO {
*/ */
private String[] param; private String[] param;
private String sendContent;
public void setParam(String... param) { public void setParam(String... param) {
this.param = param; this.param = param;
} }
......
...@@ -25,4 +25,6 @@ public class PlatAlarmCheckDTO { ...@@ -25,4 +25,6 @@ public class PlatAlarmCheckDTO {
private JSONObject properties; private JSONObject properties;
//PlatAlarmRecord.remark
private String remark;
} }
...@@ -54,7 +54,7 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> { ...@@ -54,7 +54,7 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> {
*/ */
void noticeDeviceAlarm(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord); void noticeDeviceAlarm(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord);
PlatAlarmRecord createPlatAlarmRecord(PlatAlarmCheckDTO platAlarmCheckDTO); PlatAlarmRecord convertToPlatAlarmRecord(PlatAlarmCheckDTO platAlarmCheckDTO);
void getElderListByDeviceId(PlatAlarmCheckDTO platAlarmCheckDTO); void getElderListByDeviceId(PlatAlarmCheckDTO platAlarmCheckDTO);
} }
...@@ -7,16 +7,20 @@ import com.makeit.dto.platform.alarm.PlatAlarmConfigBehaviorDTOVO; ...@@ -7,16 +7,20 @@ import com.makeit.dto.platform.alarm.PlatAlarmConfigBehaviorDTOVO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig; import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.alarm.PlatAlarmRecord; import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum; import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.redis.RedisConst; import com.makeit.enums.redis.RedisConst;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.utils.data.convert.JsonUtil; import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.redis.RedisUtil; import com.makeit.utils.redis.RedisUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -77,8 +81,18 @@ public class BehaviorAlarm implements IAlarm{ ...@@ -77,8 +81,18 @@ public class BehaviorAlarm implements IAlarm{
@Async @Async
public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) { public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) {
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO); platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
platAlarmCheckDTO.getParam().add("房间名"); List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
PlatAlarmRecord platAlarmRecord =platAlarmRecordService.createPlatAlarmRecord(platAlarmCheckDTO); if(CollectionUtils.isEmpty(platElderList)){
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(),platAlarmRecord); return;
}
PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom();
for (PlatElder platElder : platElderList) {
List<String> param = new ArrayList<>();
param.add(platElder.getName());
param.add(platRoom.getName());
platAlarmCheckDTO.setParam(param);
PlatAlarmRecord platAlarmRecord = platAlarmRecordService.convertToPlatAlarmRecord(platAlarmCheckDTO);
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(),platAlarmRecord);
}
} }
} }
...@@ -7,17 +7,22 @@ import com.makeit.dto.platform.alarm.PlatAlarmConfigRespiratoryDTOVO; ...@@ -7,17 +7,22 @@ import com.makeit.dto.platform.alarm.PlatAlarmConfigRespiratoryDTOVO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig; import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.alarm.PlatAlarmRecord; import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum; import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.redis.RedisConst; import com.makeit.enums.redis.RedisConst;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.utils.data.convert.JsonUtil; import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.redis.RedisUtil; import com.makeit.utils.redis.RedisUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
@Component @Component
public class BreathAlarm implements IAlarm{ public class BreathAlarm implements IAlarm{
...@@ -67,6 +72,12 @@ public class BreathAlarm implements IAlarm{ ...@@ -67,6 +72,12 @@ public class BreathAlarm implements IAlarm{
long count = endLong - startLong; long count = endLong - startLong;
if (br > end || br < start) { if (br > end || br < start) {
if (count >= duration) { if (count >= duration) {
if(br>end){
platAlarmCheckDTO.setRemark("呼吸过速");
}
if(br < start){
platAlarmCheckDTO.setRemark("呼吸过缓");
}
notice(platAlarmCheckDTO); notice(platAlarmCheckDTO);
RedisUtil.set(RedisConst.ALARM_DEVICE_ID + deviceId,endLong/1000); RedisUtil.set(RedisConst.ALARM_DEVICE_ID + deviceId,endLong/1000);
} }
...@@ -76,12 +87,27 @@ public class BreathAlarm implements IAlarm{ ...@@ -76,12 +87,27 @@ public class BreathAlarm implements IAlarm{
return; return;
} }
/**
* [#长者姓名][#呼吸状态],请及时处理!
* @param platAlarmCheckDTO
*/
@Override @Override
@Async @Async
public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) { public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) {
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO); platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
platAlarmCheckDTO.getParam().add("呼吸状态111"); platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
PlatAlarmRecord platAlarmRecord = platAlarmRecordService.createPlatAlarmRecord(platAlarmCheckDTO); List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(),platAlarmRecord); if(CollectionUtils.isEmpty(platElderList)){
return;
}
PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom();
for (PlatElder platElder : platElderList) {
List<String> param = new ArrayList<>();
param.add(platElder.getName());
param.add(platAlarmCheckDTO.getRemark());
platAlarmCheckDTO.setParam(param);
PlatAlarmRecord platAlarmRecord = platAlarmRecordService.convertToPlatAlarmRecord(platAlarmCheckDTO);
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(),platAlarmRecord);
}
} }
} }
...@@ -54,7 +54,7 @@ public class FallAlarm implements IAlarm{ ...@@ -54,7 +54,7 @@ public class FallAlarm implements IAlarm{
param.add(platElder.getName()); param.add(platElder.getName());
param.add(platRoom.getName()); param.add(platRoom.getName());
platAlarmCheckDTO.setParam(param); platAlarmCheckDTO.setParam(param);
PlatAlarmRecord platAlarmRecord = platAlarmRecordService.createPlatAlarmRecord(platAlarmCheckDTO); PlatAlarmRecord platAlarmRecord = platAlarmRecordService.convertToPlatAlarmRecord(platAlarmCheckDTO);
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(),platAlarmRecord); platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(),platAlarmRecord);
} }
} }
......
...@@ -7,17 +7,22 @@ import com.makeit.dto.platform.alarm.PlatAlarmConfigHeartDTOVO; ...@@ -7,17 +7,22 @@ import com.makeit.dto.platform.alarm.PlatAlarmConfigHeartDTOVO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig; import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.alarm.PlatAlarmRecord; import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum; import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.redis.RedisConst; import com.makeit.enums.redis.RedisConst;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.utils.data.convert.JsonUtil; import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.redis.RedisUtil; import com.makeit.utils.redis.RedisUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
@Component @Component
public class HeartAlarm implements IAlarm { public class HeartAlarm implements IAlarm {
...@@ -58,6 +63,12 @@ public class HeartAlarm implements IAlarm { ...@@ -58,6 +63,12 @@ public class HeartAlarm implements IAlarm {
long count = endLong - startLong; long count = endLong - startLong;
if (hr > end || hr < start) { if (hr > end || hr < start) {
if (count >= duration) { if (count >= duration) {
if(hr>end){
platAlarmCheckDTO.setRemark("心率过速");
}
if(hr < start){
platAlarmCheckDTO.setRemark("心率过缓");
}
notice(platAlarmCheckDTO); notice(platAlarmCheckDTO);
RedisUtil.set(RedisConst.ALARM_DEVICE_ID + deviceId,endLong/1000); RedisUtil.set(RedisConst.ALARM_DEVICE_ID + deviceId,endLong/1000);
} }
...@@ -70,8 +81,19 @@ public class HeartAlarm implements IAlarm { ...@@ -70,8 +81,19 @@ public class HeartAlarm implements IAlarm {
@Async @Async
public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) { public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) {
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO); platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
platAlarmCheckDTO.getParam().add("呼吸状态111"); platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
PlatAlarmRecord platAlarmRecord =platAlarmRecordService. createPlatAlarmRecord(platAlarmCheckDTO); List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(),platAlarmRecord); if(CollectionUtils.isEmpty(platElderList)){
return;
}
PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom();
for (PlatElder platElder : platElderList) {
List<String> param = new ArrayList<>();
param.add(platElder.getName());
param.add(platAlarmCheckDTO.getRemark());
platAlarmCheckDTO.setParam(param);
PlatAlarmRecord platAlarmRecord = platAlarmRecordService.convertToPlatAlarmRecord(platAlarmCheckDTO);
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(),platAlarmRecord);
}
} }
} }
...@@ -270,7 +270,13 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -270,7 +270,13 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
List<SendTypeEnum> notifyChannelList = Arrays.asList(SendTypeEnum.SMS, SendTypeEnum.VOICE_SMS, SendTypeEnum.MAIL); List<SendTypeEnum> notifyChannelList = Arrays.asList(SendTypeEnum.SMS, SendTypeEnum.VOICE_SMS, SendTypeEnum.MAIL);
Set<String> phoneSet = platUserList.stream().map(PlatUser::getMobile).collect(Collectors.toSet()); Set<String> phoneSet = platUserList.stream().map(PlatUser::getMobile).collect(Collectors.toSet());
//发送消息 //发送消息
noticeByChannel(alarmConfig, alarmRecord, phoneSet, notifyChannelList); //noticeByChannel(alarmConfig, alarmRecord, phoneSet, notifyChannelList);
String userIdJoin = platUserList.stream().map(PlatUser::getId).collect(Collectors.joining(","));
alarmRecord.setNotifyUser(userIdJoin);
saveOrUpdate(alarmRecord);
} }
/** /**
...@@ -299,21 +305,21 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -299,21 +305,21 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
} }
@Override @Override
public PlatAlarmRecord createPlatAlarmRecord(PlatAlarmCheckDTO platAlarmCheckDTO) { public PlatAlarmRecord convertToPlatAlarmRecord(PlatAlarmCheckDTO platAlarmCheckDTO) {
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig(); PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice(); PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
List<String> param = platAlarmCheckDTO.getParam(); List<String> param = platAlarmCheckDTO.getParam();
List<PlatElder> elderList = platAlarmCheckDTO.getPlatElderList(); List<PlatElder> elderList = platAlarmCheckDTO.getPlatElderList();
String elderNameJoin = elderList.stream().map(PlatElder::getName).collect(Collectors.joining(" "));
PlatAlarmRecord platAlarmRecord = new PlatAlarmRecord(); PlatAlarmRecord platAlarmRecord = new PlatAlarmRecord();
platAlarmRecord.setAlarmId(config.getId()); platAlarmRecord.setAlarmId(config.getId());
platAlarmRecord.setAlarmType(config.getAlarmType()); platAlarmRecord.setAlarmType(config.getAlarmType());
platAlarmRecord.setAlarmDate(new Date()); platAlarmRecord.setAlarmDate(new Date());
platAlarmRecord.setStatus("0"); platAlarmRecord.setStatus(CommonEnum.NO.getValue());
//todo platAlarmRecord.setNoticeStatus(CommonEnum.NO.getValue());
platAlarmRecord.setContent(replaceParam(elderNameJoin, param)); //模板信息 替换参数
platAlarmRecord.setContent(replaceParam(config.getContent(), param));
platAlarmRecord.setOrgId(platDevice.getOrgId()); platAlarmRecord.setOrgId(platDevice.getOrgId());
platAlarmRecord.setNotifyUser(config.getNotifyUser()); platAlarmRecord.setNotifyUser(config.getNotifyUser());
platAlarmRecord.setDeviceId(platDevice.getId()); platAlarmRecord.setDeviceId(platDevice.getId());
......
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