mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 03:09:48 +08:00
update 首页数据大屏
This commit is contained in:
@@ -8,6 +8,7 @@ import com.jsowell.pile.dto.IndexQueryDTO;
|
||||
import com.jsowell.pile.service.MemberBasicInfoService;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import com.jsowell.pile.service.PileConnectorInfoService;
|
||||
import com.jsowell.pile.service.PileStationInfoService;
|
||||
import com.jsowell.pile.vo.web.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -39,6 +40,9 @@ public class indexController extends BaseController {
|
||||
@Autowired
|
||||
private PileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private PileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
@PostMapping("/getGeneralSituation")
|
||||
public RestApiResponse<?> getGeneralSituation(@RequestBody IndexQueryDTO dto) {
|
||||
logger.info("首页基础数据查询 param:{}", JSON.toJSONString(dto));
|
||||
@@ -129,6 +133,40 @@ public class indexController extends BaseController {
|
||||
overviewVO.setTotalElectricity(generalSituation.getTotalChargingDegree());
|
||||
overviewVO.setTotalPiles(Long.valueOf(generalSituation.getTotalPileQuantity()));
|
||||
overviewVO.setTotalStations(pileStationInfoService.countTotalStations());
|
||||
// 新增字段
|
||||
overviewVO.setDailyNewUsers(memberBasicInfoService.countTodayNewMembers());
|
||||
java.math.BigDecimal todayAmount = pileBasicInfoService.getTodayTransactionAmount();
|
||||
overviewVO.setTodayTransactionAmount(todayAmount != null ? todayAmount.toPlainString() : "0");
|
||||
java.math.BigDecimal todayElec = pileBasicInfoService.getTodayElectricity();
|
||||
overviewVO.setTodayElectricity(todayElec != null ? todayElec.toPlainString() : "0");
|
||||
java.math.BigDecimal monthlyAvg = pileBasicInfoService.getMonthlyAvgElectricity();
|
||||
overviewVO.setMonthlyAvgElectricity(monthlyAvg != null ? monthlyAvg.toPlainString() : "0");
|
||||
overviewVO.setTotalGuns(pileConnectorInfoService.countTotalConnectors());
|
||||
overviewVO.setOnlinePiles(pileConnectorInfoService.countOnlinePiles());
|
||||
overviewVO.setOnlineStations(pileConnectorInfoService.countDcPiles());
|
||||
overviewVO.setOnlineGuns(pileConnectorInfoService.countAcPiles());
|
||||
// 节能减排计算
|
||||
java.math.BigDecimal totalElecKwh = new java.math.BigDecimal(generalSituation.getTotalChargingDegree());
|
||||
// 累计碳减排 (吨) = 累计充电量(kWh) × 0.5306 / 1000
|
||||
java.math.BigDecimal carbonKg = totalElecKwh.multiply(new java.math.BigDecimal("0.5306"));
|
||||
java.math.BigDecimal carbonTon = carbonKg.divide(new java.math.BigDecimal("1000"), 2, java.math.RoundingMode.HALF_UP);
|
||||
overviewVO.setCarbonReduction(carbonTon.toPlainString());
|
||||
// 单次充电平均减碳量 (kg) = 累计碳减排量(kg) / 总订单数
|
||||
Long totalOrderCount = overviewVO.getTotalOrders();
|
||||
if (totalOrderCount != null && totalOrderCount > 0) {
|
||||
java.math.BigDecimal avgCarbon = carbonKg.divide(new java.math.BigDecimal(totalOrderCount), 2, java.math.RoundingMode.HALF_UP);
|
||||
overviewVO.setAvgCarbonPerOrder(avgCarbon.toPlainString());
|
||||
} else {
|
||||
overviewVO.setAvgCarbonPerOrder("0");
|
||||
}
|
||||
// 节约燃油 (升) = 累计充电量(kWh) × 8 / 15
|
||||
java.math.BigDecimal fuelSaved = totalElecKwh.multiply(new java.math.BigDecimal("8"))
|
||||
.divide(new java.math.BigDecimal("15"), 2, java.math.RoundingMode.HALF_UP);
|
||||
overviewVO.setFuelSaved(fuelSaved.toPlainString());
|
||||
// 相当于替代标准煤 (吨) = 累计充电量(kWh) × 0.000404
|
||||
java.math.BigDecimal coalSaved = totalElecKwh.multiply(new java.math.BigDecimal("0.000404"))
|
||||
.setScale(2, java.math.RoundingMode.HALF_UP);
|
||||
overviewVO.setStandardCoalSaved(coalSaved.toPlainString());
|
||||
response = new RestApiResponse<>(overviewVO);
|
||||
} catch (Exception e) {
|
||||
logger.error("大数据平台总览数据查询错误", e);
|
||||
|
||||
Reference in New Issue
Block a user