Commit 59e10062 authored by wujiang's avatar wujiang

修改偏差率

parent 966888c5
......@@ -94,6 +94,8 @@ public class CommonConstans {
public static final String QueryStringEquipmentIndexName = "equipmentIndexName.keyword";
//es EquipIndexName 查绚关键字
public static final String QueryStringEquipmentIndexNameNotKeyword = "equipmentIndexName";
public static final String QueryStringEquipmentSpecificNameNotKeyword = "equipmentSpecificName.keyword";
//es gatewayId 查绚关键字
public static final String QueryStringGateWayId = "gatewayId.keyword";
public static final String QueryStringFrontMoudle = "frontModule.keyword";
......
......@@ -764,12 +764,16 @@ public class MonitorFanIdxController extends BaseController {
return ResponseHelper.buildResponse(monitorFanIndicatorImpl.collectingBox(gatewayId, current, size));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "汇流箱支路电流偏差率")
@GetMapping("/getDeaviAtionRate")
public ResponseModel<Page<DeaviationRateDto>> getDeaviAtionRate(@RequestParam(value = "stationId") String stationId, String equipNumber) {
return ResponseHelper.buildResponse(monitorFanIndicatorImpl.getDeaviAtionRate(stationId, equipNumber));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "汇流箱支路电流偏差率")
@GetMapping("/getDeaviAtionRate")
public ResponseModel<ResultsData> getDeaviAtionRate(@RequestParam(value = "stationId") String stationId,
@RequestParam(value = "zz") String zz, @RequestParam(value = "nbq") String nbq,
@RequestParam(value = "hlx") String hlx) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
return ResponseHelper.buildResponse(monitorFanIndicatorImpl.getDeaviAtionRate(gatewayId, zz, nbq, hlx));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......
......@@ -2157,28 +2157,59 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
public Page<DeaviationRateDto> getDeaviAtionRate(String stationId, String equipNumber) {
StationCacheInfoDto stationCacheInfoDto = commonServiceImpl.getStationCacheInfoDtoByStationId(stationId);
Page<DeaviationRateDto> deaviationRateDtoPage = new Page<>(1, 100);
List<DeaviationRateDto> deaviationRateDtoList = new ArrayList<>();
Map<String, List<String>> queryCondition = new HashMap<>();
queryCondition.put(CommonConstans.QueryStringEquipmentNumber, Arrays.asList(equipNumber));
queryCondition.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
Map<String, String> shouldCodtion = new HashMap<>();
shouldCodtion.put(CommonConstans.QueryStringEquipmentIndexName, "路电流");
List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondition, shouldCodtion, ESEquipments.class);
Random random = new Random();
indicatorsDtoList.forEach(esEquipments -> {
DeaviationRateDto deaviationRateDto = new DeaviationRateDto();
deaviationRateDto.setName(esEquipments.getEquipmentIndexName());
deaviationRateDto.setCurrentValue(esEquipments.getValue());
deaviationRateDto.setOffset(String.valueOf(random.nextDouble()));
deaviationRateDto.setAttValue(String.valueOf(random.nextDouble()));
deaviationRateDtoList.add(deaviationRateDto);
});
deaviationRateDtoPage.setRecords(deaviationRateDtoList);
return deaviationRateDtoPage;
}
public ResultsData getDeaviAtionRate(String gatewayId, String zz, String nbq, String hlx) {
ArrayList<Map<String, Object>> resultList = new ArrayList<>();
Map<String, List<String>> queryConditon = new HashMap<>();
queryConditon.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
Map<String, String> likeMap = new HashMap<>();
likeMap.put(CommonConstans.QueryStringEquipmentIndexNameNotKeyword, "路电流");
//hlx=hlx.replace("#0", "#");
//likeMap.put(CommonConstans.QueryStringEquipmentSpecificNameNotKeyword, hlx);
String nhlx =zz+"/"+nbq+"/"+ hlx.replace("#0", "#");
List<ESEquipments> list = commonServiceImpl.getListDataByCondtionsAndLike(queryConditon, null,
ESEquipments.class, likeMap);
// Map<String, List<String>> queryConditon1 = new HashMap<>();
// queryConditon1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
// Map<String, String> likeMap1 = new HashMap<>();
// likeMap1.put(CommonConstans.QueryStringEquipmentIndexNameNotKeyword, "平均电流");
// List<ESEquipments> list1 = commonServiceImpl.getListDataByCondtionsAndLike(queryConditon, null,
// ESEquipments.class, likeMap1);
if (!ValidationUtil.isEmpty(list)) {
list=list.stream().filter(i->i.getEquipmentSpecificName().contains(nhlx)).collect(Collectors.toList());
Double avageValue = 0.0;
avageValue = list.stream().filter(e -> !ObjectUtils.isEmpty(e.getValueF()))
.mapToDouble(l -> Double.parseDouble(l.getValueF().toString())).average().getAsDouble();
avageValue = Double.valueOf(String.format(CommonConstans.Twodecimalplaces, avageValue));
for (ESEquipments s : list) {
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("hlx", s.getEquipmentIndexName());
double now = Double.valueOf(String.format(CommonConstans.Twodecimalplaces, s.getValueF()));
resultMap.put("now", now);
resultMap.put("avg", avageValue);
double c = now - avageValue;
if (c < 0) {
c = -c;
}
double lsv = c / avageValue;
lsv = Double.valueOf(String.format(CommonConstans.Twodecimalplaces, lsv));
resultMap.put("lsv", lsv);
resultList.add(resultMap);
}
}
// 构建平台数据
DataGridMock DataGridMock = new DataGridMock(0, resultList.size(), false, 0, resultList);
ColModel colModelEventMovement = new ColModel("hlx", "hlx", "汇流箱", "汇流箱", "dataGrid", "hlx");
ColModel colModelStationName = new ColModel("now", "now", "当前值", "当前值", "dataGrid", "now");
ColModel colModelEventDesc = new ColModel("avg", "avg", "平均值", "平均值", "dataGrid", "avg");
ColModel colModelAlarmGroupName = new ColModel("pcv", "pcv", "偏差率", "偏差率", "dataGrid", "pcv");
List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelEventDesc,
colModelAlarmGroupName);
ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
return resultsData;
}
// @Scheduled(cron = "0 */10 * * * ?")
// //@Scheduled(cron = "0/1 * * * * ?")
......
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 to comment