Commit f96c1713 by huangjy

feat:第三方api,模型分析V1.0

parent f3e2ab89
...@@ -23,7 +23,11 @@ ...@@ -23,7 +23,11 @@
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.makeit</groupId>
<artifactId>server-service</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies> </dependencies>
......
package com.makeit.api.controller;
public class AlarmController {
}
package com.makeit.api.controller.external;
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.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.platform.elder.PlatElderQueryDTO;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.elder.PlatElderListVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContextAware;
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;
import javax.annotation.PostConstruct;
/**
* iot对外接口
*/
@RestController
@RequestMapping("/iot/external")
public class IotPlatExternalController {
@Autowired
private PlatElderService platElderService;
@Autowired
private PlatDeviceService platDeviceService;
@Autowired
private PlatAlarmRecordService platAlarmRecordService;
@ApiOperation("长者列表")
@PostMapping("elderPage")
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity<PageVO<PlatElderListVO>> elderPage(@RequestBody PageReqDTO<PlatElderQueryDTO> page) {
return ApiResponseUtils.success(platElderService.page(page));
}
@ApiOperation("设备列表")
@PostMapping("devicePage")
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity<PageVO<PlatDeviceListVO>> devicePage(@RequestBody PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
return ApiResponseUtils.success(platDeviceService.page(pageReqDTO));
}
@ApiOperation("告警记录列表")
@PostMapping("alarmRecordPage")
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity<PageVO<PlatAlarmRecordVO>> page(@RequestBody PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
return ApiResponseUtils.success(platAlarmRecordService.page(dto));
}
@ApiOperation("处理告警回调")
@PostMapping("dealAlarm")
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity<String> dealAlarm(@RequestBody BaseIdDTO dto) {
platAlarmRecordService.dealAlarm(dto);
return ApiResponseUtils.success();
}
}
package com.makeit.module.controller.elder;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.task.IotSyncTask;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 长者每天睡觉记录 前端控制器
* </p>
*
* @author eugene young
* @since 2023-09-13
*/
@Api(tags = "长者睡觉分析")
@RestController
@RequestMapping("/plat/elderSleep")
public class PlatElderSleepController {
@Autowired
private IotSyncTask iotSyncTask;
@ApiOperation("测试")
@PostMapping("test")
@AuthIgnore
@TenantIdIgnore
public ApiResponseEntity<Void> test() {
iotSyncTask.elderSleepSleepAnalysisTask();
return ApiResponseUtils.success();
}
}
package com.makeit.enums.report;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum DeviceNameEnum {
heart("呼吸心率","呼吸心率雷达"),
fall("跌倒","跌倒检测雷达"),
space("空间","空间人体雷达");
private String prefix;
private String name;
public static String getNameByPrefix(String productName) {
for (DeviceNameEnum value : DeviceNameEnum.values()) {
if ( productName.startsWith(value.prefix)) {
return value.name;
}
}
return "";
}
}
package com.makeit.service.platform.alarm; package com.makeit.service.platform.alarm;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO; import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO; import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
...@@ -57,4 +58,6 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> { ...@@ -57,4 +58,6 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> {
PlatAlarmRecord convertToPlatAlarmRecord(PlatAlarmCheckDTO platAlarmCheckDTO); PlatAlarmRecord convertToPlatAlarmRecord(PlatAlarmCheckDTO platAlarmCheckDTO);
void getElderListByDeviceId(PlatAlarmCheckDTO platAlarmCheckDTO); void getElderListByDeviceId(PlatAlarmCheckDTO platAlarmCheckDTO);
void dealAlarm(BaseIdDTO dto);
} }
...@@ -3,6 +3,7 @@ package com.makeit.service.platform.alarm.impl; ...@@ -3,6 +3,7 @@ package com.makeit.service.platform.alarm.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.entity.BaseBusEntity; import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity; import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
...@@ -416,4 +417,14 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -416,4 +417,14 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
return sb.toString(); return sb.toString();
} }
@Override
public void dealAlarm(BaseIdDTO dto) {
if (StringUtils.isEmpty(dto.getId())) {
throw new RuntimeException("id为空");
}
PlatAlarmRecord platAlarmRecord = getById(dto.getId());
platAlarmRecord.setStatus(CommonEnum.YES.getValue());
platAlarmRecord.setDealDate(LocalDateTime.now());
updateById(platAlarmRecord);
}
} }
...@@ -13,4 +13,5 @@ import com.makeit.entity.platform.elder.PlatElderSleep; ...@@ -13,4 +13,5 @@ import com.makeit.entity.platform.elder.PlatElderSleep;
*/ */
public interface PlatElderSleepService extends IService<PlatElderSleep> { public interface PlatElderSleepService extends IService<PlatElderSleep> {
void elderSleepSleepAnalysisTask();
} }
...@@ -6,6 +6,7 @@ import com.makeit.common.entity.BaseBusEntity; ...@@ -6,6 +6,7 @@ import com.makeit.common.entity.BaseBusEntity;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.saas.PlatTenant; import com.makeit.entity.saas.PlatTenant;
import com.makeit.enums.CommonEnum; import com.makeit.enums.CommonEnum;
import com.makeit.enums.report.DeviceNameEnum;
import com.makeit.global.aspect.tenant.TenantIdIgnore; import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.service.IotOrgService; import com.makeit.module.iot.service.IotOrgService;
import com.makeit.module.iot.vo.DeviceInstanceEntity; import com.makeit.module.iot.vo.DeviceInstanceEntity;
...@@ -13,6 +14,7 @@ import com.makeit.module.iot.vo.DeviceState; ...@@ -13,6 +14,7 @@ import com.makeit.module.iot.vo.DeviceState;
import com.makeit.module.system.service.SysDictionaryCategoryService; import com.makeit.module.system.service.SysDictionaryCategoryService;
import com.makeit.module.system.vo.DictionaryVo; import com.makeit.module.system.vo.DictionaryVo;
import com.makeit.service.platform.device.PlatDeviceService; import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderSleepService;
import com.makeit.service.saas.PlatTenantService; import com.makeit.service.saas.PlatTenantService;
import com.makeit.utils.DeviceCacheUtil; import com.makeit.utils.DeviceCacheUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -43,6 +45,8 @@ public class IotSyncTask { ...@@ -43,6 +45,8 @@ public class IotSyncTask {
private SysDictionaryCategoryService sysDictionaryCategoryService; private SysDictionaryCategoryService sysDictionaryCategoryService;
@Autowired @Autowired
private DeviceCacheUtil deviceCacheUtil; private DeviceCacheUtil deviceCacheUtil;
@Autowired
private PlatElderSleepService platElderSleepService;
/** /**
* 一小时同步一次 * 一小时同步一次
...@@ -108,7 +112,8 @@ public class IotSyncTask { ...@@ -108,7 +112,8 @@ public class IotSyncTask {
} }
platDevice.setOriDeviceId(iotDevice.getId()); platDevice.setOriDeviceId(iotDevice.getId());
platDevice.setName(iotDevice.getName()); platDevice.setName(iotDevice.getName());
platDevice.setProductName(iotDevice.getProductName()); String productName = iotDevice.getProductName();
platDevice.setProductName(productName);
platDevice.setProductId(iotDevice.getProductId()); platDevice.setProductId(iotDevice.getProductId());
if(iotDevice.getRegistryTime()!=null) { if(iotDevice.getRegistryTime()!=null) {
LocalDateTime registryTime = LocalDateTime.ofEpochSecond(iotDevice.getRegistryTime() / 1000, 0, ZoneOffset.ofHours(8)); LocalDateTime registryTime = LocalDateTime.ofEpochSecond(iotDevice.getRegistryTime() / 1000, 0, ZoneOffset.ofHours(8));
...@@ -120,7 +125,8 @@ public class IotSyncTask { ...@@ -120,7 +125,8 @@ public class IotSyncTask {
platDevice.setStatus(deviceState.getValue()); platDevice.setStatus(deviceState.getValue());
//todo 根据类型名称来匹配 //todo 根据类型名称来匹配
platDevice.setCategory(dicNameIdMap.get(iotDevice.getProductName())); String categoryName = DeviceNameEnum.getNameByPrefix(productName);
platDevice.setCategory(dicNameIdMap.get(categoryName));
// platDevice.setFirmwareVersion(); // platDevice.setFirmwareVersion();
// platDevice.setLastOnlineData(); // platDevice.setLastOnlineData();
// platDevice.setOrgId(); // platDevice.setOrgId();
...@@ -145,4 +151,15 @@ public class IotSyncTask { ...@@ -145,4 +151,15 @@ public class IotSyncTask {
* *
*/ */
/**
* 长者睡眠分析
*/
//@Scheduled(cron = "0 6 * * *")
@TenantIdIgnore
public void elderSleepSleepAnalysisTask() {
log.info("开始定时分析长者睡眠质量");
platElderSleepService.elderSleepSleepAnalysisTask();
log.info("定时分析长者睡眠质量结束");
}
} }
...@@ -21,18 +21,19 @@ ...@@ -21,18 +21,19 @@
<dependency> <dependency>
<groupId>com.makeit</groupId> <groupId>com.makeit</groupId>
<artifactId>server-common</artifactId> <artifactId>saas-module</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.makeit</groupId> <groupId>com.makeit</groupId>
<artifactId>saas-module</artifactId> <artifactId>server-module</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.makeit</groupId> <groupId>com.makeit</groupId>
<artifactId>server-module</artifactId> <artifactId>server-api</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
......
package com.makeit.mqtt;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "发送mqtt消息")
@RestController
@RequestMapping("/mqtt")
public class MqttController {
@Autowired
private MqttPushClient mqttPushClient;
@Autowired
private IotDevicePropertiesOperateService devicePropertiesOperateService;
@ApiOperation("测试")
@PostMapping("testMqtt")
@AuthIgnore
@TenantIdIgnore
public ApiResponseEntity<Void> testMqtt() {
devicePropertiesOperateService.deviceWrite("1701240048151490560", 1,1,1);
return ApiResponseUtils.success();
}
}
...@@ -44,7 +44,7 @@ public class IotDeviceInfoContentFall { ...@@ -44,7 +44,7 @@ public class IotDeviceInfoContentFall {
@Test @Test
void getOrgDevice() { void getOrgDevice() {
iotOrgService.getOrgDevice("1698939546961244160"); iotOrgService.getOrgDevice("1701223487902642176");
} }
@Test @Test
...@@ -64,7 +64,7 @@ public class IotDeviceInfoContentFall { ...@@ -64,7 +64,7 @@ public class IotDeviceInfoContentFall {
@Test @Test
void getDeviceLogByTimeRange() { void getDeviceLogByTimeRange() {
iotProductDeviceService.getDeviceLogByTimeRange("1701127702523473920", "reportProperty", 100, "2023-09-12 00:00:00", "2023-09-12 23:59:00"); iotProductDeviceService.getDeviceLogByTimeRange("1702604383784333312", "reportProperty", 1000, "2023-09-19 14:23:32", "2023-09-19 15:23:32");
} }
@Test @Test
......
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