From 7cbe1610b87da19ed8a146a09b1117f92d9d3d98 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期五, 19 九月 2025 17:30:37 +0800
Subject: [PATCH] 2025.9.19 1. 联合前端调试数据产品接口(待完成)
---
src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt | 18 +++++++++
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/DPMonitorDataInfo.kt | 2 +
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdBaseServiceImpl.kt | 12 ++++-
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/BaseResPack.kt | 2
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/middle/DPProblemTypeCount.kt | 5 ++
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdMiddleServiceImpl.kt | 25 +++++++++++-
6 files changed, 58 insertions(+), 6 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt
index 85bffce..5b6a53a 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt
@@ -89,4 +89,22 @@
orderBy("starttime").desc()
})
}
+
+ /**
+ * 鑾峰彇鐩稿悓鍖哄煙鍐呬笂涓懆鏈熺殑鎬讳换鍔�
+ */
+ fun findLastTopTask(taskId: String?): Task? {
+ val task = taskMapper.selectByPrimaryKey(taskId) ?: return null
+
+ return taskMapper.selectByExample(Example(Task::class.java).apply {
+ createCriteria()
+ .andNotEqualTo("tguid", task.tguid)
+ .andEqualTo("typeno", task.typeno)
+ .andEqualTo("levelnum", 2)
+ .andEqualTo("provincecode", task.provincecode)
+ .andEqualTo("citycode", task.citycode)
+ .andEqualTo("districtcode", task.districtcode)
+ orderBy("starttime").desc()
+ }).firstOrNull()
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdBaseServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdBaseServiceImpl.kt
index 0cd663b..8c6e098 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdBaseServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdBaseServiceImpl.kt
@@ -211,16 +211,22 @@
cache = { return@queryCache null },
calculate = {
val res = mutableListOf<DPMonitorDataInfo>()
- val objList = aopDbMapper.monitorobjectversionMapper.selectByExample(Example(Monitorobjectversion::class.java).apply {
+ val sceneIdList = aopDbMapper.monitorobjectversionMapper.selectByExample(Example(Monitorobjectversion::class.java).apply {
createCriteria().andEqualTo("tid", queryOpt.topTaskId)
+ }).map { it.sguid }
+ if (sceneIdList.isEmpty()) return@queryCache res
+
+ val sceneList = aopDbMapper.scenseMapper.selectByExample(Example(Scense::class.java).apply {
+ createCriteria().andIn("guid", sceneIdList)
+ .andEqualTo("typeid", queryOpt.sceneTypeId)
})
- if (objList.isEmpty()) return@queryCache res
aopDbMapper.dustDataResultMapper.selectByExample(Example(DustDataResult::class.java).apply {
createCriteria().andBetween("drTime", queryOpt.startTime, queryOpt.endTime)
- .andIn("objectId", objList.map { it.sguid })
+ .andIn("drSceneId", sceneList.map { it.guid })
}).forEach {
res.add(DPMonitorDataInfo().apply {
+ scene = sceneList.find { scene -> scene.guid == it?.drSceneId }
data = it
})
}
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 b6e4029..f59c1d0 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
@@ -3,6 +3,7 @@
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.common.utils.QueryByCache
import cn.flightfeather.supervision.domain.ds1.entity.SceneConstructionSite
+import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.lightshare.service.DataProdBaseService
import cn.flightfeather.supervision.lightshare.service.DataProdMiddleService
import cn.flightfeather.supervision.lightshare.vo.dataprod.QueryOpt
@@ -10,6 +11,7 @@
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 org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service
/**
@@ -18,7 +20,10 @@
* @author feiyu02
*/
@Service
-class DataProdMiddleServiceImpl(private val dataProdBaseService: DataProdBaseService) : DataProdMiddleService {
+class DataProdMiddleServiceImpl(
+ private val dataProdBaseService: DataProdBaseService, private val taskRep: TaskRep,
+) : DataProdMiddleService {
+
override fun getInspectionSummary(queryOpt: QueryOpt): DPInspectionSummary {
return QueryByCache.queryCache(
@@ -34,7 +39,7 @@
when (it.scene?.typeid.toString()) {
// 瀵逛簬寤虹瓚宸ュ湴绫诲瀷锛屾牴鎹叾csStatus鍒ゆ柇鏄惁鍋滃伐鎴栧畬宸�
Constant.SceneType.TYPE1.value -> {
- when ((it.subScene as SceneConstructionSite).csStatus) {
+ when ((it.subScene as SceneConstructionSite?)?.csStatus) {
"鍋滃伐" -> {
res.stopSceneCount++
}
@@ -62,6 +67,16 @@
return QueryByCache.queryCache(
cache = { return@queryCache null },
calculate = {
+ // 鏌ヨ涓婁竴涓懆鏈熺殑鎬讳换鍔$粺璁℃儏鍐�
+ val lastTopTask = taskRep.findLastTopTask(queryOpt.topTaskId)
+ val lastQueryOpt = QueryOpt()
+ BeanUtils.copyProperties(queryOpt, lastQueryOpt)
+ lastQueryOpt.topTaskId = lastTopTask?.tguid
+ val lastInspectionInfo = dataProdBaseService.getInspectionInfo(lastQueryOpt)
+ val lastAllProblemList = lastInspectionInfo.flatMap { it.problems ?: emptyList() }
+ val lastAllProblemMap = lastAllProblemList.groupBy { it.typeid }
+
+ // 鏌ヨ褰撳墠鍛ㄦ湡鐨勬�讳换鍔$粺璁℃儏鍐�
val res = mutableListOf<DPProblemTypeCount>()
val inspectionInfo = dataProdBaseService.getInspectionInfo(queryOpt)
val allProblemList = inspectionInfo.flatMap { it.problems ?: emptyList() }
@@ -71,6 +86,12 @@
this.typeName = problemList.firstOrNull()?.typename
this.count = problemList.size
this.ratio = problemList.size.toDouble() / allProblemList.size
+ this.ratioDiff =
+ if (lastAllProblemMap[typeid] == null) {
+ this.ratio
+ } else {
+ this.ratio - lastAllProblemMap[typeid]!!.size.toDouble() / lastAllProblemList.size
+ }
})
}
return@queryCache res
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/DPMonitorDataInfo.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/DPMonitorDataInfo.kt
index 7a50c06..daeb2ef 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/DPMonitorDataInfo.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/DPMonitorDataInfo.kt
@@ -1,6 +1,7 @@
package cn.flightfeather.supervision.lightshare.vo.dataprod
import cn.flightfeather.supervision.domain.ds1.entity.DustDataResult
+import cn.flightfeather.supervision.domain.ds1.entity.Scense
/**
* 鏁版嵁浜у搧鐩戞祴鏁版嵁淇℃伅
@@ -8,5 +9,6 @@
* @author feiyu02
*/
class DPMonitorDataInfo {
+ var scene: Scense? = null
var data: DustDataResult? = null
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/middle/DPProblemTypeCount.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/middle/DPProblemTypeCount.kt
index c647157..756b7a5 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/middle/DPProblemTypeCount.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/middle/DPProblemTypeCount.kt
@@ -25,4 +25,9 @@
* 闂鏁伴噺鍗犳瘮
*/
var ratio: Double = 0.0
+
+ /**
+ * 闂鏁伴噺鍗犳瘮涓庝笂涓�涓椂闂寸偣鐨勫樊鍊�
+ */
+ var ratioDiff: Double = 0.0
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/BaseResPack.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/BaseResPack.kt
index 08d072d..bea0ef7 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/BaseResPack.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/BaseResPack.kt
@@ -24,7 +24,7 @@
BaseResponse(false, message = e.message ?: "", stackTrace = e.stackTraceToString())
} catch (e: Exception) {
// fixme: to log system
-
+ e.printStackTrace()
BaseResponse(false, message = "鏈嶅姟鍣ㄥ嚭鐜板唴閮ㄩ敊璇�", stackTrace = e.stackTraceToString())
}
}
\ No newline at end of file
--
Gitblit v1.9.3