Commit a4e4b4d3 by 李小龙

告警记录

parent 84d31e3e
...@@ -9,6 +9,7 @@ import com.makeit.common.page.PageVO; ...@@ -9,6 +9,7 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.common.vo.ExcelImportVo; import com.makeit.common.vo.ExcelImportVo;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.module.admin.dto.plat.PlatUserDTOVO; import com.makeit.module.admin.dto.plat.PlatUserDTOVO;
...@@ -161,7 +162,7 @@ public class PlatUserController { ...@@ -161,7 +162,7 @@ public class PlatUserController {
@PostMapping("import") @PostMapping("import")
public ApiResponseEntity<ExcelImportVo> importExcel(@RequestParam(value = "excelFile", required = false) MultipartFile excelFile) throws Exception { public ApiResponseEntity<ExcelImportVo> importExcel(@RequestParam(value = "excelFile", required = false) MultipartFile excelFile) throws Exception {
if(excelFile == null ){ if(excelFile == null ){
throw new BusinessException("请上传excel"); throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_EXCEL_UPLOAD_EXIT);
} }
ExcelImportVo excelImportVo = platUserService.importExcel(excelFile); ExcelImportVo excelImportVo = platUserService.importExcel(excelFile);
return ApiResponseUtils.success(excelImportVo); return ApiResponseUtils.success(excelImportVo);
......
...@@ -108,7 +108,11 @@ public enum CodeMessageEnum { ...@@ -108,7 +108,11 @@ public enum CodeMessageEnum {
SYSTEM_ERROR_TENANT_NOT_EXIST(510, "SYSTEM.ERROR.TENANT.NOT.EXIST"), SYSTEM_ERROR_TENANT_NOT_EXIST(510, "SYSTEM.ERROR.TENANT.NOT.EXIST"),
SYSTEM_ERROR_ROLE_ADMIN_CANT_ADD(500, "SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD"), SYSTEM_ERROR_ROLE_ADMIN_CANT_ADD(500, "SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD"),
SYSTEM_ERROR_ROLE_ADMIN_CANT_EDIT(500, "SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT"), SYSTEM_ERROR_ROLE_ADMIN_CANT_EDIT(500, "SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT"),
;
PLATFORM_ERROR_ALARM_NOT_FOUND_SPACE(500,"PLATFORM.ERROR.ALARM.NOT.FOUND.SPACE"),
PLATFORM_ERROR_ALARM_NOT_FOUND_ELDER(500,"PLATFORM.ERROR.ALARM.NOT.FOUND.ELDER"),
; ;
/** /**
......
package com.makeit.utils.msg; package com.makeit.utils.msg;
import com.makeit.utils.msg.dto.MsgDTO;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Collection;
@Component @Component
public class MsgUtil { public class MsgUtil {
/** /**
* 发送消息并保存记录 * 发送消息并保存记录
*/ */
public void send(MsgDTO msgDTO){ public void send(SendTypeEnum sendTypeEnum, Collection<String> receiverList, String content){
switch (sendTypeEnum){
case SMS:
break;
case MAIL:
break;
case VOICE_SMS:
break;
case JINGQI:
break;
case YUNLING:
break;
}
} }
} }
...@@ -8,12 +8,14 @@ import lombok.Getter; ...@@ -8,12 +8,14 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
public enum SendTypeEnum implements BaseEnum { public enum SendTypeEnum implements BaseEnum {
//1-短信 2-邮件 3-语音短信 4-云龄工单 5-晶奇工单 //1-短信 2-邮件 3-语音短信 4-云龄工单 5-晶奇工单 6-子女端小程序
SMS("alarm.sendType.sms"), SMS("alarm.sendType.sms"),
MAIL("alarm.sendType.mail"), MAIL("alarm.sendType.mail"),
VOICE_SMS("alarm.sendType.voiceSms"), VOICE_SMS("alarm.sendType.voiceSms"),
YUNLING("alarm.sendType.yunling"), YUNLING("alarm.sendType.yunling"),
JINGQI("alarm.sendType.jingqi"); JINGQI("alarm.sendType.jingqi"),
CHILD_WECHAT("alarm.sendType.childWechat")
;
private String code; private String code;
...@@ -21,4 +23,9 @@ public enum SendTypeEnum implements BaseEnum { ...@@ -21,4 +23,9 @@ public enum SendTypeEnum implements BaseEnum {
public String getValue() { public String getValue() {
return SysDictUtil.getValue(code); return SysDictUtil.getValue(code);
} }
public static SendTypeEnum getByValue(String value){
SendTypeEnum byValue =(SendTypeEnum)BaseEnum.getByValue(SendTypeEnum.class, value);
return byValue;
}
} }
...@@ -33,7 +33,7 @@ public class MailMsgSender implements IMsgSender { ...@@ -33,7 +33,7 @@ public class MailMsgSender implements IMsgSender {
helper.setFrom(from); helper.setFrom(from);
helper.setTo(msgDTO.getReceiverList().toArray(new String[msgDTO.getReceiverList().size()])); helper.setTo(msgDTO.getReceiverList().toArray(new String[msgDTO.getReceiverList().size()]));
helper.setSubject(msgDTO.getSubject()); helper.setSubject(msgDTO.getSubject());
helper.setText(msgDTO.getSendContent(), false); helper.setText(msgDTO.getOriContent(), false);
mailSender.send(message); mailSender.send(message);
} catch (Exception e) { } catch (Exception e) {
sendResult.setSuccess(false); sendResult.setSuccess(false);
......
...@@ -102,3 +102,7 @@ PLATFORM.ERROR.ROOM.OTHER.USED.NOT.DEL=该房间下有床位有其他长者入 ...@@ -102,3 +102,7 @@ PLATFORM.ERROR.ROOM.OTHER.USED.NOT.DEL=该房间下有床位有其他长者入
SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD=不能在该节点下新增非管理员角色 SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD=不能在该节点下新增非管理员角色
SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT=管理员角色不能修改 SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT=管理员角色不能修改
PLATFORM.ERROR.ALARM.NOT.FOUND.SPACE=设备未绑定空间
PLATFORM.ERROR.ALARM.NOT.FOUND.ELDER=设备空间下无长者
...@@ -48,7 +48,7 @@ public class PlatAlarmRecordController { ...@@ -48,7 +48,7 @@ public class PlatAlarmRecordController {
@ApiOperation("通知家属") @ApiOperation("通知家属")
@PostMapping("notice") @PostMapping("notice")
public ApiResponseEntity<Void> notice(@RequestBody BaseIdDTO dto) { public ApiResponseEntity<Void> notice(@RequestBody BaseIdDTO dto) {
platAlarmRecordService.notice(dto.getId()); platAlarmRecordService.noticeRelation(dto.getId());
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
......
...@@ -48,7 +48,7 @@ public class WechatPlatAlarmRecordController { ...@@ -48,7 +48,7 @@ public class WechatPlatAlarmRecordController {
@ApiOperation("通知家属") @ApiOperation("通知家属")
@PostMapping("notice") @PostMapping("notice")
public ApiResponseEntity<Void> notice(@RequestBody BaseIdDTO dto) { public ApiResponseEntity<Void> notice(@RequestBody BaseIdDTO dto) {
platAlarmRecordService.notice(dto.getId()); platAlarmRecordService.noticeRelation(dto.getId());
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
......
...@@ -20,5 +20,5 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> { ...@@ -20,5 +20,5 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> {
void deal(String recordId); void deal(String recordId);
void notice(String recordId); void noticeRelation(String recordId);
} }
...@@ -9,16 +9,27 @@ import com.makeit.common.page.PageVO; ...@@ -9,16 +9,27 @@ import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO; import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
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.elder.PlatElder;
import com.makeit.entity.platform.elder.PlatElderSocialRelation;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum; import com.makeit.enums.CommonEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.alarm.PlatAlarmRecordMapper; import com.makeit.mapper.platform.alarm.PlatAlarmRecordMapper;
import com.makeit.service.platform.alarm.PlatAlarmConfigService; import com.makeit.service.platform.alarm.PlatAlarmConfigService;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.elder.PlatElderSocialRelationService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil; import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.msg.MsgUtil;
import com.makeit.utils.msg.SendTypeEnum;
import com.makeit.utils.sql.join.JoinUtil; import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.utils.user.common.CommonUserUtil; import com.makeit.utils.user.common.CommonUserUtil;
import com.makeit.utils.user.common.CommonUserVO; import com.makeit.utils.user.common.CommonUserVO;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO; import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
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.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -28,6 +39,9 @@ import java.time.LocalDateTime; ...@@ -28,6 +39,9 @@ import java.time.LocalDateTime;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @author lixl * @author lixl
...@@ -39,6 +53,15 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -39,6 +53,15 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
implements PlatAlarmRecordService{ implements PlatAlarmRecordService{
@Autowired @Autowired
private PlatAlarmConfigService platAlarmConfigService; private PlatAlarmConfigService platAlarmConfigService;
@Autowired
private PlatRoomBedDeviceService platRoomBedDeviceService;
@Autowired
private PlatElderService platElderService;
@Autowired
private PlatElderSocialRelationService platElderSocialRelationService;
@Autowired
private MsgUtil msgUtil;
@Override @Override
public PageVO<PlatAlarmRecordVO> page(PageReqDTO<PlatAlarmRecordQueryDTO> dto) { public PageVO<PlatAlarmRecordVO> page(PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
...@@ -92,7 +115,7 @@ implements PlatAlarmRecordService{ ...@@ -92,7 +115,7 @@ implements PlatAlarmRecordService{
@Override @Override
@Transactional @Transactional
public void notice(String recordId) { public void noticeRelation(String recordId) {
//todo //todo
PlatAlarmRecord platAlarmRecord = this.getById(recordId); PlatAlarmRecord platAlarmRecord = this.getById(recordId);
...@@ -100,5 +123,36 @@ implements PlatAlarmRecordService{ ...@@ -100,5 +123,36 @@ implements PlatAlarmRecordService{
String deviceId = platAlarmRecord.getDeviceId(); String deviceId = platAlarmRecord.getDeviceId();
LambdaQueryWrapper<PlatRoomBedDevice> roomBedDeviceLambdaQueryWrapper = new LambdaQueryWrapper<PlatRoomBedDevice>()
.eq(PlatRoomBedDevice::getEquipmentId, deviceId).orderByDesc(BaseEntity::getUpdateDate);
PlatRoomBedDevice platRoomBedDevice = platRoomBedDeviceService.getOne(roomBedDeviceLambdaQueryWrapper, false);
//绑定房间的设备要通知 全部老人的家属
if(platRoomBedDevice == null){
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_ALARM_NOT_FOUND_SPACE);
}
String bedId = platRoomBedDevice.getBedId();
String roomId = platRoomBedDevice.getRoomId();
LambdaQueryWrapper<PlatElder> elderLambdaQueryWrapper = new LambdaQueryWrapper<PlatElder>().eq(StringUtils.isNotBlank(bedId), PlatElder::getBedId, bedId)
.eq(PlatElder::getRoomId, roomId);
List<PlatElder> elderList = platElderService.list(elderLambdaQueryWrapper);
if(CollectionUtils.isEmpty(elderList)){
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_ALARM_NOT_FOUND_ELDER);
}
Set<String> elderIdSet = elderList.stream().map(BaseEntity::getId).collect(Collectors.toSet());
List<PlatElderSocialRelation> relations = platElderSocialRelationService.list(new LambdaQueryWrapper<PlatElderSocialRelation>().in(PlatElderSocialRelation::getElderId, elderIdSet));
Set<String> phoneList = relations.stream().map(PlatElderSocialRelation::getPhone).collect(Collectors.toSet());
String notifyChannel = platAlarmConfig.getNotifyChannel();
String[] split = notifyChannel.split(",");
List<String> notifyChannelList = Arrays.asList(SendTypeEnum.SMS.getValue(), SendTypeEnum.VOICE_SMS.getValue(),SendTypeEnum.CHILD_WECHAT.getValue());
Set<String> sendTypeList = Stream.of(split).filter(vo -> notifyChannelList.contains(vo)).collect(Collectors.toSet());
for (String sendType: sendTypeList) {
SendTypeEnum sendTypeEnum = SendTypeEnum.getByValue(sendType);
msgUtil.send(sendTypeEnum,phoneList,platAlarmRecord.getContent());
}
platAlarmRecord.setNoticeStatus(CommonEnum.YES.getValue());
updateById(platAlarmRecord);
} }
} }
...@@ -90,6 +90,7 @@ public class IotSyncTask { ...@@ -90,6 +90,7 @@ public class IotSyncTask {
if(platDevice==null){ if(platDevice==null){
platDevice=new PlatDevice(); platDevice=new PlatDevice();
platDevice.setTenantId(tenantId); platDevice.setTenantId(tenantId);
deviceMap.put(iotDevice.getId(),platDevice);
} }
platDevice.setOriDeviceId(iotDevice.getId()); platDevice.setOriDeviceId(iotDevice.getId());
platDevice.setName(iotDevice.getName()); platDevice.setName(iotDevice.getName());
...@@ -100,6 +101,9 @@ public class IotSyncTask { ...@@ -100,6 +101,9 @@ public class IotSyncTask {
platDevice.setDescription(iotDevice.getDescribe()); platDevice.setDescription(iotDevice.getDescribe());
String state = iotDevice.getState(); String state = iotDevice.getState();
platDevice.setStatus(StringUtils.equals("online",state)?CommonEnum.YES.getValue() : CommonEnum.NO.getValue()); platDevice.setStatus(StringUtils.equals("online",state)?CommonEnum.YES.getValue() : CommonEnum.NO.getValue());
//todo 根据类型名称来匹配
// platDevice.setCategory();
// platDevice.setFirmwareVersion(); // platDevice.setFirmwareVersion();
// platDevice.setLastOnlineData(); // platDevice.setLastOnlineData();
// platDevice.setOrgId(); // platDevice.setOrgId();
...@@ -114,7 +118,7 @@ public class IotSyncTask { ...@@ -114,7 +118,7 @@ public class IotSyncTask {
// platDevice.setCreateBy(); // platDevice.setCreateBy();
// platDevice.setUpdateBy(); // platDevice.setUpdateBy();
deviceMap.put(iotDevice.getId(),platDevice);
}); });
return deviceMap.values(); return deviceMap.values();
} }
......
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