Browse Source

#检修流程

zhongwei
yang_shj 1 year ago
parent
commit
1c87a81957
  1. 21
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/DeviceDataController.java
  2. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/DeviceDataService.java
  3. 68
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/DeviceDataServiceImpl.java

21
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.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.census.service.DeviceDataService; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* @author ysj * @author ysj
@ -27,16 +32,14 @@ public class DeviceDataController {
@ApiOperation("实时数据查询") @ApiOperation("实时数据查询")
@PostMapping("/real") @PostMapping("/real")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
public R<RealVo> real(@RequestParam(value = "code") String code, public R<List<FieldsData>> real(@RequestBody RealDataSearchPO search) {
@RequestParam(value = "signages") String signages) { return service.real(search);
return R.data(service.real(code,signages));
} }
@ApiOperation("实时数据查询") @ApiOperation("历史数据查询")
@PostMapping("/history") @PostMapping("/history")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
public R<RealVo> history(@RequestParam(value = "code") String code, public R<HzPage<AnalyzeDataList>> history(AnalyzeDataCondition analyzeDataCondition) {
@RequestParam(value = "signages") String signages) { return service.history(analyzeDataCondition);
return R.data(service.real(code,signages));
} }
} }

12
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.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 * @author ysj
*/ */
public interface DeviceDataService { public interface DeviceDataService {
RealVo real(String code, String signages); R<List<FieldsData>> real(RealDataSearchPO search);
R<HzPage<AnalyzeDataList>> history(AnalyzeDataCondition analyzeDataCondition);
} }

68
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.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.esotericsoftware.minlog.Log;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.census.service.DeviceDataService; import com.hnac.hzims.operational.census.service.DeviceDataService;
import com.hnac.hzims.operational.census.vo.RealVo; 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.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springblade.core.log.exception.ServiceException; 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.CollectionUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -21,55 +33,37 @@ import java.util.stream.Collectors;
/** /**
* @author ysj * @author ysj
*/ */
@Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class DeviceDataServiceImpl implements DeviceDataService { public class DeviceDataServiceImpl implements DeviceDataService {
private final RedisTemplate redisTemplate; private final IRealDataSearchClient realDataSearchClient;
@Value("${hzims.operation.realIdKey}") private final AnalyseDataSearchClient analyseDataSearchClient;
public String real_id_cofig_final;
public String device_cache_cofig_final = "hzims:equipment:emInfo:deviceCode.emInfoList";
/**
* 实时数据
* @param search
* @return
*/
@Override @Override
public RealVo real(String code, String signages) { public R<List<FieldsData>> real(RealDataSearchPO search) {
// 缓存设备数据 try{
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() { return realDataSearchClient.getRealDataByAnalyzeCode(search);
}); }catch (Exception exception){
if(CollectionUtil.isEmpty(devices)){ throw new ServiceException("系统异常!");
throw new ServiceException("不存在设备!");
}
List<EminfoAndEmParamVo> filters = devices.stream().filter(device->device.getEmCode().equals(code)).collect(Collectors.toList());
if(CollectionUtil.isEmpty(filters)){
throw new ServiceException("不存在设备!");
} }
// 设备标识
Map<String,String> 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 * @return
*/ */
private Map<String, String> getRealMap() { @Override
String json = (String) redisTemplate.opsForValue().get(real_id_cofig_final); public R<HzPage<AnalyzeDataList>> history(AnalyzeDataCondition analyzeDataCondition) {
if(StringUtil.isBlank(json)){ Result<HzPage<AnalyzeDataList>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCode(analyzeDataCondition);
return null; return R.data(result.getData());
}
return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {});
} }
} }
Loading…
Cancel
Save