riku
2021-07-12 d978297ae85b2d7453054e616bbbe87bfabe9cbe
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
package com.flightfeather.uav.lightshare.service.impl
 
import com.flightfeather.uav.common.utils.DateUtil
import com.flightfeather.uav.lightshare.service.RealTimeDataService
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 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 workbook = realTimeDataService.outToWorkbook("0a0000000001", "2021-07-05 00:00:00", "2021-07-06 23:59:59")
            val fileName = "污染溯源权重模型${DateUtil.instance.dateToString(Date(), "yyyy-MM-ddHHmmss")}.xls"
            val filePath = "E:\\工作\\开发\\走航监测\\格式化数据\\$fileName"
            val out = FileOutputStream(File(filePath))
            workbook.write(out)
            workbook.close()
            out.flush()
            out.close()
        }
    }
}