Browse Source

前端页面调整
数据统计-站点数据详情统计

skyline 2 years ago
parent
commit
49a41c4417

+ 15 - 13
admin-web/src/views/admin/invoice/index.vue

@@ -126,10 +126,10 @@
                   <h4 class="pd5">关联订单明细</h4>
                   <el-table :data="row.orderDetails" width="400" border>
                     <el-table-column label="充电订单" prop="startChargeSeq"/>
-                    <el-table-column label="总金额(元)" prop="totalMoney">
+                    <el-table-column label="订单总金额" prop="totalMoney">
                       <template #default="{row}">{{ u.fmt.fmtMoney(row.totalMoney) }}</template>
                     </el-table-column>
-                    <el-table-column label="总电量(Kwh)" prop="totalPower"/>
+                    <el-table-column label="总电量/度" prop="totalPower"/>
                     <el-table-column label="电费" prop="elecMoney">
                       <template #default="{row}">{{ u.fmt.fmtMoney(row.elecMoney) }}</template>
                     </el-table-column>
@@ -224,18 +224,20 @@ const state = reactive({
     loading: false,
     columns: [
       {type: 'expand', prop: 'expand', width: 30, fixed: 'left'},
-      {label: '用户手机号', prop: 'mobilePhone', align: 'center', fixed: 'left', width: 150},
-      {label: '申请号', prop: 'applyId', align: 'center', fixed: 'left', width: 220},
+      {label: '用户手机号', prop: 'mobilePhone', align: 'center', fixed: 'left', width: 120},
+      {label: '发票ID', prop: 'id', align: 'center', fixed: 'left', width: 110},
+      {label: '发票申请单号', prop: 'applyId', align: 'center', fixed: 'left', width: 130},
       {label: '发票状态', prop: 'status', align: 'center', fixed: 'left', width: 100},
-      {label: '发票金额(元)', prop: 'invoiceAmount', resizable: true, width: 150},
-      {label: '订单总金额(元)', prop: 'totalMoney', resizable: true, width: 150},
-      {label: '总服务费(元)', prop: 'serviceMoney', resizable: true, width: 140},
-      {label: '开票人', prop: 'biller', resizable: true, width: 130},
-      {label: '公司税号', prop: 'taxId', resizable: true, width: 130},
-      {label: '接收发票邮箱', prop: 'email', resizable: true, width: 130},
-      {label: '电话', prop: 'phone', resizable: true, width: 130},
-      {label: '发票类型', prop: 'invoiceType', resizable: true, width: 130},
-      {label: '发票抬头名称', prop: 'invoiceTitle', resizable: true, width: 130},
+      {label: '发票金额', prop: 'invoiceAmount', resizable: true, width: 90},
+      {label: '订单总额', prop: 'totalMoney', resizable: true, width: 90},
+      {label: '总服务费', prop: 'serviceMoney', resizable: true, width: 90},
+      {label: '服务费优惠', prop: 'serviceMoneyDiscount', resizable: true, width: 105},
+      {label: '开票人', prop: 'biller', resizable: true, width: 80},
+      {label: '公司税号', prop: 'taxId', resizable: true, width: 110},
+      {label: '接收发票邮箱', prop: 'email', resizable: true, width: 120},
+      {label: '电话', prop: 'phone', resizable: true, width: 90},
+      {label: '发票类型', prop: 'invoiceType', resizable: true, width: 90},
+      {label: '发票抬头', prop: 'invoiceTitle', resizable: true, width: 110},
       /*
 
             {label: '公司地址', prop: 'address', resizable: true, width: 130},

+ 14 - 14
admin-web/src/views/admin/ordering/index.vue

@@ -275,27 +275,27 @@ const state = reactive({
     data: [] as Array<any>,
     loading: false,
     columns: [
-      {label: '站点', prop: 'stationId', width: 150,align:'center', resizable: true, fixed: 'left'},
-      {label: '用户手机号', prop: 'mobilePhone', width: 130, resizable: true, fixed: 'left'},
+      {label: '站点ID/名称', prop: 'stationId', width: 130,align:'center', resizable: true, fixed: 'left'},
+      {label: '用户手机号', prop: 'mobilePhone', width: 120, resizable: true, fixed: 'left'},
       // {label: '站点ID',  prop: 'stationId',width:100, resizable: true, fixed: 'left'},
       // {label: '站点', prop: 'stationName', width: 150, resizable: true, fixed: 'left'},
       {label: '充电订单号', prop: 'startChargeSeq', width: 170, resizable: true, fixed: 'left'},
       {label: '充电设备接口编码', prop: 'connectorId', width: 160, resizable: true},
-      {label: '充电开始时间', prop: 'startTime', sortable: 'custom', width: 160, resizable: true},
+      {label: '充电开始/结束时间', prop: 'startTime', sortable: 'custom', width: 175, resizable: true},
       // {label: '充电结束时间', prop: 'endTime', sortable: 'custom', width: 160, resizable: true},
-      {label: '充电量(度)', prop: 'totalPower', width: 120, resizable: true},
-      {label: '订单总金额(元)', prop: 'totalMoney', width: 150, resizable: true},
-      {label: '服务费优惠(元)', prop: 'serviceMoneyDiscount', width: 150, resizable: true},
-      {label: '实付金额(元)', prop: 'payAmount', width: 150, resizable: true},
-      {label: '总电费(元)', prop: 'elecMoney', width: 140, resizable: true},
-      {label: '总服务费(元)', prop: 'serviceMoney', width: 150, resizable: true},
-      {label: '实付服务费(元)', prop: 'payServiceAmount', width: 150, resizable: true},
+      {label: '充电量/度', prop: 'totalPower', width: 95, resizable: true},
+      {label: '订单总金额', prop: 'totalMoney', width: 105, resizable: true},
+      {label: '服务费优惠', prop: 'serviceMoneyDiscount', width: 105, resizable: true},
+      {label: '实付金额', prop: 'payAmount', width: 90, resizable: true},
+      {label: '总电费', prop: 'elecMoney', width: 80, resizable: true},
+      {label: '总服务费', prop: 'serviceMoney', width: 90, resizable: true},
+      {label: '实付服务费', prop: 'payServiceAmount', width: 105, resizable: true},
       // {label: '时段数:0~32', prop: 'sumPeriod', width:150, resizable: true},
       // {label: '充电明细信息', prop: 'chargeDetail', width:150, resizable: true},
-      {label: '订单状态', prop: 'orderStatus', width: 120, resizable: true},
-      {label: '充电状态', prop: 'chargeStatus', width: 120, resizable: true},
-      {label: '充电停止原因', prop: 'stopReason', width: 150, resizable: true},
-      {label: '发票状态', prop: 'invoiceStatus', width: 120, resizable: true},
+      {label: '订单状态', prop: 'orderStatus', width: 90, resizable: true},
+      {label: '充电状态', prop: 'chargeStatus', width: 90, resizable: true},
+      {label: '充电停止原因', prop: 'stopReason', width: 120, resizable: true},
+      {label: '发票状态', prop: 'invoiceStatus', width: 90, resizable: true},
       // {label: '创建时间', prop: 'createTime', sortable: 'custom', width:150, resizable: true},
       // {label: '更新时间', prop: 'updateTime', sortable: 'custom',width:150,  resizable: true},
       // {

+ 8 - 0
admin/src/main/java/com/kym/admin/controller/StatController.java

@@ -50,4 +50,12 @@ public class StatController {
 
     // TODO: 2023-12-01 站点平均单度电费数据 日/月/整体维度
 
+    // 站点详细数据统计
+    @GetMapping("/stationStatDetail")
+    R<?> stationStatDetail(@ModelAttribute StatQueryParam params){
+        var res = chargeOrderService.stationStatDetail(params);
+        return R.success(res);
+    }
+
+
 }

+ 4 - 2
entity/src/main/java/com/kym/entity/admin/queryParams/StatQueryParam.java

@@ -4,6 +4,7 @@ import com.kym.entity.common.PageParams;
 import lombok.Data;
 
 import java.time.LocalDate;
+import java.util.List;
 
 /**
  * @author skyline
@@ -13,10 +14,11 @@ import java.time.LocalDate;
 @Data
 public class StatQueryParam extends PageParams {
 
-    private static final String TYPE_DAY = "day";
-    private static final String TYPE_MONTH = "month";
+    public static final String TYPE_DAY = "day";
+    public static final String TYPE_MONTH = "month";
 
     private String stationId;
+    private List<String> stationIds;
     private String type;
 
 

+ 2 - 0
service/src/main/java/com/kym/service/miniapp/ChargeOrderService.java

@@ -41,4 +41,6 @@ public interface ChargeOrderService extends MPJBaseService<ChargeOrder> {
     void exportCustomChargeOrders(CustomChargeOrdersQueryParam params, HttpServletResponse response);
 
     PageBean<ChargeOrderVo> listUserChargeOrders(OrderQueryParams params);
+
+    Map stationStatDetail(StatQueryParam params);
 }

+ 37 - 2
service/src/main/java/com/kym/service/miniapp/impl/ChargeOrderServiceImpl.java

@@ -9,6 +9,8 @@ import com.github.pagehelper.PageHelper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.kym.common.utils.CommUtil;
 import com.kym.entity.admin.RechargeRights;
+import com.kym.entity.admin.StationStatDay;
+import com.kym.entity.admin.StationStatMonth;
 import com.kym.entity.admin.queryParams.CustomChargeOrdersQueryParam;
 import com.kym.entity.admin.queryParams.StatQueryParam;
 import com.kym.entity.admin.vo.CustomOrderVo;
@@ -21,6 +23,8 @@ import com.kym.entity.miniapp.vo.ChargeOrderVo;
 import com.kym.mapper.miniapp.ChargeOrderMapper;
 import com.kym.service.admin.ExportService;
 import com.kym.service.admin.RechargeRightsService;
+import com.kym.service.admin.StationStatDayService;
+import com.kym.service.admin.StationStatMonthService;
 import com.kym.service.cache.KymCache;
 import com.kym.service.miniapp.ChargeOrderService;
 import com.kym.service.miniapp.OrderRechargeRightsService;
@@ -56,10 +60,15 @@ public class ChargeOrderServiceImpl extends MPJBaseServiceImpl<ChargeOrderMapper
     private final OrderRechargeRightsService orderRechargeRightsService;
     private final RechargeRightsService rechargeRightsService;
 
-    public ChargeOrderServiceImpl(ExportService exportService, OrderRechargeRightsService orderRechargeRightsService, RechargeRightsService rechargeRightsService) {
+    private final StationStatDayService stationStatDayService;
+    private final StationStatMonthService stationStatMonthService;
+
+    public ChargeOrderServiceImpl(ExportService exportService, OrderRechargeRightsService orderRechargeRightsService, RechargeRightsService rechargeRightsService, StationStatDayService stationStatDayService, StationStatMonthService stationStatMonthService) {
         this.exportService = exportService;
         this.orderRechargeRightsService = orderRechargeRightsService;
         this.rechargeRightsService = rechargeRightsService;
+        this.stationStatDayService = stationStatDayService;
+        this.stationStatMonthService = stationStatMonthService;
     }
 
 
@@ -208,11 +217,37 @@ public class ChargeOrderServiceImpl extends MPJBaseServiceImpl<ChargeOrderMapper
         var map = Map.of(
                 "totalPower", BigDecimal.valueOf(res.stream().mapToDouble(StationStatVo::getTotalPower).sum()).setScale(2, RoundingMode.HALF_UP).doubleValue(),
                 "serviceMoney", res.stream().mapToInt(StationStatVo::getServiceMoney).sum(),
-                "payServiceAmount",res.stream().mapToInt(StationStatVo::getPayServiceAmount).sum()
+                "payServiceAmount", res.stream().mapToInt(StationStatVo::getPayServiceAmount).sum()
         );
         return new PageBean<>(res).setExtraData(map);
     }
 
+    /**
+     * 站点统计详情
+     *
+     * @param params
+     * @return
+     */
+    @Override
+    @DS("db-admin")
+    public Map<String, ?> stationStatDetail(StatQueryParam params) {
+        if (params.getType().equals(StatQueryParam.TYPE_DAY)) {
+            return stationStatDayService.lambdaQuery()
+                    .in(StationStatDay::getStationId, params.getStationIds())
+                    .ge(StationStatDay::getStatDay, params.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
+                    .le(StationStatDay::getStatDay, params.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
+                    .orderByAsc(StationStatDay::getStatDay)
+                    .list().stream().collect(Collectors.groupingBy(StationStatDay::getStationId, Collectors.toList()));
+        } else {
+            return stationStatMonthService.lambdaQuery()
+                    .in(StationStatMonth::getStationId, params.getStationIds())
+                    .ge(StationStatMonth::getStatMonth, params.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM")))
+                    .le(StationStatMonth::getStatMonth, params.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM")))
+                    .orderByAsc(StationStatMonth::getStatMonth)
+                    .list().stream().collect(Collectors.groupingBy(StationStatMonth::getStationId, Collectors.toList()));
+        }
+    }
+
     /**
      * 充电站当日统计
      *