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 |  260 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 182 insertions(+), 78 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 7853af7..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
@@ -1,5 +1,6 @@
 package cn.flightfeather.supervision.lightshare.service.impl
 
+import cn.flightfeather.supervision.common.exception.BizException
 import cn.flightfeather.supervision.domain.ds1.entity.Problemlist
 import cn.flightfeather.supervision.domain.ds1.entity.Subtask
 import cn.flightfeather.supervision.domain.ds1.entity.Task
@@ -8,6 +9,9 @@
 import cn.flightfeather.supervision.domain.ds1.mapper.TaskMapper
 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.repository.SceneRep
+import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep
 import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
 import cn.flightfeather.supervision.lightshare.service.*
 import cn.flightfeather.supervision.lightshare.vo.*
@@ -22,6 +26,8 @@
 class TaskServiceImpl(
     val taskMapper: TaskMapper,
     private val taskRep: TaskRep,
+    private val subTaskRep: SubTaskRep,
+    private val sceneRep: SceneRep,
 ) : TaskService {
 
     @Autowired
@@ -102,7 +108,7 @@
                     townRank.standardRate = it.get("standardRate").toString().toFloat()
                 } catch (e: Exception) {
                 }
-                val s =it.get("hasScoredNum").toString()
+                val s = it.get("hasScoredNum").toString()
                 try {
                     townRank.hasScoredNum = it.get("hasScoredNum").toString().toInt()
                 } catch (e: Exception) {
@@ -162,7 +168,7 @@
         if (type == 0)
             return getAllTop()
         //鑾峰彇鏈畬鎴愰《灞備换鍔″強瀵瑰簲鏃ヤ换鍔″垪琛�
-        else if (type == 1){
+        else if (type == 1) {
             val tmp = getAllTop()
             tmp.forEach {
                 if (it.runingstatus != Constant.TaskProgress.RUNINGSTATUS3.text) {
@@ -176,13 +182,13 @@
     }
 
     //鏍规嵁鏃ユ湡鑾峰彇鏃ヤ换鍔�
-    override fun findByDate(date: String): TaskVo {
+    override fun findByDate(topTaskId: String, date: String): TaskVo {
         val taskVo = TaskVo()
         val example = Example(Task::class.java)
         val criteria = example.createCriteria()
         //gsguid涓嶄负绌轰负鏃ヤ换鍔�,鏃ヤ换鍔″紑濮嬫椂闂村拰缁撴潫鏃堕棿鍦ㄥ悓涓�澶�,杩囨护寮�濮嬫椂闂村氨ok
-        criteria.andEqualTo("starttime", dateUtil.StringToDate(date.substring(0, 10)))
-        criteria.andIsNotNull("tsguid")
+        criteria.andEqualTo("starttime", DateUtil.StringToDate(date.substring(0, 10)))
+        criteria.andEqualTo("tsguid", topTaskId)
         val tasklist = taskMapper.selectByExample(example)
         if (tasklist.isNotEmpty()) {
             BeanUtils.copyProperties(tasklist[0], taskVo)
@@ -221,10 +227,10 @@
 //                .andEqualTo("districtcode", districtCode)
 //                .andLessThanOrEqualTo("endtime", date)
 //        example.or(
-                example.createCriteria().andIsNull("tsguid")
-                        .andEqualTo("districtcode", districtCode)
-                        .andLessThanOrEqualTo("starttime", date)
-                        .andGreaterThanOrEqualTo("endtime", date)
+        example.createCriteria().andIsNull("tsguid")
+            .andEqualTo("districtcode", districtCode)
+            .andLessThanOrEqualTo("starttime", date)
+            .andGreaterThanOrEqualTo("endtime", date)
 //        )
         example.orderBy("starttime").desc()
         val tasklist = taskMapper.selectByExample(example)
@@ -287,8 +293,6 @@
         return if (tasks.isEmpty()) Task() else tasks[0]
     }
 
-    val dateUtil = DateUtil()
-
     //鏍规嵁椤跺眰鍒楄〃,鏃ユ湡,鍜屾墽琛屼汉鍛業D锛岀敤鎴风被鍨嬭幏鍙栨棩浠诲姟
     override fun getDayTaskList(taskVoList: List<TaskVo>, date: String, guid: String, userType: String): List<TaskVo> {
         if (taskVoList.isEmpty()) return taskVoList
@@ -297,9 +301,9 @@
             val criteria = example.createCriteria()
             //鏋勯�犳煡璇㈡潯浠�
             criteria.andEqualTo("tsguid", it.tguid)
-            val dateTemo = dateUtil.StringToDate(date)
+            val dateTemo = DateUtil.StringToDate(date)
             //鏉′欢杩囨护
-            criteria.andBetween("starttime", dateTemo, dateUtil.addSecond(dateUtil.addMonth(dateTemo!!, 1)!!, 1))
+            criteria.andBetween("starttime", dateTemo, DateUtil.addSecond(DateUtil.addMonth(dateTemo!!, 1)!!, 1))
             if (userType == "1") {
                 criteria.andLike("executorguids", "%$guid%")
             }
@@ -316,56 +320,127 @@
         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): 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 })
+
         //鏍规嵁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->
+                s?.tsguid == t?.tguid
             }
-
-            val total = subtaskMapper.selectCountByExample(exampleTotal)
-
-            val exampleComplete = exampleTotal.apply {
-                and().andEqualTo("status", Constant.TaskProgress.RUNINGSTATUS3.text)
+            // 鑾峰彇褰撴棩鎵�鏈夌殑闂
+            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 complete = subtaskMapper.selectCountByExample(exampleComplete)
+            /** 鎬诲贰鏌ラ噺缁熻 **/
+            // 瀛愪换鍔℃�绘暟
+            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
 
-            var changed = 0
-            problemListMapper.findUnchangedCount(it.tguid ?: "").forEach {i ->
-                //缁撴灉琛ㄧず璇ュ瓙浠诲姟鏈暣鏀归棶棰樻暟
-                if (i == 0) {
-                    changed++
+            /** 姣忎釜浜虹殑宸℃煡閲忛棶棰樻暣鏀圭巼 **/
+            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 = 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
@@ -379,9 +454,9 @@
             val criteria = example.createCriteria()
             //鏋勯�犳煡璇㈡潯浠�
             criteria.andEqualTo("tsguid", it.tguid)
-            val dateTemo = dateUtil.StringToDate(date)
+            val dateTemo = DateUtil.StringToDate(date)
             //鏉′欢杩囨护
-            criteria.andBetween("starttime", dateTemo, dateUtil.addSecond(dateUtil.addMonth(dateTemo!!, 1)!!, 1))
+            criteria.andBetween("starttime", dateTemo, DateUtil.addSecond(DateUtil.addMonth(dateTemo!!, 1)!!, 1))
             criteria.andLike("executorguids", "%$guid%")
             //鏍规嵁sql鏉′欢鏌ヨ
             val taskList = taskMapper.selectByExample(example)
@@ -402,10 +477,10 @@
         if (date.length < 7) {
             return taskVoList
         }
-        val startDate = DateUtil().StringToDate(date.substring(0, 7)) ?: return taskVoList
+        val startDate = DateUtil.StringToDate(date.substring(0, 7)) ?: return taskVoList
         //鏌ヨ涓�涓湀浠诲姟
-        var endDate = DateUtil().addMonth(startDate, 1) ?: return taskVoList
-        endDate = DateUtil().addSecond(endDate, -1)!!
+        var endDate = DateUtil.addMonth(startDate, 1) ?: return taskVoList
+        endDate = DateUtil.addSecond(endDate, -1)!!
         //鏋勯�犳煡璇㈡潯浠�
         val example = Example(Task::class.java)
         val criteria = example.createCriteria()
@@ -454,22 +529,22 @@
 //            return taskVoList
 //        }
 //        //鏃堕棿杞崲
-//        val d1 = DateUtil().StringToDate(date.substring(0, 7)) ?: return taskVoList
+//        val d1 = DateUtil.StringToDate(date.substring(0, 7)) ?: return taskVoList
 //        var startDate: Date? = null
 //        var endDate: Date? = null
 //        //鏍规嵁type绫诲瀷,寰楀埌瑕佹煡璇㈢殑鑼冨洿
 //        when (type) {
 //            "Middle" -> {
-//                startDate = DateUtil().addMonth(d1, -1);endDate = DateUtil().addMonth(d1, 2)
+//                startDate = DateUtil.addMonth(d1, -1);endDate = DateUtil.addMonth(d1, 2)
 //            }
 //            "Left" -> {
-//                startDate = DateUtil().addMonth(d1, -3);endDate = d1
+//                startDate = DateUtil.addMonth(d1, -3);endDate = d1
 //            }
 //            "Right" -> {
-//                startDate = DateUtil().addMonth(d1, 1);endDate = DateUtil().addMonth(d1, 4)
+//                startDate = DateUtil.addMonth(d1, 1);endDate = DateUtil.addMonth(d1, 4)
 //            }
 //            else -> {
-//                startDate = d1;endDate = DateUtil().addMonth(d1, 1)
+//                startDate = d1;endDate = DateUtil.addMonth(d1, 1)
 //            }
 //        }
 //
@@ -498,10 +573,10 @@
         if (date.length < 7) {
             return taskVoList
         }
-        val startDate = DateUtil().StringToDate(date.substring(0, 7)) ?: return taskVoList
+        val startDate = DateUtil.StringToDate(date.substring(0, 7)) ?: return taskVoList
         //鏌ヨ涓�涓湀浠诲姟
-        var endDate = DateUtil().addMonth(startDate, 1) ?: return taskVoList
-        endDate = DateUtil().addSecond(endDate, -1)!!
+        var endDate = DateUtil.addMonth(startDate, 1) ?: return taskVoList
+        endDate = DateUtil.addSecond(endDate, -1)!!
         //鏋勯�犳煡璇㈡潯浠�
         val example = Example(Task::class.java)
         val criteria = example.createCriteria()
@@ -522,25 +597,25 @@
 
         val criteria2 = example.createCriteria()
         criteria2.orBetween(
-                "endtime",
-                startDate,
-                endDate
+            "endtime",
+            startDate,
+            endDate
         ).andIsNull("tsguid");
         if (userType == "1") {
             criteria2.andLike("executorguids", "%$guid%")
-        } else if (userType == "2"){
+        } else if (userType == "2") {
             criteria2.andEqualTo("districtcode", districtCode)
         }
         example.or(criteria2)
 
         val criteria3 = example.createCriteria()
         criteria3.orLessThan("starttime", startDate).andGreaterThan(
-                "endtime",
-                endDate
+            "endtime",
+            endDate
         ).andIsNull("tsguid");
         if (userType == "1") {
             criteria3.andLike("executorguids", "%$guid%")
-        } else if (userType == "2"){
+        } else if (userType == "2") {
             criteria3.andEqualTo("districtcode", districtCode)
         }
         example.or(criteria3)
@@ -587,7 +662,7 @@
         }
         return taskVoList
     }
-    
+
     override fun save(task: Task): Int {
         // FIXME: 2021/10/9 鎸夌収褰撳墠鐨勯�昏緫锛屾鍑芥暟涓昏鐢ㄤ簬鏂板缓椤跺眰浠诲姟浠ュ強鏃ヤ换鍔★紝浣嗘槸鏃ヤ换鍔″唴瀹圭殑鐢熸垚閫昏緫鐩墠鐢卞墠绔痑pp瀹屾垚锛屽洜姝や細鍑虹幇涓�涓猙ug锛�
         // FIXME: 2021/10/9 褰撳墠绔涓敤鎴峰悓鏃跺湪鍚屼竴涓《灞備换鍔′笅鐨勬柊鐨勪竴澶╁垱寤轰换鍔℃椂锛屼細鍑虹幇鍚屼竴澶╂湁澶氫釜鏃ヤ换鍔★紝姝ゆ椂鍓嶇鍚庣画鏌ョ湅鍙兘鐪嬪埌鍏朵腑涓�涓棩浠诲姟涓嬬殑瀛愪换鍔�
@@ -595,6 +670,7 @@
         // FIXME: 2021/10/9 鍙﹀瀵逛簬椤跺眰浠诲姟涔熸坊鍔犵被浼奸�昏緫锛岀敱浜庨《灞備换鍔$殑浠诲姟鍚嶇О榛樿绯荤粺鑷姩鐢熸垚锛屽洜姝ゆ殏鏃跺彧鍒ゆ柇鍚屽悕鐨勯《灞備换鍔★紝褰撳瓨鍦ㄥ悓鍚嶉《灞備换鍔℃椂锛屼笉鍋氫繚瀛樻搷浣�
 
         var result = 0
+        if (task.tguid == null) task.tguid = UUIDGenerator.generate16ShortUUID()
         // 1銆侀鍏堝垽鏂槸椤跺眰浠诲姟杩樻槸鏃ヤ换鍔�
         if (task.levelnum == 2) {
             //2.1銆� 鏄《灞備换鍔℃椂锛屽垽鏂槸鍚﹀凡鏈夊悓鍚嶄换鍔�
@@ -608,7 +684,7 @@
             }
         } else {
             //3.1銆� 褰撴槸鏃ヤ换鍔℃椂锛屽垽鏂湪鍚屼竴涓《灞備换鍔′笅锛屾槸鍚︽湁鍚屽悕鐨勬棩浠诲姟
-            val r  =taskMapper.selectByExample(Example(Task::class.java).apply {
+            val r = taskMapper.selectByExample(Example(Task::class.java).apply {
                 createCriteria().andEqualTo("tsguid", task.tsguid)
                     .andEqualTo("name", task.name)
             })
@@ -634,6 +710,14 @@
         return result
     }
 
+    override fun create(task: Task): Task {
+        val res = save(task)
+        if (res < 1)
+            throw BizException("浠诲姟鍒涘缓澶辫触")
+        else
+            return task
+    }
+
     //淇敼鏃ヤ换鍔′俊鎭�,鑻ユ湁瀛愪换鍔�,瀛愪换鍔′篃淇敼
     override fun update(task: Task): Int {
         var re = 1
@@ -646,7 +730,7 @@
                 BeanUtils.copyProperties(it, subtask)
                 subtask.planstarttime = task.starttime
                 subtask.planendtime = task.endtime
-                subtaskService.update(subtask)
+                subtaskService.changeStatus(subtask)
             }
         }
         return re
@@ -665,7 +749,7 @@
         criteria.andIsNull("tsguid")
         example.orderBy("starttime").asc()
         val result = taskMapper.selectByExample(example)
-        if (result.isNotEmpty()){
+        if (result.isNotEmpty()) {
             result.forEach {
                 var mytotalcount = 0
                 var mycompletecount = 0
@@ -692,7 +776,7 @@
                     taskProgressVo.mycompletetask = mycompletecount
                     val daytaskVolist = getDayTaskByTaskID(it.tguid!!)
                     val daytasklist = mutableListOf<TaskVo>()
-                    if (daytaskVolist.isNotEmpty()){
+                    if (daytaskVolist.isNotEmpty()) {
                         daytaskVolist.forEach {
                             var mytotalcount1 = 0
                             var mycompletecount1 = 0
@@ -704,7 +788,7 @@
                                     if (Objects.equals(it.status!!, Constant.TaskProgress.RUNINGSTATUS3.text))
                                         mycompletecount1++
                                 }
-                                if(Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text))
+                                if (Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text))
                                     completecount1++
                             }
                             val daytaskProgressVo = TaskVo()
@@ -732,7 +816,7 @@
 
     override fun findTaskProgress(areaVo: AreaVo): List<TaskProgressVo?> {
         val res = mutableListOf<TaskProgressVo?>()
-        taskRep.findTasks(areaVo).forEach {t->
+        taskRep.findTasks(areaVo).forEach { t ->
             if (t?.tguid == null) return@forEach
             val pro = TaskProgressVo().apply {
                 tguid = t.tguid
@@ -746,13 +830,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
-                completetask = subtaskService.getSummary(t.tguid!!, areaVo.scensetypeid?.toIntOrNull()).size
+                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