diff --git a/business-service-api/src/main/java/com/ho/business/constant/DeviceTypeConstant.java b/business-service-api/src/main/java/com/ho/business/constant/DeviceTypeConstant.java index cc98cb9..b4b9214 100644 --- a/business-service-api/src/main/java/com/ho/business/constant/DeviceTypeConstant.java +++ b/business-service-api/src/main/java/com/ho/business/constant/DeviceTypeConstant.java @@ -71,6 +71,8 @@ public interface DeviceTypeConstant { //英博DC/DCMPPT String DCDC = "dcdc"; + String MPPT ="mppt"; + //柴油发电机_济宁微山湖 String CF = "cf"; @@ -371,6 +373,8 @@ public interface DeviceTypeConstant { String BMS_MIN_VOL = "bmsMinVol"; } + //mppt 日发起始 + String PV_DAILY_CHARGE_START = "pvDailyReleaseStart"; //日充起始 String DAILY_CHARGE_START = "dailyChargeStart"; //日放起始 diff --git a/business-service-api/src/main/java/com/ho/business/entity/EarningsCalculateMppt.java b/business-service-api/src/main/java/com/ho/business/entity/EarningsCalculateMppt.java new file mode 100644 index 0000000..ddadd25 --- /dev/null +++ b/business-service-api/src/main/java/com/ho/business/entity/EarningsCalculateMppt.java @@ -0,0 +1,101 @@ +package com.ho.business.entity; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +public class EarningsCalculateMppt implements Serializable { + + /** + * 主键id + */ + private Integer id; + + /** + * 分组id(与src_id) + */ + private Integer groupId; + + /** + * 所属id + */ + private Integer pid; + + /** + * 电站id + */ + private Integer stationId; + + /** + * device表中的id字段相连 + */ + private Integer srcId; + + /** + * 部门id + */ + private Integer deptId; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 日期 + */ + private String day; + + /** + * 数据类型: 0:充 1:放 + */ + private Integer type; + + /** + * 收益 + */ + private BigDecimal digital; + + /** + * 电量 + */ + private BigDecimal elec; + + /** + * 费率类型:elec_template_sub表type + */ + private String rateType; + + /** + * 价格 + */ + private BigDecimal price; + + /** + * 总充,总放 根据type判断 + */ + private BigDecimal total; + + /** + * 收益 + */ + private BigDecimal discharge; + + /** + * 电量 + */ + private BigDecimal disElec; + + /** + * 费率类型:elec_template_sub表type + */ + private String disRateType; + + /** + * 折扣 + */ + private BigDecimal discount; +} diff --git a/business-service-api/src/main/java/com/ho/business/entity/Station.java b/business-service-api/src/main/java/com/ho/business/entity/Station.java index b0a40c3..7d3bade 100644 --- a/business-service-api/src/main/java/com/ho/business/entity/Station.java +++ b/business-service-api/src/main/java/com/ho/business/entity/Station.java @@ -52,6 +52,9 @@ public class Station implements Serializable { @ApiModelProperty(value = "额定功率") private BigDecimal ratePower; + @ApiModelProperty(value = "额定功率(光伏mppt)") + private BigDecimal pvPower; + @ApiModelProperty(value = "sn编号列表") private List snList; diff --git a/business-service-api/src/main/java/com/ho/business/vo/req/StationPutReqVO.java b/business-service-api/src/main/java/com/ho/business/vo/req/StationPutReqVO.java index a2f52f6..c28a51a 100644 --- a/business-service-api/src/main/java/com/ho/business/vo/req/StationPutReqVO.java +++ b/business-service-api/src/main/java/com/ho/business/vo/req/StationPutReqVO.java @@ -124,6 +124,11 @@ public class StationPutReqVO { @ApiModelProperty(value = "是否接入光伏:0代表不接,1代表接入") private Integer inverterFlag; + + @ApiModelProperty(value = "额定功率(mppt)") + @Range(max = 999999999, message = "额定功率过大") + BigDecimal pvPower; + //图片地址 @ApiModelProperty(value = "图片地址") Integer logoPictureId; diff --git a/business-service-api/src/main/java/com/ho/business/vo/req/StationReqVO.java b/business-service-api/src/main/java/com/ho/business/vo/req/StationReqVO.java index fcd1191..3abd332 100644 --- a/business-service-api/src/main/java/com/ho/business/vo/req/StationReqVO.java +++ b/business-service-api/src/main/java/com/ho/business/vo/req/StationReqVO.java @@ -102,6 +102,10 @@ public class StationReqVO { @ApiModelProperty(value = "是否接入光伏(0默认不接入 1接入)") private Integer inverterFlag; + @ApiModelProperty(value = "额定功率(mppt)") + @Range(max = 999999999, message = "额定功率过大") + BigDecimal pvPower; + @ApiModelProperty(value = "卡号") private String iccId; diff --git a/business-service-api/src/main/java/com/ho/business/vo/resp/cabin/EarningsCalculateResp.java b/business-service-api/src/main/java/com/ho/business/vo/resp/cabin/EarningsCalculateResp.java index da9e7d2..7c0bdd0 100644 --- a/business-service-api/src/main/java/com/ho/business/vo/resp/cabin/EarningsCalculateResp.java +++ b/business-service-api/src/main/java/com/ho/business/vo/resp/cabin/EarningsCalculateResp.java @@ -88,4 +88,16 @@ public class EarningsCalculateResp { */ private Integer finish; + + @ApiModelProperty(value = "月发电量(mppt)") + BigDecimal monthReleaseElec; + @ApiModelProperty(value = "月收益(mppt)") + BigDecimal monthIncone; + @ApiModelProperty(value = "累计发电量(mppt)") + BigDecimal totalReleaseElec; + @ApiModelProperty(value = "累计收益(mppt)") + BigDecimal totalIncome; + @ApiModelProperty(value = "额定功率(mppt)") + BigDecimal pvPower; + } diff --git a/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/AnnualChartValue.java b/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/AnnualChartValue.java index fce9a26..a67048a 100644 --- a/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/AnnualChartValue.java +++ b/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/AnnualChartValue.java @@ -36,4 +36,6 @@ public class AnnualChartValue { @ApiModelProperty(value = "容量") BigDecimal stationCapacity; + @ApiModelProperty(value = "mppt发电量") + BigDecimal release; } diff --git a/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/AnnualPvOverviewResp.java b/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/AnnualPvOverviewResp.java new file mode 100644 index 0000000..f74203e --- /dev/null +++ b/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/AnnualPvOverviewResp.java @@ -0,0 +1,37 @@ +package com.ho.business.vo.resp.iargeScreen; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class AnnualPvOverviewResp { + + //装机容量 + @ApiModelProperty(value = "装机容量") + BigDecimal capacity; + + //电站总数 + @ApiModelProperty(value = "电站总数") + Integer stationNumber; + + @ApiModelProperty(value = "日发电量(mppt)") + BigDecimal dailyReleaseElec; + + @ApiModelProperty(value = "年发电量(mppt)") + BigDecimal yearReleaseElec; + + @ApiModelProperty(value = "累计发电量(mppt)") + BigDecimal totalReleaseElec; + + + @ApiModelProperty(value = "日收益(mppt)") + BigDecimal todayIncone; + + @ApiModelProperty(value = "年收益(mppt)") + BigDecimal yearIncone; + + @ApiModelProperty(value = "累计收益(mppt)") + BigDecimal totalIncome; +} diff --git a/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/Subdata.java b/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/Subdata.java index a506326..cde1b19 100644 --- a/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/Subdata.java +++ b/business-service-api/src/main/java/com/ho/business/vo/resp/iargeScreen/Subdata.java @@ -52,4 +52,7 @@ public class Subdata { //年总充() @ApiModelProperty(value = "总充") BigDecimal charge; + + @ApiModelProperty(value = "mppt总发电量") + BigDecimal release; } diff --git a/business-service-api/src/main/java/com/ho/business/vo/resp/mppt/MpptActiveVo.java b/business-service-api/src/main/java/com/ho/business/vo/resp/mppt/MpptActiveVo.java new file mode 100644 index 0000000..e072125 --- /dev/null +++ b/business-service-api/src/main/java/com/ho/business/vo/resp/mppt/MpptActiveVo.java @@ -0,0 +1,20 @@ +package com.ho.business.vo.resp.mppt; + +import com.ho.business.vo.DeviceTransfer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class MpptActiveVo { + + @ApiModelProperty(value = "mppt有功功率") + BigDecimal pvActivePower; + + @ApiModelProperty(value = "mppt总发电量") + BigDecimal totalRelease; + + @ApiModelProperty(value = "mppt日发电量") + BigDecimal dailyReleaseElec; +} diff --git a/business-service-api/src/main/java/com/ho/business/vo/resp/mppt/MpptVo.java b/business-service-api/src/main/java/com/ho/business/vo/resp/mppt/MpptVo.java new file mode 100644 index 0000000..2684650 --- /dev/null +++ b/business-service-api/src/main/java/com/ho/business/vo/resp/mppt/MpptVo.java @@ -0,0 +1,17 @@ +package com.ho.business.vo.resp.mppt; + +import com.ho.business.vo.DeviceTransfer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class MpptVo { + + @ApiModelProperty(value = "mppt有功功率") + DeviceTransfer pvActivePower; + @ApiModelProperty(value = "mppt总发电量") + DeviceTransfer totalRelease; + @ApiModelProperty(value = "mppt 日发电量-起始") + DeviceTransfer pvDailyReleaseStart; + +} diff --git a/business-service-api/src/main/java/com/ho/business/vo/resp/pcsStation/PcsTotalData.java b/business-service-api/src/main/java/com/ho/business/vo/resp/pcsStation/PcsTotalData.java index b2c54c3..b035848 100644 --- a/business-service-api/src/main/java/com/ho/business/vo/resp/pcsStation/PcsTotalData.java +++ b/business-service-api/src/main/java/com/ho/business/vo/resp/pcsStation/PcsTotalData.java @@ -43,4 +43,18 @@ public class PcsTotalData { @ApiModelProperty(value = "额定容量") BigDecimal rateCapacity; + //2025-11-13 储能加入mppt模块开发 + @ApiModelProperty(value = "当前功率(mppt)") + BigDecimal pvCurrentPower; + @ApiModelProperty(value = "日发电量(mppt)") + BigDecimal dailyReleaseElec; + @ApiModelProperty(value = "日收益(mppt)") + BigDecimal todayIncone; + @ApiModelProperty(value = "总发电量(mppt)") + BigDecimal totalReleaseElec; + @ApiModelProperty(value = "总收益(mppt)") + BigDecimal totalIncome; + @ApiModelProperty(value = "额定功率(mppt)") + BigDecimal pvPower; + } diff --git a/business-service-dao/src/main/java/com/ho/business/feignclient/TdFeignClient.java b/business-service-dao/src/main/java/com/ho/business/feignclient/TdFeignClient.java index eeb6c3b..ecd7293 100644 --- a/business-service-dao/src/main/java/com/ho/business/feignclient/TdFeignClient.java +++ b/business-service-dao/src/main/java/com/ho/business/feignclient/TdFeignClient.java @@ -99,6 +99,9 @@ public interface TdFeignClient { @PostMapping(value = ContextConstant.TD_CONTEXT + "device001/getToDayPVCharge") DataResult getToDayPVCharge(TdBaseTimeQuery tdBaseTimeQuery); + @PostMapping(value = ContextConstant.TD_CONTEXT + "device001/getToDayPVMpptCharge") + DataResult getToDayPVMpptCharge(TdBaseTimeQuery tdBaseTimeQuery); + //查询遥信值五遥 @PostMapping(value = ContextConstant.TD_CONTEXT + "device001/querySignal") DataResult> querySignal(@RequestBody TdBaseTimeQuery tdBaseTimeQuery); diff --git a/business-service-dao/src/main/java/com/ho/business/feignclient/TdFeignClientFallback.java b/business-service-dao/src/main/java/com/ho/business/feignclient/TdFeignClientFallback.java index db23963..d0a1b38 100644 --- a/business-service-dao/src/main/java/com/ho/business/feignclient/TdFeignClientFallback.java +++ b/business-service-dao/src/main/java/com/ho/business/feignclient/TdFeignClientFallback.java @@ -168,6 +168,12 @@ public class TdFeignClientFallback implements TdFeignClient{ throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL); } + @Override + public DataResult getToDayPVMpptCharge(TdBaseTimeQuery tdBaseTimeQuery) { + log.error("调用 [TdClient.getToDayPVCharge] 异常!"); + throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL); + } + @Override public DataResult modifyHistoryData(TdBaseTimeQuery tdBaseTimeQuery) { log.error("调用 [TdClient.modifyHistoryData] 异常!"); diff --git a/business-service-dao/src/main/java/com/ho/business/mapper/EarningsCalculateMapper.java b/business-service-dao/src/main/java/com/ho/business/mapper/EarningsCalculateMapper.java index 5deee72..79d665a 100644 --- a/business-service-dao/src/main/java/com/ho/business/mapper/EarningsCalculateMapper.java +++ b/business-service-dao/src/main/java/com/ho/business/mapper/EarningsCalculateMapper.java @@ -48,7 +48,7 @@ public interface EarningsCalculateMapper { */ List totalListByDay(@Param("ec") EarningsCalculateReq earningsCalculateReq); - public List queryElecTemplateSubByStationId(@Param("stationId")Integer stationId, @Param("templateType")Integer templateType,@Param("date")String date); + public List queryElecTemplateSubByStationId(@Param("stationId")Integer stationId, @Param("templateType")Integer templateType,@Param("date")String date,@Param("elecType")Integer elecType); public List queryElecRateTemplateSubByStationId(@Param("stationId")Integer stationId, @Param("templateType")Integer templateType,@Param("date")String date); diff --git a/business-service-dao/src/main/java/com/ho/business/mapper/EarningsCalculateMpptMapper.java b/business-service-dao/src/main/java/com/ho/business/mapper/EarningsCalculateMpptMapper.java new file mode 100644 index 0000000..c212399 --- /dev/null +++ b/business-service-dao/src/main/java/com/ho/business/mapper/EarningsCalculateMpptMapper.java @@ -0,0 +1,30 @@ +package com.ho.business.mapper; + +import com.ho.business.entity.EarningsCalculate; +import com.ho.business.entity.EarningsCalculateMppt; +import com.ho.business.vo.req.bigScreen.CommonBigScreenReq; +import com.ho.business.vo.resp.InverterResp.PowerGenerateRespVO; +import com.ho.business.vo.resp.profit.DayProfitType; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; + +@Mapper +public interface EarningsCalculateMpptMapper { + + int deleteByDay(@Param("day") String day, @Param("typeList") List typeList); + + int insertBatch(List list); + + List countPvIncome(@Param("stationId") Integer stationId, @Param("beginTime")String beginTime, @Param("endTime")String endTime); + + BigDecimal countAllPvIncome(@Param("stationId")Integer stationId,@Param("beginTime")String beginTime, @Param("endTime")String endTime); + + List getProfit(@Param("beginTime")String begin, @Param("endTime")String end, @Param("groupId")Integer groupId); + + String getFirstTime(); + + List getEarningsByParam(CommonBigScreenReq req); +} diff --git a/business-service-dao/src/main/java/com/ho/business/mapper/ElecMeterValueMapper.java b/business-service-dao/src/main/java/com/ho/business/mapper/ElecMeterValueMapper.java index c9ff118..7e00825 100644 --- a/business-service-dao/src/main/java/com/ho/business/mapper/ElecMeterValueMapper.java +++ b/business-service-dao/src/main/java/com/ho/business/mapper/ElecMeterValueMapper.java @@ -4,6 +4,7 @@ package com.ho.business.mapper; import com.ho.business.entity.ElecMeterValue; import com.ho.business.vo.req.bigScreen.CommonBigScreenReq; import com.ho.business.vo.req.carbin.ElecMeterReq; +import com.ho.business.vo.resp.profit.DayProfitType; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -54,4 +55,7 @@ public interface ElecMeterValueMapper { List selectAllList(@Param("stationId") Integer stationId, @Param("typeList") List typeList, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("deviceTypeList") List deviceTypeList); + + List getElec(@Param("beginTime") String beginTime,@Param("endTime")String endTime, + @Param("groupId") Integer groupId, @Param("type")Integer type,List stationIds); } diff --git a/business-service-dao/src/main/java/com/ho/business/service/EarningsCalculateMpptService.java b/business-service-dao/src/main/java/com/ho/business/service/EarningsCalculateMpptService.java new file mode 100644 index 0000000..f4c562a --- /dev/null +++ b/business-service-dao/src/main/java/com/ho/business/service/EarningsCalculateMpptService.java @@ -0,0 +1,34 @@ +package com.ho.business.service; + +import com.ho.business.entity.Station; +import com.ho.business.vo.req.bigScreen.CommonBigScreenReq; +import com.ho.business.vo.resp.InverterResp.PowerGenerateRespVO; +import com.ho.business.vo.resp.profit.DayProfitType; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @Description Mppt 尖峰平谷电量收益计算 + * @Author zjl + * @Date 2025/11/19 + */ +public interface EarningsCalculateMpptService { + + int deleteByDay(String transDayStr, List typeList); + + public void allMpptIncome(List stations, String beginTime); + + void todayMpptIncome(List stations, String beginTime); + + List countPvIncome(Integer stationId, String beginTime, String endTime); + + BigDecimal countAllPvIncome(Integer id,String beginTime, String endTime); + + List getProfit(String begin, String end, Integer groupId); + + Date getFirstTime(); + + List getEarningsByParam(CommonBigScreenReq req); +} diff --git a/business-service-dao/src/main/java/com/ho/business/service/EarningsCalculateService.java b/business-service-dao/src/main/java/com/ho/business/service/EarningsCalculateService.java index 9e5729a..c0b113e 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/EarningsCalculateService.java +++ b/business-service-dao/src/main/java/com/ho/business/service/EarningsCalculateService.java @@ -7,6 +7,7 @@ import com.ho.business.vo.req.bigScreen.CommonBigScreenReq; import com.ho.business.vo.req.carbin.EarningsCalculateReq; import com.ho.business.vo.req.pcsStation.PcsStationReq; import com.ho.business.vo.req.report.ReportReqVO; +import com.ho.business.vo.resp.InverterResp.PowerGenerateRespVO; import com.ho.business.vo.resp.cabin.EarningsCalculateCountResp; import com.ho.business.vo.resp.cabin.EarningsCalculateResp; import com.ho.business.vo.resp.income.RevenueOverview; @@ -137,4 +138,5 @@ public interface EarningsCalculateService { List getEarningsByParam(CommonBigScreenReq req); + List getPvMonthData(EarningsCalculateReq req); } diff --git a/business-service-dao/src/main/java/com/ho/business/service/ElecMeterValueService.java b/business-service-dao/src/main/java/com/ho/business/service/ElecMeterValueService.java index 5349bda..3ee7843 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/ElecMeterValueService.java +++ b/business-service-dao/src/main/java/com/ho/business/service/ElecMeterValueService.java @@ -3,6 +3,7 @@ package com.ho.business.service; import com.ho.business.entity.ElecMeterValue; import com.ho.business.vo.req.bigScreen.CommonBigScreenReq; import com.ho.business.vo.req.carbin.ElecMeterReq; +import com.ho.business.vo.resp.profit.DayProfitType; import java.math.BigDecimal; import java.util.List; @@ -50,4 +51,6 @@ public interface ElecMeterValueService { * @return */ List selectGroupByDay(CommonBigScreenReq req); + + List getElec(String begin, String end, Integer groupId, Integer type,List stationIds); } diff --git a/business-service-dao/src/main/java/com/ho/business/service/IargeScreenShowService.java b/business-service-dao/src/main/java/com/ho/business/service/IargeScreenShowService.java index 1d0bc6e..2f0c579 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/IargeScreenShowService.java +++ b/business-service-dao/src/main/java/com/ho/business/service/IargeScreenShowService.java @@ -118,4 +118,18 @@ public interface IargeScreenShowService { */ List getCommonEventCount(SimpleUser user); /**************************************************************/ + + List getCommonPvRegionList(List byDeptId); + + AnnualPvOverviewResp getPvOverviewData(List stationIds); + + EnergySavingRespVo getPvEnergySaving(List stationIds); + + List getPVCommonProfitCurve(CockpitReqVO vo,List stationIds); + + List getPvCommonProfit(String beginString, String endString,List stationIds); + + List getPvCommonElec(String beginString, String endString, List stationIds); + + List getCommonPvRelease(List stationIds); } diff --git a/business-service-dao/src/main/java/com/ho/business/service/OpenStationService.java b/business-service-dao/src/main/java/com/ho/business/service/OpenStationService.java index 651c176..0223298 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/OpenStationService.java +++ b/business-service-dao/src/main/java/com/ho/business/service/OpenStationService.java @@ -4,6 +4,7 @@ import com.ho.business.vo.req.StationReq; import com.ho.business.vo.req.pcsStation.PcsStationReq; import com.ho.business.vo.resp.DeviceRespVO; import com.ho.business.vo.resp.cabin.CircleCtrlResp; +import com.ho.business.vo.resp.mppt.MpptActiveVo; import com.ho.business.vo.resp.pcsStation.HomePageStationDataResp; import com.ho.business.vo.resp.station.ActiveReactivePower; import com.ho.common.tools.util.PageResult; @@ -24,6 +25,8 @@ public interface OpenStationService { ActiveReactivePower getAcPower(Integer stationId); + MpptActiveVo getPvActivePower(Integer stationId); + //环控 List getCircle(List deviceList ); diff --git a/business-service-dao/src/main/java/com/ho/business/service/OutApiService.java b/business-service-dao/src/main/java/com/ho/business/service/OutApiService.java index 7167bb0..d84f4d2 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/OutApiService.java +++ b/business-service-dao/src/main/java/com/ho/business/service/OutApiService.java @@ -25,6 +25,8 @@ public interface OutApiService { void dayPVCharge(MonitorQuery monitorQuery); + void dayPVMpptCharge(MonitorQuery monitorQuery); + //天小时的充放电量 void hourChargeDeal(MonitorQuery monitorQuery) throws ParseException; diff --git a/business-service-dao/src/main/java/com/ho/business/service/StationHomeService.java b/business-service-dao/src/main/java/com/ho/business/service/StationHomeService.java index 36dbb2e..3526c77 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/StationHomeService.java +++ b/business-service-dao/src/main/java/com/ho/business/service/StationHomeService.java @@ -8,6 +8,7 @@ import com.ho.business.vo.resp.AppRealTimeCurveRespVo; import com.ho.business.vo.resp.CountEleData; import com.ho.business.vo.resp.DeviceColData; import com.ho.business.vo.resp.DeviceRespVO; +import com.ho.business.vo.resp.InverterResp.PowerGenerateRespVO; import com.ho.business.vo.resp.cabin.TemperatureHumidityResp; import com.ho.business.vo.resp.pcsStation.OutStationData; import com.ho.business.vo.resp.pcsStation.PcsElecData; @@ -72,6 +73,8 @@ public interface StationHomeService { */ List getOpticalStorageCurve(MonitorQuery monitorQuery); + List pvCurve(MonitorQuery monitorQuery); + List getTemperatureHumidityCurve(MonitorQuery monitorQuery); CountEleData getCountEleData(StationReq req); @@ -96,6 +99,6 @@ public interface StationHomeService { */ OutStationData getStationData(StationReq req); - List getPvChargeElec(PcsStationReq req); + List getPvData(PcsStationReq req); } diff --git a/business-service-dao/src/main/java/com/ho/business/service/impl/EarningsCalculateMpptServiceImpl.java b/business-service-dao/src/main/java/com/ho/business/service/impl/EarningsCalculateMpptServiceImpl.java new file mode 100644 index 0000000..52af120 --- /dev/null +++ b/business-service-dao/src/main/java/com/ho/business/service/impl/EarningsCalculateMpptServiceImpl.java @@ -0,0 +1,212 @@ +package com.ho.business.service.impl; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import com.ho.business.constant.DeviceTypeConstant; +import com.ho.business.entity.*; +import com.ho.business.feignclient.TdFeignClient; +import com.ho.business.mapper.EarningsCalculateMapper; +import com.ho.business.mapper.EarningsCalculateMpptMapper; +import com.ho.business.service.*; +import com.ho.business.util.QueuesUtil; +import com.ho.business.vo.req.bigScreen.CommonBigScreenReq; +import com.ho.business.vo.req.device.DeviceTypeQuery; +import com.ho.business.vo.resp.DeviceRespVO; +import com.ho.business.vo.resp.InverterResp.PowerGenerateRespVO; +import com.ho.business.vo.resp.profit.DayProfitType; +import com.ho.common.tools.constant.CommonConstant; +import com.ho.common.tools.constant.RedisKeyConstant; +import com.ho.common.tools.exception.DataResult; +import com.ho.common.tools.service.RedisService; +import com.ho.common.tools.vo.req.StationHomeRespVo; +import com.ho.td.api.entity.query.TdBaseTimeQuery; +import jodd.util.CollectionUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class EarningsCalculateMpptServiceImpl implements EarningsCalculateMpptService { + + + @Autowired + EarningsCalculateMpptMapper earningsCalculateMpptMapper; + + @Autowired + private DeviceService deviceService; + + @Autowired + private ModelDeviceService modelDeviceService; + + @Autowired + private DeviceTypeConfigService deviceTypeConfigService; + + public static final String TOTAL_RELEASE = "totalRelease"; + + @Autowired + RedisService redisService; + + @Autowired + EarningsCalculateMapper earningsCalculateMapper; + + @Autowired + private TdFeignClient tdFeignClient; + @Override + public int deleteByDay(String day, List typeList) { + int i = earningsCalculateMpptMapper.deleteByDay(day, typeList); + return i; + } + + /** + * 计算光伏收益 + * @return + */ + private List countMpptIncome(Station station,String beginTime){ + List list =new ArrayList<>(); + Integer stationId = station.getId(); + // 总发 + List deviceRespVOS = deviceService.getListByDeviceType(stationId, DeviceTypeConstant.MPPT); + if (deviceRespVOS.isEmpty()) { + deviceRespVOS = deviceService.getListByFuzzyDeviceType(stationId, DeviceTypeConstant.MPPT); + } + for (DeviceRespVO vo : deviceRespVOS) { + // 查询光伏Mppt 放电量关联字段 如果没关联,则不计算 + List deviceCp = modelDeviceService.getCompListByType("device", vo.getDeviceType(), TOTAL_RELEASE); + if(deviceCp == null ){ + break; + } + // 查询设备模型,没查询到则返回,不计算 + DeviceTypeQuery deviceTypeQuery = new DeviceTypeQuery(); + deviceTypeQuery.setGroupId(station.getGroupId()); + deviceTypeQuery.setDeviceType(deviceCp.get(0).getDeviceType()); + List deviceTypeConfigs = deviceTypeConfigService.queryListByCondition(deviceTypeQuery); + if (deviceTypeConfigs == null){ + break; + } + //开始计算 + //1:组装时序数据库查询参数 + DateTime beginDate = DateUtil.beginOfDay(DateUtil.parse(beginTime)); + DateTime endDate = DateUtil.endOfDay(beginDate); + TdBaseTimeQuery tdBaseQuery = new TdBaseTimeQuery(); + tdBaseQuery.setBeginTime(beginDate.toMsStr()); + tdBaseQuery.setEndTime(endDate.toMsStr()); + tdBaseQuery.setTime("1m"); + tdBaseQuery.setStationId(station.getId()); + tdBaseQuery.setGroupId(station.getGroupId()); + tdBaseQuery.setModelName((deviceTypeConfigs.get(0)).getModelName()); + tdBaseQuery.setCol(deviceCp.get(0).getDeviceCol()); + tdBaseQuery.setSrcId(vo.getSrcId()); + // 查询设备时序数据,如果为空则不计算 + DataResult> listDataResult = tdFeignClient.queryPointTableList(tdBaseQuery); + List datas = listDataResult.getData(); + if(datas ==null){ + break; + } + // 获取电价分时段计算收益 + List elecTemplateSubs = earningsCalculateMapper.queryElecTemplateSubByStationId(station.getId(), 0, beginTime,2); + BigDecimal lastelec = BigDecimal.ZERO; + BigDecimal elec = BigDecimal.ZERO; + int num = 0 ; + for (EarningsCalculateSub sub : elecTemplateSubs ){ + String earnBegin = sub.getBeginTime(); + String earnEnd = sub.getEndTime(); + DateTime earnBeginDate = DateUtil.parse(beginTime + " " + earnBegin + ":00"); + DateTime earnEndate = DateUtil.parse(beginTime + " " + earnEnd + ":59"); + List subData = datas.stream().filter(i->DateUtil.isIn(DateUtil.parse(i.getDate()),earnBeginDate,earnEndate)).collect(Collectors.toList()); + if(subData.size()>0){ + if(num==0){ + elec = subData.get(subData.size()-1).getDigital().subtract(subData.get(0).getDigital()); + }else { + elec = subData.get(subData.size() - 1).getDigital().subtract(lastelec); + } + lastelec = subData.get(subData.size()-1).getDigital(); + num++; + EarningsCalculateMppt earn =new EarningsCalculateMppt(); + earn.setDay(beginTime); + earn.setGroupId(station.getGroupId()); + earn.setStationId(station.getId()); + earn.setSrcId(tdBaseQuery.getSrcId()); + earn.setPrice(sub.getPrice()); + earn.setRateType(sub.getType()); + earn.setType(1); + earn.setCreateTime(new Date()); + BigDecimal discount = sub.getDiscount() == null ? BigDecimal.ONE : sub.getDiscount(); + earn.setTotal(BigDecimal.ZERO); + earn.setElec(elec); + earn.setDiscount(discount); + earn.setDigital(new BigDecimal(String.format("%.4f",elec.multiply(sub.getPrice())))); + list.add(earn); + } + } + } + return list; + } + + @Override + public void todayMpptIncome(List stations,String beginTime){ + if(stations != null && stations.size() > 0){ + for (Station station:stations){ + List list = countMpptIncome(station,beginTime); + // 缓存今日收益 + if(list.size()>0){ + String key = RedisKeyConstant.PV.STATION_PV_TODAY_PROFIT + station.getId(); + BigDecimal todayIncone = list.stream().map(EarningsCalculateMppt::getDigital).reduce(BigDecimal.ZERO,BigDecimal::add); + redisService.set(key, todayIncone); + } + } + } + } + + @Override + public List countPvIncome(Integer stationId, String beginTime, String endTime) { + return earningsCalculateMpptMapper.countPvIncome(stationId,beginTime,endTime); + } + + @Override + public BigDecimal countAllPvIncome(Integer stationId,String beginTime, String endTime) { + BigDecimal data = earningsCalculateMpptMapper.countAllPvIncome(stationId,beginTime,endTime); + return data==null?BigDecimal.ZERO:data; + } + + @Override + public List getProfit(String begin, String end, Integer groupId) { + return earningsCalculateMpptMapper.getProfit(begin, end, groupId); + } + + @Override + public Date getFirstTime() { + String day = earningsCalculateMpptMapper.getFirstTime(); + DateTime date = null; + if(day!=null){ + date = DateUtil.parse(day, CommonConstant.DATE_YMD); + } + return date; + } + + @Override + public List getEarningsByParam(CommonBigScreenReq req) { + return earningsCalculateMpptMapper.getEarningsByParam(req); + } + + @Override + public void allMpptIncome(List stations,String beginTime) { + if(stations != null && stations.size() > 0){ + for (Station station:stations){ + List list = countMpptIncome(station,beginTime); + // 数据插入 + if(list.size()>0){ + int a = this.earningsCalculateMpptMapper.insertBatch(list); + System.err.println("修改的行数:" + a); + } + } + } + } +} diff --git a/business-service-dao/src/main/java/com/ho/business/service/impl/EarningsCalculateServiceImpl.java b/business-service-dao/src/main/java/com/ho/business/service/impl/EarningsCalculateServiceImpl.java index e91aef0..e915d5c 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/impl/EarningsCalculateServiceImpl.java +++ b/business-service-dao/src/main/java/com/ho/business/service/impl/EarningsCalculateServiceImpl.java @@ -24,11 +24,13 @@ import com.ho.business.vo.req.pcsStation.PcsStationReq; import com.ho.business.vo.req.report.ReportReqVO; import com.ho.business.vo.resp.CountEleData; import com.ho.business.vo.resp.DeviceRespVO; +import com.ho.business.vo.resp.InverterResp.PowerGenerateRespVO; import com.ho.business.vo.resp.cabin.EarningsCalculateCountResp; import com.ho.business.vo.resp.cabin.EarningsCalculateResp; import com.ho.business.vo.resp.colCount.ColCountResp; import com.ho.business.vo.resp.income.RevenueOverview; import com.ho.business.vo.resp.income.RevenueOverviewData; +import com.ho.business.vo.resp.mppt.MpptActiveVo; import com.ho.business.vo.resp.pcsStation.EarningsCalculateData; import com.ho.business.vo.resp.pcsStation.PcsElecData; import com.ho.business.vo.resp.profit.DayProfitType; @@ -41,6 +43,7 @@ import com.ho.common.tools.exception.BusinessException; import com.ho.common.tools.service.RedisService; import com.ho.datacollect.api.constant.DataCollectConstant; import com.ho.user.api.vo.req.SysSubDictVO; +import io.swagger.annotations.ApiModelProperty; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.BeanUtils; @@ -101,6 +104,12 @@ public class EarningsCalculateServiceImpl implements EarningsCalculateService { @Autowired UserFeignClient userFeignClient; + @Autowired + OpenStationService openStationService; + + @Autowired + EarningsCalculateMpptService earningsCalculateMpptService; + public static final String DICT_TYPE = "electrovalence_type"; /** start */ @@ -160,6 +169,10 @@ public class EarningsCalculateServiceImpl implements EarningsCalculateService { if (station == null || station.getId() == null) { return ec; } + boolean flag = false; + if(DataCollectConstant.ONE.equals(station.getInverterFlag())){ + flag = true; + } Integer stationId = station.getId(); String deviceType = colCountService.getDeviceType(stationId); List deviceRespVOS = deviceService.getListByDeviceType(stationId, deviceType); @@ -226,6 +239,10 @@ public class EarningsCalculateServiceImpl implements EarningsCalculateService { BigDecimal dailyChargeElec = BigDecimal.ZERO; //日放电量 BigDecimal dailyDischargeElec = BigDecimal.ZERO; + //今日收益(mppt) + BigDecimal todayIncone = BigDecimal.ZERO; + //今日发电量(mppt) + BigDecimal dailyReleaseElec = BigDecimal.ZERO; //当月则叠加当日,否则不叠加 if (sameMonth) { //将当日的日充日放叠加到日冻结中 @@ -240,8 +257,26 @@ public class EarningsCalculateServiceImpl implements EarningsCalculateService { dailyChargeElec = countEleData.getDailyChargeElec(); //日放电量 dailyDischargeElec = countEleData.getDailyDischargeElec(); + if(flag){ + //今日收益(mppt) + String key = RedisKeyConstant.PV.STATION_PV_TODAY_PROFIT + station.getId(); + todayIncone = (BigDecimal)redisService.get(key)==null?BigDecimal.ZERO:(BigDecimal)redisService.get(key); + //今日发电量(mppt) + MpptActiveVo pv = openStationService.getPvActivePower(stationId); + dailyReleaseElec = pv.getDailyReleaseElec(); + } + } + if(flag){ + BigDecimal monthIncone = earningsCalculateMpptService.countAllPvIncome(station.getId(),earningsCalculateReq.getBeginTime(),earningsCalculateReq.getEndTime()); + ec.setMonthIncone(monthIncone.add(todayIncone)); + BigDecimal monthReleaseElec = elecMeterValueService.selectSumByType(station.getId(),DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE,earningsCalculateReq.getBeginTime(),earningsCalculateReq.getEndTime(),null); + ec.setMonthReleaseElec(monthReleaseElec.add(dailyReleaseElec)); + BigDecimal totalIncome = earningsCalculateMpptService.countAllPvIncome(station.getId(),null,null); + ec.setTotalIncome(totalIncome.add(todayIncone)); + BigDecimal totalReleaseElec = elecMeterValueService.selectSumValue(station.getId(),DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE,null); + ec.setTotalReleaseElec(totalReleaseElec.add(dailyReleaseElec)); + ec.setPvPower(station.getPvPower()); } - ec.setTotalChargeElec(pcsElecData.stream().map(PcsElecData::getChargeElec).reduce(BigDecimal.ZERO, BigDecimal::add).add(dailyChargeElec)); ec.setTotalDischargeElec(pcsElecData.stream().map(PcsElecData::getDischargeElec).reduce(BigDecimal.ZERO, BigDecimal::add).add(dailyDischargeElec)); @@ -655,7 +690,8 @@ public class EarningsCalculateServiceImpl implements EarningsCalculateService { if (dateStr != null && !"".equals(dateStr)) { date = dateStr.substring(0, 7); } - earningsCalculateSubs = earningsCalculateMapper.queryElecTemplateSubByStationId(stationId, templateType, dateStr); + Integer elecType = 1; + earningsCalculateSubs = earningsCalculateMapper.queryElecTemplateSubByStationId(stationId, templateType, dateStr,elecType); if (earningsCalculateSubs != null && earningsCalculateSubs.size() > 0) { return earningsCalculateSubs; } @@ -1540,6 +1576,55 @@ public class EarningsCalculateServiceImpl implements EarningsCalculateService { return earningsCalculateMapper.getEarningsByParam(req); } + @Override + public List getPvMonthData(EarningsCalculateReq req) { + List list = new ArrayList<>(); + LocalDateTime mDate = DateUtil.parse(req.getTime(), CommonConstant.DATE_YM).toLocalDateTime(); + LocalDateTime begin = mDate.with(TemporalAdjusters.firstDayOfMonth()); + LocalDateTime end = mDate.with(TemporalAdjusters.lastDayOfMonth()); + String beginTime= DateUtil.format(begin, CommonConstant.DATE_YMD); + String endTime = DateUtil.format(end, CommonConstant.DATE_YMD); + //光伏收益 + List pvIncome = earningsCalculateMpptService.countPvIncome(req.getStationId(),beginTime, endTime); + Map> mapIncome = pvIncome.stream().collect(Collectors.groupingBy(i ->i.getDate())); + //光伏放电 + List types = new ArrayList<>(); + types.add(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE); + List elecMeterValues = elecMeterValueService.selectList(req.getStationId(), types, beginTime, endTime); + Map> mapMeter = elecMeterValues.stream().collect(Collectors.groupingBy(i ->i.getDay())); + + //根据天获取时间段 + List dateTimes = DateUtil.rangeToList(DateUtil.parse(beginTime), DateUtil.parse(endTime), DateField.DAY_OF_MONTH); + for (DateTime dateTime : dateTimes){ + String date = DateUtil.format(dateTime, CommonConstant.DATE_YMD); + PowerGenerateRespVO pv = new PowerGenerateRespVO(); + pv.setDate(date); + List pvIn = mapIncome.get(date); + //收益 + if(pvIn != null){ + pv.setProfit(pvIn.get(0).getProfit()); + } + //放电 + List elecs = mapMeter.get(date); + if(elecs != null){ + pv.setPowerGenerate(elecs.stream().map(ElecMeterValue::getDigital).reduce(BigDecimal.ZERO,BigDecimal::add)); + } + if(date.equals(endTime)){ + String key = RedisKeyConstant.PV.STATION_PV_TODAY_PROFIT + req.getStationId(); + //获取今日收益 + BigDecimal todayIncone = (BigDecimal)redisService.get(key); + pv.setProfit(todayIncone); + //获取今日发电 + //当前功率(光伏)、总发电量、日发电量 + MpptActiveVo todayPv = openStationService.getPvActivePower(req.getStationId()); + pv.setPowerGenerate(todayPv.getDailyReleaseElec()); + + } + list.add(pv); + } + return list; + } + public static ArrayList list(EarningsCalculateSub earningsCalculateSub) { BigDecimal[] bigDecimal = new BigDecimal[49]; ArrayList list = new ArrayList(Arrays.asList(bigDecimal)); diff --git a/business-service-dao/src/main/java/com/ho/business/service/impl/ElecMeterValueServiceImpl.java b/business-service-dao/src/main/java/com/ho/business/service/impl/ElecMeterValueServiceImpl.java index 422a58f..d1f1814 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/impl/ElecMeterValueServiceImpl.java +++ b/business-service-dao/src/main/java/com/ho/business/service/impl/ElecMeterValueServiceImpl.java @@ -5,6 +5,7 @@ import com.ho.business.mapper.ElecMeterValueMapper; import com.ho.business.service.ElecMeterValueService; import com.ho.business.vo.req.bigScreen.CommonBigScreenReq; import com.ho.business.vo.req.carbin.ElecMeterReq; +import com.ho.business.vo.resp.profit.DayProfitType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,7 +27,7 @@ public class ElecMeterValueServiceImpl implements ElecMeterValueService { @Override public BigDecimal selectSumByType(Integer stationId, Integer type, String beginTime, String endTime,Integer srcId) { BigDecimal sum = elecMeterValueMapper.selectSumByType(stationId, type, beginTime, endTime,srcId); - return sum; + return sum == null ? BigDecimal.ZERO:sum; } //按日期和类型删除 @@ -77,7 +78,7 @@ public class ElecMeterValueServiceImpl implements ElecMeterValueService { @Override public BigDecimal selectSumValue(Integer stationId, Integer type,Integer srcId) { BigDecimal sum = elecMeterValueMapper.selectSumValue(stationId, type,srcId); - return sum; + return sum == null ? BigDecimal.ZERO:sum; } @Override @@ -96,4 +97,9 @@ public class ElecMeterValueServiceImpl implements ElecMeterValueService { public List selectGroupByDay(CommonBigScreenReq req) { return elecMeterValueMapper.selectGroupByDay(req); } + + @Override + public List getElec(String begin, String end, Integer groupId, Integer type,List stationIds) { + return elecMeterValueMapper.getElec(begin,end,groupId,type,stationIds); + } } diff --git a/business-service-dao/src/main/java/com/ho/business/service/impl/IargeScreenShowServiceImpl.java b/business-service-dao/src/main/java/com/ho/business/service/impl/IargeScreenShowServiceImpl.java index b09bf11..259becd 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/impl/IargeScreenShowServiceImpl.java +++ b/business-service-dao/src/main/java/com/ho/business/service/impl/IargeScreenShowServiceImpl.java @@ -19,8 +19,10 @@ import com.ho.business.vo.resp.DeviceRespVO; import com.ho.business.vo.resp.ProvinceStation; import com.ho.business.vo.resp.colCount.ColCountResp; import com.ho.business.vo.resp.iargeScreen.*; +import com.ho.business.vo.resp.mppt.MpptActiveVo; import com.ho.business.vo.resp.profit.DayProfitType; import com.ho.common.tools.constant.CommonConstant; +import com.ho.common.tools.constant.RedisKeyConstant; import com.ho.common.tools.entity.SimpleUser; import com.ho.common.tools.service.RedisService; import com.ho.common.tools.util.BigDecimalUtil; @@ -77,6 +79,12 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { @Autowired TranslateProvinceMapper translateProvinceMapper; + @Autowired + OpenStationService openStationService; + + @Autowired + EarningsCalculateMpptService earningsCalculateMpptService; + private final static BigDecimal value = new BigDecimal("0.475"); private final static BigDecimal parameter = new BigDecimal("18.3"); @@ -201,6 +209,62 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { return annualOverviewResp; }*/ + private AnnualPvOverviewResp getPvOverviewDatas(List list){ + AnnualPvOverviewResp annualOverviewResp = new AnnualPvOverviewResp(); + //装机容量 + BigDecimal capacity = BigDecimal.ZERO; + //电站总数 + Integer stationNumber = list.size(); + BigDecimal todayIncone = BigDecimal.ZERO; + BigDecimal dailyReleaseElec = BigDecimal.ZERO; + BigDecimal yearIncone = BigDecimal.ZERO; + BigDecimal totalIncome = BigDecimal.ZERO; + BigDecimal yearReleaseElec = BigDecimal.ZERO; + BigDecimal totalReleaseElec = BigDecimal.ZERO; + //今年开始时间、结束时间 + DateTime begin = DateUtil.beginOfYear(new Date()); + String beginString = DateUtil.format(begin, CommonConstant.DATE_YMD); + String endString = DateUtil.format(DateUtil.endOfYear(new Date()), CommonConstant.DATE_YMD); + for (Station station : list) { + //装机容量进行累加 + BigDecimal capacityStation = station.getCapacity(); + if (capacityStation != null) { + capacity = capacity.add(capacityStation); + } + String key = RedisKeyConstant.PV.STATION_PV_TODAY_PROFIT + station.getId(); + // 今日收益 + BigDecimal tIncone = (BigDecimal)redisService.get(key); + todayIncone = todayIncone.add(tIncone==null?BigDecimal.ZERO:tIncone); + // 年收益 + BigDecimal yIncone = earningsCalculateMpptService.countAllPvIncome(station.getId(),beginString,endString); + yearIncone = yearIncone.add(yIncone); + // 累计收益 + BigDecimal allIncone = earningsCalculateMpptService.countAllPvIncome(station.getId(),null,null); + totalIncome = totalIncome.add(allIncone); + // 日发电 + MpptActiveVo todayPv = openStationService.getPvActivePower(station.getId()); + dailyReleaseElec = dailyReleaseElec.add(todayPv.getDailyReleaseElec()); + // 年发电 + BigDecimal yReleaseElec = elecMeterValueService.selectSumByType(station.getId(),DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE,beginString,endString,null); + yearReleaseElec = yearReleaseElec.add(yReleaseElec); + // 累计发电 + BigDecimal allReleaseElec = elecMeterValueService.selectSumValue(station.getId(),DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE,null); + totalReleaseElec = totalReleaseElec.add(allReleaseElec); + } + //装机容量、电站数量 + annualOverviewResp.setCapacity(capacity); + annualOverviewResp.setStationNumber(stationNumber); + // 今日收益、年收益、累计收益 + annualOverviewResp.setTodayIncone(todayIncone); + annualOverviewResp.setYearIncone(yearIncone.add(todayIncone)); + annualOverviewResp.setTotalIncome(totalIncome.add(todayIncone)); + //今日发电量、年发电量、累计发电量 + annualOverviewResp.setDailyReleaseElec(dailyReleaseElec); + annualOverviewResp.setYearReleaseElec(yearReleaseElec.add(dailyReleaseElec)); + annualOverviewResp.setTotalReleaseElec(totalReleaseElec.add(dailyReleaseElec)); + return annualOverviewResp; + } + private AnnualOverviewResp getOverviewDatas(List list) { AnnualOverviewResp annualOverviewResp = new AnnualOverviewResp(); List stations = new ArrayList<>(); @@ -467,7 +531,23 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { List list = stationService.selectAll(); return getEnergySavingRespVo(list); } + private EnergySavingRespVo getPvEnergySavingRespVo(List list){ + EnergySavingRespVo energySavingRespVo = new EnergySavingRespVo(); + AnnualPvOverviewResp vo = getPvOverviewDatas(list); + BigDecimal totalReleaseElec = vo.getTotalReleaseElec(); + BigDecimal reductionCO2 = totalReleaseElec.multiply(value); + energySavingRespVo.setReductionCO2(reductionCO2); + //等效植树量 等效植树量=等效减排CO2/183/40 + BigDecimal treePlanting = reductionCO2.divide(parameter, 6, BigDecimal.ROUND_HALF_UP).divide(fours, 6, BigDecimal.ROUND_HALF_UP); + energySavingRespVo.setTreePlanting(treePlanting); + //等效节约煤 等效节约煤=所有电站总充*节约标准煤转换系数(04) + BigDecimal equivalentCoal = totalReleaseElec.multiply(four); + energySavingRespVo.setEquivalentCoal(equivalentCoal); + //等效经济收入 等效经济收入=等效节约煤*煤价 (600元/吨) 等效节约煤此处单位为kg,故而单价调整为0.6元/kg + energySavingRespVo.setIncome(equivalentCoal.multiply(coalPrice)); + return energySavingRespVo; + } private EnergySavingRespVo getEnergySavingRespVo(List list) { EnergySavingRespVo energySavingRespVo = new EnergySavingRespVo(); List stations = new ArrayList<>(); @@ -518,6 +598,56 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { return subdataList; } + private List getPvElec(String beginString, String endString, List stations){ + Map stationMap = stations.stream().collect(Collectors.toMap(Station::getId, Function.identity())); + Integer groupId = null; + for (Station station : stations) { + groupId = station.getGroupId(); + } + List stationElec = elecMeterValueService.getElec(beginString, endString, groupId,DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE,null); + Map> profitMap = stationElec.stream().collect(Collectors.groupingBy(DayProfitType::getStationId)); + //创建返回对象 + List subdataList = new ArrayList<>(); + profitMap.forEach((k, v) -> { + Subdata subdata = new Subdata(); + //收益 + BigDecimal result = v.stream().map(DayProfitType::getDigital).reduce(BigDecimal.ZERO,BigDecimal::add); + if (stationMap.containsKey(k)) { + Station station = stationMap.get(k); + subdata.setStationId(k); + subdata.setStationName(station.getName()); + subdata.setRelease(result); + subdataList.add(subdata); + } + }); + subdataList.sort(Comparator.comparing((Subdata::getIncomeValue)).reversed()); + return subdataList; + } + private List getPvSubdata(String beginString, String endString, List stations){ + Map stationMap = stations.stream().collect(Collectors.toMap(Station::getId, Function.identity())); + Integer groupId = null; + for (Station station : stations) { + groupId = station.getGroupId(); + } + List stationProfit = earningsCalculateMpptService.getProfit(beginString, endString, groupId); + Map> profitMap = stationProfit.stream().collect(Collectors.groupingBy(DayProfitType::getStationId)); + //创建返回对象 + List subdataList = new ArrayList<>(); + profitMap.forEach((k, v) -> { + Subdata subdata = new Subdata(); + //收益 + BigDecimal result = v.stream().map(DayProfitType::getDigital).reduce(BigDecimal.ZERO,BigDecimal::add); + if (stationMap.containsKey(k)) { + Station station = stationMap.get(k); + subdata.setStationId(k); + subdata.setStationName(station.getName()); + subdata.setIncomeValue(result); + subdataList.add(subdata); + } + }); + subdataList.sort(Comparator.comparing((Subdata::getIncomeValue)).reversed()); + return subdataList; + } @NotNull private List getSubdata(String beginString, String endString, List stations) { Map stationMap = stations.stream().collect(Collectors.toMap(Station::getId, Function.identity())); @@ -571,6 +701,76 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { return subdataList; } + private List getPvElecByDay(String beginString, String endString, List stations){ + Map stationMap = stations.stream().collect(Collectors.toMap(Station::getId, Function.identity())); + Integer groupId = null; + List ids = new ArrayList<>(); + for (Station station : stations) { + groupId = station.getGroupId(); + ids.add(station.getId()); + } + CommonBigScreenReq req = new CommonBigScreenReq(); + req.setBeginTime(beginString); + req.setEndTime(endString); + req.setStationIds(ids); + req.setGroupId(groupId); + List stationElec = elecMeterValueService.getElec(beginString, endString, groupId,DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE,ids); + Map> elecMap = stationElec.stream().collect(Collectors.groupingBy(s -> s.getStationId() + "," + s.getDay())); + //创建返回对象 + List subdataList = new ArrayList<>(); + elecMap.forEach((k, v) -> { + Subdata subdata = new Subdata(); + // 收益 + BigDecimal result = v.stream().map(DayProfitType::getDigital).reduce(BigDecimal.ZERO,BigDecimal::add); + String[] split = k.split(","); + Integer stationId = Integer.parseInt(split[0]); + if (stationMap.containsKey(stationId)) { + Station station = stationMap.get(stationId); + subdata.setStationId(stationId); + subdata.setStationName(split[1] + station.getName()); + subdata.setRelease(result); + subdataList.add(subdata); + } + }); + subdataList.sort(Comparator.comparing((Subdata::getIncomeValue)).reversed()); + return subdataList; + + } + + private List getPvSubdataByDay(String beginString, String endString, List stations){ + Map stationMap = stations.stream().collect(Collectors.toMap(Station::getId, Function.identity())); + Integer groupId = null; + List ids = new ArrayList<>(); + for (Station station : stations) { + groupId = station.getGroupId(); + ids.add(station.getId()); + } + CommonBigScreenReq req = new CommonBigScreenReq(); + req.setBeginTime(beginString); + req.setEndTime(endString); + req.setStationIds(ids); + req.setGroupId(groupId); + List stationProfit = earningsCalculateMpptService.getEarningsByParam(req); + Map> profitMap = stationProfit.stream().collect(Collectors.groupingBy(s -> s.getStationId() + "," + s.getDay())); + //创建返回对象 + List subdataList = new ArrayList<>(); + profitMap.forEach((k, v) -> { + Subdata subdata = new Subdata(); + // 收益 + BigDecimal result = v.stream().map(DayProfitType::getDigital).reduce(BigDecimal.ZERO,BigDecimal::add); + String[] split = k.split(","); + Integer stationId = Integer.parseInt(split[0]); + if (stationMap.containsKey(stationId)) { + Station station = stationMap.get(stationId); + subdata.setStationId(stationId); + subdata.setStationName(split[1] + station.getName()); + subdata.setIncomeValue(result); + subdataList.add(subdata); + } + }); + subdataList.sort(Comparator.comparing((Subdata::getIncomeValue)).reversed()); + return subdataList; + } private List getSubdataByDay(String beginString, String endString, List stations) { Map stationMap = stations.stream().collect(Collectors.toMap(Station::getId, Function.identity())); @@ -1031,6 +1231,36 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { return getAnnualChartValues(stations); } + private List getAnnualReleaseValues(List stations){ + Integer groupId = null; + for (Station station : stations) { + groupId = station.getGroupId(); + } + //时间(近30天) + Date date = DateUtil.yesterday(); + Date startDate = DateUtils.addDays(date, -maxSize); + Date endDate = DateUtil.endOfDay(date); + List dateTimes = DateUtil.rangeToList(startDate, endDate, DateField.DAY_OF_MONTH); + String beginTime = DateUtil.format(startDate, CommonConstant.DATE_YMD); + String endTime = DateUtil.format(endDate, CommonConstant.DATE_YMD); + List stationElec = elecMeterValueService.getElec(beginTime, endTime, groupId,DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE,null); + Map> elecMap = stationElec.stream().collect(Collectors.groupingBy(s -> s.getDay())); + List resultList = new ArrayList<>(); + for (DateTime dateTime:dateTimes){ + AnnualChartValue annualChartValue = new AnnualChartValue(); + BigDecimal release = BigDecimal.ZERO; + String time = DateUtil.format(dateTime, CommonConstant.DATE_YMD); + List elecList = elecMap.get(time); + if(elecList != null && elecList.size()>0){ + release = elecList.stream().map(DayProfitType::getDigital).reduce(BigDecimal.ZERO,BigDecimal::add); + } + annualChartValue.setTime(time); + annualChartValue.setRelease(release); + resultList.add(annualChartValue); + } + return resultList; + } + private List getAnnualChartValues(List stations) { //时间(近30天) Date date = DateUtil.yesterday(); @@ -1100,47 +1330,6 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { annualChartValue.setDayDischarge(totalDischarge); resultList.add(annualChartValue); } - /*********************************************************/ -// List annualChartList = new ArrayList<>(); -// annualChartList = dateTimes.stream().map(s -> { -// AnnualChartValue annualChartValue = new AnnualChartValue(); -// String dateString = s + ""; -// String substring = dateString.substring(0, 10); -// annualChartValue.setTime(substring); -// annualChartValue.setDayCharge(BigDecimal.ZERO); -// annualChartValue.setDayDischarge(BigDecimal.ZERO); -// return annualChartValue; -// }).collect(Collectors.toList()); -// for (AnnualChartValue annualChartValue : annualChartList) { -// String time = annualChartValue.getTime(); -// //年总充/年总放(日冻结表计算)或者总充/总放 -// BigDecimal yearCharge = BigDecimal.ZERO; -// BigDecimal yearDischarge = BigDecimal.ZERO; -// List byTimeList = getByTimeList(stations, time, time); -// List chargeList = new ArrayList<>(); -// byTimeList.stream().filter(i -> DeviceTypeConstant.ELEC_METER_VALUE_TYPE.CHARGE.equals(i.getType())).forEach(s -> chargeList.add(s)); -// List disList = new ArrayList<>(); -// byTimeList.stream().filter(i -> DeviceTypeConstant.ELEC_METER_VALUE_TYPE.DISCHARGE.equals(i.getType())).forEach(s -> disList.add(s)); -// for (ElecMeterValue elecMeterValue : chargeList) { -// if (FENGStationId == elecMeterValue.getStationId()) { -// yearCharge = yearCharge.add(elecMeterValue.getDigital().multiply(new BigDecimal("1000"))); -// } else { -// yearCharge = yearCharge.add(elecMeterValue.getDigital()); -// } -// -// } -// for (ElecMeterValue elecMeterValue : disList) { -// if (FENGStationId == elecMeterValue.getStationId()) { -// yearDischarge = yearDischarge.add(elecMeterValue.getDigital().multiply(new BigDecimal("1000"))); -// } else { -// yearDischarge = yearDischarge.add(elecMeterValue.getDigital()); -// } -// -// } -// -// annualChartValue.setDayCharge(yearCharge); -// annualChartValue.setDayDischarge(yearDischarge); -// } return resultList; } @@ -1266,6 +1455,34 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { return annualOverviewResp; } + @Override + public AnnualPvOverviewResp getPvOverviewData(List stationIds) { + if (stationIds == null) { + return new AnnualPvOverviewResp(); + } + List list = getCountPvStations(stationIds); + AnnualPvOverviewResp annualOverviewResp = getPvOverviewDatas(list); + return annualOverviewResp; + } + + @Override + public EnergySavingRespVo getPvEnergySaving(List stationIds) { + if (stationIds == null) { + return new EnergySavingRespVo(); + } + List list = getCountPvStations(stationIds); + return getPvEnergySavingRespVo(list); + } + + @Override + public List getPVCommonProfitCurve(CockpitReqVO vo, List stationIds) { + if (stationIds == null) { + return new ArrayList<>(); + } + List list = getCountPvStations(stationIds); + return getPvProfitCurve(vo, list); + } + @Override public List getCommonRegionList(List stationIds) { if (stationIds == null) { @@ -1288,6 +1505,29 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { return regionList; } + + @Override + public List getCommonPvRegionList(List stationIds) { + if (stationIds == null) { + return new ArrayList<>(); + } + List list = getCountPvStations(stationIds); + List regionList = new ArrayList<>(); + Map> nationMap = list.stream().filter(i -> i.getProvince() != null).collect(Collectors.groupingBy(Station::getNation)); + if (nationMap.size() > CommonConstant.ONE) { + regionList = getListSubdata(nationMap); + } else { + Map> provinceMap = list.stream().filter(i -> i.getCity() != null).collect(Collectors.groupingBy(Station::getProvince)); + if (provinceMap.size() > CommonConstant.ONE) { + regionList = getListSubdata(provinceMap); + } else { + Map> cityMap = list.stream().filter(i -> i.getDistrict() != null).collect(Collectors.groupingBy(Station::getCity)); + regionList = getListSubdata(cityMap); + } + } + return regionList; + } + private List getListSubdata(Map> map) { List regionList = new ArrayList<>(); Subdata subdata = null; @@ -1299,7 +1539,22 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { } return regionList; } + public List getPvProfitCurve(CockpitReqVO vo, List stations){ + List curveResult = new ArrayList<>(); + Integer groupId = null; + for (Station station : stations) { + groupId = station.getGroupId(); + } + if (CommonConstant.DAY.equals(vo.getType())) { + setDayPvCurveResult(curveResult, groupId, stations); + } else if (CommonConstant.YEAR.equals(vo.getType())) { + setYearPVCurveResult(curveResult, groupId, stations); + } else { + setMonthPvCurveResult(curveResult, groupId, stations); + } + return curveResult; + } public List getProfitCurve(CockpitReqVO vo, List stations) { List curveResult = new ArrayList<>(); Integer groupId = null; @@ -1343,6 +1598,59 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { return getAnnualChartValues(getCountStations(stationIds)); } + @Override + public List getCommonPvRelease(List stationIds){ + if (stationIds == null) { + return new ArrayList<>(); + } + return getAnnualReleaseValues(getCountPvStations(stationIds)); + } + + @Override + public List getPvCommonElec(String beginString, String endString,List stationIds){ + List subdata = new ArrayList<>(); + if (stationIds == null) { + return subdata; + } + List countStations = getCountPvStations(stationIds); + if (countStations != null && !countStations.isEmpty()) { + if (countStations.size() >= CommonConstant.FIVE) { + subdata = getPvElec(beginString,endString,countStations); + } else { + //电站数目小于5个 + Date date = DateUtil.yesterday(); + Date startDate = DateUtils.addDays(date, -CommonConstant.FIVE); + Date endDate = DateUtil.endOfDay(date); + beginString = DateUtil.format(startDate, CommonConstant.DATE_YMD); + endString = DateUtil.format(endDate, CommonConstant.DATE_YMD); + subdata = getPvElecByDay(beginString, endString, countStations); + } + } + return subdata; + } + + @Override + public List getPvCommonProfit(String beginString, String endString,List stationIds){ + List subdata = new ArrayList<>(); + if (stationIds == null) { + return subdata; + } + List countStations = getCountPvStations(stationIds); + if (countStations != null && !countStations.isEmpty()) { + if (countStations.size() >= CommonConstant.FIVE) { + subdata = getPvSubdata(beginString,endString,countStations); + } else { + //电站数目小于5个 + Date date = DateUtil.yesterday(); + Date startDate = DateUtils.addDays(date, -CommonConstant.FIVE); + Date endDate = DateUtil.endOfDay(date); + beginString = DateUtil.format(startDate, CommonConstant.DATE_YMD); + endString = DateUtil.format(endDate, CommonConstant.DATE_YMD); + subdata = getPvSubdataByDay(beginString, endString, countStations); + } + } + return subdata; + } @Override public List getCommonProfit(String beginString, String endString, List stationIds) { List subdata = new ArrayList<>(); @@ -1394,6 +1702,16 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { return subdata; } + private void setMonthPvCurveResult(List curveResult, Integer groupId, List stations) { + Date date = DateUtil.yesterday(); + Date startDate = DateUtil.beginOfYear(date); + Date endDate = DateUtil.endOfDay(date); + String begin = DateUtil.format(startDate, CommonConstant.DATE_YMD); + String end = DateUtil.format(endDate, CommonConstant.DATE_YMD); + List dateTime = DateUtil.rangeToList(startDate, endDate, DateField.MONTH); + setPvProfitByDayFormat(curveResult, groupId, dateTime, begin, end, CommonConstant.DATE_YM, stations); + } + private void setMonthCurveResult(List curveResult, Integer groupId, List stations) { Date date = DateUtil.yesterday(); Date startDate = DateUtil.beginOfYear(date); @@ -1404,6 +1722,19 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { setProfitByDayFormat(curveResult, groupId, dateTime, begin, end, CommonConstant.DATE_YM, stations); } + private void setYearPVCurveResult(List curveResult, Integer groupId, List stations) { + //查询数据的最小日期 + Date beginDate = earningsCalculateMpptService.getFirstTime(); + if(beginDate != null){ + Date date = DateUtil.yesterday(); + Date startDate = DateUtil.beginOfYear(beginDate); + Date endDate = DateUtil.endOfDay(date); + String begin = DateUtil.format(startDate, CommonConstant.DATE_YMD); + String end = DateUtil.format(endDate, CommonConstant.DATE_YMD); + List dateTime = DateUtil.rangeToList(startDate, endDate, DateField.YEAR); + setPvProfitByDayFormat(curveResult, groupId, dateTime, begin, end, CommonConstant.DATE_Y, stations); + } + } private void setYearCurveResult(List curveResult, Integer groupId, List stations) { //查询数据的最小日期 Date beginDate = earningsCalculateService.getFirstTime(); @@ -1417,6 +1748,16 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { setProfitByDayFormat(curveResult, groupId, dateTime, begin, end, CommonConstant.DATE_Y, stations); } } + private void setDayPvCurveResult(List curveResult, Integer groupId, List stations) { + //开始结束时间为30天 + Date date = DateUtil.yesterday(); + Date startDate = DateUtils.addDays(date, -maxSize); + Date endDate = DateUtil.endOfDay(date); + String begin = DateUtil.format(startDate, CommonConstant.DATE_YMD); + String end = DateUtil.format(endDate, CommonConstant.DATE_YMD); + List dateTime = DateUtil.rangeToList(startDate, endDate, DateField.DAY_OF_MONTH); + setPvProfitByDayFormat(curveResult, groupId, dateTime, begin, end, CommonConstant.DATE_YMD, stations); + } private void setDayCurveResult(List curveResult, Integer groupId, List stations) { //开始结束时间为30天 @@ -1429,6 +1770,37 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { setProfitByDayFormat(curveResult, groupId, dateTime, begin, end, CommonConstant.DATE_YMD, stations); } + private void setPvProfitByDayFormat(List curveResult, Integer groupId, List dateTimes, String begin, String end, String type, List stations) { + Map> stationMap = stations.stream().collect(Collectors.groupingBy(Station::getId)); + //查询收益 + List dayProfit = earningsCalculateMpptService.getProfit(begin, end, groupId); + //在使用之前将不要的电站过滤 + List profitList = new ArrayList<>(); + for (DayProfitType dayProfitType : dayProfit) { + if (stationMap.containsKey(dayProfitType.getStationId())) { + profitList.add(dayProfitType); + } + } + Map> dayMap = profitList.stream().collect(Collectors.groupingBy(DayProfitType::getDay)); + for (DateTime dateTime : dateTimes) { + AnnualChartValue annualChartValue = new AnnualChartValue(); + String day = DateUtil.format(dateTime, type); + List dayProfitTypes = new ArrayList<>(); + Set dayList = dayMap.keySet(); + for (String key : dayList) { + if (key.contains(day)) { + dayProfitTypes.addAll(dayMap.get(key)); + } + } + //收益 + BigDecimal profit = dayProfitTypes.stream().map(DayProfitType::getDigital).reduce(BigDecimal.ZERO,BigDecimal::add); +// BigDecimal result = profit.divide(new BigDecimal("10000")); + annualChartValue.setProfit(profit); + annualChartValue.setTime(day); + curveResult.add(annualChartValue); + } + } + private void setProfitByDayFormat(List curveResult, Integer groupId, List dateTimes, String begin, String end, String type, List stations) { //直接查询需要的电站 // List list = stationService.selectAll(); @@ -1675,6 +2047,13 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService { return oneList; } + public List getCountPvStations(List stationIds) { + List list = stationService.selectStationsByIds(stationIds); + List oneList = list.stream().filter(i -> CommonConstant.ONE.equals(i.getStatus()) && CommonConstant.ONE.equals(i.getInverterFlag())).collect(Collectors.toList()); + return oneList; + } + + @Override public List getCommonCapacity(List stationIds) { List subDataList = new ArrayList<>(); diff --git a/business-service-dao/src/main/java/com/ho/business/service/impl/OpenStationServiceImpl.java b/business-service-dao/src/main/java/com/ho/business/service/impl/OpenStationServiceImpl.java index 1554261..ae7c3cf 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/impl/OpenStationServiceImpl.java +++ b/business-service-dao/src/main/java/com/ho/business/service/impl/OpenStationServiceImpl.java @@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; import com.alibaba.fastjson.JSON; import com.github.pagehelper.PageInfo; import com.ho.business.constant.DeviceTypeConstant; @@ -22,6 +23,8 @@ import com.ho.business.vo.resp.DeviceRespVO; import com.ho.business.vo.resp.VirtualDeviceColResp; import com.ho.business.vo.resp.cabin.CircleCtrlResp; import com.ho.business.vo.resp.colCount.ColCountResp; +import com.ho.business.vo.resp.mppt.MpptActiveVo; +import com.ho.business.vo.resp.mppt.MpptVo; import com.ho.business.vo.resp.openStationHome.OpenStationMiddleOrig; import com.ho.business.vo.resp.pcsStation.*; import com.ho.business.vo.resp.station.ActiveReactivePower; @@ -132,6 +135,43 @@ public class OpenStationServiceImpl implements OpenStationService { } return acList; } + public MpptActiveVo getPvActivePower(Integer stationId){ + DeviceReqVO deviceReqVO = new DeviceReqVO(); + deviceReqVO.setStationId(stationId); + List pcsList = deviceService.getListByDeviceType(stationId, DeviceTypeConstant.MPPT); + if(pcsList.isEmpty()){ + pcsList = deviceService.getListByFuzzyDeviceType(stationId, DeviceTypeConstant.MPPT); + } + MpptActiveVo mpptActiveVo =new MpptActiveVo(); + BigDecimal pvActivePower = new BigDecimal(CommonConstant.ZERO); + BigDecimal totalRelease = new BigDecimal(CommonConstant.ZERO); + BigDecimal dailyReleaseElec = new BigDecimal(CommonConstant.ZERO); + if (!pcsList.isEmpty()) { + for (DeviceRespVO deviceRespVO : pcsList) { + //在缓存里拿映射字段 + String key = deviceRespVO.getDeviceType() + ":" + stationId + ":" + deviceRespVO.getSrcId(); + if (redisService.hasKey(key)) { + Map mpptMap = redisService.hgetall(key); + if (mpptMap != null) { + MpptVo vo = JSON.parseObject(JSON.toJSONString(mpptMap), MpptVo.class); + if (vo != null) { + BigDecimal pvActivePowerMppt = vo.getPvActivePower() == null ? BigDecimal.ZERO : vo.getPvActivePower().getValue(); + BigDecimal totalReleaseMppt = vo.getTotalRelease() == null ? BigDecimal.ZERO : vo.getTotalRelease().getValue(); + BigDecimal pvDailyReleaseStart = vo.getPvDailyReleaseStart() == null ? BigDecimal.ZERO : vo.getPvDailyReleaseStart().getValue(); + BigDecimal dailyReleaseElecMppt = totalReleaseMppt.subtract(pvDailyReleaseStart); + pvActivePower.add(pvActivePowerMppt); + totalRelease.add(totalReleaseMppt); + dailyReleaseElec.add(dailyReleaseElecMppt); + } + } + } + } + } + mpptActiveVo.setPvActivePower(pvActivePower); + mpptActiveVo.setTotalRelease(totalRelease); + mpptActiveVo.setDailyReleaseElec(dailyReleaseElec); + return mpptActiveVo; + } @Override public ActiveReactivePower getAcPower(Integer stationId) { diff --git a/business-service-dao/src/main/java/com/ho/business/service/impl/OutApiServiceImpl.java b/business-service-dao/src/main/java/com/ho/business/service/impl/OutApiServiceImpl.java index 844a36e..08444b7 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/impl/OutApiServiceImpl.java +++ b/business-service-dao/src/main/java/com/ho/business/service/impl/OutApiServiceImpl.java @@ -174,29 +174,8 @@ public class OutApiServiceImpl implements OutApiService { stations.add(station); } } - - List groupIds = new ArrayList<>(); - Map> groupMap = new HashMap<>(); - groupIds = stations.stream().map(s -> { - return s.getGroupId(); - }).distinct().collect(Collectors.toList()); - if (EnvConstant.EXP.equals(env) || EnvConstant.DEV.equals(env)) { - //只增加集团为1的 - //groupIds = new ArrayList<>(); - //groupIds.add(1); - } - //groupMap = stations.stream().collect(Collectors.groupingBy(Station::getGroupId)); - log.info("dayChargeDeal groupMap:" + groupMap); - //todo 先用349来跑 - /* List stations = new ArrayList<>(); - Station s349 = stationService.selectById(monitorQuery.getStationId()); - stations.add(s349);*/ String deviceType = DeviceTypeConstant.BMS; log.info("stations.size:" + stations.size()); - //查询柴发冻结 - SysSubDictVO sysSubDictVO = new SysSubDictVO(); - sysSubDictVO.setType(CommonConstant.CF_FROZEN); - Map cfMap = userFeignClient.getSysSubDict(sysSubDictVO); for (Station station : stations) { try { //先删除站的当日数据 @@ -259,15 +238,6 @@ public class OutApiServiceImpl implements OutApiService { //当日的零点时间 tdBaseTimeQuery.setBegin(beginOfDay); tdBaseTimeQuery.setEnd(endOfDay); -// if (station.getId() == 349) { -// deviceType = deviceRespVO.getDeviceType().split("_")[0]; -// if (!DeviceTypeConstant.BMS.equals(deviceType)) { -// //日充电量 -// dailyChargeElec = new BigDecimal(CommonConstant.ZERO); -// //日放电量 -// dailyDischargeElec = new BigDecimal(CommonConstant.ZERO); -// } -// } //查询模型表 DeviceTypeConfig deviceTypeConfig = deviceTypeConfigService.selectByDeviceType(deviceRespVO.getDeviceType(), deviceRespVO.getGroupId()); if (deviceTypeConfig == null) { @@ -324,16 +294,6 @@ public class OutApiServiceImpl implements OutApiService { elecMeterValueService.insert(elecMeterValues); log.info("dayChargeDeal elecMeterValueService.insert OK"); } - if(cfMap!=null && cfMap.size()>0){ - Integer stationId = station.getId(); - if(cfMap.get(String.valueOf(stationId))!=null){ - deviceRespVOS = deviceService.getListByDeviceType(station.getId(), DeviceTypeConstant.CF); - if (deviceRespVOS.isEmpty()) { - deviceRespVOS = deviceService.getListByFuzzyDeviceType(station.getId(), DeviceTypeConstant.CF); - } - cfInsert(beginOfDay, endOfDay, dataProcessReqVO, station, deviceRespVOS); - } - } } catch (Exception e) { e.printStackTrace(); } @@ -1274,7 +1234,110 @@ public class OutApiServiceImpl implements OutApiService { } } + @Override + public void dayPVMpptCharge(MonitorQuery monitorQuery){ + //根据参数计算 beginTime 这天的起止时间 + SimpleDateFormat sdfDay = new SimpleDateFormat(CommonConstant.DATE_YMD); + SimpleDateFormat sdfDateTime = new SimpleDateFormat(CommonConstant.DATE); + //转成Date格式 + String transDayStr = null; + //时间格式的交易日期 + Date transDay = null; + if (monitorQuery != null) { + if (monitorQuery.getBeginTime() != null) { + transDayStr = monitorQuery.getBeginTime(); + try { + transDay = sdfDay.parse(monitorQuery.getBeginTime()); + } catch (ParseException e) { + e.printStackTrace(); + } + } else { + DateTime yesterdayTime = DateUtil.yesterday(); + transDayStr = sdfDay.format(yesterdayTime); + transDay = yesterdayTime; + } + } else { + DateTime yesterdayTime = DateUtil.yesterday(); + transDayStr = sdfDay.format(yesterdayTime); + transDay = yesterdayTime; + } + log.info("dayChargeDeal transDay:" + transDay); + //昨天的开始时间,昨天的结束时间 + DateTime beginOfDay = DateUtil.beginOfDay(transDay); + DateTime endOfDay = DateUtil.endOfDay(transDay); + String beginTime = sdfDateTime.format(beginOfDay); + String endTime = sdfDateTime.format(endOfDay); + DataProcessReqVO dataProcessReqVO = new DataProcessReqVO(); + dataProcessReqVO.setStartDayTime(beginTime); + dataProcessReqVO.setEndDayTime(endTime); + //业务发生日期 + dataProcessReqVO.setDay(transDayStr); + List stations = stationService.selectAll(); + stations = stations.stream().filter(i->CommonConstant.ONE.equals(i.getInverterFlag())).collect(Collectors.toList()); + for (Station station :stations){ + //先删除站的当日数据 + List typeList = Arrays.asList( + DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE + ); + //使用elecMeterValue + elecMeterValueService.deleteByStationAndDay(station.getId(), transDayStr, typeList); + //光伏总发电量 + List deviceRespVOS = deviceService.getListByDeviceType(station.getId(), DeviceTypeConstant.MPPT); + if (deviceRespVOS.isEmpty()) { + deviceRespVOS = deviceService.getListByFuzzyDeviceType(station.getId(), DeviceTypeConstant.MPPT); + } + //判断是否存在电表设备 + if (deviceRespVOS.isEmpty()) { + continue; + } + log.info("deviceRespVOS.size():" + deviceRespVOS.size()); + for (DeviceRespVO deviceRespVO : deviceRespVOS) { + //创建远程调用的查询参数 + TdBaseTimeQuery tdBaseTimeQuery = new TdBaseTimeQuery(); + //由于mppt没有日发总电量,走计算 昨日最晚总发-昨日做早总发=昨日总发 + List totalRelease = modelDeviceService.getCompListByType("device", deviceRespVO.getDeviceType(), DataCollectConstant.PV_CHARGE_POINT.TOTAL_RELEASE); + Map colNameMap = new HashMap<>(); + if (!totalRelease.isEmpty()) { + colNameMap.put(deviceRespVO.getSrcId(), totalRelease.get(0).getDeviceCol()); + } + tdBaseTimeQuery.setBeginTime(beginTime); + tdBaseTimeQuery.setEndTime(endTime); + tdBaseTimeQuery.setSrcId(deviceRespVO.getSrcId()); + tdBaseTimeQuery.setMap(colNameMap); + tdBaseTimeQuery.setGroupId(deviceRespVO.getGroupId()); + tdBaseTimeQuery.setStationId(deviceRespVO.getStationId()); + tdBaseTimeQuery.setDeviceType(deviceRespVO.getDeviceType()); + //当日的零点时间 + tdBaseTimeQuery.setBegin(beginOfDay); + tdBaseTimeQuery.setEnd(endOfDay); + //查询模型表 + DeviceTypeConfig deviceTypeConfig = deviceTypeConfigService.selectByDeviceType(deviceRespVO.getDeviceType(), deviceRespVO.getGroupId()); + if (deviceTypeConfig == null) { + log.info("电站{}未匹配到模型{}", deviceRespVO.getStationId(), deviceRespVO.getDeviceType()); + continue; + } + tdBaseTimeQuery.setModelName(deviceTypeConfig.getModelName()); + //远程调用查询 + log.info("查设备数据: start :" + new Date()); + DataResult result = tdFeignClient.getToDayPVMpptCharge(tdBaseTimeQuery); + log.info("dayChargeDeal tdFeignClient.getTodayPowerGeneration, result: {}", result); + StationHomeRespVo data = result.getData(); + ElecMeterValue elecMeterValue = new ElecMeterValue(); + elecMeterValue.setDigital(data.getDigital()); + elecMeterValue.setSrcId(deviceRespVO.getSrcId()); + elecMeterValue.setDeptId(station.getDeptId()); + elecMeterValue.setStationId(station.getId()); + elecMeterValue.setGroupId(station.getGroupId()); + elecMeterValue.setDay(dataProcessReqVO.getDay()); + elecMeterValue.setCreateTime(new Date()); + elecMeterValue.setType(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE); + elecMeterValue.setStatus(CommonConstant.STATUS_FLAG); + elecMeterValueService.insert(elecMeterValue); + log.info("dayChargeDeal elecMeterValueService.insert OK"); + } + } + } //加工昨天光伏充放电量 @Override public void dayPVCharge(MonitorQuery monitorQuery) { diff --git a/business-service-dao/src/main/java/com/ho/business/service/impl/StationHomeServiceImpl.java b/business-service-dao/src/main/java/com/ho/business/service/impl/StationHomeServiceImpl.java index b2ec14a..9086857 100644 --- a/business-service-dao/src/main/java/com/ho/business/service/impl/StationHomeServiceImpl.java +++ b/business-service-dao/src/main/java/com/ho/business/service/impl/StationHomeServiceImpl.java @@ -15,16 +15,19 @@ import com.ho.business.service.*; import com.ho.business.vo.DeviceTransfer; import com.ho.business.vo.req.DeviceReqVO; import com.ho.business.vo.req.MonitorQuery; +import com.ho.business.vo.req.PvEnegyValueReqVO; import com.ho.business.vo.req.StationReq; import com.ho.business.vo.req.colCount.ColCountReq; import com.ho.business.vo.req.device.DeviceTypeQuery; import com.ho.business.vo.req.dynamicConfig.DynamicConfigQuery; import com.ho.business.vo.req.pcsStation.PcsStationReq; import com.ho.business.vo.resp.*; +import com.ho.business.vo.resp.InverterResp.PowerGenerateRespVO; import com.ho.business.vo.resp.cabin.TemperatureHumidityResp; import com.ho.business.vo.resp.cabin.TemperatureValue; import com.ho.business.vo.resp.colCount.ColCountResp; import com.ho.business.vo.resp.dynamicConfig.CurveConfigResp; +import com.ho.business.vo.resp.mppt.MpptActiveVo; import com.ho.business.vo.resp.pcsStation.OutStationData; import com.ho.business.vo.resp.pcsStation.PcsElecData; import com.ho.business.vo.resp.pcsStation.PcsStationData; @@ -128,6 +131,9 @@ public class StationHomeServiceImpl implements StationHomeService { @Autowired ThreadPoolTaskExecutor threadPoolExecutor; + @Autowired + EarningsCalculateMpptService earningsCalculateMpptService; + private List list; @Override @@ -662,24 +668,7 @@ public class StationHomeServiceImpl implements StationHomeService { //计算系统转化效率 BigDecimal systemEfficiency = BigDecimal.ZERO; -// List deviceRespVOList = deviceService.getListByDeviceType(stationId, DeviceTypeConstant.OUTSIDE_ELE); -// if (!deviceRespVOList.isEmpty()) { -// DeviceRespVO deviceRespVO = deviceRespVOList.get(0); -// //拼接rediskey -// String redisKey = deviceRespVO.getDeviceType() + ":" + stationId + ":" + deviceRespVO.getSrcId(); -// if (redisService.hasKey(redisKey)) { -// Map map = redisService.hgetall(redisKey); -// DeviceTransfer charge = (DeviceTransfer) map.get(DeviceTypeConstant.TOTAL_CHARGE); -// DeviceTransfer discharge = (DeviceTransfer) map.get(DeviceTypeConstant.TOTAL_DISCHARGE); -// -// BigDecimal totalCharge = charge != null ? charge.getValue() : BigDecimal.ZERO; -// BigDecimal totalDisCharge = discharge != null ? discharge.getValue() : BigDecimal.ZERO; -// -// if (!totalCharge.equals(BigDecimal.ZERO)) { -// systemEfficiency = totalDisCharge.divide(totalCharge, 4, BigDecimal.ROUND_HALF_UP); -// } -// } -// } + //获取 日充日放 总充总放 CountEleData countEleData = getCountEleData(req); //总充电量 BigDecimal totalChargeElec = countEleData.getTotalChargeElec(); @@ -689,98 +678,7 @@ public class StationHomeServiceImpl implements StationHomeService { BigDecimal dailyChargeElec = countEleData.getDailyChargeElec(); //日放电量 BigDecimal dailyDischargeElec = countEleData.getDailyDischargeElec(); -// //总充电量 -// BigDecimal totalChargeElec = BigDecimal.ZERO; -// //总放电量 -// BigDecimal totalDischargeElec = BigDecimal.ZERO; -// //日充电量 来自于PCS -// BigDecimal dailyChargeElec = BigDecimal.ZERO; -// //日放电量 -// BigDecimal dailyDischargeElec = BigDecimal.ZERO; - //总充,总放默认来自于 BMS -// String deviceType = req.getDeviceType() == null ? DeviceTypeConstant.BMS : req.getDeviceType(); -// //日充电量开始 -// BigDecimal dailyChargeStartElec = BigDecimal.ZERO; -// //日放电量开始 -// BigDecimal dailyDischargeStartElec = BigDecimal.ZERO; -// boolean hasStart = false; -// //总充,总放来自于BMS ,日充, 日放也来自于BMS -// List deviceRespVOS = deviceService.getListByDeviceType(stationId, deviceType); -// if(deviceRespVOS.isEmpty()){ -// deviceRespVOS = deviceService.getListByFuzzyDeviceType(stationId, deviceType); -// } -// //从缓存中获取累计充电量与放电量 -// boolean flag = true; -// for (DeviceRespVO deviceRespVO : deviceRespVOS) { -// //拼接电表缓存key -// String redisKey = deviceRespVO.getDeviceType() + ":" + deviceRespVO.getStationId() + ":" + deviceRespVO.getSrcId(); -// //判断电表换是否存在 -// if (redisService.hasKey(redisKey)) { -// Map map = redisService.hgetall(redisKey); -// if (map != null) { -// //总充, 总放 -// Object objTotalCharge = map.get(DataCollectConstant.Elec_Meter.TOTAL_CHARGE); -// if (objTotalCharge instanceof DeviceTransfer) { -// DeviceTransfer totalCharge = (DeviceTransfer) map.get(DataCollectConstant.Elec_Meter.TOTAL_CHARGE); -// totalChargeElec = totalCharge.getValue() != null ? totalChargeElec.add(totalCharge.getValue()) : totalChargeElec; -// } -// Object objTotalDischarge = map.get(DataCollectConstant.Elec_Meter.TOTAL_DISCHARGE); -// if (objTotalDischarge instanceof DeviceTransfer) { -// DeviceTransfer totalDischarge = (DeviceTransfer) map.get(DataCollectConstant.Elec_Meter.TOTAL_DISCHARGE); -// totalDischargeElec = totalDischarge.getValue() != null ? totalDischargeElec.add(totalDischarge.getValue()) : totalDischargeElec; -// } -// //日充 -// DeviceTransfer dailyChargeObj = (DeviceTransfer) map.get(DataCollectConstant.PCS_POINT.dailyCharge); -// log.info("dailyChargeObj:{},stationId:{}", dailyChargeObj, stationId); -// if (null != dailyChargeObj) { -// DeviceTransfer dailyChargeTransfer = (DeviceTransfer) map.get(DataCollectConstant.PCS_POINT.dailyCharge); -// dailyChargeElec = dailyChargeTransfer.getValue() != null ? dailyChargeElec.add(dailyChargeTransfer.getValue()) : dailyChargeElec; -// flag = false; -// } -// //日放 -// Object dailyDischargeObj = map.get(DataCollectConstant.PCS_POINT.dailyDischarge); -// if (dailyDischargeObj instanceof DeviceTransfer) { -// DeviceTransfer dailyDischargeTransfer = (DeviceTransfer) map.get(DataCollectConstant.PCS_POINT.dailyDischarge); -// dailyDischargeElec = dailyDischargeTransfer.getValue() != null ? dailyDischargeElec.add(dailyDischargeTransfer.getValue()) : dailyDischargeElec; -// } -// //日充电量开始 -// DeviceTransfer dailyChargeStart = (DeviceTransfer) map.get(DataCollectConstant.PCS_POINT.DAILY_CHARGE_START); -// if(dailyChargeStart!=null){ -// Date updateTime = dailyChargeStart.getUpdateTime(); -// DateTime beginOfDay = DateUtil.beginOfDay(new Date()); -// if(updateTime.getTime()==beginOfDay.getTime()){ -// dailyChargeStartElec = dailyChargeStart.getValue() != null ? dailyChargeStartElec.add(dailyChargeStart.getValue()) : dailyChargeStartElec; -// hasStart = true; -// } -// } -// //日放电量开始 -// DeviceTransfer dailyDischargeStart = (DeviceTransfer) map.get(DataCollectConstant.PCS_POINT.DAILY_DISCHARGE_START); -// if(dailyDischargeStart!=null){ -// Date updateTime = dailyDischargeStart.getUpdateTime(); -// DateTime beginOfDay = DateUtil.beginOfDay(new Date()); -// if(updateTime.getTime()==beginOfDay.getTime()){ -// dailyDischargeStartElec = dailyDischargeStart.getValue() != null ? dailyDischargeStartElec.add(dailyDischargeStart.getValue()) : dailyDischargeStartElec; -// } -// } -// } -// } -// } -// //若查不到,走计算 -// if (flag) { -// if(hasStart){ -// dailyChargeElec = totalChargeElec.subtract(dailyChargeStartElec); -// dailyDischargeElec = totalDischargeElec.subtract(dailyDischargeStartElec); -// }else{ -// MonitorQuery monitorQuery = new MonitorQuery(); -// monitorQuery.setStationId(stationId); -// monitorQuery.setEndTime(req.getEndTime()); -// JSONObject info = outApiService.getDayChargeDeal(monitorQuery, deviceType); -// DeviceTransfer dailyChargeTransfer = (DeviceTransfer) info.get(DataCollectConstant.PCS_POINT.dailyCharge); -// dailyChargeElec = dailyChargeTransfer.getValue(); -// DeviceTransfer dailyDischargeTransfer = (DeviceTransfer) info.get(DataCollectConstant.PCS_POINT.dailyDischarge); -// dailyDischargeElec = dailyDischargeTransfer.getValue(); -// } -// } + ColCountReq colCountReq = new ColCountReq(); colCountReq.setStationId(station.getId()); colCountReq.setCol(DataCollectConstant.Elec_Meter.TOTAL_CHARGE); @@ -854,6 +752,28 @@ public class StationHomeServiceImpl implements StationHomeService { data.setSystemEfficiency(systemEfficiency); //当前功率 ActiveReactivePower acPower = openStationService.getAcPower(stationId); + //2025-11-13 start 储能加入mppt模块开发 + //如果接入光伏mppt模块-则统计光伏模块监控数据 + if(DataCollectConstant.ONE.equals(station.getInverterFlag())){ + //当前功率(光伏)、总发电量、日发电量 + MpptActiveVo pv = openStationService.getPvActivePower(stationId); + data.setCurrentPower(pv.getPvActivePower()); + data.setDailyReleaseElec(pv.getDailyReleaseElec()); + //计算累计发电量 + BigDecimal totalReleaseElec = elecMeterValueService.selectSumValue(station.getId(),DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE,null); + data.setTotalReleaseElec(totalReleaseElec); + //今日收益 + String key = RedisKeyConstant.PV.STATION_PV_TODAY_PROFIT + station.getId(); + BigDecimal todayIncone = (BigDecimal)redisService.get(key); + data.setTodayIncone(todayIncone); + //累计收益 + BigDecimal totalIncome = earningsCalculateMpptService.countAllPvIncome(station.getId(),null,null); + data.setTotalIncome(totalIncome); + //额定功率(光伏) + data.setPvPower(station.getPvPower()); + } + + if (acPower != null) { data.setCurrentPower(acPower.getActivePowerPCS()); } @@ -1059,147 +979,61 @@ public class StationHomeServiceImpl implements StationHomeService { return list; } - - @Override - public List getPvChargeElec(PcsStationReq req) { - req.setDeviceType(DeviceTypeConstant.PLANCURVE); - DeviceTransfer countPvData = getCountPvData(req); - //创建返回值 - List list = new ArrayList<>(); - - //查询冻结值 - List types = new ArrayList<>(); - //光伏充 - types.add(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE); - - //根据传入类型判断 - //当前时间 + public List getPvData(PcsStationReq req) { + // 获取今日光伏收益 + String type = req.getType(); Date end = new Date(); String endTime = DateUtil.format(end, CommonConstant.DATE_YMD); - String type = req.getType(); - boolean isToday = true; - if (CommonConstant.HOUR.equals(type)) { - return list; - } else if (CommonConstant.DAY.equals(type)) { - //查询最近七天 - //七天前的时间 - DateTime begin = DateUtil.offsetDay(end, -6); - String beginTime = DateUtil.format(begin, CommonConstant.DATE_YMD); - List elecMeterValues = elecMeterValueService.selectList(req.getStationId(), types, beginTime, endTime); - elecMeterValues = getMeterValues(req, elecMeterValues); - //根据天获取时间段 - List dateTimes = DateUtil.rangeToList(begin, end, DateField.DAY_OF_MONTH); - setDataByTime(dateTimes, elecMeterValues, list); - //根据类型进行分组 -// Map> map = elecMeterValues.stream().collect(Collectors.groupingBy(ElecMeterValue::getType)); -// setDataByTime(dateTimes, map, list); - } else if (CommonConstant.RANGE_TIME.equals(type)) { - list = new ArrayList<>(); - //查询时间范围数据 - List typeHourList = new ArrayList<>(); - typeHourList.add(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.HOUR_CHARGE); - typeHourList.add(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.HOUR_DISCHARGE); - DateTime begin = new DateTime(DateUtils.addDays(new DateTime(req.getBeginTime()), -1)); - DateTime dateTime = new DateTime(req.getEndTime()); - String beginTime = DateUtil.format(begin, CommonConstant.DATE); - List elecMeterValues = elecMeterValueService.selectList(req.getStationId(), typeHourList, beginTime, req.getEndTime()); - Map> map = elecMeterValues.stream().collect(Collectors.groupingBy(ElecMeterValue::getType)); - List days = DateUtil.rangeToList(begin, dateTime, DateField.DAY_OF_MONTH); - setRangeTime(days, map, list); - } else if (CommonConstant.MONTH.equals(type)) { - //七天前的时间 - DateTime begin = DateUtil.offsetDay(end, -29); - String beginTime = DateUtil.format(begin, CommonConstant.DATE_YMD); - List elecMeterValues = elecMeterValueService.selectList(req.getStationId(), types, beginTime, endTime); - elecMeterValues = getMeterValues(req, elecMeterValues); - //根据天获取时间段 - List dateTimes = DateUtil.rangeToList(begin, end, DateField.DAY_OF_MONTH); - setDataByTime(dateTimes, elecMeterValues, list); - //根据类型进行分组 -// Map> map = elecMeterValues.stream().collect(Collectors.groupingBy(ElecMeterValue::getType)); -// setDataByTime(dateTimes, map, list); - } else if (CommonConstant.YEAR.equals(type)) { - DateTime begin = DateUtil.offsetDay(end, -364); - String beginTime = DateUtil.format(begin, CommonConstant.DATE_YMD); - List elecMeterValues = elecMeterValueService.selectList(req.getStationId(), types, beginTime, endTime); - elecMeterValues = getMeterValues(req, elecMeterValues); - //根据类型进行分组 - Map> map = elecMeterValues.stream().collect(Collectors.groupingBy(ElecMeterValue::getType)); - //充电量 - List chargeList = map.get(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.CHARGE); - Map> monthChargeList = new HashMap<>(); - if (chargeList != null) { - monthChargeList = chargeList.stream().collect(Collectors.groupingBy(s -> { - String month = s.getDay().substring(0, 7); - return month; - })); - } - //放电量 - List dischargeList = map.get(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.DISCHARGE); - Map> monthDischargeList = new HashMap<>(); - if (dischargeList != null) { - monthDischargeList = dischargeList.stream().collect(Collectors.groupingBy(s -> { - String month = s.getDay().substring(0, 7); - return month; - })); - } - //根据天获取时间段 - List dateTimes = DateUtil.rangeToList(begin, end, DateField.MONTH); - for (DateTime dateTime : dateTimes) { - String yearMonth = DateUtil.format(dateTime, CommonConstant.DATE_YM); - PcsElecData pcsElecData = new PcsElecData(); - pcsElecData.setDate(yearMonth); - BigDecimal charge = BigDecimal.ZERO; - BigDecimal disCharge = BigDecimal.ZERO; - //按yyyy-MM分组 - //分别计算充电,放电 - if (monthChargeList.containsKey(yearMonth)) { - List elecMeterValues1 = monthChargeList.get(yearMonth); - for (ElecMeterValue elecMeterValue : elecMeterValues1) { - charge = charge.add(elecMeterValue.getDigital()); - } - pcsElecData.setChargeElec(charge); - } - if (monthDischargeList.containsKey(yearMonth)) { - List elecMeterValues1 = monthDischargeList.get(yearMonth); - - for (ElecMeterValue elecMeterValue : elecMeterValues1) { - disCharge = disCharge.add(elecMeterValue.getDigital()); - } - pcsElecData.setDischargeElec(disCharge); - } - - list.add(pcsElecData); - } - } - //根据时间排序 - list.stream(). - - sorted((s1, s2) -> - - { - return s1.getDate().compareTo(s2.getDate()); - }). - - collect(Collectors.toList()); - if (!isToday) { + List list = new ArrayList<>(); + DateTime begin; + if (CommonConstant.DAY.equals(type)){ + begin = DateUtil.offsetDay(end, -6); + }else if(CommonConstant.MONTH.equals(type)){ + begin = DateUtil.offsetDay(end, -29); + }else{ return list; } - //查询今天的数据,set到返回值中 - String nowDay = DateUtil.format(new Date(), CommonConstant.DATE_YMD); - String format = DateUtil.format(countPvData.getUpdateTime(), CommonConstant.DATE_YMD); - if (nowDay.equals(format)) { - for (PcsElecData pcsElecData : list) { - if (nowDay.equals(pcsElecData.getDate())) { - pcsElecData.setPvChargeElec(countPvData.getValue()); - } + String beginTime = DateUtil.format(begin, CommonConstant.DATE_YMD); + //光伏收益 + List pvIncome = earningsCalculateMpptService.countPvIncome(req.getStationId(),beginTime, endTime); + Map> mapIncome = pvIncome.stream().collect(Collectors.groupingBy(i ->i.getDate())); + //光伏放电 + List types = new ArrayList<>(); + types.add(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.PV_CHARGE); + List elecMeterValues = elecMeterValueService.selectList(req.getStationId(), types, beginTime, endTime); + Map> mapMeter = elecMeterValues.stream().collect(Collectors.groupingBy(i ->i.getDay())); + //根据天获取时间段 + List dateTimes = DateUtil.rangeToList(begin, end, DateField.DAY_OF_MONTH); + for (DateTime dateTime : dateTimes){ + String date = DateUtil.format(dateTime, CommonConstant.DATE_YMD); + PowerGenerateRespVO pv = new PowerGenerateRespVO(); + pv.setDate(date); + List pvIn = mapIncome.get(date); + //收益 + if(pvIn != null){ + pv.setProfit(pvIn.get(0).getProfit()); } - } + //放电 + List elecs = mapMeter.get(date); + if(elecs != null){ + pv.setPowerGenerate(elecs.stream().map(ElecMeterValue::getDigital).reduce(BigDecimal.ZERO,BigDecimal::add)); + } + if(date.equals(endTime)){ + String key = RedisKeyConstant.PV.STATION_PV_TODAY_PROFIT + req.getStationId(); + //获取今日收益 + BigDecimal todayIncone = (BigDecimal)redisService.get(key); + pv.setProfit(todayIncone); + //获取今日发电 + //当前功率(光伏)、总发电量、日发电量 + MpptActiveVo todayPv = openStationService.getPvActivePower(req.getStationId()); + pv.setPowerGenerate(todayPv.getDailyReleaseElec()); + } + list.add(pv); + } return list; } - /** * 慈溪电站特殊处理 * @@ -2004,7 +1838,12 @@ public class StationHomeServiceImpl implements StationHomeService { } return pcsCurveCurveList; } - + @Override + public List pvCurve(MonitorQuery monitorQuery) { + //mppt总发电量、有功功率 + List appRealTimeCurveRespVos = getAppRealTimeCurveRespVos(monitorQuery, "totalRelease", "pvActivePower"); + return appRealTimeCurveRespVos; + } @Override public List getOpticalStorageCurve(MonitorQuery monitorQuery) { //逆变有功功率、PV输出功率 diff --git a/business-service-dao/src/main/resources/mapper/EarningsCalculateMapper.xml b/business-service-dao/src/main/resources/mapper/EarningsCalculateMapper.xml index 80c721b..b3e5058 100644 --- a/business-service-dao/src/main/resources/mapper/EarningsCalculateMapper.xml +++ b/business-service-dao/src/main/resources/mapper/EarningsCalculateMapper.xml @@ -147,9 +147,9 @@ and date_format(#{date},'%Y-%m-%d') >= tem.validity_start_time and date_format(#{date},'%Y-%m-%d') <= tem.validity_end_time - - - + + and tem.elec_type = #{elecType} + order by begin_time diff --git a/business-service-dao/src/main/resources/mapper/EarningsCalculateMpptMapper.xml b/business-service-dao/src/main/resources/mapper/EarningsCalculateMpptMapper.xml new file mode 100644 index 0000000..64bf796 --- /dev/null +++ b/business-service-dao/src/main/resources/mapper/EarningsCalculateMpptMapper.xml @@ -0,0 +1,104 @@ + + + + + + + delete + from earnings_calculate_mppt + + and day = #{day} + + and type in + + #{item} + + + + + + + INSERT INTO earnings_calculate_mppt + (group_id, pid, station_id, src_id, dept_id, create_time, day, type, + digital,elec,rate_type,price,total,discount) + VALUES + + ( + #{item.groupId},#{item.pid},#{item.stationId},#{item.srcId},#{item.deptId}, now(), + #{item.day},#{item.type},#{item.digital},#{item.elec},#{item.rateType},#{item.price},#{item.total},#{item.discount} + ) + + + + + + + + + + + + + diff --git a/business-service-dao/src/main/resources/mapper/ElecMeterValueMapper.xml b/business-service-dao/src/main/resources/mapper/ElecMeterValueMapper.xml index d0744e3..8ed5b34 100644 --- a/business-service-dao/src/main/resources/mapper/ElecMeterValueMapper.xml +++ b/business-service-dao/src/main/resources/mapper/ElecMeterValueMapper.xml @@ -201,6 +201,31 @@ group by type,station_id,day + delete diff --git a/business-service-dao/src/main/resources/mapper/StationMapper.xml b/business-service-dao/src/main/resources/mapper/StationMapper.xml index bf89dff..311e583 100644 --- a/business-service-dao/src/main/resources/mapper/StationMapper.xml +++ b/business-service-dao/src/main/resources/mapper/StationMapper.xml @@ -12,7 +12,7 @@ latitude,capacity,rate_power, status,type,create_time, contact,contact_details,grid_time, - update_time,deleted,is_enable,cabin_num,district,ad_code,is_daily_count,topology_type,cupboard_type,plan_version,inverter_flag,icc_id,province,city, + update_time,deleted,is_enable,cabin_num,district,ad_code,is_daily_count,topology_type,cupboard_type,plan_version,inverter_flag,pv_power,icc_id,province,city, electricity_type,customer_type,voltage_level,batch_number,nation @@ -217,6 +217,7 @@ cupboard_type, plan_version, inverter_flag, + pv_power, icc_id, province, city, @@ -254,6 +255,7 @@ #{record.cupboardType}, #{record.planVersion}, #{record.inverterFlag}, + #{record.pvPower}, #{record.iccId}, #{record.province}, #{record.city}, @@ -343,6 +345,9 @@ inverter_flag = #{record.inverterFlag}, + + pv_power = #{record.pvPower,jdbcType=DECIMAL}, + icc_id = #{record.iccId}, diff --git a/business-service/src/main/java/com/ho/business/controller/CommonController.java b/business-service/src/main/java/com/ho/business/controller/CommonController.java index 69342fe..32b40c0 100644 --- a/business-service/src/main/java/com/ho/business/controller/CommonController.java +++ b/business-service/src/main/java/com/ho/business/controller/CommonController.java @@ -15,6 +15,7 @@ import com.ho.business.vo.resp.DeviceRespVO; import com.ho.business.vo.resp.EnvironmentalControlVo; import com.ho.business.vo.resp.cabin.TemperatureVoltageNewResp; import com.ho.business.vo.resp.point.ElecDataResp; +import com.ho.common.tools.annotation.TokenIgnore; import com.ho.common.tools.constant.CommonConstant; import com.ho.common.tools.constant.ContextConstant; import com.ho.common.tools.exception.BaseResponseCode; @@ -192,6 +193,10 @@ public class CommonController { retInfo.putAll(dd); } } + // mppt + if (deviceType != null && deviceType.contains(DeviceTypeConstant.MPPT)) { + retInfo = commonService.getRealInfo(device, cols); + } } //虚拟设备 else if (device.getVirtual() == 1) { diff --git a/business-service/src/main/java/com/ho/business/controller/EarningsCalculateController.java b/business-service/src/main/java/com/ho/business/controller/EarningsCalculateController.java index abd84a6..a34b6fa 100644 --- a/business-service/src/main/java/com/ho/business/controller/EarningsCalculateController.java +++ b/business-service/src/main/java/com/ho/business/controller/EarningsCalculateController.java @@ -8,11 +8,13 @@ import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.fill.FillConfig; import com.alibaba.excel.write.metadata.fill.FillWrapper; import com.ho.business.entity.*; +import com.ho.business.service.EarningsCalculateMpptService; import com.ho.business.service.EarningsCalculateService; import com.ho.business.service.StationService; import com.ho.business.util.QueuesUtil; import com.ho.business.vo.OneKeyComputationVo; import com.ho.business.vo.req.carbin.EarningsCalculateReq; +import com.ho.business.vo.resp.InverterResp.PowerGenerateRespVO; import com.ho.business.vo.resp.cabin.EarningsCalculateResp; import com.ho.common.tools.annotation.HzPermission; import com.ho.common.tools.annotation.TokenIgnore; @@ -24,6 +26,7 @@ import com.ho.common.tools.exception.BaseResponseCode; import com.ho.common.tools.exception.BusinessException; import com.ho.common.tools.exception.DataResult; import com.ho.common.tools.service.RedisService; +import com.ho.common.tools.util.BigDecimalUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -60,9 +63,15 @@ public class EarningsCalculateController { @Autowired EarningsCalculateService earningsCalculateService; + @Autowired + EarningsCalculateMpptService earningsCalculateMpptService; + @Autowired private StationService stationService; + @Autowired + BigDecimalUtil bigDecimalUtil; + @PostMapping("/getTotal") @ApiOperation(value = "获取月发电量报表") @TokenIgnore @@ -87,6 +96,17 @@ public class EarningsCalculateController { return DataResult.success(total); } + @PostMapping("/getPvMonthData") + @ApiOperation(value = "mppt月发电、收益(使用mppt计算)") + public DataResult> getPvMonthData(@RequestBody EarningsCalculateReq req) { + //获取光伏放电、收益 + List pvList = earningsCalculateService.getPvMonthData(req); + for (PowerGenerateRespVO pcsElecData : pvList) { + bigDecimalUtil.keepTwoDecimalPlaces(pcsElecData); + bigDecimalUtil.ifIsNUll(pcsElecData); + } + return DataResult.success(pvList); + } @TokenIgnore @PostMapping("/all") @ApiOperation(value = "查询所有电站接口") @@ -114,6 +134,49 @@ public class EarningsCalculateController { earningsCalculateService.queryDeviceByStationId(stations,null,beginTime); } + @TokenIgnore + @PostMapping("/allMpptIncome") + @ApiOperation(value = "计算所有电站Mppt电价收益") + public void allMpptIncome(@RequestBody(required = false) String beginTime) { + try { + /* + * 定时任务 如果没有时间参数 就每天跑昨日数据 + * 如果有 beginTime 参数不为空,则先清除beginTime 时间的收益数据重新计算 + */ + DateTime yesterday = DateUtil.yesterday(); + String yesterdayStr = DateUtil.formatDate(yesterday); + if ( beginTime != null ) { + int i = earningsCalculateMpptService.deleteByDay(beginTime, null); + } else { + beginTime = yesterdayStr; + int i = earningsCalculateMpptService.deleteByDay(yesterdayStr, null); + } + } catch (Exception e) { + log.error("删除昨日数据失败:{}",e.getMessage()); + } + List stations = stationService.selectAll(); + //批量算的时候只计算电站是在投的,且是接入光伏mppt的 + stations = stations.stream().filter(i -> CommonConstant.ONE.equals(i.getStatus()) + &&CommonConstant.ONE.equals(i.getInverterFlag())).collect(Collectors.toList()); + earningsCalculateMpptService.allMpptIncome(stations,beginTime); + } + @TokenIgnore + @PostMapping("/allTodayMpptIncome") + @ApiOperation(value = "计算所有电站Mppt-今日收益") + public void allTodayMpptIncome(@RequestBody(required = false) String beginTime) { + DateTime nowDay = DateUtil.date(); + String nowDayStr = DateUtil.formatDate(nowDay); + if ( beginTime == null ) { + beginTime = nowDayStr; + } + List stations = stationService.selectAll(); + //批量算的时候只计算电站是在投的,且是接入光伏mppt的 + stations = stations.stream().filter(i -> CommonConstant.ONE.equals(i.getStatus()) + &&CommonConstant.ONE.equals(i.getInverterFlag())).collect(Collectors.toList()); + earningsCalculateMpptService.todayMpptIncome(stations,beginTime); + } + + private List getBetweenDate(String begin,String end){ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); List betweenList = new ArrayList(); diff --git a/business-service/src/main/java/com/ho/business/controller/IargeScreenShowController.java b/business-service/src/main/java/com/ho/business/controller/IargeScreenShowController.java index 9ea6127..a71dfb8 100644 --- a/business-service/src/main/java/com/ho/business/controller/IargeScreenShowController.java +++ b/business-service/src/main/java/com/ho/business/controller/IargeScreenShowController.java @@ -6,11 +6,7 @@ import com.ho.business.feignclient.UserFeignClient; import com.ho.business.service.IargeScreenShowService; import com.ho.business.service.StationService; import com.ho.business.vo.req.cockpit.CockpitReqVO; -import com.ho.business.vo.resp.DeviceRespVO; -import com.ho.business.vo.resp.iargeScreen.AnnualChartValue; -import com.ho.business.vo.resp.iargeScreen.AnnualOverviewResp; -import com.ho.business.vo.resp.iargeScreen.EnergySavingRespVo; -import com.ho.business.vo.resp.iargeScreen.Subdata; +import com.ho.business.vo.resp.iargeScreen.*; import com.ho.common.tools.annotation.CommonLargeScreenToken; import com.ho.common.tools.annotation.TokenIgnore; import com.ho.common.tools.constant.ContextConstant; @@ -419,5 +415,88 @@ public class IargeScreenShowController { return DataResult.success(regionList); } - /************************************************************************/ + /*********************************以下为中自-光伏大屏接口***************************************/ + + @PostMapping("getZhongZiPvDistribution") + @ApiOperation(value = "中自-光伏电站区域分布") + @TokenIgnore + public DataResult> getZhongZiPvDistribution(@RequestBody CockpitReqVO vo) { + List regionList = iargeScreenShowService.getCommonPvRegionList((getByDeptId(vo.getDeptId()))); + regionList.sort(Comparator.comparing((Subdata::getRegionValue)).reversed()); + return DataResult.success(regionList); + } + + @PostMapping("getZhongZiPvOverviewData") + @ApiOperation(value = "中自储能-光伏年度概览/年度收益概览接口返回") + @TokenIgnore + public DataResult getZhongZiPvOverviewData(@RequestBody CockpitReqVO vo) { + AnnualPvOverviewResp annualOverviewResp = iargeScreenShowService.getPvOverviewData(getByDeptId(vo.getDeptId())); + bigDecimalUtil.keepTwoDecimalPlaces(annualOverviewResp); + bigDecimalUtil.ifIsNUll(annualOverviewResp); + return DataResult.success(annualOverviewResp); + } + + @PostMapping("getZhongZiPvEnergySaving") + @ApiOperation(value = "中自-光伏节能减排") + @TokenIgnore + public DataResult getZhongZiPvEnergySaving(@RequestBody CockpitReqVO vo) { + EnergySavingRespVo energySaving = iargeScreenShowService.getPvEnergySaving(getByDeptId(vo.getDeptId())); + bigDecimalUtil.keepTwoDecimalPlaces(energySaving); + bigDecimalUtil.ifIsNUll(energySaving); + return DataResult.success(energySaving); + } + + @PostMapping("getZhongZiPvIncomeCurve") + @ApiOperation(value = "中自光伏收益曲线") + @TokenIgnore + public DataResult> getZhongZiPvIncomeCurve(@RequestBody CockpitReqVO vo) { + List list = iargeScreenShowService.getPVCommonProfitCurve(vo, getByDeptId(vo.getDeptId())); + for (AnnualChartValue annualChartValue : list) { + bigDecimalUtil.keepTwoDecimalPlaces(annualChartValue); + bigDecimalUtil.ifIsNUll(annualChartValue); + } + return DataResult.success(list); + } + + @PostMapping("getZhongZiPvIncomeList") + @ApiOperation(value = "中自-光伏电站收益排名") + @TokenIgnore + public DataResult> getZhongZiPvIncomeList(@RequestBody CockpitReqVO vo) { + List regionList = iargeScreenShowService.getPvCommonProfit(null,null,getByDeptId(vo.getDeptId())); + if (regionList.size() > maxSize) { + regionList = regionList.subList(0, maxSize); + } + for (Subdata subdata : regionList) { + bigDecimalUtil.keepTwoDecimalPlaces(subdata); + bigDecimalUtil.ifIsNUll(subdata); + } + return DataResult.success(regionList); + } + + @PostMapping("getZhongZiPvElecList") + @ApiOperation(value = "中自-光伏电站发电量排名") + @TokenIgnore + public DataResult> getZhongZiPvElecList(@RequestBody CockpitReqVO vo) { + List regionList = iargeScreenShowService.getPvCommonElec(null,null,getByDeptId(vo.getDeptId())); + if (regionList.size() > maxSize) { + regionList = regionList.subList(0, maxSize); + } + for (Subdata subdata : regionList) { + bigDecimalUtil.keepTwoDecimalPlaces(subdata); + bigDecimalUtil.ifIsNUll(subdata); + } + return DataResult.success(regionList); + } + + @PostMapping("getZhongZiPvRelease") + @ApiOperation(value = "中自pv日发电量") + @TokenIgnore + public DataResult> getZhongZiPvRelease(@RequestBody CockpitReqVO vo) { + List list = iargeScreenShowService.getCommonPvRelease(getByDeptId(vo.getDeptId())); + for (AnnualChartValue subdata : list) { + bigDecimalUtil.keepTwoDecimalPlaces(subdata); + bigDecimalUtil.ifIsNUll(subdata); + } + return DataResult.success(list); + } } diff --git a/business-service/src/main/java/com/ho/business/controller/OpenStationController.java b/business-service/src/main/java/com/ho/business/controller/OpenStationController.java index ae8a644..fca16df 100644 --- a/business-service/src/main/java/com/ho/business/controller/OpenStationController.java +++ b/business-service/src/main/java/com/ho/business/controller/OpenStationController.java @@ -10,6 +10,7 @@ import com.ho.business.vo.req.StationReq; import com.ho.business.vo.req.dynamicConfig.DynamicConfigQuery; import com.ho.business.vo.req.pcsStation.PcsStationReq; import com.ho.business.vo.resp.DeviceRespVO; +import com.ho.business.vo.resp.InverterResp.PowerGenerateRespVO; import com.ho.business.vo.resp.cabin.CircleCtrlResp; import com.ho.business.vo.resp.cabin.EarningsCalculateCountResp; import com.ho.business.vo.resp.openStationHome.OpenStationMiddle; @@ -274,19 +275,7 @@ public class OpenStationController { req.setDeviceType(deviceType); } List list = stationHomeService.getPcsElecData(req); - //获取光伏充电 - List pvList = stationHomeService.getPvChargeElec(req); - Map> dataMap = pvList.stream().collect(Collectors.groupingBy(PcsElecData::getDate)); - - for (PcsElecData pcsElecData : list) { - if (dataMap.containsKey(pcsElecData.getDate())) { - List pcsElecData1 = dataMap.get(pcsElecData.getDate()); - if (pcsElecData1.get(CommonConstant.ZERO).getPvChargeElec() != null) { - pcsElecData.setPvChargeElec(pcsElecData1.get(CommonConstant.ZERO).getPvChargeElec()); - } - } - } for (PcsElecData pcsElecData : list) { bigDecimalUtil.keepTwoDecimalPlaces(pcsElecData); bigDecimalUtil.ifIsNUll(pcsElecData); @@ -294,6 +283,20 @@ public class OpenStationController { return DataResult.success(list); } + @PostMapping("/getPvData") + @ApiOperation(value = "mppt放电、收益(使用mppt计算)") + public DataResult> getPvData(@RequestBody PcsStationReq req) throws ParseException { + //获取光伏放电、收益 + List pvList = stationHomeService.getPvData(req); + for (PowerGenerateRespVO pcsElecData : pvList) { + bigDecimalUtil.keepTwoDecimalPlaces(pcsElecData); + bigDecimalUtil.ifIsNUll(pcsElecData); + } + return DataResult.success(pvList); + } + + + /** * 导出累计充放电量数据 * diff --git a/business-service/src/main/java/com/ho/business/controller/OuterApiController.java b/business-service/src/main/java/com/ho/business/controller/OuterApiController.java index a29bfc8..318a32f 100644 --- a/business-service/src/main/java/com/ho/business/controller/OuterApiController.java +++ b/business-service/src/main/java/com/ho/business/controller/OuterApiController.java @@ -420,11 +420,11 @@ public class OuterApiController { public DataResult jobIntegratedCabinet(@RequestBody MonitorQuery monitorQuery) { log.info("jobIntegratedCabinet, {}", monitorQuery); outApiService.dayChargeDeal(monitorQuery); - outApiService.currentMonthYearDeal(monitorQuery); - outApiService.dayPVCharge(monitorQuery); +// outApiService.currentMonthYearDeal(monitorQuery); +// outApiService.dayPVCharge(monitorQuery); + outApiService.dayPVMpptCharge(monitorQuery); return DataResult.success(); } - //暴露接口加工一体柜 充电量放电量,当月充电量,放电量 @PostMapping("jobCabinet") @ApiOperation(value = "暴露接口加工一体柜 充电量放电量,当月充电量,放电量") diff --git a/business-service/src/main/java/com/ho/business/controller/PcsController.java b/business-service/src/main/java/com/ho/business/controller/PcsController.java index fdd5b86..965fcdc 100644 --- a/business-service/src/main/java/com/ho/business/controller/PcsController.java +++ b/business-service/src/main/java/com/ho/business/controller/PcsController.java @@ -8,6 +8,7 @@ import com.ho.business.vo.req.pcs.PcsUpdateReqVo; import com.ho.business.vo.resp.AppRealTimeCurveRespVo; import com.ho.business.vo.resp.pcs.PcsRunDataSetting; import com.ho.common.tools.annotation.LogAnnotation; +import com.ho.common.tools.annotation.TokenIgnore; import com.ho.common.tools.constant.ContextConstant; import com.ho.common.tools.constant.RedisKeyConstant; import com.ho.common.tools.entity.SimpleUser; @@ -77,6 +78,18 @@ public class PcsController { return DataResult.success(resList); } + @PostMapping("/pvCurve") + @ApiOperation(value = "mppt曲线") + public DataResult> pvCurve(@RequestBody MonitorQuery monitorQuery) { + List resList = stationHomeService.pvCurve(monitorQuery); + + //返回值的BigDecimal类型保留两位小数 + for (AppRealTimeCurveRespVo realTimeCurveRespVo : resList) { + bigDecimalUtil.keepTwoDecimalPlaces(realTimeCurveRespVo); + bigDecimalUtil.ifIsNUll(realTimeCurveRespVo); + } + return DataResult.success(resList); + } @PostMapping("/opticalStorageCurve") @ApiOperation(value = "光储逆变器曲线") diff --git a/data-collect-service-api/src/main/java/com/ho/datacollect/api/constant/DataCollectConstant.java b/data-collect-service-api/src/main/java/com/ho/datacollect/api/constant/DataCollectConstant.java index a00dcae..43901dc 100644 --- a/data-collect-service-api/src/main/java/com/ho/datacollect/api/constant/DataCollectConstant.java +++ b/data-collect-service-api/src/main/java/com/ho/datacollect/api/constant/DataCollectConstant.java @@ -215,6 +215,8 @@ public interface DataCollectConstant { interface PV_CHARGE_POINT { //光伏 String PV_DAILY_CHARGING_ENERGY = "pvDailyChargingEnergy"; + // Mppt 总发 + String TOTAL_RELEASE = "totalRelease"; } interface BMS_POINT { diff --git a/td-service/src/main/java/com/ho/td/controller/Device001ApiController.java b/td-service/src/main/java/com/ho/td/controller/Device001ApiController.java index 2b3dbf3..a44d320 100644 --- a/td-service/src/main/java/com/ho/td/controller/Device001ApiController.java +++ b/td-service/src/main/java/com/ho/td/controller/Device001ApiController.java @@ -318,163 +318,6 @@ public class Device001ApiController { @PostMapping("getTodayPowerGeneration") public DataResult getTodayPowerGeneration(@RequestBody TdBaseTimeQuery query) { return getDayPowerGeneration(query); - //创建返回对象 -// ElecPowerGeneration elecPowerGeneration = new ElecPowerGeneration(); -// try { -// //拼接后缀表名 -// String tableName = new StringBuilder().append(query.getGroupId()) -// .append(DataCollectConstant.TABLE_LINK).append(query.getStationId()) -// .append(DataCollectConstant.TABLE_LINK).append(query.getSrcId()) -// .toString(); -// Map colNameMap = query.getColNameMap(); -// String modelName = query.getModelName(); -// query.setIsError(false); -// if (DeviceTypeConstant.DEVICE_SIMPLE.equals(modelName)) { -// log.info("DEVICE_SIMPLE======"); -// if (colNameMap != null) { -// //查询充电量 -// String charge = colNameMap.get(DataCollectConstant.Elec_Meter.TOTAL_CHARGE); -// if (charge != null) { -// log.info("charge != null"); -// //开始充电量 -// long start = System.currentTimeMillis(); -// BigDecimal beginCharge = deviceSimpleMapper.queryOneByTime(tableName, charge, query.getBegin()); -// long end = System.currentTimeMillis(); -// log.info("used1:" + (end - start)); -// if (beginCharge == null) { -// beginCharge = BigDecimal.ZERO; -// } -//// cacheObj(query,DeviceTypeConstant.DAILY_CHARGE_START,beginCharge); -// //结束充电量 -// start = System.currentTimeMillis(); -// BigDecimal endCharge = deviceSimpleMapper.queryOneByTime(tableName, charge, query.getEnd()); -// end = System.currentTimeMillis(); -// log.info("used2:" + (end - start)); -// if (endCharge == null) { -// endCharge = BigDecimal.ZERO; -// } -// BigDecimal ele = endCharge.subtract(beginCharge); -// //处理异常值 -// ele = handleSimpleEle(query, ele, tableName, charge, beginCharge, endCharge); -// elecPowerGeneration.setTodayChargePowerGeneration(ele); -// if (!query.getIsError()) { -// cacheObj(query, DeviceTypeConstant.DAILY_CHARGE_START, beginCharge); -// } -// // elecPowerGeneration.setTodayChargePowerGeneration(endCharge.subtract(beginCharge)); -//// if(endCharge.compareTo(beginCharge)<0){ -//// elecPowerGeneration.setTodayChargePowerGeneration(new BigDecimal(CommonConstant.ZERO)); -//// } -// } -// //查询放电量 -// String disCharge = colNameMap.get(DataCollectConstant.Elec_Meter.TOTAL_DISCHARGE); -// if (disCharge != null) { -// log.info("disCharge != null"); -// //开始放电量 -// long start = System.currentTimeMillis(); -// BigDecimal beginDisCharge = deviceSimpleMapper.queryOneByTime(tableName, disCharge, query.getBegin()); -// long end = System.currentTimeMillis(); -// log.info("used1:" + (end - start)); -// if (beginDisCharge == null) { -// beginDisCharge = BigDecimal.ZERO; -// } -//// cacheObj(query,DeviceTypeConstant.DAILY_DISCHARGE_START, beginDisCharge); -// //结束放电量 -// start = System.currentTimeMillis(); -// BigDecimal endDisCharge = deviceSimpleMapper.queryOneByTime(tableName, disCharge, query.getEnd()); -// end = System.currentTimeMillis(); -// log.info("used2:" + (end - start)); -// if (endDisCharge == null) { -// endDisCharge = BigDecimal.ZERO; -// } -// //处理异常值 -// BigDecimal ele = endDisCharge.subtract(beginDisCharge); -// ele = handleSimpleEle(query, ele, tableName, disCharge, beginDisCharge, endDisCharge); -// elecPowerGeneration.setTodayDisChargePowerGeneration(ele); -// if (!query.getIsError()) { -// cacheObj(query, DeviceTypeConstant.DAILY_DISCHARGE_START, beginDisCharge); -// } -//// elecPowerGeneration.setTodayDisChargePowerGeneration(endDisCharge.subtract(beginDisCharge)); -//// if(endDisCharge.compareTo(beginDisCharge)<0){ -//// elecPowerGeneration.setTodayDisChargePowerGeneration(new BigDecimal(CommonConstant.ZERO)); -//// } -// } -// } -// } else { -// log.info("DEVICE_COMPLEX======"); -// if (colNameMap != null) { -// //查询充电量 -// String charge = colNameMap.get(DataCollectConstant.Elec_Meter.TOTAL_CHARGE); -// if (charge != null) { -// log.info("charge != null"); -// //开始充电量 -// long start = System.currentTimeMillis(); -// BigDecimal beginCharge = deviceComplexMapper.queryOneByTime(tableName, charge, query.getBegin()); -// long end = System.currentTimeMillis(); -// log.info("used1:" + (end - start)); -// if (beginCharge == null) { -// beginCharge = BigDecimal.ZERO; -// } -//// cacheObj(query,DeviceTypeConstant.DAILY_CHARGE_START, beginCharge); -// //结束充电量 -// start = System.currentTimeMillis(); -// BigDecimal endCharge = deviceComplexMapper.queryOneByTime(tableName, charge, query.getEnd()); -// end = System.currentTimeMillis(); -// log.info("used2:" + (end - start)); -// if (endCharge == null) { -// endCharge = BigDecimal.ZERO; -// } -// BigDecimal ele = endCharge.subtract(beginCharge); -// //处理异常值 -// ele = handleComplexEle(query, ele, tableName, charge, beginCharge, endCharge); -// elecPowerGeneration.setTodayChargePowerGeneration(ele); -// if (!query.getIsError()) { -// cacheObj(query, DeviceTypeConstant.DAILY_CHARGE_START, beginCharge); -// } -//// elecPowerGeneration.setTodayChargePowerGeneration(endCharge.subtract(beginCharge)); -//// if(endCharge.compareTo(beginCharge)<0){ -//// elecPowerGeneration.setTodayChargePowerGeneration(new BigDecimal(CommonConstant.ZERO)); -//// } -// } -// //查询放电量 -// String disCharge = colNameMap.get(DataCollectConstant.Elec_Meter.TOTAL_DISCHARGE); -// if (disCharge != null) { -// log.info("disCharge != null"); -// //开始放电量 -// long start = System.currentTimeMillis(); -// BigDecimal beginDisCharge = deviceComplexMapper.queryOneByTime(tableName, disCharge, query.getBegin()); -// long end = System.currentTimeMillis(); -// log.info("used1:" + (end - start)); -// if (beginDisCharge == null) { -// beginDisCharge = BigDecimal.ZERO; -// } -//// cacheObj(query,DeviceTypeConstant.DAILY_DISCHARGE_START, beginDisCharge); -// //结束放电量 -// start = System.currentTimeMillis(); -// BigDecimal endDisCharge = deviceComplexMapper.queryOneByTime(tableName, disCharge, query.getEnd()); -// end = System.currentTimeMillis(); -// log.info("used2:" + (end - start)); -// if (endDisCharge == null) { -// endDisCharge = BigDecimal.ZERO; -// } -// //处理异常值 -// BigDecimal ele = endDisCharge.subtract(beginDisCharge); -// ele = handleComplexEle(query, ele, tableName, disCharge, beginDisCharge, endDisCharge); -// elecPowerGeneration.setTodayDisChargePowerGeneration(ele); -// if (!query.getIsError()) { -// cacheObj(query, DeviceTypeConstant.DAILY_DISCHARGE_START, beginDisCharge); -// } -//// elecPowerGeneration.setTodayDisChargePowerGeneration(endDisCharge.subtract(beginDisCharge)); -//// if(endDisCharge.compareTo(beginDisCharge)<0){ -//// elecPowerGeneration.setTodayDisChargePowerGeneration(new BigDecimal(CommonConstant.ZERO)); -//// } -// } -// } -// } -// } catch (Exception e) { -// log.error("查询电表当日发电量数据失败e "); -// log.error(e.getMessage()); -// } -// return DataResult.success(elecPowerGeneration); } /** @@ -1598,6 +1441,46 @@ public class Device001ApiController { return DataResult.success(list); } + /** + * 冻结光伏-Mppt日发电量 + * @param query + * @return + */ + @PostMapping("getToDayPVMpptCharge") + public DataResult getToDayPVMpptCharge(@RequestBody TdBaseTimeQuery query){ + //拼接后缀表名 + Map colNameMap = query.getMap(); + String modelName = query.getModelName(); + StationHomeRespVo stationHomeRespVo = new StationHomeRespVo(); + if (colNameMap != null) { + //查询发电量 + String charge = colNameMap.get(query.getSrcId()); + if (charge != null) { + query.setBeginLong(query.getBegin().getTime()); + query.setEndLong(query.getEnd().getTime()); + query.setCol(charge); + String tableName = getTableName(query); + log.info("charge != null"); + //计算昨日发电量 + BigDecimal ele = getPvBigDecimal(query, tableName, modelName, charge, DeviceTypeConstant.PV_DAILY_CHARGE_START); + stationHomeRespVo.setDigital(ele); + // 缓存今日发电量起始值 + query.setBeginLong(DateUtil.beginOfDay(DateUtil.date()).getTime()); + query.setEndLong(DateUtil.endOfDay(DateUtil.date()).getTime()); + List stationHomeRespVos = null; + if (DeviceTypeConstant.DEVICE_SIMPLE.equals(modelName)) { + stationHomeRespVos = deviceSimpleMapper.selectAll(query, tableName); + } else if (DeviceTypeConstant.DEVICE_COMPLEX.equals(modelName)) { + stationHomeRespVos = deviceComplexMapper.selectAll(query, tableName); + } + if (stationHomeRespVos != null && stationHomeRespVos.size() > 0) { + BigDecimal startEle = stationHomeRespVos.get(0).getDigital(); + cacheObj(query, DeviceTypeConstant.PV_DAILY_CHARGE_START, startEle); + } + } + } + return DataResult.success(stationHomeRespVo); + } /** * 光伏累计充 */ @@ -1780,6 +1663,31 @@ public class Device001ApiController { return ele; } + @NotNull + private BigDecimal getPvBigDecimal(TdBaseTimeQuery query, String tableName, String modelName, String col, String dayCol) { + long start = System.currentTimeMillis(); + List stationHomeRespVos = null; + if (DeviceTypeConstant.DEVICE_SIMPLE.equals(modelName)) { + stationHomeRespVos = deviceSimpleMapper.selectAll(query, tableName); + } else if (DeviceTypeConstant.DEVICE_COMPLEX.equals(modelName)) { + stationHomeRespVos = deviceComplexMapper.selectAll(query, tableName); + } + BigDecimal ele = BigDecimal.ZERO; + if (stationHomeRespVos != null && stationHomeRespVos.size() > 0) { + int len = stationHomeRespVos.size(); + BigDecimal startEle = stationHomeRespVos.get(0).getDigital(); + BigDecimal endEle = stationHomeRespVos.get(len - 1).getDigital(); + ele = endEle.subtract(startEle); + //处理异常值 + ele = handleEle(ele, startEle, endEle, stationHomeRespVos); + } else { + log.info("getDayPowerGeneration get stationHomeRespVos is empty,col:{},tableName:{},time:{}", col, tableName, new Date()); + } + long end = System.currentTimeMillis(); + log.info("getBigDecimal used1:" + (end - start)); + return ele; + } + /** * 异常值处理 * diff --git a/xxl-job/src/main/java/com/ho/xxljob/JobHandler.java b/xxl-job/src/main/java/com/ho/xxljob/JobHandler.java index 97e8cde..2ac9a3d 100644 --- a/xxl-job/src/main/java/com/ho/xxljob/JobHandler.java +++ b/xxl-job/src/main/java/com/ho/xxljob/JobHandler.java @@ -161,6 +161,11 @@ public class JobHandler { return ReturnT.SUCCESS; } + /** + * 计算储能-收益(昨日) + * @param param + * @return + */ @XxlJob("jobEarningsCalculate") public ReturnT jobEarningsCalculate(String param) { XxlJobLogger.log("jobEarningsCalculate"); @@ -171,6 +176,36 @@ public class JobHandler { return ReturnT.SUCCESS; } + /** + * 计算光伏-Mppt收益(昨日) + * @param param + * @return + */ + @XxlJob("jobEarningsCalculateMppt") + public ReturnT jobEarningsCalculateMppt(String param) { + XxlJobLogger.log("jobEarningsCalculateMppt"); + log.info("jobEarningsCalculateMpptInsert start !"); + Date date = DateUtil.addDays(new Date(), -1); + businessFeignClient.jobEarningsCalculateMppt(DateUtil.formatDate(date)); + log.info("jobEarningsCalculateMpptInsert end !"); + return ReturnT.SUCCESS; + } + + /** + * 计算光伏-Mppt收益(当日) + * @param param + * @return + */ + @XxlJob("jobEarningsCalculateMpptToDay") + public ReturnT jobEarningsCalculateMpptToDay(String param) { + XxlJobLogger.log("jobEarningsCalculateMpptToDay"); + log.info("jobEarningsCalculateMpptToDayInsert start !"); + Date date = new Date(); + businessFeignClient.jobEarningsCalculateMpptToDay(DateUtil.formatDate(date)); + log.info("jobEarningsCalculateMpptToDayInsert end !"); + return ReturnT.SUCCESS; + } + /** * 计算收益(当日) * diff --git a/xxl-job/src/main/java/com/ho/xxljob/feignclient/BusinessFeignClient.java b/xxl-job/src/main/java/com/ho/xxljob/feignclient/BusinessFeignClient.java index aa28c5e..e2ea2f6 100644 --- a/xxl-job/src/main/java/com/ho/xxljob/feignclient/BusinessFeignClient.java +++ b/xxl-job/src/main/java/com/ho/xxljob/feignclient/BusinessFeignClient.java @@ -49,6 +49,12 @@ public interface BusinessFeignClient { @PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "earningsCalculate/all") void jobEarningsCalculate(@RequestBody String dateTime); + @PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "earningsCalculate/allMpptIncome") + void jobEarningsCalculateMppt(@RequestBody String dateTime); + + @PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "earningsCalculate/allTodayMpptIncome") + void jobEarningsCalculateMpptToDay(@RequestBody String dateTime); + @PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "earningsCalculate/freezeMonthTotalEle") void jobFreezeMonthTotalEle(); diff --git a/xxl-job/src/main/java/com/ho/xxljob/feignclient/BusinessFeignClientFallback.java b/xxl-job/src/main/java/com/ho/xxljob/feignclient/BusinessFeignClientFallback.java index e567da1..e57f520 100644 --- a/xxl-job/src/main/java/com/ho/xxljob/feignclient/BusinessFeignClientFallback.java +++ b/xxl-job/src/main/java/com/ho/xxljob/feignclient/BusinessFeignClientFallback.java @@ -75,6 +75,18 @@ public class BusinessFeignClientFallback implements BusinessFeignClient { throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL); } + @Override + public void jobEarningsCalculateMppt(String dateTime) { + log.error("BusinessFeignClient.jobEarningsCalculateMppt error!"); + throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL); + } + + @Override + public void jobEarningsCalculateMpptToDay(String dateTime) { + log.error("BusinessFeignClient.jobEarningsCalculateMpptToDay error!"); + throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL); + } + @Override public void jobFreezeMonthTotalEle() { log.error("BusinessFeignClient.jobFreezeMonthTotalEle error!");