package com.flightfeather.uav.model.epw
|
|
import com.flightfeather.uav.common.utils.DateUtil
|
import com.flightfeather.uav.domain.entity.Company
|
import com.flightfeather.uav.domain.mapper.CompanyMapper
|
import com.flightfeather.uav.lightshare.bean.CompanySOP
|
import com.flightfeather.uav.lightshare.bean.DataVo
|
import com.flightfeather.uav.lightshare.service.RealTimeDataService
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook
|
import org.junit.Test
|
import org.junit.runner.RunWith
|
import org.springframework.beans.BeanUtils
|
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.FileOutputStream
|
import java.util.*
|
|
@RunWith(SpringRunner::class)
|
@SpringBootTest
|
class EPWModelTest {
|
|
@Autowired
|
lateinit var realTimeDataService: RealTimeDataService
|
|
@Autowired
|
lateinit var companyMapper: CompanyMapper
|
|
@Test
|
fun test1() {
|
val company = companyMapper
|
.selectAll()
|
// .selectByExample(Example(Company::class.java).apply {
|
// createCriteria()
|
// .orEqualTo("ciGuid", "Dp5iDYfKY7qi04Ze")
|
// .orEqualTo("ciGuid", "C9ZzWbc49AHuxa0U")
|
// .orEqualTo("ciGuid", "15xCtnjxa9pfmDSj")
|
// .orEqualTo("ciGuid", "mbd8mRmpRtcUsT61")
|
// .orEqualTo("ciGuid", "xh7fpulnFQDQjb3e")
|
// .orEqualTo("ciGuid", "mXef1NeDZyguGDLN")
|
// .orEqualTo("ciGuid", "LEU330ksO54BEH8A")
|
// .orEqualTo("ciGuid", "aZpHXOktTEuzUcTX")
|
// .orEqualTo("ciGuid", "dNDMoJfresNn5hPU")
|
// .orEqualTo("ciGuid", "J3euwNl19WZvH7iE")
|
// .orEqualTo("ciGuid", "eb2kbFjhCZN2s9If")
|
// .orEqualTo("ciGuid", "0PjZXFkpp1KT6hEM")
|
// .orEqualTo("ciGuid", "ymXoupcbVMa1bBF1")
|
// })
|
val companySOPList = mutableListOf<CompanySOP>()
|
company.forEach {
|
val companySOP = CompanySOP(it.ciGuid, it.ciName, it.ciExtension1)
|
BeanUtils.copyProperties(it, companySOP)
|
companySOPList.add(companySOP)
|
}
|
|
val dataSet = mutableListOf<DataVo>()
|
val timeSet = listOf(
|
Pair("2021-06-18 15:00:00", "2021-06-18 23:59:59"),
|
Pair("2021-06-19 00:00:00", "2021-06-19 23:59:59"),
|
Pair("2021-06-20 00:00:00", "2021-06-20 23:59:59"),
|
Pair("2021-06-21 00:00:00", "2021-06-21 23:59:59"),
|
Pair("2021-06-22 00:00:00", "2021-06-22 23:59:59"),
|
Pair("2021-06-23 00:00:00", "2021-06-23 23:59:59"),
|
Pair("2021-06-24 00:00:00", "2021-06-24 23:59:59"),
|
Pair("2021-06-25 00:00:00", "2021-06-25 23:59:59"),
|
Pair("2021-06-26 00:00:00", "2021-06-26 23:59:59"),
|
Pair("2021-06-27 00:00:00", "2021-06-27 23:59:59"),
|
Pair("2021-06-28 00:00:00", "2021-06-28 23:59:59"),
|
Pair("2021-06-29 00:00:00", "2021-06-29 23:59:59"),
|
Pair("2021-06-30 00:00:00", "2021-06-30 08:00:00"),
|
// Pair("2021-03-26 11:28:12", "2021-03-26 21:30:00"),
|
// Pair("2021-04-09 07:18:12", "2021-04-09 22:04:39"),
|
// Pair("2021-04-10 08:00:02", "2021-04-10 09:44:18"),
|
// Pair("2021-04-21 16:46:12", "2021-04-21 21:18:35"),
|
// Pair("2021-05-24 11:10:12", "2021-05-24 19:31:02"),
|
// Pair("2021-06-04 09:02:40", "2021-06-04 20:14:18"),
|
)
|
|
val epwModel = EPWModel()
|
var workbook: HSSFWorkbook? = null
|
var out: FileOutputStream? = null
|
|
for (i in timeSet.indices) {
|
val it = timeSet[i]
|
val dataList =
|
realTimeDataService.getSecondData("0d0000000001", it.first, it.second, 1, 100000).data ?: emptyList()
|
dataList.forEach {
|
if (it.lng == 0.0 && it.lat == 0.0) {
|
it.lng = 121.235813
|
it.lat = 30.835898
|
}
|
}
|
dataSet.addAll(dataList)
|
println()
|
println("[${it.first}]数据量: ${dataList.size}")
|
|
epwModel.execute(dataList, companySOPList)
|
val p = epwModel.outputToExcel(
|
// "污染权重分析结果-综合-${DateUtil().DateToString(Date(), "yyyy-MM-ddHHmmss")}.xls",
|
// "污染权重分析结果-${it.first.substring(0, 10)}.xls",
|
"污染权重分析结果-网格化-${it.first.substring(0, 10)}.xls",
|
workbook,
|
out,
|
it.first.substring(0, 10),
|
// false
|
// i == timeSet.size - 1
|
)
|
// p?.first?.let { workbook = it }
|
// p?.second?.let { out = it }
|
}
|
|
println(dataSet.size)
|
epwModel.execute(dataSet, companySOPList)
|
epwModel.outputToExcel("污染权重分析结果-综合-${DateUtil().DateToString(Date(), "yyyy-MM-ddHHmmss")}.xls", workbook, out, "综合")
|
}
|
}
|