From 6cca8f6b62cff87bde6108f0fddc1822e865a8ef Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期二, 22 七月 2025 18:10:26 +0800 Subject: [PATCH] 大屏替换路径 --- ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/PhotovoltaicPowerGenerationVO.java | 15 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 7 ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/service/impl/TScreenContentServiceImpl.java | 169 +++++++++ ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/util/KsolarUtils.java | 235 +++++++++++++ ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/PhotovoltaicAndConsumptionVO.java | 20 + ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/ScreenTopVO.java | 24 + ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java | 2 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OtherClient.java | 20 + ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RegionController.java | 52 +++ ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/ScreenStorageConfigVO.java | 37 ++ ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OtherFallbackFactory.java | 27 + ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/EmissionReductionVO.java | 27 + ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/TScreenContentController.java | 157 +++++++++ ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/LargeScreenController.java | 54 +- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java | 2 ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/service/TScreenContentService.java | 35 ++ ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/mapper/TScreenContentMapper.java | 35 ++ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TVipOrderController.java | 3 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml | 21 ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/EnergyStorageDischargeVO.java | 18 + ruoyi-service/ruoyi-jianguan/src/main/resources/mapper/jianguan/TScreenContentMapper.xml | 40 ++ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java | 5 23 files changed, 963 insertions(+), 44 deletions(-) diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OtherFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OtherFallbackFactory.java index d08ab1f..42537a7 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OtherFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OtherFallbackFactory.java @@ -12,6 +12,8 @@ import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.stereotype.Component; +import java.math.BigDecimal; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -104,6 +106,31 @@ public R<Region> getRegionBuyCode(String code) { return R.fail("远程调用根据code查询名称失败:"+throwable.getMessage()); } + + @Override + public R<List<TSystemConfiguration>> getTSystemConfiguration() { + return R.fail("远程调用获取配置失败:"+throwable.getMessage()); + } + + @Override + public R<BigDecimal> getCarDisCharge() { + return R.fail("远程调用获取配置失败:"+throwable.getMessage()); + } + + @Override + public R<BigDecimal> getGreenElectricity(List<Integer> siteIds) { + return R.fail("远程调用获取配置失败:"+throwable.getMessage()); + } + + @Override + public R carportData(String parkingPlace) { + return R.fail("远程调用获取配置失败:"+throwable.getMessage()); + } + + @Override + public R<HashMap<String, Object>> getCarportData() { + return R.fail("远程调用获取配置失败:"+throwable.getMessage()); + } }; } } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OtherClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OtherClient.java index a189721..aa6c019 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OtherClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OtherClient.java @@ -11,6 +11,8 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; +import java.math.BigDecimal; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -74,4 +76,22 @@ R<List<TEnterpriseUserApplication>> getTnterPrise(); @GetMapping("/region/getRegionBuyCode/{code}") R<Region> getRegionBuyCode(@PathVariable("code") String code); + + @GetMapping("/region/getTSystemConfiguration") + R<List<TSystemConfiguration>> getTSystemConfiguration(); + + @GetMapping(value = "/region/getCarDisCharge") + R<BigDecimal> getCarDisCharge(); + + @PostMapping(value = "/region/getGreenElectricity") + R<BigDecimal> getGreenElectricity(@RequestBody List<Integer> siteIds); + + @PostMapping(value = "/region/carportData") + R carportData(String parkingPlace); + + @GetMapping(value = "/region/getCarportData") + R<HashMap<String, Object>> getCarportData(); + + + } diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/LargeScreenController.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/LargeScreenController.java index ec3353e..9e88b0e 100644 --- a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/LargeScreenController.java +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/LargeScreenController.java @@ -37,33 +37,33 @@ } - @SneakyThrows - @ApiOperation(tags = {"大屏-停车场充电功率曲线图"},value = "停车场充电功率曲线图") - @GetMapping("/getChargingPower") - public R<List<LargeChargingPowerVo>> getChargingPower(){ - String sevenDayAgo = LocalDate.now().minusDays(7) + " 00:00:00"; - String oneDayAgo = LocalDate.now().minusDays(1) + " 23:59:59"; - Date oneDayAgoTime = format.parse(oneDayAgo); - Date sevenDayAgoTime = format.parse(sevenDayAgo); - ArrayList<LargeChargingPowerVo> largeChargingPowerVos = new ArrayList<>(); - 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 -> 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); - } - largeChargingPowerVo.setTime(time); - largeChargingPowerVos.add(largeChargingPowerVo); - } - - return R.ok(largeChargingPowerVos); - } +// @SneakyThrows +// @ApiOperation(tags = {"大屏-停车场充电功率曲线图"},value = "停车场充电功率曲线图") +// @GetMapping("/getChargingPower") +// public R<List<LargeChargingPowerVo>> getChargingPower(){ +// String sevenDayAgo = LocalDate.now().minusDays(7) + " 00:00:00"; +// String oneDayAgo = LocalDate.now().minusDays(1) + " 23:59:59"; +// Date oneDayAgoTime = format.parse(oneDayAgo); +// Date sevenDayAgoTime = format.parse(sevenDayAgo); +// ArrayList<LargeChargingPowerVo> largeChargingPowerVos = new ArrayList<>(); +// 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 -> 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); +// } +// largeChargingPowerVo.setTime(time); +// largeChargingPowerVos.add(largeChargingPowerVo); +// } +// +// return R.ok(largeChargingPowerVos); +// } diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/TScreenContentController.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/TScreenContentController.java new file mode 100644 index 0000000..ca8ac88 --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/controller/TScreenContentController.java @@ -0,0 +1,157 @@ +package com.ruoyi.jianguan.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.jianguan.service.TScreenContentService; +import com.ruoyi.jianguan.service.TSystemConfigurationService; +import com.ruoyi.jianguan.util.KsolarUtils; +import com.ruoyi.jianguan.vo.*; +import com.ruoyi.order.api.feignClient.ChargingOrderClient; +import com.ruoyi.other.api.domain.TScreenContent; +import com.ruoyi.other.api.domain.TSystemConfiguration; +import com.ruoyi.other.api.feignClient.OtherClient; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.List; + +/** + * <p> + * 前端控制器 + * </p> + * + * @author huliguo + * @since 2025/5/23 + */ +@RestController +@RequestMapping("/t_screen_content") +public class TScreenContentController { + + @Resource + private TScreenContentService screenContentService; + + + @Autowired + private OtherClient otherClient; + + + /** + * 顶部-累计电量 + */ + @ApiOperation(tags = {"顶部-累计电量"},value = "充电桩数据大屏") + @GetMapping(value = "/top") + public AjaxResult<ScreenTopVO> top(@RequestParam("siteIds") List<Integer> siteIds) { + return AjaxResult.success(screenContentService.top(siteIds)); + } + + /** + * 光伏发电和消纳 这里的绿电是调后台大屏内容管理的 + */ + @ApiOperation(tags = {"光伏发电和消纳"},value = "充电桩数据大屏") + @GetMapping(value = "/photovoltaicAndConsumption") + public AjaxResult<PhotovoltaicAndConsumptionVO> photovoltaicAndConsumption() { + //需调用接口 获取光伏发电量 + PhotovoltaicAndConsumptionVO vo = new PhotovoltaicAndConsumptionVO(); + vo.setTodayGenerateElectricity(new BigDecimal(KsolarUtils.getTodayEnergy(LocalDateTime.now().toString()))); + vo.setGreenElectricityToday(vo.getTodayGenerateElectricity().multiply(new BigDecimal("0.94")).setScale(2, RoundingMode.HALF_UP)); + return AjaxResult.success(vo); + } + + + /** + * 累计减排数据 + */ + @ApiOperation(tags = {"减排数据"},value = "充电桩数据大屏") + @GetMapping(value = "/emissionReduction") + public AjaxResult<EmissionReductionVO> emissionReduction (@RequestParam("siteIds") List<Integer> siteIds) { + return AjaxResult.success( screenContentService.emissionReduction(siteIds)); + } + /** + * 光伏发电实时情况 + */ + @ApiOperation(tags = {"光伏发电实时情况"},value = "充电桩数据大屏") + @GetMapping(value = "/photovoltaicPowerGeneration") + public AjaxResult<PhotovoltaicPowerGenerationVO> photovoltaicPowerGeneration (@RequestParam("siteIds") List<Integer> siteIds) { + return AjaxResult.success( screenContentService.photovoltaicPowerGeneration(siteIds)); + } + + /** + * 储能放电情况 + */ + @ApiOperation(tags = {"储能放电情况"},value = "充电桩数据大屏") + @GetMapping(value = "/energyStorageDischarge") + public AjaxResult<EnergyStorageDischargeVO> energyStorageDischarge() { + String electricity = KsolarUtils.getElectricity(); + R<List<TSystemConfiguration>> systemConfiguration = otherClient.getTSystemConfiguration(); + List<TSystemConfiguration> list = systemConfiguration.getData(); +// List<TSystemConfiguration> list = systemConfigurationService.list(new LambdaQueryWrapper<TSystemConfiguration>().in(TSystemConfiguration::getType, 4, 5)); + // 昨日放能 + TSystemConfiguration sysConfig = list.stream().filter(e -> e.getType() == 4).findFirst().orElse(null); + // 昨日储能 + TSystemConfiguration sysConfig1 = list.stream().filter(e -> e.getType() == 5).findFirst().orElse(null); + // 总储能 + String s = electricity.split("_")[0]; + // 总放能 + String s1 = electricity.split("_")[1]; + + EnergyStorageDischargeVO vo = new EnergyStorageDischargeVO(); + BigDecimal subtract = new BigDecimal(s1).subtract(new BigDecimal(sysConfig.getContent())); + vo.setTodayDischarge(subtract); + BigDecimal subtract1 = new BigDecimal(s).subtract(new BigDecimal(sysConfig1.getContent())); + vo.setTodayStorage(subtract1); + return AjaxResult.success(vo); + } + + + + /** + * 停车场共享情况及相关数据 + */ + @ApiOperation(tags = {"停车场共享情况及相关数据"},value = "充电桩数据大屏") + @GetMapping(value = "/screen") + public AjaxResult<TScreenContent> screen(@RequestParam("siteIds") List<Integer> siteIds) { + List<TScreenContent> list = screenContentService.list(new LambdaQueryWrapper<TScreenContent>().in(TScreenContent::getSiteId, siteIds)); + TScreenContent tScreenContent = new TScreenContent(); + if(list==null|| list.isEmpty()){ + return AjaxResult.success(tScreenContent); + } + BeanUtils.copyProperties(list.get(0),tScreenContent); + list.remove(0); + list.forEach(x->{ + tScreenContent.setCarDischarge(tScreenContent.getCarDischarge().add(x.getCarDischarge())); + tScreenContent.setGreenElectricity(tScreenContent.getGreenElectricity().add(x.getGreenElectricity())); + tScreenContent.setGreenElectricityToday(tScreenContent.getGreenElectricityToday().add(x.getGreenElectricityToday())); + tScreenContent.setValueOne(tScreenContent.getValueOne().add(x.getValueOne())); + tScreenContent.setValueTwo(tScreenContent.getValueTwo().add(x.getValueTwo())); + tScreenContent.setValueThree(tScreenContent.getValueThree().add(x.getValueThree())); + 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); + } + + +} diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/mapper/TScreenContentMapper.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/mapper/TScreenContentMapper.java new file mode 100644 index 0000000..5e495d4 --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/mapper/TScreenContentMapper.java @@ -0,0 +1,35 @@ +package com.ruoyi.jianguan.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +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; + +/** + * <p> + * 服务实现类 + * </p> + * + * @author huliguo + * @since 2025/5/23 + */ +@Mapper +public interface TScreenContentMapper extends BaseMapper<TScreenContent> { + + 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(); + + + + +} diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/service/TScreenContentService.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/service/TScreenContentService.java new file mode 100644 index 0000000..6892bc3 --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/service/TScreenContentService.java @@ -0,0 +1,35 @@ +package com.ruoyi.jianguan.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.jianguan.vo.EmissionReductionVO; +import com.ruoyi.jianguan.vo.PhotovoltaicPowerGenerationVO; +import com.ruoyi.jianguan.vo.ScreenTopVO; +import com.ruoyi.other.api.domain.TScreenContent; + +import java.util.HashMap; +import java.util.List; + +/** + * <p> + * 服务实现类 + * </p> + * + * @author huliguo + * @since 2025/5/23 + */ +public interface TScreenContentService extends IService<TScreenContent> { + + EmissionReductionVO emissionReduction(List<Integer> siteIds); + + PhotovoltaicPowerGenerationVO photovoltaicPowerGeneration(List<Integer> siteIds); + + ScreenTopVO top(List<Integer> siteIds); + + void carportData(Integer parkingPlace, Integer remainPlace); + + + HashMap<String, Object> getCarportData(); + + + +} diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/service/impl/TScreenContentServiceImpl.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/service/impl/TScreenContentServiceImpl.java new file mode 100644 index 0000000..bf71b6e --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/service/impl/TScreenContentServiceImpl.java @@ -0,0 +1,169 @@ +package com.ruoyi.jianguan.service.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.jianguan.mapper.TScreenContentMapper; +import com.ruoyi.jianguan.mapper.TSystemConfigurationMapper; +import com.ruoyi.jianguan.service.TScreenContentService; +import com.ruoyi.jianguan.util.KsolarUtils; +import com.ruoyi.jianguan.vo.EmissionReductionVO; +import com.ruoyi.jianguan.vo.PhotovoltaicPowerGenerationVO; +import com.ruoyi.jianguan.vo.ScreenTopVO; +import com.ruoyi.order.api.feignClient.ChargingOrderClient; +import com.ruoyi.other.api.domain.TScreenContent; +import com.ruoyi.other.api.feignClient.OtherClient; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDate; +import java.util.*; + +/** + * <p> + * 服务实现类 + * </p> + * + * @author huliguo + * @since 2025/5/23 + */ +@Service +public class TScreenContentServiceImpl extends ServiceImpl<TScreenContentMapper, TScreenContent> implements TScreenContentService { + + @Resource + private ChargingOrderClient chargingOrderClient; + + @Resource + private OtherClient otherClient; + + @Override + public EmissionReductionVO emissionReduction(List<Integer> siteIds) { + ScreenTopVO top = top(Arrays.asList(25, 26)); + //需调用接口 计算光伏减排 + EmissionReductionVO vo = new EmissionReductionVO(); + //获取总电量 计算累计充电二氧化碳减排量 + BigDecimal charge=top.getCarCharge(); + BigDecimal multiplier = new BigDecimal("0.1404"); + //计算累计充电二氧化碳减排量 + if (charge.compareTo(BigDecimal.ZERO) != 0) { + // 定义乘数和除数 + // 0.1404 + // 计算:charge × 0.1404 ÷ 1000 + charge = charge + .multiply(multiplier) // 乘以 0.1404 + .divide(new BigDecimal("1000"),2, RoundingMode.HALF_DOWN); // 除以 1000,保留6位小数,四舍五入 + } + vo.setCharge(charge); + + //获取累计储能放电量 + String s = KsolarUtils.getElectricity().split("_")[0]; + vo.setEnergyStorage(new BigDecimal(s).multiply(multiplier) // 乘以 0.1404 + .divide(new BigDecimal("1000"),2, RoundingMode.HALF_DOWN)); + + //获取累计发电 + vo.setPhotovoltaic(KsolarUtils.getYearAllEnergy()); + + //总数: + 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 BigDecimal calculateRatio(BigDecimal part, BigDecimal total) { + if (total.compareTo(BigDecimal.ZERO) == 0) { + throw new ArithmeticException("分母不能为零"); + } + return part.divide(total, 4, RoundingMode.HALF_UP); + } + + @Override + public PhotovoltaicPowerGenerationVO photovoltaicPowerGeneration(List<Integer> siteIds) { + PhotovoltaicPowerGenerationVO vo = new PhotovoltaicPowerGenerationVO(); + List<LocalDate> dates = new ArrayList<>(); + List<Double> values = new ArrayList<>(); + LocalDate today = LocalDate.now(); + ArrayList<Map<String, Object>> monthEnergy = KsolarUtils.getMonthEnergy(today.minusDays(7).toString().substring(0, 7), today.minusDays(1).toString().substring(0, 7)); + // 生成每天数据 + for (int i = 7; i >= 1; i--) {//升序 + LocalDate day = today.minusDays(i); + dates.add(day); + Map<String, Object> stringObjectMap = monthEnergy.stream().filter(e -> e.get("time").toString().contains(day.toString())).findFirst().orElse(null); + if(stringObjectMap!=null){ + values.add(Double.valueOf(stringObjectMap.get("value").toString())); + }else { + values.add(0.0); + } + } + vo.setDates(dates); + vo.setValues(values); + return vo; + } + + @Override + public ScreenTopVO top(List<Integer> siteIds) { + ScreenTopVO vo = new ScreenTopVO(); + + BigDecimal charge=new BigDecimal("0.00"); + BigDecimal carCharge=new BigDecimal("0.00"); + BigDecimal greenElectricity=new BigDecimal("0.00"); + if (siteIds!=null && !siteIds.isEmpty()){ + //获取充电量 + R<BigDecimal> r = chargingOrderClient.getSumDegreeBySiteIds(Arrays.asList(25,26)); + if (r.getCode()==200){ + charge=r.getData(); + } + //汽车放电量 + R<BigDecimal> r1 = otherClient.getCarDisCharge(); + if (r1.getCode()==200){ + carCharge=r1.getData(); + } + + + //累计绿电消纳电量 + R<BigDecimal> r2 = otherClient.getGreenElectricity(siteIds); + if (r2.getCode()==200){ + greenElectricity=r2.getData(); + } + + } + vo.setCarCharge(charge); + vo.setCarDisCharge(carCharge); + vo.setGreenElectricity(greenElectricity); + + //计算储能充电量 + String electricity = KsolarUtils.getElectricity(); + vo.setStorageCharge(new BigDecimal( electricity.split("_")[0])); + + vo.setPhotovoltaic(new BigDecimal(KsolarUtils.getAllEnergy(LocalDate.now().toString()))); + vo.setGreenElectricity(vo.getPhotovoltaic().multiply(new BigDecimal("0.94")).setScale(2, RoundingMode.HALF_UP)); + vo.setStorageDisCharge(new BigDecimal(electricity.split("_")[1])); + return vo; + } + + @Override + public void carportData(Integer parkingPlace, Integer remainPlace) { + otherClient.carportData(parkingPlace+"_"+remainPlace); + } + + @Override + public HashMap<String, Object> getCarportData() { + R<HashMap<String, Object>> r = otherClient.getCarportData(); + HashMap<String, Object> carportData = r.getData(); + int count = Integer.valueOf(carportData.get("parkingPlace").toString()) - Integer.valueOf(carportData.get("remainPlace").toString()); + carportData.put("useCarport",count); + return carportData; + } +} diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/util/KsolarUtils.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/util/KsolarUtils.java new file mode 100644 index 0000000..9442d71 --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/util/KsolarUtils.java @@ -0,0 +1,235 @@ +package com.ruoyi.jianguan.util; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDate; +import java.util.*; + + +/** + * 定时任务:储能放电情况 光伏发电情况 + */ +@Service +public class KsolarUtils { + + + private static String token; + + private static String accessToken; + + + private static List<String> stationIds= Arrays.asList("2025060710462417","2025060711331323","2025060715425437","2025060716010425"); + + + /** + * 获取今日总发电量 + * @param time + * @return + */ + public static Double getTodayEnergy(String time) { + try { + HttpRequest get = HttpUtil.createGet("http://111.230.136.62:8092/station/list/earn"); + get.header("Authorization", "Bearer "+token); + get.form("startDate", time); + HttpResponse execute = get.execute(); + String body = execute.body(); + JSONObject jsonObject = JSONObject.parseObject(body); + String code = jsonObject.get("code").toString(); + if(!"200".equals(code)){ + token = token(); + return getTodayEnergy(time); + } + Object data = jsonObject.get("data"); + JSONObject jsonObject1 = JSONObject.parseObject(data.toString()); + Double earn = jsonObject1.getDouble("dayGeneration"); + return earn; + } catch (Exception e) { + e.printStackTrace(); + token = token(); + return getTodayEnergy(time); + } + } + public static ArrayList<Map<String, Object>> getMonthEnergy(String time,String time1) { + ArrayList<Map<String, Object>> list = new ArrayList<>(); + try { + HttpRequest get = HttpUtil.createGet("http://111.230.136.62:8092/protocol/user/statistic/elec/chart"); + get.header("Authorization", "Bearer "+token); + get.form("stime", time); + get.form("attribId", "201"); + HttpResponse execute = get.execute(); + String body = execute.body(); + if(body.contains("code")){ + token = token(); + return getMonthEnergy(time,time1); + } + JSONArray jsonArray = JSONArray.parseArray(body); + for (Object o1 : jsonArray) { + HashMap<String, Object> stringObjectHashMap = new HashMap<>(); + JSONObject jsonObject = JSONObject.parseObject(o1.toString()) ; + stringObjectHashMap.put("time", jsonObject.getString("saveTime")); + stringObjectHashMap.put("value", jsonObject.getString("attribValue")); + list.add(stringObjectHashMap); + } + // 相同月份 + if(!time.equals(time1)){ + list.addAll(getMonthEnergy(time1,time1)); + } + + return list; + } catch (Exception e) { + e.printStackTrace(); + token = token(); + return getMonthEnergy(time,time1); + } + } + + + + /** + * 光伏累计 + * @return + */ + public static Double getAllEnergy(String time) { + try { + HttpRequest get = HttpUtil.createGet("http://111.230.136.62:8092/station/list/earn"); + get.header("Authorization", "Bearer "+token); + get.form("startDate", time); + HttpResponse execute = get.execute(); + String body = execute.body(); + JSONObject jsonObject = JSONObject.parseObject(body); + String code = jsonObject.get("code").toString(); + if(!"200".equals(code)){ + token = token(); + return getAllEnergy(time); + } + Object data = jsonObject.get("data"); + JSONObject jsonObject1 = JSONObject.parseObject(data.toString()); + Double earn = jsonObject1.getDouble("totalGeneration"); + return earn; + } catch (Exception e) { + e.printStackTrace(); + token = token(); + return getAllEnergy(time); + } + } + + + /** + * 光伏碳减排 + * @return + */ + public static BigDecimal getYearAllEnergy() { + Double yearAllEnergy = getYearAllEnergy(stationIds.get(0)); + Double yearAllEnergy1 = getYearAllEnergy(stationIds.get(1)); + Double yearAllEnergy2 = getYearAllEnergy(stationIds.get(2)); + Double yearAllEnergy3 = getYearAllEnergy(stationIds.get(3)); + double v = yearAllEnergy + yearAllEnergy1 + yearAllEnergy2 + yearAllEnergy3; + BigDecimal divide = new BigDecimal(v).multiply(new BigDecimal("0.1404")).divide(new BigDecimal("1000"), 2, RoundingMode.DOWN); + return divide; + } + + + + private static Double getYearAllEnergy(String stationId) { + try { + HttpRequest get = HttpUtil.createGet("http://111.230.136.62:8092/protocol/station/statistic/elec/chart"); + get.header("Authorization", "Bearer "+token); + get.form("stationId", stationId); + get.form("attribId", "202"); + get.form("stime",LocalDate.now().getYear()+"" ); + HttpResponse execute = get.execute(); + String body = execute.body(); + JSONArray jsonArray = JSONArray.parseArray(body); + Object o1 = jsonArray.get(0); + JSONObject jsonObject = JSONObject.parseObject(o1.toString()); + String code = jsonObject.get("attribValue").toString(); + Double earn = Double.valueOf(code); + return earn; + } catch (Exception e) { + e.printStackTrace(); + token = token(); + return getYearAllEnergy(stationId); + } + } + + + + public static String token() { + HttpRequest post = HttpUtil.createPost("http://111.230.136.62:8092/authentication/form"); + post.basicAuth("kstar","kstarSecret"); + post.form("username", "环岛光伏"); + post.form("password", "cR8GGwIXMI462A8Dfl9eXg=="); + HttpResponse execute = post.execute(); + String body = execute.body(); + JSONObject jsonObject = JSONObject.parseObject(body); + String token = jsonObject.getString("token"); + JSONObject jsonObject1 = JSONObject.parseObject(token); + String access_token = jsonObject1.getString("access_token"); + return access_token; + } + + + public static String getAccessToken(){ + HttpRequest post = HttpRequest.post("https://www.zsdcloud.cn:8443/openApi/getAccessToken.action?accessId=87bde117-1f29-4371-8d4d-82324d17ddc3"); + HttpResponse execute = post.execute(); + String body = execute.body(); + JSONObject jsonObject = JSONObject.parseObject(body); + return jsonObject.getString("result"); + } + + + /** + * 消纳数据 + * @return + */ + public static String getElectricity(){ + String valueTotal = "0"; + String value = "0"; + HttpRequest post = HttpRequest.post("https://www.zsdcloud.cn:8443/openApi/equipment/select.action"); + post.form("token", accessToken); + post.form("keyCode", "869916072003947"); + post.form("version", "V2"); + HttpResponse execute = post.execute(); + String body = execute.body(); + JSONObject jsonObject = JSONObject.parseObject(body); + String string = jsonObject.get("statusCode").toString(); + if(!string.equals("200")){ + accessToken = getAccessToken(); + return getElectricity(); + + } + String string1 = jsonObject.getString("result"); + JSONObject jsonObject1 = JSONObject.parseObject(string1); + String realInfo = jsonObject1.getString("childList"); + JSONArray jsonArray = JSONArray.parseArray(realInfo); + for (Object o : jsonArray) { + JSONObject jsonObject2 = JSONObject.parseObject(o.toString()); + String string2 = jsonObject2.get("valueList").toString(); + JSONArray jsonArray1 = JSONArray.parseArray(string2); + for (Object o1 : jsonArray1) { + JSONObject jsonObject3 = JSONObject.parseObject(o1.toString()); + if(jsonObject3.get("Name").toString().equals("系统累计充电量")){ + valueTotal= jsonObject3.get("Value").toString(); + } + if(jsonObject3.get("Name").toString().equals("系统累计放电量")){ + value= jsonObject3.get("Value").toString(); + } + } + } + return valueTotal+"_"+value; + } + public static void main(String[] args) throws Exception { + String electricity = getElectricity(); + System.out.println(electricity); + } + + + +} \ No newline at end of file diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/EmissionReductionVO.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/EmissionReductionVO.java new file mode 100644 index 0000000..8b42f76 --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/EmissionReductionVO.java @@ -0,0 +1,27 @@ +package com.ruoyi.jianguan.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class EmissionReductionVO { + @ApiModelProperty("累计光伏发电二氧化碳减排量(吨)") + private BigDecimal photovoltaic = new BigDecimal("1.39"); + @ApiModelProperty("累计光伏发电二氧化碳减排量(占比率)") + private BigDecimal photovoltaicRate ; + + @ApiModelProperty("累计储能二氧化碳减排量(吨)") + private BigDecimal energyStorage ; + @ApiModelProperty("累计储能二氧化碳减排量(占比率)") + private BigDecimal energyStorageRate ; + + @ApiModelProperty("累计充电二氧化碳减排量(吨)") + private BigDecimal charge; + @ApiModelProperty("累计充电二氧化碳减排量(占比率)") + private BigDecimal chargeRate ; + + @ApiModelProperty("总计二氧化碳减排量(吨)") + private BigDecimal total ; +} diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/EnergyStorageDischargeVO.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/EnergyStorageDischargeVO.java new file mode 100644 index 0000000..c255949 --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/EnergyStorageDischargeVO.java @@ -0,0 +1,18 @@ +package com.ruoyi.jianguan.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class EnergyStorageDischargeVO { + @ApiModelProperty("储能配置") + private Integer config=115; + @ApiModelProperty("今日储能") + private BigDecimal todayStorage; + @ApiModelProperty("今日放能") + private BigDecimal todayDischarge; + + +} diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/PhotovoltaicAndConsumptionVO.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/PhotovoltaicAndConsumptionVO.java new file mode 100644 index 0000000..ff22c2d --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/PhotovoltaicAndConsumptionVO.java @@ -0,0 +1,20 @@ +package com.ruoyi.jianguan.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class PhotovoltaicAndConsumptionVO { + @ApiModelProperty("光伏面积") + private Integer area = 3593; + @ApiModelProperty("装机容量") + private BigDecimal capacity = new BigDecimal("759.52"); + @ApiModelProperty("今日已发电") + private BigDecimal todayGenerateElectricity=new BigDecimal("0"); + + @ApiModelProperty("今日绿电消纳值") + private BigDecimal greenElectricityToday=new BigDecimal("0.00"); + +} diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/PhotovoltaicPowerGenerationVO.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/PhotovoltaicPowerGenerationVO.java new file mode 100644 index 0000000..9f0340f --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/PhotovoltaicPowerGenerationVO.java @@ -0,0 +1,15 @@ +package com.ruoyi.jianguan.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDate; +import java.util.List; + +@Data +public class PhotovoltaicPowerGenerationVO { + @ApiModelProperty("日期") + private List<LocalDate> dates; + @ApiModelProperty("数据") + private List<Double> values; +} diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/ScreenStorageConfigVO.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/ScreenStorageConfigVO.java new file mode 100644 index 0000000..93ae345 --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/ScreenStorageConfigVO.java @@ -0,0 +1,37 @@ +package com.ruoyi.jianguan.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDate; + +@Data +public class ScreenStorageConfigVO { + /** + * 系统建设日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate systemCreateTime; + + /** + * 储能放电量 随机增长,每日不超过100度 + */ + private BigDecimal storageDisCharge; + + /** + * 最后一次更改时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate lastUpdated; + + /** + * 储能放电情况 今日放能 + */ + private BigDecimal todayDischarge; + + /** + * 储能放电情况 今日储能 + */ + private BigDecimal todayStorage; +} diff --git a/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/ScreenTopVO.java b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/ScreenTopVO.java new file mode 100644 index 0000000..c99f4c8 --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/java/com/ruoyi/jianguan/vo/ScreenTopVO.java @@ -0,0 +1,24 @@ +package com.ruoyi.jianguan.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class ScreenTopVO { + @ApiModelProperty("汽车充电量") + private BigDecimal carCharge; + @ApiModelProperty("汽车放电量") + private BigDecimal carDisCharge; + @ApiModelProperty("光伏发电量") + private BigDecimal photovoltaic; + @ApiModelProperty("光伏用电量") + private BigDecimal greenElectricity; + @ApiModelProperty("储能充电量") + private BigDecimal storageCharge; + @ApiModelProperty("储能放电量") + private BigDecimal storageDisCharge; + + +} diff --git a/ruoyi-service/ruoyi-jianguan/src/main/resources/mapper/jianguan/TScreenContentMapper.xml b/ruoyi-service/ruoyi-jianguan/src/main/resources/mapper/jianguan/TScreenContentMapper.xml new file mode 100644 index 0000000..de64b9f --- /dev/null +++ b/ruoyi-service/ruoyi-jianguan/src/main/resources/mapper/jianguan/TScreenContentMapper.xml @@ -0,0 +1,40 @@ +<?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.jianguan.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 + sum(car_discharge) + FROM t_screen_content + WHERE + site_id in + <foreach item="item" index="index" collection="siteIds" open="(" separator="," close=")"> + #{item} + </foreach> + </select> + <select id="getGreenElectricity" resultType="java.math.BigDecimal"> + select + sum(green_electricity) + FROM t_screen_content + WHERE + site_id in + <foreach item="item" index="index" collection="siteIds" open="(" separator="," close=")"> + #{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> diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java index 9fce2fd..6c495ee 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java @@ -2396,9 +2396,12 @@ /** * 充电桩数据大屏 获取站点集合中总的充电量 */ + @ResponseBody @GetMapping("/getSumDegreeBySiteIds") public R<BigDecimal> getSumDegreeBySiteIds(@RequestParam("siteIds") List<Integer> SiteIds){ - return R.ok(chargingOrderService.getSumDegreeBySiteIds(SiteIds)); + Double sumDegreeBySiteIds = chargingOrderService.getSumDegreeBySiteIds(SiteIds); + + return R.ok(new BigDecimal(sumDegreeBySiteIds)); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TVipOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TVipOrderController.java index 806ec5a..9d44070 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TVipOrderController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TVipOrderController.java @@ -30,6 +30,7 @@ import org.apache.poi.ss.usermodel.Workbook; import org.omg.CORBA.PRIVATE_MEMBER; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; @@ -59,7 +60,7 @@ private TVipOrderService vipOrderService; @Resource private AppUserClient appUserClient; - @Resource + @Autowired private OtherClient otherClient; diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java index 3d07126..057e170 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java @@ -147,7 +147,7 @@ List<OrderCountByDate> countOrdersByDate(@Param("startTime")LocalDateTime startTime, @Param("endTime")LocalDateTime endTime,@Param("gunIds")List<Integer> gunIds); - BigDecimal getSumDegreeBySiteIds(@Param("siteIds") List<Integer> siteIds); + Double getSumDegreeBySiteIds(@Param("siteIds") List<Integer> siteIds); /** diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java index 4c467bc..801f023 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java @@ -329,7 +329,7 @@ */ R<StatisticsOfBatteryVO> getStatisticsOfBattery(); - BigDecimal getSumDegreeBySiteIds(List<Integer> siteIds); + Double getSumDegreeBySiteIds(List<Integer> siteIds); /** * 获取启动失败且时间超过1小时的订单 diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java index 2eb375b..3f98910 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java @@ -4324,9 +4324,10 @@ } @Override - public BigDecimal getSumDegreeBySiteIds(List<Integer> siteIds) { - - return this.baseMapper.getSumDegreeBySiteIds(siteIds); + public Double getSumDegreeBySiteIds(List<Integer> siteIds) { + Double sumDegreeBySiteIds = this.baseMapper.getSumDegreeBySiteIds(siteIds); + + return sumDegreeBySiteIds; } diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml index 1f434b9..c937271 100644 --- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml +++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml @@ -1765,15 +1765,7 @@ ORDER BY DATE(create_time, '%m/%d') ASC </select> - <select id="getSumDegreeBySiteIds" resultType="java.math.BigDecimal"> - 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> - </select> <select id="findFailedStartupOrder" resultType="com.ruoyi.order.api.model.TChargingOrder"> SELECT @@ -1826,4 +1818,17 @@ FROM t_charging_order_refund) </select> + + <select id="getSumDegreeBySiteIds" resultType="java.lang.Double"> + SELECT IFNULL(SUM(t2.charging_capacity), 0.0) AS sumDegreeBySiteIds + 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 + <if test="siteIds != null and siteIds.size() > 0"> + AND t1.site_id IN + <foreach collection="siteIds" item="item" open="(" separator="," close=")"> + #{item} + </foreach> + </if> + </select> </mapper> diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RegionController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RegionController.java index 2513b90..56faece 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RegionController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RegionController.java @@ -6,13 +6,20 @@ import com.ruoyi.common.security.annotation.Logical; import com.ruoyi.common.security.annotation.RequiresPermissions; import com.ruoyi.other.api.domain.Region; +import com.ruoyi.other.api.domain.TSystemConfiguration; +import com.ruoyi.other.mapper.TScreenContentMapper; import com.ruoyi.other.service.IRegionService; +import com.ruoyi.other.service.TScreenContentService; +import com.ruoyi.other.service.TSystemConfigurationService; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; /** @@ -25,6 +32,12 @@ @Resource private IRegionService regionService; + + @Resource + private TSystemConfigurationService tSystemConfigurationService; + + @Resource + private TScreenContentMapper screenContentMapper; @@ -50,4 +63,43 @@ Region list = regionService.getOne(new LambdaQueryWrapper<Region>().eq(Region::getCode, code)); return R.ok(list); } + + @ResponseBody + @GetMapping("/getTSystemConfiguration") + public R<List<TSystemConfiguration>> getTSystemConfiguration(){ + List<TSystemConfiguration> list = tSystemConfigurationService.list(new LambdaQueryWrapper<TSystemConfiguration>().in(TSystemConfiguration::getType, 4, 5)); + return R.ok(list); + } + + + @GetMapping(value = "/getCarDisCharge") + @ResponseBody + public R<BigDecimal> getCarDisCharge(){ + BigDecimal carDisCharge = screenContentMapper.getCarDisCharge(Arrays.asList(25,26)); + return R.ok(carDisCharge); + } + + @PostMapping(value = "/getGreenElectricity") + @ResponseBody + public R<BigDecimal> getGreenElectricity(@RequestBody List<Integer> siteIds){ + BigDecimal greenElectricity = screenContentMapper.getGreenElectricity(siteIds); + return R.ok(greenElectricity); + } + + + @PostMapping(value = "/carportData") + @ResponseBody + public void carportData(String parkingPlace){ + String[] split = parkingPlace.split("_"); + Integer parkingPlace1 = Integer.parseInt(split[0]); + Integer remainPlace = Integer.parseInt(split[1]); + screenContentMapper.carportData(parkingPlace1,remainPlace); + } + + @GetMapping(value = "/getCarportData") + @ResponseBody + public R<HashMap<String, Object>> getCarportData(){ + HashMap<String, Object> carportData = screenContentMapper.getCarportData(); + return R.ok(carportData); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java index bee6136..4dfab3a 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TScreenContentServiceImpl.java @@ -47,8 +47,6 @@ @Resource private ChargingOrderClient chargingOrderClient; - @Resource - private TSystemConfigurationMapper systemConfigurationMapper; @Override public EmissionReductionVO emissionReduction(List<Integer> siteIds) { -- Gitblit v1.7.1