Commit 43efc4f4 by 李小龙

整理代码

parent 8ec03134
...@@ -26,17 +26,19 @@ CREATE TABLE `plat_user` ( ...@@ -26,17 +26,19 @@ CREATE TABLE `plat_user` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='租户账号管理'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='租户账号管理';
CREATE TABLE `plat_role` ( CREATE TABLE `plat_role` (
`id` varchar(64) NOT NULL COLLATE utf8mb4_general_ci COMMENT 'id', `id` varchar(64) NOT NULL COMMENT 'id',
`tenant_id` varchar(64) NOT NULL COMMENT '租户id', `tenant_id` varchar(64) NOT NULL COMMENT '租户id',
`name` varchar(100) NOT NULL COMMENT '名称', `name` varchar(100) NOT NULL COMMENT '名称',
`remark` varchar(255) DEFAULT NULL COMMENT '备注', `remark` varchar(255) DEFAULT NULL COMMENT '备注',
`data_scope` varchar(600) DEFAULT NULL COMMENT '数据权限 子公司id 上级可看到下级', `data_scope` varchar(600) DEFAULT NULL COMMENT '数据权限 子公司id 上级可看到下级',
`create_date` datetime NOT NULL COMMENT '创建时间', `create_date` datetime NOT NULL COMMENT '创建时间',
`update_date` datetime NOT NULL COMMENT '更新时间', `update_date` datetime NOT NULL COMMENT '更新时间',
`del_flag` CHAR(1) DEFAULT NULL COMMENT '删除标识', `del_flag` char(1) DEFAULT NULL COMMENT '删除标识',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人', `update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人', `create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
`org_id` varchar(64) DEFAULT NULL COMMENT '所属组织', `org_id` varchar(64) DEFAULT NULL COMMENT '所属组织',
`code` varchar(64) DEFAULT NULL COMMENT 'code',
`status` char(1) DEFAULT NULL COMMENT '状态',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='租户端角色'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='租户端角色';
......
...@@ -94,7 +94,7 @@ public class RedisConst { ...@@ -94,7 +94,7 @@ public class RedisConst {
public static final String ALARM_DEVICE_ID = "alarm:device:id:"; public static final String ALARM_DEVICE_ID = "alarm:device:id:";
public static final String ALARM_CONFIG_ORG_ID = "alarm:config:org:id"; public static final String ALARM_CONFIG_ORG_ID = "alarm:config:org:id:";
public static final String PLAT_IOT_DEVICE_PREFIX = "plat:iot:device:"; public static final String PLAT_IOT_DEVICE_PREFIX = "plat:iot:device:";
......
...@@ -38,4 +38,10 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable { ...@@ -38,4 +38,10 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable {
@ApiModelProperty(value = "菜单集合") @ApiModelProperty(value = "菜单集合")
private List<PlatMenuDTOVO> menuList; private List<PlatMenuDTOVO> menuList;
private String code;
private String remark;
private String status;
} }
...@@ -33,4 +33,8 @@ public class PlatRole extends BaseBusEntity { ...@@ -33,4 +33,8 @@ public class PlatRole extends BaseBusEntity {
private String dataScope; private String dataScope;
private String orgId; private String orgId;
private String code;
private String status;
} }
\ No newline at end of file
package com.makeit.service.platform.alarm.alarmStrategy; package com.makeit.service.platform.alarm.alarmStrategy;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO; import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.dto.platform.alarm.PlatAlarmConfigBehaviorDTOVO; import com.makeit.dto.platform.alarm.PlatAlarmConfigBehaviorDTOVO;
...@@ -46,7 +47,7 @@ public class BehaviorAlarm implements IAlarm{ ...@@ -46,7 +47,7 @@ public class BehaviorAlarm implements IAlarm{
if (StringUtils.isBlank(ruleConfigStr)) { if (StringUtils.isBlank(ruleConfigStr)) {
return; return;
} }
String personState = (String) properties.get("personState"); String personState = Convert.toStr(properties.get("personState"));
PlatAlarmConfigBehaviorDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigBehaviorDTOVO.class); PlatAlarmConfigBehaviorDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigBehaviorDTOVO.class);
Integer duration = ruleConfig.getDuration(); Integer duration = ruleConfig.getDuration();
duration = duration*60; duration = duration*60;
......
package com.makeit.service.platform.alarm.alarmStrategy; package com.makeit.service.platform.alarm.alarmStrategy;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO; import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.dto.platform.alarm.PlatAlarmConfigRespiratoryDTOVO; import com.makeit.dto.platform.alarm.PlatAlarmConfigRespiratoryDTOVO;
...@@ -48,7 +49,7 @@ public class BreathAlarm implements IAlarm{ ...@@ -48,7 +49,7 @@ public class BreathAlarm implements IAlarm{
if (StringUtils.isBlank(ruleConfigStr)) { if (StringUtils.isBlank(ruleConfigStr)) {
return; return;
} }
String personState = (String) properties.get("personState"); String personState = Convert.toStr(properties.get("personState"));
//呼吸率 //呼吸率
int br = (int) properties.get("br"); int br = (int) properties.get("br");
......
package com.makeit.service.platform.alarm.alarmStrategy; package com.makeit.service.platform.alarm.alarmStrategy;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO; import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
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.space.PlatRoom;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum; import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
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.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component @Component
public class FallAlarm implements IAlarm{ public class FallAlarm implements IAlarm{
@Autowired @Autowired
...@@ -29,18 +35,27 @@ public class FallAlarm implements IAlarm{ ...@@ -29,18 +35,27 @@ public class FallAlarm implements IAlarm{
@Override @Override
public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) { public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) {
JSONObject properties = platAlarmCheckDTO.getProperties(); JSONObject properties = platAlarmCheckDTO.getProperties();
String personState = (String) properties.get("personState"); String personState = Convert.toStr(properties.get("personState"));
if (StringUtils.equals(personState, "1")) { if (StringUtils.equals(personState, "1")) {
notice(platAlarmCheckDTO); notice(platAlarmCheckDTO);
} }
} }
@Override @Override
@Async
public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) { public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) {
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO); platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
platAlarmCheckDTO.getParam().add("房间名111"); 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.createPlatAlarmRecord(platAlarmCheckDTO);
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(),platAlarmRecord);
}
} }
} }
package com.makeit.service.platform.alarm.alarmStrategy; package com.makeit.service.platform.alarm.alarmStrategy;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO; import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.dto.platform.alarm.PlatAlarmConfigHeartDTOVO; import com.makeit.dto.platform.alarm.PlatAlarmConfigHeartDTOVO;
...@@ -40,7 +41,7 @@ public class HeartAlarm implements IAlarm { ...@@ -40,7 +41,7 @@ public class HeartAlarm implements IAlarm {
if (StringUtils.isBlank(ruleConfigStr)) { if (StringUtils.isBlank(ruleConfigStr)) {
return; return;
} }
String personState = (String) properties.get("personState"); String personState = Convert.toStr(properties.get("personState"));
//心率 //心率
int hr = (int) properties.get("hr"); int hr = (int) properties.get("hr");
PlatAlarmConfigHeartDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigHeartDTOVO.class); PlatAlarmConfigHeartDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigHeartDTOVO.class);
......
...@@ -229,7 +229,7 @@ implements PlatRoleService { ...@@ -229,7 +229,7 @@ implements PlatRoleService {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR); throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR);
} }
PlatRole role = getById(dto.getId()); PlatRole role = getById(dto.getId());
role.setStatus(dto.getStatus());
updateById(role); updateById(role);
} }
......
...@@ -51,8 +51,8 @@ public class AlarmConfigCacheUtil implements ApplicationRunner { ...@@ -51,8 +51,8 @@ public class AlarmConfigCacheUtil implements ApplicationRunner {
}); });
} }
public PlatAlarmConfig get(String orgIdType) { public PlatAlarmConfig get(String orgId,String alarmType) {
return RedisUtil.get(RedisConst.ALARM_CONFIG_ORG_ID+orgIdType); return RedisUtil.get(RedisConst.ALARM_CONFIG_ORG_ID+orgId+":"+alarmType);
} }
...@@ -70,19 +70,17 @@ public class AlarmConfigCacheUtil implements ApplicationRunner { ...@@ -70,19 +70,17 @@ public class AlarmConfigCacheUtil implements ApplicationRunner {
} }
public List<PlatAlarmConfig> getDeviceAlarmConfigMap(PlatDevice platDevice) { public List<PlatAlarmConfig> getDeviceAlarmConfigMap(PlatDevice platDevice) {
List<PlatAlarmConfig> set = new ArrayList<>();
if (StringUtils.equals(platDevice.getCategory(), PlatDeviceEnum.CategoryEnum.HEART.getValue())) { if (StringUtils.equals(platDevice.getCategory(), PlatDeviceEnum.CategoryEnum.HEART.getValue())) {
List<PlatAlarmConfig> set = new ArrayList<>(); set.add(this.get(platDevice.getOrgId() ,PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue()));
set.add(this.get(platDevice.getOrgId() + PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue())); set.add(this.get(platDevice.getOrgId() , PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue()));
set.add(this.get(platDevice.getOrgId() + PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue()));
} }
if (StringUtils.equals(platDevice.getCategory(), PlatDeviceEnum.CategoryEnum.FALL.getValue())) { if (StringUtils.equals(platDevice.getCategory(), PlatDeviceEnum.CategoryEnum.FALL.getValue())) {
List<PlatAlarmConfig> set = new ArrayList<>(); set.add(this.get(platDevice.getOrgId() , PlatAlarmConfigEnum.AlarmTypeEnum.FALL.getValue()));
set.add(this.get(platDevice.getOrgId() + PlatAlarmConfigEnum.AlarmTypeEnum.FALL.getValue()));
} }
if (StringUtils.equals(platDevice.getCategory(), PlatDeviceEnum.CategoryEnum.SPACE.getValue())) { if (StringUtils.equals(platDevice.getCategory(), PlatDeviceEnum.CategoryEnum.SPACE.getValue())) {
List<PlatAlarmConfig> set = new ArrayList<>(); set.add(this.get(platDevice.getOrgId() , PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue()));
set.add(this.get(platDevice.getOrgId() + PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue()));
} }
return new ArrayList<>(); return set ;
} }
} }
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