| | |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.common.utils.ExcelUtil |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook |
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook |
| | | import java.io.File |
| | | import java.io.FileOutputStream |
| | | import java.util.* |
| | |
| | | * 污染源影响程度权重分析模型 |
| | | * 基类 |
| | | */ |
| | | abstract class BaseModel<M : BaseMData, S : BaseSOP> { |
| | | abstract class BaseModel<M : BaseMData, S: BaseSOP> { |
| | | |
| | | data class ResultCell( |
| | | var total: Double = 0.0, |
| | |
| | | * @param mDataList 监测数据集合 |
| | | * @param sopList 污染源集合 |
| | | */ |
| | | fun execute(mDataList: List<M>, sopList: List<S>, hasNext: Boolean = false) { |
| | | open fun execute(mDataList: List<M>, sopList: List<S>, hasNext: Boolean = false) { |
| | | if (!hasNext) rMap.clear() |
| | | |
| | | //1. 数据预处理 |
| | |
| | | |
| | | fun outputToExcel( |
| | | fName: String? = null, |
| | | _workbook: HSSFWorkbook? = null, |
| | | _workbook: SXSSFWorkbook? = null, |
| | | _out: FileOutputStream? = null, |
| | | sheetName: String = "sheet1", |
| | | done: Boolean = true |
| | | ): Pair<HSSFWorkbook, FileOutputStream>? { |
| | | ): Pair<SXSSFWorkbook, FileOutputStream>? { |
| | | // val rMap = formatConversion() |
| | | |
| | | val workbook = _workbook ?: HSSFWorkbook() |
| | | val workbook = _workbook ?: SXSSFWorkbook() |
| | | val fileName = fName ?: "污染溯源权重模型${DateUtil.instance.dateToString(Date(), "yyyy-MM-ddHHmmss")}.xls" |
| | | // val filePath = "E:\\work\\export\\$fileName" |
| | | // val filePath = "E:\\工作\\开发\\走航监测\\算法相关\\自动输出\\$fileName" |
| | |
| | | val lKey = "$se($factorType)" |
| | | if (lMap.containsKey(lKey)) { |
| | | val resultCell = lMap[lKey] ?: return@type |
| | | val size = resultCell.count |
| | | // val size = resultCell.count |
| | | // 添加该分类作为表头 |
| | | val h = lKey |
| | | // val h = "$lKey($size)" |
| | |
| | | return rMap |
| | | } |
| | | |
| | | /** |
| | | * 将计算结果格式化为多层级的键对值结构 |
| | | * 第一层按照不同污染源的索引值进行分类 |
| | | * 第二层按照监测因子类型进行分类 |
| | | * 第三层按照自定义的标签进行分类 |
| | | */ |
| | | private fun formatConversion2(e: BaseEffect) { |
| | | val rKey = "${e.sourceName};${e.index}" |
| | | if (!rMap.containsKey(rKey)) { |