From 85ef942e7195abeb71466b7159c3ee30161e1e54 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 07 四月 2026 08:51:01 +0800
Subject: [PATCH] 2026.4.7
---
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt | 199 ++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 161 insertions(+), 38 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 87908bb..987fb06 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
@@ -10,6 +10,9 @@
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.common.utils.DateUtil
import cn.flightfeather.supervision.common.utils.UUIDGenerator
+import cn.flightfeather.supervision.domain.ds1.entity.Scense
+import cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper
+import cn.flightfeather.supervision.domain.ds1.repository.SceneRep
import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep
import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.lightshare.service.*
@@ -18,6 +21,8 @@
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import tk.mybatis.mapper.entity.Example
+import java.time.LocalDateTime
+import java.time.ZoneId
import java.util.*
import kotlin.collections.ArrayList
@@ -26,6 +31,8 @@
val taskMapper: TaskMapper,
private val taskRep: TaskRep,
private val subTaskRep: SubTaskRep,
+ private val sceneRep: SceneRep,
+ private val scenseMapper: ScenseMapper,
) : TaskService {
@Autowired
@@ -318,56 +325,153 @@
return taskVoList
}
- override fun getDayTask(taskId: String, userId: String, userType: String): List<DayTaskProgressVo> {
- val example = Example(Task::class.java)
- val criteria = example.createCriteria()
- //鏋勯�犳煡璇㈡潯浠�
- criteria.andEqualTo("tsguid", taskId)
- if (userType == "1") {
- criteria.andLike("executorguids", "%$userId%")
- }
-
+ override fun getDayTask(taskId: String, userId: String?, userType: String, sceneTypeId: String?): List<DayTaskProgressVo> {
val resultList = ArrayList<DayTaskProgressVo>()
+ // 鑾峰彇鎬讳换鍔′笅鎵�鏈夋棩浠诲姟
+ val dayTasks = if (userType == "1") {
+ taskRep.findDayTasks(taskId, userId)
+ } else {
+ taskRep.findDayTasks(taskId)
+ }
+
+ // 鑾峰彇鎬讳换鍔′笅鎵�鏈夌殑瀛愪换鍔�
+ val subTasks = subTaskRep.findAll(Subtask().apply { tguid = taskId })
+ // 鑾峰彇鎵�鏈夊瓙浠诲姟娑夊強鐨勫贰鏌ュ満鏅俊鎭�
+ val sceneList = if (subTasks.isEmpty()) {
+ emptyList()
+ } else {
+ scenseMapper.selectByExample(Example(Scense::class.java).apply {
+ createCriteria().andIn("guid", subTasks.map { it?.scenseid })
+ })
+ }
+
//鏍规嵁sql鏉′欢鏌ヨ
- taskMapper.selectByExample(example).forEach {
- val exampleTotal = Example(Subtask::class.java).apply {
- createCriteria().andEqualTo("tsguid", it.tguid)
+ dayTasks.forEach { t ->
+ // 绛涢�夊綋鍓嶆棩浠诲姟涓嬬殑瀛愪换鍔�
+ val filterSubTasks = subTasks.filter { s ->
+ val scene = sceneList.find { it?.guid == s?.scenseid }
+ s?.tsguid == t?.tguid && (sceneTypeId.isNullOrBlank() || scene?.typeid.toString() == sceneTypeId)
+ }
+ // 鑾峰彇褰撴棩鎵�鏈夌殑闂
+ val subTaskIds = filterSubTasks.map { fs -> fs?.stguid }
+ val problemList = if (subTaskIds.isNotEmpty()) {
+ problemListMapper.selectByExample(Example(Problemlist::class.java).apply {
+ createCriteria().andIn("stguid", subTaskIds)
+ })
+ } else {
+ emptyList()
}
- val total = subtaskMapper.selectCountByExample(exampleTotal)
-
- val exampleComplete = exampleTotal.apply {
- and().andEqualTo("status", Constant.TaskProgress.RUNINGSTATUS3.text)
+ /** 鎬诲贰鏌ラ噺缁熻 **/
+ // 瀛愪换鍔℃�绘暟
+ val total = filterSubTasks.size
+ // 瀛愪换鍔″畬鎴愭暟
+ val complete = filterSubTasks.count { fs ->
+ fs?.status == Constant.TaskProgress.RUNINGSTATUS3.text
}
- val complete = subtaskMapper.selectCountByExample(exampleComplete)
- var changed = 0
- problemListMapper.findUnchangedCount(it.tguid ?: "").forEach { i ->
- //缁撴灉琛ㄧず璇ュ瓙浠诲姟鏈暣鏀归棶棰樻暟
- if (i == 0) {
- changed++
+ /** 鎬婚棶棰樻暣鏀圭巼缁熻 **/
+ // 鎬婚棶棰樻暟鍜屾�绘暣鏀规暟
+ val totalProblemNum = problemList.size
+ val changedProblemNum = problemList.filter { it.ischanged == true }.size
+
+ /** 姣忎釜浜虹殑宸℃煡閲忛棶棰樻暣鏀圭巼 **/
+ val userProgressMap = mutableMapOf<String, ProgressPerUserPerDay>()
+ filterSubTasks.forEach fst@{ fst ->
+ fst ?: return@fst
+ // 2026.2.2 灏嗘病鏈夋墽琛屼汉鍛樼殑浠诲姟瀹氫箟涓哄尶鍚嶇敤鎴�
+ 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 _changedDate = it.changedtime?.let { c->
+ LocalDateTime.ofInstant(c.toInstant(), ZoneId.systemDefault()).toLocalDate()
+ }
+ val _proDate = it.time?.let { t->
+ LocalDateTime.ofInstant(t.toInstant(), ZoneId.systemDefault()).toLocalDate()
+ }
+ val isSameDay = _changedDate?.equals(_proDate)
+ it.ischanged == true && (isSameDay ?: false)
+ }.size.toDouble() / ids.size
+ this.efficientChangedProNum += proList.filter {
+ // 鏁存敼鑰楁椂锛堝ぉ锛�
+ val day = ((it.changedtime?.time ?: 0L) - (it?.time?.time ?: 0L)).div(1000 * 60 * 60 * 24)
+ it.ischanged == true && day <= 2
+ }.size.toDouble() / ids.size
+ // 姝ゅ鍏堢疮璁″贰鏌ユ椂闀匡紝鏈�鍚庡啀鏍规嵁浠诲姟鏁伴噺骞冲潎
+ this.avgInspectionTime += if (fst.executionendtime == null || fst.executionstarttime == null) {
+ 0
+ } else {
+ (fst.executionendtime!!.time - fst.executionstarttime!!.time).div(1000).div(ids.size)
+ }
+ }
+
}
}
+ // 缁熶竴璁$畻骞冲潎宸℃煡鏃堕暱锛堢锛�
+ userProgressMap.forEach { (t, u) ->
+ u.avgInspectionTime = if (u.completeTaskNum == .0 ) 0 else (u.avgInspectionTime / u.completeTaskNum).toLong()
+ u.formatParam()
+ }
+ /** 浠诲姟鏁存敼瀹屾垚鎯呭喌鍜屽鏍告儏鍐电粺璁� **/
+ var changed = 0
//瀹℃牳鏄惁瀹屾垚
- var check = false
- with(subtaskMapper.selectByExample(exampleTotal)) breaking@{
- forEach {
- problemListMapper.selectByExample(Example(Problemlist::class.java).apply {
- createCriteria().andEqualTo("stguid", it.stguid)
- }).forEach { problem ->
- if (problem.extension3 == Constant.PROBLEM_UNCHECKED) {
- check = true
- return@breaking
- }
+ var check = true
+ filterSubTasks.forEach { fs ->
+ // 绛涢�夋瘡涓瓙浠诲姟涓嬬殑闂鏈暣鏀规暟
+ problemList.filter { p -> p?.stguid == fs?.stguid }.onEach { pro ->
+ // 褰撳瓨鍦ㄨ嚦灏戜竴涓棶棰樻病鏈夊鏍告椂锛屽綋鏃ュ鏍哥姸鎬佷负鏈鏍�
+ if (pro.extension3 == Constant.PROBLEM_UNCHECKED || pro.extension3 == Constant.CHANGE_UNCHECKED) {
+ check = false
+ }
+ }.count { i -> i?.ischanged != true }.let { c ->
+ // 娌℃湁鏈暣鏀归棶棰樻椂锛屽垯琛ㄧず璇ュ瓙浠诲姟宸茬粡鏁存敼瀹屾垚
+ if (c == 0) {
+ changed++
}
}
}
- resultList.add(DayTaskProgressVo(
- it.tguid, it.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
@@ -640,7 +744,7 @@
override fun create(task: Task): Task {
val res = save(task)
if (res < 1)
- throw BizException("浠诲姟鍒涘缓澶辫触")
+ throw BizException("鎬讳换鍔℃垨褰撴棩浠诲姟鍒涘缓澶辫触")
else
return task
}
@@ -757,14 +861,33 @@
districtName = t.districtname
townCode = t.towncode
townName = t.townname
+
var count = 0
+ val countByScene = mutableMapOf<String?, Int>()
+ val allScenes = sceneRep.findSceneList(t.tguid!!, areaVo.scensetypeid?.toInt(), areaVo.towncode)
taskRep.findMonitorList(t.tguid!!, areaVo.scensetypeid).forEach {
- val c = if (it.extension1 != null) it.extension1!!.toInt() else 1
+ val c = it.monitornum ?: 1
count += c
+
+ allScenes.find { s-> s?.guid == it.sguid }?.let { s->
+// if (!countByScene.containsKey(s.type)) {
+// countByScene[s.type] = 0
+// }
+ countByScene[s.type] = (countByScene[s.type] ?: 0) + c
+ }
}
totaltask = count
- subTaskSummary = subTaskRep.findSummary(areaVo)
+ totaltaskByScene = countByScene
+
+ subTaskSummary = subTaskRep.findSummary(AreaVo().apply {
+ topTaskId = t.tguid
+ })
+ val completeByScene = mutableMapOf<String?, Int>()
+ subTaskSummary?.forEach {
+ completeByScene[it.sceneType] = (completeByScene[it.sceneType] ?: 0) + 1
+ }
completetask = this.subTaskSummary?.size
+ completetaskByScene = completeByScene
}
res.add(pro)
}
--
Gitblit v1.9.3