Commit fb53228a by huangjy

Merge remote-tracking branch 'origin/dev'

parents 29f8fa76 69a9b144
Showing with 1339 additions and 145 deletions
......@@ -74,7 +74,7 @@ node {
}
dir(module) {
sh "/dependencies/apache-maven-3.8.6/bin/mvn -s /dependencies/apache-maven-3.8.6/conf/settings.xml clean install -Dmaven.test.skip=true"
sh "/dependencies/apache-maven-3.8.1/bin/mvn -s /dependencies/apache-maven-3.8.1/conf/settings.xml clean install -Dmaven.test.skip=true"
}
}
......
ALTER TABLE `plat_device_other`
ALTER TABLE `plat_device_other`
......@@ -20,4 +20,17 @@ ALTER TABLE `plat_elder_report_month`
ALTER TABLE `sys_api_secret`
CHANGE COLUMN `publicKey` `public_key` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '公钥' AFTER `platform`,
CHANGE COLUMN `privateKey` `private_key` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '私钥' AFTER `public_key`,
CHANGE COLUMN `orgId` `org_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构id' AFTER `private_key`;
\ No newline at end of file
CHANGE COLUMN `orgId` `org_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构id' AFTER `private_key`;
ALTER TABLE `dev_iot_yanglao_platform`.`plat_device_other`
ADD COLUMN `uuid` varchar(255) COMMENT '设备uuid' AFTER `secure_key`;
ALTER TABLE `plat_device`
ADD COLUMN `device_license` varchar(64) COMMENT '许可证' AFTER `end_date`,
ADD COLUMN `license_info` varchar(255) COMMENT '许可证信息' AFTER `license`;
ALTER TABLE `plat_device`
ADD COLUMN `expire_time` int8 COMMENT '过期时间' AFTER `license_info`,
ADD COLUMN `activation_time` int8 COMMENT '激活时间' AFTER `expire_time`;
\ No newline at end of file
......@@ -9,7 +9,9 @@ import com.makeit.dto.platform.device.PlatDeviceAttrDTO;
import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceNetAttrWechatDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.service.platform.device.PlatDeviceService;
......@@ -74,6 +76,13 @@ public class SaasDeviceController {
return ApiResponseUtils.success();
}
@ApiOperation("编辑设备网络属性 主要写入usrServerInfo信息")
@PostMapping("editDeviceNetInfo")
public ApiResponseEntity<?> editDeviceNetInfo(@RequestBody PlatDeviceNetAttrWechatDTO dto) {
platDeviceService.editDeviceNetInfo(dto);
return ApiResponseUtils.success();
}
@ApiOperation(value = "批量编辑设备属性",notes = "批量编辑属性,仅相同产品类型的设备可批量编辑属性,点击展示该产品类型的可编辑属性(呼吸心率设备不可编辑设备属性,空间可编辑雷达安装方式和雷达功能模式,跌倒可编辑雷达安装高度")
@PostMapping("batchEditProperties")
@TenantIdIgnore
......@@ -82,4 +91,12 @@ public class SaasDeviceController {
return ApiResponseUtils.success();
}
@ApiOperation("激活设备license")
@PostMapping("active")
@TenantIdIgnore
public ApiResponseEntity active(@RequestBody BaseIdDTO dto) {
platDeviceService.active(dto);
return ApiResponseUtils.success();
}
}
package com.makeit.controller.sys;
public class ElderController {
}
package com.makeit.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "shengwang")
public class ShengwangProperties {
private String appId;
private String appCertificate;
private String channelName;
private String account;
private String uid;
private String pid;
private String customerKey;
private String customerSecret;
private int tokenExpirationInSeconds;
private int privilegeExpirationInSeconds;
}
......@@ -147,8 +147,9 @@ public class IotOrgService extends IotCommonService{
List<DeviceInstanceEntity> deviceInstanceEntityList = JSONArray.parseArray(pagerResult.getData().toString()).toJavaList(DeviceInstanceEntity.class);
return deviceInstanceEntityList;
} else {
throw new RuntimeException("获取设备接口失败:{},responseMessage.getMessage()");
}
log.error("获取设备接口失败:{}",responseMessage.getMessage());
} catch (IOException e) {
log.error("调用:{}接口异常:{}",url,e.getMessage());
}
......
package com.makeit.shengwang.agora.dto;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(value="呼叫设备RTM", description="呼叫设备RTM")
public class PlatCallingDeviceDTO {
private String id;
private String userId;
}
package com.makeit.shengwang.agora.http;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.makeit.config.ShengwangProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
@Component
public class ShengwangHttpUtil {
@Autowired
private ShengwangProperties shengwangProperties;
public String active(String licenseKey) {
String plainCredentials = shengwangProperties.getCustomerKey() + ":" + shengwangProperties.getCustomerSecret();
String base64Credentials = new String(Base64.getEncoder().encode(plainCredentials.getBytes()));
// 创建 authorization header
String authorizationHeader = "Basic " + base64Credentials;
Map<String,String> reqMap = new HashMap<>();
reqMap.put("pid",shengwangProperties.getPid());
reqMap.put("licenseKey",licenseKey);
reqMap.put("appid",shengwangProperties.getAppId());
String toParams = HttpUtil.toParams(reqMap);
HttpRequest httpRequest = HttpUtil.createPost("https://api.agora.io/dabiz/license/v2/active?" + toParams);
String result = httpRequest
.header("Authorization", authorizationHeader)
.execute().body();
System.out.println(result);
return result;
}
}
package com.makeit.shengwang.agora.service;
import com.alibaba.fastjson.JSON;
import com.makeit.config.ShengwangProperties;
import com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO;
import com.makeit.shengwang.agora.rtm.RtmTokenBuilder2;
import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;
@Component
public class ShengwangService {
public static final String REDIS_DEVICE_CALL = "device::call";
@Autowired
private ShengwangProperties shengwangProperties;
@Autowired
private StringRedisTemplate redisTemplate;
public PlatAlarmCallDeviceVO callingDeviceAuthIgnoreRtm(PlatCallingDeviceDTO dto) {
String redisResult = redisTemplate.opsForValue().get(REDIS_DEVICE_CALL + dto.getUserId());
if (StringUtils.isNotBlank(redisResult)) {
return JSON.parseObject(redisResult,PlatAlarmCallDeviceVO.class);
}
PlatAlarmCallDeviceVO platAlarmCallDeviceVO = new PlatAlarmCallDeviceVO();
RtmTokenBuilder2 token = new RtmTokenBuilder2();
String result = token.buildToken(shengwangProperties.getAppId(), shengwangProperties.getAppCertificate(), dto.getUserId(), shengwangProperties.getTokenExpirationInSeconds());
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String format = String.format("%s:%s","RTM",now.format(dateTimeFormatter));
platAlarmCallDeviceVO.setAccessToken(result);
platAlarmCallDeviceVO.setChannelName(format);
platAlarmCallDeviceVO.setAppId(shengwangProperties.getAppId());
platAlarmCallDeviceVO.setUserId(dto.getUserId());
redisTemplate.opsForValue().set(REDIS_DEVICE_CALL + dto.getUserId(),JSON.toJSONString(platAlarmCallDeviceVO),
shengwangProperties.getTokenExpirationInSeconds(), TimeUnit.SECONDS);
return platAlarmCallDeviceVO;
}
}
package com.makeit.shengwang.agora.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(value="呼叫设备对象", description="呼叫设备")
public class PlatAlarmCallDeviceVO {
private String accessToken;
private String channelName;
private String userId;
private String deviceId;
private String appId;
}
package com.makeit.utils;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import org.apache.http.client.HttpClient;
import java.net.URI;
import java.util.Base64;
public class Base64Encoding {
// 客户 ID
final String customerKey = "b3b5f44e536a4fc191358926c6716b7b";
// 客户密钥
final String customerSecret = "bd81828a133140a58dfb04e9d80eba43";
public static void main(String[] args) {
Base64Encoding base64Encoding = new Base64Encoding();
base64Encoding.test();
}
public void test () {
// 拼接客户 ID 和客户密钥并使用 base64 编码
String plainCredentials = customerKey + ":" + customerSecret;
String base64Credentials = new String(Base64.getEncoder().encode(plainCredentials.getBytes()));
// 创建 authorization header
String authorizationHeader = "Basic " + base64Credentials;
System.out.println(authorizationHeader);
HttpRequest httpRequest = HttpUtil.createGet("https://api.agora.io/dev/v1/projects");
// 创建 HTTP 请求对象
String result = httpRequest
.header("Authorization", authorizationHeader)
.header("Content-Type", "application/json")
.execute().body();
// 发送 HTTP 请求
System.out.println(result);
}
}
......@@ -106,7 +106,7 @@ public class CodeGenerator {
// 使用重点 下列字段填写表名 运行方法
// strategy.setInclude("edu_teacher","..."); // 多表-逆向工程
strategy.setInclude("plat_elder_breathe_day_stat");
strategy.setInclude("plat_region_setting_fix","plat_elder_coordinate_record");
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
strategy.setTablePrefix(pc.getModuleName() + "_"); //生成实体属性时去掉表"_"前缀并且第一个字母大写 如:gmt_create -> gmtCreate
......
......@@ -7,7 +7,11 @@ 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.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO;
import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -62,6 +66,34 @@ public class PlatAlarmRecordController {
return ApiResponseUtils.success(count);
}
@ApiOperation("呼叫设备")
@PostMapping("callingDevice")
public ApiResponseEntity<PlatAlarmCallDeviceVO> callingDevice(@RequestBody PlatCallingDeviceDTO dto) {
return ApiResponseUtils.success(platAlarmRecordService.callingDevice(dto));
}
@ApiOperation("呼叫设备")
@PostMapping("callingDeviceAuthIgnore")
@AuthIgnore
@TenantIdIgnore
public ApiResponseEntity<PlatAlarmCallDeviceVO> callingDeviceAuthIgnore(@RequestBody PlatCallingDeviceDTO dto) {
return ApiResponseUtils.success(platAlarmRecordService.callingDevice(dto));
}
@ApiOperation("呼叫设备rtm")
@PostMapping("callingDeviceAuthRtm")
public ApiResponseEntity<PlatAlarmCallDeviceVO> callingDeviceAuthRtm(@RequestBody PlatCallingDeviceDTO dto) {
return ApiResponseUtils.success(platAlarmRecordService.callingDeviceAuthIgnoreRtm(dto));
}
@ApiOperation("呼叫设备rtm")
@PostMapping("callingDeviceAuthIgnoreRtm")
@AuthIgnore
@TenantIdIgnore
public ApiResponseEntity<PlatAlarmCallDeviceVO> callingDeviceAuthIgnoreRtm(@RequestBody PlatCallingDeviceDTO dto) {
return ApiResponseUtils.success(platAlarmRecordService.callingDeviceAuthIgnoreRtm(dto));
}
// @Autowired
// private MailMsgSender mailMsgSender;
// @Autowired
......
package com.makeit.module.controller.children.device;
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.dto.wechat.device.PlatChildDeviceDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.vo.platform.device.PlatChildDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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>
* 设备 前端控制器
* </p>
*
* @author eugene young
* @since 2023-09-05
*/
@Api(tags = "子女段小程序-设备")
@RestController
@RequestMapping("/children/plat/device")
public class PlatDeviceChildrenController {
@Autowired
private PlatDeviceService platDeviceService;
@ApiOperation("分页列表")
@PostMapping("page")
public ApiResponseEntity<PageVO<PlatChildDeviceListVO>> page(@RequestBody PageReqDTO<PlatChildDeviceDTO> pageReqDTO) {
return ApiResponseUtils.success(platDeviceService.pageChild(pageReqDTO));
}
@ApiOperation("详情")
@PostMapping("view")
public ApiResponseEntity<PlatDeviceViewVO> view(@RequestBody BaseIdDTO baseIdDTO) {
return ApiResponseUtils.success(platDeviceService.view(baseIdDTO.getId()));
}
@ApiOperation("修改wifi信息")
@PostMapping("modifyWifiInfo")
public ApiResponseEntity<?> modifyWifiInfo(@Validated @RequestBody PlatDeviceSetupDTO dto) {
platDeviceService.modifyWifiInfo(dto);
return ApiResponseUtils.success();
}
}
......@@ -7,15 +7,18 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.device.PlatDeviceAttrDTO;
import com.makeit.dto.platform.device.PlatDeviceBindOrgDTO;
import com.makeit.dto.platform.device.PlatDeviceEditDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceNetAttrWechatDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.task.IotSyncTask;
import com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO;
import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO;
import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceViewVO;
import io.swagger.annotations.Api;
......@@ -64,19 +67,13 @@ public class PlatDeviceController {
return ApiResponseUtils.success(platDeviceService.view(baseIdDTO.getId()));
}
@Autowired
private IotSyncTask iotSyncTask;
@ApiOperation("手动同步")
@PostMapping("iotSyncTask")
@AuthIgnore
@TenantIdIgnore
public ApiResponseEntity<Void> iotSyncTask(@RequestBody BaseIdDTO baseIdDTO) {
//iotSyncTask.savePlatDevice();
@ApiOperation("划拨组织")
@PostMapping("bindOrg")
public ApiResponseEntity<PlatDeviceViewVO> bindOrg(@RequestBody PlatDeviceBindOrgDTO platDeviceBindOrgDTO) {
platDeviceService.bindOrg(platDeviceBindOrgDTO);
return ApiResponseUtils.success();
}
@ApiOperation("产品下拉")
@PostMapping("productList")
public ApiResponseEntity<List<PlatDevice>> productList(@RequestBody PlatDeviceQueryDTO dto) {
......@@ -89,13 +86,20 @@ public class PlatDeviceController {
return ApiResponseUtils.success(platDeviceService.readDeviceProperties(dto));
}
@ApiOperation("编辑设备属性 主要写入usrServerInfo信息")
@ApiOperation("编辑设备属性 ")
@PostMapping("editDeviceProperties")
public ApiResponseEntity<?> editDeviceProperties(@RequestBody PlatDeviceAttrWechatDTO dto) {
platDeviceService.editDeviceProperties(dto);
return ApiResponseUtils.success();
}
@ApiOperation("编辑设备网络属性 主要写入usrServerInfo信息")
@PostMapping("editDeviceNetInfo")
public ApiResponseEntity<?> editDeviceNetInfo(@RequestBody PlatDeviceNetAttrWechatDTO dto) {
platDeviceService.editDeviceNetInfo(dto);
return ApiResponseUtils.success();
}
@ApiOperation(value = "批量编辑设备属性",notes = "批量编辑属性,仅相同产品类型的设备可批量编辑属性,点击展示该产品类型的可编辑属性(呼吸心率设备不可编辑设备属性,空间可编辑雷达安装方式和雷达功能模式,跌倒可编辑雷达安装高度")
@PostMapping("batchEditProperties")
......@@ -103,5 +107,20 @@ public class PlatDeviceController {
platDeviceService.batchEditProperties(dto);
return ApiResponseUtils.success();
}
@ApiOperation("设备呼叫设备")
@PostMapping("callingDevice")
public ApiResponseEntity<PlatAlarmCallDeviceVO> callingDevice(@RequestBody PlatCallingDeviceDTO dto) {
return ApiResponseUtils.success(platDeviceService.callingDevice(dto));
}
@ApiOperation("设备获取登录RTMtoken")
@PostMapping("getDeviceRtmToken")
@AuthIgnore
@TenantIdIgnore
public ApiResponseEntity<PlatAlarmCallDeviceVO> getDeviceRtmToken(@RequestBody PlatCallingDeviceDTO dto) {
return ApiResponseUtils.success(platDeviceService.getDeviceRtmToken(dto));
}
}
......@@ -75,6 +75,14 @@ public class PlatElderSleepController {
return ApiResponseUtils.success();
}
@ApiOperation("测试")
@PostMapping("test5")
@AuthIgnore
public ApiResponseEntity<Void> coordinateRecordTask() {
platElderReportTask.coordinateRecordTask();
return ApiResponseUtils.success();
}
@ApiOperation("编辑设备属性")
@PostMapping("editDeviceProperties")
@AuthIgnore
......
package com.makeit.dto.platform.device;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* <p>
* 设备
* </p>
*
* @author eugene young
* @since 2023-09-05
*/
@Data
@ApiModel(value = "设备划拨组织对象", description = "设备划拨组织")
public class PlatDeviceBindOrgDTO {
@ApiModelProperty(value = "设备id集合")
private List<String> idList;
@ApiModelProperty(value = "组织id")
@NotBlank(message = "组织id不能为空")
private String orgId;
}
......@@ -43,6 +43,7 @@ public class PlatDeviceQueryDTO extends BaseTenantDTO {
private List<String> orgIds;
private String spaceId;
private String elderId;
}
......@@ -41,7 +41,7 @@ public class PlatElderImportDTO extends BaseTenantDTO {
@ApiModelProperty(value = "小区/社区/街道空间id")
private String streetSpaceId;
@ExcelProperty({BIG_TITLE, "小区"})
@ExcelProperty({BIG_TITLE, "一级空间"})
@ApiModelProperty(value = "小区/社区/街道空间名称")
private String streetSpaceName;
......@@ -49,7 +49,7 @@ public class PlatElderImportDTO extends BaseTenantDTO {
@ApiModelProperty(value = "楼栋空间id")
private String buildingSpaceId;
@ExcelProperty({BIG_TITLE, "楼栋"})
@ExcelProperty({BIG_TITLE, "二级空间"})
@ApiModelProperty(value = "楼栋空间名称")
private String buildingSpaceName;
......@@ -57,7 +57,7 @@ public class PlatElderImportDTO extends BaseTenantDTO {
@ApiModelProperty(value = "单元空间id")
private String unitSpaceId;
@ExcelProperty({BIG_TITLE, "单元"})
@ExcelProperty({BIG_TITLE, "三级空间"})
@ApiModelProperty(value = "单元空间名称")
private String unitSpaceName;
......@@ -65,7 +65,7 @@ public class PlatElderImportDTO extends BaseTenantDTO {
@ApiModelProperty(value = "楼层id")
private String floorSpaceId;
@ExcelProperty({BIG_TITLE, "楼层"})
@ExcelProperty({BIG_TITLE, "四级空间"})
@ApiModelProperty(value = "楼层id")
private String floorSpaceName;
......
package com.makeit.dto.wechat.device;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 设备
* </p>
*
* @author eugene young
* @since 2023-09-05
*/
@Data
@ApiModel(value = "子女端设备列表", description = "子女端设备列表DTO")
public class PlatChildDeviceDTO {
@ApiModelProperty(value = "长者id")
private String elderId;
}
......@@ -46,6 +46,8 @@ public class PlatDeviceSetupDTO extends BaseTenantDTO {
private String secureId;
@ApiModelProperty(value = "密钥Key")
private String secureKey;
@ApiModelProperty(value = "设备uuid")
private String uuid;
@ApiModelProperty(value = "组织id")
private String orgId;
......
......@@ -73,6 +73,14 @@ public class PlatDevice extends BaseBusEntity {
@ApiModelProperty(value = "组织路径")
private String orgPath;
@ApiModelProperty(value = "许可证")
private String deviceLicense;
@ApiModelProperty(value = "许可证信息")
private String licenseInfo;
@ApiModelProperty(value = "过期时间")
private Long expireTime;
@ApiModelProperty(value = "激活时间")
private Long activationTime;
@ApiModelProperty(value = "设备类型 0-呼吸心率雷达 1-空间人体雷达 2-跌倒检测雷达")
private String category;
......
......@@ -59,5 +59,7 @@ public class PlatDeviceOther extends BaseBusEntity {
private String secureId;
@ApiModelProperty(value = "密钥Key")
private String secureKey;
@ApiModelProperty(value = "设备uuid")
private String uuid;
}
package com.makeit.entity.platform.elder;
import com.makeit.common.entity.BaseBusEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 长者坐标记录
* </p>
*
* @author eugene young
* @since 2023-11-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="PlatElderCoordinateRecord对象", description="长者坐标记录")
public class PlatElderCoordinateRecord extends BaseBusEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "设备Id")
private String deviceId;
@ApiModelProperty(value = "设备Id")
private String iotDeviceId;
@ApiModelProperty(value = "设备Id")
private String elderId;
@ApiModelProperty(value = "人体目标距离雷达位置")
private Integer distance;
@ApiModelProperty(value = "空间人感:0表示无人,1表示活动, 2表示微动 ,3表示静止 ,跌倒设备:0无人,1跌倒")
private Integer personState;
@ApiModelProperty(value = "1 表示空间, 2 表示跌倒")
private Integer type;
@ApiModelProperty(value = "人体目标偏离雷达法线角度范围:±60,单位°")
private Integer angle;
@ApiModelProperty(value = "安装方式")
private Integer mount;
@ApiModelProperty(value = "跌倒设备轨迹")
private String track;
@ApiModelProperty(value = "上报时间")
private Long reportTime;
}
package com.makeit.entity.platform.space;
import com.makeit.common.entity.BaseBusEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 区域设置固化
* </p>
*
* @author eugene young
* @since 2023-11-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="PlatRegionSettingFix对象", description="区域设置固化")
public class PlatRegionSettingFix extends BaseBusEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "安装方式 1-顶装 0-侧装")
private String installType;
@ApiModelProperty(value = "设备朝向 0-上 1-下 2-左 3-右")
private String toward;
@ApiModelProperty(value = "区域名称")
private String regionName;
@ApiModelProperty(value = "区域定位")
private String regionRange;
@ApiModelProperty(value = "房间门定位")
private String roomRange;
@ApiModelProperty(value = "设备定位")
private String equipmentRange;
@ApiModelProperty(value = "设备Id")
private String deviceId;
@ApiModelProperty(value = "长者id")
private String elderId;
@ApiModelProperty(value = "当前日期 yyyy-mm-dd")
private String happenDate;
@ApiModelProperty(value = "房间id")
private String roomId;
@ApiModelProperty(value = "背景色")
private String background;
}
package com.makeit.mapper.platform.elder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.platform.elder.PlatElderCoordinateRecord;
/**
* <p>
* 长者坐标记录 Mapper 接口
* </p>
*
* @author eugene young
* @since 2023-11-15
*/
public interface PlatElderCoordinateRecordMapper extends BaseMapper<PlatElderCoordinateRecord> {
}
package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.platform.space.PlatRegionSettingFix;
/**
* <p>
* 区域设置固化 Mapper 接口
* </p>
*
* @author eugene young
* @since 2023-11-15
*/
public interface PlatRegionSettingFixMapper extends BaseMapper<PlatRegionSettingFix> {
}
......@@ -9,6 +9,8 @@ import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO;
import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
/**
......@@ -67,4 +69,8 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> {
Integer unreadCount(PlatAlarmRecordQueryDTO dto);
void misinformation(String id);
PlatAlarmCallDeviceVO callingDevice(PlatCallingDeviceDTO dto);
PlatAlarmCallDeviceVO callingDeviceAuthIgnoreRtm(PlatCallingDeviceDTO id);
}
......@@ -8,12 +8,12 @@ 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.google.common.collect.Maps;
import com.makeit.common.dto.BaseIdDTO;
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.config.ShengwangProperties;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig;
......@@ -35,12 +35,18 @@ import com.makeit.service.platform.alarm.PlatAlarmConfigService;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderChildrenInfoService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.space.PlatRegionSettingService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO;
import com.makeit.shengwang.agora.media.RtcTokenBuilder2;
import com.makeit.shengwang.agora.rtm.RtmTokenBuilder2;
import com.makeit.shengwang.agora.service.ShengwangService;
import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
......@@ -56,11 +62,14 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
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;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
......@@ -74,6 +83,7 @@ import java.util.stream.Collectors;
@Slf4j
public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMapper, PlatAlarmRecord>
implements PlatAlarmRecordService {
@Autowired
private PlatAlarmConfigService platAlarmConfigService;
......@@ -98,6 +108,12 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
private PlatTenantService platTenantService;
@Autowired
private PlatOrgService platOrgService;
@Autowired
private PlatDeviceService platDeviceService;
@Autowired
private ShengwangProperties shengwangProperties;
@Autowired
private ShengwangService shengwangService;
@Override
......@@ -567,4 +583,34 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
// todo 误报结果写入设备
}
@Override
public PlatAlarmCallDeviceVO callingDevice(PlatCallingDeviceDTO dto) {
PlatAlarmCallDeviceVO platAlarmCallDeviceVO = new PlatAlarmCallDeviceVO();
PlatAlarmRecord platAlarmRecord = getById(dto.getId());
if (platAlarmRecord == null) {
throw new RuntimeException("告警记录为空:" + dto.getId());
}
String deviceId = platAlarmRecord.getDeviceId();
PlatDevice platDevice = platDeviceService.getById(deviceId);
if (platDevice == null) {
throw new RuntimeException("找不到告警关联的设备,设备已解绑" + deviceId);
}
platAlarmCallDeviceVO.setDeviceId(platDevice.getOriDeviceId());
platAlarmCallDeviceVO.setAppId(shengwangProperties.getAppId());
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String channelName = String.format("%s:%s","RTC",now.format(dateTimeFormatter));
RtcTokenBuilder2 token = new RtcTokenBuilder2();
String result = token.buildTokenWithUid(shengwangProperties.getAppId(), shengwangProperties.getAppCertificate(), channelName, 0, RtcTokenBuilder2.Role.ROLE_SUBSCRIBER,
shengwangProperties.getTokenExpirationInSeconds(), shengwangProperties.getPrivilegeExpirationInSeconds());
platAlarmCallDeviceVO.setAccessToken(result);
platAlarmCallDeviceVO.setChannelName(channelName);
return platAlarmCallDeviceVO;
}
@Override
public PlatAlarmCallDeviceVO callingDeviceAuthIgnoreRtm(PlatCallingDeviceDTO dto) {
return shengwangService.callingDeviceAuthIgnoreRtm(dto);
}
}
......@@ -403,10 +403,23 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
String isTenant = userVOCanNull.getIsTenant();
//如果是租户账号 则有所有权限 返回最顶级
if (StringUtils.equals(isTenant, CommonEnum.YES.getValue())) {
boolean typeFlag = StringUtils.isNotEmpty(param.getType());
boolean nameFlag = StringUtils.isNotEmpty(param.getName());
boolean statusFlag = StringUtils.isNotEmpty(param.getStatus());
List<PlatOrg> orgList = this.list(new LambdaQueryWrapper<PlatOrg>()
.eq(StringUtils.isNotEmpty(param.getType()), PlatOrg::getType, param.getType())
.eq(typeFlag, PlatOrg::getType, param.getType())
.like(nameFlag, PlatOrg::getName, param.getName())
.eq(statusFlag, PlatOrg::getStatus, param.getStatus())
.eq(PlatOrg::getStatus, CommonEnum.YES.getValue())
);
if (typeFlag || nameFlag) {
Map<String, List<PlatOrg>> parentIdMap = orgList.stream().collect(Collectors.groupingBy(PlatOrg::getParentId));
orgList.forEach(vo -> {
List<PlatOrg> childList = parentIdMap.get(vo.getId());
vo.setChildren(childList);
});
return orgList;
}
return getOrgTree(orgList, Collections.singletonList(TenantIdUtil.getTenantId()));
}
......@@ -414,6 +427,8 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
Set<String> orgIdList = getOrgIdListByUserId(userVOCanNull.getId());
List<PlatOrg> orgList = this.list(new LambdaQueryWrapper<PlatOrg>()
.eq(StringUtils.isNotEmpty(param.getType()), PlatOrg::getType, param.getType())
.like(StringUtils.isNotEmpty(param.getName()), PlatOrg::getName, param.getName())
.eq(StringUtils.isNotEmpty(param.getStatus()), PlatOrg::getStatus, param.getStatus())
.in(BaseEntity::getId, orgIdList).eq(PlatOrg::getStatus, CommonEnum.YES.getValue()));
if (CollectionUtils.isEmpty(orgList)) {
return new ArrayList<>();
......
......@@ -91,9 +91,12 @@ implements PlatRoleService {
List<PlatRole> tntRoleList = list(listWrapper(dto));
List<PlatRoleDTOVO> rolVOList = BeanDtoVoUtils.listVo(tntRoleList, PlatRoleDTOVO.class);
JoinUtil.join(rolVOList, platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> r.setDeptName(e.getName()));
JoinUtil.join(rolVOList, platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
r.setDeptName(e.getName());
r.setOrgPath(e.getPath()+","+e.getId());
});
return BeanDtoVoUtils.listVo(tntRoleList, PlatRoleDTOVO.class);
return rolVOList;
}
@Override
......@@ -106,8 +109,10 @@ implements PlatRoleService {
List<PlatRoleDTOVO> tntUserVOList = BeanDtoVoUtils.listVo(pageList.getRecords(), PlatRoleDTOVO.class);
JoinUtil.join(tntUserVOList, platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> r.setDeptName(e.getName()));
JoinUtil.join(tntUserVOList, platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
r.setDeptName(e.getName());
r.setOrgPath(e.getPath()+","+e.getId());
});
return PageUtil.toPageVO(tntUserVOList, pageList);
}
......
......@@ -2,20 +2,18 @@ package com.makeit.service.platform.device;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.dataScreen.PlatDataScreenQueryDTO;
import com.makeit.dto.platform.device.PlatDeviceAttrDTO;
import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.dto.platform.device.PlatDeviceEditDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.platform.device.*;
import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceNetAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.dto.wechat.device.*;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO;
import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO;
import com.makeit.vo.platform.device.PlatChildDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceViewVO;
......@@ -78,4 +76,16 @@ public interface PlatDeviceService extends IService<PlatDevice> {
boolean updateDeviceStatus(String messageType, String deviceId, String iot_tenantId);
void editDeviceNetInfo(PlatDeviceNetAttrWechatDTO dto);
PageVO<PlatChildDeviceListVO> pageChild(PageReqDTO<PlatChildDeviceDTO> pageReqDTO);
void modifyWifiInfo(PlatDeviceSetupDTO dto);
void bindOrg(PlatDeviceBindOrgDTO platDeviceBindOrgDTO);
void active(BaseIdDTO dto);
PlatAlarmCallDeviceVO getDeviceRtmToken(PlatCallingDeviceDTO dto);
PlatAlarmCallDeviceVO callingDevice(PlatCallingDeviceDTO dto);
}
......@@ -9,22 +9,22 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.dto.BaseTenantDTO;
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.common.response.ApiResponseEntity;
import com.makeit.config.ShengwangProperties;
import com.makeit.dto.platform.dataScreen.PlatDataScreenQueryDTO;
import com.makeit.dto.platform.device.*;
import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceNetAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.dto.wechat.device.*;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.device.PlatDeviceOther;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatRegionSetting;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.entity.platform.space.PlatSpace;
......@@ -48,10 +48,16 @@ import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatRoleService;
import com.makeit.service.platform.device.PlatDeviceOtherService;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderService;
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.shengwang.agora.dto.PlatCallingDeviceDTO;
import com.makeit.shengwang.agora.http.ShengwangHttpUtil;
import com.makeit.shengwang.agora.media.RtcTokenBuilder2;
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;
......@@ -60,6 +66,8 @@ import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.request.RequestUtil;
import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.vo.platform.device.PlatChildDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceActiveVO;
import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceViewVO;
import lombok.Data;
......@@ -72,6 +80,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -109,9 +118,17 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
@Autowired
private IotOrgService iotOrgService;
@Autowired
private PlatElderService platElderService;
@Autowired
private SysDictionaryCategoryService sysDictionaryCategoryService;
@Autowired
private PlatRoomBedDeviceService platRoomBedDeviceService;
@Autowired
private ShengwangHttpUtil shengwangHttpUtil;
@Autowired
private ShengwangService shengwangService;
@Autowired
private ShengwangProperties shengwangProperties;
@Override
public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
......@@ -183,6 +200,46 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
@Override
public PageVO<PlatChildDeviceListVO> pageChild(PageReqDTO<PlatChildDeviceDTO> pageReqDTO) {
PlatChildDeviceDTO dto = pageReqDTO.getData();
Page<PlatDevice> p = PageUtil.toMpPage(pageReqDTO);
if (StringUtils.isEmpty(dto.getElderId())) {
throw new RuntimeException("长者id不能为空");
}
PlatElder platElder = platElderService.getById(dto.getElderId());
if (platElder == null || StringUtils.isEmpty(platElder.getRoomId())) {
return PageVO.emptyPage();
}
List<PlatRoomBedDevice> platRoomBedDevices = platRoomBedDeviceService.list(new QueryWrapper<PlatRoomBedDevice>().lambda()
.eq(PlatRoomBedDevice::getRoomId, platElder.getRoomId()));
if (CollectionUtils.isEmpty(platRoomBedDevices)) {
return PageVO.emptyPage();
}
List<String> deviceIdList = StreamUtil.map(platRoomBedDevices, PlatRoomBedDevice::getDeviceId);
Page<PlatDevice> platDevicePage = baseMapper.selectPage(p, new QueryWrapper<PlatDevice>().lambda().in(BaseEntity::getId, deviceIdList));
List<PlatDevice> platDeviceList = platDevicePage.getRecords();
if (CollectionUtils.isEmpty(platDeviceList)) {
return PageVO.emptyPage();
}
List<PlatDeviceOther> platDeviceOtherList = platDeviceOtherService.list(new QueryWrapper<PlatDeviceOther>().lambda()
.in(PlatDeviceOther::getDeviceId, deviceIdList));
Map<String, PlatDeviceOther> platDeviceOtherMap = StreamUtil.toMapDep(platDeviceOtherList, PlatDeviceOther::getDeviceId);
List<PlatChildDeviceListVO> voList = Lists.newArrayList();
PlatChildDeviceListVO vo;
for (PlatDevice platDevice : platDeviceList) {
vo = new PlatChildDeviceListVO();
BeanUtils.copyProperties(platDevice,vo);
PlatDeviceOther platDeviceOther = platDeviceOtherMap.get(platDevice.getId());
if (platDeviceOther != null) {
vo.setPlatDeviceOther(platDeviceOther);
}
voList.add(vo);
}
return PageUtil.toPageVO(voList,platDevicePage);
}
private void check(PlatDeviceEditDTO dto) {
PlatDevice old = getOne(new QueryWrapper<PlatDevice>().lambda()
.eq(PlatDevice::getName, dto.getName()));
......@@ -208,16 +265,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if (StringUtils.isNotEmpty(dto.getAttribute())) {
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getDeviceId, db.getId()));
if (other != null) {
other.setAttribute(dto.getAttribute());
platDeviceOtherService.updateById(other);
} else {
other = new PlatDeviceOther();
other.setDeviceId(db.getId());
other.setOriDeviceId(db.getOriDeviceId());
other.setAttribute(dto.getAttribute());
platDeviceOtherService.save(other);
if (dto.getAttribute().equals(other.getAttribute())) {
return;
}
other.setAttribute(dto.getAttribute());
platDeviceOtherService.updateById(other);
// 写入设备
PlatDeviceAttrWechatDTO platDeviceAttrWechatDTO = JSON.parseObject(dto.getAttribute(), PlatDeviceAttrWechatDTO.class);
......@@ -238,7 +290,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
PlatDeviceViewVO vo = BeanDtoVoUtils.convert(db, PlatDeviceViewVO.class);
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getDeviceId, id));
.eq(PlatDeviceOther::getDeviceId, id).last("limit 1"));
if (other != null) {
BeanUtils.copyProperties(other, vo);
......@@ -261,7 +313,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
PlatDeviceViewVO vo = BeanDtoVoUtils.convert(platDevice, PlatDeviceViewVO.class);
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getDeviceId, platDevice.getId()));
.eq(PlatDeviceOther::getDeviceId, platDevice.getId())
.last("limit 1"));
if (other != null) {
BeanUtils.copyProperties(other, vo);
......@@ -285,14 +338,6 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
id = db.getId();
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, dto.getOriDeviceId()));
if (other == null) {
other = new PlatDeviceOther();
}
String otherId = other.getId();
String tenantId = db.getTenantId();
BeanUtils.copyProperties(dto, db);
db.setId(id);
......@@ -300,17 +345,16 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
db.setOrgId(dto.getOrgId());
saveOrUpdate(db);
id = db.getId();
deviceCacheUtil.put(db);
BeanUtils.copyProperties(dto, other);
other.setId(otherId);
other.setDeviceId(id);
other.setOriDeviceId(db.getOriDeviceId());
platDeviceOtherService.saveOrUpdate(other);
List<PlatDeviceOther> platDeviceOtherList = platDeviceOtherService.list(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, dto.getOriDeviceId()));
for (PlatDeviceOther platDeviceOther : platDeviceOtherList) {
BeanUtils.copyProperties(dto, platDeviceOther,"id");
platDeviceOther.setDeviceId(id);
platDeviceOther.setOriDeviceId(db.getOriDeviceId());
platDeviceOtherService.saveOrUpdate(platDeviceOther);
}
}
@Override
......@@ -363,6 +407,9 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
platDeviceOtherService.saveOrUpdate(other);
if (StringUtils.isNotEmpty(dto.getAttribute())) {
if (dto.getAttribute().equals(other.getAttribute())) {
return;
}
// 写入设备
PlatDeviceAttrWechatDTO platDeviceAttrWechatDTO = JSON.parseObject(dto.getAttribute(), PlatDeviceAttrWechatDTO.class);
platDeviceAttrWechatDTO.setDeviceId(db.getOriDeviceId());
......@@ -370,6 +417,20 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void modifyWifiInfo(PlatDeviceSetupDTO dto) {
List<PlatDeviceOther> platDeviceOtherList = platDeviceOtherService.list(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getDeviceId, dto.getId()));
for (PlatDeviceOther other : platDeviceOtherList) {
other.setWifiName(dto.getWifiName());
other.setWifiPassword(dto.getWifiPassword());
platDeviceOtherService.updateById(other);
}
}
/**
* 设备信息
*
......@@ -412,12 +473,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if (StringUtils.isNotEmpty(result)) {
throw new RuntimeException("设备写入失败:" + result);
}
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId)
.last("limit 1"));
if (other != null) {
other.setAttribute(JSON.toJSONString(map));
platDeviceOtherService.updateById(other);
List<PlatDeviceOther> platDeviceOtherList = platDeviceOtherService.list(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId));
for (PlatDeviceOther platDeviceOther : platDeviceOtherList) {
platDeviceOther.setAttribute(JSON.toJSONString(map));
platDeviceOtherService.updateById(platDeviceOther);
}
if (dto.getRadarMount() != null) {
List<PlatDevice> platDeviceList = list(new QueryWrapper<PlatDevice>().lambda().eq(PlatDevice::getOriDeviceId, deviceId));
......@@ -439,17 +499,16 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if (StringUtils.isNotEmpty(result)) {
throw new RuntimeException("设备写入失败:" + result);
}
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId)
.last("limit 1"));
if (other != null) {
other.setProtocolAccount(usrServerInfo.getUsername());
other.setProtocolPassword(usrServerInfo.getPassword());
other.setProtocolAddress(usrServerInfo.getAddr());
other.setProtocolPort(usrServerInfo.getPort() == null ? "" : usrServerInfo.getPort().toString());
other.setSecureId(usrServerInfo.getSecureId());
other.setSecureKey(usrServerInfo.getSecureKey());
platDeviceOtherService.updateById(other);
List<PlatDeviceOther> platDeviceOtherList = platDeviceOtherService.list(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId));
for (PlatDeviceOther platDeviceOther : platDeviceOtherList) {
platDeviceOther.setProtocolAccount(usrServerInfo.getUsername());
platDeviceOther.setProtocolPassword(usrServerInfo.getPassword());
platDeviceOther.setProtocolAddress(usrServerInfo.getAddr());
platDeviceOther.setProtocolPort(usrServerInfo.getPort() == null ? "" : usrServerInfo.getPort().toString());
platDeviceOther.setSecureId(usrServerInfo.getSecureId());
platDeviceOther.setSecureKey(usrServerInfo.getSecureKey());
platDeviceOtherService.updateById(platDeviceOther);
}
}
......@@ -481,13 +540,14 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if (StringUtils.isNotEmpty(result)) {
resultList.add(result);
}
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
List<PlatDeviceOther> otherList = platDeviceOtherService.list(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId)
.last("limit 1"));
if (other != null) {
other.setAttribute(JSON.toJSONString(map));
platDeviceOtherService.updateById(other);
for (PlatDeviceOther platDeviceOther : otherList) {
platDeviceOther.setAttribute(JSON.toJSONString(map));
platDeviceOtherService.updateById(platDeviceOther);
}
}
if (CollectionUtils.isNotEmpty(resultList)) {
throw new RuntimeException("修改设备属性失败:" + resultList.get(0));
......@@ -540,6 +600,9 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
//查询iot设备
List<DeviceInstanceEntity> iotDeviceList = iotOrgService.getOrgDevice(iotOrgId);
if (CollectionUtils.isEmpty(iotDeviceList)) {
continue;
}
//查询平台设备
Set<String> iotDeviceIdSet = iotDeviceList.stream().map(DeviceInstanceEntity::getId).collect(Collectors.toSet());
......@@ -560,6 +623,10 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
LambdaQueryWrapper<PlatDevice> removeQw = new LambdaQueryWrapper<PlatDevice>()
.in(PlatDevice::getId, deviceIdList)
.eq(BaseBusEntity::getTenantId, platTenant.getId());
platDeviceOtherService.remove(new QueryWrapper<PlatDeviceOther>().lambda()
.in(PlatDeviceOther::getDeviceId,deviceIdList)
.eq(BaseBusEntity::getTenantId, platTenant.getId()));
remove(removeQw);
// 同时删除关联的设备
......@@ -664,4 +731,65 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
return false;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void bindOrg(PlatDeviceBindOrgDTO dto) {
update(new UpdateWrapper<PlatDevice>().lambda()
.set(PlatDevice::getOrgId,dto.getOrgId())
.in(CollectionUtils.isNotEmpty(dto.getIdList()),BaseEntity::getId,dto.getIdList()));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void active(BaseIdDTO dto) {
PlatDevice platDevice = getById(dto.getId());
String active = shengwangHttpUtil.active(platDevice.getOriDeviceId());
ApiResponseEntity responseEntity = JSON.parseObject(active, ApiResponseEntity.class);
if (responseEntity.getCode() != 200) {
throw new RuntimeException(responseEntity.getMessage());
}
Object data = responseEntity.getData();
if (data != null) {
PlatDeviceActiveVO platDeviceActiveVO = JSON.parseObject(data.toString(), PlatDeviceActiveVO.class);
platDevice.setDeviceLicense(platDeviceActiveVO.getLicense());
platDevice.setLicenseInfo(JSON.toJSONString(platDeviceActiveVO.getSkuView()));
platDevice.setExpireTime(platDeviceActiveVO.getExpireTime());
platDevice.setActivationTime(platDeviceActiveVO.getActivationTime());
updateById(platDevice);
// 调用设备写入接口
Map<String, Object> map = new HashMap<>();
map.put("license",platDeviceActiveVO.getLicense());
map.put("appid",shengwangProperties.getAppId());
String result = devicePropertiesOperateService.deviceWriteAttr(platDevice.getOriDeviceId(), map);
if (StringUtils.isNotEmpty(result)) {
throw new RuntimeException(result);
}
}
}
@Override
public PlatAlarmCallDeviceVO callingDevice(PlatCallingDeviceDTO dto) {
PlatAlarmCallDeviceVO platAlarmCallDeviceVO = new PlatAlarmCallDeviceVO();
PlatDevice platDevice = getById(dto.getId());
platAlarmCallDeviceVO.setDeviceId(platDevice.getOriDeviceId());
platAlarmCallDeviceVO.setAppId(shengwangProperties.getAppId());
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String channelName = String.format("%s:%s","RTC",now.format(dateTimeFormatter));
RtcTokenBuilder2 token = new RtcTokenBuilder2();
String result = token.buildTokenWithUid(shengwangProperties.getAppId(), shengwangProperties.getAppCertificate(), channelName, 0, RtcTokenBuilder2.Role.ROLE_SUBSCRIBER,
shengwangProperties.getTokenExpirationInSeconds(), shengwangProperties.getPrivilegeExpirationInSeconds());
platAlarmCallDeviceVO.setAccessToken(result);
platAlarmCallDeviceVO.setChannelName(channelName);
return platAlarmCallDeviceVO;
}
@Override
public PlatAlarmCallDeviceVO getDeviceRtmToken(PlatCallingDeviceDTO dto) {
return shengwangService.callingDeviceAuthIgnoreRtm(dto);
}
}
package com.makeit.service.platform.elder;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.platform.elder.PlatElderCoordinateRecord;
/**
* <p>
* 长者坐标记录 服务类
* </p>
*
* @author eugene young
* @since 2023-11-15
*/
public interface PlatElderCoordinateRecordService extends IService<PlatElderCoordinateRecord> {
void coordinateRecordTask();
}
......@@ -70,6 +70,8 @@ public interface PlatElderService extends IService<PlatElder> {
void batchEdit(PlatElderBatchEditDTOVO dto);
List<PlatElderListVO> listByElder(PlatElderQueryDTO dto);
PlatElder getByDeviceId(String deviceId);
/*小程序*/
}
......@@ -11,6 +11,7 @@ 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;
......@@ -30,6 +31,7 @@ import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.request.RequestUtil;
import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.utils.sys.FileUtil;
import com.makeit.utils.user.common.CommonUserUtil;
import com.makeit.utils.user.common.CommonUserVO;
import com.makeit.utils.user.wechat.WechatUserUtil;
......@@ -70,6 +72,7 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild
.like(StringUtils.isNotBlank(dto.getPhone()), PlatElderChildrenInfo::getPhone, dto.getPhone())
.eq(StringUtils.isNotBlank(dto.getElderId()), PlatElderChildrenInfo::getElderId, dto.getElderId())
.eq(StringUtils.isNotBlank(dto.getTenantId()), PlatElderChildrenInfo::getTenantId, dto.getTenantId())
.in(CollectionUtils.isNotEmpty(dto.getOrgIdList()),PlatElderChildrenInfo::getOrgId,dto.getOrgIdList())
.apply(StringUtils.isNotBlank(dto.getOrgId()), "find_in_set('" + dto.getOrgId() + "',org_path)");
}
......@@ -271,6 +274,10 @@ public class PlatElderChildrenInfoServiceImpl extends ServiceImpl<PlatElderChild
List<PlatElderListVO> list = BeanDtoVoUtils.listVo(platElders, PlatElderListVO.class);
platElderService.fill(list);
FileUtil.convert(list, PlatElderListVO::getAvatar, (e, f) -> {
e.setAvatar(f.getFullUrl());
});
Map<String, PlatElderListVO> elderListVOMap = StreamUtil.toMap(list, BaseIdDTO::getId);
List<PlatElderChildrenInfoWechatVO> voList = Lists.newArrayList();
for (PlatElderChildrenInfo platElderChildrenInfo : platElderChildrenInfoList) {
......
package com.makeit.service.platform.elder.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.elder.PlatElderCoordinateRecord;
import com.makeit.entity.platform.space.PlatRegionSetting;
import com.makeit.entity.platform.space.PlatRegionSettingFix;
import com.makeit.mapper.platform.elder.PlatElderCoordinateRecordMapper;
import com.makeit.service.platform.elder.PlatElderCoordinateRecordService;
import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.service.platform.elder.PlatElderRealTimeService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.space.PlatRegionSettingFixService;
import com.makeit.service.platform.space.PlatRegionSettingService;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.time.LocalDateTimeUtils;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
/**
* <p>
* 长者坐标记录 服务实现类
* </p>
*
* @author eugene young
* @since 2023-11-15
*/
@Service
public class PlatElderCoordinateRecordServiceImpl extends ServiceImpl<PlatElderCoordinateRecordMapper, PlatElderCoordinateRecord> implements PlatElderCoordinateRecordService {
@Autowired
private PlatElderService platElderService;
@Autowired
private PlatElderDayReportDayService platElderDayReportDayService;
@Autowired
private PlatRegionSettingFixService platRegionSettingFixService;
@Autowired
private PlatRegionSettingService platRegionSettingService;
@Autowired
private PlatElderRealTimeService platElderRealTimeService;
@Override
public void coordinateRecordTask() {
LocalDate nowDate = LocalDate.now();
LocalDate yesDate = nowDate.minusDays(1);
LocalDateTime datStart = LocalDateTimeUtils.getDayStart(yesDate);
LocalDateTime dayEnd = LocalDateTimeUtils.getDayEnd(yesDate);
List<PlatElder> elderList = platElderService.list(new QueryWrapper<PlatElder>().lambda()
.isNotNull(PlatElder::getRoomId));
if (CollectionUtils.isEmpty(elderList)) {
return;
}
PlatElderCoordinateRecord platElderCoordinateRecord;
PlatRegionSettingFix platRegionSettingFix;
List<PlatRegionSetting> platRegionSettingList = platRegionSettingService.list(new QueryWrapper<>());
Function<PlatRegionSetting,String> function = entity -> entity.getRoomId() + "-" + entity.getDeviceId();
Map<String, PlatRegionSetting> platRegionSettingMap = StreamUtil.toMap(platRegionSettingList,
function);
for (PlatElder platElder : elderList) {
List<PlatElderCoordinateVO> elderCoordinateVOList = platElderDayReportDayService.coordinateList(platElder.getId(), null, datStart, dayEnd);
Set<String> deviceIdSet = Sets.newHashSet();
List<PlatElderCoordinateRecord> list = Lists.newArrayList();
for (PlatElderCoordinateVO vo : elderCoordinateVOList) {
platElderCoordinateRecord = new PlatElderCoordinateRecord();
BeanUtils.copyProperties(vo,platElderCoordinateRecord);
if (CollectionUtils.isNotEmpty(vo.getTrack())) {
platElderCoordinateRecord.setTrack(JSON.toJSONString(vo.getTrack()));
}
platElderCoordinateRecord.setReportTime(vo.getTimestamp());
platElderCoordinateRecord.setIotDeviceId(vo.getOriDeviceId());
platElderCoordinateRecord.setDeviceId(vo.getDeviceId());
platElderCoordinateRecord.setPersonState(vo.getPersonState());
platElderCoordinateRecord.setElderId(platElder.getId());
platElderCoordinateRecord.setTenantId(platElder.getTenantId());
list.add(platElderCoordinateRecord);
deviceIdSet.add(vo.getDeviceId());
}
saveBatch(list);
for (String deviceId : deviceIdSet) {
PlatRegionSetting platRegionSetting = platRegionSettingMap.get(platElder.getRoomId() + "-" + deviceId);
if (platRegionSetting != null) {
platRegionSettingFix = new PlatRegionSettingFix();
BeanUtils.copyProperties(platRegionSetting,platRegionSettingFix,"id");
platRegionSettingFix.setElderId(platElder.getId());
platRegionSettingFix.setHappenDate(yesDate.toString());
platRegionSettingFixService.save(platRegionSettingFix);
}
}
}
}
}
......@@ -5,6 +5,7 @@ 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;
......@@ -26,7 +27,6 @@ import com.makeit.utils.time.LocalDateTimeUtils;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.report.day.*;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -35,6 +35,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDayService {
......@@ -59,6 +60,8 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Autowired
private PlatElderRealTimeService platElderRealTimeService;
@Autowired
private PlatElderService platElderService;
private static LocalDateTime dayStartNow(LocalDate now) {
return LocalDateTimeUtils.getDayStart(now);
......@@ -87,8 +90,16 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
String nowString = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
String elderId = platElderIdDTO.getElderId();
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
if (platElder != null) {
elderId = platElder.getId();
}
}
PlatElderSleepAnalysis platElderSleepAnalysis = platElderSleepAnalysisService.getOne(new QueryWrapper<PlatElderSleepAnalysis>().lambda()
.eq(PlatElderSleepAnalysis::getElderId, platElderIdDTO.getElderId())
.eq(PlatElderSleepAnalysis::getElderId, elderId)
.eq(PlatElderSleepAnalysis::getHappenDate, nowString)
);
......@@ -119,9 +130,15 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
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());
if (platElder != null) {
elderId = platElder.getId();
}
}
List<PlatElderSleep> sleepList = platElderSleepService.list(new QueryWrapper<PlatElderSleep>().lambda()
.eq(PlatElderSleep::getElderId, platElderIdDTO.getElderId())
.eq(PlatElderSleep::getElderId, elderId)
.eq(PlatElderSleep::getHappenDate, nowString)
.orderByAsc(PlatElderSleep::getStartSleep)
);
......@@ -130,6 +147,7 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
PlatElderSleepDiagramVO vo = new PlatElderSleepDiagramVO();
vo.setSleepAt(e.getStartSleep());
vo.setWakeUpAt(e.getEndSleep());
vo.setElderSleepType(e.getElderSleepType());
List<PlatElderSleepDiagramContentVO> contentList = StreamUtil.map(Optional.ofNullable(e.getSleepRecord()).orElse(new ArrayList<>(10)), i -> {
PlatElderSleepDiagramContentVO contentVO = new PlatElderSleepDiagramContentVO();
......@@ -160,9 +178,15 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
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());
if (platElder != null) {
elderId = platElder.getId();
}
}
PlatElderBreatheAnalysis platElderSleepAnalysis = platElderBreatheAnalysisService.getOne(new QueryWrapper<PlatElderBreatheAnalysis>().lambda()
.eq(PlatElderBreatheAnalysis::getElderId, platElderIdDTO.getElderId())
.eq(PlatElderBreatheAnalysis::getElderId, elderId)
.eq(PlatElderBreatheAnalysis::getHappenDate, nowString)
);
......@@ -195,16 +219,22 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Override
public List<PlatElderHeartRespiratoryEvaluationRecordVO> heartRespiratoryExceptionRecordList(PlatElderReportDTO platElderIdDTO, String alarmType, LocalDateTime start, LocalDateTime end) {
PlatDevice device = platElderRealTimeService.getBreathDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
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());
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, platElderIdDTO.getElderId())
.eq(PlatAlarmRecord::getElderIds, elderId)
.ge(PlatAlarmRecord::getAlarmDate, start)
.le(PlatAlarmRecord::getAlarmDate, end)
......@@ -269,19 +299,25 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Override
public List<PlatElderBehaviorExceptionRecordVO> behaviorExceptionRecordListInternal(PlatElderReportDTO platElderIdDTO, LocalDateTime start, LocalDateTime end) {
List<PlatDevice> platDeviceList = platElderRealTimeService.getSpaceDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
List<PlatDevice> fallDeviceList = platElderRealTimeService.getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
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());
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::getElderIds, platElderIdDTO.getElderId())
.eq(PlatAlarmRecord::getElderIds, elderId)
.eq(PlatAlarmRecord::getMisinformationFlag, CommonEnum.NO.getValue())
.ge(PlatAlarmRecord::getAlarmDate, start)
.le(PlatAlarmRecord::getAlarmDate, end)
......@@ -319,23 +355,30 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Override
public List<String> failRecordListInternal(PlatElderReportDTO platElderIdDTO, LocalDateTime start, LocalDateTime end) {
List<PlatDevice> platDeviceList = platElderRealTimeService.getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
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());
if (platElder != null) {
elderId = platElder.getId();
}
}
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, platElderIdDTO.getElderId())
.eq(PlatAlarmRecord::getElderIds, finalElderId)
.eq(PlatAlarmRecord::getMisinformationFlag, CommonEnum.NO.getValue())
.ge(PlatAlarmRecord::getAlarmDate, start)
.le(PlatAlarmRecord::getAlarmDate, end)
......@@ -349,8 +392,7 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
*/
});
return voList;
return voList.stream().distinct().collect(Collectors.toList());
}
......@@ -392,10 +434,11 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
// 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());
vo.setType(1);
vo.setPersonState(i.getProperties().getPersonState());
vo.setMount(i.getProperties().getMount());
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
......@@ -413,10 +456,11 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
voList.addAll(StreamUtil.map(fallList, i -> {
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
vo.setTimestamp(i.getTimestamp());
vo.setTrack(i.getProperties().getTrack());
vo.setDeviceId(e.getId());
vo.setType(2);
vo.setPersonState(i.getProperties().getPersonState());
vo.setMount(i.getProperties().getMount());
vo.setOriDeviceId(e.getOriDeviceId());
......@@ -443,24 +487,31 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Override
public List<PlatElderBehaviorDistributionVO> behaviorDistributionInternal(PlatElderReportDTO platElderIdDTO, List<LocalDate> nowList) {
List<PlatDevice> platDeviceList = platElderRealTimeService.getSpaceDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
List<PlatDevice> fallDeviceList = platElderRealTimeService.getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
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());
if (platElder != null) {
elderId = platElder.getId();
}
}
List<PlatElderBehaviorDistributionVO> voList = new ArrayList<>(10);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
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(platElderIdDTO.getElderId()),PlatDayDurationRecord::getElderIds,platElderIdDTO.getElderId())
.eq(StringUtils.isNotEmpty(finalElderId),PlatDayDurationRecord::getElderIds, finalElderId)
.in(PlatDayDurationRecord::getDay, StreamUtil.map(nowList, dateTimeFormatter::format))
);
......
......@@ -75,6 +75,8 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
@Autowired
private PlatElderSleepAnalysisService platElderSleepAnalysisService;
@Autowired
private PlatElderService platElderService;
private LocalDateTime weekStartDateTime(LocalDateTime defaultTime) {
return weekStartDateTime(LocalDate.now().minusDays(1), defaultTime);
......@@ -174,9 +176,15 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
public PlatElderSleepEvaluationVO sleepEvaluationInternal(PlatElderReportDTO platElderIdDTO, LocalDate weekStartDate, LocalDate weekEndDate) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String elderId = platElderIdDTO.getElderId();
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
if (platElder != null) {
elderId = platElder.getId();
}
}
List<PlatElderSleepAnalysis> sleepAnalysisList = platElderSleepAnalysisService.list(new QueryWrapper<PlatElderSleepAnalysis>().lambda()
.eq(PlatElderSleepAnalysis::getElderId, platElderIdDTO.getElderId())
.eq(PlatElderSleepAnalysis::getElderId, elderId)
.ge(PlatElderSleepAnalysis::getHappenDate, dateTimeFormatter.format(weekStartDate))
.le(PlatElderSleepAnalysis::getHappenDate, dateTimeFormatter.format(weekEndDate))
);
......@@ -239,15 +247,21 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
LocalDate weekEndDate = weekEndDate(platElderIdDTO.getEndTime());
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String elderId = platElderIdDTO.getElderId();
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
if (platElder != null) {
elderId = platElder.getId();
}
}
List<PlatElderSleep> sleepList = platElderSleepService.list(new QueryWrapper<PlatElderSleep>().lambda()
.eq(PlatElderSleep::getElderId, platElderIdDTO.getElderId())
.eq(PlatElderSleep::getElderId, elderId)
.ge(PlatElderSleep::getHappenDate, dateTimeFormatter.format(weekStartDate))
.le(PlatElderSleep::getHappenDate, dateTimeFormatter.format(weekEndDate))
);
List<PlatElderSleepAnalysis> sleepAnalysisList = platElderSleepAnalysisService.list(new QueryWrapper<PlatElderSleepAnalysis>().lambda()
.eq(PlatElderSleepAnalysis::getElderId, platElderIdDTO.getElderId())
.eq(PlatElderSleepAnalysis::getElderId, elderId)
.ge(PlatElderSleepAnalysis::getHappenDate, dateTimeFormatter.format(weekStartDate))
.le(PlatElderSleepAnalysis::getHappenDate, dateTimeFormatter.format(weekEndDate))
);
......@@ -317,9 +331,15 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
public PlatElderHeartRespiratoryEvaluationVO heartRespiratoryEvaluationInternal(PlatElderReportDTO platElderIdDTO, LocalDate weekStartDate, LocalDate weekEndDate) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String elderId = platElderIdDTO.getElderId();
if (StringUtils.isNotEmpty(platElderIdDTO.getDeviceId())) {
PlatElder platElder = platElderService.getByDeviceId(platElderIdDTO.getDeviceId());
if (platElder != null) {
elderId = platElder.getId();
}
}
List<PlatElderBreatheAnalysis> breatheAnalyses = platElderBreatheAnalysisService.list(new QueryWrapper<PlatElderBreatheAnalysis>().lambda()
.eq(PlatElderBreatheAnalysis::getElderId, platElderIdDTO.getElderId())
.eq(PlatElderBreatheAnalysis::getElderId, elderId)
.ge(PlatElderBreatheAnalysis::getHappenDate, dateTimeFormatter.format(weekStartDate))
.le(PlatElderBreatheAnalysis::getHappenDate, dateTimeFormatter.format(weekEndDate))
);
......
......@@ -112,7 +112,15 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
}
if (StringUtils.isNotBlank(deviceId)) {
deviceList = Arrays.asList(platDeviceService.getById(deviceId));
PlatDevice platDevice = platDeviceService.getById(deviceId);
if (platDevice != null) {
deviceList.add(platDevice);
}
PlatDevice device = platDeviceService.getOne(new QueryWrapper<PlatDevice>().lambda()
.eq(PlatDevice::getOriDeviceId, deviceId).last("limit 1"));
if (device != null) {
deviceList.add(device);
}
}
return deviceList;
......@@ -127,7 +135,15 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
}
if (StringUtils.isNotBlank(deviceId)) {
deviceList = Arrays.asList(platDeviceService.getById(deviceId));
PlatDevice platDevice = platDeviceService.getById(deviceId);
if (platDevice != null) {
deviceList.add(platDevice);
}
PlatDevice device = platDeviceService.getOne(new QueryWrapper<PlatDevice>().lambda()
.eq(PlatDevice::getOriDeviceId, deviceId).last("limit 1"));
if (device != null) {
deviceList.add(device);
}
}
return deviceList;
......@@ -476,11 +492,22 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
if (platElderIdDTO == null || StringUtils.isEmpty(platElderIdDTO.getElderId())) {
/* if (platElderIdDTO == null || StringUtils.isEmpty(platElderIdDTO.getElderId())) {
return voList;
}*/
List<PlatDevice> deviceListSpace = Lists.newArrayList();
List<PlatDevice> fallDeviceList = Lists.newArrayList();
if (StringUtils.isNotBlank(platElderIdDTO.getDeviceId())) {
PlatDevice device = platDeviceService.getOne(new QueryWrapper<PlatDevice>().lambda()
.eq(PlatDevice::getOriDeviceId, platElderIdDTO.getDeviceId()).last("limit 1"));
if (device != null) {
deviceListSpace.add(device);
}
} else {
deviceListSpace = getSpaceDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
fallDeviceList = getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
}
List<PlatDevice> deviceListSpace = getSpaceDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
List<PlatDevice> fallDeviceList = getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
deviceListSpace.addAll(fallDeviceList);
for (PlatDevice platDevice : deviceListSpace) {
String spaceResult = redisTemplate.opsForValue().get(DEVICE_SPACE_DATA + platDevice.getOriDeviceId());
......
......@@ -25,6 +25,7 @@ import com.makeit.entity.platform.elder.PlatElderOtherInfo;
import com.makeit.entity.platform.elder.PlatElderSocialRelation;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
......@@ -908,7 +909,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
addressToDetail(vo);
FileUtil.convert(Arrays.asList(vo), PlatElderDTOVO::getAvatar, (e, f) -> {
e.setAvatar(f.getFullUrl());
e.setAvatarPath(f.getFullUrl());
});
List<PlatElderSocialRelation> dbSocialRelationList = platElderSocialRelationService.list(new QueryWrapper<PlatElderSocialRelation>().lambda()
......@@ -1191,6 +1192,19 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
return voList;
}
@Override
public PlatElder getByDeviceId(String deviceId) {
PlatRoomBedDevice platRoomBedDevice = platRoomBedDeviceService.getOne(new QueryWrapper<PlatRoomBedDevice>().lambda()
.eq(PlatRoomBedDevice::getDeviceId, deviceId)
.last("limit 1"));
if (platRoomBedDevice != null && StringUtils.isNotEmpty(platRoomBedDevice.getBedId())) {
PlatElder platElder = getOne(new QueryWrapper<PlatElder>().lambda()
.eq(PlatElder::getBedId, platRoomBedDevice.getBedId()));
return platElder;
}
return null;
}
}
//TODO ywc 数据字典
//还有空间相关的没有 列表 详情 导入 导出
......
package com.makeit.service.platform.space;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.platform.space.PlatRegionSettingFix;
/**
* <p>
* 区域设置固化 服务类
* </p>
*
* @author eugene young
* @since 2023-11-15
*/
public interface PlatRegionSettingFixService extends IService<PlatRegionSettingFix> {
}
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.platform.space.PlatRegionSettingFix;
import com.makeit.mapper.platform.space.PlatRegionSettingFixMapper;
import com.makeit.service.platform.space.PlatRegionSettingFixService;
import org.springframework.stereotype.Service;
/**
* <p>
* 区域设置固化 服务实现类
* </p>
*
* @author eugene young
* @since 2023-11-15
*/
@Service
public class PlatRegionSettingFixServiceImpl extends ServiceImpl<PlatRegionSettingFixMapper, PlatRegionSettingFix> implements PlatRegionSettingFixService {
}
......@@ -71,18 +71,20 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
platDeviceOthers = platDeviceOthers.stream().filter(platDeviceOther -> StringUtils.isNotEmpty(platDeviceOther.getAttribute())).collect(Collectors.toList());
Map<String,String> map = platDeviceOthers.stream().collect(Collectors.toMap(PlatDeviceOther::getDeviceId,PlatDeviceOther::getAttribute));
List<PlatRegionSetting> list = new ArrayList<>();
listDeviceId.forEach(item->{
for (String item : listDeviceId) {
PlatRegionSetting platRegionSetting = new PlatRegionSetting();
platRegionSetting.setDeviceId(item);
platRegionSetting.setRoomId(roomId);
if(map.get(item)!=null){
String attribute = map.get(item);
PlatDeviceAttrWechatDTO deviceAttrWechatDTO = JsonUtil.toObj(attribute,PlatDeviceAttrWechatDTO.class);
platRegionSetting.setInstallType(deviceAttrWechatDTO.getRadarMount()+"");
if (deviceAttrWechatDTO == null || deviceAttrWechatDTO.getRadarMount() == null) {
continue;
}
platRegionSetting.setInstallType(deviceAttrWechatDTO.getRadarMount().toString());
}
list.add(platRegionSetting);
});
}
if(!list.isEmpty()){
saveBatch(list);
......
......@@ -68,6 +68,15 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
//空间下的房间
List<PlatRoom> rooms = platRoomService.list(new QueryWrapper<PlatRoom>().lambda()
.in(PlatRoom::getSpaceId,spaceIds));
if (CollectionUtils.isEmpty(rooms)) {
spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getParentId,spaceIds));
if (CollectionUtils.isNotEmpty(spaces)) {
spaceIds = spaces.stream().map(PlatSpace::getId).collect(Collectors.toList());
rooms = platRoomService.list(new QueryWrapper<PlatRoom>().lambda()
.in(PlatRoom::getSpaceId,spaceIds));
}
}
Map<String,List<PlatRoom>> spaceRoomMap = rooms.stream().collect(Collectors.groupingBy(PlatRoom::getSpaceId));
List<String> roomIds = rooms.stream().map(PlatRoom::getId).collect(Collectors.toList());
List<PlatBed> beds = platBedService.list(new QueryWrapper<PlatBed>().lambda()
......
......@@ -9,6 +9,7 @@ import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.space.PlatRoomDTO;
import com.makeit.dto.platform.space.PlatRoomQueryDTO;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
......@@ -17,6 +18,7 @@ import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.space.PlatRoomMapper;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.service.platform.space.PlatRoomService;
......@@ -49,6 +51,8 @@ public class PlatRoomServiceImpl extends ServiceImpl<PlatRoomMapper, PlatRoom> i
@Autowired
private PlatSpaceService platSpaceService;
@Autowired
private PlatElderService platElderService;
@Autowired
private PlatRoomBedDeviceService platRoomBedDeviceService;
private void checkName(PlatRoom platRoom){
......@@ -95,6 +99,16 @@ public class PlatRoomServiceImpl extends ServiceImpl<PlatRoomMapper, PlatRoom> i
updateById(platRoom);
platBedService.add(platRoom);
// 同步更新长者房间
List<PlatElder> platElderList = platElderService.list(new QueryWrapper<PlatElder>().lambda()
.eq(PlatElder::getRoomId, platRoom.getId()));
for (PlatElder platElder : platElderList) {
platElder.setSpaceId(dto.getSpaceId());
platElder.setSpacePath(dto.getSpacePath() + "," + platElder.getRoomId() + "," + platElder.getBedId());
platElderService.updateById(platElder);
}
}
@Override
......
......@@ -3,6 +3,7 @@ package com.makeit.task;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.elder.PlatElderBreatheAnalysisService;
import com.makeit.service.platform.elder.PlatElderBreatheDayStatService;
import com.makeit.service.platform.elder.PlatElderCoordinateRecordService;
import com.makeit.service.platform.elder.PlatElderSleepService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -19,6 +20,8 @@ public class PlatElderReportTask {
private PlatElderBreatheDayStatService platElderBreatheDayStatService;
@Autowired
private PlatElderBreatheAnalysisService platElderBreatheAnalysisService;
@Autowired
private PlatElderCoordinateRecordService platElderCoordinateRecordService;
......@@ -30,6 +33,14 @@ public class PlatElderReportTask {
log.info("生成长者每日呼吸,异常情况结束");
}
@Scheduled(cron = "0 30 1 * * ?")
@TenantIdIgnore
public void coordinateRecordTask() {
log.info("开始生成长者每日实时定位");
platElderCoordinateRecordService.coordinateRecordTask();
log.info("生成长者每日实时定位结束");
}
/**
* 长者呼吸心率分析
......
package com.makeit.vo.platform.device;
import com.makeit.entity.platform.device.PlatDeviceOther;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 设备
* </p>
*
* @author eugene young
* @since 2023-09-05
*/
@Data
@ApiModel(value = "子女端设备对象", description = "子女端设备")
public class PlatChildDeviceListVO {
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "原始设备ID")
private String oriDeviceId;
@ApiModelProperty(value = "设备名称")
private String name;
@ApiModelProperty(value = "产品名称")
private String productName;
@ApiModelProperty(value = "产品id")
private String productId;
@ApiModelProperty(value = "说明")
private String description;
@ApiModelProperty(value = "状态 数据字典 1 在线 0离线")
private String status;
@ApiModelProperty(value = "设备类型 0-呼吸心率雷达 1-空间人体雷达 2-跌倒检测雷达")
private String category;
@ApiModelProperty(value = "组织id")
private String orgId;
@ApiModelProperty(value = "组织名称")
private String orgName;
private PlatDeviceOther platDeviceOther;
}
package com.makeit.vo.platform.device;
import io.swagger.annotations.ApiModel;
import lombok.Data;
/**
* <p>
* 设备
* </p>
*
* @author eugene young
* @since 2023-09-05
*/
@Data
@ApiModel(value = "设备激活许可", description = "设备激活许可")
public class PlatDeviceActiveVO {
private String license;
private SkuView skuView;
private Long expireTime;
private Long activationTime;
@Data
public static class SkuView {
private Integer product;
private Integer minutes;
private Integer mediaType;
private String name;
private String period;
}
}
......@@ -2,6 +2,7 @@ package com.makeit.vo.platform.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.makeit.common.dto.BaseTenantDTO;
import com.makeit.entity.platform.device.PlatDeviceOther;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......
......@@ -31,7 +31,7 @@ public class PlatElderExportVO extends BaseTenantDTO {
@ApiModelProperty(value = "小区/社区/街道空间id")
private String streetSpaceId;
@ExcelProperty("小区")
@ExcelProperty("一级空间")
@ApiModelProperty(value = "小区/社区/街道空间名称")
private String streetSpaceName;
......@@ -39,7 +39,7 @@ public class PlatElderExportVO extends BaseTenantDTO {
@ApiModelProperty(value = "楼栋空间id")
private String buildingSpaceId;
@ExcelProperty("楼栋")
@ExcelProperty("二级空间")
@ApiModelProperty(value = "楼栋空间名称")
private String buildingSpaceName;
......@@ -47,7 +47,7 @@ public class PlatElderExportVO extends BaseTenantDTO {
@ApiModelProperty(value = "单元空间id")
private String unitSpaceId;
@ExcelProperty("单元")
@ExcelProperty("三级空间")
@ApiModelProperty(value = "单元空间名称")
private String unitSpaceName;
......@@ -55,7 +55,7 @@ public class PlatElderExportVO extends BaseTenantDTO {
@ApiModelProperty(value = "楼层id")
private String floorSpaceId;
@ExcelProperty("楼层")
@ExcelProperty("四级空间")
@ApiModelProperty(value = "楼层id")
private String floorSpaceName;
......
......@@ -135,6 +135,7 @@ public class PlatElderListVO extends BaseTenantDTO {
@ApiModelProperty(value = "更新人名称")
private String updateBy;
@ApiModelProperty(value = "头像文件id")
private String avatar;
}
......@@ -25,6 +25,8 @@ public class PlatElderCoordinateVO {
private Integer angle;
@ApiModelProperty("安装方式")
private Integer mount;
@ApiModelProperty("上报时间")
private Long timestamp;
@ApiModelProperty("跌倒设备轨迹")
private List<Integer> track;
......
......@@ -21,5 +21,9 @@ public class PlatElderSleepDiagramVO {
@ApiModelProperty("图表集合")
private List<PlatElderSleepDiagramContentVO> contentList;
@ApiModelProperty(value = "睡眠类型 1 睡眠 2 小憩")
private Integer elderSleepType;
}
......@@ -48,7 +48,7 @@
</if>
</where>
order by pd.update_date desc,prbd.update_date desc
order by pd.update_date desc,pd.id desc
</select>
<select id="getDevices" resultType="com.makeit.vo.platform.device.PlatDeviceListVO">
......
......@@ -70,7 +70,7 @@ file:
storage:
location: ${file.file}
type: local
url: http://localhost:8888/${file.filePath}
url: https://localhost:8888/${file.filePath}
# aliBaseDir: point
......@@ -108,7 +108,7 @@ redis:
libreOffice: C:\\Program Files\\LibreOffice\\program\\soffice
iot:
url: http://iot.qa.insightica.cn/api/
url: https://iot.qa.insightica.cn/api/
clientId: fyxmb5h52iKwE2Hi
secureKey: 22fZbnH36wdHn7ZTyKKHraFw233npcez
......@@ -149,6 +149,17 @@ voice-sms:
uid: 362
pwd: xmksyy123456
shengwang:
appId: 883078934ecd4193aa7a62a3cdacd810
appCertificate: b29be69c9c034120a68f1d5c199d2e74
channelName: 1
uid: 0
tokenExpirationInSeconds: 3600
privilegeExpirationInSeconds: 3600
customerKey: b3b5f44e536a4fc191358926c6716b7b
customerSecret: bd81828a133140a58dfb04e9d80eba43
pid: 9851781E9E31453DA3C572A4A4AF9402
......
......@@ -67,7 +67,7 @@ file:
storage:
location: ${file.file}
type: local
url: http://saas.qa.insightica.cn/api/${file.filePath}
url: https://saas.qa.insightica.cn/api/${file.filePath}
# aliBaseDir: point
# aliEndpoint: obs.cn-south-1.myhuaweicloud.com
......@@ -104,7 +104,7 @@ redis:
libreOffice: /home/group1_lzy/iot-server/LibreOffice/program/soffice
iot:
url: http://iot.qa.insightica.cn/api/
url: https://iot.qa.insightica.cn/api/
clientId: fyxmb5h52iKwE2Hi
secureKey: 22fZbnH36wdHn7ZTyKKHraFw233npcez
......@@ -146,3 +146,14 @@ voice-sms:
uid: 362
pwd: xmksyy123456
shengwang:
appId: 883078934ecd4193aa7a62a3cdacd810
appCertificate: b29be69c9c034120a68f1d5c199d2e74
channelName: 1
uid: 0
tokenExpirationInSeconds: 3600
privilegeExpirationInSeconds: 3600
customerKey: b3b5f44e536a4fc191358926c6716b7b
customerSecret: bd81828a133140a58dfb04e9d80eba43
pid: 9851781E9E31453DA3C572A4A4AF9402
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