From 9cb8d7e0f4ffca386b14a15f8a0aca4d1db23252 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 30 十月 2025 15:58:45 +0800
Subject: [PATCH] 2025.10.30 新增单场景纵向统计接口

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdMiddleServiceImpl.kt |   47 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdMiddleServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdMiddleServiceImpl.kt
index f59c1d0..6d46bc9 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdMiddleServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdMiddleServiceImpl.kt
@@ -7,10 +7,7 @@
 import cn.flightfeather.supervision.lightshare.service.DataProdBaseService
 import cn.flightfeather.supervision.lightshare.service.DataProdMiddleService
 import cn.flightfeather.supervision.lightshare.vo.dataprod.QueryOpt
-import cn.flightfeather.supervision.lightshare.vo.dataprod.middle.DPEvaluationByArea
-import cn.flightfeather.supervision.lightshare.vo.dataprod.middle.DPInspectionSummary
-import cn.flightfeather.supervision.lightshare.vo.dataprod.middle.DPProblemCountByArea
-import cn.flightfeather.supervision.lightshare.vo.dataprod.middle.DPProblemTypeCount
+import cn.flightfeather.supervision.lightshare.vo.dataprod.middle.*
 import org.springframework.beans.BeanUtils
 import org.springframework.stereotype.Service
 
@@ -59,7 +56,6 @@
                 }
                 return@queryCache res
             },
-            save = {}
         )
     }
 
@@ -96,7 +92,6 @@
                 }
                 return@queryCache res
             },
-            save = {}
         )
     }
 
@@ -122,13 +117,12 @@
                             this.townName = firstSubtask?.townname
                             this.sceneCount = ins.distinctBy { it.subTask?.scenseid }.size
                             this.problemCount = allProblemList.size
-                            this.ratio = problemCount.toDouble() / sceneCount
+                            this.proAvg = problemCount.toDouble() / sceneCount
                         })
                     }
 
                 return@queryCache res
             },
-            save = {}
         )
     }
 
@@ -168,7 +162,42 @@
 
                 return@queryCache res
             },
-            save = {}
+        )
+    }
+
+    override fun getTypicalProblems(queryOpt: QueryOpt, rateTotal: Double): List<DPTypicalProblemScene> {
+        return QueryByCache.queryCache(
+            cache = { return@queryCache null },
+            calculate = {
+                val res = mutableListOf<DPTypicalProblemScene>()
+                val inspectionInfo = dataProdBaseService.getInspectionInfo(queryOpt)
+                inspectionInfo.groupBy { it.subTask?.scenseid }.forEach { (sceneId, ins) ->
+                    val problems = ins.flatMap { it.problems ?: emptyList() }
+                    if (problems.isEmpty()) return@forEach
+
+                    val unChangePros = problems.filter { it.ischanged != true }
+                    val changeRatio = if (problems.isNotEmpty()) {
+                        (problems.size - unChangePros.size.toDouble()) / problems.size
+                    } else {
+                        0.0
+                    }
+                    if (changeRatio < rateTotal) {
+                        res.add(DPTypicalProblemScene().apply {
+                            val firstSubtask = ins.first().subTask
+                            this.sceneId = sceneId
+                            this.sceneName = firstSubtask?.scensename
+                            this.townCode = firstSubtask?.towncode
+                            this.townName = firstSubtask?.townname
+                            this.problemCount = problems.size
+                            this.changeCount = problems.size - unChangePros.size
+                            this.changeRatio = changeRatio
+                            this.typicalProblems = unChangePros
+                                .distinctBy { it.ptguid }
+                        })
+                    }
+                }
+                return@queryCache res
+            },
         )
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3