Commit 691dc667 authored by tangwei's avatar tangwei

解决冲突

parents fef8bab4 497f11df
...@@ -21,17 +21,13 @@ import java.util.List; ...@@ -21,17 +21,13 @@ import java.util.List;
@Component @Component
public class KSolarRequestUtil { public class KSolarRequestUtil {
@Autowired
private AESUtils aesUtils;
/** /**
* @return HashMap<String, Object> 发送请求前的准备 准备header信息 * @return HashMap<String, Object> 发送请求前的准备 准备header信息
* @deprecated 根据厂商编码获取厂商的hearer * @deprecated 根据厂商编码获取厂商的hearer
*/ */
public HashMap<String, Object> getHeader() { public HashMap<String, String> getHeader() {
HashMap<String, Object> hashMap = new HashMap<>(); HashMap<String, String> hashMap = new HashMap<>();
HashMap<String, Object> requsetParams = new HashMap<>();
String requestParam=""; String requestParam="";
HashMap<String, String> hashMaphead = new HashMap<>(); HashMap<String, String> hashMaphead = new HashMap<>();
try { try {
...@@ -43,6 +39,10 @@ public class KSolarRequestUtil { ...@@ -43,6 +39,10 @@ public class KSolarRequestUtil {
hashMaphead.put("Content-Type","application/x-www-form-urlencoded;charset=utf-8"); 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))); 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(); 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; return hashMap;
} }
...@@ -62,13 +62,8 @@ public class KSolarRequestUtil { ...@@ -62,13 +62,8 @@ public class KSolarRequestUtil {
JSONArray jsonArray = null; JSONArray jsonArray = null;
List<T> result = new ArrayList<>(); List<T> result = new ArrayList<>();
try { try {
HashMap<String, Object> producerInfo = getHeader(); HashMap<String, String> headMap = getHeader();
String baseurl = (String) producerInfo.get("apiurl"); String url = KSolarConstant.baseurl + 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);
respone = sendRequest(requestMethod, url, requestParmInfo, headMap); respone = sendRequest(requestMethod, url, requestParmInfo, headMap);
jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone); jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone);
if (!ObjectUtils.isEmpty(jsonArray)) { if (!ObjectUtils.isEmpty(jsonArray)) {
......
...@@ -8,4 +8,9 @@ public class KSolarConstant { ...@@ -8,4 +8,9 @@ public class KSolarConstant {
public static String authUsername ="kstar"; public static String authUsername ="kstar";
public static String authPassword ="kstarSecret"; 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; ...@@ -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.HouseholdPvUtils;
import com.yeejoin.amos.api.householdapi.Utils.KSolarRequestUtil; 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.GoLangDataAcquisitionService;
import com.yeejoin.amos.api.householdapi.face.service.KSolarDataAcquisitionService;
import fastjson.JSON; import fastjson.JSON;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -32,7 +33,7 @@ public class HouseholdTestController { ...@@ -32,7 +33,7 @@ public class HouseholdTestController {
@Autowired @Autowired
private GoLangDataAcquisitionService goLangDataAcquisitionService; private GoLangDataAcquisitionService goLangDataAcquisitionService;
@Autowired @Autowired
private KSolarRequestUtil kSolarRequestUtil; private KSolarDataAcquisitionService kSolarDataAcquisitionService;
/** /**
...@@ -110,13 +111,13 @@ public class HouseholdTestController { ...@@ -110,13 +111,13 @@ public class HouseholdTestController {
@PostMapping(value = "/ksolarnew") @PostMapping(value = "/ksolarnew")
@ApiOperation(httpMethod = "POST", value = "科士达", notes = "科士达") @ApiOperation(httpMethod = "POST", value = "科士达", notes = "科士达")
public void ksolarnew() throws IOException { public void ksolarnew() throws IOException {
// goLangDataAcquisitionService.stationList(); kSolarDataAcquisitionService.stationList();
// goLangDataAcquisitionService.stationDetail(); // goLangDataAcquisitionService.stationDetail();
// goLangDataAcquisitionService.collectorList(); // goLangDataAcquisitionService.collectorList();
//// goLangDataAcquisitionService.inverterList(); //// goLangDataAcquisitionService.inverterList();
// goLangDataAcquisitionService.collectorDetail(); // goLangDataAcquisitionService.collectorDetail();
// goLangDataAcquisitionService.inverterDetail(); // goLangDataAcquisitionService.inverterDetail();
// goLangDataAcquisitionService.inverAlramInfo(); // 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 { ...@@ -347,7 +347,7 @@ public class BigScreenAnalyseController extends BaseController {
List<Integer> zyList = new ArrayList<>(); List<Integer> zyList = new ArrayList<>();
List<Integer> jgList = 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 -> { list.forEach(item -> {
wxList.add(wxMap.getOrDefault(item, 0)); wxList.add(wxMap.getOrDefault(item, 0));
......
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
@Repository @Repository
public interface IndicatorDataMapper extends BaseMapper<IndicatorData> { 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); 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; ...@@ -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.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.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.dto.IndicatorsDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test; 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.StationBasicServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.TestServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.TestServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils; import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
...@@ -53,6 +55,9 @@ public class DemoController extends BaseController { ...@@ -53,6 +55,9 @@ public class DemoController extends BaseController {
EmqKeeper emqKeeper; EmqKeeper emqKeeper;
@Autowired @Autowired
PowerGeneration powerGeneration;
@Autowired
private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper; private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
...@@ -199,4 +204,15 @@ public class DemoController extends BaseController { ...@@ -199,4 +204,15 @@ public class DemoController extends BaseController {
return ResponseHelper.buildResponse(hashMap); 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; ...@@ -6,6 +6,7 @@ import java.io.Serializable;
@Data @Data
public class StationCacheInfoDto implements Serializable { public class StationCacheInfoDto implements Serializable {
private static final long serialVersionUID = 1L;
//场站id //场站id
private String stationId; private String stationId;
//场站名称 //场站名称
......
...@@ -12,61 +12,62 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto; ...@@ -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.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j
@Component @Component
public class StationCacheDataInit implements CommandLineRunner { 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); Logger logger = LoggerFactory.getLogger(StationCacheDataInit.class);
@Resource
private StationBasicMapper stationBasicMapper;
@Resource
private RegionMapper regionMapper;
@Resource
private MapRegionMapper mapRegionMapper;
@Resource
private SjglZsjZsbtzMapper sjglZsjZsbtzMapper;
@Resource
private CommonServiceImpl commonServiceImpl;
@Resource
private RedisTemplate redisTemplate;
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
log.info("-------------------------------------开始缓存场站基础数据----------------------------"); redisTemplate.delete("station_info_cache_bigscreen");
List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>(); List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
redisTemplate.delete("station_info_cache");
List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1)); 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")); List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
stationBasicList.forEach(stationBasic -> { stationBasicList.forEach(stationBasic -> {
StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto(); StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto();
stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString()); stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString());
stationCacheInfoDto.setStationName(stationBasic.getStationName()); stationCacheInfoDto.setStationName(stationBasic.getStationName());
stationCacheInfoDto.setStationType(stationBasic.getStationType()); 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.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.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.setInstalledCapacity(String.format("%.2f",sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber()))); try {
List<QueryDto> queryDtoList = new ArrayList<>(); List<QueryDto> queryDtoList = new ArrayList<>();
queryDtoList.add(new QueryDto("gatewayId",stationBasic.getFanGatewayId())); queryDtoList.add(new QueryDto("gatewayId", stationBasic.getFanGatewayId()));
queryDtoList.add(new QueryDto("equipmentIndexName.keyword","有功功率")); queryDtoList.add(new QueryDto("equipmentIndexName.keyword", "有功功率"));
if(!stationBasic.getStationType().equals("FDZ")){ if (!stationBasic.getStationType().equals("FDZ")) {
queryDtoList.add(new QueryDto("frontModule","逆变器")); 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.setFanGatewayId(stationBasic.getFanGatewayId());
stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId()); stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId());
stationCacheInfoDtos.add(stationCacheInfoDto); stationCacheInfoDtos.add(stationCacheInfoDto);
}); });
redisTemplate.opsForList().leftPushAll("station_info_cache",stationCacheInfoDtos); redisTemplate.opsForList().leftPushAll("station_info_cache_bigscreen", stationCacheInfoDtos);
log.info("-------------------------------------结束缓存场站基础数据----------------------------");
} }
} }
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; ...@@ -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.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil; import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchPhraseQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders;
...@@ -163,41 +164,39 @@ public class CommonServiceImpl { ...@@ -163,41 +164,39 @@ public class CommonServiceImpl {
return socialContributionDtoPage; return socialContributionDtoPage;
} }
public List<StationCacheInfoDto> getListStationCacheInfoDto(){ public List<StationCacheInfoDto> getListStationCacheInfoDto() {
List<StationCacheInfoDto> stationCacheInfoDtoList =redisTemplate.opsForList().range("station_info_cache",0,-1); List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
if(ObjectUtils.isEmpty(stationCacheInfoDtoList)){ stationCacheInfoDtos = redisTemplate.opsForList().range("station_info_cache_bigscreen", 0, -1);
try { if (ObjectUtils.isEmpty(stationCacheInfoDtos)) {
List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>(); List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
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"));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id")); for (int i = 0; i < stationBasicList.size(); i++) {
stationBasicList.forEach(stationBasic -> { StationBasic stationBasic = stationBasicList.get(i);
StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto(); StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto();
stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString()); stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString());
stationCacheInfoDto.setStationName(stationBasic.getStationName()); stationCacheInfoDto.setStationName(stationBasic.getStationName());
stationCacheInfoDto.setStationType(stationBasic.getStationType()); 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.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.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.setInstalledCapacity(String.format("%.2f",sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber()))); try {
List<QueryDto> queryDtoList = new ArrayList<>(); List<QueryDto> queryDtoList = new ArrayList<>();
queryDtoList.add(new QueryDto("gatewayId",stationBasic.getFanGatewayId())); queryDtoList.add(new QueryDto("gatewayId", stationBasic.getFanGatewayId()));
queryDtoList.add(new QueryDto("equipmentIndexName.keyword","有功功率")); queryDtoList.add(new QueryDto("equipmentIndexName.keyword", "有功功率"));
if(!stationBasic.getStationType().equals("FDZ")){ if (!stationBasic.getStationType().equals("FDZ")) {
queryDtoList.add(new QueryDto("frontModule","逆变器")); queryDtoList.add(new QueryDto("frontModule", "逆变器"));
} }
stationCacheInfoDto.setEquipmentNumbers(this.getCount(queryDtoList,"equipmentNumber.Keyword", ESEquipments.class).toString()); stationCacheInfoDto.setEquipmentNumbers(getCount(queryDtoList, "equipmentNumber.Keyword", ESEquipments.class).toString());
stationCacheInfoDto.setFanGatewayId(stationBasic.getFanGatewayId()); } catch (Exception exception) {
stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId()); }
stationCacheInfoDtos.add(stationCacheInfoDto); stationCacheInfoDto.setFanGatewayId(stationBasic.getFanGatewayId());
}); stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId());
redisTemplate.opsForList().leftPushAll("station_info_cache",stationCacheInfoDtos); stationCacheInfoDtos.add(stationCacheInfoDto);
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 { ...@@ -222,7 +221,7 @@ public class CommonServiceImpl {
.withPageable(PageRequest.of(0, 1)) .withPageable(PageRequest.of(0, 1))
.build(); .build();
query.setTrackTotalHits(true); query.setTrackTotalHits(true);
SearchHits search = elasticsearchTemplate.search(query, ESEquipments.class); SearchHits search = elasticsearchTemplate.search(query, clas);
if (search.hasAggregations()) { if (search.hasAggregations()) {
Aggregations aggregations = search.getAggregations(); Aggregations aggregations = search.getAggregations();
if (Objects.nonNull(aggregations)) { if (Objects.nonNull(aggregations)) {
......
...@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.entity.StationPlan;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationPlanMapper; 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.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.SeriesData;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil; import com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil;
...@@ -274,7 +276,7 @@ public class LargeScreenImpl { ...@@ -274,7 +276,7 @@ public class LargeScreenImpl {
//全国发电趋势 //全国发电趋势
@Scheduled(cron = "0/10 * * * * ?") @Scheduled(cron = "0/10 * * * * ? ")
public SeriesData getSeriesDataqg(){ public SeriesData getSeriesDataqg(){
//获取今年当月 日发电趋势 //获取今年当月 日发电趋势
...@@ -289,8 +291,8 @@ public class LargeScreenImpl { ...@@ -289,8 +291,8 @@ public class LargeScreenImpl {
mapjn.put("data",listjn); mapjn.put("data",listjn);
mapjn.put("name","当前值"); mapjn.put("name","当前值");
Map<String,Object> mapqn=new HashMap<>(); Map<String,Object> mapqn=new HashMap<>();
mapjn.put("data",listqn); mapqn.put("data",listqn);
mapjn.put("name","同期值"); mapqn.put("name","同期值");
List<Map<String,Object>> list=new ArrayList<>(); List<Map<String,Object>> list=new ArrayList<>();
list.add(mapjn); list.add(mapjn);
...@@ -377,7 +379,7 @@ public class LargeScreenImpl { ...@@ -377,7 +379,7 @@ public class LargeScreenImpl {
value1.add(monthy); value1.add(monthy);
map.put("moon.keyword",value1); 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<>(); Map<String,Double> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000"); DecimalFormat format2 = new DecimalFormat("#.0000");
...@@ -489,7 +491,7 @@ public class LargeScreenImpl { ...@@ -489,7 +491,7 @@ public class LargeScreenImpl {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(month);//month 为指定月份任意日期 cal.setTime(month);//month 为指定月份任意日期
int year = cal.get(Calendar.YEAR); 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); int dayNumOfMonth = DateUtil.getDaysByYearMonth(year, m);
cal.set(Calendar.DAY_OF_MONTH, 1);// 从一号开始 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 ...@@ -80,8 +80,9 @@ amos.secret.key=qaz
#eureka.instance.ip-address=172.16.3.122 #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.user=admin
spring.activemq.password=admin spring.activemq.password=admin
spring.jms.pub-sub-domain=false spring.jms.pub-sub-domain=false
myqueue=amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness 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; ...@@ -7,7 +7,7 @@ import java.util.HashMap;
public class CommonConstans { public class CommonConstans {
//光伏发电量系数 //光伏发电量系数
public static final Double pvGenPoweActor = 0.00001; 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; ...@@ -4,21 +4,14 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; 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.MonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; 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.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.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.IndicatorsDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto; 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.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test; 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.repository.ESEquipmentsRepository;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.*; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.*;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils; import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
...@@ -26,35 +19,23 @@ import com.yeejoin.amos.component.influxdb.InfluxDbConnection; ...@@ -26,35 +19,23 @@ import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; 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.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermsQueryBuilder;
import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations; 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.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.AvgAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.AvgAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.ParsedAvg; import org.elasticsearch.search.aggregations.metrics.ParsedAvg;
import org.elasticsearch.search.aggregations.metrics.ParsedSum; import org.elasticsearch.search.aggregations.metrics.ParsedSum;
import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHits; 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.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -65,12 +46,9 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -65,12 +46,9 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@RestController @RestController
...@@ -103,8 +81,6 @@ public class DemoController extends BaseController { ...@@ -103,8 +81,6 @@ public class DemoController extends BaseController {
CommonServiceImpl commonServiceImpl; CommonServiceImpl commonServiceImpl;
// @Autowired // @Autowired
// PowerGenerationImpl powerGenerationImpl; // PowerGenerationImpl powerGenerationImpl;
@Autowired
StationCacheDataInit stationCacheDataInit;
// @Autowired // @Autowired
// LargeScreenImpl largeScreenImpl; // LargeScreenImpl largeScreenImpl;
...@@ -133,7 +109,7 @@ public class DemoController extends BaseController { ...@@ -133,7 +109,7 @@ public class DemoController extends BaseController {
public String updateStationCacheInfo() { public String updateStationCacheInfo() {
String updateResult = "更新场站信息缓存成功"; String updateResult = "更新场站信息缓存成功";
try { try {
stationCacheDataInit.run();
} catch (Exception e) { } catch (Exception e) {
updateResult = "更新场站信息缓存成功"; updateResult = "更新场站信息缓存成功";
throw new RuntimeException(e); throw new RuntimeException(e);
......
...@@ -6,6 +6,7 @@ import java.io.Serializable; ...@@ -6,6 +6,7 @@ import java.io.Serializable;
@Data @Data
public class StationCacheInfoDto implements Serializable { public class StationCacheInfoDto implements Serializable {
private static final long serialVersionUID = 1L;
//场站id //场站id
private String stationId; 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);
}
}
...@@ -28,15 +28,14 @@ public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto, ...@@ -28,15 +28,14 @@ public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto,
public ResultsData getEventByEquipIndex(String gatewayId, int current, int size, String equipIndex, String frontModule) { public ResultsData getEventByEquipIndex(String gatewayId, int current, int size, String equipIndex, String frontModule) {
List<EquipAlarmEvent> equipAlarmEvents = new ArrayList<>(); List<EquipAlarmEvent> equipAlarmEvents = new ArrayList<>();
//参数传递进来的实际上为场站id
StationBasic stationBasic = this.stationBasicMapper.selectById(gatewayId);
LambdaQueryWrapper<EquipAlarmEvent> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<EquipAlarmEvent> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EquipAlarmEvent::getEquipIndex, equipIndex); queryWrapper.eq(EquipAlarmEvent::getEquipIndex, equipIndex);
queryWrapper.eq(EquipAlarmEvent::getGatewayId, stationBasic.getFanGatewayId()); queryWrapper.eq(EquipAlarmEvent::getGatewayId, gatewayId);
queryWrapper.eq(EquipAlarmEvent::getFrontModule, frontModule); queryWrapper.eq(EquipAlarmEvent::getFrontModule, frontModule);
queryWrapper.orderByDesc(EquipAlarmEvent::getCreatedTime); queryWrapper.orderByDesc(EquipAlarmEvent::getCreatedTime);
equipAlarmEvents = equipAlarmEventMapper.selectList(queryWrapper); 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 colModelEventMovement = new ColModel("equipName", "equipName", "设备名", "设备名", "dataGrid", "equipName");
ColModel colModelStationName = new ColModel("alarmDesc", "alarmDesc", "事件描述", "事件描述", "dataGrid", "alarmDesc"); ColModel colModelStationName = new ColModel("alarmDesc", "alarmDesc", "事件描述", "事件描述", "dataGrid", "alarmDesc");
ColModel colModelEventDesc = new ColModel("createdTime", "createdTime", "告警时间", "告警时间", "dataGrid", "createdTime"); ColModel colModelEventDesc = new ColModel("createdTime", "createdTime", "告警时间", "告警时间", "dataGrid", "createdTime");
......
...@@ -32,6 +32,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils; ...@@ -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.boot.module.jxiop.biz.service.IMonitorFanIndicator;
import com.yeejoin.amos.component.robot.BadRequest; import com.yeejoin.amos.component.robot.BadRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.expression.DoubleValue;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
...@@ -211,6 +212,17 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -211,6 +212,17 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
.skip((long) (current - 1) * size) .skip((long) (current - 1) * size)
.limit(size) .limit(size)
.collect(Collectors.toList()); .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.setTotal(result.size());
page.setRecords(collect); page.setRecords(collect);
return page; return page;
...@@ -516,12 +528,12 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -516,12 +528,12 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN); String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
List<IndicatorData> indicatorDataListActivePowers = new ArrayList<>(); List<IndicatorData> indicatorDataListActivePowers = new ArrayList<>();
indicatorDataListActivePowers= indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber("有功功率",name,startTime,endTime,gatewayId); indicatorDataListActivePowers = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber("有功功率", name, startTime, endTime, gatewayId);
List<String> axisData= new ArrayList<>(); List<String> axisData = new ArrayList<>();
List<String> activePowers = new ArrayList<>(); List<String> activePowers = new ArrayList<>();
for (int i = 0; i < indicatorDataListActivePowers.size(); i++) { for (int i = 0; i < indicatorDataListActivePowers.size(); i++) {
activePowers.add(indicatorDataListActivePowers.get(i).getValue()); 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<>(); List<Map<String, Object>> seriesData = new ArrayList<>();
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -1741,7 +1753,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1741,7 +1753,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date()); Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(currentDayEndTime, 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(); originarPVs.size();
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
Map<String, List<IndicatorData>> data = originarPVs.stream().collect(Collectors.groupingBy(IndicatorData::getEquipmentIndexName, TreeMap::new, Collectors.toList())); 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 { ...@@ -1750,11 +1762,11 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
for (String s : data.keySet()) { for (String s : data.keySet()) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
List<String> value = data.get(s).stream().map(IndicatorData::getValue).collect(Collectors.toList()); 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); map.put("data", value);
seriesData.add(map); seriesData.add(map);
} }
resultMap.put("axisData",axisData); resultMap.put("axisData", axisData);
resultMap.put("seriesData", seriesData); resultMap.put("seriesData", seriesData);
return resultMap; return resultMap;
} }
......
...@@ -439,44 +439,44 @@ public class MonitoringServiceIMQTTmpl { ...@@ -439,44 +439,44 @@ public class MonitoringServiceIMQTTmpl {
@Scheduled(cron = "0 0/1 * * * *") @Scheduled(cron = "0 0/1 * * * *")
public void getIndicatorsSwitchInfo() { public void getIndicatorsSwitchInfo() {
Integer current = 1; // Integer current = 1;
Integer size = 99; // Integer size = 99;
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("booster_gateway_id").eq("station_type", "FDZ")); // List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("booster_gateway_id").eq("station_type", "FDZ"));
stationBasicList.forEach(stationBasic -> { // stationBasicList.forEach(stationBasic -> {
//获取系统的forntmodule 前期每次都查询 后续应该放到缓存中 // //获取系统的forntmodule 前期每次都查询 后续应该放到缓存中
List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(stationBasic.getBoosterGatewayId()); // List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(stationBasic.getBoosterGatewayId());
for (int i = 0; i < boosterStationInfo.size(); i++) { // for (int i = 0; i < boosterStationInfo.size(); i++) {
Map<String, String> map = boosterStationInfo.get(i); // Map<String, String> map = boosterStationInfo.get(i);
sendIndicatorSwitch(stationBasic.getSequenceNbr().toString(), stationBasic.getBoosterGatewayId(), map.get("boosterName")); // sendIndicatorSwitch(stationBasic.getSequenceNbr().toString(), stationBasic.getBoosterGatewayId(), map.get("boosterName"));
} // }
}); // });
} }
public void sendIndicatorSwitch(String stationId, String bootStationGateWayId, String frontMoudule) { // public void sendIndicatorSwitch(String stationId, String bootStationGateWayId, String frontMoudule) {
String sql = "SELECT * FROM indicators_" + bootStationGateWayId + " where frontModule = '" + frontMoudule + "' and systemType='开关'"; // String sql = "SELECT * FROM indicators_" + bootStationGateWayId + " where frontModule = '" + frontMoudule + "' and systemType='开关'";
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql, IndicatorsDto.class); // List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql, IndicatorsDto.class);
//过滤掉包含数字的开关 // //过滤掉包含数字的开关
List<IndicatorsDto> result = indicatorsDtoList.stream().filter(indicatorsDto -> !indicatorsDto.getDisplayName().matches(".*\\d+.*")).collect(Collectors.toList()); // List<IndicatorsDto> result = indicatorsDtoList.stream().filter(indicatorsDto -> !indicatorsDto.getDisplayName().matches(".*\\d+.*")).collect(Collectors.toList());
HashMap<String, String> hashMap = new HashMap<>(); // HashMap<String, String> hashMap = new HashMap<>();
for (int i = 0; i < result.size(); i++) { // for (int i = 0; i < result.size(); i++) {
IndicatorsDto indicatorsDto = result.get(i); // IndicatorsDto indicatorsDto = result.get(i);
//此处需要根据查询的结果来动态的给定图片的url路径。 // //此处需要根据查询的结果来动态的给定图片的url路径。
hashMap.put("url" + i, "tetee"); // hashMap.put("url" + i, "tetee");
hashMap.put("display" + i, indicatorsDto.getDisplayName()); // hashMap.put("display" + i, indicatorsDto.getDisplayName());
} // }
Page<HashMap<String, String>> hashMapPage = new Page<>(); // Page<HashMap<String, String>> hashMapPage = new Page<>();
List<HashMap<String, String>> list = new ArrayList<>(); // List<HashMap<String, String>> list = new ArrayList<>();
list.add(hashMap); // list.add(hashMap);
hashMapPage.setRecords(list); // hashMapPage.setRecords(list);
hashMapPage.setTotal(list.size()); // hashMapPage.setTotal(list.size());
hashMapPage.setCurrent(1); // hashMapPage.setCurrent(1);
System.out.println(result.size()); // System.out.println(result.size());
try { // try {
emqKeeper.getMqttClient().publish(stationId + bootStationGateWayId + "_topic", JSON.toJSON(hashMapPage).toString().getBytes("UTF-8"), 1, true); // emqKeeper.getMqttClient().publish(stationId + bootStationGateWayId + "_topic", JSON.toJSON(hashMapPage).toString().getBytes("UTF-8"), 1, true);
logger.info(JSON.toJSONString(hashMapPage)); // logger.info(JSON.toJSONString(hashMapPage));
logger.info("-----------------发送升压站数据成功=================== 成功!"); // logger.info("-----------------发送升压站数据成功=================== 成功!");
} catch (Exception e) { // } catch (Exception e) {
logger.info("-----------------发送升压站数据成功=================== 成功!"); // logger.info("-----------------发送升压站数据成功=================== 成功!");
} // }
} // }
} }
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