From d54f09c8ed456b431d386ec3752306f52eec607c Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期五, 01 十一月 2024 16:14:34 +0800
Subject: [PATCH] merge

---
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java |   44 +++++++++++++++++++++++++-------------------
 1 files changed, 25 insertions(+), 19 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 0ce1585..06a4e3f 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
@@ -18,6 +18,7 @@
 import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
 import com.ruoyi.chargingPile.service.*;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.DateUtils;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.core.web.page.PageInfo;
@@ -122,12 +123,14 @@
 		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) {
 			// 当前时间属于那个阶段 取哪个阶段的电价
-			if(LocalTime.now().isAfter(LocalTime.parse(tAccountingStrategyDetail.getStartTime())) && LocalTime.now().isBefore(LocalTime.parse(tAccountingStrategyDetail.getEndTime()))){
+			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()){
 					siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
@@ -168,9 +171,11 @@
 		Site byId = siteService.getById(one.getSiteId());
 		TAccountingStrategy byId1 = accountingStrategyService.getById(byId.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) {
 			// 当前时间属于那个阶段 取哪个阶段的电价
-			if(LocalTime.now().isAfter(LocalTime.parse(tAccountingStrategyDetail.getStartTime())) && LocalTime.now().isBefore(LocalTime.parse(tAccountingStrategyDetail.getEndTime()))){
+			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()){
 					siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
@@ -224,17 +229,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);
 
 			//利用率
@@ -290,14 +300,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);
-		}
+
 
 
 
@@ -311,6 +314,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) {
@@ -320,7 +326,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