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