拖旺项目:聊城公交辅助决策系统
zhaoxing
2022-04-28 76950affed3e62fbc4e322432f874a2a797c0ba7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<template>
  <div class="v-data-board-right">
    <div>
      <div class="flex g-picker">
        <div class="flex-1 _large-title">司机详情</div>
        <el-date-picker
          v-model="day1"
          :clearable="false"
          value-format="yyyy-MM-dd"
          @change="handleSelect"
          type="date">
        </el-date-picker>
        <div class="_detail-btn ml20" @click="$to(`/driverList`)">司机详情</div>
      </div>
      <div class="flex align-c ju-c">
        <div class="_drive-detail-box">
          <div>{{ drive.total }}人</div>
          <img src="../../../assets/driverappraise/drive_1.png" style="top:-2px"/>
          <div class="mt5">司机总数</div>
        </div>
         <div class="ml10 _drive-detail-box">
           <div>
              <span class="_drive-num fz18 mr5">{{ drive.dangBan }}</span>人
            </div>
           <img src="../../../assets/driverappraise/drive_3.png"/>
            <div class="mt5">当班司机</div>
        </div>
         <div class="ml10 _drive-detail-box">
           <div>
              <span class="_drive-num fz18 _drive-blue">{{ drive.boy }}</span><span class="_drive-num fz18 mr5 _drive-red">/{{ drive.girl }}</span>人
            </div>
           <img src="../../../assets/driverappraise/drive_2.png"/>
            <div class="mt5">男性/女性</div>
        </div>
 
      </div>
 
    </div>
     <v-title :content="page == 1 ? `驾龄分布` : '年龄分布'" :pageShow="true" :page-text="pageText"  class="mt10" @handlePage="(e) => handlePage(e)"
            :page="page" />
     <v-border-decorate class="mt10">
       <div class="mb20 _drive-box">
          <div class="_progress">
            <circleProgress 
              v-for="(item, index) in agePercentData" 
              :key="index" 
              :class="`_progress-${index + 1}`" 
              :size="150 - index*20"
              :center-position="77"
              :id="`canvas_${page}_${index}`"
              lineWidth="4" 
              :color="echartColor[index]" 
              :progress="(item.num/driverSum)*100" 
            />
            <div class="_drive-name t-center">
                <div>{{ driverSum }}</div>
                <div>全部司机</div>
            </div>
          </div>
          <div class="_drive-detail">
            <div  class="flex" v-for="(item, index) in agePercentData" :key="index">
                <div class="_icon" :style="{background: echartColor[index]}"/>
                <span style="width: 70px">{{ item.workYear }}</span>
                <span class="_num font16 flex-1 ml20">{{ item.percent }} %</span>
                <span><span class="_num font16">{{ item.num }}</span>人</span>
            </div>
          </div>
       </div>
 
 
     </v-border-decorate>
    <v-title content="被投诉分析"  class="mt20"  />
      <v-border-decorate class="mt10">
        <div class="mb20 pie3d-wrap">
          <div>
            <pie3d
                id="driverComplain3dPie"
                pheight="150px"
                pwidth="180px"
                class="_echart-pie-box"
                :options="{ grid: { top: 0 }, legend: legend }"
                :optionData="pie3dOptionData"
            ></pie3d>
            <div class="bg-content">
              <!-- <img :src="require('@/assets/driverappraise/bg_3dpie.png')" alt=""> -->
              <div class="font12 _num">
                {{ complaintsNum }}
              </div>
              <div class="font12">总数</div>
            </div>
 
          </div>
          <div class="_drive-detail">
            <div  class="flex" v-for="(item, index) in complaintList" :key="index">
                <div class="_icon ml10" :style="{background: echartColor[index]}"/>
                <span style="width: 70px">{{ item.dutiesComplaintsNum }}</span>
                <span class="_num font16 flex-1 ml20">{{ item.percent }} %</span>
                <span><span class="_num font16">{{ item.times }}</span>人</span>
            </div>
          </div>
            
        </div>
      </v-border-decorate>
     
    <v-title content="工作时长排名"  class="mt20"  />
     <v-border-decorate class="mt10">
        <div class="mb20">
          <Table :data="workTimeData" :columnName="workTimeName" height="14vh"/>
        </div>
      </v-border-decorate>
  
  </div>
</template>
<script>
  import moment from "moment";
 import Table from '@/components/common/table/table';
 import pie3d from "@/components/echart/pie3d";
 import circleProgress from '@/components/common/progress/circle'
 
  export  default {
    name:'',
    components:{ Table, pie3d, circleProgress },
    data(){
      return{
        workTimeData: [],
        pageText: {
          1: '驾龄',
          2: '年龄'
 
        },
        workTimeName: ['排名', '司机', '工作时长(小时)'],
        day1: moment().subtract(1, 'day').format("yyyy-MM-DD"), 
        pie3dOptionData: [],
        driverSum: 0,
        page:1,
        drive: {},
        legend: {
          top: 0,
          show: false,
        },
        complaintsNum: 0,
        complaintList: [],
        agePercentData: [],
        echartColor: ['#1483F2', '#02FED3', '#D9A534', '#6BC2FC'],
      }
    },
    watch:{
      
    },
    created() {
     
      
 
    },
    methods:{
      handleSelect() {
        this.loadData();
        this.workTimeLoad();
        this.complaintLoad();
        this.drivingAgeLoad();
 
      },
      handlePage(e) {
        this.page = e;
        this.drivingAgeLoad()
        console.log(e, '1');
        
 
      },
      loadData() {
        this.$axios.get(this.$Interface.data.getDriverCount, {
          params: { statDate: this.day1,  }
        }).then((res) => {
          console.log(res, 'res');
          this.drive=res.data&&res.data[0];
          
        });
 
      },
      workTimeLoad() {
        this.$axios.get(this.$Interface.driver.workRank, {
          params: { statDate: this.day1, }
        }).then((res) => {
          this.workTimeData = res.data.map(i => {
                return {
                   ...i,
                  column1: i.name,
                  column2: i.hours
                }
              });
          if(this.workTimeData.length > 1){
            this.workTimeData.sort(function (a, b){
              return b.hours - a.hours
            })
          }
        });
        
      },
      complaintLoad() {
        // 被投诉分析
        this.$axios.get(this.$Interface.driver.complaint, {
          params: { statDate: this.day1, }
        }).then((res) => {
          const data = res.data;
          this.complaintList = [...res.data];
          const temp = [];
          this.complaintsNum = 0;
          if(data.length < 4) {
            let len = data.length;
             for (let index = 0; index < 4-len; index++) {
              const element = {
                "dutiesComplaintsNum": len + index,
                "times": "0",
                "percent": 0
              }
              this.complaintList.push(element);
              
            }
          }
         console.log(this.complaintList, 'this.complaintList');
         
          data.forEach((item, index) => {
            item.times = Number(item.times);
            this.complaintsNum += item.dutiesComplaintsNum * item.times;
            temp.push({
              name: item.dutiesComplaintsNum + "次投诉",
              value: item.times,
              itemStyle: {
                color: this.echartColor[index]
              }
            });
          });
          console.log(temp, 'temp');
          
          this.pie3dOptionData = temp;
        });
        
      },
      drivingAgeLoad() {
        let url = this.page == 1 ? 'age' : 'age1'
          //驾龄分布
      this.$axios.get(this.$Interface.driver[url], {
        params: { statDate: this.day1, }
      }).then((res) => {
         let sum = 0;
        let nulNum=0;
         this.driverSum = 0;
        const data = res.data || []
        if(this.page == 1) {
           data.forEach(item => {
 
            sum += Number(item.num);
 
            if(!item.workYear){
              nulNum=item.num;
            }
 
            if(item.workYear){
              item.workYear = item.workYear.replace(/\d\//, '');
            }
            if(item.workYear && item.workYear.indexOf('to') > -1){
              item.workYear = item.workYear.replace('to', '-');
              item.workYear += '年'
            }
            if(item.workYear && item.workYear.indexOf('less') > -1){
              item.workYear = item.workYear.replace('less', '');
              item.workYear += '年以下';
            }
            if(item.workYear && item.workYear.indexOf('more') > -1){
              item.workYear = item.workYear.replace('more', '');
              item.workYear += '年以上';
            }
          });
          this.driverSum = sum;
          for(let i=0; i<data.length; i++){
            if(!data[i].workYear){
              data.splice(i, 1);
              i--
            };
            if(data[i] && data[i].workYear==="4年以下"){
              data[i].num = Number(data[i].num) + Number(nulNum);
            }
          }
         this.agePercentData = [...data]
        } else {
           this.agePercentData = data.map(i => {
             this.driverSum += Number(i.value);
              return {
                num: i.value,
                percent: Number(i.proportion * 100).toFixed(2),
                workYear: i.name
 
              }
           })
        }
      });
 
      }
      
      
 
    },
    activated() {
      this.loadData();
      this.workTimeLoad();
      this.complaintLoad();
      this.drivingAgeLoad();
     
    },
  }
</script>
<style lang="less">
.v-data-board-right {
  width: 100%;
  padding-top: 30px;
  position: relative;
  z-index: 10;
  ._drive-box {
    display: flex;
    align-items: center;
    height: 15vh;
    min-height: 130px;
 
    
  }
  ._drive-detail-box {
    color: #fff;
    position: relative;
    padding-left: 55px;
    flex: 1;
    ._drive-num {
      color: #F5BD37;
      font-family: 'Digital';
      font-size: 18px;
 
    }
    ._drive-blue {
      color: #1185E2
    }
    ._drive-red {
      color: #FF6F6A
    }
    img {
      left: 0;
      top: 2px;
      width: 135px;
      position: absolute;
    } 
 
  }
  ._progress{
    position: relative;
    width: 154px;
    height: 154px;
    margin: 0 10px;
    ._progress-1, ._progress-2, ._progress-3, ._progress-4, ._drive-name{
      color: #fff;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%)
    }
 
  }
   .pie3d-wrap {
      margin: auto;
      position: relative;
      z-index: 100;
      color: #fff;
      display: flex;
      align-items: center;
      height: calc(11vh);
      ._echart-pie-box {
        position: absolute;
        top: -50px;
        left: -25px;
      }
      .bg-content {
        width: 130px;
        height: 100px;
        background-image: url("../../../assets/driverappraise/bg_3dpie.png");
        background-repeat: no-repeat;
        background-size: 130px 95px;
        margin: auto;
        display: flex;
        font-size: 12px;
        align-items: center;
        padding-top: 20px;
        flex-direction: column;
        animation: scale 2s linear infinite;
      }
    }
    @keyframes scale {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.03);
  }
  50% {
    transform: scale(1.06);
  }
  75% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}
 
}
</style>