xuhy
2025-06-09 f18b35727a11a5f8b5e326f6045f49b571954ba3
Merge remote-tracking branch 'origin/dev' into dev
19个文件已修改
573 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/model/UploadRealTimeMonitoringData.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TScreenContent.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/util/TCECCJianGuanontroller.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/LargeScreenController.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/LargeChargingPowerVo.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TScreenContentMapper.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TScreenContentService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java 121 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EnergyRefreshService.java 286 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/EmissionReductionVO.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/EnergyStorageDischargeVO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicAndConsumptionVO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ScreenStorageConfigVO.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ScreenTopVO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TScreenContentMapper.xml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/model/UploadRealTimeMonitoringData.java
@@ -17,7 +17,7 @@
@Data
@Document(collection = "upload_real_time_monitoring_data") //指定要对应的文档名(表名)
@Accessors(chain = true)
public class UploadRealTimeMonitoringData extends BaseModel {
public class UploadRealTimeMonitoringData  {
    @Id
    private String id;
    private String transaction_serial_number; // 交易流水号
@@ -63,6 +63,9 @@
    @ApiModelProperty(value = "删除按钮权限 ")
    private Boolean authDelete = true;
    private Date create_time=new Date();
    private Date last_time = new Date();
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TScreenContent.java
@@ -30,15 +30,15 @@
    @TableField("green_electricity_today")
    @ApiModelProperty("今日绿电消纳值")
    private BigDecimal greenElectricityToday;
    private BigDecimal greenElectricityToday=BigDecimal.ZERO;
    @TableField("car_discharge")
    @ApiModelProperty("累计汽车放电量")
    private BigDecimal carDischarge;
    private BigDecimal carDischarge=BigDecimal.ZERO;
    @TableField("green_electricity")
    @ApiModelProperty("累计绿电消纳电量")
    private BigDecimal greenElectricity;
    private BigDecimal greenElectricity=BigDecimal.ZERO;
    @TableField("title")
    @ApiModelProperty("标题")
@@ -83,15 +83,15 @@
    @TableField("statistical_deadline")
    @ApiModelProperty("截止统计日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime statisticalDeadline;
    private Date statisticalDeadline;
    @TableField("create_time")
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    private Date createTime;
    @TableField("update_time")
    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    private Date updateTime;
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java
@@ -359,7 +359,7 @@
    @GetMapping("/getLargeScreenGun")
    public R<LargeScreenGunVo> getLargeScreenGun(){
        LargeScreenGunVo largeScreenGunVo = new LargeScreenGunVo();
        List<TChargingGun> tChargingGuns = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getDelFlag, 0).in(TChargingGun::getSiteId,25,26).in(TChargingGun::getChargeMode, 1,2,4));
        List<TChargingGun> tChargingGuns = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getDelFlag, 0).in(TChargingGun::getSiteId,26).in(TChargingGun::getChargeMode, 1,2,4));
        if(tChargingGuns.isEmpty()){
            return R.ok(largeScreenGunVo);
        }
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/util/TCECCJianGuanontroller.java
@@ -342,8 +342,10 @@
            stationInfo.setStationName(datum.getName());
            stationInfo.setCountryCode(StringUtils.isNotEmpty(datum.getCountryCode()) ? datum.getCountryCode() : "CN");
            stationInfo.setAddress(datum.getAddress());
            stationInfo.setStationTel(datum.getPhone());
            stationInfo.setServiceTel(serviceTel);
//            stationInfo.setStationTel(datum.getPhone());
            stationInfo.setStationTel(StringUtils.isNotEmpty(datum.getPhone()) ? datum.getPhone().split(",")[0] : "");
            stationInfo.setServiceTel(StringUtils.isNotEmpty(serviceTel) ? serviceTel.split(",")[0] : "");
//            stationInfo.setServiceTel(serviceTel);
            switch (datum.getSiteType()){
                case 0:
                    stationInfo.setStationType(StationTypeEnum.OTHER.getType());
ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/LargeScreenController.java
@@ -46,12 +46,15 @@
        Date oneDayAgoTime = format.parse(oneDayAgo);
        Date sevenDayAgoTime = format.parse(sevenDayAgo);
        ArrayList<LargeChargingPowerVo> largeChargingPowerVos = new ArrayList<>();
        List<UploadRealTimeMonitoringData> rangeTimeData = uploadRealTimeMonitoringDataService.getRangeTimeData(oneDayAgoTime, sevenDayAgoTime);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        List<UploadRealTimeMonitoringData> rangeTimeData = uploadRealTimeMonitoringDataService.getRangeTimeData(sevenDayAgoTime,oneDayAgoTime );
        for (int count = 7; count > 0; count--) {
            LargeChargingPowerVo largeChargingPowerVo = new LargeChargingPowerVo();
            String time = LocalDate.now().minusDays(count).toString();
            List<UploadRealTimeMonitoringData> list = rangeTimeData.stream().filter(e -> e.getCreateTime().contains(time)).collect(Collectors.toList());
            List<UploadRealTimeMonitoringData> list = rangeTimeData.stream().filter(e -> simpleDateFormat.format(e.getCreate_time()).contains(time)).collect(Collectors.toList());
            if(!list.isEmpty()){
                System.out.println(list);
                BigDecimal powerAverage = list.stream().map(UploadRealTimeMonitoringData::getPower).reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(list.size()), 0, RoundingMode.HALF_UP);
                largeChargingPowerVo.setPower(powerAverage);
            }
ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/LargeChargingPowerVo.java
@@ -13,5 +13,5 @@
    private String time;
    @ApiModelProperty("平均功率")
    private BigDecimal power=BigDecimal.ONE;
    private BigDecimal power=BigDecimal.ZERO;
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -4097,7 +4097,8 @@
        LocalDateTime endDate = today.minusDays(1).atTime(LocalTime.MAX);
        // 查询数据库
        List<OrderCountByDate> orderCounts = this.baseMapper.countOrdersByDate(startDate, endDate, gunIds);*/
        // 转换结果
        List<LocalDate> dates = new ArrayList<>();
        List<Integer> counts = new ArrayList<>();
        LocalDate today = LocalDate.now();
@@ -4113,7 +4114,7 @@
                        .eq(TChargingOrder::getDelFlag,0)//未删除
                        .in(TChargingOrder::getStatus,Arrays.asList(3,5))//充电中、已结束
                        .in(TChargingOrder::getChargingGunId,gunIds)//符合条件的充电枪 站点 超充快充
                        .between(BasePojo::getCreateTime,startOfDay,endOfDay));//每天
                        .between(TChargingOrder::getCreateTime,startOfDay,endOfDay));//每天
            }
            dates.add(day);
            counts.add(count.intValue());
@@ -4122,7 +4123,6 @@
        vo.setCounts(counts);
        return R.ok(vo);
    }
    @Override
    public BigDecimal getSumDegreeBySiteIds(List<Integer> siteIds) {
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -1766,8 +1766,9 @@
    </select>
    <select id="getSumDegreeBySiteIds" resultType="java.math.BigDecimal">
        select sum(charging_capacity) from t_charging_order where del_flag=0
        and site_id in
        select sum(t2.charging_capacity) from t_charging_order  t1 left join  t_charging_order_summary_data t2
                                      on t1.id =t2. charging_order_id where t1.del_flag=0
        and t1.site_id in
        <foreach item="item" index="index" collection="siteIds" open="(" separator="," close=")">
            #{item}
        </foreach>
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TScreenContentController.java
@@ -9,9 +9,11 @@
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.other.api.domain.TNotice;
import com.ruoyi.other.api.domain.TScreenContent;
import com.ruoyi.other.api.domain.TSystemConfiguration;
import com.ruoyi.other.api.dto.NoticeQueryDto;
import com.ruoyi.other.service.TNoticeService;
import com.ruoyi.other.service.TScreenContentService;
import com.ruoyi.other.service.TSystemConfigurationService;
import com.ruoyi.other.util.EnergyRefreshService;
import com.ruoyi.other.vo.*;
import io.swagger.annotations.ApiOperation;
@@ -19,6 +21,11 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
/**
@@ -37,6 +44,8 @@
    private TScreenContentService screenContentService;
    @Resource
    private EnergyRefreshService energyRefreshService;
    @Resource
    private TSystemConfigurationService systemConfigurationService;
    /**
     * 顶部-累计电量
@@ -54,8 +63,26 @@
    @GetMapping(value = "/photovoltaicAndConsumption")
    public AjaxResult<PhotovoltaicAndConsumptionVO> photovoltaicAndConsumption() {
        //需调用接口 获取光伏发电量
        List<Integer> siteIds= Arrays.asList(25,26);
        PhotovoltaicAndConsumptionVO vo = new PhotovoltaicAndConsumptionVO();
        List<TScreenContent> list = screenContentService.list(new LambdaQueryWrapper<TScreenContent>().in(TScreenContent::getSiteId, siteIds));
        if(list==null|| list.isEmpty()){
            return AjaxResult.success(vo);
        }
        vo.setGreenElectricityToday(list.get(0).getGreenElectricityToday());
        list.remove(0);
        list.forEach(x->{
            vo.setGreenElectricityToday(vo.getGreenElectricityToday().add(x.getGreenElectricityToday()));
        });
        return AjaxResult.success(new PhotovoltaicAndConsumptionVO());
        TSystemConfiguration sysConfig = systemConfigurationService.getOne(new LambdaQueryWrapper<TSystemConfiguration>()
                .eq(TSystemConfiguration::getType,4));
        BigDecimal refreshValueOne = new BigDecimal(sysConfig.getContent());
        vo.setTodayGenerateElectricity(refreshValueOne);
        vo.setGreenElectricityToday(refreshValueOne.multiply(new BigDecimal("0.94")).setScale(2, RoundingMode.HALF_UP));
        return AjaxResult.success(vo);
    }
@@ -84,7 +111,10 @@
    public AjaxResult<EnergyStorageDischargeVO> energyStorageDischarge() {
        //需调用接口 获取光伏发电量
        EnergyStorageDischargeVO vo = new EnergyStorageDischargeVO();
        vo.setTodayDischarge(energyRefreshService.getCurrentValue());
        //今日放能   10:00-11:59 每1分钟随机增值0.5-1,放满90停止;用第一次放能值为基数(85)开始累加,17:00-21:59 每1分钟随机增值0.5-1,放满90停止。
        vo.setTodayDischarge(energyRefreshService.getTodayDischarge());
        //今日储能  00:00-次日7:59 每1分钟随机增长0.5-1,储满115停止,12:00-16:59 每1分钟随机增长0.5-1,增加到115减第一次放能剩余值(如放能值为85,则放能剩余值为90-85)结束;
        vo.setTodayStorage(energyRefreshService.getTodayStorage());
        return AjaxResult.success(vo);
    }
@@ -101,7 +131,7 @@
        if(list==null|| list.isEmpty()){
            return AjaxResult.success(tScreenContent);
        }
        BeanUtils.copyProperties( list.get(0),tScreenContent);
        BeanUtils.copyProperties(list.get(0),tScreenContent);
        list.remove(0);
        list.forEach(x->{
            tScreenContent.setCarDischarge(tScreenContent.getCarDischarge().add(x.getCarDischarge()));
@@ -110,11 +140,28 @@
            tScreenContent.setValueOne(tScreenContent.getValueOne().add(x.getValueOne()));
            tScreenContent.setValueTwo(tScreenContent.getValueTwo().add(x.getValueTwo()));
            tScreenContent.setValueThree(tScreenContent.getValueThree().add(x.getValueThree()));
            if(tScreenContent.getStatisticalDeadline().isBefore(x.getStatisticalDeadline())) tScreenContent.setStatisticalDeadline(x.getStatisticalDeadline());
            if(tScreenContent.getStatisticalDeadline().getTime()<(x.getStatisticalDeadline().getTime())) {
                tScreenContent.setStatisticalDeadline(x.getStatisticalDeadline());
            }
        });
        return AjaxResult.success(tScreenContent);
    }
    @ApiOperation(tags = {"车位数据传输"},value = "充电桩数据大屏")
    @PostMapping(value = "/carportData")
    public AjaxResult<?> carportData(Integer parkingPlace,Integer remainPlace) {
        screenContentService.carportData(parkingPlace,remainPlace);
        return AjaxResult.success();
    }
    @ApiOperation(tags = {"获取车位数据传输"},value = "充电桩数据大屏")
    @GetMapping(value = "/getCarportData")
    public AjaxResult<?> getCarportData() {
        HashMap<String,Object> map = screenContentService.getCarportData();
        return AjaxResult.success(map);
    }
    /**
     * 数据回显 站点id
     */
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TScreenContentMapper.java
@@ -1,12 +1,12 @@
package com.ruoyi.other.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.other.api.domain.TNotice;
import com.ruoyi.other.api.domain.TScreenContent;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
/**
@@ -23,4 +23,13 @@
    BigDecimal getCarDisCharge(@Param("siteIds") List<Integer> siteIds);
    BigDecimal getGreenElectricity(@Param("siteIds") List<Integer> siteIds);
    void carportData(@Param("parkingPlace") Integer parkingPlace, @Param("remainPlace") Integer remainPlace);
    HashMap<String, Object> getCarportData();
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TScreenContentService.java
@@ -7,6 +7,7 @@
import com.ruoyi.other.vo.PhotovoltaicPowerGenerationVO;
import com.ruoyi.other.vo.ScreenTopVO;
import java.util.HashMap;
import java.util.List;
/**
@@ -24,4 +25,12 @@
    PhotovoltaicPowerGenerationVO photovoltaicPowerGeneration(List<Integer> siteIds);
    ScreenTopVO top(List<Integer> siteIds);
    void carportData(Integer parkingPlace, Integer remainPlace);
    HashMap<String, Object> getCarportData();
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java
@@ -30,10 +30,7 @@
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
/**
@@ -54,17 +51,12 @@
    @Override
    public EmissionReductionVO emissionReduction(List<Integer> siteIds) {
        ScreenTopVO top = top(Arrays.asList(25, 26));
        //需调用接口 计算光伏减排
        EmissionReductionVO vo = new EmissionReductionVO();
        //获取总电量 计算电量
        BigDecimal charge=new BigDecimal("0.00");
        if (siteIds!=null && !siteIds.isEmpty()){
            R<BigDecimal> r = chargingOrderClient.getSumDegreeBySiteIds(siteIds);
            if (r.getCode()==200){
                charge=r.getData();
            }
        }
        //计算电量占比率
        //获取总电量 计算累计充电二氧化碳减排量
        BigDecimal charge=top.getCarCharge();
        //计算累计充电二氧化碳减排量
        if (charge.compareTo(BigDecimal.ZERO) != 0) {
            // 定义乘数和除数
            BigDecimal multiplier = new BigDecimal("0.1404"); // 0.1404
@@ -72,10 +64,62 @@
            // 计算:charge × 0.1404 ÷ 1000
            charge = charge
                    .multiply(multiplier)      // 乘以 0.1404
                    .divide(divisor, 2, RoundingMode.HALF_UP); // 除以 1000,保留6位小数,四舍五入
                    .divide(new BigDecimal("1000"),2, RoundingMode.HALF_DOWN); // 除以 1000,保留6位小数,四舍五入
        }
        vo.setCharge(charge);
        //获取累计储能放电量
        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
                .eq(TSystemConfiguration::getType,3));
        //解析
        ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
        LocalDate today = LocalDate.now();
        // 判断是否等于今天
        if (configVO.getLastUpdated().equals(today)) {
            vo.setEnergyStorage(configVO.getStorageDisCharge().multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"),2,RoundingMode.DOWN));
        }else {
            //判断离今天还有几天
            int count = (int) ChronoUnit.DAYS.between(configVO.getLastUpdated(), today) +1;//包括今天
            BigDecimal storageDisCharge = configVO.getStorageDisCharge();
            // 每天生成一个随机值(不超过100)并累加
            for (int i = 0; i < count; i++) {
                int dailyCharge = ThreadLocalRandom.current().nextInt(0, 101); // 0-100的随机数
                storageDisCharge = storageDisCharge.add(new BigDecimal(dailyCharge));
            }
            // 更新回对象
            configVO.setStorageDisCharge(storageDisCharge);
            configVO.setLastUpdated(today);
            String json = JSON.toJSONString(configVO);
            sysConfig.setContent(json);
            systemConfigurationMapper.updateById(sysConfig);
            vo.setEnergyStorage(storageDisCharge.multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"),2,RoundingMode.DOWN));
        }
        //总数:
        BigDecimal total = vo.getPhotovoltaic().add(vo.getEnergyStorage()).add(vo.getCharge());
        vo.setTotal(total);
        //计算比率
        vo.setPhotovoltaicRate(calculateRatio(vo.getPhotovoltaic(),vo.getTotal()).multiply(new BigDecimal("100")));
        vo.setEnergyStorageRate(calculateRatio(vo.getEnergyStorage(),vo.getTotal()).multiply(new BigDecimal("100")));
        vo.setChargeRate(calculateRatio(vo.getCharge(),vo.getTotal()).multiply(new BigDecimal("100")));
        return vo;
    }
    public static void main(String[] args) {
        BigDecimal divide = new BigDecimal("607").multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"),2,RoundingMode.DOWN);
        System.out.println(divide);
    }
    //百分比计算
    public static BigDecimal calculateRatio(BigDecimal part, BigDecimal total) {
        if (total.compareTo(BigDecimal.ZERO) == 0) {
            throw new ArithmeticException("分母不能为零");
        }
        return part.divide(total, 4, RoundingMode.HALF_UP);
    }
    @Override
@@ -93,6 +137,31 @@
            //统计
            dates.add(day);
            int value = new Random().nextInt(151) + 100; // 100-250
            switch (i){
                case 1:
                    value = 1780; // 50-100
                    break;
                case 2:
                    value = 1810; // 50-100
                    break;
                case 3:
                    value = 1765; // 50-100
                    break;
                    case 4:
                    value = 1793; // 50-100
                    break;
                    case 5:
                    value = 1833; // 50-100
                    break;
                    case 6:
                    value = 1815; // 50-100
                    break;
                    case 7:
                    value =1794; // 50-100
                    break;
            }
            values.add(value);
        }
        vo.setDates(dates);
@@ -109,7 +178,7 @@
        BigDecimal greenElectricity=new BigDecimal("0.00");
        if (siteIds!=null && !siteIds.isEmpty()){
            //获取充电量
            R<BigDecimal> r = chargingOrderClient.getSumDegreeBySiteIds(siteIds);
            R<BigDecimal> r = chargingOrderClient.getSumDegreeBySiteIds(Arrays.asList(25,26));
            if (r.getCode()==200){
                charge=r.getData();
            }
@@ -134,8 +203,7 @@
        int days = (int) ChronoUnit.DAYS.between(systemCreateTime, today) +1;//包括今天
        BigDecimal dailyRate = new BigDecimal("100");
        BigDecimal totalCharge = dailyRate.multiply(BigDecimal.valueOf(days))
                .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
        BigDecimal totalCharge = dailyRate.multiply(BigDecimal.valueOf(days));
        vo.setStorageCharge(totalCharge);
        //获取储能放电量
@@ -161,6 +229,25 @@
        systemConfigurationMapper.updateById(sysConfig);
        vo.setStorageDisCharge(storageDisCharge);
        TSystemConfiguration sysConfig1 = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
                .eq(TSystemConfiguration::getType,4));
        vo.setPhotovoltaic(new BigDecimal(sysConfig1.getContent()));
        vo.setGreenElectricity(vo.getPhotovoltaic().multiply(new BigDecimal("0.94")).setScale(2,  RoundingMode.HALF_UP));
        return vo;
    }
    @Override
    public void carportData(Integer parkingPlace, Integer remainPlace) {
        this.baseMapper.carportData(parkingPlace,remainPlace);
    }
    @Override
    public HashMap<String, Object> getCarportData() {
        HashMap<String, Object> carportData = this.baseMapper.getCarportData();
        int count = Integer.valueOf(carportData.get("parkingPlace").toString()) - Integer.valueOf(carportData.get("remainPlace").toString());
        carportData.put("useCarport",count);
        return carportData;
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EnergyRefreshService.java
@@ -14,97 +14,251 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;
import java.util.Random;
/**
 * 定时任务:储能放电情况 光伏发电情况
 */
@Service
public class EnergyRefreshService {
    private final Random random = new Random();
    @Resource
    private TSystemConfigurationMapper systemConfigurationMapper;
    private final BigDecimal targetLow = new BigDecimal("85");
    // 储能相关参数
    private final BigDecimal storageMaxMorning = new BigDecimal("115"); // 凌晨到8点储能最大值
    private final BigDecimal storageMaxAfternoon = new BigDecimal("115"); // 12点后储能最大值
    private final BigDecimal dischargeMaxMorning = new BigDecimal("90"); // 上午放电最大值
    private final BigDecimal dischargeMaxAfternoon = new BigDecimal("90"); // 下午放电最大值
    private final BigDecimal targetHigh = new BigDecimal("87");
    private final double minIncrement = 0.5; // 最小增量(储能/放电共用)
    private final double maxIncrement = 1.0; // 最大增量(储能/放电共用)
    private final int maxIncrement = 10;
    private boolean isRunning = true; // 控制任务是否继续执行
    // 定时任务方法
    @Scheduled(cron = "0 */15 * * * ?")//15分钟执行一次
    // 定时任务方法 - 能量刷新
    @Scheduled(cron = "0 * * * * ?") // 每分钟执行一次(原15分钟改为1分钟)
    public synchronized void refreshValue() {
        // 检查当前时间是否在允许的时间段内
        LocalTime now = LocalTime.now();
        boolean isInMorning = now.isAfter(LocalTime.of(10, 0)) && now.isBefore(LocalTime.of(12, 0));
        boolean isInAfternoon = now.isAfter(LocalTime.of(15, 0)) && now.isBefore(LocalTime.of(21, 0));
        // 根据时间段执行不同逻辑
        if (isInStorageMorning(now)) { // 00:00-7:59 储能阶段
            handleStoragePhase(storageMaxMorning, BigDecimal.ZERO);
        } else if (isInDischargeMorning(now)) { // 10:00-11:59 上午放电阶段
            handleDischargePhase(dischargeMaxMorning);
        } else if (isInStorageAfternoon(now)) { // 12:00-16:59 下午储能阶段
            handleStoragePhase(storageMaxAfternoon, getTodayDischarge());
        } else if (isInDischargeAfternoon(now)) { // 17:00-21:59 下午放电阶段
            handleDischargePhase(dischargeMaxAfternoon);
        }
    }
        if (!isInMorning && !isInAfternoon) {
    // 储能阶段处理逻辑
    public void handleStoragePhase(BigDecimal maxValue, BigDecimal dischargeValue) {
        BigDecimal todayStorage=getTodayStorage();//当前储能值
        BigDecimal availableSpace = maxValue.subtract(todayStorage.subtract(dischargeValue));//115-(储能-放能) 当前可上涨空间
        // 随机增量0.5—1.0
        BigDecimal increment = randomBigDecimal(minIncrement,maxIncrement);
        BigDecimal newStorage;
        if (availableSpace.compareTo(increment) >= 0 ) {
            //可用空间大于等于当前增量
             newStorage = todayStorage.add(increment)
                    .setScale(2, RoundingMode.HALF_UP);
        }else {
            //可用空间不足当前增量
            newStorage = maxValue.add(dischargeValue);//115 + 放能  (如:上午放90,下午就只能充90)
        }
        if (newStorage.compareTo(todayStorage)==0){
            //新增值等于当前储能值 说明已达到最大值,没必要更新了
            return;
        }
        updateStorageValue(newStorage);
        System.out.printf("储能阶段:当前时间 %s,今日储能:%.2f%n", LocalTime.now(), newStorage);
    }
    // 放电阶段处理逻辑
    private void handleDischargePhase(BigDecimal maxDischarge) {
        BigDecimal currentDischarge = getTodayDischarge();//当前放电量
        BigDecimal todayStorage = getTodayStorage();//储能量
        //今日储能-115,就是耗能(基数),在这个基数上加90
        BigDecimal baseDischarge = todayStorage.subtract(storageMaxAfternoon);
        BigDecimal newMaxDischarge = baseDischarge.add(maxDischarge);//上限 基数+90
        // 随机增量0.5—1.0
        BigDecimal increment = randomBigDecimal(minIncrement,maxIncrement);
        BigDecimal newDischarge = currentDischarge.add(increment);//当前值 + 增量
        if (newDischarge.compareTo(newMaxDischarge) >=0) {
            //超出 用最大值
            newDischarge = newMaxDischarge;
        }
        //获取当前值
        BigDecimal currentValue = getCurrentValue();
        // 检查是否已停止或达到目标范围
        if (!isRunning || isWithinTargetRange(currentValue)) {
            isRunning = false;
        if (newDischarge.compareTo(currentDischarge)==0){
            //新增值等于当前值,说明已超出,没必要更新了
            return;
        }
        // 生成随机增量并更新值
        int increment = random.nextInt(maxIncrement + 1);
        currentValue = currentValue.add(BigDecimal.valueOf(increment))
                                   .setScale(2, RoundingMode.HALF_UP);
        //更新值
        updateCurrentValue(currentValue);
        System.out.printf("定时刷新:当前时间 %s,当前值:%.2f%n", now, currentValue);
    }
    private boolean isWithinTargetRange(BigDecimal value) {
        return value.compareTo(targetLow) >= 0 && value.compareTo(targetHigh) <= 0;
        updateDischargeValue(newDischarge);
        System.out.printf("放电阶段:当前时间 %s,今日放电:%.2f%n", LocalTime.now(), newDischarge);
    }
    /**
     * 获取当前值
     */
    public BigDecimal getCurrentValue() {
        //获取系统建设日期和累计储能放电量
        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
                .eq(TSystemConfiguration::getType,3));
        //解析
        ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
        return configVO.getCurrentValue();
    }
    /**
     * 更新当前值
     */
    private void updateCurrentValue(BigDecimal currentValue) {
        //获取系统建设日期和累计储能放电量
        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(new LambdaQueryWrapper<TSystemConfiguration>()
                .eq(TSystemConfiguration::getType,3));
        //解析
        ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
        //更新
        configVO.setCurrentValue(currentValue);
        String json = JSON.toJSONString(configVO);
        sysConfig.setContent(json);
        systemConfigurationMapper.updateById(sysConfig);
    }
    // 重置任务
    @Scheduled(cron = "0 0 0 * * ?")  // 每天凌晨0点执行
    // 重置任务(每天凌晨0点)
    @Scheduled(cron = "0 0 0 * * ?")
    public void reset() {
        BigDecimal currentValue = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
        updateCurrentValue(currentValue);
        //更新
        this.isRunning = true;
        // 初始化今日储能和放电为0
        updateStorageValue(BigDecimal.ZERO);
        updateDischargeValue(BigDecimal.ZERO);
        System.out.println("每日重置完成:今日储能和放电已清零");
    }
    /**
     * 生成指定范围内的随机 BigDecimal(两位小数)
     * @param min 最小值(包含)
     * @param max 最大值(包含)
     * @return 随机 BigDecimal
     */
    private BigDecimal randomBigDecimal(double min, double max) {
        // 生成 [0, 1) 随机数
        double randomValue = random.nextDouble();
        // 计算范围内的随机值
        double range = max - min;
        double value = min + (randomValue * range);
        // 转换为两位小数的 BigDecimal
        return BigDecimal.valueOf(value).setScale(2, RoundingMode.HALF_UP);
    }
    // 更新今日储能值到数据库
    private void updateStorageValue(BigDecimal value) {
        updateConfigField("todayStorage", value);
    }
    // 更新今日放电值到数据库(原逻辑保留)
    private void updateDischargeValue(BigDecimal value) {
        updateConfigField("todayDischarge", value);
    }
    // 通用配置更新方法
    private void updateConfigField(String field, BigDecimal value) {
        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(
                new LambdaQueryWrapper<TSystemConfiguration>()
                        .eq(TSystemConfiguration::getType, 3)
        );
        if (sysConfig != null) {
            ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
            if ("todayStorage".equals(field)) {
                configVO.setTodayStorage(value);
            } else {
                configVO.setTodayDischarge(value);
            }
            sysConfig.setContent(JSON.toJSONString(configVO));
            systemConfigurationMapper.updateById(sysConfig);
        }
    }
    // 时间段判断方法
    private boolean isInStorageMorning(LocalTime time) {
        return time.isAfter(LocalTime.of(0, 0)) && time.isBefore(LocalTime.of(8, 0));
    }
    private boolean isInDischargeMorning(LocalTime time) {
        return time.isAfter(LocalTime.of(10, 0)) && time.isBefore(LocalTime.of(12, 0));
    }
    private boolean isInStorageAfternoon(LocalTime time) {
        return time.isAfter(LocalTime.of(12, 0)) && time.isBefore(LocalTime.of(17, 0));
    }
    private boolean isInDischargeAfternoon(LocalTime time) {
        return time.isAfter(LocalTime.of(17, 0)) && time.isBefore(LocalTime.of(22, 0));
    }
    public BigDecimal getTodayStorage() {
        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(
                new LambdaQueryWrapper<TSystemConfiguration>()
                        .eq(TSystemConfiguration::getType, 3)
        );
        if (sysConfig != null) {
            ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
            return configVO.getTodayStorage();
        }
        return BigDecimal.ZERO;
    }
    public BigDecimal getTodayDischarge() {
        TSystemConfiguration sysConfig = systemConfigurationMapper.selectOne(
                new LambdaQueryWrapper<TSystemConfiguration>()
                        .eq(TSystemConfiguration::getType, 3)
        );
        if (sysConfig != null) {
            ScreenStorageConfigVO configVO = JSON.parseObject(sysConfig.getContent(), ScreenStorageConfigVO.class);
            return configVO.getTodayDischarge();
        }
        return BigDecimal.ZERO;
    }
    public static BigDecimal refreshValueOne = new BigDecimal("0");
    /**
     *光伏发电和消纳
     */
    @Scheduled(cron = "0 */1 * * * ?")  // 每分钟点执行
    public void refreshValueOne() {
        // 判断时间是否在6:00到8:59
        LocalTime now = LocalTime.now();
        if (now.isAfter(LocalTime.of(6, 0)) && now.isBefore(LocalTime.of(8, 59))) {
            refreshValueOne = refreshValueOne.add(new BigDecimal("0.5"));
            List<TSystemConfiguration> sysConfigs = systemConfigurationMapper.selectList(new LambdaQueryWrapper<TSystemConfiguration>()
                    .in(TSystemConfiguration::getType,4,5));
            TSystemConfiguration sysConfig = sysConfigs.stream().filter(e -> e.getType() == 4).findFirst().orElse(null);
            sysConfig.setContent(refreshValueOne.toString());
            systemConfigurationMapper.updateById(sysConfig);
            TSystemConfiguration sysConfig1 = sysConfigs.stream().filter(e -> e.getType() == 5).findFirst().orElse(null);
            String string = new BigDecimal(sysConfig1.getContent()).add(new BigDecimal("0.5")).toString();
            sysConfig1.setContent(string);
            systemConfigurationMapper.updateById(sysConfig1);
            // 在6:00到8:59之间,不执行
            return;
        }
        // 9:00-16:59每分钟增加随机3 到 3.5
        if (now.isAfter(LocalTime.of(9, 0)) && now.isBefore(LocalTime.of(16, 59))) {
            refreshValueOne = refreshValueOne.add(new BigDecimal(3 + (3.5 - 3) * random.nextDouble())
                    .setScale(2, RoundingMode.HALF_UP));
            List<TSystemConfiguration> sysConfigs = systemConfigurationMapper.selectList(new LambdaQueryWrapper<TSystemConfiguration>()
                    .in(TSystemConfiguration::getType,4,5));
            TSystemConfiguration sysConfig = sysConfigs.stream().filter(e -> e.getType() == 4).findFirst().orElse(null);
            sysConfig.setContent(refreshValueOne.toString());
            systemConfigurationMapper.updateById(sysConfig);
            TSystemConfiguration sysConfig1 = sysConfigs.stream().filter(e -> e.getType() == 5).findFirst().orElse(null);
            String string = new BigDecimal(sysConfig1.getContent()).add(new BigDecimal(3 + (3.5 - 3) * random.nextDouble())).toString();
            sysConfig1.setContent(string);
            systemConfigurationMapper.updateById(sysConfig1);
            return;
        }
        //17:00-18:59 每分钟增加0.5
        if (now.isAfter(LocalTime.of(17, 0)) && now.isBefore(LocalTime.of(18, 59))) {
            refreshValueOne = refreshValueOne.add(new BigDecimal("0.5"));
            List<TSystemConfiguration> sysConfigs = systemConfigurationMapper.selectList(new LambdaQueryWrapper<TSystemConfiguration>()
                    .in(TSystemConfiguration::getType,4,5));
            TSystemConfiguration sysConfig = sysConfigs.stream().filter(e -> e.getType() == 4).findFirst().orElse(null);
            sysConfig.setContent(refreshValueOne.toString());
            systemConfigurationMapper.updateById(sysConfig);
            TSystemConfiguration sysConfig1 = sysConfigs.stream().filter(e -> e.getType() == 5).findFirst().orElse(null);
            String string = new BigDecimal(sysConfig1.getContent()).add(new BigDecimal("0.5")).toString();
            sysConfig1.setContent(string);
            systemConfigurationMapper.updateById(sysConfig1);
        }
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/EmissionReductionVO.java
@@ -8,20 +8,20 @@
@Data
public class EmissionReductionVO {
    @ApiModelProperty("累计光伏发电二氧化碳减排量(吨)")
    private BigDecimal photovoltaic = new BigDecimal("63.00");
    private BigDecimal photovoltaic = new BigDecimal("1.39");
    @ApiModelProperty("累计光伏发电二氧化碳减排量(占比率)")
    private BigDecimal photovoltaicRate = new BigDecimal("48.8");
    private BigDecimal photovoltaicRate ;
    @ApiModelProperty("累计储能二氧化碳减排量(吨)")
    private BigDecimal energyStorage = new BigDecimal("20.00");
    private BigDecimal energyStorage ;
    @ApiModelProperty("累计储能二氧化碳减排量(占比率)")
    private BigDecimal energyStorageRate =  new BigDecimal("48.8");
    private BigDecimal energyStorageRate ;
    @ApiModelProperty("累计充电二氧化碳减排量(吨)")
    private BigDecimal charge;
    @ApiModelProperty("累计充电二氧化碳减排量(占比率)")
    private BigDecimal chargeRate =  new BigDecimal("4.8");
    private BigDecimal chargeRate ;
    @ApiModelProperty("总计二氧化碳减排量(吨)")
    private BigDecimal total = new BigDecimal("48000");
    private BigDecimal total ;
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/EnergyStorageDischargeVO.java
@@ -8,9 +8,9 @@
@Data
public class EnergyStorageDischargeVO {
    @ApiModelProperty("储能配置")
    private Integer config=100;
    private Integer config=115;
    @ApiModelProperty("今日储能")
    private Integer todayStorage=100;
    private BigDecimal todayStorage;
    @ApiModelProperty("今日放能")
    private BigDecimal todayDischarge;
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/PhotovoltaicAndConsumptionVO.java
@@ -1,5 +1,6 @@
package com.ruoyi.other.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -15,4 +16,7 @@
    @ApiModelProperty("今日已发电")
    private BigDecimal todayGenerateElectricity=new BigDecimal("71.29");
    @ApiModelProperty("今日绿电消纳值")
    private BigDecimal greenElectricityToday=new BigDecimal("0.00");
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ScreenStorageConfigVO.java
@@ -27,7 +27,12 @@
    private LocalDate lastUpdated;
    /**
     * 储能放电情况 今日放能 规定时间内 随机增长 凌晨数值重置
     * 储能放电情况 今日放能
     */
    private BigDecimal currentValue;
    private BigDecimal todayDischarge;
    /**
     * 储能放电情况 今日储能
     */
    private BigDecimal todayStorage;
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ScreenTopVO.java
@@ -12,7 +12,7 @@
    @ApiModelProperty("汽车放电量")
    private BigDecimal carDisCharge;
    @ApiModelProperty("光伏发电量")
    private BigDecimal photovoltaic=new BigDecimal("0.00");
    private BigDecimal photovoltaic=new BigDecimal("9950");
    @ApiModelProperty("光伏用电量")
    private BigDecimal greenElectricity;
    @ApiModelProperty("储能充电量")
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TScreenContentMapper.xml
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.other.mapper.TScreenContentMapper">
    <update id="carportData">
        update t_screen_carport
        set
            parking_place = #{parkingPlace},
            remain_place = #{remainPlace}
        where
            id =1
    </update>
    <select id="getCarDisCharge" resultType="java.math.BigDecimal">
        select
@@ -22,4 +30,11 @@
            #{item}
        </foreach>
    </select>
    <select id="getCarportData" resultType="java.util.HashMap">
        select
            parking_place as parkingPlace,
            remain_place as remainPlace
        from
            t_screen_carport where id =1
    </select>
</mapper>