package com.flightfeather.uav.lightshare.service.impl
|
|
import com.flightfeather.uav.domain.entity.RealTimeDataVehicle
|
import com.flightfeather.uav.domain.mapper.RealTimeDataVehicleMapper
|
import com.flightfeather.uav.lightshare.service.RealTimeDataService
|
import com.flightfeather.uav.domain.repository.impl.AirDataRepImpl
|
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 java.io.File
|
import java.io.FileOutputStream
|
|
@RunWith(SpringRunner::class)
|
@SpringBootTest
|
class RealTimeDataServiceImplTest {
|
|
@Autowired
|
lateinit var realTimeDataService: RealTimeDataService
|
|
@Autowired
|
lateinit var realTimeDataVehicleMapper: RealTimeDataVehicleMapper
|
|
@Autowired
|
lateinit var airDataRepository: AirDataRepImpl
|
|
@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)
|
}
|
|
@Test
|
fun averageData() {
|
val r = realTimeDataService.averageData()
|
println(r.data)
|
}
|
|
@Test
|
fun dataCalibration() {
|
val r = realTimeDataService.dataCalibration()
|
println(r.data)
|
}
|
|
@Test
|
fun dataTransform() {
|
|
var page = 1
|
var total = -1
|
var count = 0
|
|
while (total == -1 || page <= total) {
|
println("------车载数据转换start------")
|
val res = realTimeDataService.getOriginData("0a0000000001", "2021-01-01 00:00:00", "2021-10-25 15:37:21", page, 50000)
|
res.head?.let {
|
total = it.totalPage
|
}
|
if (page == 1) {
|
println("总页数:$total")
|
}
|
println("当前页数:$page")
|
res.data?.forEach {vo ->
|
val d = RealTimeDataVehicle()
|
airDataRepository.dataTransform(vo, d)
|
realTimeDataVehicleMapper.insert(d)
|
count++
|
}
|
page++
|
}
|
}
|
}
|