| | |
| | | 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.apache.poi.xssf.streaming.SXSSFWorkbook |
| | | 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.* |
| | | import kotlin.math.ceil |
| | | import kotlin.math.floor |
| | | |
| | | @RunWith(SpringRunner::class) |
| | | @SpringBootTest |
| | |
| | | |
| | | 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-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"), |
| | | |
| | | // 网格化监测 |
| | | Pair("2021-06-18 15: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 deviceCode = "0d0000000001" |
| | | |
| | | val epwModel = EPWModel() |
| | | var workbook: HSSFWorkbook? = null |
| | | var workbook: SXSSFWorkbook? = 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 |
| | | |
| | | var page = 1 |
| | | var totalPage = -1 |
| | | while (totalPage == -1 || page <= totalPage) { |
| | | realTimeDataService.getSecondData(deviceCode, it.first, it.second, page, 10000).apply { |
| | | if (totalPage == -1) { |
| | | totalPage = head?.totalPage ?: 0 |
| | | } |
| | | |
| | | val dataList = 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("[${page}]数据量: ${dataList.size}") |
| | | |
| | | epwModel.execute(dataList, companySOPList, true) |
| | | |
| | | page++ |
| | | } |
| | | } |
| | | dataSet.addAll(dataList) |
| | | println() |
| | | println("[${it.first}]数据量: ${dataList.size}") |
| | | |
| | | epwModel.execute(dataList, companySOPList) |
| | | val p = epwModel.outputToExcel( |
| | | // "污染权重分析结果-综合-${DateUtil().DateToString(Date(), "yyyy-MM-ddHHmmss")}.xls", |
| | | "污染权重分析结果-综合-${DateUtil.instance.dateToString(Date(), "yyyy-MM-ddHHmmss")}.xls", |
| | | // "污染权重分析结果-${it.first.substring(0, 10)}.xls", |
| | | "污染权重分析结果-网格化-${it.first.substring(0, 10)}.xls", |
| | | // "污染权重分析结果-网格化-${it.first.substring(0, 10)}.xls", |
| | | workbook, |
| | | out, |
| | | it.first.substring(0, 10), |
| | |
| | | // p?.second?.let { out = it } |
| | | } |
| | | |
| | | println(dataSet.size) |
| | | epwModel.execute(dataSet, companySOPList) |
| | | epwModel.outputToExcel("污染权重分析结果-综合-${DateUtil().DateToString(Date(), "yyyy-MM-ddHHmmss")}.xls", workbook, out, "综合") |
| | | // var page = 1 |
| | | // var totalPage = ceil(dataSet.size.toDouble() / 5000) |
| | | // println(dataSet.size) |
| | | |
| | | // val epwModel1 = EPWModel() |
| | | // epwModel1.execute(dataSet, companySOPList) |
| | | // epwModel1.outputToExcel("污染权重分析结果-综合-${DateUtil.instance.dateToString(Date(), "yyyy-MM-ddHHmmss")}.xls", workbook, out, "综合") |
| | | } |
| | | } |