Просмотр исходного кода

网页端:修改整体统计

余思翰 1 неделю назад
Родитель
Сommit
2abd02b499

+ 1
- 1
oa-back/ruoyi-admin/src/main/java/com/ruoyi/web/controller/oa/CmcContractController.java Просмотреть файл

@@ -169,7 +169,7 @@ public class CmcContractController extends BaseController
169 169
                     paidMonthAmountObject.put(monthList.get(i), paidMonthAmount);
170 170
                 }
171 171
             }
172
-            cmcContract.setSignDate(null);
172
+            cmcContract.setContractCode(null);
173 173
         }
174 174
         else if (cmcContract.getSignDate() != null) {
175 175
             //输入年份合同数量及金额

+ 0
- 6
oa-back/ruoyi-system/src/main/resources/mapper/oa/CmcContractMapper.xml Просмотреть файл

@@ -166,12 +166,6 @@
166 166
             <if test="projectSource != null  and projectSource != ''"> and p.project_source = #{projectSource}</if>
167 167
             <if test="projectName != null  and projectName != ''"> and p.project_name like concat('%', #{projectName}, '%')</if>
168 168
             <if test="partyAName != null  and partyAName != ''"> and pa.party_a_name like concat('%', #{partyAName}, '%')</if>
169
-            <if test="params.beginTime != null and params.beginTime != ''">
170
-                and date_format(t1.sign_date,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
171
-            </if>
172
-            <if test="params.endTime != null and params.endTime != ''">
173
-                and date_format(t1.sign_date,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
174
-            </if>
175 169
         </where>
176 170
         group by t1.contract_id
177 171
         order by t1.draft_time desc

+ 2
- 2
oa-back/ruoyi-system/src/main/resources/mapper/oa/CmcDeviceApprovalMapper.xml Просмотреть файл

@@ -85,8 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
85 85
             <if test="applyDate != null and @com.ruoyi.common.utils.DateUtils@parseDateToStr('yyyy', applyDate) != '2000' "> and YEAR(da.apply_date) = YEAR(#{applyDate})</if>
86 86
             <if test="params.beginTime != null and params.beginTime != '' and applyDate != null"> and MONTH(da.apply_date) = MONTH(#{applyDate})</if>
87 87
             <if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != '' and applyDate == null">
88
-                and date_format(da.begin_date,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
89
-                and date_format(da.end_date,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
88
+                and date_format(da.apply_date,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
89
+                and date_format(da.apply_date,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
90 90
             </if>
91 91
             <if test="returnDate != null "> and da.return_date = #{returnDate}</if>
92 92
             <if test="beginDate != null "> and da.begin_date = #{beginDate}</if>

+ 134
- 220
oa-ui/src/views/statistics/components/topHead.vue Просмотреть файл

@@ -95,12 +95,11 @@
95 95
 <script>
96 96
 import upSrc from '@/assets/icons/up.png'
97 97
 import downSrc from '@/assets/icons/down.png'
98
-import * as echarts from 'echarts'
99 98
 import { echartsInit } from '@/utils/echarts'
100
-import { listProject } from '@/api/oa/project/project'
101
-import { listContract } from '@/api/oa/contract/contract'
102
-import { listBorrow } from '@/api/oa/borrow/borrow'
103
-import { listDeviceApproval } from '@/api/oa/device/deviceApproval'
99
+import { getProjectStatistic } from '@/api/oa/project/project'
100
+import { getContractStatistic } from '@/api/oa/contract/contract'
101
+import { getBorrowStatistic } from '@/api/oa/borrow/borrow'
102
+import { getDeviceStatistic } from '@/api/oa/device/device'
104 103
 
105 104
 let thisYearChart, contractYearChart, deviceYearChart, borrowYearChart, settleYearChart
106 105
 export default {
@@ -185,7 +184,8 @@ export default {
185 184
       deviceMonthLabels: [],
186 185
       deviceMonthThisYear: [],
187 186
       deviceMonthLastYear: [],
188
-      loading: true
187
+      loading: true,
188
+      statsLoading: false
189 189
     }
190 190
   },
191 191
   watch: {
@@ -251,18 +251,30 @@ export default {
251 251
     }
252 252
   },
253 253
   created() {
254
+    this.loadHeadStats()
254 255
   },
255 256
   mounted() {
256 257
   },
257 258
   methods: {
258
-    async initDatas() {
259
+    async loadHeadStats() {
260
+      if (this.statsLoading) {
261
+        return
262
+      }
263
+      this.statsLoading = true
259 264
       this.loading = true
260
-      await Promise.all([
261
-        this.loadProjectStats(),
262
-        this.loadContractStats(),
263
-        this.loadBorrowStats(),
264
-        this.loadDeviceStats()
265
-      ])
265
+      try {
266
+        await Promise.all([
267
+          this.loadProjectStats(),
268
+          this.loadContractStats(),
269
+          this.loadBorrowStats(),
270
+          this.loadDeviceStats()
271
+        ])
272
+      } finally {
273
+        this.loading = false
274
+        this.statsLoading = false
275
+      }
276
+    },
277
+    initDatas() {
266 278
       if (Object.keys(this.pDatas).length !== 0) {
267 279
         this.year = this.pDatas.year[0];
268 280
         this.type = this.pDatas.type[0];
@@ -293,229 +305,131 @@ export default {
293 305
         this.settleYear = this.sDatas.year[0];
294 306
         this.getSettleYearSub(this.settleYear);
295 307
       }
296
-
297
-      this.loading = false
298 308
     },
299
-    getMonthRange(year, month, capToToday = false) {
300
-      const monthStr = String(month).padStart(2, '0')
301
-      const begin = `${year}-${monthStr}-01`
302
-      const lastDay = new Date(year, month, 0).getDate()
303
-      let end = `${year}-${monthStr}-${String(lastDay).padStart(2, '0')}`
304
-      if (capToToday) {
305
-        const now = new Date()
306
-        if (year === now.getFullYear() && month === now.getMonth() + 1) {
307
-          end = this.parseTime(now, '{y}-{m}-{d}')
308
-        }
309
-      }
310
-      return [begin, end]
309
+    getMonthKey(year, month) {
310
+      return `${year}-${String(month).padStart(2, '0')}`
311 311
     },
312
-    async fetchProjectCount(begin, end) {
313
-      const res = await listProject(this.addDateRange({ pageNum: 1, pageSize: 1 }, [begin, end]))
314
-      return res.total || 0
312
+    getMonthValue(monthData, year, month) {
313
+      return Number(monthData[this.getMonthKey(year, month)] || 0)
315 314
     },
316
-    async loadProjectStats() {
317
-      const now = new Date()
318
-      const year = now.getFullYear()
319
-      const today = this.parseTime(now, '{y}-{m}-{d}')
320
-      const thisYearBegin = `${year}-01-01`
321
-      const lastYearBegin = `${year - 1}-01-01`
322
-      const lastYearDate = new Date(now)
323
-      lastYearDate.setFullYear(year - 1)
324
-      const lastYearToday = this.parseTime(lastYearDate, '{y}-{m}-{d}')
325
-      const currentMonth = now.getMonth() + 1
326
-      const lastMonthDate = new Date(year, now.getMonth() - 1, 1)
327
-      const lastMonthYear = lastMonthDate.getFullYear()
328
-      const lastMonth = lastMonthDate.getMonth() + 1
329
-      const [thisMonthBegin, thisMonthEnd] = this.getMonthRange(year, currentMonth, true)
330
-      const [lastMonthBegin, lastMonthEnd] = this.getMonthRange(lastMonthYear, lastMonth)
331
-
332
-      const monthTasks = []
333
-      const monthLabels = []
334
-      for (let m = 1; m <= currentMonth; m++) {
335
-        monthLabels.push(`${m}月`)
336
-        const [begin, end] = this.getMonthRange(year, m, m === currentMonth)
337
-        const [lastBegin, lastEnd] = this.getMonthRange(year - 1, m, false)
338
-        monthTasks.push(this.fetchProjectCount(begin, end))
339
-        monthTasks.push(this.fetchProjectCount(lastBegin, lastEnd))
315
+    parseMonthSeries(monthData, year, upToMonth) {
316
+      const labels = []
317
+      const values = []
318
+      for (let m = 1; m <= upToMonth; m++) {
319
+        labels.push(`${m}月`)
320
+        values.push(this.getMonthValue(monthData, year, m))
340 321
       }
341
-
342
-      const [thisYearCount, lastYearCount, thisMonthCount, lastMonthCount, ...monthCounts] = await Promise.all([
343
-        this.fetchProjectCount(thisYearBegin, today),
344
-        this.fetchProjectCount(lastYearBegin, lastYearToday),
345
-        this.fetchProjectCount(thisMonthBegin, thisMonthEnd),
346
-        this.fetchProjectCount(lastMonthBegin, lastMonthEnd),
347
-        ...monthTasks
348
-      ])
349
-
350
-      this.projectNum = thisYearCount
351
-      this.subYear = Math.abs(thisYearCount - lastYearCount)
352
-      this.isProjectUp = thisYearCount >= lastYearCount
353
-      this.subMonth = Math.abs(thisMonthCount - lastMonthCount)
354
-      this.isProjectMonthUp = thisMonthCount >= lastMonthCount
355
-
356
-      this.projectMonthLabels = monthLabels
357
-      this.projectMonthThisYear = []
358
-      this.projectMonthLastYear = []
359
-      for (let i = 0; i < monthCounts.length; i += 2) {
360
-        this.projectMonthThisYear.push(monthCounts[i])
361
-        this.projectMonthLastYear.push(monthCounts[i + 1])
322
+      return { labels, values }
323
+    },
324
+    sumMonths(monthData, year, fromMonth, toMonth) {
325
+      let sum = 0
326
+      for (let m = fromMonth; m <= toMonth; m++) {
327
+        sum += this.getMonthValue(monthData, year, m)
362 328
       }
329
+      return sum
363 330
     },
364
-    async fetchContractCount(begin, end) {
365
-      const res = await listContract(this.addDateRange({ pageNum: 1, pageSize: 1 }, [begin, end]))
366
-      return res.total || 0
331
+    calcCompareStats(thisYearData, lastYearData, year, currentMonth) {
332
+      const thisYearCount = this.sumMonths(thisYearData, year, 1, currentMonth)
333
+      const lastYearCount = this.sumMonths(lastYearData, year - 1, 1, currentMonth)
334
+      const thisMonthCount = this.getMonthValue(thisYearData, year, currentMonth)
335
+      let lastMonthYear = year
336
+      let lastMonth = currentMonth - 1
337
+      if (lastMonth === 0) {
338
+        lastMonth = 12
339
+        lastMonthYear = year - 1
340
+      }
341
+      const lastMonthData = lastMonthYear === year ? thisYearData : lastYearData
342
+      const lastMonthCount = this.getMonthValue(lastMonthData, lastMonthYear, lastMonth)
343
+      return { thisYearCount, lastYearCount, thisMonthCount, lastMonthCount }
367 344
     },
368
-    async loadContractStats() {
369
-      const now = new Date()
370
-      const year = now.getFullYear()
371
-      const today = this.parseTime(now, '{y}-{m}-{d}')
372
-      const thisYearBegin = `${year}-01-01`
373
-      const lastYearBegin = `${year - 1}-01-01`
374
-      const lastYearDate = new Date(now)
375
-      lastYearDate.setFullYear(year - 1)
376
-      const lastYearToday = this.parseTime(lastYearDate, '{y}-{m}-{d}')
377
-      const currentMonth = now.getMonth() + 1
378
-      const lastMonthDate = new Date(year, now.getMonth() - 1, 1)
379
-      const lastMonthYear = lastMonthDate.getFullYear()
380
-      const lastMonth = lastMonthDate.getMonth() + 1
381
-      const [thisMonthBegin, thisMonthEnd] = this.getMonthRange(year, currentMonth, true)
382
-      const [lastMonthBegin, lastMonthEnd] = this.getMonthRange(lastMonthYear, lastMonth)
383
-
384
-      const monthTasks = []
385
-      const monthLabels = []
386
-      for (let m = 1; m <= currentMonth; m++) {
387
-        monthLabels.push(`${m}月`)
388
-        const [begin, end] = this.getMonthRange(year, m, m === currentMonth)
389
-        const [lastBegin, lastEnd] = this.getMonthRange(year - 1, m, false)
390
-        monthTasks.push(this.fetchContractCount(begin, end))
391
-        monthTasks.push(this.fetchContractCount(lastBegin, lastEnd))
345
+    applyCompareResult(result, prefix) {
346
+      const {
347
+        thisYearCount,
348
+        lastYearCount,
349
+        thisMonthCount,
350
+        lastMonthCount,
351
+        labels,
352
+        thisYearValues,
353
+        lastYearValues
354
+      } = result
355
+      const fieldMap = {
356
+        project: { num: 'projectNum', subYear: 'subYear', subMonth: 'subMonth', up: 'isProjectUp', monthUp: 'isProjectMonthUp' },
357
+        contract: { num: 'contractNum', subYear: 'contractSubYear', subMonth: 'contractSubMonth', up: 'isContractUp', monthUp: 'isContractMonthUp' },
358
+        borrow: { num: 'borrowNum', subYear: 'borrowSubYear', subMonth: 'borrowSubMonth', up: 'isBorrowUp', monthUp: 'isBorrowMonthUp' },
359
+        device: { num: 'deviceNum', subYear: 'deviceSubYear', subMonth: 'deviceSubMonth', up: 'isDeviceUp', monthUp: 'isDeviceMonthUp' }
392 360
       }
393
-
394
-      const [thisYearCount, lastYearCount, thisMonthCount, lastMonthCount, ...monthCounts] = await Promise.all([
395
-        this.fetchContractCount(thisYearBegin, today),
396
-        this.fetchContractCount(lastYearBegin, lastYearToday),
397
-        this.fetchContractCount(thisMonthBegin, thisMonthEnd),
398
-        this.fetchContractCount(lastMonthBegin, lastMonthEnd),
399
-        ...monthTasks
361
+      const fields = fieldMap[prefix]
362
+      this[fields.num] = thisYearCount
363
+      this[fields.subYear] = Math.abs(thisYearCount - lastYearCount)
364
+      this[fields.up] = thisYearCount >= lastYearCount
365
+      this[fields.subMonth] = Math.abs(thisMonthCount - lastMonthCount)
366
+      this[fields.monthUp] = thisMonthCount >= lastMonthCount
367
+      this[`${prefix}MonthLabels`] = labels
368
+      this[`${prefix}MonthThisYear`] = thisYearValues
369
+      this[`${prefix}MonthLastYear`] = lastYearValues
370
+    },
371
+    async fetchYearMonthData(fetchFn, year) {
372
+      const res = await fetchFn(year)
373
+      return res.data || {}
374
+    },
375
+    async loadProjectStats() {
376
+      const year = new Date().getFullYear()
377
+      const currentMonth = new Date().getMonth() + 1
378
+      const [thisYearRes, lastYearRes] = await Promise.all([
379
+        this.fetchYearMonthData(y => getProjectStatistic({ projectNumber: String(y) }), year),
380
+        this.fetchYearMonthData(y => getProjectStatistic({ projectNumber: String(y) }), year - 1)
400 381
       ])
401
-
402
-      this.contractNum = thisYearCount
403
-      this.contractSubYear = Math.abs(thisYearCount - lastYearCount)
404
-      this.isContractUp = thisYearCount >= lastYearCount
405
-      this.contractSubMonth = Math.abs(thisMonthCount - lastMonthCount)
406
-      this.isContractMonthUp = thisMonthCount >= lastMonthCount
407
-
408
-      this.contractMonthLabels = monthLabels
409
-      this.contractMonthThisYear = []
410
-      this.contractMonthLastYear = []
411
-      for (let i = 0; i < monthCounts.length; i += 2) {
412
-        this.contractMonthThisYear.push(monthCounts[i])
413
-        this.contractMonthLastYear.push(monthCounts[i + 1])
414
-      }
382
+      const thisYearData = thisYearRes.month ? thisYearRes.month[0] : {}
383
+      const lastYearData = lastYearRes.month ? lastYearRes.month[0] : {}
384
+      const { labels, values: thisYearValues } = this.parseMonthSeries(thisYearData, year, currentMonth)
385
+      const { values: lastYearValues } = this.parseMonthSeries(lastYearData, year - 1, currentMonth)
386
+      const compare = this.calcCompareStats(thisYearData, lastYearData, year, currentMonth)
387
+      this.applyCompareResult({ ...compare, labels, thisYearValues, lastYearValues }, 'project')
415 388
     },
416
-    async fetchBorrowCount(begin, end) {
417
-      const res = await listBorrow(this.addDateRange({ pageNum: 1, pageSize: 1 }, [begin, end]))
418
-      return res.total || 0
389
+    async loadContractStats() {
390
+      const year = new Date().getFullYear()
391
+      const currentMonth = new Date().getMonth() + 1
392
+      const fetchContractMonths = y => getContractStatistic({ signDate: `${y}-01-01` })
393
+      const [thisYearRes, lastYearRes] = await Promise.all([
394
+        this.fetchYearMonthData(fetchContractMonths, year),
395
+        this.fetchYearMonthData(fetchContractMonths, year - 1)
396
+      ])
397
+      const thisYearData = thisYearRes.monthCount ? thisYearRes.monthCount[0] : {}
398
+      const lastYearData = lastYearRes.monthCount ? lastYearRes.monthCount[0] : {}
399
+      const { labels, values: thisYearValues } = this.parseMonthSeries(thisYearData, year, currentMonth)
400
+      const { values: lastYearValues } = this.parseMonthSeries(lastYearData, year - 1, currentMonth)
401
+      const compare = this.calcCompareStats(thisYearData, lastYearData, year, currentMonth)
402
+      this.applyCompareResult({ ...compare, labels, thisYearValues, lastYearValues }, 'contract')
419 403
     },
420 404
     async loadBorrowStats() {
421
-      const now = new Date()
422
-      const year = now.getFullYear()
423
-      const today = this.parseTime(now, '{y}-{m}-{d}')
424
-      const thisYearBegin = `${year}-01-01`
425
-      const lastYearBegin = `${year - 1}-01-01`
426
-      const lastYearDate = new Date(now)
427
-      lastYearDate.setFullYear(year - 1)
428
-      const lastYearToday = this.parseTime(lastYearDate, '{y}-{m}-{d}')
429
-      const currentMonth = now.getMonth() + 1
430
-      const lastMonthDate = new Date(year, now.getMonth() - 1, 1)
431
-      const lastMonthYear = lastMonthDate.getFullYear()
432
-      const lastMonth = lastMonthDate.getMonth() + 1
433
-      const [thisMonthBegin, thisMonthEnd] = this.getMonthRange(year, currentMonth, true)
434
-      const [lastMonthBegin, lastMonthEnd] = this.getMonthRange(lastMonthYear, lastMonth)
435
-
436
-      const monthTasks = []
437
-      const monthLabels = []
438
-      for (let m = 1; m <= currentMonth; m++) {
439
-        monthLabels.push(`${m}月`)
440
-        const [begin, end] = this.getMonthRange(year, m, m === currentMonth)
441
-        const [lastBegin, lastEnd] = this.getMonthRange(year - 1, m, false)
442
-        monthTasks.push(this.fetchBorrowCount(begin, end))
443
-        monthTasks.push(this.fetchBorrowCount(lastBegin, lastEnd))
444
-      }
445
-
446
-      const [thisYearCount, lastYearCount, thisMonthCount, lastMonthCount, ...monthCounts] = await Promise.all([
447
-        this.fetchBorrowCount(thisYearBegin, today),
448
-        this.fetchBorrowCount(lastYearBegin, lastYearToday),
449
-        this.fetchBorrowCount(thisMonthBegin, thisMonthEnd),
450
-        this.fetchBorrowCount(lastMonthBegin, lastMonthEnd),
451
-        ...monthTasks
405
+      const year = new Date().getFullYear()
406
+      const currentMonth = new Date().getMonth() + 1
407
+      const fetchBorrowMonths = y => getBorrowStatistic({ lendTime: `${y}-01-01` })
408
+      const [thisYearRes, lastYearRes] = await Promise.all([
409
+        this.fetchYearMonthData(fetchBorrowMonths, year),
410
+        this.fetchYearMonthData(fetchBorrowMonths, year - 1)
452 411
       ])
453
-
454
-      this.borrowNum = thisYearCount
455
-      this.borrowSubYear = Math.abs(thisYearCount - lastYearCount)
456
-      this.isBorrowUp = thisYearCount >= lastYearCount
457
-      this.borrowSubMonth = Math.abs(thisMonthCount - lastMonthCount)
458
-      this.isBorrowMonthUp = thisMonthCount >= lastMonthCount
459
-
460
-      this.borrowMonthLabels = monthLabels
461
-      this.borrowMonthThisYear = []
462
-      this.borrowMonthLastYear = []
463
-      for (let i = 0; i < monthCounts.length; i += 2) {
464
-        this.borrowMonthThisYear.push(monthCounts[i])
465
-        this.borrowMonthLastYear.push(monthCounts[i + 1])
466
-      }
467
-    },
468
-    async fetchDeviceCount(begin, end) {
469
-      const res = await listDeviceApproval(this.addDateRange({ pageNum: 1, pageSize: 1 }, [begin, end]))
470
-      return res.total || 0
412
+      const thisYearData = thisYearRes.month ? thisYearRes.month[0] : {}
413
+      const lastYearData = lastYearRes.month ? lastYearRes.month[0] : {}
414
+      const { labels, values: thisYearValues } = this.parseMonthSeries(thisYearData, year, currentMonth)
415
+      const { values: lastYearValues } = this.parseMonthSeries(lastYearData, year - 1, currentMonth)
416
+      const compare = this.calcCompareStats(thisYearData, lastYearData, year, currentMonth)
417
+      this.applyCompareResult({ ...compare, labels, thisYearValues, lastYearValues }, 'borrow')
471 418
     },
472 419
     async loadDeviceStats() {
473
-      const now = new Date()
474
-      const year = now.getFullYear()
475
-      const today = this.parseTime(now, '{y}-{m}-{d}')
476
-      const thisYearBegin = `${year}-01-01`
477
-      const lastYearBegin = `${year - 1}-01-01`
478
-      const lastYearDate = new Date(now)
479
-      lastYearDate.setFullYear(year - 1)
480
-      const lastYearToday = this.parseTime(lastYearDate, '{y}-{m}-{d}')
481
-      const currentMonth = now.getMonth() + 1
482
-      const lastMonthDate = new Date(year, now.getMonth() - 1, 1)
483
-      const lastMonthYear = lastMonthDate.getFullYear()
484
-      const lastMonth = lastMonthDate.getMonth() + 1
485
-      const [thisMonthBegin, thisMonthEnd] = this.getMonthRange(year, currentMonth, true)
486
-      const [lastMonthBegin, lastMonthEnd] = this.getMonthRange(lastMonthYear, lastMonth)
487
-
488
-      const monthTasks = []
489
-      const monthLabels = []
490
-      for (let m = 1; m <= currentMonth; m++) {
491
-        monthLabels.push(`${m}月`)
492
-        const [begin, end] = this.getMonthRange(year, m, m === currentMonth)
493
-        const [lastBegin, lastEnd] = this.getMonthRange(year - 1, m, false)
494
-        monthTasks.push(this.fetchDeviceCount(begin, end))
495
-        monthTasks.push(this.fetchDeviceCount(lastBegin, lastEnd))
496
-      }
497
-
498
-      const [thisYearCount, lastYearCount, thisMonthCount, lastMonthCount, ...monthCounts] = await Promise.all([
499
-        this.fetchDeviceCount(thisYearBegin, today),
500
-        this.fetchDeviceCount(lastYearBegin, lastYearToday),
501
-        this.fetchDeviceCount(thisMonthBegin, thisMonthEnd),
502
-        this.fetchDeviceCount(lastMonthBegin, lastMonthEnd),
503
-        ...monthTasks
420
+      const year = new Date().getFullYear()
421
+      const currentMonth = new Date().getMonth() + 1
422
+      const fetchDeviceMonths = y => getDeviceStatistic({ applyDate: `${y}-01-01` })
423
+      const [thisYearRes, lastYearRes] = await Promise.all([
424
+        this.fetchYearMonthData(fetchDeviceMonths, year),
425
+        this.fetchYearMonthData(fetchDeviceMonths, year - 1)
504 426
       ])
505
-
506
-      this.deviceNum = thisYearCount
507
-      this.deviceSubYear = Math.abs(thisYearCount - lastYearCount)
508
-      this.isDeviceUp = thisYearCount >= lastYearCount
509
-      this.deviceSubMonth = Math.abs(thisMonthCount - lastMonthCount)
510
-      this.isDeviceMonthUp = thisMonthCount >= lastMonthCount
511
-
512
-      this.deviceMonthLabels = monthLabels
513
-      this.deviceMonthThisYear = []
514
-      this.deviceMonthLastYear = []
515
-      for (let i = 0; i < monthCounts.length; i += 2) {
516
-        this.deviceMonthThisYear.push(monthCounts[i])
517
-        this.deviceMonthLastYear.push(monthCounts[i + 1])
518
-      }
427
+      const thisYearData = thisYearRes.month ? thisYearRes.month[0] : {}
428
+      const lastYearData = lastYearRes.month ? lastYearRes.month[0] : {}
429
+      const { labels, values: thisYearValues } = this.parseMonthSeries(thisYearData, year, currentMonth)
430
+      const { values: lastYearValues } = this.parseMonthSeries(lastYearData, year - 1, currentMonth)
431
+      const compare = this.calcCompareStats(thisYearData, lastYearData, year, currentMonth)
432
+      this.applyCompareResult({ ...compare, labels, thisYearValues, lastYearValues }, 'device')
519 433
     },
520 434
     initChartOne() {
521 435
       let option = {

Загрузка…
Отмена
Сохранить