Commit 8f174669 by 罗志长

feat: 跌倒告警上报第三方限制组织

parent 707c3172
ALTER TABLE `plat_device_other` ALTER TABLE `plat_device_other`
...@@ -123,4 +123,6 @@ alter table plat_elder_sleep_analysis add column `ori_device_id` varchar(64) de ...@@ -123,4 +123,6 @@ alter table plat_elder_sleep_analysis add column `ori_device_id` varchar(64) de
alter table plat_elder_breathe_analysis add column `ori_device_id` varchar(64) default NULL COMMENT 'iot设备id'; alter table plat_elder_breathe_analysis add column `ori_device_id` varchar(64) default NULL COMMENT 'iot设备id';
alter table plat_elder_children_info add column weChat_openid varchar(64) default null comment '公众号openid'; alter table plat_elder_children_info add column weChat_openid varchar(64) default null comment '公众号openid';
\ No newline at end of file
alter table plat_tenant add column report_org_ids varchar(255) default null comment '主动上报机构ids';
\ No newline at end of file
...@@ -67,6 +67,11 @@ public class PlatTenant extends BaseEntity { ...@@ -67,6 +67,11 @@ public class PlatTenant extends BaseEntity {
private String secret; private String secret;
private String openApiUrl; private String openApiUrl;
/**
* 租户标识
*/
private String reportOrgIds;
} }
\ No newline at end of file
...@@ -102,12 +102,14 @@ public class FallAlarm implements IAlarm { ...@@ -102,12 +102,14 @@ public class FallAlarm implements IAlarm {
// 跌倒了设备需要发送告警到第三方平台 // 跌倒了设备需要发送告警到第三方平台
PlatTenant platTenant = platTenantService.getById(platDevice.getTenantId()); PlatTenant platTenant = platTenantService.getById(platDevice.getTenantId());
if (platTenant != null) { if (platTenant != null) {
OpenApiBaseStrategy strategyFactoryHandler = openApiBaseStrategyFactory.getHandler(platTenant.getCode()); if (isSupportAlarm(platTenant, platDevice)) {
if (strategyFactoryHandler != null) { OpenApiBaseStrategy strategyFactoryHandler = openApiBaseStrategyFactory.getHandler(platTenant.getCode());
try { if (strategyFactoryHandler != null) {
strategyFactoryHandler.alarm(platTenant, platDevice.getOriDeviceId(), properties); try {
} catch (Exception e) { strategyFactoryHandler.alarm(platTenant, platDevice.getOriDeviceId(), properties);
log.error("调用openapi告警接口失败:{}", e.getMessage(), e); } catch (Exception e) {
log.error("调用openapi告警接口失败:{}", e.getMessage(), e);
}
} }
} }
} }
...@@ -120,6 +122,15 @@ public class FallAlarm implements IAlarm { ...@@ -120,6 +122,15 @@ public class FallAlarm implements IAlarm {
} }
} }
private boolean isSupportAlarm(PlatTenant platTenant, PlatDevice platDevice) {
String reportOrgIds = platTenant.getReportOrgIds();
if (StringUtils.isBlank(reportOrgIds)) {
return false;
}
List<String> orgIds = Arrays.asList(StringUtils.split(reportOrgIds, ","));
return orgIds.contains(platDevice.getOrgId());
}
private void recordDuration(PlatAlarmCheckDTO platAlarmCheckDTO) { private void recordDuration(PlatAlarmCheckDTO platAlarmCheckDTO) {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice(); PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
PlatAlarmConfig config = alarmConfigCacheUtil.get(platDevice.getOrgId(), PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue()); PlatAlarmConfig config = alarmConfigCacheUtil.get(platDevice.getOrgId(), PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue());
......
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