Commit 90ec7ecf by huangjy

feat,查询设备日志

parent aa39aee9
...@@ -10,6 +10,7 @@ import com.makeit.entity.saas.analysis.SaasSleepEvaluateReport; ...@@ -10,6 +10,7 @@ import com.makeit.entity.saas.analysis.SaasSleepEvaluateReport;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.service.saas.SaasDiseaseEvaluateReportService; import com.makeit.service.saas.SaasDiseaseEvaluateReportService;
import com.makeit.service.saas.SaasSleepEvaluateReportService; import com.makeit.service.saas.SaasSleepEvaluateReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@RestController @RestController
@RequestMapping("/saas/diseaseEvaluateReport") @RequestMapping("/saas/diseaseEvaluateReport")
@Api(tags = "saas端-报告管理")
public class SaasDiseaseEvaluateReportController { public class SaasDiseaseEvaluateReportController {
......
...@@ -8,6 +8,7 @@ import com.makeit.dto.saas.analysis.SaasDiseaseModelDTO; ...@@ -8,6 +8,7 @@ import com.makeit.dto.saas.analysis.SaasDiseaseModelDTO;
import com.makeit.entity.saas.analysis.SaasDiseaseModel; import com.makeit.entity.saas.analysis.SaasDiseaseModel;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.service.saas.SaasDiseaseModelService; import com.makeit.service.saas.SaasDiseaseModelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@RestController @RestController
@RequestMapping("/saas/diseaseModel") @RequestMapping("/saas/diseaseModel")
@Api(tags = "saas端-模型管理")
public class SaasDiseaseModelController { public class SaasDiseaseModelController {
......
...@@ -8,6 +8,7 @@ import com.makeit.dto.saas.analysis.SaasElderReportConfigDTO; ...@@ -8,6 +8,7 @@ import com.makeit.dto.saas.analysis.SaasElderReportConfigDTO;
import com.makeit.entity.saas.analysis.SaasElderReportConfig; import com.makeit.entity.saas.analysis.SaasElderReportConfig;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.service.saas.SaasElderReportConfigService; import com.makeit.service.saas.SaasElderReportConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@RestController @RestController
@RequestMapping("/saas/elderReportConfig") @RequestMapping("/saas/elderReportConfig")
@Api(tags = "saas端-报告管理")
public class SaasElderReportConfigController { public class SaasElderReportConfigController {
@Autowired @Autowired
private SaasElderReportConfigService saasElderReportConfigService; private SaasElderReportConfigService saasElderReportConfigService;
......
...@@ -9,6 +9,7 @@ import com.makeit.entity.saas.analysis.SaasModelManage; ...@@ -9,6 +9,7 @@ import com.makeit.entity.saas.analysis.SaasModelManage;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.module.admin.vo.plat.PlatTenantVO; import com.makeit.module.admin.vo.plat.PlatTenantVO;
import com.makeit.service.saas.SaasModelManageService; import com.makeit.service.saas.SaasModelManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -28,13 +29,14 @@ import java.util.List; ...@@ -28,13 +29,14 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/saas/modelManage") @RequestMapping("/saas/modelManage")
@Api(tags = "saas端-报告管理")
public class SaasModelManageController { public class SaasModelManageController {
@Autowired @Autowired
private SaasModelManageService saasModelManageService; private SaasModelManageService saasModelManageService;
@Action(module = "租户管理-租户", name = "分页列表", code = "saas:modelManage:page") @Action(module = "数据分析-模型管理", name = "分页列表", code = "saas:modelManage:page")
@ApiOperation("分页列表") @ApiOperation("分页列表")
@PostMapping("list") @PostMapping("list")
public ApiResponseEntity<List<SaasModelManage>> list(){ public ApiResponseEntity<List<SaasModelManage>> list(){
......
...@@ -8,6 +8,7 @@ import com.makeit.entity.saas.analysis.SaasReportManage; ...@@ -8,6 +8,7 @@ import com.makeit.entity.saas.analysis.SaasReportManage;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.service.saas.SaasModelManageService; import com.makeit.service.saas.SaasModelManageService;
import com.makeit.service.saas.SaasReportManageService; import com.makeit.service.saas.SaasReportManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -26,13 +27,14 @@ import java.util.List; ...@@ -26,13 +27,14 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/saas/reportManage") @RequestMapping("/saas/reportManage")
@Api(tags = "saas端-报告管理")
public class SaasReportManageController { public class SaasReportManageController {
@Autowired @Autowired
private SaasReportManageService saasReportManageService; private SaasReportManageService saasReportManageService;
@Action(module = "租户管理-租户", name = "分页列表", code = "saas:reportManage:page") @Action(module = "数据分析-报告管理", name = "分页列表", code = "saas:reportManage:page")
@ApiOperation("分页列表") @ApiOperation("分页列表")
@PostMapping("list") @PostMapping("list")
public ApiResponseEntity<List<SaasReportManage>> list(){ public ApiResponseEntity<List<SaasReportManage>> list(){
......
...@@ -9,6 +9,7 @@ import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel; ...@@ -9,6 +9,7 @@ import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.module.admin.dto.plat.PlatTenantDTOVO; import com.makeit.module.admin.dto.plat.PlatTenantDTOVO;
import com.makeit.service.saas.SaasSleepAnalysisModelService; import com.makeit.service.saas.SaasSleepAnalysisModelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@RestController @RestController
@RequestMapping("/saas/sleepAnalysisModel") @RequestMapping("/saas/sleepAnalysisModel")
@Api(tags = "saas端-模型管理")
public class SaasSleepAnalysisModelController { public class SaasSleepAnalysisModelController {
@Autowired @Autowired
......
...@@ -8,6 +8,7 @@ import com.makeit.dto.saas.analysis.SaasSleepEvaluateReportDTO; ...@@ -8,6 +8,7 @@ import com.makeit.dto.saas.analysis.SaasSleepEvaluateReportDTO;
import com.makeit.entity.saas.analysis.SaasSleepEvaluateReport; import com.makeit.entity.saas.analysis.SaasSleepEvaluateReport;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.service.saas.SaasSleepEvaluateReportService; import com.makeit.service.saas.SaasSleepEvaluateReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@RestController @RestController
@RequestMapping("/saas/sleepEvaluateReport") @RequestMapping("/saas/sleepEvaluateReport")
@Api(tags = "saas端-报告管理")
public class SaasSleepEvaluateReportController { public class SaasSleepEvaluateReportController {
......
...@@ -8,6 +8,7 @@ import com.makeit.dto.saas.analysis.SaasSleepEvaluateStandardReportDTO; ...@@ -8,6 +8,7 @@ import com.makeit.dto.saas.analysis.SaasSleepEvaluateStandardReportDTO;
import com.makeit.entity.saas.analysis.SaasSleepEvaluateStandardReport; import com.makeit.entity.saas.analysis.SaasSleepEvaluateStandardReport;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.service.saas.SaasSleepEvaluateStandardReportService; import com.makeit.service.saas.SaasSleepEvaluateStandardReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@RestController @RestController
@RequestMapping("/saas/sleepEvaluateStandardReport") @RequestMapping("/saas/sleepEvaluateStandardReport")
@Api(tags = "saas端-报告管理")
public class SaasSleepEvaluateStandardReportController { public class SaasSleepEvaluateStandardReportController {
......
...@@ -128,6 +128,48 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -128,6 +128,48 @@ public class IotProductDeviceService extends IotCommonService {
return getDeviceLog(deviceId, 10,typeValue); return getDeviceLog(deviceId, 10,typeValue);
} }
public List<DeviceOperationLogEntity> getDeviceLogByTimeRange(String deviceId, int pageSize,String startTime,String endTime) {
IotQueryParam iotQueryParam = buildQueryParam(pageSize);
List<Term> terms = Lists.newArrayList();
Term term1 = Term.builder()
.column("timestamp")
.termType("gte")
.type(Term.Type.or)
.value(startTime)
.terms(Lists.newArrayList())
.options(Lists.newArrayList())
.build();
Term term2 = Term.builder()
.column("timestamp")
.termType("lte")
.type(Term.Type.and)
.value(endTime)
.terms(Lists.newArrayList())
.options(Lists.newArrayList())
.build();
terms.add(term1);
terms.add(term2);
iotQueryParam.setTerms(terms);
String body = JsonUtil.toJson(iotQueryParam);
String url = iotUrl + DEVICE_PREFIX_URL + deviceId + "/logs";
HttpRequest request = buildRequest(url, body);
try {
ResponseMessage responseMessage = sendPost(url, request);
if (responseMessage.getStatus() == 200) {
IotPagerResult pagerResult = JSON.parseObject(responseMessage.getResult().toString(), IotPagerResult.class);
List<DeviceOperationLogEntity> deviceOperationLogEntities = JSONArray.parseArray(pagerResult.getData().toString()).toJavaList(DeviceOperationLogEntity.class);
//Map maps = (Map) JSON.parse(datum.getContent().toString());
return deviceOperationLogEntities;
}
log.error("获取设备接口失败:{}", responseMessage.getMessage());
} catch (IOException e) {
log.error("调用:{}接口异常:{}", url, e.getMessage());
}
return Lists.newArrayList();
}
/** /**
* 获取设备的日志 * 获取设备的日志
* *
...@@ -141,7 +183,7 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -141,7 +183,7 @@ public class IotProductDeviceService extends IotCommonService {
List<Term> terms = Lists.newArrayList(); List<Term> terms = Lists.newArrayList();
Term term = Term.builder() Term term = Term.builder()
.column("type") .column("type")
.termType("eq") .termType("btw")
.type(Term.Type.or) .type(Term.Type.or)
.value(typeValue) .value(typeValue)
.terms(Lists.newArrayList()) .terms(Lists.newArrayList())
......
...@@ -63,6 +63,11 @@ public class IotTest { ...@@ -63,6 +63,11 @@ public class IotTest {
} }
@Test @Test
void getDeviceLogByTimeRange() {
iotProductDeviceService.getDeviceLogByTimeRange("1701127702523473920",100,"2023-09-12 00:00:00","2023-09-12 23:59:00");
}
@Test
void getIotOrgInfo() { void getIotOrgInfo() {
iotOrgService.getIotOrgInfo("1698964909267415040"); iotOrgService.getIotOrgInfo("1698964909267415040");
} }
......
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