Pārlūkot izejas kodu

首页统计修改

zuypeng 1 gadu atpakaļ
vecāks
revīzija
56eb31cd4c

+ 40 - 17
admin-web/src/views/admin/index.vue

@@ -46,9 +46,9 @@
 
             <div class="trend-summary">
               总收益金额:
-              <el-tag type="success">{{ u.fmt.fmtMoney(state.homeOneExtra.payServiceAmount) }}元</el-tag>
+              <el-tag type="success">{{ u.fmt.fmtMoney(state.homeOneExtra.totalIncome||0) }}元</el-tag>
               总订单数量:
-              <el-tag type="danger">{{ state.homeOneExtra.totalPower }}Kwh</el-tag>
+              <el-tag type="danger">{{ state.homeOneExtra.totalWashOrders||0 }}笔</el-tag>
             </div>
           </div>
 
@@ -166,7 +166,10 @@ const state = reactive({
     bgColor: '',
     color: '#303133',
   },
-  homeOneExtra: {}
+  homeOneExtra: {
+    totalIncome:0,
+    totalWashOrders:0,
+  }
 });
 
 const shortcuts = [
@@ -203,10 +206,16 @@ const shortcuts = [
 const initLineChart = (dataList: Array<any>) => {
   if (!state.global.dispose.some((b: any) => b === state.global.homeChartOne)) state.global.homeChartOne.dispose();
   state.global.homeChartOne = markRaw(echarts.init(homeLineRef.value, state.charts.theme));
+  dataList.forEach(item=>{
+    item['startTime'] = item.statTime.slice(0,3).join("-")
+    item['seq'] = Number(item.statTime.join(""))
+  })
 
-  u.sort(dataList, "statTime")
+  state.homeOneExtra.totalIncome=dataList.reduce((k,v)=>k+v.totalAmount,0);
+  state.homeOneExtra.totalWashOrders=dataList.reduce((k,v)=>k+v.totalOrders,0);
+  u.sort(dataList, "seq")
 
-  let xAxis = dataList.map(k => k.statTime)
+  let xAxis = dataList.map(k =>k.startTime )
   const option = {
     backgroundColor: state.charts.bgColor,
     title: {
@@ -216,7 +225,7 @@ const initLineChart = (dataList: Array<any>) => {
     },
     grid: {top: 70, right: 0, bottom: 30, left: 50},
     tooltip: {trigger: 'axis'},
-    legend: {data: ['洗车量', /*'总金额','电费',*/'实付服务费',], right: 0},
+    legend: {data: ['洗车量','总金额',], right: 20},
     xAxis: {
       data: xAxis,
       // data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
@@ -224,7 +233,7 @@ const initLineChart = (dataList: Array<any>) => {
     yAxis: [
       {
         type: 'value',
-        name: '费用/元 洗车量/度',
+        name: '费用/元  洗车量/次',
         position: 'left',
         splitLine: {show: true, lineStyle: {type: 'dashed', color: '#f5f5f5'}},
       },
@@ -233,10 +242,11 @@ const initLineChart = (dataList: Array<any>) => {
       {
         name: '洗车量',
         type: 'bar',
+        barWidth:10,
         symbolSize: 6,
         symbol: 'circle',
         smooth: true,
-        data: dataList.map(k => k.totalPower),
+        data: dataList.map(k => k.totalOrders),
         // data: [0, 41.1, 30.4, 65.1, 53.3, 53.3, 53.3, 41.1, 30.4, 65.1, 53.3, 10],
         lineStyle: {color: '#68a7a0'},
         itemStyle: {color: '#68a7a0', borderColor: '#68a7a0', barBorderRadius: 5},
@@ -280,12 +290,12 @@ const initLineChart = (dataList: Array<any>) => {
               },
             },*/
       {
-        name: '实付服务费',
+        name: '总金额',
         type: 'line',
         symbolSize: 6,
         symbol: 'circle',
         smooth: true,
-        data: dataList.map(k => u.fmt.fmtMoney(k.payServiceAmount)),
+        data: dataList.map(k => u.fmt.fmtMoney(k.totalAmount)),
         lineStyle: {color: '#3770ff'},
         itemStyle: {color: '#3770ff', borderColor: '#3770ff'},
         areaStyle: {
@@ -324,15 +334,27 @@ const initLineChart = (dataList: Array<any>) => {
 const initPieChart = (dataMap: any) => {
   if (!state.global.dispose.some((b: any) => b === state.global.homeChartTwo)) state.global.homeChartTwo.dispose();
   state.global.homeChartTwo = markRaw(echarts.init(homePieRef.value, state.charts.theme));
-  var getname = ['离线', '空闲', '已连接', '洗车中', '预约中', '故障'];
-  const colorList = ['#6B6F75FF', '#36C78B', '#e9ee8e', '#ffa496', '#E790E8','#363638FF'];
+  const sessionDicts = Session.get("dicts");
+  let dicts: any[] = [];
+  if (!u.isEmptyOrNull(sessionDicts)) {
+     dicts = sessionDicts[`WashDevice.state`]
+    if (u.isEmptyOrNull(dicts)) {
+      return;
+    }
+  }
+  // var getname = ['离线', '空闲', '已连接', '洗车中', '预约中', '故障'];
+  let getname = dicts.map(k => k.name)
+  const colorList = ['#6B6F75FF', '#36C78B', '#e9ee8e', '#ffa496', '#E790E8', '#363638FF'];
   // var getvalue = [34.2, 38.87, 17.88];
   // var data = [dataMap["0"]||0,dataMap["1"]||0,dataMap["2"]||0];
   var data = [];
   for (var i = 0; i < getname.length; i++) {
-    data.push({name: getname[i], value: dataMap[`${i}`] || 0});
+    let dict =dicts.find(k=>k.name==getname[i])
+    data.push({name: getname[i], value: dataMap[`${dict.value}`] || 0});
   }
 
+  console.log(getname,data)
+
   const option = {
     backgroundColor: state.charts.bgColor,
     title: {
@@ -425,7 +447,7 @@ const initEchartsResize = () => {
 
 const loadCurrentEquipmentStatus = () => {
   $get(`stat/washDeviceStatus`, {stationId: state.currentStationId}).then((res: any) => {
-    //console.log(res)
+    console.log(res)
     initPieChart(res || {});
   })
 }
@@ -443,8 +465,8 @@ const loadStationStat = () => {
     stationId: state.currentStationId
   }).then((res: any) => {
     //console.log(res)
-    state.homeOneExtra = res.extraData
-    initLineChart(res.list);
+    // state.homeOneExtra = res.extraData
+    initLineChart(res);
   })
 }
 
@@ -452,13 +474,14 @@ const loadStationStatToday = () => {
   $get(`stat/dashboard`, {stationId: state.currentStationId}).then((res: any) => {
     //console.log(res)
     if (!u.isEmptyOrNull(res)) {
-      let {todayIncome, todayConsumptionAmount, todayRegisteredMembers, todayWashOrders, avgOrderPrice, avgOrderDuration} = res
+      let {todayIncome, todayConsumptionAmount, todayRegisteredMembers, todayWashOrders, avgOrderPrice, avgOrderDuration,totalIncome,totalWashOrders} = res
       state.homeOne[0].num1 = todayRegisteredMembers;
       state.homeOne[1].num1 = u.fmt.fmtMoney(todayIncome);
       state.homeOne[2].num1 = u.fmt.fmtMoney(todayConsumptionAmount);
       state.homeOne[3].num1 = u.fmt.fmtMoney(avgOrderPrice);
       state.homeOne[4].num1 = todayWashOrders;
       state.homeOne[5].num1 = avgOrderDuration;
+
     }
 
   })

+ 5 - 0
car-wash-entity/src/main/java/com/kym/entity/DataDict.java

@@ -43,4 +43,9 @@ public class DataDict extends BaseEntity implements Serializable {
      * 备注
      */
     private String remark;
+
+    /**
+     * 颜色
+     */
+    private String color;
 }