From 5a003a42d2b34e8362910ac1d3e5a8866768e5fe Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期六, 20 十二月 2025 16:50:28 +0800
Subject: [PATCH] 2025.12.20 巡查任务统计相关功能修改
---
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt | 84 ++++++++++++++++++++++++++++++++++++-----
1 files changed, 73 insertions(+), 11 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt
index f103925..61140aa 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt
@@ -339,14 +339,6 @@
val filterSubTasks = subTasks.filter {s->
s?.tsguid == t?.tguid
}
- // 瀛愪换鍔℃�绘暟
- val total = filterSubTasks.size
-
- // 瀛愪换鍔″畬鎴愭暟
- val complete = filterSubTasks.count {fs->
- fs?.status == Constant.TaskProgress.RUNINGSTATUS3.text
- }
-
// 鑾峰彇褰撴棩鎵�鏈夌殑闂
val subTaskIds = filterSubTasks.map { fs-> fs?.stguid }
val problemList = if (subTaskIds.isNotEmpty()) {
@@ -356,8 +348,69 @@
} else{
emptyList()
}
+ /** 鎬诲贰鏌ラ噺缁熻 **/
+ // 瀛愪换鍔℃�绘暟
+ val total = filterSubTasks.size
+ // 瀛愪换鍔″畬鎴愭暟
+ val complete = filterSubTasks.count {fs->
+ fs?.status == Constant.TaskProgress.RUNINGSTATUS3.text
+ }
+ /** 鎬婚棶棰樻暣鏀圭巼缁熻 **/
+ // 鎬婚棶棰樻暟鍜屾�绘暣鏀规暟
+ val totalProblemNum = problemList.size
+ val changedProblemNum = problemList.filter { it.ischanged == true }.size
+ /** 姣忎釜浜虹殑宸℃煡閲忛棶棰樻暣鏀圭巼 **/
+ val userProgressMap = mutableMapOf<String, ProgressPerUserPerDay>()
+ filterSubTasks.forEach fst@ { fst->
+ fst ?: return@fst
+ // fixme 2025.11.30 鐢变簬鐩戠APP鐨刡ug锛屽鑷寸敤鎴峰彲浠ヤ笉閫夋嫨鎵ц浜哄憳鐩存帴鍒涘缓浠诲姟锛屾墍浠ユ殏鏃跺皢娌℃湁鎵ц浜哄憳鐨勪换鍔″畾涔変负鍖垮悕鐢ㄦ埛
+ if (fst.executorguids.isNullOrBlank()) {
+ fst.executorguids = "niming"
+ fst.executorusernames = "niming"
+ fst.executorrealtimes = "鍖垮悕鐢ㄦ埛"
+ }
+ val ids = fst.executorguids?.split("#") ?: return@fst
+ val names = fst.executorrealtimes?.split("#") ?: return@fst
+ // 绛涢�夋瘡涓瓙浠诲姟涓嬬殑闂
+ val proList = problemList.filter { p-> p?.stguid == fst.stguid }
+ for (i in ids.indices) {
+ val key = ids[i]
+ if (!userProgressMap.containsKey(key)) {
+ userProgressMap[key] = ProgressPerUserPerDay().apply {
+ this.userId = key
+ this.userName = names[i]
+ }
+ }
+ userProgressMap[key]?.apply {
+ // 鍗曚汉宸℃煡閲忕疮璁�
+ // 褰撳涓汉涓�璧锋墽琛屽悓涓�浠诲姟鏃讹紝骞冲垎宸℃煡閲�
+ this.totalTaskNum += 1.0 / ids.size
+ if (fst.status== Constant.TaskProgress.RUNINGSTATUS3.text)
+ this.completeTaskNum += 1.0 / ids.size
+ // 鍗曚汉鏁存敼鐜囩疮璁★紙璇勫垎锛�
+ this.totalProblemNum += proList.size.toDouble() / ids.size
+ this.changedProblemNum += proList.filter { it.ischanged == true }.size.toDouble() / ids.size
+ this.changedProblemNumOnTime += proList.filter {
+ // 鏁存敼鑰楁椂锛堝ぉ锛�
+ val day = ((it.changedtime?.time ?: 0L) - (it?.time?.time ?: 0L)).div(1000 * 60 * 60 * 24)
+ it.ischanged == true && day <= 1
+ }.size.toDouble() / ids.size
+ // 姝ゅ鍏堢疮璁″贰鏌ユ椂闀匡紝鏈�鍚庡啀鏍规嵁浠诲姟鏁伴噺骞冲潎
+ this.avgInspectionTime +=
+ ((fst.executionendtime?.time ?: 0L) - (fst.executionstarttime?.time ?: 0L)).div(1000).div(ids.size)
+ }
+
+ }
+ }
+ // 缁熶竴璁$畻骞冲潎宸℃煡鏃堕暱锛堢锛�
+ userProgressMap.forEach { (t, u) ->
+ u.avgInspectionTime = (u.avgInspectionTime / u.completeTaskNum).toLong()
+ u.formatParam()
+ }
+
+ /** 浠诲姟鏁存敼瀹屾垚鎯呭喌鍜屽鏍告儏鍐电粺璁� **/
var changed = 0
//瀹℃牳鏄惁瀹屾垚
var check = true
@@ -376,9 +429,18 @@
}
}
- resultList.add(DayTaskProgressVo(
- t?.tguid, t?.starttime, taskId, complete, changed, total, check
- ))
+ resultList.add(DayTaskProgressVo().apply {
+ this.guid =t?.tguid
+ this.date =t?.starttime
+ this.tsGuid = taskId
+ this.totalTaskNum = total
+ this.completeTaskNum = complete
+ this.changedTaskNum = changed
+ this.check = check
+ this.totalProblemNum = totalProblemNum
+ this.changedProblemNum = changedProblemNum
+ this.progressPerUser = userProgressMap.entries.map { it.value }
+ })
}
return resultList
--
Gitblit v1.9.3