package com.flightfeather.uav.dataprocess
|
|
import com.flightfeather.uav.common.utils.DateUtil
|
import com.flightfeather.uav.common.utils.ExcelUtil
|
import com.flightfeather.uav.domain.entity.RealTimeData
|
import com.flightfeather.uav.domain.mapper.RealTimeDataMapper
|
import com.flightfeather.uav.lightshare.service.RealTimeDataService
|
import com.github.pagehelper.PageHelper
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook
|
import org.junit.Assert.*
|
import org.junit.Test
|
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.text.SimpleDateFormat
|
import java.time.LocalDateTime
|
import java.time.format.DateTimeFormatter
|
import java.util.*
|
|
@RunWith(SpringRunner::class)
|
@SpringBootTest
|
class DataProcessTest {
|
|
@Autowired
|
lateinit var realTimeDataMapper: RealTimeDataMapper
|
|
@Autowired
|
lateinit var realTimeDataService: RealTimeDataService
|
|
@Test
|
fun dataProcess() {
|
val fileName = "网格化监测数据预处理${Date().time}.xls"
|
val filePath = "C:\\work\\工作\\走航监测\\走航监测\\$fileName"
|
// val filePath = "E:\\工作\\开发\\走航监测\\数据预处理\\$fileName"
|
val process = DataProcess(filePath)
|
|
/**
|
* 按每日间隔循环获取数据,进行数处理
|
* 数据为4秒钟1个值,因此一天的数据量最多为21600个
|
*/
|
//截止时间
|
val endDateTime = LocalDateTime.of(2021, 10, 5, 10, 0, 0)
|
var sTime = LocalDateTime.of(2021, 6, 19, 0, 0, 0)
|
var eTime = LocalDateTime.of(2021, 6, 19, 23, 59, 59)
|
|
while (sTime.isBefore(endDateTime)) {
|
if (eTime.isAfter(endDateTime)) {
|
eTime = endDateTime
|
}
|
val deviceCode = "0d0000000001"
|
val dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
val s = sTime.format(dateFormatter)
|
val e = eTime.format(dateFormatter)
|
val data = realTimeDataService.getSecondData(deviceCode, s, e, 1, 30000).data
|
data?.let {
|
process.process(it)
|
}
|
sTime = sTime.plusDays(1)
|
eTime = eTime.plusDays(1)
|
}
|
|
process.outPutDailyVariation()
|
process.done()
|
}
|
}
|