Browse Source

#通讯中断统计增加站点权限

zhongwei
yang_shj 3 months ago
parent
commit
4ff5b95677
  1. 22
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/ComprehensiveElectricVo.java
  2. 79
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java
  3. 4
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/interruption/mapper/InterruptionMapper.java

22
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/ComprehensiveElectricVo.java

@ -1,5 +1,7 @@
package com.hnac.hzims.electric.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -14,52 +16,60 @@ public class ComprehensiveElectricVo {
private String month;
@ApiModelProperty(value = "本月电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double monthGenerate;
@ApiModelProperty(value = "去年同月")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lastMonthGenerate;
@ApiModelProperty(value = "月同比")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lastMonthGenerateRate;
@ApiModelProperty(value = "年发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double yearGenerate;
@ApiModelProperty(value = "去年同期")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lastYearGenerate;
@ApiModelProperty(value = "年同比")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lastYearGenerateRate;
@ApiModelProperty(value = "本月降雨")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double monthRain;
@ApiModelProperty(value = "去年同月")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lastMonthRain;
@ApiModelProperty(value = "月同比")
private Double lastMonthRainRate;
@ApiModelProperty(value = "年降雨量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double yearRain;
@ApiModelProperty(value = "去年同期")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lastYearRain;
@ApiModelProperty(value = "年同比")
private Double lastYearRainRate;
@ApiModelProperty(value = "本月等效小时")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double monthEquivalent;
@ApiModelProperty(value = "去年同月")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lastMonthEquivalent;
@ApiModelProperty(value = "年等效小时")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double yearEquivalent;
@ApiModelProperty(value = "去年同期")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lastYearEquivalent;
}

79
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java

@ -1,7 +1,6 @@
package com.hnac.hzims.electric.service.impl;
import cn.hutool.core.io.unit.DataUnit;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -32,6 +31,8 @@ import org.springblade.system.feign.ISysClient;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@ -134,14 +135,82 @@ public class ElectricReportServiceImpl implements IElectricReportService {
Date finish = calendar.getTime();
calendar.add(Calendar.YEAR,-1);
Date current = calendar.getTime();
// fixme 随机器模拟数据
Random random = new Random();
List<ComprehensiveElectricVo> electrics = new ArrayList<>();
while (current.compareTo(finish) < 0){
ComprehensiveElectricVo comprehensive = new ComprehensiveElectricVo();
comprehensive.setMonth(current.getMonth() + 1 + "月");
String currentMon = DateUtil.format(calendar.getTime(),"yyyy-MM");
String currentYear = DateUtil.format(calendar.getTime(),"yyyy");
calendar.add(Calendar.YEAR,-1);
String lastMon = DateUtil.format(calendar.getTime(),"yyyy-MM");
String lastYear = DateUtil.format(calendar.getTime(),"yyyy");
calendar.add(Calendar.YEAR,1);
// 电量
if(CollectionUtil.isNotEmpty(threes)){
comprehensive.setMonthGenerate(threes.stream().filter(o->o.getStrMonth().contains(currentMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
comprehensive.setLastMonthGenerate(threes.stream().filter(o->o.getStrMonth().contains(lastMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
if(comprehensive.getMonthGenerate() > 0 && comprehensive.getLastMonthGenerate() > 0){
comprehensive.setLastMonthGenerateRate(BigDecimal.valueOf(comprehensive.getMonthGenerate() / comprehensive.getLastMonthGenerate() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}else{
comprehensive.setLastMonthGenerateRate(0.0);
}
// 本月等效小时
if(comprehensive.getMonthGenerate() > 0){
comprehensive.setMonthEquivalent(BigDecimal.valueOf(comprehensive.getMonthGenerate() / installedCapacity).setScale(2, RoundingMode.HALF_UP).doubleValue());
}else{
comprehensive.setMonthEquivalent(0.0);
}
// 去年同月等效小时
if(comprehensive.getLastMonthGenerate() > 0){
comprehensive.setLastMonthEquivalent(BigDecimal.valueOf(comprehensive.getLastMonthGenerate() / installedCapacity).setScale(2, RoundingMode.HALF_UP).doubleValue());
}else{
comprehensive.setLastMonthEquivalent(0.0);
}
comprehensive.setYearGenerate(threes.stream().filter(o->o.getStrMonth().contains(currentYear)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
comprehensive.setLastYearGenerate(threes.stream().filter(o->o.getStrMonth().contains(lastYear)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
if(comprehensive.getYearGenerate() > 0 && comprehensive.getLastYearGenerate() > 0){
comprehensive.setLastYearGenerateRate(BigDecimal.valueOf(comprehensive.getYearGenerate() / comprehensive.getLastYearGenerate() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
if(CollectionUtil.isEmpty(electrics)){
// 本年等效小时
comprehensive.setYearEquivalent(comprehensive.getMonthEquivalent());
// 去年同期等效小时
comprehensive.setLastYearEquivalent(comprehensive.getLastMonthEquivalent());
}else{
// 累计等效小时
comprehensive.setYearEquivalent(electrics.stream().mapToDouble(ComprehensiveElectricVo::getMonthEquivalent).sum() + comprehensive.getMonthEquivalent());
comprehensive.setLastYearEquivalent(electrics.stream().mapToDouble(ComprehensiveElectricVo::getLastMonthEquivalent).sum() + comprehensive.getLastMonthEquivalent());
}
}else{
comprehensive.setMonthGenerate(0.0);
comprehensive.setLastMonthGenerate(0.0);
comprehensive.setYearGenerate(0.0);
comprehensive.setLastYearGenerate(0.0);
comprehensive.setLastMonthGenerateRate(0.0);
comprehensive.setLastYearGenerateRate(0.0);
comprehensive.setMonthEquivalent(0.0);
comprehensive.setLastMonthEquivalent(0.0);
comprehensive.setYearEquivalent(0.0);
comprehensive.setLastYearEquivalent(0.0);
}
// 降雨 : fixme 模拟降雨
comprehensive.setMonthRain(BigDecimal.valueOf(random.nextDouble() * 10 * 8).setScale(2, RoundingMode.HALF_UP).doubleValue());
comprehensive.setLastMonthRain(BigDecimal.valueOf(random.nextDouble() * 10 * 8).setScale(2, RoundingMode.HALF_UP).doubleValue());
if(CollectionUtil.isEmpty(electrics)){
comprehensive.setYearRain(comprehensive.getMonthRain());
comprehensive.setLastYearRain(comprehensive.getLastMonthRain());
}else{
// 累计降雨
comprehensive.setYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getMonthRain).sum() + comprehensive.getMonthRain());
comprehensive.setLastYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getLastMonthRain).sum() + comprehensive.getLastMonthRain());
}
electrics.add(comprehensive);
calendar.add(Calendar.MONTH,1);
current = calendar.getTime();
}
return null;
return electrics;
}

4
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/interruption/mapper/InterruptionMapper.java

@ -1,15 +1,15 @@
package com.hnac.hzims.business.interruption.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.business.interruption.entity.InterruptionEntity;
import com.hnac.hzims.business.interruption.vo.InterruptionStationVo;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.util.List;
/**
* @author ysj
*/
public interface InterruptionMapper extends BaseMapper<InterruptionEntity> {
public interface InterruptionMapper extends UserDataScopeBaseMapper<InterruptionEntity> {
List<InterruptionStationVo> interruptionStations();
}

Loading…
Cancel
Save