Commit 691dc667 authored by tangwei's avatar tangwei

解决冲突

parents fef8bab4 497f11df
......@@ -21,17 +21,13 @@ import java.util.List;
@Component
public class KSolarRequestUtil {
@Autowired
private AESUtils aesUtils;
/**
* @return HashMap<String, Object> 发送请求前的准备 准备header信息
* @deprecated 根据厂商编码获取厂商的hearer
*/
public HashMap<String, Object> getHeader() {
HashMap<String, Object> hashMap = new HashMap<>();
HashMap<String, Object> requsetParams = new HashMap<>();
public HashMap<String, String> getHeader() {
HashMap<String, String> hashMap = new HashMap<>();
String requestParam="";
HashMap<String, String> hashMaphead = new HashMap<>();
try {
......@@ -43,6 +39,10 @@ public class KSolarRequestUtil {
hashMaphead.put("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
hashMaphead.put("Authorization", "Basic " + Base64.getUrlEncoder().encodeToString((KSolarConstant.authUsername + ":" + KSolarConstant.authPassword).getBytes(StandardCharsets.UTF_8)));
String ResPonse = HttpUtil.createPost(url).headerMap(hashMaphead, false).body(requestParam).execute().body();
JSONObject jsonObject = JSONObject.parseObject(ResPonse);
jsonObject = (JSONObject) jsonObject.get("token");
String token= (String) jsonObject.get("access_token");
hashMap.put("Authorization", "Bearer "+ token);
return hashMap;
}
......@@ -62,13 +62,8 @@ public class KSolarRequestUtil {
JSONArray jsonArray = null;
List<T> result = new ArrayList<>();
try {
HashMap<String, Object> producerInfo = getHeader();
String baseurl = (String) producerInfo.get("apiurl");
HashMap<String, String> headMap = (HashMap<String, String>) producerInfo.get("header");
String orginalAuthorization = headMap.get("Authorization") + ":";
String url = baseurl + apiurl;
String appsecret = (String) producerInfo.get("appsecret");
JLYHeaderMapHandler(params, headMap, orginalAuthorization, appsecret, apiurl);
HashMap<String, String> headMap = getHeader();
String url = KSolarConstant.baseurl + apiurl;
respone = sendRequest(requestMethod, url, requestParmInfo, headMap);
jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone);
if (!ObjectUtils.isEmpty(jsonArray)) {
......
......@@ -8,4 +8,9 @@ public class KSolarConstant {
public static String authUsername ="kstar";
public static String authPassword ="kstarSecret";
public static String requestPOST="POST";
public static String requestGET="GET";
public static String stationListUrl="/station/list/info";
public static String resovle_rows="rows";
}
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.api.householdapi.controller;
import com.yeejoin.amos.api.householdapi.Utils.HouseholdPvUtils;
import com.yeejoin.amos.api.householdapi.Utils.KSolarRequestUtil;
import com.yeejoin.amos.api.householdapi.face.service.GoLangDataAcquisitionService;
import com.yeejoin.amos.api.householdapi.face.service.KSolarDataAcquisitionService;
import fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -32,7 +33,7 @@ public class HouseholdTestController {
@Autowired
private GoLangDataAcquisitionService goLangDataAcquisitionService;
@Autowired
private KSolarRequestUtil kSolarRequestUtil;
private KSolarDataAcquisitionService kSolarDataAcquisitionService;
/**
......@@ -110,13 +111,13 @@ public class HouseholdTestController {
@PostMapping(value = "/ksolarnew")
@ApiOperation(httpMethod = "POST", value = "科士达", notes = "科士达")
public void ksolarnew() throws IOException {
// goLangDataAcquisitionService.stationList();
kSolarDataAcquisitionService.stationList();
// goLangDataAcquisitionService.stationDetail();
// goLangDataAcquisitionService.collectorList();
//// goLangDataAcquisitionService.inverterList();
// goLangDataAcquisitionService.collectorDetail();
// goLangDataAcquisitionService.inverterDetail();
// goLangDataAcquisitionService.inverAlramInfo();
kSolarRequestUtil.getHeader();
}
}
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine;
import io.swagger.models.auth.In;
import lombok.Data;
@Data
public class KSolarStationList {
private String stationId;
private String stationName;
private Integer stationType;
private Integer status;
private Double totalGeneration;
private String userName;
private Double powerInter;
private Double installCapacity;
private Double dayGeneration;
private Integer collects;
private String address;
}
package com.yeejoin.amos.api.householdapi.face.service;
public interface KSolarDataAcquisitionService {
/**
* @descrption 场站列表数据入库
*/
void stationList();
/**
* @descrption 场站详情数据入库
*/
void stationDetail();
/**
* @descrption 采集器列表数据入库
*/
void collectorList();
/**
* @descrption 采集器详情数据入库
*/
void collectorDetail();
/**
* @descrption 逆变器列表数据入库
*/
void inverterList();
/**
* @descrption 逆变器详情数据入库
*/
void inverterDetail();
/**
* @descrption 采集器告警列表数据入库
*/
void inverAlramInfo();
}
package com.yeejoin.amos.api.householdapi.face.service.impl;
import com.yeejoin.amos.api.householdapi.Utils.KSolarRequestUtil;
import com.yeejoin.amos.api.householdapi.constant.KSolarConstant;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.KSolarStationList;
import com.yeejoin.amos.api.householdapi.face.service.KSolarDataAcquisitionService;
import fastjson.JSON;
import jdk.nashorn.internal.ir.RuntimeNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
@Service
public class KSolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionService {
@Autowired
KSolarRequestUtil kSolarRequestUtil;
@Override
public void stationList() {
HashMap<String, Object> requestInfo = new HashMap<>();
String requestParaminfo = JSON.toJSONString(requestInfo);
List<KSolarStationList> kSolarStationListList = kSolarRequestUtil.getResPonse(
KSolarConstant.stationListUrl,
KSolarConstant.requestGET,
requestParaminfo,
KSolarConstant.resovle_rows,
KSolarStationList.class);
for (int i = 0; i < kSolarStationListList.size(); i++) {
KSolarStationList kSolarStationList = kSolarStationListList.get(i);
kSolarStationList.getStationId();
}
}
@Override
public void stationDetail() {
}
@Override
public void collectorList() {
}
@Override
public void collectorDetail() {
}
@Override
public void inverterList() {
}
@Override
public void inverterDetail() {
}
@Override
public void inverAlramInfo() {
}
}
......@@ -347,7 +347,7 @@ public class BigScreenAnalyseController extends BaseController {
List<Integer> zyList = new ArrayList<>();
List<Integer> jgList = new ArrayList<>();
List<String> list = allEquipAlarmInfo.stream().map(t -> t.get("pointName").toString()).collect(Collectors.toList());
List<String> list = allEquipAlarmInfo.stream().map(t -> t.get("pointName").toString()).distinct().collect(Collectors.toList());
list.forEach(item -> {
wxList.add(wxMap.getOrDefault(item, 0));
......
......@@ -11,7 +11,7 @@ import java.util.List;
@Repository
public interface IndicatorDataMapper extends BaseMapper<IndicatorData> {
@Select("select `value`, createdTime, `value_f` as valueF from iot_data.indicator_data where address=#{address} and createdtime >= #{startTime} and createdtime <= #{endTime} and gateway_id =#{gatewayId}")
@Select("select `value`, created_time as createdTime, `value_f` as valueF from iot_data.indicator_data where address=#{address} and created_time >= #{startTime} and created_time <= #{endTime} and gateway_id =#{gatewayId}")
List<IndicatorData> selectDataByAddressAndtime(@Param("address")String address,@Param("startTime") String startTime, @Param("endTime")String endTime, @Param("gatewayId")String gatewayId);
}
......@@ -9,8 +9,10 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
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.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test;
import com.yeejoin.amos.boot.module.jxiop.biz.scheduled.PowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.StationBasicServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.TestServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
......@@ -53,6 +55,9 @@ public class DemoController extends BaseController {
EmqKeeper emqKeeper;
@Autowired
PowerGeneration powerGeneration;
@Autowired
private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -199,4 +204,15 @@ public class DemoController extends BaseController {
return ResponseHelper.buildResponse(hashMap);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "test99")
@GetMapping("/test99")
public void test19() {
powerGeneration.addESDailyPowerGeneration();
powerGeneration.addESYearPowerGeneration();
powerGeneration.addESMoonPowerGeneration();
}
}
......@@ -6,6 +6,7 @@ import java.io.Serializable;
@Data
public class StationCacheInfoDto implements Serializable {
private static final long serialVersionUID = 1L;
//场站id
private String stationId;
//场站名称
......
......@@ -12,61 +12,62 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Component
public class StationCacheDataInit implements CommandLineRunner {
Logger logger = LoggerFactory.getLogger(StationCacheDataInit.class);
@Resource
@Autowired
private StationBasicMapper stationBasicMapper;
@Resource
@Autowired
private RegionMapper regionMapper;
@Resource
@Autowired
private MapRegionMapper mapRegionMapper;
@Resource
@Autowired
private SjglZsjZsbtzMapper sjglZsjZsbtzMapper;
@Resource
@Autowired
private CommonServiceImpl commonServiceImpl;
@Resource
@Autowired
private RedisTemplate redisTemplate;
Logger logger = LoggerFactory.getLogger(StationCacheDataInit.class);
public void run(String... args) throws Exception {
log.info("-------------------------------------开始缓存场站基础数据----------------------------");
redisTemplate.delete("station_info_cache_bigscreen");
List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
redisTemplate.delete("station_info_cache");
List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
List< MapRegion > mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
stationBasicList.forEach(stationBasic -> {
StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto();
stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString());
stationCacheInfoDto.setStationName(stationBasic.getStationName());
stationCacheInfoDto.setStationType(stationBasic.getStationType());
stationCacheInfoDto.setBelongProvince(regionList.stream().filter(region -> region.getRegionCode().toString().equals(stationBasic.getBelongArea().replace("[","").split(",")[0])).map(region -> region.getRegionName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,2))||mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,3))).map(mapRegion -> mapRegion.getName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setAreaCode(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,2))||mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,3))).map(mapRegion -> mapRegion.getAreaCode()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setInstalledCapacity(String.format("%.2f",sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber())));
stationCacheInfoDto.setBelongProvince(regionList.stream().filter(region -> region.getRegionCode().toString().equals(stationBasic.getBelongArea().replace("[", "").split(",")[0])).map(region -> region.getRegionName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 2)) || mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 3))).map(mapRegion -> mapRegion.getName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setInstalledCapacity(String.format("%.2f", sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber())));
try {
List<QueryDto> queryDtoList = new ArrayList<>();
queryDtoList.add(new QueryDto("gatewayId",stationBasic.getFanGatewayId()));
queryDtoList.add(new QueryDto("equipmentIndexName.keyword","有功功率"));
if(!stationBasic.getStationType().equals("FDZ")){
queryDtoList.add(new QueryDto("frontModule","逆变器"));
queryDtoList.add(new QueryDto("gatewayId", stationBasic.getFanGatewayId()));
queryDtoList.add(new QueryDto("equipmentIndexName.keyword", "有功功率"));
if (!stationBasic.getStationType().equals("FDZ")) {
queryDtoList.add(new QueryDto("frontModule", "逆变器"));
}
stationCacheInfoDto.setEquipmentNumbers(commonServiceImpl.getCount(queryDtoList, "equipmentNumber.Keyword", ESEquipments.class).toString());
} catch (Exception exception) {
logger.info("--------------------查询ES错误---------------------------");
}
stationCacheInfoDto.setEquipmentNumbers(commonServiceImpl.getCount(queryDtoList,"equipmentNumber.Keyword", ESEquipments.class).toString());
stationCacheInfoDto.setFanGatewayId(stationBasic.getFanGatewayId());
stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId());
stationCacheInfoDtos.add(stationCacheInfoDto);
});
redisTemplate.opsForList().leftPushAll("station_info_cache",stationCacheInfoDtos);
log.info("-------------------------------------结束缓存场站基础数据----------------------------");
redisTemplate.opsForList().leftPushAll("station_info_cache_bigscreen", stationCacheInfoDtos);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.repository;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
/**
* @description:
* @author: tw
* @createDate: 2023/8/9
*/
@Repository
public interface ESDailyPowerGenerationRepository extends PagingAndSortingRepository<ESDailyPowerGeneration, String> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.repository;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
/**
* @description:
* @author: tw
* @createDate: 2023/8/8
*/
@Repository
public interface ESEquipmentsRepository extends PagingAndSortingRepository<ESEquipments, String> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.repository;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
/**
* @description:
* @author: tw
* @createDate: 2023/8/9
*/
@Repository
public interface ESMoonPowerGenerationRepository extends PagingAndSortingRepository<ESMoonPowerGeneration, String> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.repository;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESWindSpeed;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
/**
* @description:
* @author: tw
* @createDate: 2023/8/8
*/
@Repository
public interface ESWindSpeedRepository extends PagingAndSortingRepository<ESWindSpeed, Long> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.repository;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESYearPowerGeneration;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
/**
* @description:
* @author: tw
* @createDate: 2023/8/9
*/
@Repository
public interface ESYearPowerGenerationRepository extends PagingAndSortingRepository<ESYearPowerGeneration, String> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.scheduled;//package com.yeejoin.amos.boot.module.jxiop.biz.scheduled;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.PowerGenerationImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/8/9
*/
@Component
@EnableScheduling
public class PowerGeneration {
@Autowired
PowerGenerationImpl powerGenerationImpl;
@Autowired
CommonServiceImpl commonServiceImpl;
private final String dayvalue="日发电量";
private final String moonValue="月发电量";
private final String yearValue="年发电量";
private final String dayDateFormat="yyyy-MM-dd";
private final String moonDateFormat="yyyy-MM";
private final String yearDateFormat="yyyy";
private final String dayType="day";
private final String moonType="moon";
private final String yearType="year";
//定时更新日发电量
@Scheduled(cron = "${daily.power.generation.cron}")
public void addESDailyPowerGeneration(){
List<StationCacheInfoDto> list =commonServiceImpl.getListStationCacheInfoDto();
//获取时间天字符串
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
Date now=new Date();
String daty= myFmt2.format(now);
for (StationCacheInfoDto stationCacheInfoDto : list) {
if("FDZ".equals(stationCacheInfoDto.getStationType())){
//风机
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"FDZ",daty);
}else{
//光伏
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"GFDZ",daty);
}
}
}
//定时更新月发电量
@Scheduled(cron = "${moon.power.generation.cron}")
public void addESMoonPowerGeneration(){
List<StationCacheInfoDto> list =commonServiceImpl.getListStationCacheInfoDto();
//获取时间天字符串
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
Date now=new Date();
String daty= myFmt2.format(now);
for (StationCacheInfoDto stationCacheInfoDto : list) {
//风机
if("FDZ".equals(stationCacheInfoDto.getStationType())){
//风机
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"FDZ",daty);
}else{
//光伏
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"GFDZ",daty);
}
}
}
//定时更新年发电量
@Scheduled(cron = "${year.power.generation.cron}")
public void addESYearPowerGeneration(){
List<StationCacheInfoDto> list =commonServiceImpl.getListStationCacheInfoDto();
//获取时间天字符串
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
Date now=new Date();
String daty= myFmt2.format(now);
for (StationCacheInfoDto stationCacheInfoDto : list) {
//风机
if("FDZ".equals(stationCacheInfoDto.getStationType())){
//风机
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"FDZ",daty);
}else{
//光伏
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"GFDZ",daty);
}
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.scheduled;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.TemporaryDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESWindSpeedRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@EnableScheduling
public class WindSpeedScheduled {
@Autowired
TemporaryDataMapper temporaryDataMapper;
@Autowired
ESWindSpeedRepository esWindSpeedRepository;
@Scheduled(cron="${windSpeed.cron}")
private void initData(){
esWindSpeedRepository.saveAll(temporaryDataMapper.getAllData());
}
}
......@@ -17,6 +17,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchPhraseQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders;
......@@ -163,41 +164,39 @@ public class CommonServiceImpl {
return socialContributionDtoPage;
}
public List<StationCacheInfoDto> getListStationCacheInfoDto(){
List<StationCacheInfoDto> stationCacheInfoDtoList =redisTemplate.opsForList().range("station_info_cache",0,-1);
if(ObjectUtils.isEmpty(stationCacheInfoDtoList)){
try {
public List<StationCacheInfoDto> getListStationCacheInfoDto() {
List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
stationCacheInfoDtos = redisTemplate.opsForList().range("station_info_cache_bigscreen", 0, -1);
if (ObjectUtils.isEmpty(stationCacheInfoDtos)) {
List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
stationBasicList.forEach(stationBasic -> {
for (int i = 0; i < stationBasicList.size(); i++) {
StationBasic stationBasic = stationBasicList.get(i);
StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto();
stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString());
stationCacheInfoDto.setStationName(stationBasic.getStationName());
stationCacheInfoDto.setStationType(stationBasic.getStationType());
stationCacheInfoDto.setBelongProvince(regionList.stream().filter(region -> region.getRegionCode().toString().equals(stationBasic.getBelongArea().replace("[","").split(",")[0])).map(region -> region.getRegionName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,2))||mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,3))).map(mapRegion -> mapRegion.getName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setAreaCode(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,2))||mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,3))).map(mapRegion -> mapRegion.getAreaCode()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setInstalledCapacity(String.format("%.2f",sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber())));
stationCacheInfoDto.setBelongProvince(regionList.stream().filter(region -> region.getRegionCode().toString().equals(stationBasic.getBelongArea().replace("[", "").split(",")[0])).map(region -> region.getRegionName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 2)) || mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 3))).map(mapRegion -> mapRegion.getName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setInstalledCapacity(String.format("%.2f", sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber())));
try {
List<QueryDto> queryDtoList = new ArrayList<>();
queryDtoList.add(new QueryDto("gatewayId",stationBasic.getFanGatewayId()));
queryDtoList.add(new QueryDto("equipmentIndexName.keyword","有功功率"));
if(!stationBasic.getStationType().equals("FDZ")){
queryDtoList.add(new QueryDto("frontModule","逆变器"));
queryDtoList.add(new QueryDto("gatewayId", stationBasic.getFanGatewayId()));
queryDtoList.add(new QueryDto("equipmentIndexName.keyword", "有功功率"));
if (!stationBasic.getStationType().equals("FDZ")) {
queryDtoList.add(new QueryDto("frontModule", "逆变器"));
}
stationCacheInfoDto.setEquipmentNumbers(getCount(queryDtoList, "equipmentNumber.Keyword", ESEquipments.class).toString());
} catch (Exception exception) {
}
stationCacheInfoDto.setEquipmentNumbers(this.getCount(queryDtoList,"equipmentNumber.Keyword", ESEquipments.class).toString());
stationCacheInfoDto.setFanGatewayId(stationBasic.getFanGatewayId());
stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId());
stationCacheInfoDtos.add(stationCacheInfoDto);
});
redisTemplate.opsForList().leftPushAll("station_info_cache",stationCacheInfoDtos);
return stationCacheInfoDtos;
} catch (Exception e) {
throw new RuntimeException(e);
}
redisTemplate.opsForList().leftPushAll("station_info_cache_bigscreen", stationCacheInfoDtos);
}
return stationCacheInfoDtoList;
return stationCacheInfoDtos;
}
......@@ -222,7 +221,7 @@ public class CommonServiceImpl {
.withPageable(PageRequest.of(0, 1))
.build();
query.setTrackTotalHits(true);
SearchHits search = elasticsearchTemplate.search(query, ESEquipments.class);
SearchHits search = elasticsearchTemplate.search(query, clas);
if (search.hasAggregations()) {
Aggregations aggregations = search.getAggregations();
if (Objects.nonNull(aggregations)) {
......
......@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationPlan;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationPlanMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SeriesData;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil;
......@@ -274,7 +276,7 @@ public class LargeScreenImpl {
//全国发电趋势
@Scheduled(cron = "0/10 * * * * ?")
@Scheduled(cron = "0/10 * * * * ? ")
public SeriesData getSeriesDataqg(){
//获取今年当月 日发电趋势
......@@ -289,8 +291,8 @@ public class LargeScreenImpl {
mapjn.put("data",listjn);
mapjn.put("name","当前值");
Map<String,Object> mapqn=new HashMap<>();
mapjn.put("data",listqn);
mapjn.put("name","同期值");
mapqn.put("data",listqn);
mapqn.put("name","同期值");
List<Map<String,Object>> list=new ArrayList<>();
list.add(mapjn);
......@@ -377,7 +379,7 @@ public class LargeScreenImpl {
value1.add(monthy);
map.put("moon.keyword",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"valueDouble" ,"day.keyword",ESEquipments.class);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"value" ,"day.keyword", ESDailyPowerGeneration.class);
Map<String,Double> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000");
......@@ -489,7 +491,7 @@ public class LargeScreenImpl {
Calendar cal = Calendar.getInstance();
cal.setTime(month);//month 为指定月份任意日期
int year = cal.get(Calendar.YEAR);
int m = cal.get(Calendar.MONTH);
int m = cal.get(Calendar.MONTH)+1;
int dayNumOfMonth = DateUtil.getDaysByYearMonth(year, m);
cal.set(Calendar.DAY_OF_MONTH, 1);// 从一号开始
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;//package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESYearPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESDailyPowerGenerationRepository;
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESMoonPowerGenerationRepository;
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESYearPowerGenerationRepository;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/8/9
*/
@Service
public class PowerGenerationImpl {
@Autowired
InfluxDButils influxDButils;
@Autowired
private ElasticsearchRestTemplate elasticsearchTemplate;
@Autowired
ESYearPowerGenerationRepository yearPowerGenerationRepository;
@Autowired
ESMoonPowerGenerationRepository moonPowerGenerationRepository;
@Autowired
ESDailyPowerGenerationRepository dailyPowerGenerationRepository;
//获取指定指标,当天最后一条数据
public List<IndexDto> getlast(String gatewayId, String value,String daty){
IndexDto indexDto=null;
String querySql = " SELECT * FROM iot_data_%s WHERE equipmentIndexName='%s' and time >='%sT00:55:00Z' AND time < '%sT23:59:59Z' group by equipmentsIdx order by time desc LIMIT 1";
querySql = String.format(querySql, gatewayId, value,daty,daty);
List<IndexDto> queryList = influxDButils.getListData(querySql,IndexDto.class);
return queryList;
}
public List<IndexDto> getlastgf(String gatewayId, String value,String daty){
IndexDto indexDto=null;
String querySql = " SELECT * FROM iot_data_%s WHERE equipmentIndexName='%s' and equipmentSpecificName =~/.*逆变器.*/ and time >='%sT00:55:00Z' AND time < '%sT23:59:59Z' group by equipmentsIdx order by time desc LIMIT 1";
querySql = String.format(querySql, gatewayId, value,daty,daty);
List<IndexDto> queryList = influxDButils.getListData(querySql,IndexDto.class);
return queryList;
}
//更新es 数据
//@Async("jxiopAsyncExecutor")
public void addPowerGeneration(StationCacheInfoDto stationCacheInfoDto,String gatewayId, String value, String dateFormat, String type, String stationType,String datyvalue){
//获取指标值
List<IndexDto> indexDto=null;
if("FDZ".equals(stationType)){
indexDto= this.getlast(gatewayId,value, datyvalue);
}else{
indexDto= this.getlastgf(gatewayId,value,datyvalue);
}
SimpleDateFormat myFmt2=new SimpleDateFormat(dateFormat);
Date now=new Date();
String daty= myFmt2.format(now);
this.PowerGeneration(stationCacheInfoDto,indexDto,daty,type);
}
//更新es
public void PowerGeneration(StationCacheInfoDto stationCacheInfoDto,List<IndexDto> indexDto,String daty,String type){
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DATE);
int month = calendar.get(Calendar.MONTH) + 1;
int year = calendar.get(Calendar.YEAR);
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyyMM");
Date now=new Date();
String monthy= myFmt2.format(now);
SimpleDateFormat myFmty=new SimpleDateFormat("yyyy");
Date nowy=new Date();
String yeary= myFmty.format(nowy);
switch (type) {
case "day":
List<ESDailyPowerGeneration> listd= this.getESDailyPowerGeneration(stationCacheInfoDto,indexDto,daty,String.valueOf(day),monthy);
dailyPowerGenerationRepository.saveAll(listd);
break;
case "moon":
List<ESMoonPowerGeneration> listm= this.getESMoonPowerGeneration(stationCacheInfoDto,indexDto,daty,String.valueOf(month),yeary);
moonPowerGenerationRepository.saveAll(listm);
break;
case "year":
List<ESYearPowerGeneration> listy= this.getESYearPowerGeneration(stationCacheInfoDto,indexDto,daty,String.valueOf(year));
yearPowerGenerationRepository.saveAll(listy);
break;
default:
break;
}
}
// 组装数据
public List<ESDailyPowerGeneration> getESDailyPowerGeneration(StationCacheInfoDto stationCacheInfoDto,List<IndexDto> indexDto,String daty,String day,String month){
List<ESDailyPowerGeneration> list=new ArrayList<>();
if(indexDto!=null&&!indexDto.isEmpty()){
for (IndexDto dto : indexDto) {
ESDailyPowerGeneration dailyPowerGeneration=new ESDailyPowerGeneration(
daty+"_"+dto.getAddress(),
stationCacheInfoDto.getStationId(),
stationCacheInfoDto.getStationName(),
stationCacheInfoDto.getStationType(),
stationCacheInfoDto.getBelongProvince(),
stationCacheInfoDto.getBelongArea(),
day,
dto.getGatewayId(),
new Date(),
dto.getValue()!=null?Double.valueOf(dto.getValue()):null,
dto.getEquipmentIndexName(),
dto.getEquipmentNumber(),
dto.getAddress(),
month
);
list.add(dailyPowerGeneration);
}
}
return list;
}
public List<ESMoonPowerGeneration> getESMoonPowerGeneration(StationCacheInfoDto stationCacheInfoDto,List<IndexDto> indexDto,String daty,String day,String year){
List<ESMoonPowerGeneration> list=new ArrayList<>();
if(indexDto!=null&&!indexDto.isEmpty()){
for (IndexDto dto : indexDto) {
ESMoonPowerGeneration moonPowerGeneration=new ESMoonPowerGeneration(
daty+"_"+dto.getAddress(),
stationCacheInfoDto.getStationId(),
stationCacheInfoDto.getStationName(),
stationCacheInfoDto.getStationType(),
stationCacheInfoDto.getBelongProvince(),
stationCacheInfoDto.getBelongArea(),
day,
dto.getGatewayId(),
new Date(),
dto.getValue()!=null?Double.valueOf(dto.getValue()):null,
dto.getEquipmentIndexName(),
dto.getEquipmentNumber(),
dto.getAddress(),
year
);
list.add(moonPowerGeneration);
}
}
return list;
}
public List<ESYearPowerGeneration> getESYearPowerGeneration(StationCacheInfoDto stationCacheInfoDto,List<IndexDto> indexDto,String daty,String day){
List<ESYearPowerGeneration> list=new ArrayList<>();
if(indexDto!=null&&!indexDto.isEmpty()){
for (IndexDto dto : indexDto) {
ESYearPowerGeneration yearPowerGeneration=new ESYearPowerGeneration(
daty+"_"+dto.getAddress(),
stationCacheInfoDto.getStationId(),
stationCacheInfoDto.getStationName(),
stationCacheInfoDto.getStationType(),
stationCacheInfoDto.getBelongProvince(),
stationCacheInfoDto.getBelongArea(),
day,
dto.getGatewayId(),
new Date(),
dto.getValue()!=null?Double.valueOf(dto.getValue()):null,
dto.getEquipmentIndexName(),
dto.getEquipmentNumber(),
dto.getAddress()
);
list.add(yearPowerGeneration);
}
}
return list;
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.listener;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.api.entity.PersonAccount;
import com.yeejoin.amos.boot.module.jxiop.api.entity.PersonAccountFed;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.PersonAccountFedMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.PersonAccountMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQTextMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import javax.jms.Message;
@Component
@Slf4j
public class PlatformModifyPasswordistener {
@Autowired
PersonAccountMapper personAccountMapper;
@Autowired
PersonAccountFedMapper personAccountFedMapper;
@Value("${amos.secret.key}")
private String secretKey;
@JmsListener(destination = "${modifypasswordqueue}")
public void reciveMesssage(Message message) {
try {
String dadainfo = ((ActiveMQTextMessage) message).getText();
JSONObject jsonObject = JSONObject.parseObject(dadainfo);
jsonObject = (JSONObject) jsonObject.get("body");
jsonObject = (JSONObject) jsonObject.get("authData");
PersonAccount personAccount = personAccountMapper.selectOne(new QueryWrapper<PersonAccount>().eq("puser_id", jsonObject.get("userId")));
if (!ObjectUtils.isEmpty(personAccount)) {
personAccount.setPassword((String) jsonObject.get("password"));
personAccount.setSecondaryPassword((String) jsonObject.get("rePassword"));
personAccountMapper.updateById(personAccount);
}
PersonAccountFed personAccountFed = personAccountFedMapper.selectOne(new QueryWrapper<PersonAccountFed>().eq("puser_id", jsonObject.get("userId")));
if (!ObjectUtils.isEmpty(personAccount)) {
personAccountFed.setPassword((String) jsonObject.get("password"));
personAccountFed.setSecondaryPassword((String) jsonObject.get("rePassword"));
personAccountFedMapper.updateById(personAccountFed);
}
message.acknowledge();
log.info("--------------------消息消费成功 {}", jsonObject);
} catch (Exception e) {
e.printStackTrace();
} finally {
}
}
}
......@@ -80,8 +80,9 @@ amos.secret.key=qaz
#eureka.instance.ip-address=172.16.3.122
spring.activemq.broker-url=tcp://139.9.173.44:61616
spring.activemq.broker-url=tcp://172.16.10.253:61616
spring.activemq.user=admin
spring.activemq.password=admin
spring.jms.pub-sub-domain=false
myqueue=amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness
modifypasswordqueue= amos.privilege.v1.JXIOP.AMOS_ADMIN.modifyPassword
\ No newline at end of file
......@@ -7,7 +7,7 @@ import java.util.HashMap;
public class CommonConstans {
//光伏发电量系数
public static final Double pvGenPoweActor = 0.00001;
public static final Double pvGenPoweActorDay = 0.01;
public static final Double pvGenPoweActorDay = 0.1;
// 风电站:
// (日/月/年)发电量=场站所有风机(日/月/年)发电量总和
// 装机容量=场站所有风机装机容量总和
......
......@@ -4,21 +4,14 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
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.biz.ESDto.ESDailyPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESYearPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test;
import com.yeejoin.amos.boot.module.jxiop.biz.initdata.StationCacheDataInit;
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESEquipmentsRepository;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.*;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
......@@ -26,35 +19,23 @@ import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermsQueryBuilder;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.AvgAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.ParsedAvg;
import org.elasticsearch.search.aggregations.metrics.ParsedSum;
import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.MinAndMax;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.web.bind.annotation.*;
......@@ -65,12 +46,9 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@RestController
......@@ -103,8 +81,6 @@ public class DemoController extends BaseController {
CommonServiceImpl commonServiceImpl;
// @Autowired
// PowerGenerationImpl powerGenerationImpl;
@Autowired
StationCacheDataInit stationCacheDataInit;
// @Autowired
// LargeScreenImpl largeScreenImpl;
......@@ -133,7 +109,7 @@ public class DemoController extends BaseController {
public String updateStationCacheInfo() {
String updateResult = "更新场站信息缓存成功";
try {
stationCacheDataInit.run();
} catch (Exception e) {
updateResult = "更新场站信息缓存成功";
throw new RuntimeException(e);
......
......@@ -68,19 +68,17 @@ public class MonitorFanIdxController extends BaseController {
@Value("${gl.avg.column}")
String avgColumn;
@Value("${fan.statuts.stattuspath}")
private String fanStatusImagePathPrefix;
@Autowired
IndicatorDataMapper indicatorDataMapper;
@Autowired
MonitorFanIndicatorMapper monitorFanIndicatorMapper;
@Autowired
EmqKeeper emqKeeper;
@Autowired
InfluxdbUtil influxdbUtil;
@Value("${fan.statuts.stattuspath}")
private String fanStatusImagePathPrefix;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据设备编号、场站id、前段展示模块、系统类型查询表数据")
@GetMapping("/getFanIdxInfoByPage")
......@@ -122,27 +120,27 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图 - 风机状态图片")
@GetMapping("/getFanStatusListImage")
public ResponseModel<IPage<HashMap<String,String>>> getFanStatusListImages(@RequestParam(value = "stationId", required = false) String stationId){
public ResponseModel<IPage<HashMap<String, String>>> getFanStatusListImages(@RequestParam(value = "stationId", required = false) String stationId) {
List<ESEquipmentsDTO> fanStatusList = monitorFanIndicator.getFanStatusList(stationId);
List<ESEquipmentsDTO> collect = fanStatusList.stream()
.limit(999)
.collect(Collectors.toList());
IPage<HashMap<String,String>> page = new Page<>();
HashMap<String,String> hashMap = new HashMap<>();
IPage<HashMap<String, String>> page = new Page<>();
HashMap<String, String> hashMap = new HashMap<>();
List<ESEquipmentsDTO> indexDtoList = collect.stream().sorted(Comparator.comparing(ESEquipmentsDTO::getEquipmentNumber)).collect(Collectors.toList());
//获取拼音首字母
String prefix =commonService.getFanDevicePrefix(stationId);
String prefix = commonService.getFanDevicePrefix(stationId);
for (int i = 1; i <= indexDtoList.size(); i++) {
ESEquipmentsDTO ESEquipments = indexDtoList.get(i-1);
hashMap.put("url"+i,fanStatusImagePathPrefix+"/"+"风机-"+ESEquipments.getAddress()+".gif");
hashMap.put("name"+i,prefix+ESEquipments.getEquipmentNumber());
ESEquipmentsDTO ESEquipments = indexDtoList.get(i - 1);
hashMap.put("url" + i, fanStatusImagePathPrefix + "/" + "风机-" + ESEquipments.getAddress() + ".gif");
hashMap.put("name" + i, prefix + ESEquipments.getEquipmentNumber());
//用于参数传递
hashMap.put("name"+i+'d',ESEquipments.getEquipmentNumber());
hashMap.put("name" + i + 'd', ESEquipments.getEquipmentNumber());
}
page.setTotal(10);
page.setSize(10);
page.setCurrent(1);
List<HashMap<String,String>> hashMapList = new ArrayList<>();
List<HashMap<String, String>> hashMapList = new ArrayList<>();
hashMapList.add(hashMap);
page.setRecords(hashMapList);
return ResponseHelper.buildResponse(page);
......@@ -201,71 +199,71 @@ public class MonitorFanIdxController extends BaseController {
public ResponseModel<HashMap<String, List<String>>> getRealTimeTemperature(@RequestParam(value = "equipNum", required = false) String equipNum,
@RequestParam(value = "stationId", required = false) String stationId,
@RequestParam(value = "frontModule", required = false) String frontModule) {
return ResponseHelper.buildResponse(monitorFanIndicator.getRealTimeTemperature(equipNum, stationId, frontModule)) ;
return ResponseHelper.buildResponse(monitorFanIndicator.getRealTimeTemperature(equipNum, stationId, frontModule));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图-总概览")
@GetMapping("/overview")
public ResponseModel<IPage<Map<String, Object>>> getData(@RequestParam(value = "stationId")String stationId) {
public ResponseModel<IPage<Map<String, Object>>> getData(@RequestParam(value = "stationId") String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
String [] columnList = new String[]{"日发电量","月发电量","年发电量"};
String [] columnLists = new String[]{"瞬时风速"};
String[] columnList = new String[]{"日发电量", "月发电量", "年发电量"};
String[] columnLists = new String[]{"瞬时风速"};
Map<String, Object> columnMap = new HashMap<>();
for (String column : columnList) {
Double result = commonService.getTotalByIndicatior(gatewayId, column);
columnMap.put(column, String.format("%.2f",result));
columnMap.put(column, String.format("%.2f", result));
}
for (String column : columnLists) {
Double result = commonService.getAvgvalueByIndicatior(gatewayId, column);
columnMap.put(column, String.format("%.2f",result));
columnMap.put(column, String.format("%.2f", result));
}
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()/1000));
columnMap.put("有功功率", String.format("%.2f", result1.get(0).getValueF() / 1000));
String num = monitorFanIndicator.getEquipCount(gatewayId,"FDZ");
columnMap.put("风机台数",num);
String num = monitorFanIndicator.getEquipCount(gatewayId, "FDZ");
columnMap.put("风机台数", num);
Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber());
columnMap.put("装机容量",String.format("%.2f",capacityl));
columnMap.put("装机容量", String.format("%.2f", capacityl));
List<Map<String,Object>> objects = new ArrayList<>();
List<Map<String, Object>> objects = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("title",columnMap.get("装机容量").toString());
data.put("title", columnMap.get("装机容量").toString());
objects.add(data);
Map<String, Object> data1 = new HashMap<>();
data1.put("title",columnMap.get("日发电量").toString());
data1.put("title", columnMap.get("日发电量").toString());
objects.add(data1);
Map<String, Object> data2 = new HashMap<>();
data2.put("title",columnMap.get("风机台数").toString().replace(".0",""));
data2.put("title", columnMap.get("风机台数").toString().replace(".0", ""));
objects.add(data2);
Map<String, Object> data3 = new HashMap<>();
data3.put("title",columnMap.get("月发电量").toString());
data3.put("title", columnMap.get("月发电量").toString());
objects.add(data3);
Map<String, Object> data4 = new HashMap<>();
data4.put("title",columnMap.get("瞬时风速").toString());
data4.put("title", columnMap.get("瞬时风速").toString());
objects.add(data4);
Map<String, Object> data5 = new HashMap<>();
data5.put("title",columnMap.get("年发电量").toString());
data5.put("title", columnMap.get("年发电量").toString());
objects.add(data5);
Map<String, Object> data6 = new HashMap<>();
data6.put("title", columnMap.get("有功功率")) ;
data6.put("title", columnMap.get("有功功率"));
objects.add(data6);
Map<String, Object> data7 = new HashMap<>();
data7.put("title",String.format("%.2f",((Double.parseDouble(columnMap.get("日发电量").toString())*10)/ (Double.parseDouble(columnMap.get("装机容量").toString())))));
data7.put("title", String.format("%.2f", ((Double.parseDouble(columnMap.get("日发电量").toString()) * 10) / (Double.parseDouble(columnMap.get("装机容量").toString())))));
objects.add(data7);
IPage<Map<String,Object>> result = new Page<>();
IPage<Map<String, Object>> result = new Page<>();
result.setRecords(objects);
result.setCurrent(1);
result.setTotal(objects.size());
......@@ -274,16 +272,15 @@ public class MonitorFanIdxController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "概览-全站功率曲线")
@GetMapping("/overviewWindSpeed")
public ResponseModel<Map<String, Object>> getOverviewWindSpeed(@RequestParam(value = "stationId", required = false)String stationId,@RequestParam(value = "type", required = false)String type,@RequestParam(value = "areaCode", required = false)String areaCode) {
public ResponseModel<Map<String, Object>> getOverviewWindSpeed(@RequestParam(value = "stationId", required = false) String stationId, @RequestParam(value = "type", required = false) String type, @RequestParam(value = "areaCode", required = false) String areaCode) {
String gatewayId = "";
if (null != stationId){
if (null != stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
gatewayId = stationBasic.getBoosterGatewayId();
if (null == type){
if (null == type) {
gatewayId = stationBasic.getFanGatewayId();
}
}
......@@ -296,8 +293,8 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机详情-风速功率曲线")
@GetMapping("/detailsWindSpeed")
public ResponseModel<Map<String, Object>> getDetailsWindSpeed(@RequestParam(value = "stationId")String stationId,String name) {
name = name + "风机";
public ResponseModel<Map<String, Object>> getDetailsWindSpeed(@RequestParam(value = "stationId") String stationId, String name) {
// name = name + "风机";
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
Map<String, Object> detailsWindSpeed = monitorFanIndicator.getDetailsWindSpeed(gatewayId, name);
......@@ -308,11 +305,11 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "逆变器-功率曲线")
@GetMapping("/getDetailsWindSpeeds")
public ResponseModel<Map<String, Object>> getDetailsWindSpeeds(@RequestParam(value = "stationId")String stationId,String equipNum) {
public ResponseModel<Map<String, Object>> getDetailsWindSpeeds(@RequestParam(value = "stationId") String stationId, String equipNum) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
Map<String, Object> detailsWindSpeed = monitorFanIndicator.getDetailsWindSpeeds(gatewayId,equipNum);
Map<String, Object> detailsWindSpeed = monitorFanIndicator.getDetailsWindSpeeds(gatewayId, equipNum);
return ResponseHelper.buildResponse(detailsWindSpeed);
}
......@@ -320,11 +317,11 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "状态监控")
@GetMapping("/statusMonitoring")
public ResponseModel<IPage<Map<String, Object>>> getStatusMonitoring(@RequestParam(value = "stationId")String stationId,String equipNum,String systemType) {
public ResponseModel<IPage<Map<String, Object>>> getStatusMonitoring(@RequestParam(value = "stationId") String stationId, String equipNum, String systemType) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusMonitoring(gatewayId, equipNum, systemType);
IPage<Map<String,Object>> result = new Page<>();
IPage<Map<String, Object>> result = new Page<>();
result.setRecords(statusMonitoring);
result.setCurrent(1);
result.setTotal(statusMonitoring.size());
......@@ -335,14 +332,14 @@ public class MonitorFanIdxController extends BaseController {
@ApiOperation(value = "升压站光字牌/开关-通用")
@GetMapping("/getStatusGzp")
public ResponseModel<IPage<Map<String, Object>>> getStatusGzp(@RequestParam(value = "stationId")String stationId,String frontModule,String systemType,String equipNum,@RequestParam(required = false) String stationType) {
public ResponseModel<IPage<Map<String, Object>>> getStatusGzp(@RequestParam(value = "stationId") String stationId, String frontModule, String systemType, String equipNum, @RequestParam(required = false) String stationType) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
if (null != stationType){
if (null != stationType) {
gatewayId = stationBasic.getFanGatewayId();
}
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId ,systemType,frontModule,equipNum);
IPage<Map<String,Object>> result = new Page<>();
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId, systemType, frontModule, equipNum);
IPage<Map<String, Object>> result = new Page<>();
result.setRecords(statusMonitoring);
result.setCurrent(1);
result.setTotal(statusMonitoring.size());
......@@ -350,7 +347,6 @@ public class MonitorFanIdxController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "升压站光字牌/压板状态API-通用")
@GetMapping("/getStatusGzpAndYb")
......@@ -359,20 +355,20 @@ public class MonitorFanIdxController extends BaseController {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
Map<String, String> map = monitorFanIndicatorMapper.getMajorBoosterStationInfoBySort(gatewayId, frontModule);
String name = map.get("text").contains("主变")?map.get("text").substring(0,3):map.get("text");
String name = map.get("text").contains("主变") ? map.get("text").substring(0, 3) : map.get("text");
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("gzp", "光字牌");
stringStringHashMap.put("ybzt", "压板");
stringStringHashMap.put("agzp", "A套保护光字牌");
stringStringHashMap.put("bgzp", "B套保护光字牌");
for (Map.Entry<String, String> stringStringEntry : stringStringHashMap.entrySet()) {
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId ,stringStringEntry.getValue(), name,null);
IPage<Map<String,Object>> result = new Page<>();
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId, stringStringEntry.getValue(), name, null);
IPage<Map<String, Object>> result = new Page<>();
result.setRecords(statusMonitoring);
result.setCurrent(1);
result.setTotal(statusMonitoring.size());
try {
emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, frontModule, stringStringEntry.getKey()), JSON.toJSONString(result).getBytes(),0,false);
emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, frontModule, stringStringEntry.getKey()), JSON.toJSONString(result).getBytes(), 0, false);
} catch (MqttException e) {
e.printStackTrace();
}
......@@ -384,15 +380,15 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "模拟量接口Api")
@GetMapping("/getAnalogQuantity")
public ResponseModel<IPage<Map<String, Object>>> getAnalogQuantity(@RequestParam(value = "stationId")String stationId,String frontModule,@RequestParam(required = false) String systemType) {
public ResponseModel<IPage<Map<String, Object>>> getAnalogQuantity(@RequestParam(value = "stationId") String stationId, String frontModule, @RequestParam(required = false) String systemType) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
if (null == systemType){
if (null == systemType) {
systemType = "模拟量";
}
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getAnalogQuantity(gatewayId ,frontModule,systemType);
IPage<Map<String,Object>> result = new Page<>();
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getAnalogQuantity(gatewayId, frontModule, systemType);
IPage<Map<String, Object>> result = new Page<>();
result.setRecords(statusMonitoring);
result.setCurrent(1);
result.setTotal(statusMonitoring.size());
......@@ -400,7 +396,6 @@ public class MonitorFanIdxController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "集电线路图左侧 集电线列表")
@GetMapping("/jdTree")
......@@ -411,10 +406,10 @@ public class MonitorFanIdxController extends BaseController {
for (StationBasic stationBasic : stationBasics) {
String gatewayId = stationBasic.getBoosterGatewayId();
String werks = stationBasic.getStationNumber();
if (stationBasic.getStationType().equals("FDZ")){
monitorFanIndicator.getStatusJDX(gatewayId, stationBasic.getSequenceNbr().toString(),"集电");
}else if (stationBasic.getStationType().equals("JZSGFDZ") ){
monitorFanIndicator.getStatusJDX(gatewayId, stationBasic.getSequenceNbr().toString(),"前光");
if (stationBasic.getStationType().equals("FDZ")) {
monitorFanIndicator.getStatusJDX(gatewayId, stationBasic.getSequenceNbr().toString(), "集电");
} else if (stationBasic.getStationType().equals("JZSGFDZ")) {
monitorFanIndicator.getStatusJDX(gatewayId, stationBasic.getSequenceNbr().toString(), "前光");
}
}
return CommonResponseUtil.success();
......@@ -433,7 +428,7 @@ public class MonitorFanIdxController extends BaseController {
for (StationBasic stationBasic : stationBasics) {
String gatewayId = stationBasic.getFanGatewayId();
String werks = stationBasic.getStationNumber();
monitorFanIndicator.getListByFJ(gatewayId,werks,stationBasic.getSequenceNbr().toString());
monitorFanIndicator.getListByFJ(gatewayId, werks, stationBasic.getSequenceNbr().toString());
}
......@@ -441,7 +436,6 @@ public class MonitorFanIdxController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取升压站信息 通过排序等")
@GetMapping("/getBoosterStationInfo")
......@@ -473,22 +467,22 @@ public class MonitorFanIdxController extends BaseController {
return ResponseHelper.buildResponse(resultsData);
}
// @Scheduled(cron = "0/15 * * * * ? ")
// @Scheduled(cron = "0/15 * * * * ? ")
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "模拟量列表消息")
@GetMapping("/getAnalogQuantityInfo")
public ResponseModel getAnalogQuantityInfo(@RequestParam(value = "stationId") String stationId, @RequestParam(value = "routeName")String routeName) {
public ResponseModel getAnalogQuantityInfo(@RequestParam(value = "stationId") String stationId, @RequestParam(value = "routeName") String routeName) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
monitorFanIndicator.getAnalogQuantityInfo(gatewayId, stationBasic.getSequenceNbr().toString(), routeName);
return CommonResponseUtil.success();
}
// @Scheduled(cron = "0/15 * * * * ? ")
// @Scheduled(cron = "0/15 * * * * ? ")
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "升压站主屏消息接口")
@GetMapping("/getMajorAnalogQuantityByPage")
public ResponseModel getMajorAnalogQuantityByPage(@RequestParam (required = false) String stationId) {
public ResponseModel getMajorAnalogQuantityByPage(@RequestParam(required = false) String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
if ("夏造风电站".equals(stationBasic.getStationName())) {
......@@ -507,13 +501,13 @@ public class MonitorFanIdxController extends BaseController {
@RequestParam(value = "stationId") String stationId,
@RequestParam(value = "type") String type) {
ResultsData resultsData = new ResultsData();
if (type.equals("0")){
if (type.equals("0")) {
resultsData = monitorFanIndicatorImpl.getAlarmEventList(current, size, stationId);
}else if (type.equals("1")){
} else if (type.equals("1")) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String fanGatewayId = stationBasic.getFanGatewayId();
resultsData=monitorFanIndicatorImpl.getNationWideInfo( current, size, fanGatewayId, null);
resultsData = monitorFanIndicatorImpl.getNationWideInfo(current, size, fanGatewayId, null);
}
return ResponseHelper.buildResponse(resultsData);
}
......@@ -525,10 +519,10 @@ public class MonitorFanIdxController extends BaseController {
public ResponseModel<ResultsData> getElectricQuantityList(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "stationId") String stationId,
@RequestParam(value = "stationType",required = false) String stationType) {
@RequestParam(value = "stationType", required = false) String stationType) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
ResultsData resultsData = monitorFanIndicatorImpl.getElectricQuantityList(current, size, gatewayId,stationType);
ResultsData resultsData = monitorFanIndicatorImpl.getElectricQuantityList(current, size, gatewayId, stationType);
return ResponseHelper.buildResponse(resultsData);
}
......@@ -536,7 +530,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "开关图片API/消息")
@GetMapping("/switchUrl")
public ResponseModel<Map<String,Object>> getElectricQuantityList(
public ResponseModel<Map<String, Object>> getElectricQuantityList(
@RequestParam(value = "stationId") String stationId
) {
......@@ -553,7 +547,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "动态面板页面消息")
@GetMapping("/pageTopic")
public ResponseModel<Map<String,Object>> sendPageTopic(
public ResponseModel<Map<String, Object>> sendPageTopic(
@RequestParam(value = "stationId") String stationId, @RequestParam(value = "equipName") String equipName
) {
......@@ -562,15 +556,15 @@ public class MonitorFanIdxController extends BaseController {
Map<String, String> map = monitorFanIndicatorMapper.getMajorBoosterStationInfoBySort(gatewayId, equipName);
String name = map.get("text").equals("1主变高压侧") || map.get("text").equals("1主变低压侧") ?map.get("text").substring(0,3):map.get("text");
String sql = " SELECT * FROM indicators_" + gatewayId + " WHERE (equipmentIndexName ='待机' or equipmentIndexName ='故障停机' or equipmentIndexName ='告警运行' or equipmentIndexName ='限额运行' or equipmentIndexName ='停机 or 'equipmentIndexName ='停机' or equipmentIndexName ='停机') and value = 'true'";
String name = map.get("text").equals("1主变高压侧") || map.get("text").equals("1主变低压侧") ? map.get("text").substring(0, 3) : map.get("text");
// String sql = " SELECT * FROM indicators_" + gatewayId + " WHERE (equipmentIndexName ='待机' or equipmentIndexName ='故障停机' or equipmentIndexName ='告警运行' or equipmentIndexName ='限额运行' or equipmentIndexName ='停机 or 'equipmentIndexName ='停机' or equipmentIndexName ='停机') and value = 'true'";
Map<String, Object> switchUrl = monitorFanIndicatorImpl.getSwitchUrl(gatewayId, name);
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId ,"网络",name,null);
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId, "网络", name, null);
IPage<Map<String, Object>> result = new Page<>();
switchUrl.put("records",statusMonitoring);
switchUrl.put("current",1);
switchUrl.put("total",100);
switchUrl.put("records", statusMonitoring);
switchUrl.put("current", 1);
switchUrl.put("total", 100);
List<Map<String, Object>> data = new ArrayList<>();
data.add(switchUrl);
result.setRecords(data);
......@@ -578,7 +572,7 @@ public class MonitorFanIdxController extends BaseController {
result.setTotal(100);
try {
emqKeeper.getMqttClient().publish(stationId+"/switch/"+equipName, JSON.toJSONString(result).getBytes(),0,false);
emqKeeper.getMqttClient().publish(stationId + "/switch/" + equipName, JSON.toJSONString(result).getBytes(), 0, false);
} catch (MqttException e) {
e.printStackTrace();
}
......@@ -588,10 +582,10 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "1#主变油温")
@GetMapping("/zbyw")
public ResponseModel<Map<String,Object>> getYwData(@RequestParam(value = "stationId") String stationId) {
public ResponseModel<Map<String, Object>> getYwData(@RequestParam(value = "stationId") String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
Map<String,Object> resultsData = monitorFanIndicatorImpl.getyw( gatewayId);
Map<String, Object> resultsData = monitorFanIndicatorImpl.getyw(gatewayId);
return ResponseHelper.buildResponse(resultsData);
}
......@@ -599,75 +593,83 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "光伏-总概览")
@GetMapping("/solarPowerOverview")
public ResponseModel<IPage<Map<String, Object>>> solarPowerData(@RequestParam(value = "stationId")String stationId) {
public ResponseModel<IPage<Map<String, Object>>> solarPowerData(@RequestParam(value = "stationId") String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
String boosterGatewayId = stationBasic.getBoosterGatewayId();
String [] columnList = new String[]{"日发电量","月发电量","年发电量"};
String [] columnLists = new String[]{"有功功率"};
String[] columnList = new String[]{"日发电量", "月发电量", "年发电量"};
String[] columnLists = new String[]{"有功功率"};
Map<String, Object> columnMap = new HashMap<>();
//日 月 年发电量同仅统计逆变器数据
List<Map<String, Object>> mapList;
for (String column : columnList) {
Double result = commonService.getTotalByIndicatiorByGF(gatewayId, column);
columnMap.put(column, String.format("%.2f",result*CommonConstans.pvGenPoweActor));
if (column.equals("日发电量")) {
columnMap.put(column, String.format(CommonConstans.Fourdecimalplaces, result * CommonConstans.pvGenPoweActorDay));
} else {
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.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));
columnMap.put("有功功率", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv));
// mapList = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and(equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量' or equipmentIndexName='有功功率')");
//日-月-年-发电量需要保留四位小数问题修改
String num = monitorFanIndicator.getEquipCount(gatewayId,"GF");
columnMap.put("风机台数",num);
String num = monitorFanIndicator.getEquipCount(gatewayId, "GF");
columnMap.put("风机台数", num);
Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber());
//装机容量保留两位小数
columnMap.put("装机容量",String.format("%.2f",capacityl));
List<Map<String,Object>> objects = new ArrayList<>();
columnMap.put("装机容量", String.format("%.2f", capacityl));
List<Map<String, Object>> objects = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("title",columnMap.get("装机容量").toString());
data.put("title", columnMap.get("装机容量").toString());
objects.add(data);
Map<String, Object> data1 = new HashMap<>();
data1.put("title",columnMap.get("日发电量").toString());
data1.put("title", columnMap.get("日发电量").toString());
objects.add(data1);
Map<String, Object> data2 = new HashMap<>();
data2.put("title",columnMap.get("风机台数").toString().replace(".0",""));
data2.put("title", columnMap.get("风机台数").toString().replace(".0", ""));
objects.add(data2);
Map<String, Object> data3 = new HashMap<>();
data3.put("title",columnMap.get("月发电量").toString());
data3.put("title", columnMap.get("月发电量").toString());
objects.add(data3);
Map<String, Object> data4 = new HashMap<>();
data4.put("title",String.format("%.2f",commonService.getSumByEquipmentIndxName(result1,"WTX-801_25_WTX-801_总辐射")));
data4.put("title", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射")));
objects.add(data4);
Map<String, Object> data5 = new HashMap<>();
data5.put("title",columnMap.get("年发电量").toString());
data5.put("title", columnMap.get("年发电量").toString());
objects.add(data5);
Map<String, Object> data6 = new HashMap<>();
data6.put("title", columnMap.get("有功功率").toString()) ;
data6.put("title", columnMap.get("有功功率").toString());
objects.add(data6);
Map<String, Object> data7 = new HashMap<>();
data7.put("title",String.format("%.2f",((Double.parseDouble(columnMap.get("日发电量").toString())/10)/ (Double.parseDouble(columnMap.get("装机容量").toString())))));
data7.put("title", String.format("%.2f", ((Double.parseDouble(columnMap.get("日发电量").toString()) * CommonConstans.wkwhToMv) / (Double.parseDouble(columnMap.get("装机容量").toString())))));
objects.add(data7);
Map<String, Object> data8 = new HashMap<>();
data8.put("title",String.format("%.2f",commonService.getSumByEquipmentIndxName(result1,"WTX-801_25_WTX-801_总辐射累计")));
data8.put("title", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射累计")));
objects.add(data8);
Map<String, Object> data9 = new HashMap<>();
//综合效率 = 发电量/理论发电量
//理论发电量 = 峰值日照数 * 总装机容量
//峰值日照数 = 累计辐照度/3.6
Double powerAll = Double.valueOf((indicatorDataMapper.selectLastDataOfPower("313光差保护_总反向有功电度",boosterGatewayId).getValueF()*CommonConstans.kwToMv*0.028));
Double overallEfficiency = powerAll/((commonService.getSumByEquipmentIndxName(result1,"WTX-801_25_WTX-801_总辐射累计")/3.6)*capacityl);
data9.put("title",String.format("%.2f",overallEfficiency*100)+"%");//综合效率
Double powerAll = indicatorDataMapper.selectLastDataOfPower("313光差保护_总反向有功电度", boosterGatewayId).getValueF() * CommonConstans.kwToMv * 0.028;
Double total = commonService.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射累计");
if (powerAll > 0 && total > 0) {
Double overallEfficiency = powerAll / ((total / 3.6) * capacityl);
data9.put("title", String.format("%.2f", overallEfficiency * 100) + "%");//综合效率
} else {
data9.put("title", "0.00%");//综合效率
}
objects.add(data9);
IPage<Map<String,Object>> result = new Page<>();
IPage<Map<String, Object>> result = new Page<>();
result.setRecords(objects);
result.setCurrent(1);
result.setTotal(objects.size());
......@@ -676,15 +678,14 @@ public class MonitorFanIdxController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "详情基础信息")
@GetMapping("/getEquipInfoByEquipNum")
public ResponseModel<Map<String,Object>> getEquipInfoByEquipNum(@RequestParam(value = "equipNum", required = false) String equipNum,
public ResponseModel<Map<String, Object>> getEquipInfoByEquipNum(@RequestParam(value = "equipNum", required = false) String equipNum,
@RequestParam(value = "stationId", required = false) String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
return ResponseHelper.buildResponse(monitorFanIndicator.getEquipInfoByEquipNum(gatewayId,equipNum ));
return ResponseHelper.buildResponse(monitorFanIndicator.getEquipInfoByEquipNum(gatewayId, equipNum));
}
......@@ -706,11 +707,10 @@ public class MonitorFanIdxController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "详情基础信息")
@GetMapping("/getStatisticsInfo")
public ResponseModel<Map<String,Object>> getStatisticsInfo(@RequestParam(value = "equipmentIndexName", required = false) String equipmentIndexName,
public ResponseModel<Map<String, Object>> getStatisticsInfo(@RequestParam(value = "equipmentIndexName", required = false) String equipmentIndexName,
@RequestParam(value = "stationId", required = false) String stationId,
@RequestParam(value = "stationType", required = false) String stationType) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
......@@ -718,26 +718,26 @@ public class MonitorFanIdxController extends BaseController {
// if (null != stationType){
// gatewayId = stationBasic.getBoosterGatewayId();
// }
return ResponseHelper.buildResponse(monitorFanIndicator.getStatisticsInfo(equipmentIndexName,stationId));
return ResponseHelper.buildResponse(monitorFanIndicator.getStatisticsInfo(equipmentIndexName, stationId));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "码速表")
@GetMapping("/SpeedIndicator")
public ResponseModel<Map<String,Object>> SpeedIndicator(@RequestParam(value = "equipNum", required = false) String equipNum,
public ResponseModel<Map<String, Object>> SpeedIndicator(@RequestParam(value = "equipNum", required = false) String equipNum,
@RequestParam(value = "stationId", required = false) String stationId,
@RequestParam(value = "equipmentIndexName", required = false) String equipmentIndexName
) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
return ResponseHelper.buildResponse(monitorFanIndicator.SpeedIndicator(gatewayId,equipNum,equipmentIndexName ));
return ResponseHelper.buildResponse(monitorFanIndicator.SpeedIndicator(gatewayId, equipNum, equipmentIndexName));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "箱变实时开关状态")
@GetMapping("/equipSwitchStatus")
@Scheduled(cron = "0/10 * * * * ? ")
public ResponseModel<Map<String,Object>> getEquipSwitchStatus() {
public ResponseModel<Map<String, Object>> getEquipSwitchStatus() {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
......@@ -759,20 +759,21 @@ public class MonitorFanIdxController extends BaseController {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
return ResponseHelper.buildResponse(monitorFanIndicatorImpl.collectingBox(gatewayId,current, size ));
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 ));
return ResponseHelper.buildResponse(monitorFanIndicatorImpl.getDeaviAtionRate(stationId, equipNumber));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "光伏 运行列表")
@GetMapping("/solarPowerOperation")
public ResponseModel<IPage<Map<String, Object>>> solarPowerOperation(@RequestParam(value = "stationId")String stationId,@RequestParam(value = "current") int current, int size) {
public ResponseModel<IPage<Map<String, Object>>> solarPowerOperation(@RequestParam(value = "stationId") String stationId, @RequestParam(value = "current") int current, int size) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
......@@ -782,7 +783,7 @@ public class MonitorFanIdxController extends BaseController {
.skip((long) (current - 1) * size)
.limit(size)
.collect(Collectors.toList());
IPage<Map<String,Object>> result = new Page<>();
IPage<Map<String, Object>> result = new Page<>();
result.setRecords(collect);
result.setCurrent(current);
result.setTotal(statusMonitoring.size());
......@@ -793,11 +794,11 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "汇流箱 功率曲线")
@GetMapping("/hlWindSpeeds")
public ResponseModel<Map<String, Object>> hlWindSpeeds(@RequestParam(value = "stationId")String stationId,@RequestParam(value = "equipNum") String equipNum) {
public ResponseModel<Map<String, Object>> hlWindSpeeds(@RequestParam(value = "stationId") String stationId, @RequestParam(value = "equipNum") String equipNum) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
Map<String, Object> result = monitorFanIndicator.hlWindSpeeds(gatewayId,equipNum);
Map<String, Object> result = monitorFanIndicator.hlWindSpeeds(gatewayId, equipNum);
return ResponseHelper.buildResponse(result);
}
......@@ -814,8 +815,8 @@ public class MonitorFanIdxController extends BaseController {
for (StationBasic stationBasic : stationBasics) {
String gatewayId = stationBasic.getFanGatewayId();
String werks = stationBasic.getStationNumber();
if (!stationBasic.getStationType() .equals("FDZ")){
monitorFanIndicator.getListByNbq(gatewayId,werks,stationBasic.getSequenceNbr().toString());
if (!stationBasic.getStationType().equals("FDZ")) {
monitorFanIndicator.getListByNbq(gatewayId, werks, stationBasic.getSequenceNbr().toString());
}
}
......@@ -826,10 +827,11 @@ public class MonitorFanIdxController extends BaseController {
@ApiOperation(value = "风机-三维告警")
@GetMapping("/partofWaring3D")
public ResponseModel<Map<String, Object>> partofWaring3D(@RequestParam(value = "stationId")String stationId,@RequestParam(value = "equipNum") String equipNum) {
Map<String, Object> result = monitorFanIndicator.partofWaring3D(stationId,equipNum);
public ResponseModel<Map<String, Object>> partofWaring3D(@RequestParam(value = "stationId") String stationId, @RequestParam(value = "equipNum") String equipNum) {
Map<String, Object> result = monitorFanIndicator.partofWaring3D(stationId, equipNum);
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "逆变器状态数量")
@GetMapping("/nbqStatus")
......
......@@ -6,6 +6,7 @@ import java.io.Serializable;
@Data
public class StationCacheInfoDto implements Serializable {
private static final long serialVersionUID = 1L;
//场站id
private String stationId;
//场站名称
......
package com.yeejoin.amos.boot.module.jxiop.biz.initdata;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MapRegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
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.dto.QueryDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class StationCacheDataInit implements CommandLineRunner {
@Autowired
private StationBasicMapper stationBasicMapper;
@Autowired
private RegionMapper regionMapper;
@Autowired
private MapRegionMapper mapRegionMapper;
@Autowired
private SjglZsjZsbtzMapper sjglZsjZsbtzMapper;
@Autowired
private CommonServiceImpl commonServiceImpl;
@Autowired
private RedisTemplate redisTemplate;
Logger logger = LoggerFactory.getLogger(StationCacheDataInit.class);
public void run(String... args) throws Exception {
// List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
// redisTemplate.delete("station_info_cache");
// List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
// List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
// List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
// stationBasicList.forEach(stationBasic -> {
// StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto();
// stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString());
// stationCacheInfoDto.setStationName(stationBasic.getStationName());
// stationCacheInfoDto.setStationType(stationBasic.getStationType());
// stationCacheInfoDto.setBelongProvince(regionList.stream().filter(region -> region.getRegionCode().toString().equals(stationBasic.getBelongArea().replace("[", "").split(",")[0])).map(region -> region.getRegionName()).collect(Collectors.toList()).get(0));
// stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 2)) || mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 3))).map(mapRegion -> mapRegion.getName()).collect(Collectors.toList()).get(0));
// stationCacheInfoDto.setInstalledCapacity(String.format("%.2f", sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber())));
// try {
// List<QueryDto> queryDtoList = new ArrayList<>();
// queryDtoList.add(new QueryDto("gatewayId", stationBasic.getFanGatewayId()));
// queryDtoList.add(new QueryDto("equipmentIndexName.keyword", "有功功率"));
// if (!stationBasic.getStationType().equals("FDZ")) {
// queryDtoList.add(new QueryDto("frontModule", "逆变器"));
// }
// stationCacheInfoDto.setEquipmentNumbers(commonServiceImpl.getCount(queryDtoList, "equipmentNumber.Keyword", ESEquipments.class).toString());
// } catch (Exception exception) {
// logger.info("--------------------查询ES错误---------------------------");
// }
// stationCacheInfoDto.setFanGatewayId(stationBasic.getFanGatewayId());
// stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId());
// stationCacheInfoDtos.add(stationCacheInfoDto);
// });
// redisTemplate.opsForList().leftPushAll("station_info_cache", stationCacheInfoDtos);
}
}
......@@ -14,10 +14,10 @@ import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.initdata.StationCacheDataInit;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESEquipmentsRepository;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.index.query.*;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptType;
......@@ -44,6 +44,7 @@ import java.util.*;
import java.util.stream.Collectors;
@Service
@Slf4j
public class CommonServiceImpl {
@Autowired
......@@ -54,8 +55,6 @@ public class CommonServiceImpl {
ESEquipmentsRepository equipmentsRepository;
@Autowired
private ElasticsearchRestTemplate elasticsearchTemplate;
@Autowired
private StationCacheDataInit stationCacheDataInit;
@Autowired
private RedisTemplate redisTemplate;
......@@ -240,14 +239,14 @@ public class CommonServiceImpl {
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(indicator));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
likeQuerCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器");
List<ESEquipments> result = getListDataByCondtions(queryCondtion, null, ESEquipments.class,likeQuerCondtion);
List<ESEquipments> result = getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeQuerCondtion);
Double totalvalue = 0.00;
try {
totalvalue = result.stream().filter(stringObjectMap -> !ObjectUtils.isEmpty(stringObjectMap.getValueF())).mapToDouble(l -> Double.parseDouble(l.getValueF().toString())).sum();
} catch (Exception e) {
return totalvalue;
}
return Double.valueOf(String.format("%.2f", totalvalue*CommonConstans.pvGenPoweActor));
return Double.valueOf(String.format("%.4f", totalvalue * CommonConstans.pvGenPoweActor));
}
public Double getTotalByIndicatiorAndParams(String gatewayId, String indicator, String querySql) {
......@@ -388,42 +387,28 @@ public class CommonServiceImpl {
* @deprecated 获取缓存场站信息数据
*/
public List<StationCacheInfoDto> getListStationCacheInfoDto() {
List<StationCacheInfoDto> stationCacheInfoDtoList = redisTemplate.opsForList().range("station_info_cache", 0, -1);
if (ObjectUtils.isEmpty(stationCacheInfoDtoList)) {
try {
List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
stationBasicList.forEach(stationBasic -> {
for (int i = 0; i < stationBasicList.size(); i++) {
StationBasic stationBasic = stationBasicList.get(i);
StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto();
stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString());
stationCacheInfoDto.setStationName(stationBasic.getStationName());
stationCacheInfoDto.setStationType(stationBasic.getStationType());
stationCacheInfoDto.setBelongProvince(regionList.stream().filter(region -> region.getRegionCode().toString().equals(stationBasic.getBelongArea().replace("[", "").split(",")[0])).map(region -> region.getRegionName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 2)) || mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 3))).map(mapRegion -> mapRegion.getName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setAreaCode(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 2)) || mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 3))).map(mapRegion -> mapRegion.getAreaCode()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setInstalledCapacity(String.format("%.2f", sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber())));
List<QueryDto> queryDtoList = new ArrayList<>();
queryDtoList.add(new QueryDto("gatewayId", stationBasic.getFanGatewayId()));
queryDtoList.add(new QueryDto("equipmentIndexName.keyword", "有功功率"));
if (!stationBasic.getStationType().equals("FDZ")) {
queryDtoList.add(new QueryDto("frontModule", "逆变器"));
}
stationCacheInfoDto.setEquipmentNumbers(this.getCount(queryDtoList, "equipmentNumber.Keyword", ESEquipments.class).toString());
stationCacheInfoDto.setFanGatewayId(stationBasic.getFanGatewayId());
stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId());
stationCacheInfoDtos.add(stationCacheInfoDto);
});
redisTemplate.opsForList().leftPushAll("station_info_cache", stationCacheInfoDtos);
return stationCacheInfoDtos;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return stationCacheInfoDtoList;
return stationCacheInfoDtos;
}
/**
* @param stationId 场站id
* @return 缓存的场站对象
......@@ -494,7 +479,6 @@ public class CommonServiceImpl {
}
/**
* 根据查询条件获取列表信息
*
......@@ -539,7 +523,6 @@ public class CommonServiceImpl {
}
public <T> List<T> getListDataByCondtions(Map<String, List<String>> mustQuerCondtion, Map<String, String> shouldQuerCondtion, Map<String, String> notMustQuerCondtion, Class<T> tClass) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
if (!ObjectUtils.isEmpty(mustQuerCondtion)) {
......@@ -571,19 +554,20 @@ public class CommonServiceImpl {
}
return null;
}
public Double getAvagerByEquipmentIndxName(List<ESEquipments> equipments, String indexName) {
Double result = 0.00;
result = equipments.stream().filter(esEquipments -> esEquipments.getEquipmentIndexName().equals(indexName)).filter(esEquipments -> esEquipments.getValueF()!= null).mapToDouble(ESEquipments::getValueF).average().getAsDouble();
result = equipments.stream().filter(esEquipments -> esEquipments.getEquipmentIndexName().equals(indexName)).filter(esEquipments -> esEquipments.getValueF() != null).mapToDouble(ESEquipments::getValueF).average().getAsDouble();
return result;
}
public Double getSumByEquipmentIndxName(List<ESEquipments> equipments, String indexName) {
Double result = 0.00;
result = equipments.stream().filter(esEquipments -> esEquipments.getEquipmentIndexName().equals(indexName)).filter(esEquipments -> esEquipments.getValueF()!= null).mapToDouble(ESEquipments::getValueF).sum();
result = equipments.stream().filter(esEquipments -> esEquipments.getEquipmentIndexName().equals(indexName)).filter(esEquipments -> esEquipments.getValueF() != null).mapToDouble(ESEquipments::getValueF).sum();
return result;
}
public <T> List<T> getListDataByCondtions(Map<String, List<String>> mustQuerCondtion, Map<String, String> shouldQuerCondtion, Class<T> tClass,Map<String, String> likeQuerCondtion) {
public <T> List<T> getListDataByCondtions(Map<String, List<String>> mustQuerCondtion, Map<String, String> shouldQuerCondtion, Class<T> tClass, Map<String, String> likeQuerCondtion) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
if (!ObjectUtils.isEmpty(mustQuerCondtion)) {
for (String key : mustQuerCondtion.keySet()) {
......@@ -599,7 +583,7 @@ public class CommonServiceImpl {
if (!ObjectUtils.isEmpty(likeQuerCondtion)) {
for (String key : likeQuerCondtion.keySet()) {
queryBuilder.must(QueryBuilders.wildcardQuery(key, "*"+likeQuerCondtion.get(key)+"*"));
queryBuilder.must(QueryBuilders.wildcardQuery(key, "*" + likeQuerCondtion.get(key) + "*"));
}
}
Query query = new NativeSearchQueryBuilder()
......
......@@ -28,15 +28,14 @@ public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto,
public ResultsData getEventByEquipIndex(String gatewayId, int current, int size, String equipIndex, String frontModule) {
List<EquipAlarmEvent> equipAlarmEvents = new ArrayList<>();
//参数传递进来的实际上为场站id
StationBasic stationBasic = this.stationBasicMapper.selectById(gatewayId);
LambdaQueryWrapper<EquipAlarmEvent> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EquipAlarmEvent::getEquipIndex, equipIndex);
queryWrapper.eq(EquipAlarmEvent::getGatewayId, stationBasic.getFanGatewayId());
queryWrapper.eq(EquipAlarmEvent::getGatewayId, gatewayId);
queryWrapper.eq(EquipAlarmEvent::getFrontModule, frontModule);
queryWrapper.orderByDesc(EquipAlarmEvent::getCreatedTime);
equipAlarmEvents = equipAlarmEventMapper.selectList(queryWrapper);
DataGridMock DataGridMock = new DataGridMock(current, equipAlarmEvents.size(), false, current, equipAlarmEvents);
DataGridMock DataGridMock = new DataGridMock(current, equipAlarmEvents.size(), false, current, equipAlarmEvents.subList((current - 1) * size, current * size));
ColModel colModelEventMovement = new ColModel("equipName", "equipName", "设备名", "设备名", "dataGrid", "equipName");
ColModel colModelStationName = new ColModel("alarmDesc", "alarmDesc", "事件描述", "事件描述", "dataGrid", "alarmDesc");
ColModel colModelEventDesc = new ColModel("createdTime", "createdTime", "告警时间", "告警时间", "dataGrid", "createdTime");
......
......@@ -32,6 +32,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IMonitorFanIndicator;
import com.yeejoin.amos.component.robot.BadRequest;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.expression.DoubleValue;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
......@@ -211,6 +212,17 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
.skip((long) (current - 1) * size)
.limit(size)
.collect(Collectors.toList());
List<String> powerOther = Arrays.asList("月发电量", "年发电量", "总发电量");
if (!stationBasic.getStationType().equals("FDZ")) {
collect.forEach(esEquipments -> {
if (esEquipments.getEquipmentIndexName().equals("日发电量")) {
esEquipments.setValue(String.format(CommonConstans.Fourdecimalplaces, Double.valueOf(esEquipments.getValue()) * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
}
if (powerOther.contains(esEquipments.getEquipmentIndexName())) {
esEquipments.setValue(String.format(CommonConstans.Fourdecimalplaces, Double.valueOf(esEquipments.getValue()) * CommonConstans.pvGenPoweActor));
}
});
}
page.setTotal(result.size());
page.setRecords(collect);
return page;
......@@ -516,12 +528,12 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
List<IndicatorData> indicatorDataListActivePowers = new ArrayList<>();
indicatorDataListActivePowers= indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber("有功功率",name,startTime,endTime,gatewayId);
List<String> axisData= new ArrayList<>();
indicatorDataListActivePowers = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber("有功功率", name, startTime, endTime, gatewayId);
List<String> axisData = new ArrayList<>();
List<String> activePowers = new ArrayList<>();
for (int i = 0; i < indicatorDataListActivePowers.size(); i++) {
activePowers.add(indicatorDataListActivePowers.get(i).getValue());
axisData.add(DateUtil.format(indicatorDataListActivePowers.get(i).getCreatedTime(),"HH:mm"));
axisData.add(DateUtil.format(indicatorDataListActivePowers.get(i).getCreatedTime(), "HH:mm"));
}
List<Map<String, Object>> seriesData = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
......@@ -1741,7 +1753,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
List<IndicatorData> originarPVs = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumberPv(equipNum,startTime,endTime,gatewayId);
List<IndicatorData> originarPVs = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumberPv(equipNum, startTime, endTime, gatewayId);
originarPVs.size();
Map<String, Object> resultMap = new HashMap<>();
Map<String, List<IndicatorData>> data = originarPVs.stream().collect(Collectors.groupingBy(IndicatorData::getEquipmentIndexName, TreeMap::new, Collectors.toList()));
......@@ -1750,11 +1762,11 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
for (String s : data.keySet()) {
Map<String, Object> map = new HashMap<>();
List<String> value = data.get(s).stream().map(IndicatorData::getValue).collect(Collectors.toList());
axisData =data.get(s).stream().map(indicatorData -> DateUtil.format(indicatorData.getCreatedTime(),"HH:mm")).collect(Collectors.toList());
axisData = data.get(s).stream().map(indicatorData -> DateUtil.format(indicatorData.getCreatedTime(), "HH:mm")).collect(Collectors.toList());
map.put("data", value);
seriesData.add(map);
}
resultMap.put("axisData",axisData);
resultMap.put("axisData", axisData);
resultMap.put("seriesData", seriesData);
return resultMap;
}
......
......@@ -439,44 +439,44 @@ public class MonitoringServiceIMQTTmpl {
@Scheduled(cron = "0 0/1 * * * *")
public void getIndicatorsSwitchInfo() {
Integer current = 1;
Integer size = 99;
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("booster_gateway_id").eq("station_type", "FDZ"));
stationBasicList.forEach(stationBasic -> {
//获取系统的forntmodule 前期每次都查询 后续应该放到缓存中
List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(stationBasic.getBoosterGatewayId());
for (int i = 0; i < boosterStationInfo.size(); i++) {
Map<String, String> map = boosterStationInfo.get(i);
sendIndicatorSwitch(stationBasic.getSequenceNbr().toString(), stationBasic.getBoosterGatewayId(), map.get("boosterName"));
}
});
// Integer current = 1;
// Integer size = 99;
// List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("booster_gateway_id").eq("station_type", "FDZ"));
// stationBasicList.forEach(stationBasic -> {
// //获取系统的forntmodule 前期每次都查询 后续应该放到缓存中
// List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(stationBasic.getBoosterGatewayId());
// for (int i = 0; i < boosterStationInfo.size(); i++) {
// Map<String, String> map = boosterStationInfo.get(i);
// sendIndicatorSwitch(stationBasic.getSequenceNbr().toString(), stationBasic.getBoosterGatewayId(), map.get("boosterName"));
// }
// });
}
public void sendIndicatorSwitch(String stationId, String bootStationGateWayId, String frontMoudule) {
String sql = "SELECT * FROM indicators_" + bootStationGateWayId + " where frontModule = '" + frontMoudule + "' and systemType='开关'";
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql, IndicatorsDto.class);
//过滤掉包含数字的开关
List<IndicatorsDto> result = indicatorsDtoList.stream().filter(indicatorsDto -> !indicatorsDto.getDisplayName().matches(".*\\d+.*")).collect(Collectors.toList());
HashMap<String, String> hashMap = new HashMap<>();
for (int i = 0; i < result.size(); i++) {
IndicatorsDto indicatorsDto = result.get(i);
//此处需要根据查询的结果来动态的给定图片的url路径。
hashMap.put("url" + i, "tetee");
hashMap.put("display" + i, indicatorsDto.getDisplayName());
}
Page<HashMap<String, String>> hashMapPage = new Page<>();
List<HashMap<String, String>> list = new ArrayList<>();
list.add(hashMap);
hashMapPage.setRecords(list);
hashMapPage.setTotal(list.size());
hashMapPage.setCurrent(1);
System.out.println(result.size());
try {
emqKeeper.getMqttClient().publish(stationId + bootStationGateWayId + "_topic", JSON.toJSON(hashMapPage).toString().getBytes("UTF-8"), 1, true);
logger.info(JSON.toJSONString(hashMapPage));
logger.info("-----------------发送升压站数据成功=================== 成功!");
} catch (Exception e) {
logger.info("-----------------发送升压站数据成功=================== 成功!");
}
}
// public void sendIndicatorSwitch(String stationId, String bootStationGateWayId, String frontMoudule) {
// String sql = "SELECT * FROM indicators_" + bootStationGateWayId + " where frontModule = '" + frontMoudule + "' and systemType='开关'";
// List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql, IndicatorsDto.class);
// //过滤掉包含数字的开关
// List<IndicatorsDto> result = indicatorsDtoList.stream().filter(indicatorsDto -> !indicatorsDto.getDisplayName().matches(".*\\d+.*")).collect(Collectors.toList());
// HashMap<String, String> hashMap = new HashMap<>();
// for (int i = 0; i < result.size(); i++) {
// IndicatorsDto indicatorsDto = result.get(i);
// //此处需要根据查询的结果来动态的给定图片的url路径。
// hashMap.put("url" + i, "tetee");
// hashMap.put("display" + i, indicatorsDto.getDisplayName());
// }
// Page<HashMap<String, String>> hashMapPage = new Page<>();
// List<HashMap<String, String>> list = new ArrayList<>();
// list.add(hashMap);
// hashMapPage.setRecords(list);
// hashMapPage.setTotal(list.size());
// hashMapPage.setCurrent(1);
// System.out.println(result.size());
// try {
// emqKeeper.getMqttClient().publish(stationId + bootStationGateWayId + "_topic", JSON.toJSON(hashMapPage).toString().getBytes("UTF-8"), 1, true);
// logger.info(JSON.toJSONString(hashMapPage));
// logger.info("-----------------发送升压站数据成功=================== 成功!");
// } catch (Exception e) {
// logger.info("-----------------发送升压站数据成功=================== 成功!");
// }
// }
}
......@@ -205,24 +205,24 @@ public class MonitoringServiceImpl {
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getAvagerByEquipmentIndxName(result, "瞬时风速")));
completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值")/1000));
completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值") / 1000));
completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
} else {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList( "日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
Map<String, String> likeQuerCondtion = new HashMap<>();
likeQuerCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器");
Map<String, List<String>> queryCondtion1 = new HashMap<>();
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("WTX-801_25_WTX-801_总辐射","南瑞光差保护_313P"));
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("WTX-801_25_WTX-801_总辐射", "南瑞光差保护_313P"));
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getBoosterGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class,likeQuerCondtion);
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeQuerCondtion);
List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射")));
completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P")*CommonConstans.kwToMv));
completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor*CommonConstans.pvGenPoweActorDay));
completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv));
completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor));
completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, new BigDecimal(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor)));
}
......@@ -279,17 +279,17 @@ public class MonitoringServiceImpl {
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
dailyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"));
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"));
annualPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量"));
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
monthlyPower.updateAndGet(v -> v +keepFourdecimalPlaces( commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
} else {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
dailyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor*CommonConstans.pvGenPoweActorDay);
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor);
annualPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor);
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor));
}
installCapacity.updateAndGet(v -> v + Double.parseDouble(stationCacheInfoDto.getInstalledCapacity()));
});
......@@ -486,7 +486,7 @@ public class MonitoringServiceImpl {
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
total.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"));
total.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
} else {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量"));
......@@ -494,7 +494,7 @@ public class MonitoringServiceImpl {
Map<String, String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put("frontModule", "逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldQueryCondtion, ESEquipments.class);
total.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor);
total.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor));
}
} catch (Exception e) {
......@@ -603,17 +603,17 @@ public class MonitoringServiceImpl {
Map<String, String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put("frontModule", "逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldQueryCondtion, ESEquipments.class);
dailyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"));
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"));
annualPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量"));
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
} else {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
dailyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor*CommonConstans.pvGenPoweActorDay);
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor);
annualPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor);
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor));
}
});
HashMap<String, String> dayHashMap = new HashMap<>();
......@@ -772,18 +772,18 @@ public class MonitoringServiceImpl {
Double total = 0.00;
List<Map<String, Object>> mapListData = new ArrayList<>();
if (!stationBasic.getStationType().equals("FDZ")) {
Map<String,List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName,Arrays.asList(finalIndicator));
queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getFanGatewayId()));
Map<String,String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put("frontModule","逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion,shouldQueryCondtion,ESEquipments.class);
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(finalIndicator));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
Map<String, String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put("frontModule", "逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldQueryCondtion, ESEquipments.class);
total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor;
} else {
Map<String,List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName,Arrays.asList(finalIndicator));
queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion,null,ESEquipments.class);
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(finalIndicator));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor;
}
stationBasic.setAddress(String.format(CommonConstans.Twodecimalplaces, (total * 10) / install));
......@@ -825,7 +825,7 @@ public class MonitoringServiceImpl {
//计算所有场站年计划完成量
int year = Calendar.getInstance().get(Calendar.YEAR);
LambdaQueryWrapper<StationPlan> query = new LambdaQueryWrapper<>();
query.eq(StationPlan::getYear,String.valueOf(year));
query.eq(StationPlan::getYear, String.valueOf(year));
List<StationPlan> stationPlans = stationPlanMapper.selectList(query);
double yearValue = stationPlans.stream().mapToDouble(StationPlan::getValue).sum();
double fdzValue = stationPlans.stream().filter(e -> e.getStationType().equals("FDZ")).mapToDouble(StationPlan::getValue).sum();
......@@ -891,27 +891,27 @@ public class MonitoringServiceImpl {
AtomicReference<Double> powerOfMonthGF = new AtomicReference<>(new Double(0.00));
AtomicReference<Double> powerOfAnnualGF = new AtomicReference<>(new Double(0.00));
fdzList.forEach(stationBasic -> {
Map<String,List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName,Arrays.asList("日发电量","月发电量","年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion,null,ESEquipments.class);
powerOfDayFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"));
powerOfMonthFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"));
powerOfAnnualFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量"));
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
powerOfDayFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
powerOfMonthFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
powerOfAnnualFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
});
gfList.forEach(stationBasic -> {
Map<String,List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName,Arrays.asList("日发电量","月发电量","年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getFanGatewayId()));
Map<String,String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put("frontModule","逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion,shouldQueryCondtion,ESEquipments.class);
powerOfDayGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"));
powerOfMonthGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"));
powerOfAnnualGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量"));
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
Map<String, String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put("frontModule", "逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldQueryCondtion, ESEquipments.class);
powerOfDayGF.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
powerOfMonthGF.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
powerOfAnnualGF.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
});
HashMap<String, String> stringHashMap4 = new HashMap<>();
stringHashMap4.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfDayGF.get() * CommonConstans.pvGenPoweActor));
stringHashMap4.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfDayGF.get() * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
list1.add(stringHashMap4);
HashMap<String, String> stringHashMap5 = new HashMap<>();
stringHashMap5.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfMonthGF.get() * CommonConstans.pvGenPoweActor));
......@@ -920,14 +920,14 @@ public class MonitoringServiceImpl {
stringHashMap6.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get() * CommonConstans.pvGenPoweActor));
list1.add(stringHashMap6);
HashMap<String, String> stringHashMap7 = new HashMap<>();
stringHashMap7.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get()/fdzValue ) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get()*CommonConstans.pvGenPoweActor/gfvalue));
stringHashMap7.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get() / fdzValue) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get() * CommonConstans.pvGenPoweActor / gfvalue));
list1.add(stringHashMap7);
HashMap<String, String> stringHashMap8 = new HashMap<>();
stringHashMap8.put("title", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() * CommonConstans.wkwhToMv) / fdzInstall.doubleValue()) + "/" + String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualGF.get() * CommonConstans.pvGenPoweActor * CommonConstans.wkwhToMv) / gfInstall.doubleValue()));
list1.add(stringHashMap8);
page1.setRecords(list1);
HashMap<String, String> stringHashMap9 = new HashMap<>();
stringHashMap9.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get() + (powerOfDayGF.get() * CommonConstans.pvGenPoweActor*CommonConstans.pvGenPoweActorDay)));
stringHashMap9.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get() + (powerOfDayGF.get() * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay)));
list2.add(stringHashMap9);
HashMap<String, String> stringHashMap10 = new HashMap<>();
stringHashMap10.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get() * CommonConstans.pvGenPoweActor));
......@@ -936,7 +936,7 @@ public class MonitoringServiceImpl {
stringHashMap11.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get() + powerOfAnnualGF.get() * CommonConstans.pvGenPoweActor));
list2.add(stringHashMap11);
HashMap<String, String> stringHashMap12 = new HashMap<>();
stringHashMap12.put("title", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() + powerOfAnnualGF.get()*CommonConstans.pvGenPoweActor) /yearValue));
stringHashMap12.put("title", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() + powerOfAnnualGF.get() * CommonConstans.pvGenPoweActor) / yearValue));
list2.add(stringHashMap12);
page2.setRecords(list2);
Double totalAnnual = (powerOfAnnualFD.get() + powerOfAnnualGF.get() * CommonConstans.pvGenPoweActor);
......@@ -973,18 +973,18 @@ public class MonitoringServiceImpl {
stationBasicListAll.forEach(stationBasic -> {
List<Map<String, Object>> mapList;
if (stationBasic.getStationType().equals("FDZ")) {
Map<String,List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName,Arrays.asList("年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion,null,ESEquipments.class);
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
stationBasic.setAddress(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
} else {
Map<String,List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName,Arrays.asList("年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getFanGatewayId()));
Map<String,String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put("frontModule","逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion,shouldQueryCondtion,ESEquipments.class);
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
Map<String, String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put("frontModule", "逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldQueryCondtion, ESEquipments.class);
stationBasic.setAddress(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor));
}
});
......@@ -1170,20 +1170,24 @@ public class MonitoringServiceImpl {
HashMap<String, String> hashMap = new HashMap<>();
AtomicReference<Double> total = new AtomicReference<>(0.0);
List<StationBasic> stationBasicListAll = new ArrayList<>();
Map<String,List<String>> queryCondtion = new HashMap<>();
Map<String, List<String>> queryCondtion = new HashMap<>();
if (!ObjectUtils.isEmpty(areaName)) {
stationBasicListAll = getListOfStationBasicByAreaName(areaName);
} else {
stationBasicListAll = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
}
stationBasicListAll.forEach(stationBasic -> {
queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getFanGatewayId()));
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName,Arrays.asList("有功功率"));
List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion,null,ESEquipments.class);
total.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(esEquipmentsList,"有功功率"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("有功功率"));
List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
total.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(esEquipmentsList, "有功功率"));
});
//有功功率换算
hashMap.put("title", String.format(CommonConstans.Twodecimalplaces, total.get()));
return hashMap;
}
public Double keepFourdecimalPlaces(Double param) {
return Double.valueOf(String.format("%.4f", param));
}
}
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