mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-13 03:39:55 +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);
|
||||
|
||||
@@ -147,4 +147,11 @@ public interface MemberBasicInfoMapper {
|
||||
* @return 会员总数
|
||||
*/
|
||||
Long countTotalMembers();
|
||||
|
||||
/**
|
||||
* 统计今日新增会员数
|
||||
*
|
||||
* @return 今日新增会员数
|
||||
*/
|
||||
Long countTodayNewMembers();
|
||||
}
|
||||
|
||||
@@ -179,4 +179,25 @@ public interface PileBasicInfoMapper {
|
||||
List<PileDetailInfoVO> getPileDetailInfoList(String stationId);
|
||||
|
||||
int movePile2AnotherStation(ReplaceMerchantStationDTO dto);
|
||||
|
||||
/**
|
||||
* 查询当日累计交易金额
|
||||
*
|
||||
* @return 当日交易金额
|
||||
*/
|
||||
java.math.BigDecimal getTodayTransactionAmount();
|
||||
|
||||
/**
|
||||
* 查询当日充电电量
|
||||
*
|
||||
* @return 当日充电电量
|
||||
*/
|
||||
java.math.BigDecimal getTodayElectricity();
|
||||
|
||||
/**
|
||||
* 查询本月日均充电电量
|
||||
*
|
||||
* @return 月均充电电量
|
||||
*/
|
||||
java.math.BigDecimal getMonthlyAvgElectricity();
|
||||
}
|
||||
|
||||
@@ -150,4 +150,32 @@ public interface PileConnectorInfoMapper {
|
||||
* @return
|
||||
*/
|
||||
List<String> queryAbnormalDeviceCount(String stationId);
|
||||
|
||||
/**
|
||||
* 统计充电枪总数
|
||||
*
|
||||
* @return 充电枪总数
|
||||
*/
|
||||
Long countTotalConnectors();
|
||||
|
||||
/**
|
||||
* 统计在线充电桩数量(枪口状态不为离网和故障的桩)
|
||||
*
|
||||
* @return 在线充电桩数量
|
||||
*/
|
||||
Long countOnlinePiles();
|
||||
|
||||
/**
|
||||
* 统计直流充电桩数量(快充)
|
||||
*
|
||||
* @return 直流充电桩数量
|
||||
*/
|
||||
Long countDcPiles();
|
||||
|
||||
/**
|
||||
* 统计交流充电桩数量(慢充)
|
||||
*
|
||||
* @return 交流充电桩数量
|
||||
*/
|
||||
Long countAcPiles();
|
||||
}
|
||||
|
||||
@@ -189,4 +189,11 @@ public interface MemberBasicInfoService {
|
||||
* @return 会员总数
|
||||
*/
|
||||
Long countTotalMembers();
|
||||
|
||||
/**
|
||||
* 统计今日新增会员数
|
||||
*
|
||||
* @return 今日新增会员数
|
||||
*/
|
||||
Long countTodayNewMembers();
|
||||
}
|
||||
|
||||
@@ -258,4 +258,25 @@ public interface PileBasicInfoService {
|
||||
* @return
|
||||
*/
|
||||
int movePile2AnotherStation(ReplaceMerchantStationDTO dto);
|
||||
|
||||
/**
|
||||
* 查询当日累计交易金额
|
||||
*
|
||||
* @return 当日交易金额
|
||||
*/
|
||||
java.math.BigDecimal getTodayTransactionAmount();
|
||||
|
||||
/**
|
||||
* 查询当日充电电量
|
||||
*
|
||||
* @return 当日充电电量
|
||||
*/
|
||||
java.math.BigDecimal getTodayElectricity();
|
||||
|
||||
/**
|
||||
* 查询本月日均充电电量
|
||||
*
|
||||
* @return 月均充电电量
|
||||
*/
|
||||
java.math.BigDecimal getMonthlyAvgElectricity();
|
||||
}
|
||||
|
||||
@@ -191,4 +191,32 @@ public interface PileConnectorInfoService {
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getConnectorStatusNum(List<String> stationIds, String connectorStatus);
|
||||
|
||||
/**
|
||||
* 统计充电枪总数
|
||||
*
|
||||
* @return 充电枪总数
|
||||
*/
|
||||
Long countTotalConnectors();
|
||||
|
||||
/**
|
||||
* 统计在线充电桩数量
|
||||
*
|
||||
* @return 在线充电桩数量
|
||||
*/
|
||||
Long countOnlinePiles();
|
||||
|
||||
/**
|
||||
* 统计直流充电桩数量(快充)
|
||||
*
|
||||
* @return 直流充电桩数量
|
||||
*/
|
||||
Long countDcPiles();
|
||||
|
||||
/**
|
||||
* 统计交流充电桩数量(慢充)
|
||||
*
|
||||
* @return 交流充电桩数量
|
||||
*/
|
||||
Long countAcPiles();
|
||||
}
|
||||
|
||||
@@ -920,4 +920,9 @@ public class MemberBasicInfoServiceImpl implements MemberBasicInfoService {
|
||||
return memberBasicInfoMapper.countTotalMembers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTodayNewMembers() {
|
||||
return memberBasicInfoMapper.countTodayNewMembers();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1633,4 +1633,19 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
||||
.build();
|
||||
pileTransactionService.doCreatePileTransaction(transactionDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.math.BigDecimal getTodayTransactionAmount() {
|
||||
return pileBasicInfoMapper.getTodayTransactionAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.math.BigDecimal getTodayElectricity() {
|
||||
return pileBasicInfoMapper.getTodayElectricity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.math.BigDecimal getMonthlyAvgElectricity() {
|
||||
return pileBasicInfoMapper.getMonthlyAvgElectricity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1304,4 +1304,24 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
Set<String> set = new HashSet<>(list);
|
||||
return set.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTotalConnectors() {
|
||||
return pileConnectorInfoMapper.countTotalConnectors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countOnlinePiles() {
|
||||
return pileConnectorInfoMapper.countOnlinePiles();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countDcPiles() {
|
||||
return pileConnectorInfoMapper.countDcPiles();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countAcPiles() {
|
||||
return pileConnectorInfoMapper.countAcPiles();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +38,68 @@ public class BigDataOverviewVO {
|
||||
* 充电站数量
|
||||
*/
|
||||
private Long totalStations;
|
||||
|
||||
/**
|
||||
* 日增用户数
|
||||
*/
|
||||
private Long dailyNewUsers;
|
||||
|
||||
/**
|
||||
* 当日累计交易金额(元)
|
||||
*/
|
||||
private String todayTransactionAmount;
|
||||
|
||||
/**
|
||||
* 今日充电电量(kWh)
|
||||
*/
|
||||
private String todayElectricity;
|
||||
|
||||
/**
|
||||
* 月均充电电量(kWh)
|
||||
*/
|
||||
private String monthlyAvgElectricity;
|
||||
|
||||
/**
|
||||
* 充电枪总数
|
||||
*/
|
||||
private Long totalGuns;
|
||||
|
||||
/**
|
||||
* 在线充电桩数量
|
||||
*/
|
||||
private Long onlinePiles;
|
||||
|
||||
/**
|
||||
* 直流充电桩数量
|
||||
*/
|
||||
private Long onlineStations;
|
||||
|
||||
/**
|
||||
* 交流充电桩数量
|
||||
*/
|
||||
private Long onlineGuns;
|
||||
|
||||
/**
|
||||
* 累计碳减排量(吨)
|
||||
* = 累计充电量(kWh) × 0.5306 / 1000
|
||||
*/
|
||||
private String carbonReduction;
|
||||
|
||||
/**
|
||||
* 单次充电平均减碳量(kg)
|
||||
* = 累计碳减排量(kg) / 总订单数
|
||||
*/
|
||||
private String avgCarbonPerOrder;
|
||||
|
||||
/**
|
||||
* 节约燃油(升)
|
||||
* = 累计充电量(kWh) × 8 / 15
|
||||
*/
|
||||
private String fuelSaved;
|
||||
|
||||
/**
|
||||
* 相当于替代标准煤(吨)
|
||||
* = 累计充电量(kWh) × 0.000404
|
||||
*/
|
||||
private String standardCoalSaved;
|
||||
}
|
||||
|
||||
@@ -342,4 +342,8 @@
|
||||
<select id="countTotalMembers" resultType="java.lang.Long">
|
||||
select count(*) from member_basic_info where del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="countTodayNewMembers" resultType="java.lang.Long">
|
||||
select count(*) from member_basic_info where del_flag = '0' and DATE(create_time) = CURDATE()
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -496,4 +496,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{pileId,jdbcType=BIGINT}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="getTodayTransactionAmount" resultType="java.math.BigDecimal">
|
||||
select ifnull(sum(t1.total_amount), 0)
|
||||
from settle_order_report t1
|
||||
where t1.del_flag = '0'
|
||||
and t1.trade_date = DATE_FORMAT(CURDATE(), '%Y-%m-%d')
|
||||
</select>
|
||||
|
||||
<select id="getTodayElectricity" resultType="java.math.BigDecimal">
|
||||
select ifnull(sum(t1.use_electricity), 0)
|
||||
from settle_order_report t1
|
||||
where t1.del_flag = '0'
|
||||
and t1.trade_date = DATE_FORMAT(CURDATE(), '%Y-%m-%d')
|
||||
</select>
|
||||
|
||||
<select id="getMonthlyAvgElectricity" resultType="java.math.BigDecimal">
|
||||
select ifnull(avg(day_total), 0)
|
||||
from (
|
||||
select sum(t1.use_electricity) as day_total
|
||||
from settle_order_report t1
|
||||
where t1.del_flag = '0'
|
||||
and t1.trade_date >= DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) - 1 DAY), '%Y-%m-%d')
|
||||
and t1.trade_date < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 DAY), '%Y-%m-%d')
|
||||
group by t1.trade_date
|
||||
) day_data
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -350,4 +350,33 @@
|
||||
AND t1.status = #{status,jdbcType=VARCHAR}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="countTotalConnectors" resultType="java.lang.Long">
|
||||
select count(*) from pile_connector_info where del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="countOnlinePiles" resultType="java.lang.Long">
|
||||
select count(distinct t1.pile_sn)
|
||||
from pile_connector_info t1
|
||||
where t1.del_flag = '0'
|
||||
and t1.status not in ('0', '255')
|
||||
</select>
|
||||
|
||||
<select id="countDcPiles" resultType="java.lang.Long">
|
||||
select count(distinct t1.pile_sn)
|
||||
from pile_connector_info t1
|
||||
join pile_basic_info t2 on t2.sn = t1.pile_sn and t2.del_flag = '0'
|
||||
join pile_model_info t3 on t3.id = t2.model_id and t3.del_flag = '0'
|
||||
where t1.del_flag = '0'
|
||||
and t3.speed_type = '1'
|
||||
</select>
|
||||
|
||||
<select id="countAcPiles" resultType="java.lang.Long">
|
||||
select count(distinct t1.pile_sn)
|
||||
from pile_connector_info t1
|
||||
join pile_basic_info t2 on t2.sn = t1.pile_sn and t2.del_flag = '0'
|
||||
join pile_model_info t3 on t3.id = t2.model_id and t3.del_flag = '0'
|
||||
where t1.del_flag = '0'
|
||||
and t3.speed_type = '2'
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user