Commit 9aacd689 authored by chenzhao's avatar chenzhao

移动端驾驶舱提供接口

parent 948cdc1e
......@@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
@FeignClient(name = "${amos.idx.name:AMOS-IDX}", path = "idx", configuration = {FeignConfiguration.class})
......@@ -24,4 +28,23 @@ public interface IdxFeign {
@GetMapping("/table/getPage")
FeignClientResult<Page<Map<String, Object>>> getPage(@RequestParam Map<String, Object> map);
@RequestMapping(value = "/publicAnalysis/getStationMessage", method = RequestMethod.GET, consumes = "application/json")
FeignClientResult<List<Map<String, Object>>> getStationMark(@RequestParam(value = "code") String code);
@RequestMapping(value = "/publicAnalysis/appletSroce", method = RequestMethod.GET, consumes = "application/json")
Map<String, Object> getStationMarkList(@RequestParam(value = "code") String code,
@RequestParam(value = "pageNumber") String pageNumber,
@RequestParam(value = "pageSize") String pageSize);
@RequestMapping(value = "/jxIopAnalysis/stationRanking", method = RequestMethod.GET, consumes = "application/json")
FeignClientResult<Map<String, Object>> stationRanking(@RequestParam("pageNumber") Long pageNumber,
@RequestParam("pageSize") Long pageSize,
@RequestParam(required = false, value = "stationType") String type,
@RequestParam(required = false, value = "parentCode") String parentCode);
}
......@@ -69,4 +69,8 @@ public interface StationBasicMapper extends BaseMapper<StationBasic> {
*/
List<StationBasicDto> getStationBasicListAll();
StationBasicDto getStationInfoByCode(@Param("stationCode")String stationCode);
List<StationBasicDto> getStationsByAreaCode(@Param("areaCode")String stationCode);
}
......@@ -192,4 +192,23 @@
FROM
station_basic
</select>
<select id="getStationInfoByCode" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto">
select
*
from
station_basic
where
station_code = #{stationCode}
</select>
<select id="getStationsByAreaCode" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto">
select
*
from
station_basic
where
area_code = #{areaCode}
</select>
</mapper>
package com.yeejoin.amos.boot.module.jxiop.api.amosprojectmapper;
public interface CompanyMapper {
public String getAreaCompanyCode(String code);
}
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.util.CommonResponse;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.AppletMonitorServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*;
@RestController
@Api(tags = "小程序-监盘")
@RequestMapping(value = "/applet")
public class AppletMonitorController {
@Autowired
AppletMonitorServiceImpl appletMonitorService;
@Autowired
StationBasicMapper stationBasicMapper;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图-总概览")
@GetMapping("/CockpitData")
public ResponseModel<Map<String, Object>> getData(@RequestParam(value = "code") String code,
@RequestParam(value = "level") String level) {
if ("station".equals(level)){
StationBasicDto stationBasic = stationBasicMapper.getStationInfoByCode(code);
if (stationBasic.getStationType().equals("FDZ")) {
return ResponseHelper.buildResponse(appletMonitorService.getFanStationInfo(stationBasic));
}else {
return ResponseHelper.buildResponse(appletMonitorService.getPvStationInfo(stationBasic));
}
}else {
return ResponseHelper.buildResponse(appletMonitorService.getAreaInfo(code));
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto;
import com.yeejoin.amos.boot.module.jxiop.api.feign.IdxFeign;
import com.yeejoin.amos.boot.module.jxiop.api.amosprojectmapper.CompanyMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ESEquipmentsDTO;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class AppletMonitorServiceImpl {
@Autowired
CommonServiceImpl commonServiceImpl;
@Autowired
StationBasicMapper stationBasicMapper;
@Autowired
CompanyMapper companyMapper;
@Autowired
CommonServiceImpl commonService;
@Autowired
MonitorFanIndicatorImpl monitorFanIndicator;
@Autowired
IdxFeign idxFeign;
@Autowired
AmosRequestContext requestContext;
public Map<String,Object> getFanStationInfo(StationBasicDto stationBasic ){
String gatewayId = stationBasic.getFanGatewayId();
Map<String, Object> columnMap = new HashMap<>();
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("30秒平均风速", "日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
List<ESEquipments> result2 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
columnMap.put("日发电量", String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result2, "日发电量")));
columnMap.put("月发电量", String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result2, "月发电量")));
columnMap.put("年发电量", String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result2, "年发电量")));
columnMap.put("30秒平均风速", String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getAvagerByEquipmentIndxName(result2, "30秒平均风速")));
Map<String, List<String>> queryCondtion1 = new HashMap<>();
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"));
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result1 = commonService.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
columnMap.put("有功功率", String.format("%.2f", result1.get(0).getValueF()));
String num = monitorFanIndicator.getEquipCount(gatewayId, "FDZ");
columnMap.put("风机台数", num);
Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber());
columnMap.put("装机容量", String.format("%.2f", capacityl));
Map<String, Object> data = new HashMap<>();
data.put("installedCapacity", columnMap.get("装机容量").toString());
data.put("dayPowerGeneration", columnMap.get("日发电量").toString());
data.put("equipNum", columnMap.get("风机台数").toString().replace(".0", ""));
data.put("monthPowerGeneration", columnMap.get("月发电量").toString());
data.put("windSpeed", columnMap.get("30秒平均风速").toString());
data.put("yearPowerGeneration", columnMap.get("年发电量").toString());
data.put("activePower", columnMap.get("有功功率"));
data.put("dailyUseOfHour", String.format("%.2f", ((Double.parseDouble(columnMap.get("日发电量").toString()) * 10) / (Double.parseDouble(columnMap.get("装机容量").toString())))));
//风机运行 及 停机
List<ESEquipmentsDTO> equipmentsDTOS = monitorFanIndicator.getFanStatusList(String.valueOf(stationBasic.getSequenceNbr()));
Map<String, Long> countMap = equipmentsDTOS.stream()
.collect(Collectors.groupingBy(ESEquipmentsDTO::getAddress, Collectors.counting()));
data.put("closeNum", countMap.containsKey("停机状态") ? String.valueOf(countMap.get("停机状态")) : "0");
data.put("operationNum",Integer.parseInt(num) - Integer.parseInt(data.get("closeNum").toString()));
Map<String, Object> stationMark = idxFeign.getStationMarkList(stationBasic.getProjectOrgCode(),"1","4");
// Map<String, Object> result = stationMark.getResult();
List<String> list = Arrays.asList("P1", "S1", "H2", "V1");
// P1 工况管控分数 S1 设备管控分数 H2 其他分数 V1 人员管控分数
list.forEach(e->{
data.put(e,stationMark.get(e));
});
data.put("value",stationMark.get("value"));
return data;
}
public Map<String,Object> getPvStationInfo(StationBasicDto stationBasic){
String gatewayId = stationBasic.getFanGatewayId();
String boosterGatewayId = stationBasic.getBoosterGatewayId();
String[] columnList = new String[]{CommonConstans.taiHeGenIndicatorDay, CommonConstans.taiHeGenIndicatorMonth, CommonConstans.taiHeGenIndicatorYear};
Map<String, Object> columnMap = new HashMap<>();
//日 月 年发电量同仅统计逆变器数据
List<Map<String, Object>> mapList;
for (String column : columnList) {
Double result = commonService.getTotalByIndicatiorByGF(boosterGatewayId, column);
columnMap.put(column, result);
}
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P", "WTX-801_25_WTX-801_总辐射累计", "WTX-801_25_WTX-801_总辐射", "313光差保护_总反向有功电度"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result1 = commonService.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
columnMap.put("有功功率", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv));
String num = monitorFanIndicator.getEquipCount(gatewayId, "GF");
columnMap.put("风机台数", num);
Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber());
//装机容量保留两位小数
columnMap.put("装机容量", String.format("%.2f", capacityl));
Map<String, Object> data = new HashMap<>();
data.put("installedCapacity", columnMap.get("装机容量").toString());
data.put("dayPowerGeneration", columnMap.get(CommonConstans.taiHeGenIndicatorDay).toString());
data.put("equipNum", columnMap.get("风机台数").toString().replace(".0", ""));
data.put("monthPowerGeneration", columnMap.get(CommonConstans.taiHeGenIndicatorMonth).toString());
data.put("irradiation", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射")));
data.put("yearPowerGeneration", columnMap.get(CommonConstans.taiHeGenIndicatorYear).toString());
data.put("activePower", columnMap.get("有功功率").toString());
data.put("dailyUseOfHour", String.format("%.2f", ((Double.parseDouble(columnMap.get(CommonConstans.taiHeGenIndicatorDay).toString()) * CommonConstans.wkwhToMv) / (Double.parseDouble(columnMap.get("装机容量").toString())))));
data.put("globalRadiation", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射累计")));
//综合效率 = 发电量/理论发电量
//理论发电量 = 峰值日照数 * 总装机容量
//峰值日照数 = 累计辐照度/3.6
Double todayPower = Double.valueOf(columnMap.get(CommonConstans.taiHeGenIndicatorDay).toString());
Double total = commonService.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射累计");
if (todayPower > 0 && total > 0) {
Double overallEfficiency = todayPower * CommonConstans.wkwhToMv / ((total / 3.6) * capacityl);
data.put("combinedEfficiency", String.format("%.2f", overallEfficiency * 100) + "%");//综合效率
} else {
data.put("combinedEfficiency", "0.00%");//综合效率
}
Map<String, Object> stationMark = idxFeign.getStationMarkList(stationBasic.getProjectOrgCode(),"1","4");
List<String> list = Arrays.asList("P1", "S1", "H2", "V1");
// P1 工况管控分数 S1 设备管控分数 H2 其他分数 V1 人员管控分数
list.forEach(e->{
data.put(e,stationMark.get(e));
});
data.put("value",stationMark.get("value"));
return data;
}
public Map<String,Object> getAreaInfo(String code) {
List<StationBasicDto> stations = stationBasicMapper.getStationsByAreaCode(code);
Map<String, Object> result = new HashMap<>();
//全部场站的总装机容量
double installedCapacity = stations.stream().mapToDouble(StationBasicDto::getInstalledCapacity).sum();
result.put("installedCapacity",String.format("%.2f",installedCapacity));
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P", "WTX-801_25_WTX-801_总辐射累计", "WTX-801_25_WTX-801_总辐射", "313光差保护_总反向有功电度"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, stations.stream().map(StationBasicDto::getBoosterGatewayId).collect(Collectors.toList()));
List<ESEquipments> result1 = commonService.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
List<StationBasicDto> fdz = stations.stream().filter(e -> e.getStationType().equals("FDZ")).collect(Collectors.toList());
Map<String, List<String>> queryCondtion2 = new HashMap<>();
queryCondtion2.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"));
queryCondtion2.put(CommonConstans.QueryStringGateWayId, Arrays.asList(fdz.get(0).getBoosterGatewayId()));
List<ESEquipments> result2 = commonService.getListDataByCondtions(queryCondtion2, null, ESEquipments.class);
stations.removeAll(fdz);
List<Map<String,Object>> list = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("type","风电");
data.put("installedCapacity",String.format("%.2f",fdz.stream().mapToDouble(StationBasicDto::getInstalledCapacity).sum()));
data.put("num",stations.size());
data.put("activePower",String.format("%.2f", result2.get(0).getValueF()));
list.add(data);
Map<String, Object> data2 = new HashMap<>();
data2.put("type","光伏");
data2.put("installedCapacity",String.format("%.2f",stations.stream().mapToDouble(StationBasicDto::getInstalledCapacity).sum()));
data2.put("num",fdz.size());
data2.put("activePower",String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv));
list.add(data2);
result.put("stationList",list);
result.put("activePower",commonService.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv+result2.get(0).getValueF());
double fzl = (commonService.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv+result2.get(0).getValueF())/installedCapacity;
String load = String.format(CommonConstans.Fourdecimalplaces, fzl);
result.put("load",load);
String areaCompanyCode = companyMapper.getAreaCompanyCode(code);
Map<String, Object> stationMark = idxFeign.getStationMarkList(areaCompanyCode,"1","4");
List<String> params = Arrays.asList("P1", "S1", "H2", "V1");
// P1 工况管控分数 S1 设备管控分数 H2 其他分数 V1 人员管控分数
params.forEach(e->{
result.put(e,stationMark.get(e));
});
result.put("value",stationMark.get("value"));
//获取区域场站排名
FeignClientResult<Map<String, Object>> map = idxFeign.stationRanking(1L, Long.MAX_VALUE, "FDZ", areaCompanyCode);
FeignClientResult<Map<String, Object>> map1 = idxFeign.stationRanking(1L, Long.MAX_VALUE, "JZSGFDZ", areaCompanyCode);;
Map<String, Object> result3 = map.getResult();
Map<String, Object> result4 = map1.getResult();
result.put("rankingFD", result3.get("records"));
result.put("rankingGF", result4.get("records"));
Map<String, List<String>> queryCondtion1 = new HashMap<>();
List<String> collect = fdz.stream().map(StationBasicDto::getFanGatewayId).collect(Collectors.toList());
collect.addAll(stations.stream().map(StationBasicDto::getBoosterGatewayId).collect(Collectors.toList()));
queryCondtion1.put(CommonConstans.QueryStringGateWayId, collect);
Map<String, String> likeMap = new HashMap<String, String>();
likeMap.put(CommonConstans.QueryStringEquipmentIndexName, "发电量");
List<ESEquipments> resultWarn = commonServiceImpl.getListDataByCondtions(queryCondtion1, null,
ESEquipments.class, likeMap);
double dayPowerGeneration = resultWarn.stream().filter(e -> e.getEquipmentIndexName().contains("日发电量")).mapToDouble(ESEquipments::getValueF).sum();
double monthPowerGeneration = resultWarn.stream().filter(e -> e.getEquipmentIndexName().contains("月发电量")).mapToDouble(ESEquipments::getValueF).sum();
double yearPowerGeneration = resultWarn.stream().filter(e -> e.getEquipmentIndexName().contains("年发电量")).mapToDouble(ESEquipments::getValueF).sum();
result.put("dayPowerGeneration",String.format("%.4f",dayPowerGeneration));
result.put("monthPowerGeneration",String.format("%.4f",monthPowerGeneration));
result.put("yearPowerGeneration",String.format("%.4f",yearPowerGeneration));
return result;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.api.amosprojectmapper.CompanyMapper">
<select id="getAreaCompanyCode" resultType="string">
select
ORG_CODE
from
privilege_company
where
COMPANY_CODE = #{code}
and
LEVEL = 'area'
and IS_DELETED = 0
</select>
</mapper>
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