feiyu02
2021-11-10 db7243622e8b5f4cc23de5594b2d973562f0b2a3
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
package com.flightfeather.uav.lightshare.service.impl
 
import com.flightfeather.uav.common.utils.DateUtil
import com.flightfeather.uav.common.utils.ExcelUtil
import com.flightfeather.uav.dataprocess.DataProcess
import com.flightfeather.uav.domain.entity.RealTimeData
import com.flightfeather.uav.lightshare.service.RealTimeDataService
import com.github.pagehelper.PageHelper
import org.apache.poi.xssf.streaming.SXSSFWorkbook
import org.junit.Test
 
import org.junit.Assert.*
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
import tk.mybatis.mapper.entity.Example
import java.io.File
import java.io.FileOutputStream
import java.util.*
 
@RunWith(SpringRunner::class)
@SpringBootTest
class RealTimeDataServiceImplTest {
 
    @Autowired
    lateinit var realTimeDataService: RealTimeDataService
 
    @Test
    fun outToExcel() {
        if (realTimeDataService is RealTimeDataServiceImpl) {
//            val deviceCode = "0a0000000001"
//            val deviceCode = "0a0000000002"
            val deviceCode = "0d0000000001"
            val timeSet = listOf(
//                Pair("2021-06-10 00:00:00", "2021-06-30 23:59:59"),
                Pair("2021-07-01 00:00:00", "2021-07-31 23:59:59"),
                Pair("2021-08-01 00:00:00", "2021-08-31 23:59:59"),
                Pair("2021-09-01 00:00:00", "2021-09-30 23:59:59"),
//            网格化监测每日
//                Pair("2021-06-02 00:00:00", "2021-06-03 23:59:59"),
//                Pair("2021-06-04 00:00:00", "2021-06-05 23:59:59"),
//                Pair("2021-06-06 00:00:00", "2021-06-07 23:59:59"),
//                Pair("2021-06-08 00:00:00", "2021-06-09 23:59:59"),
//                Pair("2021-06-10 00:00:00", "2021-06-11 23:59:59"),
//                Pair("2021-06-12 00:00:00", "2021-06-13 23:59:59"),
//                Pair("2021-06-14 00:00:00", "2021-06-15 23:59:59"),
//                Pair("2021-06-16 00:00:00", "2021-06-17 23:59:59"),
//                Pair("2021-06-18 00:00:00", "2021-06-19 23:59:59"),
//                Pair("2021-06-20 17:00:00", "2021-06-21 23:59:59"),
//                Pair("2021-06-22 00:00:00", "2021-06-23 23:59:59"),
//                Pair("2021-06-24 00:00:00", "2021-06-25 23:59:59"),
//                Pair("2021-06-26 00:00:00", "2021-06-27 23:59:59"),
//                Pair("2021-06-28 00:00:00", "2021-06-29 23:59:59"),
//                Pair("2021-06-30 00:00:00", "2021-06-30 23:59:59"),
 
//                Pair("2021-07-01 00:00:00", "2021-07-02 23:59:59"),
//                Pair("2021-07-03 00:00:00", "2021-07-04 23:59:59"),
//                Pair("2021-07-05 00:00:00", "2021-07-06 23:59:59"),
//                Pair("2021-07-07 00:00:00", "2021-07-08 23:59:59"),
//                Pair("2021-07-09 00:00:00", "2021-07-10 23:59:59"),
//                Pair("2021-07-11 00:00:00", "2021-07-12 23:59:59"),
//                Pair("2021-07-13 00:00:00", "2021-07-14 23:59:59"),
//                Pair("2021-07-15 00:00:00", "2021-07-16 23:59:59"),
//                Pair("2021-07-17 00:00:00", "2021-07-18 23:59:59"),
//                Pair("2021-07-19 17:00:00", "2021-07-20 23:59:59"),
//                Pair("2021-07-21 00:00:00", "2021-07-22 23:59:59"),
//                Pair("2021-07-23 00:00:00", "2021-07-24 23:59:59"),
//                Pair("2021-07-25 00:00:00", "2021-07-26 23:59:59"),
//                Pair("2021-07-27 00:00:00", "2021-07-28 23:59:59"),
//                Pair("2021-07-29 00:00:00", "2021-07-30 23:59:59"),
//                Pair("2021-07-31 00:00:00", "2021-07-31 23:59:59"),
 
//                Pair("2021-08-01 00:00:00", "2021-08-02 23:59:59"),
//                Pair("2021-08-03 00:00:00", "2021-08-04 23:59:59"),
//                Pair("2021-08-05 00:00:00", "2021-08-06 23:59:59"),
//                Pair("2021-08-07 00:00:00", "2021-08-08 23:59:59"),
//                Pair("2021-08-09 00:00:00", "2021-08-10 23:59:59"),
//                Pair("2021-08-11 00:00:00", "2021-08-12 23:59:59"),
//                Pair("2021-08-13 00:00:00", "2021-08-14 23:59:59"),
//                Pair("2021-08-15 00:00:00", "2021-08-16 23:59:59"),
//                Pair("2021-08-17 00:00:00", "2021-08-18 23:59:59"),
//                Pair("2021-08-19 17:00:00", "2021-08-20 23:59:59"),
//                Pair("2021-08-21 00:00:00", "2021-08-22 23:59:59"),
//                Pair("2021-08-23 00:00:00", "2021-08-24 23:59:59"),
//                Pair("2021-08-25 00:00:00", "2021-08-26 23:59:59"),
//                Pair("2021-08-27 00:00:00", "2021-08-28 23:59:59"),
//                Pair("2021-08-29 00:00:00", "2021-08-30 23:59:59"),
//                Pair("2021-08-31 00:00:00", "2021-08-31 23:59:59"),
 
//                Pair("2021-09-01 00:00:00", "2021-09-02 23:59:59"),
//                Pair("2021-09-03 00:00:00", "2021-09-04 23:59:59"),
//                Pair("2021-09-05 00:00:00", "2021-09-06 23:59:59"),
//                Pair("2021-09-07 00:00:00", "2021-09-08 23:59:59"),
//                Pair("2021-09-09 00:00:00", "2021-09-10 23:59:59"),
//                Pair("2021-09-11 00:00:00", "2021-09-12 23:59:59"),
//                Pair("2021-09-13 00:00:00", "2021-09-14 23:59:59"),
//                Pair("2021-09-15 00:00:00", "2021-09-16 23:59:59"),
//                Pair("2021-09-17 00:00:00", "2021-09-18 23:59:59"),
//                Pair("2021-09-19 17:00:00", "2021-09-20 23:59:59"),
//                Pair("2021-09-21 00:00:00", "2021-09-22 23:59:59"),
//                Pair("2021-09-23 00:00:00", "2021-09-24 23:59:59"),
//                Pair("2021-09-25 00:00:00", "2021-09-26 23:59:59"),
//                Pair("2021-09-27 00:00:00", "2021-09-28 23:59:59"),
//                Pair("2021-09-29 00:00:00", "2021-09-30 23:59:59"),
            )
            timeSet.forEach {(s, e) ->
                val workbook = realTimeDataService.outToWorkbook(deviceCode, s, e)
                val fileName = "网格化监测_${deviceCode}_${s.substring(0, 10).replace("-", ".")}-${e.substring(8, 10)}.xls"
                val filePath = "E:\\工作\\开发\\走航监测\\格式化数据\\$fileName"
                val out = FileOutputStream(File(filePath))
                workbook.write(out)
                workbook.close()
                out.flush()
                out.close()
            }
        }
    }
 
    @Test
    fun dataPreprocessing() {
        val r = realTimeDataService.dataPreprocessing()
        println(r.data)
    }
}