From a4ff377b75e98b199d99a7c97f167df6a7904bb7 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 01 十一月 2024 19:50:09 +0800
Subject: [PATCH] bug修改
---
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java | 117 +++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 75 insertions(+), 42 deletions(-)
diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
index dbd0aa4..f45575b 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
@@ -1,10 +1,16 @@
package com.ruoyi.chargingPile.controller;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.feignClient.AppUserVipDetailClient;
import com.ruoyi.account.api.model.TAppUser;
+import com.ruoyi.account.api.model.TAppUserVipDetail;
+import com.ruoyi.account.api.vo.GetAppUserVipDetail;
import com.ruoyi.chargingPile.api.dto.GetSiteListDTO;
import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient;
import com.ruoyi.chargingPile.api.model.*;
@@ -41,6 +47,7 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -100,7 +107,8 @@
private TokenService tokenService;
@Resource
private AppUserClient appUserClient;
-
+ @Resource
+ private AppUserVipDetailClient vipDetailClient;
/**
* 根据站点id 查询所有充电桩
@@ -123,8 +131,8 @@
SiteInfoVO siteInfoVO = new SiteInfoVO();
TChargingGun chargingGun = chargingGunService.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getFullNumber, number));
TChargingPile one = chargingPileService.getById(chargingGun.getChargingPileId());
- Site byId = siteService.getById(one.getSiteId());
- TAccountingStrategy byId1 = accountingStrategyService.getById(byId.getAccountingStrategyId());
+ Site byId = siteService.getById(chargingGun.getSiteId());
+ TAccountingStrategy byId1 = accountingStrategyService.getById(chargingGun.getAccountingStrategyId());
List<TAccountingStrategyDetail> list = accountingStrategyDetailService.lambdaQuery().eq(TAccountingStrategyDetail::getAccountingStrategyId, byId1.getId()).list();
list.stream().filter(item -> "00:00".equals(item.getEndTime())).forEach(item -> item.setEndTime("23:59:59"));
for (TAccountingStrategyDetail tAccountingStrategyDetail : list) {
@@ -132,22 +140,28 @@
if(DateUtils.string2LocalTime(tAccountingStrategyDetail.getStartTime() + ":00").compareTo(LocalTime.now()) <= 0
&& DateUtils.string2LocalTime(tAccountingStrategyDetail.getEndTime() + ("23:59:59".equals(tAccountingStrategyDetail.getEndTime())?"":":00")).compareTo(LocalTime.now()) > 0){
siteInfoVO.setElectrovalence(tAccountingStrategyDetail.getElectrovalence().add(tAccountingStrategyDetail.getServiceCharge()).setScale(4, BigDecimal.ROUND_HALF_UP));
- if(null != byId1.getDiscount()){
+ // 获取当前登录用户id
+ Long userId = tokenService.getLoginUserApplet().getUserId();
+ // 根据id查询用户信息
+ TAppUser appUser = appUserClient.getUserById(userId).getData();
+ if(Objects.nonNull(byId1.getDiscount())){
siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
- }else{
- // 获取当前登录用户id
- Long userId = tokenService.getLoginUserApplet().getUserId();
- // 根据id查询用户信息
- TAppUser appUser = appUserClient.getUserById(userId).getData();
- if(Objects.nonNull(appUser)){
- TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
+ }else {
+ siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
+ }
+ if(Objects.nonNull(appUser)){
+// TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
+ GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
+ getAppUserVipDetail.setAppUserId(userId);
+ getAppUserVipDetail.setVipId(appUser.getVipId());
+ R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
+ TAppUserVipDetail data1 = appUserVipDetail.getData();
+ if(Objects.nonNull(data1)){
+ String vipJson = data1.getVipJson();
+ TVip vip = JSON.parseObject(vipJson, TVip.class);
if(Objects.nonNull(vip) && vip.getType() == 2){
siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence()));
- }else {
- siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence());
}
- }else {
- siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence());
}
}
}
@@ -177,25 +191,43 @@
if(DateUtils.string2LocalTime(tAccountingStrategyDetail.getStartTime() + ":00").compareTo(LocalTime.now()) <= 0
&& DateUtils.string2LocalTime(tAccountingStrategyDetail.getEndTime() + ("23:59:59".equals(tAccountingStrategyDetail.getEndTime())?"":":00")).compareTo(LocalTime.now()) > 0){
siteInfoVO.setElectrovalence(tAccountingStrategyDetail.getElectrovalence().add(tAccountingStrategyDetail.getServiceCharge()).setScale(4, BigDecimal.ROUND_HALF_UP));
- if(null != byId1.getDiscount()){
+ // 获取当前登录用户id
+ Long userId = tokenService.getLoginUserApplet().getUserId();
+ // 根据id查询用户信息
+ TAppUser appUser = appUserClient.getUserById(userId).getData();
+ if(Objects.nonNull(byId1.getDiscount())){
siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
- }else{
- // 获取当前登录用户id
- Long userId = tokenService.getLoginUserApplet().getUserId();
- // 根据id查询用户信息
- TAppUser appUser = appUserClient.getUserById(userId).getData();
- if(Objects.nonNull(appUser)){
- TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
+ }else {
+ siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
+ }
+ if(Objects.nonNull(appUser)){
+// TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
+ GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
+ getAppUserVipDetail.setAppUserId(userId);
+ getAppUserVipDetail.setVipId(appUser.getVipId());
+ R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
+ TAppUserVipDetail data1 = appUserVipDetail.getData();
+ if(Objects.nonNull(data1)){
+ String vipJson = data1.getVipJson();
+ TVip vip = JSON.parseObject(vipJson, TVip.class);
if(Objects.nonNull(vip) && vip.getType() == 2){
siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence()));
- }else {
- siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence());
}
- }else {
- siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence());
}
}
}
+ }
+ List<TVip> vips = vipClient.getVipList().getData();
+ if(!CollectionUtils.isEmpty(vips)){
+ TVip tVip = vips.get(0);
+ JSONArray objects = JSONArray.parseArray(tVip.getCoupon());
+ Integer num = 0;
+ for (Object object : objects) {
+ JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(object));
+ Integer number1 = jsonObject.getInteger("number");
+ num += number1;
+ }
+ siteInfoVO.setCouponCount(num);
}
siteInfoVO.setChargingPileId(one.getId());
siteInfoVO.setName(byId.getName());
@@ -229,17 +261,22 @@
siteList.setPageSize(99999);
PageInfo<GetSiteListDTO> list = siteService.getSiteList(siteList);
for (GetSiteListDTO record : list.getRecords()) {
- Long count = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 1).eq(TChargingGun::getStatus, new int[]{3, 4, 5, 6}).count();
+ List<Integer> c1 = new ArrayList<>();
+ c1.add(3);
+ c1.add(4);
+ c1.add(5);
+ c1.add(6);
+ Long count = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 1).eq(TChargingGun::getStatus, 2).count();
record.setC1(count);
- Long count1 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 1).eq(TChargingGun::getStatus, 2).count();
+ Long count1 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 1).count();
record.setC2(count1);
- Long count2 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 2).eq(TChargingGun::getStatus, new int[]{3, 4, 5, 6}).count();
+ Long count2 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 2).eq(TChargingGun::getStatus, 2).count();
record.setK1(count2);
- Long count3 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 2).eq(TChargingGun::getStatus, 2).count();
+ Long count3 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 2).count();
record.setK2(count3);
- Long count4 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 3).eq(TChargingGun::getStatus, new int[]{3, 4, 5, 6}).count();
+ Long count4 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 3).eq(TChargingGun::getStatus, 2).count();
record.setM1(count4);
- Long count5 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 3).eq(TChargingGun::getStatus, 2).count();
+ Long count5 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 3).count();
record.setM2(count5);
//利用率
@@ -295,14 +332,7 @@
@ApiOperation(value = "获取该充电站的利用率", tags = {"管理后台-数据分析-电站分析"})
public R getPercentByCityCode(@RequestBody ChargingPercentProvinceDto chargingPercentProvinceDto){
- if (chargingPercentProvinceDto.getDate1()==null){
- LocalDate today = LocalDate.now();
- LocalDate lastMonth = today.minusMonths(1);
- LocalDate firstDayOfLastMonth = lastMonth.withDayOfMonth(1);
- LocalDate lastDayOfLastMonth =lastMonth.withDayOfMonth(lastMonth.lengthOfMonth());
- chargingPercentProvinceDto.setDate1(firstDayOfLastMonth);
- chargingPercentProvinceDto.setDate2(lastDayOfLastMonth);
- }
+
@@ -316,6 +346,9 @@
List<GetSiteListDTO> records = siteService.getSiteList(siteList).getRecords();
List<Integer> collect = records.stream().map(GetSiteListDTO::getId).collect(Collectors.toList());
// 通过时间段获取和充电桩id获取各个充电站的充电订单
+ if (chargingPercentProvinceDto.getDate1().equals(chargingPercentProvinceDto.getDate2())){
+ chargingPercentProvinceDto.setDate2(chargingPercentProvinceDto.getDate1().plusDays(1));
+ }
List<ChargingOrderGroup> data = chargingOrderClient.getBySiteIdAndTime(chargingPercentProvinceDto).getData();
// 计算利用率展示
for (ChargingOrderGroup datum : data) {
@@ -325,7 +358,7 @@
bigDecimal1 = bigDecimal1.add(chargingPile.getRatedPower());
}
- long daysBetween = ChronoUnit.DAYS.between(chargingPercentProvinceDto.getDate1(), chargingPercentProvinceDto.getDate2()) + 1;
+ long daysBetween = ChronoUnit.DAYS.between(chargingPercentProvinceDto.getDate1(), chargingPercentProvinceDto.getDate2());
BigDecimal multiply = bigDecimal1.multiply(new BigDecimal("24")).multiply(BigDecimal.valueOf(daysBetween));
//得到利用率
BigDecimal divide = datum.getChargingCapacity().divide(multiply, 0, BigDecimal.ROUND_HALF_UP);
--
Gitblit v1.7.1