diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/DeviceDataController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/DeviceDataController.java index 34bfe68..a448691 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/DeviceDataController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/DeviceDataController.java @@ -2,16 +2,21 @@ package com.hnac.hzims.operational.census.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.census.service.DeviceDataService; -import com.hnac.hzims.operational.census.vo.RealVo; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataCondition; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataList; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; +import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.core.response.HzPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.List; /** * @author ysj @@ -27,16 +32,14 @@ public class DeviceDataController { @ApiOperation("实时数据查询") @PostMapping("/real") @ApiOperationSupport(order = 1) - public R real(@RequestParam(value = "code") String code, - @RequestParam(value = "signages") String signages) { - return R.data(service.real(code,signages)); + public R> real(@RequestBody RealDataSearchPO search) { + return service.real(search); } - @ApiOperation("实时数据查询") + @ApiOperation("历史数据查询") @PostMapping("/history") @ApiOperationSupport(order = 1) - public R history(@RequestParam(value = "code") String code, - @RequestParam(value = "signages") String signages) { - return R.data(service.real(code,signages)); + public R> history(AnalyzeDataCondition analyzeDataCondition) { + return service.history(analyzeDataCondition); } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/DeviceDataService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/DeviceDataService.java index f9aaa2d..6726c14 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/DeviceDataService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/DeviceDataService.java @@ -2,11 +2,21 @@ package com.hnac.hzims.operational.census.service; import com.hnac.hzims.operational.census.vo.RealVo; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataCondition; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataList; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; +import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import org.springblade.core.tool.api.R; + +import java.util.List; /** * @author ysj */ public interface DeviceDataService { - RealVo real(String code, String signages); + R> real(RealDataSearchPO search); + + R> history(AnalyzeDataCondition analyzeDataCondition); } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/DeviceDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/DeviceDataServiceImpl.java index 6f284f5..91ca62c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/DeviceDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/DeviceDataServiceImpl.java @@ -2,12 +2,24 @@ package com.hnac.hzims.operational.census.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.esotericsoftware.minlog.Log; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.operational.census.service.DeviceDataService; import com.hnac.hzims.operational.census.vo.RealVo; +import com.hnac.hzinfo.datasearch.PointData; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataCondition; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataList; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; +import com.hnac.hzinfo.datasearch.real.IRealDataSearchClient; +import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.analyse.AnalyseDataSearchClient; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import com.hnac.hzinfo.sdk.core.response.Result; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Value; @@ -21,55 +33,37 @@ import java.util.stream.Collectors; /** * @author ysj */ +@Slf4j @Service @RequiredArgsConstructor public class DeviceDataServiceImpl implements DeviceDataService { - private final RedisTemplate redisTemplate; + private final IRealDataSearchClient realDataSearchClient; - @Value("${hzims.operation.realIdKey}") - public String real_id_cofig_final; - - public String device_cache_cofig_final = "hzims:equipment:emInfo:deviceCode.emInfoList"; + private final AnalyseDataSearchClient analyseDataSearchClient; + /** + * 实时数据 + * @param search + * @return + */ @Override - public RealVo real(String code, String signages) { - // 缓存设备数据 - List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference>() { - }); - if(CollectionUtil.isEmpty(devices)){ - throw new ServiceException("不存在设备!"); - } - List filters = devices.stream().filter(device->device.getEmCode().equals(code)).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(filters)){ - throw new ServiceException("不存在设备!"); + public R> real(RealDataSearchPO search) { + try{ + return realDataSearchClient.getRealDataByAnalyzeCode(search); + }catch (Exception exception){ + throw new ServiceException("系统异常!"); } - // 设备标识 - Map point = filters.get(0).getPoint(); - if(MapUtils.isEmpty(point)){ - throw new ServiceException("设备未绑定模型实列监测点位!"); - } - if(!point.containsKey(signages)){ - throw new ServiceException("设备未绑定模型实列监测点位!"); - } - // 查找realId数据 - RealVo real = new RealVo(); - real.setRealId(point.get(signages)); - real.setValue(this.getRealMap().get(real.getRealId())); - real.setQuality("0"); - return real; } - /** - * 获取实时数据 + * 历史数据 + * @param analyzeDataCondition * @return */ - private Map getRealMap() { - String json = (String) redisTemplate.opsForValue().get(real_id_cofig_final); - if(StringUtil.isBlank(json)){ - return null; - } - return JSONObject.parseObject(json, new TypeReference>() {}); + @Override + public R> history(AnalyzeDataCondition analyzeDataCondition) { + Result> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCode(analyzeDataCondition); + return R.data(result.getData()); } } \ No newline at end of file