feiyu02
昨天 e58a05b78d09bcd4c1a12e8610c5adfc316494e8
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt
@@ -46,12 +46,12 @@
        // Fixme 2025.5.14: 污染源的坐标是高德地图坐标系(火星坐标系),而走航数据是WGS84坐标系
        // 按照区域检索内部污染源信息
        var result = mutableListOf<SceneInfo>()
        // 1. 首先按照四至范围从数据库初步筛选污染源,此处的区域坐标已转换为火星坐标系
        val polygonTmp = pollutedArea.polygon
        this.sceneList = emptyList()
        if (polygonTmp != null) {
            val fb = MapUtil.calFourBoundaries(polygonTmp)
            // 1. 首先按照四至范围从数据库初步筛选污染源,此处的区域坐标已转换为火星坐标系
            val sceneList = sceneInfoRep.findByCoordinateRange(fb)
            // 2. 再精确判断是否在反向溯源区域多边形内部
            sceneList.forEach {
@@ -61,6 +61,7 @@
                }
            }
            // 3. 再统一检索近距离污染圆形区域内部的污染源
            val closePolygonTmp = pollutedArea.closePolygon!!
            val closeFb = MapUtil.calFourBoundaries(closePolygonTmp)
            val closeSceneList = sceneInfoRep.findByCoordinateRange(closeFb)
@@ -70,13 +71,12 @@
                    result.add(it)
                }
            }
            // 去重
            // 4. 去重
            result = result.distinctBy { it.guid }.toMutableList()
            // 根据污染因子的量级,计算主要的污染场景类型,筛选结果
            // 5. 根据污染因子的量级,计算主要的污染场景类型,筛选结果
            val mainSceneType = calSceneType(pollutedData)
            if (mainSceneType != null) {
//            this.conclusion = mainSceneType.first
                result = result.filter {
                    val r = mainSceneType.second.find { s ->
                        s.value == it.typeId.toInt()
@@ -107,7 +107,7 @@
//                    val coAvg = round(pollutedData.dataList.map { it.co!! }.average()) / 1000
                    val coAvg = round(pollutedData.statisticMap[FactorType.CO]?.avg ?: .0) / 1000
                    "氮氧化合物偏高,CO的量级为${coAvg}mg/m³,一般由于机动车尾气造成,污染源以汽修、加油站为主" to
                            listOf(SceneType.TYPE6, SceneType.TYPE10, SceneType.TYPE17)
                            listOf(SceneType.TYPE1, SceneType.TYPE6, SceneType.TYPE10, SceneType.TYPE17)
                }
                FactorType.CO -> "" to listOf(SceneType.TYPE6, SceneType.TYPE10, SceneType.TYPE17)
@@ -229,9 +229,6 @@
     * @return 溯源描述
     */
    private fun summaryTxt(pollutedData: PollutedData, sceneList: List<SceneInfoVo>): String {
//        pollutedData.exception
//        pollutedData.selectedFactor?.main
        val st = DateUtil.instance.getTime(pollutedData.startTime)
        val et = DateUtil.instance.getTime(pollutedData.endTime)
@@ -277,7 +274,7 @@
                        val curValue = pollutedData.dataList.last().getByFactorType(s.key)
                        if (preValue == null || curValue == null) return@forEach
                        val r = round((curValue - preValue) / preValue * 100)
                        txt += ",从${preValue}μg/m³快速上升至${curValue}μg/m³,变化率为${r}%"
                        txt += ",${s.key.getTxt()}从${preValue}μg/m³快速上升至${curValue}μg/m³,变化率为${r}%"
                    }
                }
            }