Commit a9a4f371 by 朱淼
parents 12f0ae27 73fd4e94
......@@ -111,6 +111,7 @@ public enum CodeMessageEnum {
PLATFORM_ERROR_BAD_NAME_EXIT(500, "PLATFORM.ERROR.BAD.NAME.EXIT"),
PLATFORM_ERROR_BAD_NOT_DEL(500, "PLATFORM.ERROR.BAD.NOT.DEL"),
PLATFORM_ERROR_ROOM_OTHER_USED_NOT_DEL(500, "PLATFORM.ERROR.ROOM.OTHER.USED.NOT.DEL"),
PLATFORM_ERROR_BED_BIND_DEVICE_NOT_AUTH(500, "PLATFORM.ERROR.BED.BIND_DEVICE_NOT_AUTH"),
SYSTEM_ERROR_CANT_CHANGE_TENANT_STATUS(500, "SYSTEM.ERROR.CANT.CHANGE.TENANT.STATUS"),
SYSTEM_ERROR_CANT_REMOVE_TENANT_USER_LINK(500, "SYSTEM.ERROR.CANT.REMOVE.TENANT.USER.LINK"),
......
......@@ -106,6 +106,7 @@ PLATFORM.ERROR.BAD.NAME.EXIT=床位名称已存在
PLATFORM.ERROR.BAD.NOT.DEL=床位已绑定长者或设备,不可删除
PLATFORM.ERROR.ROOM.OTHER.USED.NOT.DEL=该房间下有床位有其他长者入住
PLATFORM.ERROR.BED.BIND_DEVICE_NOT_AUTH=该床位已绑定设备,请重新选择床位
SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD=不能在该节点下新增非管理员角色
......
......@@ -8,26 +8,22 @@ import lombok.Data;
public class PlatUserImportDTO {
private static final String headDesc = "导入说明:\n" +
"\n" +
"1.带*号为必填项\n" +
"\n" +
"2.手机号和邮箱不可重复\n" +
"\n" +
"3.角色必须为【角色管理】处维护的角色名称\n" +
"\n" +
"4.导入人员默认登录密码为:888888";
"4.导入人员默认登录密码为:abc888888";
@ExcelProperty(value = "姓名*")
@ExcelProperty(value = {headDesc,"姓名*"})
private String username;
@ExcelProperty(value = "手机号*")
@ExcelProperty(value = {headDesc,"手机号*"})
private String mobile;
@ExcelProperty(value = "邮箱")
@ExcelProperty(value = {headDesc,"邮箱"})
private String email;
@ExcelProperty(value = "*所属组织")
@ExcelProperty(value = {headDesc,"*所属组织"})
private String orgName;
@ExcelProperty(value = "*角色")
@ExcelProperty(value = {headDesc,"*角色"})
private String roleName;
@ExcelProperty(value = "备注")
@ExcelProperty(value = {headDesc,"备注"})
private String remark;
......
......@@ -63,7 +63,7 @@ public class BehaviorAlarm implements IAlarm {
String ruleConfigStr = config.getRuleConfig();
JSONObject properties = platAlarmCheckDTO.getProperties();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getOriDeviceId();
String deviceId = platDevice.getId();
if (StringUtils.isBlank(ruleConfigStr)) {
log.error("行为告警配置未配置,告警配置id:" + config.getId());
return;
......@@ -71,7 +71,7 @@ public class BehaviorAlarm implements IAlarm {
String personState = Convert.toStr(properties.get("personState"));
PlatAlarmConfigBehaviorDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigBehaviorDTOVO.class);
Integer duration = ruleConfig.getAverageDuration();//分钟
PlatDayDurationRecord platDayDurationRecord = dayDurationUtil.get(platDevice.getOriDeviceId());
PlatDayDurationRecord platDayDurationRecord = dayDurationUtil.get(deviceId);
// if (platDayDurationRecord == null) {
// log.error("行为告警未找到行为异常平均时长,设备plat_id:" + platDevice.getId());
// return;
......@@ -155,11 +155,11 @@ public class BehaviorAlarm implements IAlarm {
log.error("未关联长者,设备id:"+platDevice.getId());
return;
}
PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom();
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
if(CollectionUtils.isNotEmpty(platElderList)){
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
platElderList = platAlarmCheckDTO.getPlatElderList();
}
for (PlatElder platElder : platElderList) {
PlatDayDurationRecord durationRecord = new PlatDayDurationRecord();
......
......@@ -84,7 +84,7 @@ public class BreathAlarm implements IAlarm {
Integer duration = ruleConfig.getDuration();
JSONObject properties = platAlarmCheckDTO.getProperties();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getOriDeviceId();
String deviceId = platDevice.getId();
String personState = Convert.toStr(properties.get("personState"));
//呼吸率
......
......@@ -44,7 +44,7 @@ public class FallAlarm implements IAlarm {
public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) {
JSONObject properties = platAlarmCheckDTO.getProperties();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getOriDeviceId();
String deviceId = platDevice.getId();
String personState = Convert.toStr(properties.get("personState"));
AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_FALL_ID + deviceId);
if(alarmRedisDTO==null){
......@@ -54,7 +54,7 @@ public class FallAlarm implements IAlarm {
}
if (StringUtils.equals(personState, CommonEnum.YES.getValue())) {
if (StringUtils.equals(alarmRedisDTO.getAlarm(),CommonEnum.YES.getValue())){
log.error("长者跌倒,已告警过,设备iot_id:"+deviceId);
log.error("长者跌倒,已告警过,设备plat_id:"+deviceId);
return;
}
notice(platAlarmCheckDTO);
......
......@@ -71,7 +71,7 @@ public class HeartAlarm implements IAlarm {
JSONObject properties = platAlarmCheckDTO.getProperties();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getOriDeviceId();
String deviceId = platDevice.getId();
Integer start = ruleConfig.getHeartRateStart();
Integer end = ruleConfig.getHeartRateeEnd();
Integer duration = ruleConfig.getDuration();
......
......@@ -210,9 +210,10 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe
});
saveBatch(configList);
alarmConfigUtil.putAll(configList);
});
alarmConfigUtil.putAll(configList);
}
@Override
......
......@@ -269,7 +269,8 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
} else {
String notifyUser = alarmConfig.getNotifyUser();
if(StringUtils.isBlank(notifyUser)){
throw new BusinessException("告警内部人员未配置,告警配置id:"+alarmConfig.getId());
log.error("告警内部人员未配置,告警配置id:"+alarmConfig.getId());
return;
}
String[] userArray = notifyUser.split(",");
List<PlatUser> platUsers = platUserService.listByIds(Arrays.asList(userArray));
......@@ -277,7 +278,8 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
}
platUserList.removeIf(Objects::isNull);
if (CollectionUtils.isEmpty(platUserList)) {
throw new BusinessException("通知工作人员时,找不到人员数据;" + "orgId:" + alarmConfig.getOrgId() + ",tenantId:" + alarmConfig.getTenantId() + "alarmConfigId:" + alarmConfig.getId());
log.error("通知工作人员时,找不到人员数据;" + "orgId:" + alarmConfig.getOrgId() + ",tenantId:" + alarmConfig.getTenantId() + "alarmConfigId:" + alarmConfig.getId());
return;
}
List<SendTypeEnum> notifyChannelList = Arrays.asList(SendTypeEnum.SMS, SendTypeEnum.VOICE_SMS, SendTypeEnum.MAIL);
Set<String> phoneSet = platUserList.stream().map(PlatUser::getMobile).collect(Collectors.toSet());
......@@ -363,8 +365,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
;
//todo 要支持 设备绑定多个空间
List<PlatRoomBedDevice> platRoomBedDeviceList = platRoomBedDeviceService.list(roomBedDeviceLambdaQueryWrapper);
if(CollectionUtils.isNotEmpty(platRoomBedDeviceList)){
throw new BusinessException("设备没绑定房间:"+platDevice.getId());
if(CollectionUtils.isEmpty(platRoomBedDeviceList)){
log.error("设备没绑定房间:"+platDevice.getId());
return;
}
platRoomBedDeviceList.forEach(platRoomBedDevice -> {
......
......@@ -369,10 +369,14 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
vo.setDistance(i.getProperties().getDistance());
vo.setAngle(i.getProperties().getAngle());
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
return vo;
})
);
});
return voList;
......
......@@ -652,6 +652,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
PlatElder db = getById(dto.getId());
String oldBedId = db.getBedId();
PlatElder platElder = BeanDtoVoUtils.convert(dto, PlatElder.class);
fillSpace(platElder);
......@@ -662,6 +664,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
if (StringUtils.isNotBlank(dto.getBedId()) && StringUtils.isBlank(db.getBedId())) {
checkInInternal(dto.getBedId());
checkOutInternal(oldBedId);
}
......@@ -744,6 +747,14 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
platBedService.changeStatus(statusDTO);
}
private void checkOutInternal(String bedId) {
StatusDTO statusDTO = new StatusDTO();
statusDTO.setId(bedId);
statusDTO.setStatus(CommonEnum.YES.getValue());
platBedService.changeStatus(statusDTO);
}
//TODO ywc 可能要改床位表状态
@Transactional
......
......@@ -16,8 +16,10 @@ import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.device.PlatDeviceEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.space.PlatRoomBedDeviceMapper;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.space.*;
......@@ -63,6 +65,16 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
List<String> listEquipmentIds = dto.getListDeviceId();
List<PlatRoomBedDevice> list = new ArrayList<>();
if(dto.getBedId() != null){
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatRoomBedDevice::getRoomId,dto.getRoomId());
queryWrapper.eq(PlatRoomBedDevice::getBedId,dto.getBedId());
queryWrapper.isNotNull(PlatRoomBedDevice::getDeviceId);
if(count(queryWrapper) > 0){
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_BED_BIND_DEVICE_NOT_AUTH);
}
}
listEquipmentIds.forEach(item -> {
PlatRoomBedDevice data = new PlatRoomBedDevice();
......
......@@ -39,7 +39,7 @@ public class DayDurationUtil implements ApplicationRunner {
if(CollectionUtils.isEmpty(platDayDurationRecords)){
return;
}
Map<String, List<PlatDayDurationRecord>> deviceIdMap = platDayDurationRecords.stream().collect(Collectors.groupingBy(PlatDayDurationRecord::getOriDeviceId));
Map<String, List<PlatDayDurationRecord>> deviceIdMap = platDayDurationRecords.stream().collect(Collectors.groupingBy(PlatDayDurationRecord::getDeviceId));
deviceIdMap.entrySet().stream().map(vo -> {
List<PlatDayDurationRecord> value = vo.getValue();
int size = value.size();
......@@ -52,16 +52,16 @@ public class DayDurationUtil implements ApplicationRunner {
}
public void put(PlatDayDurationRecord platDayDurationRecord) {
RedisUtil.set(RedisConst.ELDER_DAY_DURATION_PREFIX + platDayDurationRecord.getOriDeviceId(), platDayDurationRecord);
RedisUtil.set(RedisConst.ELDER_DAY_DURATION_PREFIX + platDayDurationRecord.getDeviceId(), platDayDurationRecord);
}
public PlatDayDurationRecord get(String oriDeviceId) {
PlatDayDurationRecord platDayDurationRecord = RedisUtil.get(RedisConst.ELDER_DAY_DURATION_PREFIX + oriDeviceId);
public PlatDayDurationRecord get(String platDeviceId) {
PlatDayDurationRecord platDayDurationRecord = RedisUtil.get(RedisConst.ELDER_DAY_DURATION_PREFIX + platDeviceId);
if(platDayDurationRecord==null){
//getAll();
}
return RedisUtil.get(RedisConst.ELDER_DAY_DURATION_PREFIX + oriDeviceId);
return RedisUtil.get(RedisConst.ELDER_DAY_DURATION_PREFIX + platDeviceId);
}
/**
......
......@@ -8,6 +8,12 @@ import java.math.BigDecimal;
@Data
public class PlatElderCoordinateVO {
@ApiModelProperty(value = "设备ID")
private String deviceId;
@ApiModelProperty(value = "原始设备ID")
private String oriDeviceId;
@ApiModelProperty("x")
private BigDecimal x;
......
......@@ -29,7 +29,7 @@
</sql>
<select id="getDayMaxDurationList" resultType="com.makeit.entity.platform.alarm.PlatDayDurationRecord">
select
pddr.ori_device_id,
pddr.device_id,
pddr.day,
max(pddr.duration) as duration
from plat_day_duration_record pddr
......@@ -47,7 +47,7 @@
</foreach>
</if>
</where>
group by pddr.ori_device_id, pddr.day
group by pddr.device_id, pddr.day
order by duration
</select>
</mapper>
......@@ -83,44 +83,48 @@ public class PushCallback implements MqttCallback {
HeaderInfo headers = device.getHeaders();
List<HeaderInfo.Bind> bindings = headers.getBindings();
for (HeaderInfo.Bind binding : bindings) {
String iot_tenantId = binding.getId();
StopWatch stopWatch = new StopWatch();
stopWatch.start("checkAlarm-1");
String deviceId = device.getDeviceId();
JSONObject properties = device.getProperties();
//iot设备id
PlatDevice platDevice = deviceCacheUtil.get(deviceId+":"+iot_tenantId);
if(platDevice==null){
logger.error("获取设备信息异常,设备iot-id:"+deviceId);
return;
}
List<PlatAlarmConfig> deviceAlarmConfigList = alarmConfigCacheUtil.getDeviceAlarmConfigMap(platDevice);
deviceAlarmConfigList.removeIf(Objects::isNull);
if (CollectionUtils.isEmpty(deviceAlarmConfigList)) {
logger.error("该设备没有告警配置,设备iot-id:"+deviceId);
return;
}
for (PlatAlarmConfig config : deviceAlarmConfigList) {
String alarmType = config.getAlarmType();
PlatAlarmCheckDTO platAlarmCheckDTO = new PlatAlarmCheckDTO();
//告警配置
platAlarmCheckDTO.setPlatAlarmConfig(config);
//设备信息
platAlarmCheckDTO.setPlatDevice(platDevice);
//iot上报数据
platAlarmCheckDTO.setProperties(properties);
for (IAlarm alarm : alarmList) {
if (alarm.support(alarmType)) {
alarm.checkConfig(platAlarmCheckDTO);
try {
String iot_tenantId = binding.getId();
StopWatch stopWatch = new StopWatch();
stopWatch.start("checkAlarm-1");
String deviceId = device.getDeviceId();
JSONObject properties = device.getProperties();
//iot设备id
PlatDevice platDevice = deviceCacheUtil.get(deviceId + ":" + iot_tenantId);
if (platDevice == null) {
logger.error("获取设备信息异常,设备iot-id,iot_tenantId:" + deviceId+","+iot_tenantId);
return;
}
List<PlatAlarmConfig> deviceAlarmConfigList = alarmConfigCacheUtil.getDeviceAlarmConfigMap(platDevice);
deviceAlarmConfigList.removeIf(Objects::isNull);
if (CollectionUtils.isEmpty(deviceAlarmConfigList)) {
logger.error("该设备没有告警配置,设备iot-id,iot_tenantId:" + deviceId+","+iot_tenantId);
return;
}
for (PlatAlarmConfig config : deviceAlarmConfigList) {
String alarmType = config.getAlarmType();
PlatAlarmCheckDTO platAlarmCheckDTO = new PlatAlarmCheckDTO();
//告警配置
platAlarmCheckDTO.setPlatAlarmConfig(config);
//设备信息
platAlarmCheckDTO.setPlatDevice(platDevice);
//iot上报数据
platAlarmCheckDTO.setProperties(properties);
for (IAlarm alarm : alarmList) {
if (alarm.support(alarmType)) {
alarm.checkConfig(platAlarmCheckDTO);
}
}
}
stopWatch.stop();
logger.info(stopWatch.prettyPrint());
}catch (Exception e){
logger.error("告警异常pushCallback:",e);
}
stopWatch.stop();
logger.info(stopWatch.prettyPrint());
}
......
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