feiyu02
2024-05-31 da431c25dfe5122e4ed70372da36ede3e4eaec4a
src/main/kotlin/com/flightfeather/uav/biz/dataprocess/DataProcess.kt
ÎļþÃû´Ó src/main/kotlin/com/flightfeather/uav/dataprocess/DataProcess.kt ÐÞ¸Ä
@@ -1,14 +1,13 @@
package com.flightfeather.uav.dataprocess
package com.flightfeather.uav.biz.dataprocess
import com.flightfeather.uav.common.utils.DateUtil
import com.flightfeather.uav.common.utils.ExcelUtil
import com.flightfeather.uav.lightshare.bean.DataVo
import com.flightfeather.uav.socket.eunm.FactorType
import org.apache.poi.xssf.streaming.SXSSFWorkbook
import org.apache.poi.xssf.usermodel.XSSFWorkbook
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.util.*
/**
 * æ•°æ®å¤„理
@@ -22,7 +21,21 @@
    companion object {
        const val SHEET1 = "小时数据"
        const val SHEET2 = "日数据"
        const val SHEET3 = "日变化"
        const val SHEET3 = "日变化"//需要计算的项目
        val needFactor: List<FactorType> = listOf(
            FactorType.NO2,
            FactorType.CO,
            FactorType.H2S,
            FactorType.SO2,
            FactorType.O3,
            FactorType.PM25,
            FactorType.PM10,
            FactorType.VOC
        )
        val items = listOf(
            "记录数", "均值", "标准差", "最小值", "最大值", "10%分位值", "25%分位值", "50%分位值", "75%分位值", "90%分位值"
        )
    }
    //每日小时数据
    private val dateData = mutableMapOf<String?, PreData>()
@@ -73,7 +86,7 @@
            dayData[day]?.add(it)
            if (!dailyVariationData.containsKey(hour)) {
                dailyVariationData[hour] = PreData(hour, false)
                dailyVariationData[hour] = PreData(hour, needQuartile = false)
            }
            dailyVariationData[hour]?.add(it)
        }
@@ -92,12 +105,12 @@
        //第一行为时间以及监测因子名称,并且需要根据下一行的统计项合并列
        val firstRow = mutableListOf<ExcelUtil.MyCell>()
        firstRow.add(ExcelUtil.MyCell("时间", 2))
        PreData.needFactor.forEach { firstRow.add(ExcelUtil.MyCell(it.des, colSpan = PreData.items.size)) }
        needFactor.forEach { firstRow.add(ExcelUtil.MyCell(it.des, colSpan = items.size)) }
        contents.add(firstRow.toTypedArray())
        //第二行为每种监测因子对应的统计项,具体为记录数、均值、标准差、最小值、最大值、10/25/50/75/90%分位值,每种监测因子有10列
        val secondRow = mutableListOf<String>()
        secondRow.add("")
        repeat(PreData.needFactor.size) { secondRow.addAll(PreData.items) }
        repeat(needFactor.size) { secondRow.addAll(items) }
        contents.add(secondRow.toTypedArray())
        //分sheet建立标题
        sheetRow.forEach { (s, i) ->