Commit c1c027fe by 罗志长

Merge branch 'dev'

parents bbc5094a 1a9a479c
Showing with 1925 additions and 676 deletions
......@@ -3,7 +3,7 @@ INSERT INTO `saas_user`(`id`, `username`, `account`, `password`, `mobile`, `stat
INSERT INTO `plat_alarm_config`(`id`, `alarm_type`, `status`, `org_id`, `city_org_id`, `district_org_id`, `street_org_id`, `org_path`, `rule_config`, `content`, `notify_channel`, `notify_relation`, `notify_way`, `notify_user`, `description`, `create_by`, `create_date`, `update_by`, `update_date`, `del_flag`, `tenant_id`, `content_audit`) VALUES ('1699667670087065604', '1', '1', '1701542574740770817', NULL, NULL, NULL, NULL, '{}', '[#长者姓名]在[#房间名]跌倒,请及时处理!', '', '1', '1', NULL, NULL, 'platAdmin02', '2023-09-07 14:15:26', '测试clt', '2023-09-12 17:09:17', '0', '0', NULL);
INSERT INTO `plat_alarm_config`(`id`, `alarm_type`, `status`, `org_id`, `city_org_id`, `district_org_id`, `street_org_id`, `org_path`, `rule_config`, `content`, `notify_channel`, `notify_relation`, `notify_way`, `notify_user`, `description`, `create_by`, `create_date`, `update_by`, `update_date`, `del_flag`, `tenant_id`, `content_audit`) VALUES ('16996678722776842251', '2', '1', '1701542574740770817', NULL, NULL, NULL, NULL, '{\"respiratoryRateStart\":\"10\",\"respiratoryRateEnd\":\"120\",\"duration\":\"5\"}', '[#长者姓名][#呼吸状态],请及时处理!', '', '1', '1', NULL, NULL, 'platAdmin02', '2023-09-07 14:16:14', 'platAdmin02', '2023-09-07 14:16:14', '0', '0', NULL);
INSERT INTO `plat_alarm_config`(`id`, `alarm_type`, `status`, `org_id`, `city_org_id`, `district_org_id`, `street_org_id`, `org_path`, `rule_config`, `content`, `notify_channel`, `notify_relation`, `notify_way`, `notify_user`, `description`, `create_by`, `create_date`, `update_by`, `update_date`, `del_flag`, `tenant_id`, `content_audit`) VALUES ('16996680489417687051', '3', '1', '1701542574740770817', NULL, NULL, NULL, NULL, '{\"heartRateStart\":\"60\",\"heartRateeEnd\":\"90\",\"duration\":\"5\"}', '[#长者姓名][#心率状态],请及时处理!', '', '1', '1', NULL, NULL, 'platAdmin02', '2023-09-07 14:16:56', 'platAdmin02', '2023-09-07 14:16:56', '0', '0', NULL);
INSERT INTO `plat_alarm_config`(`id`, `alarm_type`, `status`, `org_id`, `city_org_id`, `district_org_id`, `street_org_id`, `org_path`, `rule_config`, `content`, `notify_channel`, `notify_relation`, `notify_way`, `notify_user`, `description`, `create_by`, `create_date`, `update_by`, `update_date`, `del_flag`, `tenant_id`, `content_audit`) VALUES ('16996680489417687051', '3', '1', '1701542574740770817', NULL, NULL, NULL, NULL, '{\"heartRateStart\":\"60\",\"heartRateEnd\":\"90\",\"duration\":\"5\"}', '[#长者姓名][#心率状态],请及时处理!', '', '1', '1', NULL, NULL, 'platAdmin02', '2023-09-07 14:16:56', 'platAdmin02', '2023-09-07 14:16:56', '0', '0', NULL);
INSERT INTO `plat_alarm_config`(`id`, `alarm_type`, `status`, `org_id`, `city_org_id`, `district_org_id`, `street_org_id`, `org_path`, `rule_config`, `content`, `notify_channel`, `notify_relation`, `notify_way`, `notify_user`, `description`, `create_by`, `create_date`, `update_by`, `update_date`, `del_flag`, `tenant_id`, `content_audit`) VALUES ('16996682046846648331', '4', '1', '1701542574740770817', NULL, NULL, NULL, NULL, '{\"averageDuration\":\"5\"}', '[#长者姓名]在[#上级空间名-房间名]内存在行为异常,请及时处理!', '', '1', '1', NULL, NULL, 'platAdmin02', '2023-09-07 14:17:33', 'platAdmin02', '2023-09-07 14:17:33', '0', '0', NULL);
......
ALTER TABLE `plat_device_other`
ALTER TABLE `plat_device_other`
......@@ -4,8 +4,7 @@ ADD COLUMN `secure_key` varchar(255) COMMENT '密钥key' AFTER `secure_id`;
ALTER TABLE `plat_alarm_record`
ADD COLUMN `misinformation_flag` char(1) DEFAULT 0 COMMENT '是否误报 1 误报 0 没有误报' AFTER `read_flag`
ADD COLUMN `wechat_read_flag` char(1) DEFAULT 0 COMMENT '小程序端是否读取 0未读 1已读' AFTER `misinformation_flag`;
ADD COLUMN `misinformation_flag` char(1) DEFAULT 0 COMMENT '是否误报 1 误报 0 没有误报' AFTER `read_flag`;
ALTER TABLE `plat_elder_report_month`
......@@ -55,3 +54,34 @@ CREATE TABLE `plat_device_log` (
`tenant_id` varchar(64) DEFAULT NULL COMMENT ' 租户id',
PRIMARY KEY ( `id` )
) ENGINE = INNODB DEFAULT CHARSET = utf8mb4 ROW_FORMAT = COMPACT COMMENT = '设备日志';
-- 12.15 迭代执行sql
## 告警中心新增离床异常 初始化
ALTER TABLE `plat_alarm_config` modify column alarm_type char(1) comment '告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常 5 离床异常';
INSERT INTO `plat_alarm_config`(`id`, `alarm_type`, `status`, `org_id`, `city_org_id`, `district_org_id`, `street_org_id`, `org_path`, `rule_config`, `content`, `notify_channel`, `notify_relation`, `notify_way`, `notify_user`, `description`, `create_by`, `create_date`, `update_by`, `update_date`, `del_flag`, `tenant_id`, `content_audit`)
VALUES ('16996678722776842252', '5', '1', '1701542574740770817', NULL, NULL, NULL, NULL, '{"offBedStart":"00:00:00","offBedEnd":"05:00:00","duration":"60"}', '[#长者姓名]离床时间过长,请及时处理!', '', '1', '1', NULL, NULL, 'platAdmin02', NOW(), 'platAdmin02', NOW(), '0', '0', NULL);
## 离床异常字典
INSERT INTO `sys_dictionary` VALUES ('204', 'alarm.alarmType.offBed', '离床异常', '5', 5, '', '200', NOW(), NOW(), '0', NULL, NULL, NULL);
## 离床次数月统计
ALTER TABLE `plat_elder_report_month` add column off_bed_exception_count int(11) default 0 COMMENT '离床异常次数' after behavior_exception_count;
CREATE TABLE `saas_pid_manage` (
`id` varchar(64) NOT NULL COMMENT 'id',
`pid` varchar(100) NOT NULL COMMENT 'pid',
`status` char(1) DEFAULT NULL COMMENT '状态 0禁用 1启用',
`available_credit` int4 DEFAULT NULL COMMENT '可用额度',
`used_credit` int4 DEFAULT NULL COMMENT '已用额度',
`total_credit` int4 DEFAULT NULL COMMENT '总额度',
`create_date` datetime NOT NULL COMMENT '创建时间',
`update_date` datetime NOT NULL COMMENT '更新时间',
`del_flag` char(1) DEFAULT NULL COMMENT '删除标识',
`create_by` varchar(64) NOT NULL COMMENT '创建人',
`update_by` varchar(64) NOT NULL COMMENT '更新人',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='声网pid管理';
ALTER TABLE `plat_alarm_record`
ADD COLUMN `wechat_read_flag` char(1) DEFAULT 0 COMMENT '小程序端是否读取 0未读 1已读' AFTER `misinformation_flag`;
......@@ -43,6 +43,7 @@ public class SaasDeviceController {
@ApiOperation("列表")
@PostMapping("page")
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity<PageVO<PlatDeviceListVO>> page(@RequestBody PageReqDTO<PlatDevice> pageReqDTO) {
return ApiResponseUtils.success(platDeviceService.pageSaas(pageReqDTO));
......
......@@ -4,6 +4,7 @@ package com.makeit.controller.device;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
......@@ -43,6 +44,7 @@ public class SaasDeviceReportDayController {
@ApiOperation("睡眠评价")
@PostMapping("sleepEvaluation")
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderDayReportDayService.sleepEvaluation(platElderIdDTO));
}
......
......@@ -52,7 +52,7 @@ public class PlatOrgController {
@ApiOperation("树形列表")
@PostMapping("list")
public ApiResponseEntity<List<PlatOrg>> list(@RequestBody PlatOrgQueryDTO platOrgQueryDTO){
return ApiResponseUtils.success(platOrgService.subOrgList(platOrgQueryDTO));
return ApiResponseUtils.success(platOrgService.currentOrg(platOrgQueryDTO));
}
@Action(module = "平台端-组织", name = "新增", code = "plat:org:add")
......
package com.makeit.controller.saas;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.entity.platform.device.PlatDeviceLog;
import com.makeit.entity.saas.SaasPidManage;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.saas.SaasPidManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 声网pid管理 前端控制器
* </p>
*
* @author eugene young
* @since 2023-12-13
*/
@RestController
@RequestMapping("/saas/pidManage")
@Api(tags = "租户管理-声网pid管理")
public class SaasPidManageController {
@Autowired
private SaasPidManageService saasPidManageService;
@ApiOperation("列表")
@PostMapping("page")
@TenantIdIgnore
public ApiResponseEntity<PageVO<SaasPidManage>> page(@RequestBody PageReqDTO<SaasPidManage> pageReqDTO) {
return ApiResponseUtils.success(saasPidManageService.pageList(pageReqDTO));
}
@ApiOperation("新增")
@PostMapping("add")
@TenantIdIgnore
public ApiResponseEntity<Void> add(@RequestBody SaasPidManage dto) {
saasPidManageService.add(dto);
return ApiResponseUtils.success();
}
@ApiOperation("新增")
@PostMapping("delete")
@TenantIdIgnore
public ApiResponseEntity<Void> delete(@RequestBody BaseIdDTO dto) {
saasPidManageService.delete(dto.getId());
return ApiResponseUtils.success();
}
}
......@@ -29,23 +29,24 @@ public class RSAUtils {
public static final String RSA_ALGORITHM = "RSA";
public static final String RSA_ALGORITHM_SIGN = "SHA256WithRSA";
public static final String PRIVATE_KEY = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDEjW_RLCPPCeAPWzQWIAwMGNvHf1pat27oH6CZDCG5nLwxyDsUgxdF89IB2_rLURVTkkrB5tq_dcBk5Wi2pmu2yMn8Dpk2XYsm0LJwJe3gg2qqRXQm8DGbf9kvtHUqBLe_24PMHL88YavJdrcS6HNlwwth2YINmViroqMZgqW4bQnmV4t5X4BO1dl3gTB5y8pRXd1zoKsLNgjzbuVBgieA0-e99eMsdjJadZFPzETQW-BO9Q6Kbbx4fIjOkqxiS8KzsiDSvf3KXG9lfvoz67vuNez_QBFauA_MJsUP_bgHLXFV9-XzcjCE2fkDbKbNHPAP20o1IM1S3G43mGzRwAb5AgMBAAECggEAV_nOsNuG86bB6V2zRKv3eHqv9O2l7bDpLXDqm1Z4yfHDsqyi9R1wD1mBCGAEM3kJiKyUVZIVG1mDUiX05rw6vkfFUNLf9RuNq0QCenwfqzxnQ-tuf_dG3Qkul1G4l6Qg8vk4VuYPGuHE2JoQe6Ab9tKEh7mpopievcRAKKz3rEIn4NGGfg4tlTP2hoZ_EhCDMc02UTtjm2YXUux2T2KLZPXMeClbxU1vTMTxFNp9edWyB9syLbfJp34lrnrueKnqpBPUI4oldKj-3QsE4v3Ie8wLTp5leiowzKqZUXqTplWAvROpIvVfj9eeouBPAz_IQR_U77c3m22cisCh-5QT-QKBgQD764Um0miLVQQIrfM9GQiWpiiM75nzmt4QaRkjoNg896b-qjDelG9K_EQ3RjopFuQBKBf7xY304qtD6nY_5IFRlhdB58nrSgPgSxLaShAQ2yUkdDPr00rDBu_9cAT9GZxSRmDhds-87rnz21QMNIofg2cpKNpl1HQQfTcFN9OETwKBgQDHvFvQ0bizfkh4o71pfD0tiiWEeQzV7KMjuwQ3nnUBfgv2Rd1QkOUo3x_dLBTRzacIslQ3DFljXqoBJWJasRFUSAyikR1KUAven7z5D3u-rdye6MLofKkf0YY_qAlNQXEDh9hzhlWqifd4UJTcZujVQNvkuvjldGnMMTK1W49GNwKBgBUbZ52YFYBPEDZ19KJS3aBZrZ4ZWSnK-P4hACU3DccV7Nz7f3q2rxh2SHTlImxc6Z-bL1897yXsc_MNyviRebBPRgWUmRtoqSh6wcqeV_hBlDwYrFz-6A2tICB46UIXijxufyGE5eTrj5L59nHLWSNIzDTroljT0yGqjBiY09ULAoGAN339hGbACh5rxBi55zS9Som3Irb--fBk4uhyo4FCwMdkS2fdtSSMhm53S9uTbTbV0XS6MREdRJ5oXSklykyno-Lgn8nxeVQD-DYpKolCuBdV1FCW1kDMPCraQZVOAEjOPUzgtjf8VQU_3A2HTjTJO3ZpoYLQ4-8T9cc1b22gwMECgYBCq2CPsNMSf55_VCD23b2B_PuppnowWw-k_zl4MkZGLtLJx5qsLRp-hNRvqW2t81fFkOieDdGg_6s7DPinwKfjH8KNgv7ke3kv9euiJ-AmF8HQKlRNCsX_-J7JeB39BHZXU9WPRI4YT8dR6NzZS3D_ug_Coeiq9TIFa2Za6Q6mXg";
public static final String PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDOQEOR73MVcKL6pMROood6gpq-NGJgSC_q07Zj4KEa81jL8yt9x32vn97-zoGjaq_5R22rPBM-ou1czekvrgs1-XDunyRwXb6yzD83Z8T8AykqWPY1t0YnAXhck-uNWyeJPIsNBQWT38HOywxHUB21Mly8G1dEF4uRUs2fB--XZ78tw1QPl-1DHwIthHelnFTlSCQcxFXEI-vGFPpStvHZ3eNM1tTei8IkNsTimsl3EGgta355pEv6PpSNnGpv_TVzq3Uto5qD4p2VCv2OL96bUN3iLlSOSOz7axi_HHTBau2JEzPZ05kztlMOkwAgdox3fHbI9oayPYIMnsq_1tVLAgMBAAECggEAODXRdINixPQWpuKi0Z9_9saDb9UM_pqN3Jzod13v6k1p5OOX9caZnXSfrKgRMr1PyktKO0G7KPX0ZLeFlsYDLimWOqJKpwkVgNsjW3E_gUNHQ9BNAaS6TMUczXZO2w59vuwuJVU6COwRgM9bwE-4WPqpxWZaKSeVlPyRJ4ddJ9DUHKfugsNxFVKfAKs6TqaF6epOZQLSS6hsX33ZCT7PiYwOp_lltdCNb9IWNu9FhL5H8RqmmruW_9lIrdOYBvLS5R5dYUBZNvSAi0UgaYxfk6q26hyHZnFln1npZDhLnIL5QF2R6eXYa5sgILedToEWvhmTt0kzmnTGXID1sBLsGQKBgQDyvWgGWboCxe5vkwtFNL0Fsh5h4vjyN-o0icYR1VINhTSwJ6beIPWsN9sHrTS2GLDUdhn2o8nkImmJ8GEfQ_ylqdRuYbOSN9DgmwnDJjT2-Pun0QKAKwa5BV4WQbwPTBNpZE85dVU-K0Wam9tcJ3nQQSDHbijQ57RH0J1MPQ33jwKBgQDZhJRq9DOK_gSjPWC-1VzbhuvkuHOGFUuH94V-oCr9dyqCIimPwXAkkO-CxeVnFkDHtdkYa5Jmpa1jmwjmuBgZOjwfq3LmRDgK-sE8fTXPrum4bWWn078DUaFjPCbo0nunIBh3cMBs_FI5UUhJsBzzuJFoR6CXe2JjTvpeNDtIhQKBgDJjJsjKr1YMCCaY-2nuPJ6GDtB68Po2qSMmxjrFcTblQ76dPII3jUemgIzjY2G5VluD-He-IBZ_HjFH-KEo17T7v-D53vCnLXCyPiCIOc5aeMKpHD_GrqqRdqpgEs2KGS1zaQ6gUIWLLfOeDrbeaubT3h4Hu-lBb6bIox5EPjX5AoGAXE04NdJ-dMKp8SNAhHpBtx4fx6TF0OYEcSQFz9_jnj8NGL-qZ0gscDfYiuOzHvWAc76k6wnqzAgN9bB6LH1-LGZb0QyN60yTg4U4rpRrWz_cCdjSRE9ERQJEu7lwwWdf9WFXQIfl_9lqgswNIsfK4Vk2ystqSB2heIaxE3ySk4kCgYEA5g75I3C0UDCLqpft_VJKlmMGm7LaitXznt2ywsaCOPmPpuuz-mGsWeR2FSXol6lLKxarxrCI2llKi8PaarRyoHLnVBkwGxRtJptuyLvrJncpeQwRmY9gxnx3J73y_EXymJxAx1jigkZH0F1T5UA-xJ8wdbGd5y_UE1MEKbCKvHg";
public static final String PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxI1v0SwjzwngD1s0FiAMDBjbx39aWrdu6B-gmQwhuZy8Mcg7FIMXRfPSAdv6y1EVU5JKwebav3XAZOVotqZrtsjJ_A6ZNl2LJtCycCXt4INqqkV0JvAxm3_ZL7R1KgS3v9uDzBy_PGGryXa3EuhzZcMLYdmCDZlYq6KjGYKluG0J5leLeV-ATtXZd4EwecvKUV3dc6CrCzYI827lQYIngNPnvfXjLHYyWnWRT8xE0FvgTvUOim28eHyIzpKsYkvCs7Ig0r39ylxvZX76M-u77jXs_0ARWrgPzCbFD_24By1xVffl83IwhNn5A2ymzRzwD9tKNSDNUtxuN5hs0cAG-QIDAQAB";
public static final String PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzkBDke9zFXCi-qTETqKHeoKavjRiYEgv6tO2Y-ChGvNYy_Mrfcd9r5_e_s6Bo2qv-UdtqzwTPqLtXM3pL64LNflw7p8kcF2-ssw_N2fE_AMpKlj2NbdGJwF4XJPrjVsniTyLDQUFk9_BzssMR1AdtTJcvBtXRBeLkVLNnwfvl2e_LcNUD5ftQx8CLYR3pZxU5UgkHMRVxCPrxhT6Urbx2d3jTNbU3ovCJDbE4prJdxBoLWt-eaRL-j6UjZxqb_01c6t1LaOag-KdlQr9ji_em1Dd4i5Ujkjs-2sYvxx0wWrtiRMz2dOZM7ZTDpMAIHaMd3x2yPaGsj2CDJ7Kv9bVSwIDAQAB";
public static void main(String[] args) throws Exception {
Map<String, String> keys = createKeys(2048);
System.out.println("privateKey:" + keys.get("privateKey"));
System.out.println("publicKey:" + keys.get("publicKey"));
System.out.println("privateKey:" + PRIVATE_KEY);
System.out.println("publicKey:" + PUBLIC_KEY);
RSAPublicKey publicKey = getPublicKey(PUBLIC_KEY);
System.out.println("------------");
String encrypt = publicEncrypt("{\"page\":1,\"limit\":10,\"data\":{}}", publicKey, "UTF-8");
System.out.println(encrypt);
RSAPrivateKey privateKey = getPrivateKey(PRIVATE_KEY);
String decrypt = privateDecrypt(encrypt, privateKey, "UTF-8");
System.out.println("------------");
System.out.println(decrypt);
......
......@@ -17,14 +17,14 @@ import java.util.Properties;
/**
* @author Robert Hafner
*/
@Component
/*@Component
@Intercepts({
@Signature(type = Executor.class, method = "query",
args = { MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class }),
@Signature(type = Executor.class, method = "query",
args = { MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class }),
@Signature(type= Executor.class, method = "update", args = { MappedStatement.class, Object.class})
})
})*/
public class LogSqlExecutionTimePlugin implements Interceptor {
private static final Logger LOGGER = LoggerFactory.getLogger(LogSqlExecutionTimePlugin.class);
......
......@@ -28,6 +28,10 @@ public class DataScopeHandler {
if (where == null) {
where = new HexValue(" 1 = 1 ");
}
if ("com.makeit.mapper.platform.auth.PlatUserMapper.listAll".equals(whereSegment)) {
ItemsList delFlag = new ExpressionList(Stream.of("0").map(LongValue::new).collect(Collectors.toList()));
return new AndExpression(where, new InExpression(new Column("del_flag"), delFlag));
}
Table fromItem = (Table) plainSelect.getFromItem();
// 有别名用别名,无别名用表名,防止字段冲突报错
Alias fromItemAlias = fromItem.getAlias();
......
......@@ -106,6 +106,7 @@ public enum CodeMessageEnum {
PLATFORM_ERROR_SPACE_NAME_DUPLICATE(500, "PLATFORM.ERROR.SPACE.NAME.DUPLICATE"),
PLATFORM_ERROR_SPACE_NOT_DEL(500, "PLATFORM.ERROR.SPACE.NOT.DEL"),
PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT(500, "PLATFORM.ERROR.SPACE.NOT.AUTH.PARENT"),
PLATFORM_ERROR_SPACE_OVER_LEVEL(500, "PLATFORM.ERROR.SPACE.OVER.LEVEL"),
PLATFORM_ERROR_SPACE_USER_NOT_ADD(500, "PLATFORM.ERROR.SPACE.USER.NOT.ADD"),
PLATFORM_ERROR_SPACE_ROOM_NOT_ADD(500, "PLATFORM.ERROR.SPACE.ROOM.NOT.ADD"),
PLATFORM_ERROR_ROOM_EXIT_BAD(500, "PLATFORM.ERROR.ROOM.EXIT.BED"),
......
......@@ -96,6 +96,7 @@ public class RedisConst {
public static final String ALARM_DEVICE_HR_ID = "alarm:device:hr:id:";
public static final String ALARM_DEVICE_FALL_ID = "alarm:device:fall:id:";
public static final String ALARM_DEVICE_BEHAVIOR_ID = "alarm:device:behavior:id:";
public static final String ALARM_DEVICE_OFF_BED_ID = "alarm:device:off_bed:id:";
public static final String ALARM_CONFIG_ORG_ID = "alarm:config:org:id:";
public static final String PLAT_IOT_DEVICE_PREFIX = "plat:iot:device:";
......
......@@ -10,8 +10,8 @@ import org.springframework.stereotype.Component;
import java.util.Arrays;
@Aspect
@Component
//@Aspect
//@Component
public class ControllerLogAspect {
private static final Logger logger = LoggerFactory.getLogger(ControllerLogAspect.class);
......
......@@ -56,9 +56,7 @@ public class JavaProxyUtil {
// logger.info(content, t.getClass() + "." + method.getName(), parseParams(args), (System.currentTimeMillis() - start));
// }
return CostTimeUtil.executeException(() -> method.invoke(t, args), c -> {
logger.info(content, t.getClass() + "." + method.getName(), parseParams(args), c);
});
return CostTimeUtil.executeException(() -> method.invoke(t, args), c -> {});
};
......
......@@ -18,7 +18,7 @@ public class RedisConnectionFactoryWrapper implements RedisConnectionFactory {
@Override
public RedisConnection getConnection() {
return JavaProxyUtil.getProxyLog("RedisTemplate 执行:{},参数:{},耗时:{} ms", rcf.getConnection(),EXCLUDE_METHOD_LIST);
return JavaProxyUtil.getProxyLog("", rcf.getConnection(),EXCLUDE_METHOD_LIST);
}
@Override
......
......@@ -12,8 +12,8 @@ import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
@Aspect
@Component
//@Aspect
//@Component
public class RedissonLogAspect {
private static final Logger logger = LoggerFactory.getLogger(RedissonLogAspect.class);
......
......@@ -10,8 +10,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Aspect
@Component
//@Aspect
//@Component
public class ServiceLogAspect {
private static final Logger logger = LoggerFactory.getLogger(ServiceLogAspect.class);
......
......@@ -233,6 +233,7 @@ public class IotProductDeviceService extends IotCommonService {
DeviceInfoContentBreathe.Properties tempProperties;
for (Map.Entry<String, List<DeviceInfoContentBreathe>> entry : minuteMap.entrySet()) {
deviceInfoContentBreathes = entry.getValue();
int reportCount = deviceInfoContentBreathes.size();
DeviceInfoContentBreathe.Properties breatheProperties;
Integer bodymove = 0;
int br = 0;
......@@ -246,15 +247,27 @@ public class IotProductDeviceService extends IotCommonService {
noPersonCount++;
continue;
}
// 0和255直接跳过
if (breatheProperties.getHr() == 255 || breatheProperties.getHr() == 0 ) {
noPersonCount++;
continue;
}
if (breatheProperties.getBr() == 255 || breatheProperties.getBr() == 0) {
noPersonCount++;
continue;
}
hr += breatheProperties.getHr();
br += breatheProperties.getBr();
bodymove += breatheProperties.getBodymove();
}
temp = new DeviceInfoContentBreathe();
tempProperties = new DeviceInfoContentBreathe.Properties();
tempProperties.setHr(noPersonCount == 60 ? 0 : hr / (60 - noPersonCount));
tempProperties.setBr(noPersonCount == 60 ? 0 : br / (60 - noPersonCount));
tempProperties.setBodymove(noPersonCount == 60 ? 0 : bodymove / (60- noPersonCount));
if (noPersonCount == reportCount) {
continue;
}
tempProperties.setHr(hr / (reportCount - noPersonCount));
tempProperties.setBr(br / (reportCount - noPersonCount));
tempProperties.setBodymove(bodymove / (reportCount- noPersonCount));
temp.setTimestamp(timestamp);
temp.setProperties(tempProperties);
tempList.add(temp);
......
......@@ -14,6 +14,8 @@ public class DeviceInfo {
private Long timestamp;
private String messageId;
private String messageType;
private HeaderInfo headers;
......
......@@ -17,7 +17,7 @@ public class ShengwangHttpUtil {
@Autowired
private ShengwangProperties shengwangProperties;
public String active(String licenseKey) {
public String active(String licenseKey,String pid) {
String plainCredentials = shengwangProperties.getCustomerKey() + ":" + shengwangProperties.getCustomerSecret();
String base64Credentials = new String(Base64.getEncoder().encode(plainCredentials.getBytes()));
// 创建 authorization header
......
......@@ -10,7 +10,7 @@ public class StandardDeviationUtil {
* @param x
* @return 平均值
*/
public static double average(double[] x) {
public static double average(Double[] x) {
int n = x.length; //数列元素个数
double sum = 0;
for (double i : x) { //求和
......@@ -35,7 +35,7 @@ public class StandardDeviationUtil {
* @param x 要计算的数列
* @return 方差
*/
public static double variance(double[] x) {
public static double variance(Double[] x) {
int n = x.length; //数列元素个数
double avg = average(x); //求平均值
double var = 0;
......@@ -62,7 +62,7 @@ public class StandardDeviationUtil {
* @param x 要计算的数列
* @return 标准差
*/
public static double standardDeviation(double[] x) {
public static double standardDeviation(Double[] x) {
return Math.sqrt(variance(x));
}
......
......@@ -65,7 +65,7 @@ public class SmsVoiceSender implements IMsgSender{
paramMap.put("pwd", md32);
paramMap.put("time", time);
paramMap.put("mobile", vo);
//告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常
//告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常 5 离床异常
if (StringUtils.equals(alarmType, "1")) {
paramMap.put("vid", "142");
}
......@@ -78,6 +78,9 @@ public class SmsVoiceSender implements IMsgSender{
if (StringUtils.equals(alarmType, "4")) {
paramMap.put("vid", "145");
}
if (StringUtils.equals(alarmType, "5")) {
paramMap.put("vid", "158");
}
String[] param = msgDTO.getParam();
List<BiConsumer<HashMap<String, String>, String>> consumerList = Arrays.asList(
......
# 业务信息
# 信息类型: info, error, warning, notice
# 格式: business + 信息类型 +\u3000模块\u3000+ 功能 +信息
# 请按模块区分\u3000例如business=error=auth=not=found, business=info=system
# \u4E1A\u52A1\u4FE1\u606F
# \u4FE1\u606F\u7C7B\u578B: info, error, warning, notice
# \u683C\u5F0F: business + \u4FE1\u606F\u7C7B\u578B +\u3000\u6A21\u5757\u3000+ \u529F\u80FD +\u4FE1\u606F
# \u8BF7\u6309\u6A21\u5757\u533A\u5206\u3000\u4F8B\u5982business=error=auth=not=found, business=info=system
# 业务错误
# \u4E1A\u52A1\u9519\u8BEF
TEST1=%ste%sst1
TEST2={0}te{1}st2
SYSTEM.ERROR.PARAMETER.ILLEGAL=参数不合法
SYSTEM.ERROR.PARAMETER.ILLEGAL=\u53C2\u6570\u4E0D\u5408\u6CD5
SYSTEM.ERROR.SIGN.NOT.BLANK=签名不能为空
SYSTEM.ERROR.SIGN.ERROR=签名错误
SYSTEM.ERROR.SIGN.NOT.BLANK=\u7B7E\u540D\u4E0D\u80FD\u4E3A\u7A7A
SYSTEM.ERROR.SIGN.ERROR=\u7B7E\u540D\u9519\u8BEF
SYSTEM.ERROR.PHONE.DUPLICATE=该手机号已存在
SYSTEM.ERROR.PHONE.DUPLICATE=\u8BE5\u624B\u673A\u53F7\u5DF2\u5B58\u5728
SYSTEM.ERROR.NAME.DUPLICATE=该名称已存在
SYSTEM.ERROR.NAME.ENG.DUPLICATE=该英文名称已存在
SYSTEM.ERROR.NAME.DUPLICATE=\u8BE5\u540D\u79F0\u5DF2\u5B58\u5728
SYSTEM.ERROR.NAME.ENG.DUPLICATE=\u8BE5\u82F1\u6587\u540D\u79F0\u5DF2\u5B58\u5728
SYSTEM.ERROR.CODE.DUPLICATE=该编码已存在
SYSTEM.ERROR.TENANT.CODE.DUPLICATE=该标识已存在
SYSTEM.ERROR.DICT.VALUE.DUPLICATE=该字典值已存在
SYSTEM.ERROR.DICT.NOT.EXIST=该字典值不存在
SYSTEM.ERROR.CODE.DUPLICATE=\u8BE5\u7F16\u7801\u5DF2\u5B58\u5728
SYSTEM.ERROR.TENANT.CODE.DUPLICATE=\u8BE5\u6807\u8BC6\u5DF2\u5B58\u5728
SYSTEM.ERROR.DICT.VALUE.DUPLICATE=\u8BE5\u5B57\u5178\u503C\u5DF2\u5B58\u5728
SYSTEM.ERROR.DICT.NOT.EXIST=\u8BE5\u5B57\u5178\u503C\u4E0D\u5B58\u5728
SYSTEM.ERROR.USER.JOB.NO.DUPLICATE=该登录名已存在
SYSTEM.ERROR.USER.ACCOUNT.DUPLICATE=该账号已存在
SYSTEM.ERROR.USER.NAME.DUPLICATE=该姓名已存在
SYSTEM.ERROR.USER.MOBILE.DUPLICATE=该手机号已存在
SYSTEM.ERROR.USER.MAIL.DUPLICATE=该邮箱已存在
SYSTEM.ERROR.USER.JOB.NO.DUPLICATE=\u8BE5\u767B\u5F55\u540D\u5DF2\u5B58\u5728
SYSTEM.ERROR.USER.ACCOUNT.DUPLICATE=\u8BE5\u8D26\u53F7\u5DF2\u5B58\u5728
SYSTEM.ERROR.USER.NAME.DUPLICATE=\u8BE5\u59D3\u540D\u5DF2\u5B58\u5728
SYSTEM.ERROR.USER.MOBILE.DUPLICATE=\u8BE5\u624B\u673A\u53F7\u5DF2\u5B58\u5728
SYSTEM.ERROR.USER.MAIL.DUPLICATE=\u8BE5\u90AE\u7BB1\u5DF2\u5B58\u5728
SYSTEM.ERROR.CODE.RATE.LIMIT=验证码发送过于频繁,请稍后在发送
SYSTEM.ERROR.CODE.RATE.LIMIT=\u9A8C\u8BC1\u7801\u53D1\u9001\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u5728\u53D1\u9001
SYSTEM.ERROR.USER.PASSWORD.NOT.BLANK=密码不能为空
#SYSTEM.ERROR.USER.PASSWORD.FORMAT.ERROR=密码必须是包含大写字母、小写字母、数字、特殊符号(不含空格)的6~18位组合
SYSTEM.ERROR.USER.PASSWORD.FORMAT.ERROR=含字母和数字的6-20位密码
SYSTEM.ERROR.USER.PASSWORD.SAME=支付密码不能与登录密码一致
SYSTEM.ERROR.USER.PASSWORD.NOT.BLANK=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
#SYSTEM.ERROR.USER.PASSWORD.FORMAT.ERROR=\u5BC6\u7801\u5FC5\u987B\u662F\u5305\u542B\u5927\u5199\u5B57\u6BCD\u3001\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u7279\u6B8A\u7B26\u53F7(\u4E0D\u542B\u7A7A\u683C)\u76846~18\u4F4D\u7EC4\u5408
SYSTEM.ERROR.USER.PASSWORD.FORMAT.ERROR=\u542B\u5B57\u6BCD\u548C\u6570\u5B57\u76846-20\u4F4D\u5BC6\u7801
SYSTEM.ERROR.USER.PASSWORD.SAME=\u652F\u4ED8\u5BC6\u7801\u4E0D\u80FD\u4E0E\u767B\u5F55\u5BC6\u7801\u4E00\u81F4
SYSTEM.ERROR.USER.SUPER.ADMIN.CANT.DO=超级管理员或超级管理员角色不支持该操作
SYSTEM.ERROR.USER.SUPER.ADMIN.CANT.EDIT=不能修改超级管理员或者超级管理员角色
SYSTEM.ERROR.USER.SUPER.ADMIN.CANT.DO=\u8D85\u7EA7\u7BA1\u7406\u5458\u6216\u8D85\u7EA7\u7BA1\u7406\u5458\u89D2\u8272\u4E0D\u652F\u6301\u8BE5\u64CD\u4F5C
SYSTEM.ERROR.USER.SUPER.ADMIN.CANT.EDIT=\u4E0D\u80FD\u4FEE\u6539\u8D85\u7EA7\u7BA1\u7406\u5458\u6216\u8005\u8D85\u7EA7\u7BA1\u7406\u5458\u89D2\u8272
SYSTEM.ERROR.ROLE.CANT.DELETE=存在员工绑定该角色,则不可删除
SYSTEM.ERROR.ROLE.CANT.DELETE=\u5B58\u5728\u5458\u5DE5\u7ED1\u5B9A\u8BE5\u89D2\u8272\uFF0C\u5219\u4E0D\u53EF\u5220\u9664
SYSTEM.ERROR.START.END.TIME.NOT.NULL=开始时间和结束时间不能为空
SYSTEM.ERROR.START.LE.END=开始时间要小于等于结束时间
SYSTEM.ERROR.START.END.TIME.NOT.NULL=\u5F00\u59CB\u65F6\u95F4\u548C\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u4E3A\u7A7A
SYSTEM.ERROR.START.LE.END=\u5F00\u59CB\u65F6\u95F4\u8981\u5C0F\u4E8E\u7B49\u4E8E\u7ED3\u675F\u65F6\u95F4
SYSTEM.ERROR.CANT.CHANGE.TENANT.STATUS=当前时间要在开始时间和结束时间之间才能设置为启用
SYSTEM.ERROR.CANT.CHANGE.TENANT.STATUS=\u5F53\u524D\u65F6\u95F4\u8981\u5728\u5F00\u59CB\u65F6\u95F4\u548C\u7ED3\u675F\u65F6\u95F4\u4E4B\u95F4\u624D\u80FD\u8BBE\u7F6E\u4E3A\u542F\u7528
SYSTEM.ERROR.CANT.REMOVE.TENANT.USER.LINK=已经关联了租户的管理员账号不允许删除
SYSTEM.ERROR.CANT.REMOVE.TENANT.USER.LINK=\u5DF2\u7ECF\u5173\u8054\u4E86\u79DF\u6237\u7684\u7BA1\u7406\u5458\u8D26\u53F7\u4E0D\u5141\u8BB8\u5220\u9664
SYSTEM.ERROR.TMP.CODE.BLANK=验证码不能为空
#SYSTEM.ERROR.TMP.TOKEN.BLANK=token不能为空
SYSTEM.ERROR.TMP.TOKEN.BLANK=验证码不匹配
SYSTEM.ERROR.TMP.CODE.BLANK=\u9A8C\u8BC1\u7801\u4E0D\u80FD\u4E3A\u7A7A
#SYSTEM.ERROR.TMP.TOKEN.BLANK=token\u4E0D\u80FD\u4E3A\u7A7A
SYSTEM.ERROR.TMP.TOKEN.BLANK=\u9A8C\u8BC1\u7801\u4E0D\u5339\u914D
SYSTEM.ERROR.TOKEN.BLANK.OR.NOT.EXIST=token失效或不存在
SYSTEM.ERROR.NO.PERMISSION=无权限访问
SYSTEM.ERROR.TOKEN.BLANK.OR.NOT.EXIST=token\u5931\u6548\u6216\u4E0D\u5B58\u5728
SYSTEM.ERROR.NO.PERMISSION=\u65E0\u6743\u9650\u8BBF\u95EE
SYSTEM.ERROR.TENANT.ID.NOT.BLANK=租户id不能为空
SYSTEM.ERROR.TENANT.NOT.EXIST=该租户不存在或者被禁用
SYSTEM.ERROR.TENANT.ID.NOT.BLANK=\u79DF\u6237id\u4E0D\u80FD\u4E3A\u7A7A
SYSTEM.ERROR.TENANT.NOT.EXIST=\u8BE5\u79DF\u6237\u4E0D\u5B58\u5728\u6216\u8005\u88AB\u7981\u7528
SYSTEM.ERROR.DUPLICATE.REQUEST=请勿重复请求
SYSTEM.ERROR.DUPLICATE.REQUEST=\u8BF7\u52FF\u91CD\u590D\u8BF7\u6C42
#SYSTEM.ERROR.AUTH.USER.HAS.DISABLED=该用户已经离职/冻结
SYSTEM.ERROR.AUTH.USER.HAS.DISABLED=用户不存在
SYSTEM.ERROR.AUTH.USER.ACCOUNT.PASSWORD=账号或者密码错误!
SYSTEM.ERROR.AUTH.USER.PASSWORD=密码错误
SYSTEM.ERROR.AUTH.USER.OLD.PASSWORD=旧密码错误
SYSTEM.ERROR.AUTH.USER.PAY.PASSWORD.BLANK=支付密码未设置
SYSTEM.ERROR.AUTH.USER.MAIL.NOT.SET=邮箱未设置
SYSTEM.ERROR.AUTH.USER.PASSWORD.NOT.EQUALS=新密码与确认密码不一致
#SYSTEM.ERROR.AUTH.USER.HAS.DISABLED=\u8BE5\u7528\u6237\u5DF2\u7ECF\u79BB\u804C/\u51BB\u7ED3
SYSTEM.ERROR.AUTH.USER.HAS.DISABLED=\u7528\u6237\u4E0D\u5B58\u5728
SYSTEM.ERROR.AUTH.USER.ACCOUNT.PASSWORD=\u8D26\u53F7\u6216\u8005\u5BC6\u7801\u9519\u8BEF!
SYSTEM.ERROR.AUTH.USER.PASSWORD=\u5BC6\u7801\u9519\u8BEF
SYSTEM.ERROR.AUTH.USER.OLD.PASSWORD=\u65E7\u5BC6\u7801\u9519\u8BEF
SYSTEM.ERROR.AUTH.USER.PAY.PASSWORD.BLANK=\u652F\u4ED8\u5BC6\u7801\u672A\u8BBE\u7F6E
SYSTEM.ERROR.AUTH.USER.MAIL.NOT.SET=\u90AE\u7BB1\u672A\u8BBE\u7F6E
SYSTEM.ERROR.AUTH.USER.PASSWORD.NOT.EQUALS=\u65B0\u5BC6\u7801\u4E0E\u786E\u8BA4\u5BC6\u7801\u4E0D\u4E00\u81F4
SYSTEM.ERROR.WECHAT.USER.NOT.EXIST=该企微账号对应的用户不存在
SYSTEM.ERROR.WECHAT.USER.NOT.EXIST=\u8BE5\u4F01\u5FAE\u8D26\u53F7\u5BF9\u5E94\u7684\u7528\u6237\u4E0D\u5B58\u5728
SYSTEM.ERROR.WECHAT.OPENID.NOT.EXIST=openid获取失败,请重试
SYSTEM.ERROR.WECHAT.OPENID.NOT.EXIST=openid\u83B7\u53D6\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5
SYSTEM.ERROR.EXCEL.UPLOAD.EXIT=请上传excel
SYSTEM.ERROR.EXCEL.NOT.DATA=请至少上传一条数据
SYSTEM.ERROR.EXCEL.MAX.LIMIT=最大上传%s条数据
SYSTEM.ERROR.NO.EXCEL.FILE=请导入excel文件
SYSTEM.ERROR.EXCEL.UPLOAD.EXIT=\u8BF7\u4E0A\u4F20excel
SYSTEM.ERROR.EXCEL.NOT.DATA=\u8BF7\u81F3\u5C11\u4E0A\u4F20\u4E00\u6761\u6570\u636E
SYSTEM.ERROR.EXCEL.MAX.LIMIT=\u6700\u5927\u4E0A\u4F20%s\u6761\u6570\u636E
SYSTEM.ERROR.NO.EXCEL.FILE=\u8BF7\u5BFC\u5165excel\u6587\u4EF6
SYSTEM.ERROR.CONFIG.NOT.EXIST=相关配置(数据字典不存在)
SYSTEM.ERROR.CONFIG.NOT.EXIST=\u76F8\u5173\u914D\u7F6E(\u6570\u636E\u5B57\u5178\u4E0D\u5B58\u5728)
SYSTEM.ERROR.COMPANY.LEVEL.EXCEED=公司最多两级,集团——子公司
SYSTEM.ERROR.COMPANY.NOT.EXIST=公司不存在或者被禁用
SYSTEM.ERROR.DEPT.NAME.DUPLICATE=同一个公司下的部门不可重名
SYSTEM.ERROR.DEPT.LEVEL.EXCEED=同一个公司下的部门最多5级
SYSTEM.ERROR.DEPT.DELETE=当前部门有员工或当前部门有下级部门,不可删除
SYSTEM.ERROR.COMPANY.GROUP.CANT.EDIT=不能修改或删除集团
SYSTEM.ERROR.COMPANY.LEVEL.EXCEED=\u516C\u53F8\u6700\u591A\u4E24\u7EA7\uFF0C\u96C6\u56E2\u2014\u2014\u5B50\u516C\u53F8
SYSTEM.ERROR.COMPANY.NOT.EXIST=\u516C\u53F8\u4E0D\u5B58\u5728\u6216\u8005\u88AB\u7981\u7528
SYSTEM.ERROR.DEPT.NAME.DUPLICATE=\u540C\u4E00\u4E2A\u516C\u53F8\u4E0B\u7684\u90E8\u95E8\u4E0D\u53EF\u91CD\u540D
SYSTEM.ERROR.DEPT.LEVEL.EXCEED=\u540C\u4E00\u4E2A\u516C\u53F8\u4E0B\u7684\u90E8\u95E8\u6700\u591A5\u7EA7
SYSTEM.ERROR.DEPT.DELETE=\u5F53\u524D\u90E8\u95E8\u6709\u5458\u5DE5\u6216\u5F53\u524D\u90E8\u95E8\u6709\u4E0B\u7EA7\u90E8\u95E8,\u4E0D\u53EF\u5220\u9664
SYSTEM.ERROR.COMPANY.GROUP.CANT.EDIT=\u4E0D\u80FD\u4FEE\u6539\u6216\u5220\u9664\u96C6\u56E2
SYSTEM.ERROR.SMS.SEND=短信发送错误,错误信息%s
SYSTEM.ERROR.SMS.CODE.NOT.EXIST=验证码已过期
SYSTEM.ERROR.SMS.CODE.NOT.CORRECT=验证码不正确
SYSTEM.ERROR.SMS.SEND=\u77ED\u4FE1\u53D1\u9001\u9519\u8BEF\uFF0C\u9519\u8BEF\u4FE1\u606F%s
SYSTEM.ERROR.SMS.CODE.NOT.EXIST=\u9A8C\u8BC1\u7801\u5DF2\u8FC7\u671F
SYSTEM.ERROR.SMS.CODE.NOT.CORRECT=\u9A8C\u8BC1\u7801\u4E0D\u6B63\u786E
PLATFORM.ERROR.ELDER.CERTIFICATENUMBER.DUPLICATE=证件号不能重复
PLATFORM.ERROR.ELDER.CERTIFICATENUMBER.DUPLICATE=\u8BC1\u4EF6\u53F7\u4E0D\u80FD\u91CD\u590D
PLATFORM.ERROR.CHILDREN.ELDER.ID.BIND.DUPLICATE=不能重复绑定该老人
PLATFORM.ERROR.CHILDREN.ELDER.ID.BIND.DUPLICATE=\u4E0D\u80FD\u91CD\u590D\u7ED1\u5B9A\u8BE5\u8001\u4EBA
PLATFORM.ERROR.SPACE.NAME.DUPLICATE=同一层级,空间名称不能重复
PLATFORM.ERROR.SPACE.NOT.DEL=该空间下存在下级或者房间,不可删除
PLATFORM.ERROR.SPACE.NOT.AUTH.PARENT=上级空间不能是自己的下级空间
PLATFORM.ERROR.SPACE.USER.NOT.ADD=当前用户没有所属组织,请先分配组织
PLATFORM.ERROR.SPACE.ROOM.NOT.ADD=该空间下已创建房间,不可当做上级空间
PLATFORM.ERROR.ROOM.EXIT.BED=房间中存在已入住的床位,不可删除
PLATFORM.ERROR.ROOM.NAME.EXIT=该房间名称已存在
PLATFORM.ERROR.ROOM.BED.NUMBER.NOT.AUTH=床位数量不能改小
PLATFORM.ERROR.BED.NAME.EXIT=床位名称已存在
PLATFORM.ERROR.BED.NOT.DEL=床位已绑定长者或设备,不可删除
PLATFORM.ERROR.BED.NOT.BIND.ELDER=床位已入住长者,不可再次入住
PLATFORM.ERROR.SPACE.NAME.DUPLICATE=\u540C\u4E00\u5C42\u7EA7,\u7A7A\u95F4\u540D\u79F0\u4E0D\u80FD\u91CD\u590D
PLATFORM.ERROR.SPACE.NOT.DEL=\u8BE5\u7A7A\u95F4\u4E0B\u5B58\u5728\u4E0B\u7EA7\u6216\u8005\u623F\u95F4\uFF0C\u4E0D\u53EF\u5220\u9664
PLATFORM.ERROR.SPACE.NOT.AUTH.PARENT=\u4E0A\u7EA7\u7A7A\u95F4\u4E0D\u80FD\u662F\u81EA\u5DF1\u7684\u4E0B\u7EA7\u7A7A\u95F4
PLATFORM.ERROR.SPACE.OVER.LEVEL=\u5C42\u7EA7\u8D85\u51FA\uFF0C\u4E0D\u53EF\u7F16\u8F91
PLATFORM.ERROR.SPACE.USER.NOT.ADD=\u5F53\u524D\u7528\u6237\u6CA1\u6709\u6240\u5C5E\u7EC4\u7EC7\uFF0C\u8BF7\u5148\u5206\u914D\u7EC4\u7EC7
PLATFORM.ERROR.SPACE.ROOM.NOT.ADD=\u8BE5\u7A7A\u95F4\u4E0B\u5DF2\u521B\u5EFA\u623F\u95F4\uFF0C\u4E0D\u53EF\u5F53\u505A\u4E0A\u7EA7\u7A7A\u95F4
PLATFORM.ERROR.ROOM.EXIT.BED=\u623F\u95F4\u4E2D\u5B58\u5728\u5DF2\u5165\u4F4F\u7684\u5E8A\u4F4D\uFF0C\u4E0D\u53EF\u5220\u9664
PLATFORM.ERROR.ROOM.NAME.EXIT=\u8BE5\u623F\u95F4\u540D\u79F0\u5DF2\u5B58\u5728
PLATFORM.ERROR.ROOM.BED.NUMBER.NOT.AUTH=\u5E8A\u4F4D\u6570\u91CF\u4E0D\u80FD\u6539\u5C0F
PLATFORM.ERROR.BED.NAME.EXIT=\u5E8A\u4F4D\u540D\u79F0\u5DF2\u5B58\u5728
PLATFORM.ERROR.BED.NOT.DEL=\u5E8A\u4F4D\u5DF2\u7ED1\u5B9A\u957F\u8005\u6216\u8BBE\u5907\uFF0C\u4E0D\u53EF\u5220\u9664
PLATFORM.ERROR.BED.NOT.BIND.ELDER=\u5E8A\u4F4D\u5DF2\u5165\u4F4F\u957F\u8005\uFF0C\u4E0D\u53EF\u518D\u6B21\u5165\u4F4F
PLATFORM.ERROR.ROOM.OTHER.USED.NOT.DEL=该房间下有床位有其他长者入住
PLATFORM.ERROR.BED.BIND.DEVICE.NOT.AUTH=该床位已绑定设备,请重新选择床位
PLATFORM.ERROR.ROOM.OTHER.USED.NOT.DEL=\u8BE5\u623F\u95F4\u4E0B\u6709\u5E8A\u4F4D\u6709\u5176\u4ED6\u957F\u8005\u5165\u4F4F
PLATFORM.ERROR.BED.BIND.DEVICE.NOT.AUTH=\u8BE5\u5E8A\u4F4D\u5DF2\u7ED1\u5B9A\u8BBE\u5907\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u5E8A\u4F4D
PLATFORM.ERROR.ELDER.BED.CANT.DEL=含入住床位的老人,不可删除
PLATFORM.ERROR.ELDER.BED.CANT.DEL=\u542B\u5165\u4F4F\u5E8A\u4F4D\u7684\u8001\u4EBA\uFF0C\u4E0D\u53EF\u5220\u9664
SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD=不能在该节点下新增非管理员角色
SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT=管理员角色不能修改
SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD=\u4E0D\u80FD\u5728\u8BE5\u8282\u70B9\u4E0B\u65B0\u589E\u975E\u7BA1\u7406\u5458\u89D2\u8272
SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT=\u7BA1\u7406\u5458\u89D2\u8272\u4E0D\u80FD\u4FEE\u6539
PLATFORM.ERROR.ALARM.NOT.FOUND.SPACE=设备未绑定空间
PLATFORM.ERROR.ALARM.NOT.FOUND.ELDER=设备空间下无长者
PLATFORM.ERROR.ALARM.NOT.FOUND.SPACE=\u8BBE\u5907\u672A\u7ED1\u5B9A\u7A7A\u95F4
PLATFORM.ERROR.ALARM.NOT.FOUND.ELDER=\u8BBE\u5907\u7A7A\u95F4\u4E0B\u65E0\u957F\u8005
SYSTEM.ERROR.TENANT.FORBIDDEN=该租户被禁用
SYSTEM.ERROR.ORG.FORBIDDEN=该组织被禁用
SYSTEM.ERROR.TENANT.FORBIDDEN=\u8BE5\u79DF\u6237\u88AB\u7981\u7528
SYSTEM.ERROR.ORG.FORBIDDEN=\u8BE5\u7EC4\u7EC7\u88AB\u7981\u7528
SYSTEM.ERROR.MENU.CODE.DUPLICATE=跳转页面已存在
SYSTEM.ERROR.MENU.CODE.DUPLICATE=\u8DF3\u8F6C\u9875\u9762\u5DF2\u5B58\u5728
......@@ -106,7 +106,7 @@ public class CodeGenerator {
// 使用重点 下列字段填写表名 运行方法
// strategy.setInclude("edu_teacher","..."); // 多表-逆向工程
strategy.setInclude("plat_device_log");
strategy.setInclude("saas_pid_manage");
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
strategy.setTablePrefix(pc.getModuleName() + "_"); //生成实体属性时去掉表"_"前缀并且第一个字母大写 如:gmt_create -> gmtCreate
......
......@@ -97,5 +97,15 @@ public class PlatAlarmConfigController {
}
@ApiOperation("初始化数据")
@PostMapping("/data/init")
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity<PlatAlarmConfig> initConfig() {
platAlarmConfigService.initData();
return ApiResponseUtils.success();
}
}
package com.makeit.module.controller.children.alarm;
import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Maps;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
......@@ -8,6 +10,7 @@ import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.enums.report.PlatformTypeEnum;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
......@@ -19,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Api(tags = "子女端小程序-告警记录")
@RestController
@RequestMapping("/children/alarm-record")
......@@ -30,9 +35,14 @@ public class PlatAlarmRecordChildrenController {
@ApiOperation("列表")
@PostMapping("page")
@TenantIdIgnore
public ApiResponseEntity<PageVO<PlatAlarmRecordVO>> page(@RequestBody PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
public ApiResponseEntity<Map<String, Object>> page(@RequestBody PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
//只能看到发给关联的长者告警
return ApiResponseUtils.success(platAlarmRecordService.childrenPage(dto));
PageVO<PlatAlarmRecordVO> result = platAlarmRecordService.childrenPage(dto);
Map<String, Object> resMap = Maps.newHashMap();
boolean b = CollUtil.isNotEmpty(result.getList()) && result.getList().get(0).getIsUnWechatRead();
resMap.put("wechatReadFlag", b);
resMap.put("page", result);
return ApiResponseUtils.success(resMap);
}
@ApiOperation("查看")
@PostMapping("view")
......@@ -45,7 +55,7 @@ public class PlatAlarmRecordChildrenController {
@PostMapping("read")
@TenantIdIgnore
public ApiResponseEntity<Void> read(@RequestBody BaseIdDTO dto) {
platAlarmRecordService.read(dto.getId(), PlatformTypeEnum.PC);
platAlarmRecordService.read(dto.getId(), PlatformTypeEnum.WECHAT);
return ApiResponseUtils.success();
}
......
package com.makeit.module.controller.wechat.alarm;
import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Maps;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO;
......@@ -8,14 +9,13 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.report.PlatformTypeEnum;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.utils.user.common.CommonUserUtil;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -34,6 +34,7 @@ public class PlatAlarmRecordWechatController {
@ApiOperation("列表")
@PostMapping("page")
@AuthIgnore
public ApiResponseEntity<Map<String,Object>> page(@RequestBody PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
//小程序告警记录只看到发给自己的告警
String userId = CommonUserUtil.getUserId();
......@@ -42,7 +43,8 @@ public class PlatAlarmRecordWechatController {
Map<String,Object> resMap = Maps.newHashMap();
PageVO<PlatAlarmRecordVO> page = platAlarmRecordService.page(dto);
boolean b = page.getList().stream().anyMatch(platAlarmRecord -> StringUtils.equals(CommonEnum.NO.getValue(), platAlarmRecord.getStatus()));
// boolean b = page.getList().stream().anyMatch(platAlarmRecord -> StringUtils.equals(CommonEnum.NO.getValue(), platAlarmRecord.getStatus()));
boolean b = CollUtil.isNotEmpty(page.getList()) && page.getList().get(0).getStatusFlag();
resMap.put("todoFlag",b);
resMap.put("page",page);
return ApiResponseUtils.success(resMap);
......@@ -62,7 +64,7 @@ public class PlatAlarmRecordWechatController {
@ApiOperation("已读")
@PostMapping("read")
public ApiResponseEntity<Void> read(@RequestBody BaseIdDTO dto) {
platAlarmRecordService.read(dto.getId(), PlatformTypeEnum.WECHAT);
platAlarmRecordService.read(dto.getId(), PlatformTypeEnum.PC);
return ApiResponseUtils.success();
}
@ApiOperation("通知家属")
......
......@@ -25,7 +25,7 @@ public class PlatAlarmConfigDTOVO extends BaseTenantDTO {
@NotBlank(message = "告警类型不能为空")
@DictEnum(em = PlatAlarmConfigEnum.AlarmTypeEnum.class, message = "告警类型可选值为{m}")
@ApiModelProperty(value = "告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常")
@ApiModelProperty(value = "告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常,5 离床异常")
private String alarmType;
@ApiModelProperty(value = "所属组织机构id")
......@@ -55,6 +55,9 @@ public class PlatAlarmConfigDTOVO extends BaseTenantDTO {
@ApiModelProperty(value = "行为异常")
private PlatAlarmConfigBehaviorDTOVO behavior;
@ApiModelProperty(value = "离床异常")
private PlatAlarmConfigOffBedDTOVO offBed;
@ApiModelProperty(value = "内容")
private String content;
......
......@@ -22,7 +22,7 @@ public class PlatAlarmConfigHeartDTOVO {
private Integer heartRateStart;
@ApiModelProperty("心率正常范围结束")
private Integer heartRateeEnd;
private Integer heartRateEnd;
@ApiModelProperty("异常持续时间")
private Integer duration;
......
package com.makeit.dto.platform.alarm;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalTime;
/**
* <p>
* 离床异常告警配置
* </p>
*
* @author wangzy
* @since 2023-12-05
*/
@Data
@EqualsAndHashCode
@ApiModel(value = "PlatAlarmConfig对象", description = "离床异常告警配置")
public class PlatAlarmConfigOffBedDTOVO {
@ApiModelProperty("离床开始时间")
@DateTimeFormat(pattern = "HH:mm:ss")
@JsonFormat(pattern = "HH:mm:ss",timezone="GMT+8")
private LocalTime offBedStart;
// @ApiModelProperty("离床时间类型 :1-当日,2-次日")
// private String startTimeType;
@ApiModelProperty("离床结束时间")
@DateTimeFormat(pattern = "HH:mm:ss")
@JsonFormat(pattern = "HH:mm:ss",timezone="GMT+8")
private LocalTime offBedEnd;
// @ApiModelProperty("离床时间类型 :1-当日,2-次日")
// private String endTimeType;
@ApiModelProperty("离床持续时间")
private Integer duration;
}
......@@ -72,6 +72,8 @@ public class PlatAlarmRecordQueryDTO extends BaseTenantDTO {
@ApiModelProperty(value = "微信端 0-未读 1-已读")
private String wechatReadFlag;
@ApiModelProperty(value = "是否误报 1 误报 0 没有误报")
private String misinformationFlag;
......
......@@ -65,7 +65,7 @@ public class PlatHealthConfigDTO {
if(heartConfig){
PlatAlarmConfigHeartDTOVO dto = new PlatAlarmConfigHeartDTOVO();
dto.setHeartRateStart(heartRateStart);
dto.setHeartRateeEnd(heartRateEnd);
dto.setHeartRateEnd(heartRateEnd);
dto.setDuration(heartDuration);
return dto;
}
......
......@@ -30,6 +30,7 @@ public class PlatUserImportDTO {
* 导入手机号会作为账号使用,所以导入需要特殊处理,手机号没有判重后,账号要再判断下有没有判重
*/
@ExcelProperty(value = {headDesc,"账户"})
@ExcelIgnore
private String account;
......
......@@ -42,6 +42,10 @@ public class PlatDeviceBaseAttrDTO {
private DeviceAttrRange radarAngle;
@ApiModelProperty(value = "雷达检测延迟时间 单位S ,范围:0-32768")
private Integer radarDelay;
@ApiModelProperty(value = "雷达安装场景 0:客厅;1:卧室;2:卫生间")
private Integer radarSence;
@ApiModelProperty(value = "雷达灵敏度 0:灵敏;1:标准;2:鲁棒")
private Integer radarSPL;
@Data
......
......@@ -39,5 +39,12 @@ public class PlatDeviceDTO {
@ApiModelProperty(value = "设备类型 0-呼吸心率雷达 1-空间人体雷达 2-跌倒检测雷达")
private String category;
@ApiModelProperty(value = "许可证")
private String deviceLicense;
@ApiModelProperty(value = "许可证信息")
private String licenseInfo;
@ApiModelProperty(value = "过期时间")
private Long expireTime;
@ApiModelProperty(value = "激活时间")
private Long activationTime;
}
......@@ -23,7 +23,7 @@ public class PlatAlarmConfig extends BaseBusEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常")
@ApiModelProperty(value = "告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常 5离床异常")
private String alarmType;
@ApiModelProperty(value = "状态 数据字典 1 启用 0 禁用")
......
......@@ -21,7 +21,7 @@ public class PlatAlarmRecord extends BaseBusEntity {
*/
private String alarmId;
@ApiModelProperty(value = "告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常")
@ApiModelProperty(value = "告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常, 5 离床异常")
private String alarmType;
/**
......
......@@ -63,6 +63,10 @@ public class PlatOrg extends BaseBusEntity {
@TableField(exist = false)
private PlatOrg parent;
@ApiModelProperty(value = "级别")
@TableField(exist = false)
private Integer grade;
private String remark;
}
\ No newline at end of file
......@@ -38,6 +38,9 @@ public class PlatDeviceLog extends BaseBusEntity {
private String url;
@ApiModelProperty(value = "文件名称")
private String fileName;
@ApiModelProperty(value = "租户名称")
@TableField(exist = false)
private String tenantName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
......
package com.makeit.entity.platform.elder;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDate;
import com.baomidou.mybatisplus.annotation.TableId;
import com.makeit.common.entity.BaseBusEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDate;
/**
* <p>
* 长者月报
......@@ -57,5 +56,7 @@ public class PlatElderReportMonth extends BaseBusEntity {
@ApiModelProperty(value = "行为异常次数")
private Integer behaviorExceptionCount;
@ApiModelProperty(value = "离床异常次数")
private Integer offBedExceptionCount;
}
package com.makeit.entity.saas;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 声网pid管理
* </p>
*
* @author eugene young
* @since 2023-12-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="SaasPidManage对象", description="声网pid管理")
public class SaasPidManage extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "pid")
private String pid;
@ApiModelProperty(value = "状态 0已用完 1可用")
private String status;
@ApiModelProperty(value = "可用额度")
private Integer availableCredit;
@ApiModelProperty(value = "已用额度")
private Integer usedCredit;
@ApiModelProperty(value = "总额度")
private Integer totalCredit;
}
......@@ -9,7 +9,8 @@ public class PlatAlarmConfigEnum {
FALL("alarm.alarmType.fall"),
BREATHE("alarm.alarmType.breathe"),
HEART("alarm.alarmType.heart"),
BEHAVIOR("alarm.alarmType.behavior");
BEHAVIOR("alarm.alarmType.behavior"),
OFF_BED("alarm.alarmType.offBed");
private String code;
......
......@@ -6,10 +6,11 @@ import com.makeit.utils.sys.SysDictUtil;
public class PlatElderRealtimeReportEnum {
public enum NowStatus implements BaseEnum {
OUT("elder.realtime.now.status.out"),
RUN("elder.realtime.now.status.run"),
REST("elder.realtime.now.status.rest"),
BED("elder.realtime.now.status.bed"),
SLEEP("elder.realtime.now.status.sleep");
RUN("elder.realtime.now.status.noBed.run"),
REST("elder.realtime.now.status.noBen.rest"),
BED("elder.realtime.now.status.bed.rest"),
SLEEP("elder.realtime.now.status.bed.sleep"),
SPORT("elder.realtime.now.status.bed.sport");
private String code;
......
......@@ -10,7 +10,8 @@ public enum PlatAlarmRecordType {
FALL("fall","长者跌倒"),
BEHAVIOR("behavior","行为异常");
BEHAVIOR("behavior","行为异常"),
OFF_BED("off_bed","离床告警");
private final String value;
private final String name;
......
......@@ -12,8 +12,8 @@ import lombok.Getter;
@AllArgsConstructor
public enum PlatformTypeEnum {
PC("1", "pc端"),
WECHAT("2", "微信小程序");
PC("1", "pc端、小程序"),
WECHAT("2", "子女端小程序");
private String code;
private String value;
......
......@@ -20,4 +20,11 @@ public interface PlatUserMapper extends BaseMapper<PlatUser> {
Page<PlatUser> noDeptUserList(Page<PlatUser> page, PlatUserQueryDTO dto);
List<PlatMenu> getMenuListByUserId(String userId);
/**
* DataScopeHandler#getSqlSegment(PlainSelect, String)
* 改查询过滤掉全局org=xxx设置
* @return
*/
List<PlatUser> listAll();
}
package com.makeit.mapper.saas;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.saas.SaasPidManage;
/**
* <p>
* 声网pid管理 Mapper 接口
* </p>
*
* @author eugene young
* @since 2023-12-13
*/
public interface SaasPidManageMapper extends BaseMapper<SaasPidManage> {
}
......@@ -41,4 +41,5 @@ public interface PlatAlarmConfigService extends IService<PlatAlarmConfig> {
List<PlatHealthConfigDTO> getHealthConfigList();
void initData();
}
package com.makeit.service.platform.alarm.alarmStrategy;
import cn.hutool.core.convert.Convert;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.dto.platform.alarm.PlatAlarmConfigBehaviorDTOVO;
......@@ -61,6 +62,7 @@ public class FallAlarm implements IAlarm {
*/
@Override
public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) {
log.info("跌倒预警config开始");
JSONObject properties = platAlarmCheckDTO.getProperties();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getId();
......@@ -68,7 +70,7 @@ public class FallAlarm implements IAlarm {
properties = new JSONObject();
}
String personState = Convert.toStr(properties.get("personState"));
log.info("跌倒预警personState:{}", personState);
//记录停留时长
recordDuration(platAlarmCheckDTO);
......@@ -182,8 +184,10 @@ public class FallAlarm implements IAlarm {
@Override
public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
log.info("跌倒预警参数platAlarmCheckDTO:{}", platAlarmCheckDTO);
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
log.info("跌倒预警长者:{}", JSONUtil.toJsonStr(platElderList));
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
log.error("告警配置为禁用,告警配置id:" + config.getId());
......
......@@ -81,7 +81,7 @@ public class HeartAlarm implements IAlarm {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getId();
Integer start = ruleConfig.getHeartRateStart();
Integer end = ruleConfig.getHeartRateeEnd();
Integer end = ruleConfig.getHeartRateEnd();
Integer duration = ruleConfig.getDuration();
String personState = Convert.toStr(properties.get("personState"));
//心率
......@@ -107,7 +107,7 @@ public class HeartAlarm implements IAlarm {
RedisUtil.delete(RedisConst.ALARM_DEVICE_HR_ID + deviceId);
return;
}
log.info("hr:{},end:{},start:{},mes:{}", hr, end, start, messageType);
if ((hr > end || hr < start) && StringUtils.equalsAnyIgnoreCase(messageType, "REPORT_PROPERTY")) {
if(alarmRedisDTO==null){
alarmRedisDTO = new AlarmRedisDTO();
......
package com.makeit.service.platform.alarm.alarmStrategy;
import cn.hutool.core.convert.Convert;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.dto.platform.alarm.PlatAlarmConfigOffBedDTOVO;
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.enums.CommonEnum;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.redis.RedisConst;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.utils.AlarmConfigCacheUtil;
import com.makeit.utils.AlarmRedisDTO;
import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.redis.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Component
@Slf4j
public class OffBedAlarm implements IAlarm {
@Resource
private PlatAlarmRecordService platAlarmRecordService;
private final PlatAlarmConfigEnum.AlarmTypeEnum alarmTypeEnum = PlatAlarmConfigEnum.AlarmTypeEnum.OFF_BED;
@Resource
private AlarmConfigCacheUtil alarmConfigCacheUtil;
@Override
public boolean support(String alarmType) {
return StringUtils.equals(alarmType, alarmTypeEnum.getValue());
}
/**
* 4.离床异常:长者绑定的呼吸心率设备在配置时间段内,检测到长者的离床状态(设备状态无人)持续时间超过配置的离床持续时间,则告警
*
* @param platAlarmCheckDTO
*/
@Override
public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
log.info("执行离床checkConfig方法:");
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
if (CollectionUtils.isEmpty(platElderList)) {
log.error("离床告警心率设备未关联长者,设备plat_id:" + platAlarmCheckDTO.getPlatDevice().getId());
return;
}
PlatAlarmConfig config = alarmConfigCacheUtil.get(platDevice.getOrgId(), PlatAlarmConfigEnum.AlarmTypeEnum.OFF_BED.getValue());
log.info("离床预警配置:{},orgid:{}", JSONUtil.toJsonStr(config), platDevice.getOrgId());
if (config == null || StringUtils.isBlank(config.getRuleConfig()) || !"5".equals(config.getAlarmType())) {
log.error("离床告警配置不存在,config:{}", JSONUtil.toJsonStr(config));
return;
}
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
log.error("离床告警配置为禁用,告警配置id:" + config.getId());
return;
}
String ruleConfigStr = config.getRuleConfig();
if (StringUtils.isBlank(ruleConfigStr)) {
log.error("离床告警配置未配置,告警配置id:" + config.getId());
return;
}
PlatAlarmConfigOffBedDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigOffBedDTOVO.class);
if (ruleConfig == null) {
log.error("离床告警配置解析失败,config:{}", JSONUtil.toJsonStr(config));
return;
}
if (ruleConfig.getOffBedStart() == null || ruleConfig.getOffBedEnd() == null) {
log.error("离床告警配置时间不能为空,config:{}", JSONUtil.toJsonStr(config));
return;
}
JSONObject properties = platAlarmCheckDTO.getProperties();
if (properties == null) {
properties = new JSONObject();
}
String deviceId = platDevice.getId();
LocalTime startTime = ruleConfig.getOffBedStart();
LocalTime endTime = ruleConfig.getOffBedEnd();
if (startTime == null || endTime == null) {
log.error("离床告警配置时间段解析失败,config:{}", JSONUtil.toJsonStr(ruleConfig));
return;
}
log.info("离床预警时间范围,begin:{},end:{}", startTime, endTime);
String personState = Convert.toStr(properties.get("person"));
boolean isOffBed = "0".equals(personState);
// 1-有人 0-无人
log.info("离床告警config:{}", JSONUtil.toJsonStr(properties));
AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId);
if (!isOffBed && alarmRedisDTO != null) {
log.info("离床告警有人状态下,删除redis!");
RedisUtil.delete(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId);
return;
}
// 设备无人,在范围内上报存储redis,超过离床持续时间,则预警
String messageType = platAlarmCheckDTO.getMessageType();
if (StringUtils.equalsAnyIgnoreCase(messageType, "OFFLINE", "DISCONNECT")) {
log.info("离床告警设备下线,删除redis off_bed 预警");
RedisUtil.delete(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId);
}
if (isOffBed) {
// 离床推送redis
sendToRedis(alarmRedisDTO, deviceId);
alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId);
Long firstOffBedLong = alarmRedisDTO.getStartLong();
LocalDateTime firstOffBedTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(firstOffBedLong), ZoneOffset.of("+8"));
log.info("离床告警第一次离床时间为:" + firstOffBedTime);
if ("1".equals(alarmRedisDTO.getAlarm())) {
log.info("离床告警已发送预警过!");
return;
}
// 是否跨天
boolean isCrossDay = startTime.isAfter(endTime);
if (isCrossDay) {
log.info("离床预警跨天处理:config:{}", config.getRuleConfig());
handleCrossDay(alarmRedisDTO, ruleConfig, platAlarmCheckDTO, config, deviceId);
} else {
log.info("离床预警未跨天处理:config:{}", config.getRuleConfig());
handleUnCrossDay(alarmRedisDTO, ruleConfig, platAlarmCheckDTO, config, deviceId);
}
}
}
private void handleCrossDay(AlarmRedisDTO alarmRedisDTO, PlatAlarmConfigOffBedDTOVO ruleConfig,
PlatAlarmCheckDTO platAlarmCheckDTO,
PlatAlarmConfig config,
String deviceId) {
Integer duration = ruleConfig.getDuration();
LocalTime startTime = ruleConfig.getOffBedStart();
LocalTime endTime = ruleConfig.getOffBedEnd();
Long firstOffBedLong = alarmRedisDTO.getStartLong();
long currentTimeMillis = System.currentTimeMillis();
boolean isOverTime = (currentTimeMillis - firstOffBedLong) / 1000 >= duration * 60;
LocalDateTime firstOffBedTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(firstOffBedLong), ZoneOffset.of("+8"));
LocalTime firstTime = firstOffBedTime.toLocalTime();
boolean isInTime = firstTime.isAfter(startTime) || firstTime.isBefore(endTime);
LocalTime endTimeLimit = endTime.plusMinutes(-duration);
// 离床时间在范围内
if (isInTime && isOverTime) {
if (firstTime.isAfter(endTimeLimit)) {
log.info("handleCrossDay 第一次离床时间,{}+持续时间:{}将超过范围,{}", firstTime, duration, endTime);
return;
}
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
platAlarmCheckDTO.setPlatAlarmConfig(config);
log.info("cross离床告警离床时间在范围时间内,配置:{}", config.getRuleConfig());
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
return;
}
LocalDateTime now = LocalDateTime.now();
LocalDateTime startLocalDteTime = LocalDateTime.of(LocalDate.now(), startTime);
if (!isInTime) {
long mills = Duration.between(startLocalDteTime, now).toMillis() / 1000;
boolean noInOverTime = mills >= duration * 60;
if (noInOverTime) {
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
platAlarmCheckDTO.setPlatAlarmConfig(config);
log.info("cross离床告警第一次离床时间在范围前,配置:{}", config.getRuleConfig());
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
} else {
log.info("cross离床告警,第一次离床时间在范围前,未预警,配置:{},时间持续:{},start:{}", config.getRuleConfig(), mills, startLocalDteTime);
}
} else {
log.info("handleCrossDay 未满足预警条件!fisrttime:{},config:{}", firstTime, config.getRuleConfig());
}
}
private void handleUnCrossDay(AlarmRedisDTO alarmRedisDTO, PlatAlarmConfigOffBedDTOVO ruleConfig,
PlatAlarmCheckDTO platAlarmCheckDTO,
PlatAlarmConfig config,
String deviceId) {
Integer duration = ruleConfig.getDuration();
LocalTime startTime = ruleConfig.getOffBedStart();
LocalDateTime startLocalDteTime = LocalDateTime.of(LocalDate.now(), startTime);
LocalTime endTime = ruleConfig.getOffBedEnd();
LocalDateTime endLocalDteTime = LocalDateTime.of(LocalDate.now(), endTime);
Long firstOffBedLong = alarmRedisDTO.getStartLong();
long currentTimeMillis = System.currentTimeMillis();
boolean isOverTime = (currentTimeMillis - firstOffBedLong) / 1000 >= duration * 60;
LocalDateTime firstOffBedTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(firstOffBedLong), ZoneOffset.of("+8"));
LocalTime firstTime = firstOffBedTime.toLocalTime();
if (firstTime.isAfter(endTime)) {
log.info("handleUnCrossDay第一次离床时间:{},在时间范围外 config:{}", firstTime, config.getRuleConfig());
return;
}
boolean isInTime = firstTime.isAfter(startTime) && firstTime.isBefore(endTime);
LocalTime endTimeLimit = endTime.plusMinutes(-duration);
// 离床时间在范围内
if (isInTime && isOverTime) {
if (firstTime.isAfter(endTimeLimit)) {
log.info("handleUnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}", firstTime, duration, endTime);
return;
}
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
platAlarmCheckDTO.setPlatAlarmConfig(config);
log.info("uncross离床告警离床时间在范围时间内,配置:{}", config.getRuleConfig());
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
return;
}
LocalDateTime now = LocalDateTime.now();
if (!isInTime && now.isAfter(startLocalDteTime) && now.isBefore(endLocalDteTime)) {
long mills = Duration.between(startLocalDteTime, now).toMillis() / 1000;
boolean noInOverTime = mills >= duration * 60;
if (noInOverTime) {
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
platAlarmCheckDTO.setPlatAlarmConfig(config);
log.info("uncross离床告警第一次离床时间在范围前,配置:{}", config.getRuleConfig());
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
} else {
log.info("uncross离床告警第一次离床时间在范围前,未预警,配置:{},时间持续:{},start:{}", config.getRuleConfig(), mills, startLocalDteTime);
}
} else {
log.info("handleUnCrossDay 未满足预警条件!fisrttime:{},config:{}", firstTime, config.getRuleConfig());
}
}
private void sendToRedis(AlarmRedisDTO alarmRedisDTO, String deviceId) {
Date now = new Date();
long endLong = now.getTime();
// 第一次上报
if (alarmRedisDTO == null) {
alarmRedisDTO = new AlarmRedisDTO();
alarmRedisDTO.setAlarm(CommonEnum.NO.getValue());
alarmRedisDTO.setStart(now);
alarmRedisDTO.setStartLong(endLong);
RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
log.info("离床告警 离床设备存储redis,第一次上报时间:{},开始上报时间:{},是否上报:{}",
getDateTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
} else {
alarmRedisDTO.setStart(now);
log.info("离床告警离床更新redis,第一次上报时间:{},更新时间:{},是否上报:{}",
getDateTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
}
}
private void noticeAlarm(AlarmRedisDTO alarmRedisDTO, PlatAlarmCheckDTO platAlarmCheckDTO, String deviceId) {
notice(platAlarmCheckDTO);
alarmRedisDTO.setStart(new Date());
alarmRedisDTO.setAlarm(CommonEnum.YES.getValue());
RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
log.info("离床告警推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{}",
getDateTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
}
@Override
public void notice(PlatAlarmCheckDTO platAlarmCheckDTO) {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
log.error("离床告警配置为禁用,告警配置id:" + config.getId());
return;
}
if (StringUtils.isBlank(config.getRuleConfig())) {
log.error("离床告警配置未配置,告警配置id:" + config.getId());
return;
}
if (CollectionUtils.isEmpty(platElderList)) {
log.error("离床告警配置未关联长者,设备plat_id:" + platDevice.getId());
return;
}
// PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom();
for (PlatElder platElder : platElderList) {
if (!platElder.getOrgId().equals(config.getOrgId())) {
log.info("长者不再配置组织内:长者:{},config:{}", platElder.getName(), config.getRuleConfig());
continue;
}
List<String> param = new ArrayList<>();
// param.add(platRoom.getName());
param.add(platElder.getName());
platAlarmCheckDTO.setParam(param);
PlatAlarmRecord platAlarmRecord = platAlarmRecordService.convertToPlatAlarmRecord(platAlarmCheckDTO, platElder);
platAlarmRecord.setElderName(platElder.getName());
platAlarmRecord.setElderIds(platElder.getId());
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(), platAlarmRecord);
log.info("离床告警配置,发出告警,设备id:" + platDevice.getId() + ", 长者名称:" + platElder.getName()
+ "config_id:" + config.getId() + "--" + config.getRuleConfig());
}
}
private static String getDateTime(long longTime) {
return dateToString(new Date(longTime), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
}
/**
* 日期类型转换成字符串类型
*
* @param date 日期
* @param dateFormat 日期格式
* @return 日期字符串
*/
private static String dateToString(Date date, DateFormat dateFormat) {
return dateFormat.format(date);
}
}
package com.makeit.service.platform.alarm.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.dto.StatusDTO;
import com.makeit.dto.platform.alarm.PlatAlarmConfigDTOVO;
......@@ -16,6 +19,7 @@ import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.mapper.platform.alarm.PlatAlarmConfigMapper;
import com.makeit.service.platform.alarm.PlatAlarmConfigService;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.utils.AlarmConfigCacheUtil;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
......@@ -23,13 +27,17 @@ import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.vo.platform.alarm.PlatAlarmConfigListVO;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
/**
* <p>
......@@ -47,6 +55,8 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe
@Autowired
private AlarmConfigCacheUtil alarmConfigUtil;
@Resource
private PlatOrgService platOrgService;
@Override
public List<PlatAlarmConfigListVO> list(PlatAlarmConfigQueryDTO dto) {
......@@ -221,4 +231,29 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe
public List<PlatHealthConfigDTO> getHealthConfigList() {
return baseMapper.getHealthConfigList();
}
@Override
public void initData() {
List<PlatOrg> orgList = platOrgService.list();
PlatAlarmConfig config = getOne(Wrappers.<PlatAlarmConfig>lambdaQuery().eq(PlatAlarmConfig::getTenantId, 0)
.eq(PlatAlarmConfig::getAlarmType, "5"));
List<String> orgIds = orgList.stream().map(PlatOrg::getId).collect(Collectors.toList());
List<PlatAlarmConfig> existList = list(Wrappers.<PlatAlarmConfig>lambdaQuery().in(PlatAlarmConfig::getOrgId, orgIds)
.eq(PlatAlarmConfig::getAlarmType, "5"));
Map<String, PlatAlarmConfig> configMap = StreamUtil.toMap(existList, PlatAlarmConfig::getOrgId);
List<PlatAlarmConfig> saveList = Lists.newArrayList();
for (PlatOrg o : orgList) {
if (configMap.containsKey(o.getId())) {
continue;
}
PlatAlarmConfig alarmConfig = new PlatAlarmConfig();
BeanUtil.copyProperties(config, alarmConfig, "id");
alarmConfig.setTenantId(o.getTenantId());
alarmConfig.setOrgId(o.getId());
saveList.add(alarmConfig);
}
if (CollUtil.isNotEmpty(saveList)) {
saveBatch(saveList);
}
}
}
package com.makeit.service.platform.alarm.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -118,6 +119,11 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
PlatAlarmRecordQueryDTO param = dto.getData();
Page<PlatAlarmRecord> mpPage = PageUtil.toMpPage(dto);
LambdaQueryWrapper<PlatAlarmRecord> lambdaQueryWrapper = getLambdaQueryWrapper(param);
List<PlatAlarmRecord> list = list(lambdaQueryWrapper);
Boolean isUnWechatRead = CollUtil.isNotEmpty(list) && list.stream()
.anyMatch(a -> CommonEnum.NO.getValue().equals(a.getWechatReadFlag()));
Boolean statusFlag = CollUtil.isNotEmpty(list) && list.stream()
.anyMatch(a -> CommonEnum.NO.getValue().equals(a.getStatus()));
Page<PlatAlarmRecord> page = page(mpPage, lambdaQueryWrapper);
List<PlatAlarmRecord> records = page.getRecords();
List<PlatAlarmRecordVO> dtos = BeanDtoVoUtils.listVo(records, PlatAlarmRecordVO.class);
......@@ -131,6 +137,8 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
if (platDevice != null) {
platAlarmRecordVO.setDevice(platDevice);
}
platAlarmRecordVO.setIsUnWechatRead(isUnWechatRead);
platAlarmRecordVO.setStatusFlag(statusFlag);
}
return PageUtil.toPageVO(dtos, page);
}
......@@ -202,6 +210,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
.in(CollectionUtils.isNotEmpty(param.getElderIdList()),PlatAlarmRecord::getElderIds,param.getElderIdList())
.eq(StringUtils.isNotBlank(param.getNoticeStatus()),PlatAlarmRecord::getNoticeStatus,param.getNoticeStatus())
.eq(StringUtils.isNotBlank(param.getReadFlag()),PlatAlarmRecord::getReadFlag,param.getReadFlag())
.eq(StringUtils.isNotBlank(param.getMisinformationFlag()),PlatAlarmRecord::getMisinformationFlag,param.getMisinformationFlag())
.eq(StringUtils.isNotBlank(param.getWechatReadFlag()), PlatAlarmRecord::getWechatReadFlag, param.getWechatReadFlag())
.orderByDesc(BaseEntity::getCreateDate)
;
......@@ -399,7 +408,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
msgSendDTO.setSubject(alarmRecord.getContent());
msgSendDTO.setParam(alarmRecord.getElderName());
String alarmType = alarmConfig.getAlarmType();
//告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常
//告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常 5 离床异常
if (StringUtils.equals(alarmType, "1")) {
msgSendDTO.setParam(alarmRecord.getElderName(),alarmRecord.getRegionName());
}
......@@ -412,6 +421,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
if (StringUtils.equals(alarmType, "4")) {
msgSendDTO.setParam(alarmRecord.getElderName(),alarmRecord.getRegionName());
}
if (StringUtils.equals(alarmType, "5")) {
msgSendDTO.setParam(alarmRecord.getElderName(), "");
}
msgSendDTO.setAlarmType(alarmConfig.getAlarmType());
//todo 小程序消息
msgUtil.send(msgSendDTO);
......@@ -522,7 +534,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
}
private String replaceParam(String oriContent,List<String> param) {
public static String replaceParam(String oriContent,List<String> param) {
Pattern p = Pattern.compile("\\[#\\d+\\]|\\[#[\\p{IsHan}]+\\]|\\[#[^\\]]*\\]");
Matcher m = p.matcher(oriContent);
StringBuffer sb = new StringBuffer();
......@@ -597,7 +609,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
platAlarmRecord.setStatus(CommonEnum.YES.getValue());
platAlarmRecord.setDealDate(LocalDateTime.now());
CommonUserVO user = CommonUserUtil.getUser();
//platAlarmRecord.setDealUser(user.getName());
platAlarmRecord.setDealUser(user.getName());
updateById(platAlarmRecord);
String deviceId = platAlarmRecord.getDeviceId();
......@@ -607,7 +619,11 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
}
Timestamp timestamp = Timestamp.valueOf(platAlarmRecord.getCreateDate());
log.info("开始想设备发送误报通知");
iotDevicePropertiesOperateService.deviceFunctionAttr(platDevice.getOriDeviceId(),timestamp.getTime());
String result = iotDevicePropertiesOperateService.deviceFunctionAttr(platDevice.getOriDeviceId(), timestamp.getTime());
if (StringUtils.isNotEmpty(result)) {
throw new RuntimeException("发送误报通知失败:" + result);
}
}
@Override
......
......@@ -89,6 +89,8 @@ public interface PlatOrgService extends IService<PlatOrg> {
List<PlatOrg> subOrgList(PlatOrgQueryDTO platOrgQueryDTO);
List<PlatOrg> currentOrg(PlatOrgQueryDTO platOrgQueryDTO);
/**
* 组织表增加一条数据
* 增加告警配置
......@@ -116,4 +118,6 @@ public interface PlatOrgService extends IService<PlatOrg> {
* @return
*/
List<PlatOrg> belongToScopeListIgnoreTenant(PlatOrg param);
List<String> getCurrentAndSubIds(String id);
}
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
......@@ -571,6 +572,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
.like(StringUtils.isNotBlank(dto.getName()),PlatOrg::getName,dto.getName())
.eq(StringUtils.isNotBlank(dto.getType()),PlatOrg::getType,dto.getType())
.eq(StringUtils.isNotBlank(dto.getStatus()),PlatOrg::getStatus,dto.getStatus())
.in(CollectionUtils.isNotEmpty(dto.getOrgIds()), PlatOrg::getId, dto.getOrgIds())
.orderByDesc(BaseEntity::getUpdateDate);
return queryWrapper;
}
......@@ -594,6 +596,24 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
return orgTree;
}
@Override
public List<PlatOrg> currentOrg(PlatOrgQueryDTO platOrgQueryDTO) {
PlatUserVO userVOCanNull = PlatUserUtil.getUserVOCanNull();
String orgId = userVOCanNull.getOrgId();
List<String> orgIds = this.getCurrentAndSubIds(orgId);
platOrgQueryDTO.setOrgIds(orgIds);
LambdaQueryWrapper<PlatOrg> queryWrapper = getLambdaQueryWrapper(platOrgQueryDTO);
List<PlatOrg> list = list(queryWrapper);
if(CollectionUtils.isEmpty(list)){
return new ArrayList<>();
}
list = list.stream().map(org -> {
org.setGrade(org.getPath().split(",").length);
return org;
}).collect(Collectors.toList());
return createOrgTree(list);
}
/**
* 返回parentId的 树
* @param platOrgQueryDTO
......@@ -721,4 +741,14 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
}
return orgList;
}
@Override
public List<String> getCurrentAndSubIds(String id) {
List<String> ids = Lists.newArrayList(id);
LambdaQueryWrapper<PlatOrg> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(PlatOrg::getPath, id);
List<String> subIds = this.list(queryWrapper).stream().map(PlatOrg::getId).collect(Collectors.toList());
ids.addAll(subIds);
return ids;
}
}
......@@ -84,6 +84,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
......@@ -127,6 +128,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
@Autowired
private PlatOrgService platOrgService;
@Resource
private PlatUserMapper platUserMapper;
private DefaultIdentifierGenerator defaultIdentifierGenerator = new DefaultIdentifierGenerator();
......@@ -611,7 +614,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
TokenUtil.platLogin(TokenUtil.tntGetToken(), userLoginVO);
supperRoleMenuList(userLoginVO);
filterOrgManageMenu(userLoginVO);
// filterOrgManageMenu(userLoginVO); // 去除该逻辑
setRoleMenuToRedis(userLoginVO);
return userLoginVO;
}
......@@ -620,7 +623,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
List<PlatMenu> menuList = getMenuListByUserId(userLoginVO);
fillMenuList(menuList, userLoginVO);
filterOrgManageMenu(userLoginVO);
// filterOrgManageMenu(userLoginVO);
setRoleMenuToRedis(userLoginVO);
return userLoginVO;
......@@ -1179,9 +1182,10 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
LambdaQueryWrapper<PlatUser> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
userLambdaQueryWrapper.select(PlatUser::getMobile, PlatUser::getEmail,PlatUser::getAccount, BaseEntity::getId);
List<PlatUser> userList = this.list(userLambdaQueryWrapper);
List<PlatUser> allUserList = platUserMapper.listAll();
Map<String, String> mobileMap = userList.stream().collect(Collectors.toMap(PlatUser::getMobile, BaseEntity::getId, (a, b) -> a));
Map<String, String> emailMap = userList.stream().filter(vo->StringUtils.isNotBlank(vo.getEmail())).collect(Collectors.toMap(PlatUser::getEmail, BaseEntity::getId, (a, b) -> a));
Map<String, String> accountMap = userList.stream().collect(Collectors.toMap(PlatUser::getAccount, BaseEntity::getId, (a, b) -> a));
Map<String, String> accountMap = allUserList.stream().collect(Collectors.toMap(PlatUser::getAccount, BaseEntity::getId, (a, b) -> a));
return ExcelValidatorUtil.validateMain(3, platUserImportDTOS, list -> {
......
package com.makeit.service.platform.device;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.dto.BaseIdDTO;
......@@ -92,4 +93,6 @@ public interface PlatDeviceService extends IService<PlatDevice> {
PlatAlarmCallDeviceVO callingDevice(PlatCallingDeviceDTO dto);
void devicePushLog(MultipartFile multipartFile, String deviceId) throws IOException;
void syncIotProperties(String deviceId, JSONObject iotProperties);
}
......@@ -4,19 +4,28 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.device.PlatDeviceLog;
import com.makeit.entity.saas.PlatTenant;
import com.makeit.mapper.platform.device.PlatDeviceLogMapper;
import com.makeit.service.platform.device.PlatDeviceLogService;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* <p>
* 设备日志 服务实现类
......@@ -30,6 +39,8 @@ public class PlatDeviceLogServiceImpl extends ServiceImpl<PlatDeviceLogMapper, P
@Autowired
private PlatDeviceLogMapper platDeviceLogMapper;
@Autowired
private PlatTenantService platTenantService;
@Override
public PageVO<PlatDeviceLog> pageList(PageReqDTO<PlatDeviceLog> pageReqDTO) {
......@@ -38,12 +49,19 @@ public class PlatDeviceLogServiceImpl extends ServiceImpl<PlatDeviceLogMapper, P
LambdaQueryWrapper<PlatDeviceLog> lambdaQueryWrapper = new QueryWrapper<PlatDeviceLog>().lambda()
.eq(StringUtils.isNotEmpty(dto.getDeviceId()), PlatDeviceLog::getDeviceId, dto.getDeviceId())
.eq(StringUtils.isNotEmpty(dto.getProductName()), PlatDeviceLog::getProductName, dto.getProductName())
.like(StringUtils.isNotEmpty(dto.getProductName()), PlatDeviceLog::getProductName, dto.getProductName())
.eq(StringUtils.isNotEmpty(dto.getTenantId()), PlatDeviceLog::getTenantId, dto.getTenantId())
.ge(dto.getStartTime() != null, PlatDeviceLog::getCreateDate, dto.getStartTime())
.ge(dto.getEndTime() != null, PlatDeviceLog::getCreateDate, dto.getEndTime());
.le(dto.getEndTime() != null, PlatDeviceLog::getCreateDate, dto.getEndTime());
Page<PlatDeviceLog> deviceLogPage = platDeviceLogMapper.selectPage(p, lambdaQueryWrapper);
List<PlatDeviceLog> records = deviceLogPage.getRecords();
List<String> tenantIdList = StreamUtil.map(records, BaseBusEntity::getTenantId);
List<PlatTenant> platTenantList = platTenantService.listByIds(tenantIdList);
Map<String, String> tenantMap = platTenantList.stream().collect(Collectors.toMap(BaseEntity::getId, PlatTenant::getName, ((v1, v2) -> v2)));
for (PlatDeviceLog record : records) {
record.setTenantName(tenantMap.getOrDefault(record.getTenantId(),""));
}
return PageUtil.toPageVO(deviceLogPage.getRecords(), deviceLogPage);
return PageUtil.toPageVO(records, deviceLogPage);
}
}
......@@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
......@@ -34,8 +35,10 @@ import com.makeit.entity.platform.space.PlatRegionSetting;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.entity.saas.PlatTenant;
import com.makeit.entity.saas.SaasPidManage;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.device.PlatDeviceEnum;
import com.makeit.enums.report.DeviceNameEnum;
import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
......@@ -59,6 +62,7 @@ import com.makeit.service.platform.space.PlatRegionSettingService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.service.saas.SaasPidManageService;
import com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO;
import com.makeit.shengwang.agora.http.ShengwangHttpUtil;
import com.makeit.shengwang.agora.media.RtcTokenBuilder2;
......@@ -66,6 +70,7 @@ import com.makeit.shengwang.agora.service.ShengwangService;
import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO;
import com.makeit.utils.DeviceCacheUtil;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.old.StringUtils;
......@@ -87,6 +92,7 @@ import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -138,6 +144,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private AliyunOSSRepository aliyunOSSRepository;
@Autowired
private PlatDeviceLogService platDeviceLogService;
@Autowired
private SaasPidManageService saasPidManageService;
/**
* 平台设备列表
......@@ -374,11 +382,42 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
for (PlatDeviceOther platDeviceOther : platDeviceOtherList) {
BeanUtils.copyProperties(dto, platDeviceOther,"id");
platDeviceOther.setDeviceId(id);
platDeviceOther.setAttribute(getDefaultAttr(db));
platDeviceOther.setOriDeviceId(db.getOriDeviceId());
platDeviceOtherService.saveOrUpdate(platDeviceOther);
}
}
private String getDefaultAttr(PlatDevice platDevice) {
String category = platDevice.getCategory();
if (!(PlatDeviceEnum.CategoryEnum.FALL.getValue().equals(category) || PlatDeviceEnum.CategoryEnum.SPACE.getValue().equals(category))) {
return null;
}
PlatDeviceBaseAttrDTO platDeviceBaseAttrDTO = new PlatDeviceBaseAttrDTO();
// 跌倒
if (PlatDeviceEnum.CategoryEnum.FALL.getValue().equals(category)) {
platDeviceBaseAttrDTO.setRadarMount(1);
platDeviceBaseAttrDTO.setRadarHight(300);
platDeviceBaseAttrDTO.setRadarSence(2);
platDeviceBaseAttrDTO.setRadarSPL(1);
}
// 空间人体
if (PlatDeviceEnum.CategoryEnum.SPACE.getValue().equals(category)) {
platDeviceBaseAttrDTO.setRadarMount(0);
platDeviceBaseAttrDTO.setRadarMode(1);
PlatDeviceBaseAttrDTO.DeviceAttrRange distance = new PlatDeviceBaseAttrDTO.DeviceAttrRange();
distance.setMax(1000);
distance.setMin(10);
platDeviceBaseAttrDTO.setRadarDistance(distance);
PlatDeviceBaseAttrDTO.DeviceAttrRange angle = new PlatDeviceBaseAttrDTO.DeviceAttrRange();
angle.setMax(60);
angle.setMin(-60);
platDeviceBaseAttrDTO.setRadarAngle(angle);
platDeviceBaseAttrDTO.setRadarDelay(30);
}
return JSON.toJSONString(platDeviceBaseAttrDTO);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void wechatEdit(PlatDeviceEditWechatDTO dto) {
......@@ -550,16 +589,22 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
PlatDeviceBaseAttrDTO.DeviceAttrRange radarDistance = platDeviceBaseAttrDTO.getRadarDistance();
if (!Objects.equals(radarDistance, dto.getRadarDistance())) {
if (radarDistance != null && radarDistance.getMax() != null && radarDistance.getMin() != null) {
if (dto.getRadarDistance() != null) {
map.put("radarDistance", JSON.toJSONString(dto.getRadarDistance()));
}
}
PlatDeviceBaseAttrDTO.DeviceAttrRange radarAngle = platDeviceBaseAttrDTO.getRadarAngle();
if (!Objects.equals(radarAngle, dto.getRadarAngle())) {
if (radarAngle != null && radarAngle.getMax() != null && radarAngle.getMin() != null) {
if (dto.getRadarAngle() != null) {
map.put("radarAngle", JSON.toJSONString(dto.getRadarAngle()));
}
}
if (!Objects.equals(platDeviceBaseAttrDTO.getRadarSence(), dto.getRadarSence())) {
map.put("radarSence", dto.getRadarSence() );
}
if (!Objects.equals(platDeviceBaseAttrDTO.getRadarSPL(), dto.getRadarSPL())) {
map.put("radarSPL", dto.getRadarSPL() );
}
return map;
}
......@@ -694,10 +739,13 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
Set<String> newIotDeviceIdSet = Sets.newHashSet(iotDeviceIdSet);
Set<String> newPlatformDeviceIdSet = Sets.newHashSet(platformDeviceIdList);
if (CollectionUtils.isEmpty(newIotDeviceIdSet)) {
continue;
}
newPlatformDeviceIdSet.removeAll(newIotDeviceIdSet);
//iotDeviceIdSet.removeAll(platformDeviceIdList);
if (CollectionUtils.isNotEmpty(newPlatformDeviceIdSet)) {
log.info("删除不存在iot的设备:{}",platTenant.getId());
List<PlatDevice> platDevices = list(new QueryWrapper<PlatDevice>().lambda().eq(BaseBusEntity::getTenantId, platTenant.getId())
.in(PlatDevice::getOriDeviceId, newPlatformDeviceIdSet));
......@@ -741,7 +789,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private void saveDeviceOtherInfo(Collection<PlatDevice> platDevices) {
List<String> deviceIdList = platDevices.stream().map(BaseEntity::getId).collect(Collectors.toList());
List<PlatDeviceOther> platDeviceOtherList = platDeviceOtherService.list(new QueryWrapper<PlatDeviceOther>().lambda().in(PlatDeviceOther::getDeviceId, deviceIdList));
Map<String, PlatDeviceOther> deviceOtherMap = StreamUtil.toMap(platDeviceOtherList, PlatDeviceOther::getDeviceId);
Map<String, PlatDeviceOther> deviceOtherMap = platDeviceOtherList.stream().collect(Collectors.toMap(PlatDeviceOther::getDeviceId, Function.identity(),(v1,v2)->v1));
for (PlatDevice platDevice : platDevices) {
PlatDeviceOther platDeviceOther = deviceOtherMap.get(platDevice.getId());
if (platDeviceOther == null) {
......@@ -832,7 +880,22 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if (StringUtils.isNotEmpty(AttrResult)) {
throw new RuntimeException(AttrResult);
}
String active = shengwangHttpUtil.active(platDevice.getOriDeviceId());
SaasPidManage saasPidManage = saasPidManageService.getOne(new QueryWrapper<SaasPidManage>().lambda()
.eq(SaasPidManage::getStatus, "1")
.orderByAsc(BaseEntity::getCreateDate)
.last("limit 1"));
if (saasPidManage == null) {
throw new RuntimeException("当前没有可用的pid");
}
saasPidManage.setUsedCredit(Math.min(saasPidManage.getUsedCredit() + 1,saasPidManage.getTotalCredit()));
saasPidManage.setAvailableCredit(Math.max(saasPidManage.getAvailableCredit() - 1,0));
if (Objects.equals(saasPidManage.getTotalCredit(), saasPidManage.getUsedCredit())) {
saasPidManage.setStatus("0");
}
saasPidManageService.updateById(saasPidManage);
// 先为了业务测试注释
/* String active = shengwangHttpUtil.active(platDevice.getOriDeviceId(),saasPidManage.getPid());
ApiResponseEntity responseEntity = JSON.parseObject(active, ApiResponseEntity.class);
if (responseEntity.getCode() != 200) {
throw new RuntimeException(responseEntity.getMessage());
......@@ -854,7 +917,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if (StringUtils.isNotEmpty(result)) {
throw new RuntimeException(result);
}
}
}*/
}
......@@ -905,4 +968,82 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
platDeviceLog.setFileName(name);
platDeviceLogService.save(platDeviceLog);
}
@Override
@TenantIdIgnore
@Transactional(rollbackFor = Exception.class)
public void syncIotProperties(String deviceId, JSONObject iotProperties) {
PlatDeviceBaseAttrDTO iotAttr = iotProperties.toJavaObject(PlatDeviceBaseAttrDTO.class);
List<PlatDeviceOther> deviceOthers = platDeviceOtherService.list(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId));
Integer radarMount = null;
for (PlatDeviceOther deviceOther : deviceOthers) {
PlatDeviceBaseAttrDTO platDeviceBaseAttrDTO = JSON.parseObject(deviceOther.getAttribute(), PlatDeviceBaseAttrDTO.class);
if (platDeviceBaseAttrDTO == null) {
platDeviceBaseAttrDTO = new PlatDeviceBaseAttrDTO();
}
if (iotAttr.getRadarMode() != null && !Objects.equals(platDeviceBaseAttrDTO.getRadarMode(), iotAttr.getRadarMode())) {
platDeviceBaseAttrDTO.setRadarMode(iotAttr.getRadarMode());
}
if (iotAttr.getRadarMount() != null && !Objects.equals(platDeviceBaseAttrDTO.getRadarMount(), iotAttr.getRadarMount())) {
platDeviceBaseAttrDTO.setRadarMount(iotAttr.getRadarMount());
radarMount = platDeviceBaseAttrDTO.getRadarMount();
}
if (iotAttr.getRadarHight() != null && !Objects.equals(platDeviceBaseAttrDTO.getRadarHight(), iotAttr.getRadarHight())) {
platDeviceBaseAttrDTO.setRadarHight(iotAttr.getRadarHight());
}
if (iotAttr.getRadarDelay() != null && !Objects.equals(platDeviceBaseAttrDTO.getRadarDelay(), iotAttr.getRadarDelay())) {
platDeviceBaseAttrDTO.setRadarDelay(iotAttr.getRadarDelay());
}
PlatDeviceBaseAttrDTO.DeviceAttrRange radarDistance = platDeviceBaseAttrDTO.getRadarDistance();
if (iotAttr.getRadarDistance() != null && !Objects.equals(radarDistance, iotAttr.getRadarDistance())) {
platDeviceBaseAttrDTO.setRadarDistance(iotAttr.getRadarDistance());
}
PlatDeviceBaseAttrDTO.DeviceAttrRange radarAngle = platDeviceBaseAttrDTO.getRadarAngle();
if (iotAttr.getRadarAngle() != null && !Objects.equals(radarAngle, iotAttr.getRadarAngle())) {
platDeviceBaseAttrDTO.setRadarAngle(iotAttr.getRadarAngle());
}
if (iotAttr.getRadarSence() != null && !Objects.equals(platDeviceBaseAttrDTO.getRadarSence(), iotAttr.getRadarSence())) {
platDeviceBaseAttrDTO.setRadarSence(iotAttr.getRadarSence());
}
if (iotAttr.getRadarSPL() != null && !Objects.equals(platDeviceBaseAttrDTO.getRadarSPL(), iotAttr.getRadarSPL())) {
platDeviceBaseAttrDTO.setRadarSPL(iotAttr.getRadarSPL());
}
String attr = JSON.toJSONString(platDeviceBaseAttrDTO);
platDeviceOtherService.update(new UpdateWrapper<PlatDeviceOther>().lambda()
.set(PlatDeviceOther::getAttribute, attr)
.eq(PlatDeviceOther::getId, deviceOther.getId()));
}
if (radarMount != null) {
List<PlatDevice> platDeviceList = list(new QueryWrapper<PlatDevice>().lambda().eq(PlatDevice::getOriDeviceId, deviceId));
//更新区域设置设备安装方式
platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda()
.set(PlatRegionSetting::getInstallType, radarMount)
.in(CollectionUtils.isNotEmpty(platDeviceList),PlatRegionSetting::getDeviceId, StreamUtil.map(platDeviceList,BaseEntity::getId)));
}
}
private PlatDeviceBaseAttrDTO getDeviceBaseAttrDTO(PlatDevice platDevice) {
String category = platDevice.getCategory();
if (!(PlatDeviceEnum.CategoryEnum.FALL.getValue().equals(category) || PlatDeviceEnum.CategoryEnum.SPACE.getValue().equals(category))) {
return new PlatDeviceBaseAttrDTO();
}
String propertiesName = "";
// 跌倒
if (PlatDeviceEnum.CategoryEnum.FALL.getValue().equals(category)) {
propertiesName = "radarMount,radarHight,radarSence,radarSPL";
}
// 空间人体
if (PlatDeviceEnum.CategoryEnum.SPACE.getValue().equals(category)) {
propertiesName = "radarMount,radarMode,radarDistance,radarAngle,radarDelay";
}
PlatDeviceAttrWechatDTO dto = new PlatDeviceAttrWechatDTO();
dto.setDeviceId(platDevice.getOriDeviceId());
dto.setReadProperties(propertiesName);
List<DeviceProperties> data = this.readDeviceProperties(dto);
Map<String, Object> attrMap = data.stream().filter(p -> !Objects.isNull(p.getValue())).collect(Collectors.toMap(DeviceProperties::getProperty, DeviceProperties::getValue));
PlatDeviceBaseAttrDTO platDeviceBaseAttrDTO = JsonUtil.mapToBean(attrMap, PlatDeviceBaseAttrDTO.class);
return platDeviceBaseAttrDTO;
}
}
......@@ -71,7 +71,7 @@ public interface PlatElderService extends IService<PlatElder> {
List<PlatElderListVO> listByElder(PlatElderQueryDTO dto);
PlatElder getByDeviceId(String deviceId);
PlatElder getByDeviceId(String deviceId, String tenantId);
/*小程序*/
}
......@@ -102,7 +102,7 @@ public class PlatElderBreatheAnalysisServiceImpl extends ServiceImpl<PlatElderBr
.in(PlatElderBreatheDayStat::getElderId, elderIdList)
.eq(PlatElderBreatheDayStat::getDay, yesDate));
Map<String, PlatElderBreatheDayStat> breatheDayStatMap = StreamUtil.toMap(elderBreatheDayStatList, PlatElderBreatheDayStat::getElderId);
Map<String, PlatElderBreatheDayStat> breatheDayStatMap = StreamUtil.toMapDep(elderBreatheDayStatList, PlatElderBreatheDayStat::getElderId);
SaasSleepAnalysisModel analysisModel = saasSleepAnalysisModelService.getOne(new QueryWrapper<SaasSleepAnalysisModel>().lambda()
.orderByDesc(BaseEntity::getCreateBy)
......
......@@ -4,13 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.*;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.elder.PlatElderBreatheDayStat;
import com.makeit.entity.platform.elder.PlatElderReportMonth;
import com.makeit.entity.platform.elder.PlatElderSleepAnalysis;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.report.BreatheTypeEnum;
import com.makeit.enums.report.HeartRateTypeEnum;
import com.makeit.mapper.platform.elder.PlatElderBreatheDayStatMapper;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.analysis.DiseaseReportVO;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.elder.*;
......@@ -19,16 +19,17 @@ import com.makeit.utils.data.validate.CollectionUtils;
import com.makeit.utils.data.validate.MapUtil;
import com.makeit.utils.time.LocalDateTimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import static com.makeit.service.platform.elder.impl.PlatElderRealTimeServiceImpl.*;
/**
* <p>
......@@ -53,10 +54,16 @@ public class PlatElderBreatheDayStatServiceImpl extends ServiceImpl<PlatElderBre
private PlatElderRealTimeService platElderRealTimeService;
@Autowired
private PlatElderReportMonthService platElderReportMonthService;
@Autowired
private StringRedisTemplate redisTemplate;
@Transactional(rollbackFor = Exception.class)
@Override
public void heartRespiratoryTask() {
redisTemplate.delete(Objects.requireNonNull(redisTemplate.keys(DEVICE_BR_ANALYSIS + "*")));
redisTemplate.delete(Objects.requireNonNull(redisTemplate.keys(DEVICE_SPACE_TEMP_DATA + "*")));
redisTemplate.delete(Objects.requireNonNull(redisTemplate.keys(DEVICE_FALL_TEMP_DATA + "*")));
LocalDate nowDate = LocalDate.now();
LocalDate yesDate = nowDate.minusDays(1);
......@@ -134,6 +141,7 @@ public class PlatElderBreatheDayStatServiceImpl extends ServiceImpl<PlatElderBre
reportMonth.setHeartExceptionCount((int) StreamUtil.count(rList, i -> PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue().equals(i.getAlarmType())));
reportMonth.setRespiratoryExceptionCount((int) StreamUtil.count(rList, i -> PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue().equals(i.getAlarmType())));
reportMonth.setBehaviorExceptionCount((int) StreamUtil.count(rList, i -> PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue().equals(i.getAlarmType())));
reportMonth.setOffBedExceptionCount((int) StreamUtil.count(rList, i -> PlatAlarmConfigEnum.AlarmTypeEnum.OFF_BED.getValue().equals(i.getAlarmType())));
reportMonth.setTenantId(e.getTenantId());
reportMonthList.add(reportMonth);
......
package com.makeit.service.platform.elder.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -11,7 +12,6 @@ import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.auth.PlatOrgSplitDTO;
import com.makeit.dto.platform.elder.add.PlatElderDTOVO;
import com.makeit.dto.platform.elder.children.PlatElderChildrenInfoDTOVO;
import com.makeit.dto.platform.elder.children.PlatElderChildrenInfoQueryDTO;
import com.makeit.dto.platform.elder.children.PlatElderChildrenInfoWechatDTOVO;
......@@ -19,7 +19,6 @@ import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.elder.PlatElderChildrenInfo;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.Const;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.elder.PlatElderChildrenInfoMapper;
import com.makeit.service.platform.auth.PlatOrgService;
......@@ -44,8 +43,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.function.Function;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -253,7 +254,12 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild
@Override
public PlatElderChildrenInfoWechatVO view() {
return BeanDtoVoUtils.convert(getById(WechatUserUtil.getUserId()), PlatElderChildrenInfoWechatVO.class);
PlatElderChildrenInfoWechatVO wechatVO =
BeanDtoVoUtils.convert(getById(WechatUserUtil.getUserId()), PlatElderChildrenInfoWechatVO.class);
if (wechatVO != null && (StrUtil.isBlank(wechatVO.getName()) && StrUtil.isNotBlank(wechatVO.getPhone()))) {
wechatVO.setName(wechatVO.getPhone());
}
return wechatVO;
}
@Override
......@@ -299,7 +305,9 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild
@Transactional(rollbackFor = Exception.class)
public void bind(String elderId) {
PlatElderChildrenInfo childrenInfo = getById(WechatUserUtil.getUserId());
if (childrenInfo == null) {
return;
}
List<PlatElderChildrenInfo> platElderChildrenInfoList = list(new QueryWrapper<PlatElderChildrenInfo>().lambda()
.eq(PlatElderChildrenInfo::getOpenid, childrenInfo.getOpenid())
.isNotNull(PlatElderChildrenInfo::getElderId));
......@@ -313,11 +321,26 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild
if (platElder == null) {
throw new RuntimeException("找不到要绑定的长者");
}
// 优先同租户同组织下的长者,没有的话就同租户下的,再没有就拿初始的数据
PlatElderChildrenInfo orgChildrenInfo = platElderChildrenInfoList.stream()
.filter(f -> f.getOrgId().equals(platElder.getOrgId())).findFirst().orElse(null);
PlatElderChildrenInfo tenantInfo = platElderChildrenInfoList.stream()
.filter(f -> f.getTenantId().equals(platElder.getTenantId())).findFirst().orElse(null);
PlatElderChildrenInfo copyInfo = null;
if(orgChildrenInfo != null){
copyInfo = orgChildrenInfo;
}
if(tenantInfo != null && orgChildrenInfo == null){
copyInfo = tenantInfo;
}
if(copyInfo == null){
copyInfo = childrenInfo;
}
newChildrenInfo.setTenantId(platElder.getTenantId());
newChildrenInfo.setOpenid(childrenInfo.getOpenid());
newChildrenInfo.setPhone(childrenInfo.getPhone());
newChildrenInfo.setName(childrenInfo.getName());
newChildrenInfo.setAvatar(childrenInfo.getAvatar());
newChildrenInfo.setOpenid(copyInfo.getOpenid());
newChildrenInfo.setPhone(copyInfo.getPhone());
newChildrenInfo.setName(copyInfo.getName());
newChildrenInfo.setAvatar(copyInfo.getAvatar());
PlatOrgSplitDTO vo = platOrgService.getOrgSplitVO(platElder.getOrgId());
......
package com.makeit.service.platform.elder.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.makeit.common.entity.BaseEntity;
import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.alarm.PlatDayDurationRecord;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.elder.PlatElderBreatheAnalysis;
import com.makeit.entity.platform.elder.PlatElderSleep;
import com.makeit.entity.platform.elder.PlatElderSleepAnalysis;
import com.makeit.entity.platform.elder.*;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.module.iot.service.IotProductDeviceService;
......@@ -62,6 +61,8 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
private PlatElderRealTimeService platElderRealTimeService;
@Autowired
private PlatElderService platElderService;
@Autowired
private PlatElderCoordinateRecordService platElderCoordinateRecordService;
private static LocalDateTime dayStartNow(LocalDate now) {
return LocalDateTimeUtils.getDayStart(now);
......@@ -92,7 +93,7 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
String elderId = platElderIdDTO.getElderId();
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId(),platElderIdDTO.getTenantId());
if (platElder != null) {
elderId = platElder.getId();
}
......@@ -101,6 +102,8 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
PlatElderSleepAnalysis platElderSleepAnalysis = platElderSleepAnalysisService.getOne(new QueryWrapper<PlatElderSleepAnalysis>().lambda()
.eq(PlatElderSleepAnalysis::getElderId, elderId)
.eq(PlatElderSleepAnalysis::getHappenDate, nowString)
.orderByDesc(BaseEntity::getCreateDate)
.last("limit 1")
);
if (platElderSleepAnalysis == null) {
......@@ -124,15 +127,12 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
public List<PlatElderSleepDiagramVO> sleepDiagram(PlatElderReportDTO platElderIdDTO) {
LocalDate now = Optional.ofNullable(platElderIdDTO.getNow()).orElse(LocalDate.now());
LocalDateTime start = dayStartNow(now);
LocalDateTime end = dayEndNow(now);
List<PlatElderSleepDiagramVO> voList;
String nowString = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
String elderId = platElderIdDTO.getElderId();
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId(), platElderIdDTO.getTenantId());
if (platElder != null) {
elderId = platElder.getId();
}
......@@ -172,15 +172,12 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
public PlatElderHeartRespiratoryEvaluationVO heartRespiratoryEvaluation(PlatElderReportDTO platElderIdDTO) {
LocalDate now = Optional.ofNullable(platElderIdDTO.getNow()).orElse(LocalDate.now());
LocalDateTime start = dayStartNow(now);
LocalDateTime end = dayEndNow(now);
PlatElderHeartRespiratoryEvaluationVO platElderSleepEvaluationVO = new PlatElderHeartRespiratoryEvaluationVO();
String nowString = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
String elderId = platElderIdDTO.getElderId();
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId(), platElderIdDTO.getTenantId());
if (platElder != null) {
elderId = platElder.getId();
}
......@@ -220,20 +217,14 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
public List<PlatElderHeartRespiratoryEvaluationRecordVO> heartRespiratoryExceptionRecordList(PlatElderReportDTO platElderIdDTO, String alarmType, LocalDateTime start, LocalDateTime end) {
String elderId = platElderIdDTO.getElderId();
PlatDevice device = platElderRealTimeService.getBreathDevice(elderId, platElderIdDTO.getDeviceId());
if (device == null) {
return new ArrayList<>(10);
}
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId(), platElderIdDTO.getTenantId());
if (platElder != null) {
elderId = platElder.getId();
}
}
List<PlatAlarmRecord> recordList = platAlarmRecordService.list(new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(PlatAlarmRecord::getAlarmType, alarmType)
.eq(PlatAlarmRecord::getDeviceId, device.getId())
.eq(PlatAlarmRecord::getElderIds, elderId)
.ge(PlatAlarmRecord::getAlarmDate, start)
......@@ -242,7 +233,7 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
.orderByDesc(PlatAlarmRecord::getAlarmDate)
);
List<PlatElderHeartRespiratoryEvaluationRecordVO> voList = StreamUtil.map(recordList, e -> {
return StreamUtil.map(recordList, e -> {
PlatElderHeartRespiratoryEvaluationRecordVO vo = new PlatElderHeartRespiratoryEvaluationRecordVO();
vo.setTime(e.getAlarmDate());
vo.setStatus(e.getRemark());
......@@ -252,8 +243,6 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
});
return voList;
}
......@@ -283,7 +272,7 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
List<DeviceInfoContentBreathe> breatheList = iotProductDeviceService.getDeviceLogByTimeRangeBreathe(platDevice.getOriDeviceId(), 2 * 24 * 3600, start, end);
List<PlatElderRealTimeHeartRespiratoryVO> voList = StreamUtil.map(breatheList, e -> {
return StreamUtil.map(breatheList, e -> {
PlatElderRealTimeHeartRespiratoryVO vo = new PlatElderRealTimeHeartRespiratoryVO();
vo.setTime(LongTimestampUtil.toLocalDateTime(e.getTimestamp()));
......@@ -293,51 +282,37 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
return vo;
});
return voList;
}
@Override
public List<PlatElderBehaviorExceptionRecordVO> behaviorExceptionRecordListInternal(PlatElderReportDTO platElderIdDTO, LocalDateTime start, LocalDateTime end) {
String elderId = platElderIdDTO.getElderId();
List<PlatDevice> platDeviceList = platElderRealTimeService.getSpaceDevice(elderId, platElderIdDTO.getDeviceId());
List<PlatDevice> fallDeviceList = platElderRealTimeService.getFallDevice(elderId, platElderIdDTO.getDeviceId());
platDeviceList.addAll(fallDeviceList);
if (CollectionUtils.isEmpty(platDeviceList)) {
return new ArrayList<>(10);
}
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId(), platElderIdDTO.getTenantId());
if (platElder != null) {
elderId = platElder.getId();
}
}
List<PlatAlarmRecord> recordList = platAlarmRecordService.list(new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(PlatAlarmRecord::getAlarmType, PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue())
.in(PlatAlarmRecord::getDeviceId, StreamUtil.mapId(platDeviceList, PlatDevice::getId))
// .eq(PlatAlarmRecord::getAlarmType, PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue())
.in(PlatAlarmRecord::getAlarmType, Lists.newArrayList(PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue()
, PlatAlarmConfigEnum.AlarmTypeEnum.OFF_BED.getValue()))
.eq(PlatAlarmRecord::getElderIds, elderId)
.eq(PlatAlarmRecord::getMisinformationFlag, CommonEnum.NO.getValue())
.ge(PlatAlarmRecord::getAlarmDate, start)
.le(PlatAlarmRecord::getAlarmDate, end)
.orderByDesc(PlatAlarmRecord::getAlarmDate)
);
List<PlatElderBehaviorExceptionRecordVO> voList = StreamUtil.map(recordList, e -> {
return StreamUtil.map(recordList, e -> {
PlatElderBehaviorExceptionRecordVO vo = new PlatElderBehaviorExceptionRecordVO();
vo.setTime(e.getAlarmDate());
vo.setAlarmType(e.getAlarmType());
//vo.setRoomId(e.get);
vo.setRoomName(e.getRegionName());
vo.setDuration(MathUtil.stringToInteger(e.getAbnormalValue()));
return vo;
});
return voList;
}
......@@ -356,15 +331,10 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Override
public List<String> failRecordListInternal(PlatElderReportDTO platElderIdDTO, LocalDateTime start, LocalDateTime end) {
String elderId = platElderIdDTO.getElderId();
List<PlatDevice> platDeviceList = platElderRealTimeService.getFallDevice(elderId, platElderIdDTO.getDeviceId());
if (CollectionUtils.isEmpty(platDeviceList)) {
return new ArrayList<>(10);
}
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId(), platElderIdDTO.getTenantId());
if (platElder != null) {
elderId = platElder.getId();
}
......@@ -372,12 +342,9 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
List<String> voList = new ArrayList<>(10);
String finalElderId = elderId;
platDeviceList.forEach(e -> {
List<PlatAlarmRecord> recordList = platAlarmRecordService.list(new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(PlatAlarmRecord::getAlarmType, PlatAlarmConfigEnum.AlarmTypeEnum.FALL.getValue())
.in(PlatAlarmRecord::getDeviceId, StreamUtil.mapId(platDeviceList, PlatDevice::getId))
.eq(PlatAlarmRecord::getElderIds, finalElderId)
.eq(PlatAlarmRecord::getMisinformationFlag, CommonEnum.NO.getValue())
.ge(PlatAlarmRecord::getAlarmDate, start)
......@@ -386,12 +353,6 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
);
voList.addAll(StreamUtil.map(recordList, i -> i.getAlarmDate().format(dateTimeFormatter)));
/* List<DeviceInfoContentFall> fallList = iotProductDeviceService.getDeviceLogByTimeRangeFall(e.getOriDeviceId(), 2 * 24 * 3600, start, end);
fallList = StreamUtil.filter(fallList, i -> DeviceInfoContentFallEnum.PersonStateEnum.FALL.getValue().equals(i.getProperties().getPersonState()));
*/
});
return voList.stream().distinct().collect(Collectors.toList());
}
......@@ -431,9 +392,6 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
voList.addAll(StreamUtil.map(spaceList, i -> {
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
// vo.setX(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
// vo.setY(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo.setTimestamp(i.getTimestamp());
vo.setDistance(i.getProperties().getDistance());
vo.setAngle(i.getProperties().getAngle());
......@@ -488,16 +446,9 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Override
public List<PlatElderBehaviorDistributionVO> behaviorDistributionInternal(PlatElderReportDTO platElderIdDTO, List<LocalDate> nowList) {
String elderId = platElderIdDTO.getElderId();
List<PlatDevice> platDeviceList = platElderRealTimeService.getSpaceDevice(elderId, platElderIdDTO.getDeviceId());
List<PlatDevice> fallDeviceList = platElderRealTimeService.getFallDevice(elderId, platElderIdDTO.getDeviceId());
platDeviceList.addAll(fallDeviceList);
if (CollectionUtils.isEmpty(platDeviceList)) {
return new ArrayList<>(10);
}
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId(), platElderIdDTO.getTenantId());
if (platElder != null) {
elderId = platElder.getId();
}
......@@ -508,10 +459,8 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
List<PlatElderBehaviorDistributionVO> finalVoList = voList;
String finalElderId = elderId;
platDeviceList.forEach(e -> {
List<PlatDayDurationRecord> recordList = platDayDurationRecordService.list(new QueryWrapper<PlatDayDurationRecord>().lambda()
.eq(PlatDayDurationRecord::getDeviceId, e.getId())
.eq(StringUtils.isNotEmpty(finalElderId),PlatDayDurationRecord::getElderIds, finalElderId)
.eq(StringUtils.isNotEmpty(finalElderId), PlatDayDurationRecord::getElderIds, finalElderId)
.in(PlatDayDurationRecord::getDay, StreamUtil.map(nowList, dateTimeFormatter::format))
);
......@@ -524,7 +473,6 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
}));
});
voList.forEach(e -> {
if (StringUtils.isBlank(e.getAreaName())) {
......@@ -554,11 +502,7 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
public List<PlatElderBehaviorDistributionVO> behaviorDistribution(PlatElderReportDTO platElderIdDTO) {
LocalDate now = Optional.ofNullable(platElderIdDTO.getNow()).orElse(LocalDate.now());
LocalDateTime start = dayStartNow(now);
LocalDateTime end = dayEndNow(now);
return behaviorDistributionInternal(platElderIdDTO, Arrays.asList(now));
return behaviorDistributionInternal(platElderIdDTO, Collections.singletonList(now));
}
}
......@@ -4,25 +4,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.*;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.report.SleepTypeEnum;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.analysis.EvaluateReportVO;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.elder.*;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.service.saas.SaasDiseaseReportService;
import com.makeit.service.saas.SaasElderReportConfigService;
import com.makeit.service.saas.SaasSleepEvaluateReportService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.data.validate.CollectionUtils;
import com.makeit.utils.data.validate.MapUtil;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.time.LocalDateTimeUtils;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
......@@ -45,6 +38,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
......@@ -178,7 +172,7 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String elderId = platElderIdDTO.getElderId();
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId(), platElderIdDTO.getTenantId());
if (platElder != null) {
elderId = platElder.getId();
}
......@@ -249,7 +243,7 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String elderId = platElderIdDTO.getElderId();
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId(), platElderIdDTO.getTenantId());
if (platElder != null) {
elderId = platElder.getId();
}
......@@ -268,7 +262,8 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
Map<Integer, Map<String, List<PlatElderSleep>>> sleepMap = sleepList.stream().collect(Collectors.groupingBy(PlatElderSleep::getElderSleepType, Collectors.groupingBy(PlatElderSleep::getHappenDate)));
Map<String, PlatElderSleepAnalysis> sleepAnalysisMap = StreamUtil.toMap(sleepAnalysisList, PlatElderSleepAnalysis::getHappenDate);
Map<String, PlatElderSleepAnalysis> sleepAnalysisMap = sleepAnalysisList.stream().collect(Collectors.toMap(PlatElderSleepAnalysis::getHappenDate, Function.identity(),(v1,v2)->v1));
// Map<String, PlatElderSleepAnalysis> sleepAnalysisMap = StreamUtil.toMap(sleepAnalysisList, PlatElderSleepAnalysis::getHappenDate);
List<LocalDate> dateList = LocalDateTimeUtils.getDateSeries(weekStartDate, weekEndDate);
......@@ -333,7 +328,7 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String elderId = platElderIdDTO.getElderId();
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId(), platElderIdDTO.getTenantId());
if (platElder != null) {
elderId = platElder.getId();
}
......@@ -345,13 +340,19 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
);
int score = 0;
int br = 0;
int hr = 0;
if (CollectionUtils.isNotEmpty(breatheAnalyses)) {
score = StreamUtil.reduce(breatheAnalyses, e -> Integer.valueOf(e.getBreatheScore() + ""), 0, Integer::sum) / breatheAnalyses.size();
br = StreamUtil.reduce(breatheAnalyses, e -> Integer.valueOf(e.getAvgBreatheRate() + ""), 0, Integer::sum) / breatheAnalyses.size();
hr = StreamUtil.reduce(breatheAnalyses, e -> Integer.valueOf(e.getAvgHeartRate() + ""), 0, Integer::sum) / breatheAnalyses.size();
}
PlatElderHeartRespiratoryEvaluationVO platElderHeartRespiratoryEvaluationVO = new PlatElderHeartRespiratoryEvaluationVO();
platElderHeartRespiratoryEvaluationVO.setScore(score);
platElderHeartRespiratoryEvaluationVO.setHeartRate(hr);
platElderHeartRespiratoryEvaluationVO.setRespiratoryRate(br);
EvaluateReportVO evaluateReportVO = saasDiseaseReportService.getByScore(platElderHeartRespiratoryEvaluationVO.getScore());
if (evaluateReportVO != null) {
......@@ -412,12 +413,10 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
}
LambdaQueryWrapper<PlatElderBreatheDayStat> lambdaQueryWrapper = new QueryWrapper<PlatElderBreatheDayStat>().lambda();
lambdaQueryWrapper.ge(PlatElderBreatheDayStat::getDay, weekStartDate);
lambdaQueryWrapper.le(PlatElderBreatheDayStat::getDay, weekEndDate);
String finalDeviceId = deviceId;
//String finalOriDeviceId = oriDeviceId;
lambdaQueryWrapper.and(StringUtils.isNotBlank(platElderIdDTO.getElderId()) || StringUtils.isNotBlank(finalDeviceId) /*|| StringUtils.isNotBlank(finalOriDeviceId)*/, qw -> {
if (StringUtils.isNotBlank(platElderIdDTO.getElderId())) {
qw.eq(PlatElderBreatheDayStat::getElderId, platElderIdDTO.getElderId());
......@@ -425,9 +424,6 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
if (StringUtils.isNotBlank(finalDeviceId)) {
qw.or().eq(PlatElderBreatheDayStat::getDeviceId, finalDeviceId);
}
// if (StringUtils.isNotBlank(finalOriDeviceId)) {
// qw.or().eq(PlatElderBreatheDayStat::getOriDeviceId, finalOriDeviceId);
// }
});
lambdaQueryWrapper.eq(StringUtils.isNotBlank(platElderIdDTO.getTenantId()), BaseBusEntity::getTenantId,platElderIdDTO.getTenantId());
......
......@@ -26,7 +26,6 @@ import com.makeit.service.saas.SaasSleepAnalysisModelService;
import com.makeit.utils.StandardDeviationUtil;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.data.validate.CollectionUtils;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.redis.RedisUtil;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO;
......@@ -34,6 +33,7 @@ import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
......@@ -41,11 +41,9 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -69,8 +67,19 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
public static final String DEVICE_BR_DATA = "device:brhr:data:";
public static final String SLEEP_ANALYSIS_KEY = "saas:sleep:analysis";
public static final String DEVICE_SPACE_DATA = "device:space:data:";
public static final String DEVICE_FALL_DATA = "device:fall:data:";
public static final String DEVICE_BR_ANALYSIS = "device:brhr:analysis:";
public static final String SLEEP_ANALYSIS_THRESHOLD_KEY = "saas:sleep:analysis:threshold";
public static final String DEVICE_SPACE_TEMP_DATA = "device:space:tempData:";
public static final String DEVICE_FALL_TEMP_DATA = "device:fall:tempData:";
@Autowired
private PlatElderService platElderService;
......@@ -79,10 +88,6 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
@Autowired
private IotProductDeviceService iotProductDeviceService;
@Autowired
private PlatElderDayReportDayService platElderDayReportDayService;
@Autowired
private SaasSleepAnalysisModelService saasSleepAnalysisModelService;
@Autowired
......@@ -167,203 +172,220 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
}
private List<DeviceInfoContentSpace> getNowDataSpace(String elderId, String deviceId) {
List<PlatDevice> deviceList = getSpaceDevice(elderId, deviceId);
if (CollectionUtils.isEmpty(deviceList)) {
return null;
}
return deviceList.stream().map(e -> iotProductDeviceService.getLastDeviceLogSpace(e.getOriDeviceId(), 10)).filter(Objects::nonNull)
.collect(Collectors.toList());
}
private List<DeviceInfoContentFall> getNowDataFall(String elderId, String deviceId) {
List<PlatDevice> deviceList = getFallDevice(elderId, deviceId);
if (CollectionUtils.isEmpty(deviceList)) {
return null;
@Override
public PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO) {
PlatElderRealTimeNowVO platElderRealTimeNowVO = new PlatElderRealTimeNowVO();
PlatDevice platDevice = getBreathDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (platDevice == null) {
return platElderRealTimeNowVO;
}
return deviceList.stream().map(e -> iotProductDeviceService.getLastDeviceLogFall(e.getOriDeviceId(), 10)).filter(Objects::nonNull)
.collect(Collectors.toList());
long currentSecond = System.currentTimeMillis() / 1000;
boolean brNoPersonFlag = false;
String brResult = redisTemplate.opsForValue().get(DEVICE_BR_DATA + platDevice.getOriDeviceId());
if (brResult != null) {
JSONObject jsonObject = JSON.parseObject(brResult);
String person = jsonObject.getString("person");
String personState = jsonObject.getString("personState");
if (StringUtils.equals(person,"1")) {
// 判断是否在床睡觉
Integer sleepTimeActionThreshold = getSleepTimeActionThreshold();
long sleepTimeActionDuration = getSleepTimeActionDuration();
Set<String> dataSet = redisTemplate.opsForZSet().rangeByScore(DEVICE_BR_ANALYSIS + platDevice.getOriDeviceId(), currentSecond - sleepTimeActionDuration, currentSecond);
boolean empty = CollectionUtils.isNotEmpty(dataSet);
log.info("当前呼吸设备:{},大小:{}",platDevice.getOriDeviceId(),empty ? dataSet.size() : 0);
if (empty && dataSet.size() >= sleepTimeActionDuration * 0.9 ) {
boolean flag = dataSet.stream().allMatch(s -> {
JSONObject result = JSON.parseObject(s);
JSONObject properties = (JSONObject)result.get("properties");
Integer bodymove = Integer.valueOf(properties.getString("bodymove"));
return bodymove.compareTo(sleepTimeActionThreshold) <= 0 && properties.getInteger("person") == 1;
});
log.info("计算后睡眠集合大小:{}",dataSet.size());
if (flag) {
log.info("当前属于在床睡眠:" + platElderIdDTO.getElderId());
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.SLEEP.getValue());
return platElderRealTimeNowVO;
}
private void nowStatusOut(PlatElderRealTimeNowVO platElderRealTimeNowVO, PlatElderIdDTO platElderIdDTO) {
List<DeviceInfoContentSpace> deviceInfoContentSpaceList = getNowDataSpace(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
List<DeviceInfoContentFall> deviceInfoContentFallList = getNowDataFall(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (CollectionUtils.isEmpty(deviceInfoContentSpaceList) && CollectionUtils.isEmpty(deviceInfoContentFallList)) {
return;
}
// if (StreamUtil.allMatch(deviceInfoContentSpaceList, e -> DeviceInfoContentSpaceEnum.PersonStateEnum.NOBODY.getValue().equals(e.getProperties().getPersonState()))) {
// platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.OUT.getValue());
// }
Boolean spaceFlag = null;
Boolean fallFlag = null;
if (CollectionUtils.isNotEmpty(deviceInfoContentSpaceList)) {
spaceFlag = StreamUtil.allMatch(deviceInfoContentSpaceList, e -> DeviceInfoContentSpaceEnum.PersonStateEnum.NOBODY.getValue().equals(e.getProperties().getPersonState()));
}
if (CollectionUtils.isNotEmpty(deviceInfoContentFallList)) {
fallFlag = StreamUtil.allMatch(deviceInfoContentFallList, e -> DeviceInfoContentFallEnum.PersonStateEnum.NOBODY.getValue().equals(e.getProperties().getPersonState()));
// 在床运动
if (StringUtils.equals(personState,"1")) {
log.info("当前属于在床运动:" + platElderIdDTO.getElderId());
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.SPORT.getValue());
return platElderRealTimeNowVO;
}
List<Boolean> flagList = Stream.of(spaceFlag, fallFlag).filter(Objects::nonNull).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(flagList) && StreamUtil.allMatch(flagList, Boolean.TRUE::equals)) {
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.OUT.getValue());
// 在床静息
if (StringUtils.equals(personState,"2") || StringUtils.equals(personState,"3")) {
log.info("当前属于在床静息:" + platElderIdDTO.getElderId());
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.BED.getValue());
return platElderRealTimeNowVO;
}
} else {
brNoPersonFlag = true;
}
private void nowStatusRun(PlatElderRealTimeNowVO platElderRealTimeNowVO, PlatElderIdDTO platElderIdDTO, DeviceInfoContentBreathe nowDataBreathe, List<PlatElderCoordinateVO> coordinateList) {
if (nowDataBreathe == null) {
return;
} else {
log.info("当前呼吸设备没有上报数据直接返回:" + platElderIdDTO.getElderId());
redisTemplate.delete(DEVICE_BR_ANALYSIS + platDevice.getOriDeviceId());
return platElderRealTimeNowVO;
}
List<PlatDevice> spaceDeviceList = getSpaceDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
List<PlatDevice> fallDeviceList = getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
boolean sportFlag = true;
boolean flag = DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowDataBreathe.getProperties().getPersonState() + "");
if (!flag) {
return;
boolean spaceNoPersonFlag = false;
if (CollectionUtils.isEmpty(spaceDeviceList)) {
spaceNoPersonFlag = true;
}
if (CollectionUtils.isNotEmpty(coordinateList)) {
double v = StandardDeviationUtil.average(StreamUtil.map(coordinateList, e -> e.getDistance().doubleValue()));
if (new BigDecimal(v + "").compareTo(new BigDecimal(2)) > 0) {
platElderRealTimeNowVO.setStatus((PlatElderRealtimeReportEnum.NowStatus.RUN.getValue()));
for (PlatDevice device : spaceDeviceList) {
Set<String> dataSet = redisTemplate.opsForZSet().rangeByScore(DEVICE_SPACE_TEMP_DATA + device.getOriDeviceId(), currentSecond - 10,currentSecond);
if (CollectionUtils.isEmpty(dataSet)) {
log.info("空间设备当前没有上报数据直接返回");
spaceNoPersonFlag = true;
continue;
}
log.info("空间设备当前大小:{}",dataSet.size());
List<PlatElderCoordinateVO> voList = dataSet.stream().map(entity -> {
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
JSONObject result = JSON.parseObject(entity);
JSONObject properties = (JSONObject)result.get("properties");
String distance = properties.getString("distance");
String angle = properties.getString("angle");
vo.setX(Integer.parseInt(distance) * Math.cos(90 - Integer.parseInt(angle)));
vo.setY(Integer.parseInt(distance) * Math.sin(90 - Integer.parseInt(angle)));
int personState = properties.getInteger("personState");
vo.setPersonState(personState);
if (personState == 0) {
vo.setX(0.0);
vo.setY(0.0);
}
return vo;
}).collect(Collectors.toList());
spaceNoPersonFlag = voList.stream().allMatch(e -> e.getPersonState() == 0);
if (spaceNoPersonFlag) {
continue;
}
Double[] doubleArrX = voList.stream().map(PlatElderCoordinateVO::getX).toArray(Double[]::new);
double x = StandardDeviationUtil.variance(doubleArrX);
boolean xFlag = new BigDecimal(x + "").compareTo(new BigDecimal(2)) > 0;
log.info("空间设备算出来X方差为:{},是否大于2:{},设备id:{}",x,xFlag,device.getOriDeviceId());
private void nowStatusRest(PlatElderRealTimeNowVO platElderRealTimeNowVO, PlatElderIdDTO platElderIdDTO, DeviceInfoContentBreathe nowDataBreathe, List<PlatElderCoordinateVO> coordinateList) {
Double[] doubleArrY = voList.stream().map(PlatElderCoordinateVO::getY).toArray(Double[]::new);
double y = StandardDeviationUtil.variance(doubleArrY);
boolean yFlag = new BigDecimal(y + "").compareTo(new BigDecimal(2)) > 0;
if (nowDataBreathe == null) {
return;
log.info("空间设备算出来Y方差为:{},是否大于2:{},设备id:{}",y,yFlag,device.getOriDeviceId());
if (xFlag && yFlag) {
log.info("当前属于空间设备离床运动:" + platElderIdDTO.getElderId());
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.RUN.getValue());
return platElderRealTimeNowVO;
} else {
sportFlag = false;
}
boolean flag = DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowDataBreathe.getProperties().getPersonState() + "");
if (!flag) {
return;
}
if (CollectionUtils.isNotEmpty(coordinateList)) {
double v = StandardDeviationUtil.average(StreamUtil.map(coordinateList, e -> e.getDistance().doubleValue()));
if (new BigDecimal(v + "").compareTo(new BigDecimal(2)) <= 0) {
platElderRealTimeNowVO.setStatus((PlatElderRealtimeReportEnum.NowStatus.RUN.getValue()));
boolean fallNoPersonFlag = false;
if (CollectionUtils.isEmpty(fallDeviceList)) {
fallNoPersonFlag = true;
}
for (PlatDevice device : fallDeviceList) {
Set<String> dataSet = redisTemplate.opsForZSet().rangeByScore(DEVICE_FALL_TEMP_DATA + device.getOriDeviceId(), currentSecond - 10, currentSecond);
if (CollectionUtils.isEmpty(dataSet)) {
log.info("跌倒设备当前没有上报数据直接返回");
fallNoPersonFlag = true;
continue;
}
log.info("跌倒设备当前大小:{}",dataSet.size());
List<PlatElderCoordinateVO> voList = dataSet.stream().map(entity -> {
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
JSONObject result = JSON.parseObject(entity);
JSONObject properties = (JSONObject)result.get("properties");
Object track = properties.get("track");
List<Integer> list = track == null ? Lists.newArrayList() : (List<Integer>) track;
vo.setX(CollectionUtils.isNotEmpty(list) ? list.get(1).doubleValue() : null);
vo.setY(CollectionUtils.isNotEmpty(list) ? list.get(2).doubleValue(): null);
int personState = properties.getInteger("personState");
vo.setPersonState(personState);
int person = properties.getIntValue("person");
vo.setPerson(person);
if (person == 0) {
vo.setX(0.0);
vo.setY(0.0);
}
return vo;
}).collect(Collectors.toList());
private void nowStatusSleepAndBed(PlatElderRealTimeNowVO platElderRealTimeNowVO, PlatElderIdDTO platElderIdDTO, DeviceInfoContentBreathe nowDataBreathe) {
if (nowDataBreathe == null) {
return;
boolean xFlag = false;
fallNoPersonFlag = voList.stream().allMatch(e -> e.getPerson() == 0);
if (fallNoPersonFlag) {
continue;
}
boolean flag = !DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowDataBreathe.getProperties().getPersonState() + "");
if (!flag) {
return;
Double[] doubleArrX = voList.stream().map(PlatElderCoordinateVO::getX).filter(Objects::nonNull).toArray(Double[]::new);
if (doubleArrX.length > 0) {
double x = StandardDeviationUtil.variance(doubleArrX);
xFlag = new BigDecimal(x + "").compareTo(new BigDecimal(2)) > 0;
log.info("跌倒设备算出来X方差为:{},是否大于2:{},设备id:{}",x,xFlag,device.getOriDeviceId());
}
SaasSleepAnalysisModel analysisModel = saasSleepAnalysisModelService.getOne(new QueryWrapper<SaasSleepAnalysisModel>().lambda()
.orderByDesc(BaseEntity::getCreateBy)
.last("limit 1"));
if (analysisModel == null) {
return;
boolean yFlag = false;
Double[] doubleArrY = voList.stream().map(PlatElderCoordinateVO::getY).filter(Objects::nonNull).toArray(Double[]::new);
if (doubleArrY.length > 0) {
double y = StandardDeviationUtil.variance(doubleArrY);
yFlag = new BigDecimal(y + "").compareTo(new BigDecimal(2)) > 0;
log.info("跌倒设备算出来Y方差为:{},是否大于2:{},设备id:{}",y,yFlag,device.getOriDeviceId());
}
BigDecimal sleepTimeActionDuration = new BigDecimal(analysisModel.getSleepTimeActionDuration() + "");
BigDecimal sleepTimeActionThreshold = new BigDecimal(analysisModel.getSleepTimeActionThreshold() + "");
LocalDateTime now = LocalDateTime.now();
LocalDateTime start = now.minusMinutes(sleepTimeActionDuration.multiply(new BigDecimal(60).setScale(0, RoundingMode.HALF_UP)).intValue());
PlatDevice platDevice = getBreathDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
List<DeviceInfoContentBreathe> breatheList = iotProductDeviceService.getDeviceLogByTimeRangeBreathe(platDevice.getOriDeviceId(), 2 * 24 * 3600, start, now);
if (CollectionUtils.isNotEmpty(breatheList)) {
if (StreamUtil.allMatch(breatheList, e -> new BigDecimal(e.getProperties().getBodymove()).compareTo(sleepTimeActionThreshold) <= 0)) {
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.SLEEP.getValue());
if (xFlag && yFlag) {
log.info("当前属于跌倒设备离床运动:" + platElderIdDTO.getElderId());
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.RUN.getValue());
return platElderRealTimeNowVO;
} else {
sportFlag = false;
}
}
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.BED.getValue());
if (!sportFlag) {
log.info("当前属于离床静息:" + platElderIdDTO.getElderId());
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.REST.getValue());
return platElderRealTimeNowVO;
}
@Override
public PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO) {
PlatElderRealTimeNowVO platElderRealTimeNowVO = new PlatElderRealTimeNowVO();
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.RUN.getValue());
PlatDevice platDevice = getBreathDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (platDevice == null) {
if (brNoPersonFlag && spaceNoPersonFlag && fallNoPersonFlag) {
log.info("所有设备都无人,判断为外出:" + platElderIdDTO.getElderId());
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.OUT.getValue());
return platElderRealTimeNowVO;
}
String brResult = redisTemplate.opsForValue().get(DEVICE_BR_DATA + platDevice.getOriDeviceId());
if (brResult != null) {
JSONObject jsonObject = JSON.parseObject(brResult);
String person = jsonObject.getString("person");
log.info("当前人员人员状态:{}",person);
if (StringUtils.equals(person,"1")) {
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.BED.getValue());
log.info("当前设备无状态匹配直接返回:" + platElderIdDTO.getElderId());
return platElderRealTimeNowVO;
}
}
return platElderRealTimeNowVO;
/* Object result = RedisUtil.get(ELDER_STATUS + platElderIdDTO.getElderId());
private Long getSleepTimeActionDuration() {
String sleepTimeActionDuration = "";
String result = redisTemplate.opsForValue().get(SLEEP_ANALYSIS_KEY);
if (result != null) {
return JSON.parseObject(result.toString(), PlatElderRealTimeNowVO.class);
sleepTimeActionDuration = result;
} else {
SaasSleepAnalysisModel analysisModel = saasSleepAnalysisModelService.getOne(new QueryWrapper<SaasSleepAnalysisModel>().lambda()
.orderByDesc(BaseEntity::getCreateBy)
.last("limit 1"));
redisTemplate.opsForValue().set(SLEEP_ANALYSIS_KEY,analysisModel.getSleepTimeActionDuration(),1,TimeUnit.DAYS);
sleepTimeActionDuration = analysisModel.getSleepTimeActionDuration();
}
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
//
if (deviceInfoContentBreathe == null) {
return platElderRealTimeNowVO;
BigDecimal s = new BigDecimal(sleepTimeActionDuration).multiply(new BigDecimal(3600));
return s.longValue();
}
//platElderRealTimeNowVO.setStatus(deviceInfoContentBreathe.getProperties().getPersonState() + "");
nowStatusOut(platElderRealTimeNowVO, platElderIdDTO);
LocalDateTime now = LocalDateTime.now();
LocalDateTime start = now.minusSeconds(10);
List<PlatElderCoordinateVO> coordinateList = platElderDayReportDayService.coordinateList(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId(), start, now);
nowStatusRun(platElderRealTimeNowVO, platElderIdDTO, deviceInfoContentBreathe, coordinateList);
nowStatusRest(platElderRealTimeNowVO, platElderIdDTO, deviceInfoContentBreathe, coordinateList);
nowStatusSleepAndBed(platElderRealTimeNowVO, platElderIdDTO, deviceInfoContentBreathe);
// if(StringUtils.isBlank(platElderRealTimeNowVO.getStatus())){
// platElderRealTimeNowVO.setStatus();
// }
platElderRealTimeNowVO.setHeartRate(deviceInfoContentBreathe.getProperties().getHr());
platElderRealTimeNowVO.setRespiratoryRate(deviceInfoContentBreathe.getProperties().getBr());
platElderRealTimeNowVO.setBodyMove(deviceInfoContentBreathe.getProperties().getBodymove());
RedisUtil.set(ELDER_STATUS + platElderIdDTO.getElderId(), JSON.toJSONString(platElderRealTimeNowVO), 10, TimeUnit.SECONDS);
return platElderRealTimeNowVO;
*/
private Integer getSleepTimeActionThreshold() {
Integer sleepTimeActionThreshold;
String result = redisTemplate.opsForValue().get(SLEEP_ANALYSIS_THRESHOLD_KEY);
if (result != null) {
sleepTimeActionThreshold = Integer.parseInt(result);
} else {
SaasSleepAnalysisModel analysisModel = saasSleepAnalysisModelService.getOne(new QueryWrapper<SaasSleepAnalysisModel>().lambda()
.orderByDesc(BaseEntity::getCreateBy)
.last("limit 1"));
redisTemplate.opsForValue().set(SLEEP_ANALYSIS_THRESHOLD_KEY,analysisModel.getSleepTimeActionThreshold(),1,TimeUnit.DAYS);
sleepTimeActionThreshold = Integer.parseInt(analysisModel.getSleepTimeActionThreshold());
}
return sleepTimeActionThreshold;
}
@Override
......@@ -388,70 +410,15 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
vo.setHeartRate(0);
vo.setRespiratoryRate(0);
vo.setBody(0);
vo.setStatus(PlatElderRealtimeReportEnum.NowStatus.RUN.getValue());
} else {
vo.setHeartRate(Integer.valueOf(jsonObject.getString("hr")));
vo.setRespiratoryRate(Integer.valueOf(jsonObject.getString("br")));
vo.setBody(Integer.valueOf(jsonObject.getString("bodymove")));
vo.setStatus(PlatElderRealtimeReportEnum.NowStatus.BED.getValue());
}
}
return vo;
}
return vo;
/* DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (deviceInfoContentBreathe == null) {
return vo;
}
int heartRate = deviceInfoContentBreathe.getProperties().getHr();
int respiratoryRate = deviceInfoContentBreathe.getProperties().getBr();
int body = deviceInfoContentBreathe.getProperties().getBodymove();
int person = deviceInfoContentBreathe.getProperties().getPerson();
if (heartRate == 0) {
vo.setHeartRate(0);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5;
vo.setHeartRate(Math.max(heartRate + hrRange,0));
}
if (respiratoryRate == 0) {
vo.setRespiratoryRate(0);
} else {
int brRange = RandomUtils.nextInt(1, 7) - 3;
vo.setRespiratoryRate(Math.max(respiratoryRate + brRange,0));
}
if (body == 0) {
vo.setBody(body);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5;
vo.setBody(Math.max(body + hrRange,0));
}
vo.setStatus(person == 1 ? PlatElderRealtimeReportEnum.NowStatus.BED.getValue() : PlatElderRealtimeReportEnum.NowStatus.RUN.getValue());
return vo;*/
/* String brResult = redisTemplate.opsForList().rightPop(ELDER_BR_HR + platElderIdDTO.getElderId());
if (brResult != null) {
return JSON.parseObject(brResult,PlatElderRealTimeHeartRespiratoryVO.class);
}
if (deviceInfoContentBreathe == null) {
return new PlatElderRealTimeHeartRespiratoryVO();
}
int count = 10;
for (int i = 0; i < count; i++) {
}
redisTemplate.opsForList().leftPush(ELDER_BR_HR + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeHeartRespiratoryVO));
}
return JSON.parseObject(redisTemplate.opsForList().rightPop(ELDER_BR_HR + platElderIdDTO.getElderId()),PlatElderRealTimeHeartRespiratoryVO.class);*/
/*
PlatElderRealTimeHeartRespiratoryVO platElderRealTimeHeartRespiratoryVO = new PlatElderRealTimeHeartRespiratoryVO();
platElderRealTimeHeartRespiratoryVO.setTime(LocalDateTime.now());
platElderRealTimeHeartRespiratoryVO.setHeartRate(deviceInfoContentBreathe.getProperties().getHr());
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(deviceInfoContentBreathe.getProperties().getBr());*/
//return platElderRealTimeHeartRespiratoryVO;
}
@Override
......@@ -517,8 +484,10 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
if (jsonObject != null) {
vo.setDeviceId(platDevice.getId());
vo.setOriDeviceId(platDevice.getOriDeviceId());
if (Integer.parseInt(jsonObject.getString("mode")) != 0) {
vo.setDistance(Integer.valueOf(jsonObject.getString("distance")));
vo.setAngle(Integer.valueOf(jsonObject.getString("angle")));
}
vo.setPersonState(Integer.valueOf(jsonObject.getString("personState")));
vo.setMount(Integer.valueOf(jsonObject.getString("mount")));
vo.setType(1);
......
......@@ -5,10 +5,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.entity.platform.elder.PlatElderReportMonth;
import com.makeit.mapper.platform.elder.PlatElderReportMonthMapper;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.elder.*;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.service.platform.elder.PlatElderDayReportWeekService;
import com.makeit.service.platform.elder.PlatElderReportMonthService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.time.LocalDateTimeUtils;
......@@ -33,27 +31,9 @@ import java.util.List;
@Service
public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReportMonthMapper, PlatElderReportMonth> implements PlatElderReportMonthService {
@Autowired
private PlatElderRealTimeService platElderRealTimeService;
@Autowired
private PlatElderDayReportWeekService platElderDayReportWeekService;
@Autowired
private PlatTenantService platTenantService;
@Autowired
private PlatElderService platElderService;
@Autowired
private PlatElderSleepAnalysisService platElderSleepAnalysisService;
@Autowired
private PlatAlarmRecordService platAlarmRecordService;
@Autowired
private IotProductDeviceService iotProductDeviceService;
public LocalDate monthStartDate(PlatElderReportDTO platElderIdDTO) {
return monthStartDate(platElderIdDTO.getYear(), platElderIdDTO.getMonth());
......
package com.makeit.service.platform.elder.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
......@@ -8,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
......@@ -399,17 +402,17 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
return vo;
});
JoinUtil.join(list, platSpaceService, Arrays.asList(
PlatElderExportVO::getStreetSpaceId,
PlatElderExportVO::getBuildingSpaceId,
PlatElderExportVO::getUnitSpaceId,
PlatElderExportVO::getFloorSpaceId
), PlatSpace::getId, Arrays.asList(
(e, s) -> e.setStreetSpaceName(s.getName()),
(e, s) -> e.setBuildingSpaceName(s.getName()),
(e, s) -> e.setUnitSpaceName(s.getName()),
(e, s) -> e.setFloorSpaceName(s.getName())
));
// JoinUtil.join(list, platSpaceService, Arrays.asList(
// PlatElderExportVO::getStreetSpaceId,
// PlatElderExportVO::getBuildingSpaceId,
// PlatElderExportVO::getUnitSpaceId,
// PlatElderExportVO::getFloorSpaceId
// ), PlatSpace::getId, Arrays.asList(
// (e, s) -> e.setStreetSpaceName(s.getName()),
// (e, s) -> e.setBuildingSpaceName(s.getName()),
// (e, s) -> e.setUnitSpaceName(s.getName()),
// (e, s) -> e.setFloorSpaceName(s.getName())
// ));
JoinUtil.join(list, platRoomService, PlatElderExportVO::getRoomId, PlatRoom::getId, (e, l) -> {
e.setRoomName(l.getName());
......@@ -419,9 +422,84 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
e.setBedName(l.getName());
});
handleExcelData(list, dbList);
ExcelUtil.export(response, "长者信息" + FileSuffixEnum.EXCEL.getSuffix(), "长者信息",PlatElderExportVO.class, list);
}
private void handleExcelData(List<PlatElderExportVO> list, List<PlatElder> dbList) {
if (CollUtil.isEmpty(list) || CollUtil.isEmpty(dbList)) {
return;
}
Map<String, PlatElder> platElderMap = StreamUtil.toMap(dbList, PlatElder::getId);
Set<String> placeList = new HashSet<>();
for (PlatElder platElder : dbList) {
if (StrUtil.isBlank(platElder.getSpacePath())) {
continue;
}
List<String> pathList = new ArrayList<>(Arrays.asList(platElder.getSpacePath().split(",")));
if (StrUtil.isNotBlank(platElder.getRoomId())) {
pathList.remove(platElder.getRoomId());
}
if (StrUtil.isNotBlank(platElder.getBedId())) {
pathList.remove(platElder.getBedId());
}
CollUtil.addAll(placeList, pathList);
}
Map<String, String> spaceMap = new HashMap<>();
if (CollUtil.isNotEmpty(placeList)) {
spaceMap = platSpaceService.listByIds(placeList).stream()
.collect(Collectors.toMap(PlatSpace::getId, PlatSpace::getName));
}
Map<String, String> finalSpaceMap = spaceMap;
list.forEach(e -> {
PlatElder platElder = platElderMap.get(e.getId());
if (platElder == null) {
return;
}
String spacePath = platElder.getSpacePath();
if (StrUtil.isBlank(spacePath)) {
e.setStreetSpaceName(null);
e.setBuildingSpaceName(null);
e.setUnitSpaceName(null);
e.setFloorSpaceName(null);
return;
}
List<String> pathList = new ArrayList<>(Arrays.asList(spacePath.split(",")));
if (StrUtil.isNotBlank(platElder.getRoomId())) {
pathList.remove(platElder.getRoomId());
}
if (StrUtil.isNotBlank(platElder.getBedId())) {
pathList.remove(platElder.getBedId());
}
if (pathList.size() >= 4) {
e.setStreetSpaceName(finalSpaceMap.get(pathList.get(0)));
e.setBuildingSpaceName(finalSpaceMap.get(pathList.get(1)));
e.setUnitSpaceName(finalSpaceMap.get(pathList.get(2)));
e.setFloorSpaceName(finalSpaceMap.get(pathList.get(3)));
}
if (pathList.size() == 3) {
e.setStreetSpaceName(finalSpaceMap.get(pathList.get(0)));
e.setBuildingSpaceName(finalSpaceMap.get(pathList.get(1)));
e.setUnitSpaceName(finalSpaceMap.get(pathList.get(2)));
e.setFloorSpaceName(null);
}
if (pathList.size() == 2) {
e.setStreetSpaceName(finalSpaceMap.get(pathList.get(0)));
e.setBuildingSpaceName(finalSpaceMap.get(pathList.get(1)));
e.setUnitSpaceName(null);
e.setFloorSpaceName(null);
}
if (pathList.size() == 1) {
e.setStreetSpaceName(finalSpaceMap.get(pathList.get(0)));
e.setBuildingSpaceName(null);
e.setUnitSpaceName(null);
e.setFloorSpaceName(null);
}
});
}
@Override
public void exportTemplate(HttpServletResponse response) {
ExcelUtil.exportTemplate(response, "长者信息导入模板" + FileSuffixEnum.EXCEL.getSuffix(), "长者信息",PlatElderImportDTO.class);
......@@ -1247,10 +1325,22 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
}
@Override
public PlatElder getByDeviceId(String deviceId) {
PlatRoomBedDevice platRoomBedDevice = platRoomBedDeviceService.getOne(new QueryWrapper<PlatRoomBedDevice>().lambda()
public PlatElder getByDeviceId(String deviceId, String tenantId) {
PlatDevice platDevice = platDeviceService.getOne(new QueryWrapper<PlatDevice>().lambda()
.eq(PlatDevice::getOriDeviceId, deviceId)
.eq(BaseBusEntity::getTenantId, tenantId));
PlatRoomBedDevice platRoomBedDevice;
if (platDevice == null) {
platRoomBedDevice = platRoomBedDeviceService.getOne(new QueryWrapper<PlatRoomBedDevice>().lambda()
.eq(PlatRoomBedDevice::getDeviceId, deviceId)
.eq(StringUtils.isNotEmpty(tenantId), BaseBusEntity::getTenantId, tenantId)
.last("limit 1"));
} else {
platRoomBedDevice = platRoomBedDeviceService.getOne(new QueryWrapper<PlatRoomBedDevice>().lambda()
.eq(PlatRoomBedDevice::getDeviceId, platDevice.getId())
.eq(StringUtils.isNotEmpty(tenantId), BaseBusEntity::getTenantId, tenantId)
.last("limit 1"));
}
if (platRoomBedDevice != null && StringUtils.isNotEmpty(platRoomBedDevice.getBedId())) {
PlatElder platElder = getOne(new QueryWrapper<PlatElder>().lambda()
.eq(PlatElder::getBedId, platRoomBedDevice.getBedId()));
......
......@@ -164,6 +164,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
DeviceInfoContentBreathe.Properties breatheProperties;
Integer bodymove;
int reportSize = deviceInfoContentBreathes.size();
// 记录总呼吸率和总心率
int maxBr = 0;
int minBr = 0;
......@@ -182,6 +183,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
boolean isMoveBed = true;
boolean awakeMinuteActionFlag = true; // 清醒每分钟体动是否满足要求
int noPersonCount = 0; // 无人跳过计数
int sleepDeepMinuteCount = 0; // 深睡每分钟体动和翻身次数
int sleepModerateAMinuteCount = 0; // 中度睡每分钟体动和翻身次数
for (DeviceInfoContentBreathe infoContentBreathe : deviceInfoContentBreathes) {
......@@ -191,6 +193,21 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
int br = breatheProperties.getBr();
int hr = breatheProperties.getHr();
Integer hasPerson = breatheProperties.getPerson(); // 0无人,1有人
if (breatheProperties.getPerson() == 0) {
noPersonCount++;
continue;
}
// 0和255直接跳过
if (breatheProperties.getHr() == 255 || breatheProperties.getHr() == 0 ) {
noPersonCount++;
continue;
}
if (breatheProperties.getBr() == 255 || breatheProperties.getBr() == 0) {
noPersonCount++;
continue;
}
if (bodymove > actionThreshold) {
bodymoveCount++;
}
......@@ -234,12 +251,15 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
hrBrCount++;
}
}
if (reportSize == noPersonCount) {
continue;
}
analysisVO.setTotalBr(totalBr);
analysisVO.setAvgBr(totalBr / 60);
analysisVO.setAvgBr(totalBr / reportSize);
analysisVO.setTotalHr(totalHr);
analysisVO.setAvgHr(totalHr / 60);
analysisVO.setAvgHr(totalHr / reportSize);
analysisVO.setMaxBr(maxBr);
analysisVO.setMinBr(minBr);
......@@ -277,12 +297,11 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
for (Map.Entry<String, AnalysisVO> entry : totalMap.entrySet()) {
AnalysisVO analysisVO = entry.getValue();
if (!analysisVO.getIsAction()) {
if (!analysisVO.getIsAction() && !analysisVO.getIsMoveBed()) {
if (StringUtils.isEmpty(startSleepTime)) {
startSleepTime = entry.getKey();
}
sleepMinute++;
continue;
}
if (StringUtils.isEmpty(startSleepTime) && sleepMinute == 0) {
continue;
......@@ -440,7 +459,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
TreeMap<String, AnalysisVO> sleepMap = entry.getValue();
for (Map.Entry<String, AnalysisVO> voEntry : sleepMap.entrySet()) {
AnalysisVO analysisVO = voEntry.getValue();
if (analysisVO.getAwakeMinuteActionFlag()) {
if (analysisVO.getAwakeMinuteActionFlag() || analysisVO.getIsMoveBed()) {
if (StringUtils.isEmpty(startAwakeTime)) {
startAwakeTime = voEntry.getKey();
}
......@@ -828,6 +847,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
platElderReportMonth.setRespiratoryExceptionCount(0);
platElderReportMonth.setHeartExceptionCount(0);
platElderReportMonth.setBehaviorExceptionCount(0);
platElderReportMonth.setOffBedExceptionCount(0);
platElderReportMonth.setHeartRate(80);
platElderReportMonth.setRespiratoryRate(20);
platElderReportMonth.setFailCount(0);
......
package com.makeit.service.platform.space.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
......@@ -10,7 +8,9 @@ import com.makeit.common.dto.StatusDTO;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.space.*;
import com.makeit.dto.platform.space.PlatBedEditDTO;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.space.PlatBedQueryDTO;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.space.PlatBed;
......@@ -33,12 +33,13 @@ import com.makeit.vo.platform.workstation.WorkStationHomeBedVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO;
import jodd.util.StringUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
......@@ -162,12 +163,11 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
@Override
public Page<PlatBedPanoramaVO> selectBySpaceIdAndStatus(PageReqDTO<PlatBedPanoramaDTO> pageReqDTO, PlatBedPanoramaDTO dto) {
List<String> typeOrgIdList = Lists.newArrayList();
List<String> choiceOrgIdList = Lists.newArrayList();
if (StringUtils.isNotEmpty(dto.getOrgType())) {
List<PlatOrg> platOrgList = platOrgService.list(new QueryWrapper<PlatOrg>().lambda().eq(PlatOrg::getType, dto.getOrgType()));
typeOrgIdList = StreamUtil.map(platOrgList, BaseEntity::getId);
}
PlatOrg platOrg = new PlatOrg();
platOrg.setType(dto.getOrgType());
List<PlatOrg> platOrgList = platOrgService.belongToScopeList(platOrg);
List<String> typeOrgIdList = StreamUtil.map(platOrgList, BaseEntity::getId);
if (StringUtil.isNotEmpty(dto.getOrgId())) {
choiceOrgIdList.addAll(Lists.newArrayList(dto.getOrgId().split(",")));
}
......@@ -194,13 +194,6 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
}
}
// 数据权限
if (StrUtil.isBlank(dto.getOrgId()) && StrUtil.isBlank(dto.getType())) {
//查询用户权限组织id
List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg());
orgIdList = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
}
return baseMapper.selectBySpaceIdAndStatus(new Page<>(pageReqDTO.getPage(),pageReqDTO.getLimit()),dto,orgIdList);
}
......
......@@ -34,6 +34,8 @@ import com.makeit.utils.user.plat.PlatUserUtil;
import com.makeit.utils.user.plat.PlatUserVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -53,6 +55,7 @@ import java.util.stream.Collectors;
* @Describe:
*/
@Service
@Slf4j
public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace> implements PlatSpaceService {
@Autowired
......@@ -145,12 +148,30 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
if (parentSpace!=null && parentSpace.getParentPath()!=null && parentSpace.getParentPath().contains(dto.getId())) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT);
}
// todo 编辑后层级大于4,不允许编辑 脏数据太多,待校验
// checkAndUpdateSonSpace(space);
this.updateById(space);
List<PlatRoom> platRoomList = platRoomService.listBySpaceId(space.getId());
List<String> lastSpaceIds = recursionLastSpaceIds(space.getId(), new ArrayList<>());
if (CollUtil.isEmpty(lastSpaceIds)) {
return;
}
List<PlatRoom> platRoomList = platRoomService.list(Wrappers.<PlatRoom>lambdaQuery().in(PlatRoom::getSpaceId, lastSpaceIds));
if (CollUtil.isEmpty(platRoomList)) {
return;
}
for (PlatRoom platRoom : platRoomList) {
platRoom.setSpacePath(dto.getParentPath() + "," + space.getId());
List<String> roomSpaceIds = recursionRoomId(platRoom.getSpaceId(), new ArrayList<>(), space.getId());
if(CollUtil.isEmpty(roomSpaceIds)){
return;
}
String join = String.join(",", CollUtil.reverse(roomSpaceIds));
log.info("房间id:{},对应的空间id:{},parentId:{}", platRoom.getId(), join, dto.getParentPath());
String roomSpacePath = dto.getParentPath() + "," + join;
log.info("roomSpacePath" + roomSpacePath);
platRoom.setSpacePath(roomSpacePath);
platRoomService.updateById(platRoom);
}
List<String> roomIds = platRoomList.stream().map(PlatRoom::getId).collect(Collectors.toList());
......@@ -168,12 +189,78 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return;
}
PlatRoom platRoom = roomMap.get(roomId);
e.setSpacePath(platRoom.getSpacePath() + "," + e.getBedId());
e.setSpacePath(platRoom.getSpacePath() + "," + e.getRoomId() + "," + e.getBedId());
platElderService.updateById(e);
});
}
}
private List<String> recursionLastSpaceIds(String spaceId, List<String> result) {
List<PlatSpace> platSpaces = this.list(Wrappers.<PlatSpace>lambdaQuery().eq(PlatSpace::getParentId, spaceId));
if (CollUtil.isNotEmpty(platSpaces)) {
platSpaces.forEach(p -> recursionLastSpaceIds(p.getId(), result));
} else {
result.add(spaceId);
return result;
}
return result;
}
private List<String> recursionRoomId(String roomSpaceId, List<String> result, String updateSpaceId) {
result.add(roomSpaceId);
if (roomSpaceId.equals(updateSpaceId)) {
return result;
}else {
PlatSpace platSpaces = this.getById(roomSpaceId);
recursionRoomId(platSpaces.getParentId(), result, updateSpaceId);
}
return result;
}
private void checkAndUpdateSonSpace(PlatSpace space) {
String parentPath = space.getParentPath();
int level = StrUtil.isBlank(parentPath) ? 0 : parentPath.split(",").length;
if (level > 3) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_OVER_LEVEL);
}
String spaceId = space.getId();
List<PlatSpace> platSpaceList = list(Wrappers.<PlatSpace>lambdaQuery()
.apply(StringUtils.isNotBlank(spaceId), "find_in_set('" + spaceId + "',parent_path)"));
int sonLevel = 0;
if (CollUtil.isNotEmpty(platSpaceList)) {
final int[] maxLength = {1};
platSpaceList.forEach(s -> {
if (StrUtil.isBlank(s.getParentPath())) {
return;
}
String[] parentSpaceIds = s.getParentPath().split(",");
if (parentSpaceIds.length > maxLength[0]) {
maxLength[0] = parentSpaceIds.length;
}
});
sonLevel = maxLength[0];
}
if (level + sonLevel > 3) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_OVER_LEVEL);
}
// 更新下级空间的parentPath
if (CollUtil.isNotEmpty(platSpaceList)) {
platSpaceList.forEach(s -> {
if (StrUtil.isBlank(s.getParentPath())) {
return;
}
int indexOf = s.getParentPath().indexOf(spaceId);
if (indexOf == -1) {
return;
}
String oldSpacePath = s.getParentPath().substring(indexOf);
s.setParentPath(parentPath + "," + oldSpacePath);
updateById(s);
});
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void del(String id) {
......
......@@ -42,8 +42,6 @@ import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.service.platform.workstation.WorkStationService;
import com.makeit.service.saas.SaasModelManageService;
import com.makeit.service.saas.SaasSleepAnalysisModelService;
import com.makeit.shengwang.agora.service.ShengwangService;
import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO;
import com.makeit.utils.StandardDeviationUtil;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
......@@ -281,12 +279,11 @@ public class WorkStationServiceImpl implements WorkStationService {
for (WorkStationInstitutionRoomVO vo : roomVOList) {
vo.setPathName(vo.getPathName() + "-" + vo.getRoomName());
List<PlatDevice> deviceList = Lists.newArrayList();
if (bedMap.get(vo.getRoomId()) != null) {
List<WorkStationInstitutionBedVO> roomBedVos = bedMap.get(vo.getRoomId());
//获取告警类型及老人状态
for(WorkStationInstitutionBedVO r : roomBedVos){
List<PlatDevice> deviceList = Lists.newArrayList();
List<PlatRoomBedDevice> platRoomBedDevices = roomDeviceMap.get(r.getRoomId());
if (CollectionUtils.isNotEmpty(platRoomBedDevices)) {
List<String> tempDeviceIdList = StreamUtil.map(platRoomBedDevices, PlatRoomBedDevice::getDeviceId);
......@@ -305,9 +302,9 @@ public class WorkStationServiceImpl implements WorkStationService {
PlatElderIdDTO platElderIdDTO = new PlatElderIdDTO();
platElderIdDTO.setElderId(r.getElderId());
PlatElderRealTimeHeartRespiratoryVO heartRespiratoryVO = platElderRealTimeService.heartRespiratory(platElderIdDTO);
r.setElderStatus(heartRespiratoryVO.getStatus());
PlatElderRealTimeNowVO realTimeNowVO = platElderRealTimeService.nowStatus(platElderIdDTO);
r.setElderStatus(realTimeNowVO.getStatus());
PlatRoomBedDevice platRoomBedDevice = bedDeviceMap.get(r.getBedId());
if (platRoomBedDevice != null) {
PlatDevice platDevice = deviceMap.get(platRoomBedDevice.getDeviceId());
......@@ -421,6 +418,8 @@ public class WorkStationServiceImpl implements WorkStationService {
typeMap.put(a.getAlarmType(), PlatAlarmRecordType.FALL.getName());
} else if(PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue().equals(a.getAlarmType())){
typeMap.put(a.getAlarmType(), PlatAlarmRecordType.BEHAVIOR.getName());
} else if (PlatAlarmConfigEnum.AlarmTypeEnum.OFF_BED.getValue().equals(a.getAlarmType())) {
typeMap.put(a.getAlarmType(), PlatAlarmRecordType.OFF_BED.getName());
}
map.put(e, typeMap);
......@@ -437,6 +436,8 @@ public class WorkStationServiceImpl implements WorkStationService {
typeMap.put(a.getAlarmType(), PlatAlarmRecordType.FALL.getName());
} else if(PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue().equals(a.getAlarmType())){
typeMap.put(a.getAlarmType(), PlatAlarmRecordType.BEHAVIOR.getName());
} else if (PlatAlarmConfigEnum.AlarmTypeEnum.OFF_BED.getValue().equals(a.getAlarmType())) {
typeMap.put(a.getAlarmType(), PlatAlarmRecordType.OFF_BED.getName());
}
map.put(e, typeMap);
}
......@@ -619,7 +620,8 @@ public class WorkStationServiceImpl implements WorkStationService {
platElderIdDTO.setElderId(vo.getElderId());
PlatElderRealTimeHeartRespiratoryVO respiratoryVO = platElderRealTimeService.heartRespiratory(platElderIdDTO);
vo.setElderStatus(respiratoryVO.getStatus());
PlatElderRealTimeNowVO realTimeNowVO = platElderRealTimeService.nowStatus(platElderIdDTO);
vo.setElderStatus(realTimeNowVO.getStatus());
vo.setHeartRate(respiratoryVO.getHeartRate());
vo.setRespiratoryRate(respiratoryVO.getRespiratoryRate());
......
package com.makeit.service.saas;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.entity.saas.SaasPidManage;
/**
* <p>
* 声网pid管理 服务类
* </p>
*
* @author eugene young
* @since 2023-12-13
*/
public interface SaasPidManageService extends IService<SaasPidManage> {
PageVO<SaasPidManage> pageList(PageReqDTO<SaasPidManage> pageReqDTO);
void add(SaasPidManage dto);
void delete(String id);
}
package com.makeit.service.saas.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.entity.saas.SaasPidManage;
import com.makeit.mapper.saas.SaasPidManageMapper;
import com.makeit.service.saas.SaasPidManageService;
import com.makeit.utils.data.convert.PageUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* <p>
* 声网pid管理 服务实现类
* </p>
*
* @author eugene young
* @since 2023-12-13
*/
@Service
public class SaasPidManageServiceImpl extends ServiceImpl<SaasPidManageMapper, SaasPidManage> implements SaasPidManageService {
@Resource
private SaasPidManageMapper saasPidManageMapper;
@Override
public PageVO<SaasPidManage> pageList(PageReqDTO<SaasPidManage> pageReqDTO) {
SaasPidManage dto = pageReqDTO.getData();
Page<SaasPidManage> p = PageUtil.toMpPage(pageReqDTO);
LambdaQueryWrapper<SaasPidManage> lambdaQueryWrapper = new QueryWrapper<SaasPidManage>().lambda()
.like(StringUtils.isNotEmpty(dto.getPid()), SaasPidManage::getPid, dto.getPid())
.eq(StringUtils.isNotEmpty(dto.getStatus()), SaasPidManage::getStatus, dto.getStatus());
Page<SaasPidManage> saasPidManagePage = saasPidManageMapper.selectPage(p, lambdaQueryWrapper);
List<SaasPidManage> records = saasPidManagePage.getRecords();
return PageUtil.toPageVO(records, saasPidManagePage);
}
@Override
public void add(SaasPidManage dto) {
dto.setStatus("1");
dto.setUsedCredit(dto.getTotalCredit() - dto.getAvailableCredit());
save(dto);
}
@Override
public void delete(String id) {
delete(id);
}
}
......@@ -14,10 +14,15 @@ import com.makeit.utils.user.common.CommonUserVO;
import com.makeit.utils.user.saas.SaasUserUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;
import static com.makeit.service.platform.elder.impl.PlatElderRealTimeServiceImpl.SLEEP_ANALYSIS_KEY;
import static com.makeit.service.platform.elder.impl.PlatElderRealTimeServiceImpl.SLEEP_ANALYSIS_THRESHOLD_KEY;
/**
* <p>
......@@ -32,6 +37,8 @@ public class SaasSleepAnalysisModelServiceImpl extends ServiceImpl<SaasSleepAnal
@Autowired
private SaasModelManageService saasModelManageService;
@Autowired
private StringRedisTemplate redisTemplate;
@Override
public SaasSleepAnalysisModel view(String id) {
......@@ -54,5 +61,8 @@ public class SaasSleepAnalysisModelServiceImpl extends ServiceImpl<SaasSleepAnal
saasModelManageService.updateEntity(dto.getId(),"sleep");
redisTemplate.opsForValue().set(SLEEP_ANALYSIS_KEY,entity.getSleepTimeActionDuration(),1, TimeUnit.DAYS);
redisTemplate.opsForValue().set(SLEEP_ANALYSIS_THRESHOLD_KEY,entity.getSleepTimeActionThreshold(),1,TimeUnit.DAYS);
}
}
......@@ -121,7 +121,8 @@ public class PlatElderCenterWechatServiceImpl implements PlatElderCenterWechatSe
PlatElderIdDTO platElderIdDTO = new PlatElderIdDTO();
platElderIdDTO.setElderId(vo.getElderId());
PlatElderRealTimeHeartRespiratoryVO heartRespiratoryVO = platElderRealTimeService.heartRespiratory(platElderIdDTO);
vo.setElderStatus(heartRespiratoryVO.getStatus());
PlatElderRealTimeNowVO realTimeNowVO = platElderRealTimeService.nowStatus(platElderIdDTO);
vo.setElderStatus(realTimeNowVO.getStatus());
vo.setHeartRate(heartRespiratoryVO.getHeartRate());
vo.setRespiratoryRate(heartRespiratoryVO.getRespiratoryRate());
}
......@@ -199,21 +200,9 @@ public class PlatElderCenterWechatServiceImpl implements PlatElderCenterWechatSe
PlatElderIdDTO platElderIdDTO = new PlatElderIdDTO();
platElderIdDTO.setElderId(r.getElderId());
PlatElderRealTimeHeartRespiratoryVO respiratoryVO = platElderRealTimeService.heartRespiratory(platElderIdDTO);
r.setElderStatus(respiratoryVO.getStatus());
/*PlatElderRealTimeNowVO nowStatus = platElderRealTimeService.nowStatus(platElderIdDTO);
if(nowStatus.getStatus()!=null){
DeviceInfoContentBreathe deviceInfoContentBreathe = workStationService.getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowStatus.getStatus())) {
r.setElderStatus(WorkStationStatusEnum.NowStatus.OUT.getValue());
} else if (nowStatus.getBodyMove() != null && nowStatus.getBodyMove() > turnedThreshold) {
r.setElderStatus(WorkStationStatusEnum.NowStatus.TURNED.getValue());
} else {
List<PlatElderCoordinateVO> coordinateList = platElderDayReportDayService.coordinateList(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId(), start, now);
workStationService.nowStatusRest(r, platElderIdDTO, deviceInfoContentBreathe, coordinateList);
workStationService.nowStatusSleep(r, platElderIdDTO, deviceInfoContentBreathe);
}
}*/
PlatElderRealTimeNowVO realTimeNowVO = platElderRealTimeService.nowStatus(platElderIdDTO);
r.setElderStatus(realTimeNowVO.getStatus());
}
}
vo.setList(roomBedVos);
......
......@@ -43,8 +43,6 @@ public class PlatLoginWechatServiceImpl implements PlatLoginWechatService {
PlatUser platUser = platUserService.getOne(new QueryWrapper<PlatUser>().lambda()
.eq(PlatUser::getAccount, loginDTO.getAccount())
.or()
.eq(PlatUser::getMobile, loginDTO.getAccount())
);
if (platUser == null) {
......
......@@ -69,6 +69,7 @@ public class AlarmConfigCacheUtil implements ApplicationRunner {
if (StringUtils.equals(platDevice.getCategory(), PlatDeviceEnum.CategoryEnum.HEART.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.OFF_BED.getValue()));
}
if (StringUtils.equals(platDevice.getCategory(), PlatDeviceEnum.CategoryEnum.FALL.getValue())) {
set.add(this.get(platDevice.getOrgId() , PlatAlarmConfigEnum.AlarmTypeEnum.FALL.getValue()));
......
......@@ -30,7 +30,7 @@ public class PlatAlarmRecordVO extends BaseTenantDTO {
@ApiModelProperty(value = "通知家属 数据字典 1、同步通知 2 可选通知 3 不通知")
private String notifyRelation;
@ApiModelProperty(value = "告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常")
@ApiModelProperty(value = "告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常,5 离床异常")
private String alarmType;
@ApiModelProperty(value = "告警时间")
......@@ -72,4 +72,8 @@ public class PlatAlarmRecordVO extends BaseTenantDTO {
private String deviceId;
private PlatDevice device;
@ApiModelProperty(value = "是否存在未读")
private Boolean isUnWechatRead;
@ApiModelProperty(value = "是否存在未处理")
private Boolean statusFlag;
}
......@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel("租户端部门 查询")
@Data
public class PlatOrgQueryDTO extends BaseOrgDTO {
......@@ -18,4 +20,7 @@ public class PlatOrgQueryDTO extends BaseOrgDTO {
@ApiModelProperty(value = "字典类型 1-居家 2-机构")
private String type;
@ApiModelProperty(value = "机构id", hidden = true)
private List<String> orgIds;
}
......@@ -3,6 +3,7 @@ package com.makeit.vo.platform.elder.realtime;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
......@@ -18,6 +19,8 @@ public class PlatElderCoordinateVO {
private Integer distance;
@ApiModelProperty("空间人感:0表示无人,1表示活动, 2表示微动 ,3表示静止 ,跌倒设备:0无人,1跌倒")
private Integer personState;
@ApiModelProperty("跌倒设备:0无人,1跌倒")
private Integer person;
@ApiModelProperty("1 表示空间, 2 表示跌倒")
private Integer type;
......@@ -31,5 +34,9 @@ public class PlatElderCoordinateVO {
@ApiModelProperty("跌倒设备轨迹")
private List<Integer> track;
@ApiModelProperty("x")
private Double x;
@ApiModelProperty("y")
private Double y;
}
......@@ -9,13 +9,5 @@ public class PlatElderRealTimeNowVO {
@ApiModelProperty("状态")
private String status;
@ApiModelProperty("心率")
private Integer heartRate;
@ApiModelProperty("呼吸率")
private Integer respiratoryRate;
@ApiModelProperty("体动")
private Integer bodyMove;
}
......@@ -22,5 +22,8 @@ public class PlatElderBehaviorExceptionRecordVO {
@ApiModelProperty("时长")//min 或者 s
private Integer duration;
@ApiModelProperty(value = "告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常, 5 离床异常")
private String alarmType;
}
......@@ -35,5 +35,8 @@ public class PlatElderReportMonthVO {
@ApiModelProperty("行为异常次数")
private Integer behaviorExceptionCount;
@ApiModelProperty(value = "离床异常次数")
private Integer offBedExceptionCount;
}
......@@ -43,14 +43,12 @@
<if test="param.tenantId != null and param.tenantId != ''">
and pd.tenant_id = #{param.tenantId}
</if>
<choose>
<when test="param.active !=null and param.active !='' and param.active == 1">
<if test="param.active !=null and param.active == 1">
and pd.device_license is not null
</when>
<when test="param.active !=null and param.active !='' and param.active == 0">
</if>
<if test="param.active !=null and param.active == 0">
and pd.device_license is null
</when>
</choose>
</if>
<if test="param.orgIds != null and param.orgIds.size() > 0 ">
AND pd.org_id in
<foreach collection="param.orgIds" item="item" separator="," open="(" close=")" index="">
......
......@@ -67,5 +67,9 @@
</where>
</select>
<select id="listAll" resultType="com.makeit.entity.platform.auth.PlatUser">
SELECT id, mobile, email, account, id FROM plat_user WHERE del_flag = '0'
</select>
</mapper>
......@@ -5,8 +5,11 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Objects;
@Component
@ConfigurationProperties("mqtt")
......@@ -16,7 +19,12 @@ public class MqttConfig {
private MqttPushClient mqttPushClient;
@Autowired
private IotTokenService iotTokenService;
@Autowired
private StringRedisTemplate redisTemplate;
public static final String DEVICE_BR_ANALYSIS = "device:brhr:analysis:";
public static final String DEVICE_SPACE_TEMP_DATA = "device:space:tempData:";
public static final String DEVICE_FALL_TEMP_DATA = "device:fall:tempData:";
private String username;
private String password;
private String hostUrl;
......@@ -52,6 +60,10 @@ public class MqttConfig {
mqttPushClient.connect(hostUrl, clientId, username, password, timeout, keepalive);
// 订阅主题
mqttPushClient.subscribe(defaultTopic, 0);
redisTemplate.delete(Objects.requireNonNull(redisTemplate.keys(DEVICE_BR_ANALYSIS + "*")));
redisTemplate.delete(Objects.requireNonNull(redisTemplate.keys(DEVICE_SPACE_TEMP_DATA + "*")));
redisTemplate.delete(Objects.requireNonNull(redisTemplate.keys(DEVICE_FALL_TEMP_DATA + "*")));
return mqttPushClient;
}
......
......@@ -2,18 +2,25 @@ package com.makeit.mqtt;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.common.entity.BaseEntity;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.enums.DeviceState;
import com.makeit.module.iot.vo.DeviceInfo;
import com.makeit.module.iot.vo.HeaderInfo;
import com.makeit.service.platform.alarm.PlatAlarmConfigService;
import com.makeit.service.platform.alarm.alarmStrategy.IAlarm;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.saas.SaasSleepAnalysisModelService;
import com.makeit.utils.AlarmConfigCacheUtil;
import com.makeit.utils.DeviceCacheUtil;
import com.makeit.utils.redis.RedisUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
......@@ -26,8 +33,11 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
......@@ -38,8 +48,22 @@ public class PushCallback implements MqttCallback {
public static final String DEVICE_BR_DATA = "device:brhr:data:";
public static final String DEVICE_SPACE_DATA = "device:space:data:";
public static final String DEVICE_FALL_DATA = "device:fall:data:";
public static final String DEVICE_OFF_BED_DATA = "device:off_bed:data:";
public static final String SLEEP_ANALYSIS_KEY = "saas:sleep:analysis";
public static final String DEVICE_BR_ANALYSIS = "device:brhr:analysis:";
public static final String DEVICE_SPACE_TEMP_DATA = "device:space:tempData:";
public static final String DEVICE_FALL_TEMP_DATA = "device:fall:tempData:";
public static final String DEVICE_OFF_BED_TEMP_DATA = "device:off_bed:tempData:";
public static final String DEVICE_WRITE_PROPERTY_KEY = "device:write_property:";
public static final String REPORT_PROPERTY = "REPORT_PROPERTY";
public static final String WRITE_PROPERTY = "WRITE_PROPERTY";
public static final String WRITE_PROPERTY_REPLY = "WRITE_PROPERTY_REPLY";
@Autowired
private MqttConfig mqttConfig;
......@@ -56,6 +80,10 @@ public class PushCallback implements MqttCallback {
private PlatDeviceService platDeviceService;
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private SaasSleepAnalysisModelService saasSleepAnalysisModelService;
@Resource
private PlatAlarmConfigService alarmConfigService;
@Override
......@@ -78,6 +106,7 @@ public class PushCallback implements MqttCallback {
DeviceInfo device = JSON.parseObject(payload, DeviceInfo.class);
// todo
syncProperties(device);
checkAlarm(device);
}
......@@ -88,6 +117,39 @@ public class PushCallback implements MqttCallback {
}
/**
* IOT端设备属性修改后同步
* @param device
*/
public void syncProperties(DeviceInfo device) {
if (!(WRITE_PROPERTY.equals(device.getMessageType()) || WRITE_PROPERTY_REPLY.equals(device.getMessageType()))) {
return;
}
// 记录修改的属性
String redisKey = DEVICE_WRITE_PROPERTY_KEY + device.getMessageId();
if (WRITE_PROPERTY.equals(device.getMessageType())) {
JSONObject properties = device.getProperties();
RedisUtil.set(redisKey, properties, 10, TimeUnit.SECONDS);
}
// 收到修改属性回复
if (WRITE_PROPERTY_REPLY.equals(device.getMessageType())) {
JSONObject properties = RedisUtil.get(redisKey);
if (properties == null) {
return;
}
String key = properties.keySet().stream().findFirst().orElse("key");
JSONObject replayProperties = device.getProperties();
String success = replayProperties.getString(key);
if (!"0".equals(success)) {
return;
}
CompletableFuture.runAsync(() -> {
platDeviceService.syncIotProperties(device.getDeviceId(), properties);
RedisUtil.delete(redisKey);
}); // 要加线程池
}
}
/**
* 触发告警耗时 3.07s
* 未触发告警耗时 0.08s
* @param device
......@@ -97,16 +159,25 @@ public class PushCallback implements MqttCallback {
public void checkAlarm(DeviceInfo device) {
HeaderInfo headers = device.getHeaders();
List<HeaderInfo.Bind> bindings = headers.getBindings();
// TODO 先这样判断
Long timestamp = device.getTimestamp();
long currentSecond = System.currentTimeMillis() / 1000;
// 先通过产品名称判断
if (REPORT_PROPERTY.equals(device.getMessageType()) && headers.getProductName().contains("呼吸")) {
cacheBrDeviceData(device, currentSecond);
redisTemplate.opsForValue().set(DEVICE_BR_DATA + device.getDeviceId(),JSON.toJSONString(device.getProperties()),
5000, TimeUnit.MILLISECONDS);
}
if (REPORT_PROPERTY.equals(device.getMessageType()) && headers.getProductName().contains("空间")) {
cacheSpaceFallDeviceData(DEVICE_SPACE_TEMP_DATA, device, currentSecond);
redisTemplate.opsForValue().set(DEVICE_SPACE_DATA + device.getDeviceId(),JSON.toJSONString(device.getProperties()),
5000, TimeUnit.MILLISECONDS);
}
if (REPORT_PROPERTY.equals(device.getMessageType()) && headers.getProductName().contains("跌倒")) {
cacheSpaceFallDeviceData(DEVICE_FALL_TEMP_DATA, device, currentSecond);
redisTemplate.opsForValue().set(DEVICE_FALL_DATA + device.getDeviceId(),JSON.toJSONString(device.getProperties()),
5000, TimeUnit.MILLISECONDS);
}
......@@ -120,9 +191,6 @@ public class PushCallback implements MqttCallback {
for (HeaderInfo.Bind binding : bindings) {
try {
String iot_tenantId = binding.getId();
StopWatch stopWatch = new StopWatch();
stopWatch.start("checkAlarm-1");
JSONObject properties = device.getProperties();
//iot设备id
......@@ -156,10 +224,6 @@ public class PushCallback implements MqttCallback {
}
}
}
stopWatch.stop();
logger.info(stopWatch.prettyPrint());
}catch (Exception e){
logger.error("告警异常pushCallback:",e);
}
......@@ -168,7 +232,36 @@ public class PushCallback implements MqttCallback {
}
private void cacheSpaceFallDeviceData(String deviceSpaceTempData, DeviceInfo device, long currentSecond) {
long maxSize = 10L;
String key = deviceSpaceTempData + device.getDeviceId();
redisTemplate.opsForZSet().add(key,JSON.toJSONString(device),currentSecond);
redisTemplate.expire(key,60,TimeUnit.SECONDS);
}
private void cacheBrDeviceData(DeviceInfo device, long currentSecond) {
// 缓存呼吸设备某段时间的数据,hash 最大长度 duration
String key = DEVICE_BR_ANALYSIS + device.getDeviceId();
long duration = getSleepTimeActionDuration();
redisTemplate.opsForZSet().add(key,JSON.toJSONString(device),currentSecond);
redisTemplate.expire(key,duration + 180,TimeUnit.SECONDS);
}
private Long getSleepTimeActionDuration() {
String sleepTimeActionDuration = "";
String result = redisTemplate.opsForValue().get(SLEEP_ANALYSIS_KEY);
if (result != null) {
sleepTimeActionDuration = result;
} else {
SaasSleepAnalysisModel analysisModel = saasSleepAnalysisModelService.getOne(new QueryWrapper<SaasSleepAnalysisModel>().lambda()
.orderByDesc(BaseEntity::getCreateBy)
.last("limit 1"));
redisTemplate.opsForValue().set(SLEEP_ANALYSIS_KEY,analysisModel.getSleepTimeActionDuration(),1,TimeUnit.DAYS);
sleepTimeActionDuration = analysisModel.getSleepTimeActionDuration();
}
BigDecimal s = new BigDecimal(sleepTimeActionDuration).multiply(new BigDecimal(3600));
return s.longValue();
}
}
......@@ -62,10 +62,6 @@ mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
logging:
level:
root: debug
file:
filePath: file
......
......@@ -69,6 +69,11 @@ storage:
type: local
url: https://saas.qa.insightica.cn/api/${file.filePath}
logging:
level:
root: info
config: classpath:logback-spring-test.xml
# aliBaseDir: point
# aliEndpoint: obs.cn-south-1.myhuaweicloud.com
# aliAccessKeyId: HY7KT4GKCOGSRCHLXBAR
......
......@@ -8,7 +8,7 @@
value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{appName}] [%X{profile}] [%X{traceId:-},%X{spanId:-}] [%X{requestId}] [%X{userId}] [%thread] %-5level %logger{50} - %msg%n"/>
<springProfile name="prod">
<property name="logback.logdir" value="/home/group1_lzy/iot-server/logs"/>
<property name="logback.logdir" value="/opt/iot-platform-server/logs"/>
<property name="logback.appname" value="app"/>
</springProfile>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- 从高到地低 OFF 、 FATAL 、 ERROR 、 WARN 、 INFO 、 DEBUG 、 TRACE 、 ALL -->
<!-- 日志输出规则 根据当前ROOT 级别,日志输出时,级别高于root默认的级别时 会输出 -->
<!-- 以下 每个配置的 filter 是过滤掉输出文件里面,会出现高级别文件,依然出现低级别的日志信息,通过filter 过滤只记录本级别的日志 -->
<!-- 属性描述 scan:性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。
debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>d1money-web-ys-ems</contextName>
<!-- 定义日志文件 输入位置 -->
<configuration>
<property name="logback.logdir" value="/opt/iot-platform-server/logs"/>
<property name="logback.appname" value="app"/>
<property name="pattern"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{appName}] [%X{profile}] [%X{traceId:-},%X{spanId:-}] [%X{requestId}] [%X{userId}] [%thread] %-5level %logger{50} - %msg%n"/>
<springProfile name="prod">
<property name="logback.logdir" value="/home/group1_lzy/iot-server/logs"/>
<!-- 日志最大的历史 30天 -->
<property name="maxHistory" value="180" />
<property name="maxFileSize" value="10MB" />
<!-- ERROR级别日志 -->
<!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 RollingFileAppender -->
<appender name="ERROR"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 过滤器,只记录WARN级别的日志 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
<property name="logback.appname" value="app"/>
</springProfile>
<springProfile name="test">
<property name="logback.logdir" value="/home/group1_lzy/iot-server/logs"/>
<property name="logback.appname" value="app"/>
</springProfile>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<encoder>
<pattern>${pattern}</pattern>
</encoder>
</appender>
<!-- info -->
<appender name="FILELOGGING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责出发滚动 -->
<file>${logback.logdir}/${logback.appname}/logging/logging.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志输出位置 可相对、和绝对路径 -->
<fileNamePattern>
${log_dir}/app_error.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<!-- 可选节点,控制保留的归档文件的最大数量,超出数量就删除旧文件假设设置每个月滚动,且<maxHistory>是6, 则只保存最近6个月的文件,删除之前的旧文件。注意,删除旧文件是,那些为了归档而创建的目录也会被删除 -->
<maxHistory>${maxHistory}</maxHistory>
<FileNamePattern>${logback.logdir}/${logback.appname}/logging/logging.%d{yyyy-MM-dd}.%i.log
</FileNamePattern>
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>${maxFileSize}</maxFileSize>
<maxFileSize>20MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 按照固定窗口模式生成日志文件,当文件大于20MB时,生成新的日志文件。窗口大小是1到3,当保存了3个归档文件后,将覆盖最早的日志。
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/.log.zip</fileNamePattern> <minIndex>1</minIndex>
<maxIndex>3</maxIndex> </rollingPolicy> -->
<!-- 查看当前活动文件的大小,如果超过指定大小会告知RollingFileAppender 触发当前活动文件滚动 <triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <maxFileSize>5MB</maxFileSize>
</triggeringPolicy> -->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
<pattern>${pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- INFO级别日志 appender -->
<appender name="INFO"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 过滤器,只记录INFO级别的日志 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- info -->
<appender name="FILEINFOLOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>${logback.logdir}/${logback.appname}/info/log_info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logback.logdir}/${logback.appname}/info/log_info.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>20MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>${pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- error -->
<appender name="FILEERRORLOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<file>${logback.logdir}/${logback.appname}/error/log_error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logback.logdir}/${logback.appname}/error/log_error.%d{yyyy-MM-dd}.%i.log
</FileNamePattern>
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>20MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>${pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- WARN -->
<appender name="FILEWARNLOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
<file>${logback.logdir}/${logback.appname}/warn/log_warn.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>
${log_dir}/app_info.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<!-- 日志最大的历史 30天 -->
<maxHistory>${maxHistory}</maxHistory>
<FileNamePattern>${logback.logdir}/${logback.appname}/warn/log_warn.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>${maxFileSize}</maxFileSize>
<maxFileSize>20MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
<pattern>${pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<logger name="java.sql.PreparedStatement" value="DEBUG" />
<logger name="java.sql.Connection" value="DEBUG" />
<logger name="java.sql.Statement" value="DEBUG" />
<logger name="com.ibatis" value="DEBUG" />
<logger name="com.ibatis.common.jdbc.SimpleDataSource" value="DEBUG" />
<logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG" />
<logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate"
value="DEBUG" />
<!-- root级别 DEBUG -->
<springProfile name="dev">
<root level="INFO">
<!-- 文件输出 -->
<appender-ref ref="ERROR" />
<appender-ref ref="INFO" />
<appender-ref ref="FILEINFOLOG"/>
<appender-ref ref="FILEERRORLOG"/>
<appender-ref ref="FILEWARNLOG"/>
</root>
<logger name="com.makeit" level="DEBUG" additivity="false">
<appender-ref ref="FILEINFOLOG"/>
<appender-ref ref="FILEERRORLOG"/>
<appender-ref ref="FILEWARNLOG"/>
</logger>
</springProfile>
<springProfile name="test">
<root level="INFO">
<appender-ref ref="FILEINFOLOG"/>
<appender-ref ref="FILEERRORLOG"/>
<appender-ref ref="FILEWARNLOG"/>
</root>
<logger name="com.makeit" level="DEBUG" additivity="false">
<appender-ref ref="FILEINFOLOG"/>
<appender-ref ref="FILEERRORLOG"/>
<appender-ref ref="FILEWARNLOG"/>
</logger>
</springProfile>
<springProfile name="prod">
<property name="logback.logdir" value="/home/project/jianfa-integral/logs"/>
<property name="logback.appname" value="app"/>
<root level="INFO">
<appender-ref ref="FILEINFOLOG"/>
<appender-ref ref="FILEERRORLOG"/>
<appender-ref ref="FILEWARNLOG"/>
</root>
<logger name="com.makeit" level="DEBUG" additivity="false">
<appender-ref ref="FILEINFOLOG"/>
<appender-ref ref="FILEERRORLOG"/>
<appender-ref ref="FILEWARNLOG"/>
</logger>
</springProfile>
</configuration>
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