From cc2a28ad6b99795d05cd9c923d8f7da27b4509e3 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期三, 04 六月 2025 17:31:41 +0800
Subject: [PATCH] 1. 新增动态污染溯源新的判定逻辑(待完成)
---
src/main/kotlin/com/flightfeather/uav/biz/report/MissionReport.kt | 61 +++++++++++++++++++++---------
1 files changed, 42 insertions(+), 19 deletions(-)
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionReport.kt b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionReport.kt
index 0a497c4..e898e97 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionReport.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionReport.kt
@@ -1,18 +1,19 @@
package com.flightfeather.uav.biz.report
+import com.flightfeather.uav.biz.FactorFilter
import com.flightfeather.uav.biz.dataanalysis.ExceptionAnalysisController
import com.flightfeather.uav.biz.dataanalysis.model.ExceptionResult
import com.flightfeather.uav.biz.dataprocess.PreData
-import com.flightfeather.uav.common.chart.ChartUtil
import com.flightfeather.uav.common.chart.DataToChartUtil
import com.flightfeather.uav.common.exception.BizException
+import com.flightfeather.uav.common.location.LocationRoadNearby
import com.flightfeather.uav.common.pdf.GeneratePdfUtil
import com.flightfeather.uav.common.utils.DateUtil
import com.flightfeather.uav.common.utils.ImageUtil
import com.flightfeather.uav.domain.entity.Mission
import com.flightfeather.uav.domain.repository.MissionRep
import com.flightfeather.uav.domain.repository.RealTimeDataRep
-import com.flightfeather.uav.socket.eunm.FactorType
+import com.flightfeather.uav.domain.repository.SegmentInfoRep
import org.springframework.beans.BeanUtils
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component
@@ -25,12 +26,17 @@
*/
@Component
class MissionReport(
- private val exceptionAnalysisController: ExceptionAnalysisController,
private val missionRep: MissionRep,
private val realTimeDataRep: RealTimeDataRep,
+ private val locationRoadNearby: LocationRoadNearby,
+ private val segmentInfoRep: SegmentInfoRep,
@Value("\${filePath}")
private val filePath: String,
) {
+
+ private val exceptionAnalysisController =
+ ExceptionAnalysisController(realTimeDataRep, locationRoadNearby, segmentInfoRep)
+
data class Param(
val district: String,
val town: String,
@@ -54,11 +60,22 @@
*/
fun addExceptions(exceptions: List<ExceptionResult>) {
this.exceptions = exceptions.map {
- val byteArray = DataToChartUtil.lineToByteArray(FactorType.getByValue(it.factorId!!), it.dataList)
- val base64Str = ImageUtil.compressImage2(byteArray, 400, needPrefix = false)
val c = ExceptionChart()
BeanUtils.copyProperties(it, c)
- c.pict = base64Str
+ // 鍒涘缓涓绘薄鏌撳洜瀛愮殑鏁版嵁鎶樼嚎鍥�
+ val byteArray = DataToChartUtil.lineToByteArray(it.selectedFactor?.main, it.dataList)
+ val base64Str = ImageUtil.compressImage2(byteArray, 800, needPrefix = false)
+ c.mainPict = base64Str
+ // 鍒涘缓鍏宠仈鍥犲瓙鐨勬暟鎹姌绾垮浘
+ if (it.selectedFactor?.subs?.isNotEmpty() == true) {
+ val subList = mutableListOf<String>()
+ it.selectedFactor!!.subs.forEach { type ->
+ val byteArray1 = DataToChartUtil.lineToByteArray(type, it.dataList)
+ val base64Str1 = ImageUtil.compressImage2(byteArray1, 800, needPrefix = false)
+ subList.add(base64Str1)
+ }
+ c.subPictList = subList
+ }
return@map c
}
}
@@ -82,8 +99,11 @@
* 鏁版嵁寮傚父鎵�鍦ㄦ椂娈电殑鎶樼嚎鍥�
*/
class ExceptionChart : ExceptionResult() {
- // 鏁版嵁鎶樼嚎鍥綛ase64缂栫爜
- var pict: String? = null
+ // 姹℃煋鍥犲瓙鐨勫紓甯告暟鎹姌绾垮浘Base64缂栫爜
+ var mainPict: String? = null
+
+ // 鍏宠仈鍥犲瓙鐨勫紓甯告暟鎹姌绾垮浘Base64缂栫爜
+ var subPictList: List<String>? = null
}
private val templateName = "report-underway.ftl"
@@ -91,13 +111,16 @@
private val dateFormatter = DateTimeFormatter.ofPattern("HH:mm")
// 鑾峰彇寮傚父鍒嗘瀽缁撴灉
- fun exceptionAnalysis(mission: Mission): List<ExceptionResult> {
- return exceptionAnalysisController.run(mission)
+ fun exceptionAnalysis(mission: Mission, factorFilter: FactorFilter): List<ExceptionResult> {
+ return exceptionAnalysisController.execute(mission, factorFilter)
}
// 璁$畻鍧囧�煎拰鏁版嵁鑼冨洿
- fun dataSummary(mission: Mission): List<Summary> {
- val preData = PreData(DateUtil.instance.dateToString(mission.startTime, DateUtil.DateStyle.YYYY_MM_DD))
+ fun dataSummary(mission: Mission, factorFilter: FactorFilter): List<Summary> {
+ val preData = PreData(
+ DateUtil.instance.dateToString(mission.startTime, DateUtil.DateStyle.YYYY_MM_DD),
+ factorFilter.mainList()
+ )
val realTimeData = realTimeDataRep.fetchData(mission)
realTimeData.forEach {
preData.add(it.toDataVo())
@@ -114,7 +137,7 @@
max = u.max
val byteArray = DataToChartUtil.lineToByteArray(t, realTimeData)
- val base64Str = ImageUtil.compressImage2(byteArray, 400, needPrefix = false)
+ val base64Str = ImageUtil.compressImage2(byteArray, 800, needPrefix = false)
pict = base64Str
})
}
@@ -123,22 +146,22 @@
// 鐢熸垚鍙傛暟
// 鏍规嵁鎶ュ憡妯℃澘鐢熸垚瀵瑰簲鎶ュ憡
- fun execute(missionCode: String): String {
+ fun execute(missionCode: String, factorFilter: FactorFilter): String {
// 1. 浠诲姟鍚堟硶鎬ф鏌�
val mission = missionRep.findOne(missionCode) ?: throw BizException("璇ヤ换鍔$紪鍙蜂笉瀛樺湪")
- // 2. 鑾峰彇鏁版嵁寮傚父缁熻缁撴灉
- val exceptions = exceptionAnalysis(mission)
+ // 2. 鑾峰彇鏁版嵁寮傚父缁熻缁撴灉锛屾牴鎹�
+ val exceptions = exceptionAnalysis(mission, factorFilter)
// 3. 鑾峰彇鍧囧�笺�佽寖鍥寸瓑缁熻鏁版嵁
- val summaries = dataSummary(mission)
+ val summaries = dataSummary(mission, factorFilter)
// 4. 鐢熸垚鎶ュ憡
val fileName = "report/" + "${mission.districtName}璧拌埅鐩戞祴鎶ュ憡-${
DateUtil.instance.dateToString(mission.startTime, DateUtil.DateStyle.YYYY_MM_DD)
- }.doc"
+ }(${mission.missionCode}).doc"
val reportTemplate = ReportTemplate(templateName, filePath, fileName)
val param = getParam(mission, exceptions, summaries)
val params = reportTemplate.getParam(param)
GeneratePdfUtil.generateWord(params)
- return fileName
+ return filePath + fileName
}
private fun getParam(mission: Mission, exceptions: List<ExceptionResult>, summaries: List<Summary>): Param {
--
Gitblit v1.9.3