From 99be60a4c8c1f39eb01d414460cbe0ac76ca97d3 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 21 七月 2022 17:47:40 +0800
Subject: [PATCH] 1. 巡查汇总报告功能添加整改跟踪提醒统计列; 2. 新增获取巡查任务统计信息接口;

---
 src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt                     |    5 
 src/main/resources/mapper/ds1/MonitorobjectversionMapper.xml                                    |   12 ++
 src/main/kotlin/cn/flightfeather/supervision/business/storage/item/StScoreItem_1.kt             |    6 
 src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/SubTaskSummary.kt                    |   18 +++
 src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/SubtaskMapper.kt                 |    2 
 src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt   |    6 
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt   |    9 +
 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt                |   12 +
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt     |    2 
 src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStrategy.kt                |  106 +++++++++++++++++
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt      |   81 ++++++++----
 src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/MonitorobjectversionMapper.kt    |    6 
 src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStatus.kt                  |   17 +-
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SubtaskService.kt               |    4 
 src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt                      |    2 
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt  |   12 ++
 src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTotalGrade.kt              |    4 
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt |   39 +++++-
 18 files changed, 280 insertions(+), 63 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
index cea8933..da0703a 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
@@ -110,7 +110,7 @@
                 }
             })
         } else {
-            taskSceneIdList = dbMapper.monitorobjectversionMapper.getSceneByType(config.topTaskGuid, config.sceneType)
+            taskSceneIdList = dbMapper.monitorobjectversionMapper.getSceneByType(config.topTaskGuid, config.sceneType, config.townCode)
             dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
                 createCriteria().andIn("scenseid", taskSceneIdList)
                     .andEqualTo("tguid", config.topTaskGuid)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStatus.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStatus.kt
index da630da..3d40ce8 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStatus.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStatus.kt
@@ -18,22 +18,27 @@
     }
 
     override fun onOneRow(rowData: DataSource.RowData): List<Any> {
-        val status = when (rowData.scene?.typeid.toString()) {
+        var status: String? = ""
+        var stage: String? = ""
+        when (rowData.scene?.typeid.toString()) {
             Constant.ScenseType.TYPE1.value -> {
-                (rowData.baseScene as SceneConstructionSite?)?.csStatus
+                (rowData.baseScene as SceneConstructionSite?)?.apply {
+                    status = csStatus
+                    stage = siExtension1
+                }
             }
             Constant.ScenseType.TYPE2.value -> {
-                (rowData.baseScene as SceneWharf?)?.getwStatus()
+                status = (rowData.baseScene as SceneWharf?)?.getwStatus()
             }
             Constant.ScenseType.TYPE3.value -> {
-                (rowData.baseScene as SceneMixingPlant?)?.mpStatus
+                status = (rowData.baseScene as SceneMixingPlant?)?.mpStatus
             }
             Constant.ScenseType.TYPE14.value -> {
-                (rowData.baseScene as SceneStorageYard?)?.syStatus
+                status = (rowData.baseScene as SceneStorageYard?)?.syStatus
             }
             else -> ""
         }
         val s = status ?: ""
-        return listOf(s, s)
+        return listOf(s, stage ?: "")
     }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStrategy.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStrategy.kt
new file mode 100644
index 0000000..4f12b5c
--- /dev/null
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStrategy.kt
@@ -0,0 +1,106 @@
+package cn.flightfeather.supervision.business.report.cols
+
+import cn.flightfeather.supervision.business.report.BaseCols
+import cn.flightfeather.supervision.business.report.DataSource
+import cn.flightfeather.supervision.common.utils.Constant
+import cn.flightfeather.supervision.common.utils.ExcelUtil
+import java.time.Duration
+import java.time.LocalDateTime
+import java.time.ZoneId
+
+class ColStrategy : BaseCols() {
+    override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> {
+        return mutableListOf(mutableListOf(
+            ExcelUtil.MyCell("鏁存敼璺熻釜鎻愰啋")
+        ))
+    }
+
+    override fun onOneRow(rowData: DataSource.RowData): List<Any> {
+        if (rowData.problems.isEmpty()) return listOf("")
+
+        val strategyList = listOf(
+            "1銆佸瓨鍦ㄩ棶棰樿秴鏈�3澶╀笉婊�7澶╂湭鏁存敼锛岀敱绯荤粺鎺ㄩ�佹暣鏀规彁閱掞紱",
+            "2銆佸瓨鍦ㄩ棶棰樿秴鏈�7澶╂湭鏁存敼锛岀敱鎶�鏈湇鍔¢儴绾夸笂鐫d績锛�",
+            "3銆佸贰鏌ュ悗10澶╂垨鏈堟湯鍓�3澶╋紝闂鏁存敼鐜囦綆浜�50%锛岀敱鏁版嵁搴旂敤閮ㄤ竴瀵逛竴鐫d績锛屽苟浜庝富绠¢儴闂ㄨ仈鍔紱",
+            "4銆侀棶棰樺鏍告垨鏁存敼瀹℃牳鏈紑灞曟垨闂瀹℃牳杈冨贰鏌ユ椂闂村欢鍚�24灏忔椂浠ヤ笂鎴栭棶棰樹笌鏁存敼鏃堕棿闂撮殧瓒呰繃涓�鍛紝椤圭洰绠$悊浜哄憳搴斿強鏃跺紑灞曞鏍告垨鍚庣画搴旀彁鍗囧鏍告椂鏁堟�э紱",
+            "5銆佸彴璐︽湭鎸夋椂鎻愪氦锛岀敱鎶�鏈湇鍔¢儴涓�瀵逛竴鐫d績锛�",
+            "6銆佸彴璐﹀凡閮ㄥ垎鎻愪氦锛屾彁浜ゆ瘮渚嬩笉瓒�100%鐨勶紝鐢辨暟鎹簲鐢ㄩ儴涓�瀵逛竴鐫d績锛�",
+            "7銆佸綋鏈堥棶棰樻暟瓒�3涓笖鍏ㄩ儴鏈暣鏀规垨杩炵画涓ゆ湀闂鏁存敼鐜囦綆浜�50%鐨勫満鏅紝鍒椾负閲嶇偣鐩戠锛岀敱鎶�鏈湇鍔¢儴褰撴湀澧炲姞涓嶅皯浜庝竴娆$幇鍦哄鏍革紱",
+            "8銆佽繛缁袱鏈堝彴璐︽彁浜ゆ瘮渚嬩綆浜�50%鐨勶紝鐢辨妧鏈湇鍔¢儴褰撴湀澧炲姞涓�娆$幇鍦烘垨绾夸笂鎿嶄綔鎸囧锛�",
+            "9銆佸彴璐﹀鏍歌緝鎻愪氦鏃堕棿寤跺悗5鏃ヤ互涓婃垨鏈堟湯鍓�3鏃ヤ粛鏈鏍哥殑锛岀敱鏁版嵁搴旂敤閮ㄥ強鏃跺紑灞曪紱"
+        )
+
+        var result = ""
+        val now = LocalDateTime.now()
+
+        var cPros = 0//鏁存敼鎬绘暟
+        for (p in rowData.problems) {
+            if (p.ischanged == true) {
+                cPros++
+                continue
+            }
+            val pTime = LocalDateTime.ofInstant(p.time?.toInstant(), ZoneId.systemDefault())
+            val duration = Duration.between(pTime.toLocalDate(), now)
+            val day = duration.toDays()
+
+            when {
+                day in 3..6 -> {
+                    result += strategyList[0] + "\n"
+                    break
+                }
+                day > 6 -> {
+                    result += strategyList[1] + "\n"
+                    break
+                }
+            }
+        }
+        //鏁存敼鐜�
+        val cPer = cPros.toDouble() / rowData.problems.size
+        //宸℃煡鏃堕棿
+        val sTime = LocalDateTime.ofInstant(rowData.subTask?.planstarttime?.toInstant(), ZoneId.systemDefault())
+        val day1 = Duration.between(sTime.toLocalDate(), now).toDays()
+        val lastDayOfMon = now.plusMonths(1).withDayOfMonth(1).minusDays(1)
+        val day2 = Duration.between(lastDayOfMon.toLocalDate(), now.toLocalDate()).toDays()
+        if (cPer < .5 && (day1 >= 10 || day2 <= 3)) result += strategyList[2] + "\n"
+
+        //瀹℃牳
+        for (p in rowData.problems) {
+            //闂瀹℃牳鎴栨暣鏀瑰鏍告湭寮�灞�
+            when (p.extension3) {
+                Constant.PROBLEM_UNCHECKED,
+                Constant.CHANGE_UNCHECKED -> {
+                    result += strategyList[3] + "\n"
+                    break
+                }
+            }
+            //闂瀹℃牳杈冨贰鏌ユ椂闂村欢鍚�24灏忔椂浠ヤ笂
+            // TODO: 2022/7/20
+
+            //闂涓庢暣鏀规椂闂撮棿闅旇秴杩囦竴鍛�
+            if (p.changedtime != null) {
+                val ct = LocalDateTime.ofInstant(p.changedtime?.toInstant(), ZoneId.systemDefault())
+                val pt = LocalDateTime.ofInstant(p.time?.toInstant(), ZoneId.systemDefault())
+                if (Duration.between(pt.toLocalDate(), ct.toLocalDate()).toDays() > 7) {
+                    result += strategyList[3] + "\n"
+                    break
+                }
+            }
+
+
+        }
+
+        //鍙拌处
+        val rNum = rowData.ledgerRecords.size
+        if (rNum == 0) result += strategyList[4] + "\n"
+        if (rNum != 0 && rNum < rowData.ledgerCount) result += strategyList[5] + "\n"
+
+        //7銆佸綋鏈堥棶棰樻暟瓒�3涓笖鍏ㄩ儴鏈暣鏀规垨杩炵画涓ゆ湀闂鏁存敼鐜囦綆浜�50%鐨勫満鏅紝鍒椾负閲嶇偣鐩戠锛岀敱鎶�鏈湇鍔¢儴褰撴湀澧炲姞涓嶅皯浜庝竴娆$幇鍦哄鏍革紱
+        if (rowData.problems.size > 3 && cPros == 0) {
+        }
+
+        //8銆佽繛缁袱鏈堝彴璐︽彁浜ゆ瘮渚嬩綆浜�50%鐨勶紝鐢辨妧鏈湇鍔¢儴褰撴湀澧炲姞涓�娆$幇鍦烘垨绾夸笂鎿嶄綔鎸囧锛�
+        //9銆佸彴璐﹀鏍歌緝鎻愪氦鏃堕棿寤跺悗5鏃ヤ互涓婃垨鏈堟湯鍓�3鏃ヤ粛鏈鏍哥殑锛岀敱鏁版嵁搴旂敤閮ㄥ強鏃跺紑灞曪紱
+
+        return strategyList
+    }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTotalGrade.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTotalGrade.kt
index 4efda09..f77e2b6 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTotalGrade.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTotalGrade.kt
@@ -35,8 +35,8 @@
                         else -> ExcelUtil.MyCell("瓒呭嚭鑼冨洿锛�${s}", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
                     }
                     val normalization = when (s) {
-                        in 0..59 -> ExcelUtil.MyCell("涓ラ噸涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.RED.index)
-                        in 60..89 -> ExcelUtil.MyCell("涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.ROSE.index)
+                        in 0..39 -> ExcelUtil.MyCell("涓ラ噸涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.RED.index)
+                        in 40..89 -> ExcelUtil.MyCell("涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.ROSE.index)
                         in 90..99 -> ExcelUtil.MyCell("鍩烘湰瑙勮寖", fontColor = HSSFColor.HSSFColorPredefined.GOLD.index)
                         100 -> ExcelUtil.MyCell("瑙勮寖", fontColor = HSSFColor.HSSFColorPredefined.BRIGHT_GREEN.index)
                         -1 -> ExcelUtil.MyCell("", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt
index 7a62467..957f61f 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt
@@ -60,7 +60,7 @@
                     else -> ""
                 }
                 // FIXME: 2022/7/18 鍚庣画鍦烘櫙鐨勬柦宸ョ姸鎬佹敼涓哄竷灏斿�煎瓨鍌�
-                if ((status?.contains("瀹屽伐") == true) || (status?.contains("鏈柦宸�") == true) || (status?.contains("鍋�") == true)
+                if ((status?.contains("瀹屽伐") == true) || (status?.contains("鏈柦宸�") == true) || (status?.contains("鍋滃伐") == true)
                     || (status?.contains("鍏�") == true)
                 ) {
                     inactiveScenes++
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt
index 1eec3c3..83cdc70 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt
@@ -16,6 +16,20 @@
 
         summarys.sortByDescending { it.count }
 
+        var tPros = 0
+        var mainTPros = 0
+        var pDes = ""
+        for (i in summarys.indices) {
+            val it = summarys[i]
+            tPros += it.count
+            if (i < max) {
+                val lr = if (i > 0) "\n" else ""
+                mainTPros += it.count
+                pDes += "${lr}${i+1}銆�${it.proDes}"
+            }
+        }
+        var per = if (tPros == 0) .0 else mainTPros.toDouble() / tPros
+
         head.clear()
         head.add(
             mutableListOf(
@@ -41,16 +55,23 @@
                 ExcelUtil.MyCell("涓昏闂鍗犳瘮"),
             )
         )
-        for (i in summarys.indices) {
-            if (i >= max) break
+//        for (i in summarys.indices) {
+//            if (i >= max) break
+//
+//            val s = summarys[i]
+//            contents.add(
+//                mutableListOf(
+//                    i + 1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area, s.count,
+//                    s.proDes, s.count, ExcelUtil.MyCell(s.countPer.toString(), isPercent = true)
+//                )
+//            )
+//        }
 
-            val s = summarys[i]
-            contents.add(
-                mutableListOf(
-                    i + 1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area, s.count,
-                    s.proDes, s.count, ExcelUtil.MyCell(s.countPer.toString(), isPercent = true)
-                )
+        contents.add(
+            mutableListOf(
+                1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area, tPros,
+                pDes, mainTPros, ExcelUtil.MyCell(per.toString(), isPercent = true)
             )
-        }
+        )
     }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt
index aa6e38a..ce7cea3 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt
@@ -23,7 +23,8 @@
         val proMap = mutableMapOf<String?, MutableMap<String?, Summary>>()
         dataSource.loop { _, rowData ->
             rowData.problems.forEach {
-                val s = (rowData.baseScene as SceneConstructionSite?)?.csStatus
+                val baseScene = rowData.baseScene as SceneConstructionSite?
+                val s = baseScene?.siExtension1
                 if (!proMap.containsKey(s)) {
                     proMap[s] = mutableMapOf()
                 }
@@ -32,7 +33,8 @@
                     proMap[s]?.put(pt, Summary().apply {
                         for (p in rowData.problemTypes) {
                             if (p.guid == pt) {
-                                status = s ?: ""
+                                stage = s ?: ""
+                                status = baseScene?.csStatus ?: ""
                                 proType = p.typename ?: ""
                                 proDes = p.description ?: ""
                                 break
@@ -100,7 +102,7 @@
             val s = summarys[i]
             contents.add(
                 mutableListOf(
-                    i + 1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area, s.status, s.status,
+                    i + 1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area, s.status, s.stage,
                     s.proType, s.proDes,
                     s.count, ExcelUtil.MyCell(s.countPer.toString(), isPercent = true),
                     s.changeNum, ExcelUtil.MyCell(s.changePer.toString(), isPercent = true),
@@ -111,6 +113,7 @@
 
     inner class Summary() {
         var status = ""
+        var stage = ""
         var proType = ""
         var proDes = ""
         var count = 0
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/storage/item/StScoreItem_1.kt b/src/main/kotlin/cn/flightfeather/supervision/business/storage/item/StScoreItem_1.kt
index a9d0dba..a6dbd59 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/storage/item/StScoreItem_1.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/storage/item/StScoreItem_1.kt
@@ -34,9 +34,9 @@
      */
     override fun otherProblem(size: Int): Int? {
         val p = problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
-            createCriteria().andEqualTo("sguid", info.sceneId)
-                .andGreaterThanOrEqualTo("time", info.sTime)
-                .andLessThan("time", info.eTime)
+            createCriteria().andEqualTo("stguid", info.subTask?.stguid)
+//                .andGreaterThanOrEqualTo("time", info.sTime)
+//                .andLessThan("time", info.eTime)
         })
         var i = 0
 
diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/MonitorobjectversionMapper.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/MonitorobjectversionMapper.kt
index 0cbce76..3aed701 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/MonitorobjectversionMapper.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/MonitorobjectversionMapper.kt
@@ -8,7 +8,7 @@
 @Mapper
 interface MonitorobjectversionMapper:MyMapper<Monitorobjectversion> {
 
-    @Select("select b.S_GUID from sm_t_monitorobjectversion as a left join sm_t_scense as b on a.S_GUID = b.S_GUID" +
-            " where a.T_ID = #{param1} and b.S_TypeID = #{param2}")
-    fun getSceneByType(topTaskId: String, sceneTypeId: Int): List<String>
+    //    @Select("select b.S_GUID from sm_t_monitorobjectversion as a left join sm_t_scense as b on a.S_GUID = b.S_GUID" +
+//            " where a.T_ID = #{param1} and b.S_TypeID = #{param2}")
+    fun getSceneByType(topTaskId: String, sceneTypeId: Int, townCode: String? = null): List<String>
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/SubtaskMapper.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/SubtaskMapper.kt
index fbf1ba0..3a49785 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/SubtaskMapper.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/SubtaskMapper.kt
@@ -18,4 +18,6 @@
     fun selectByTopTask(topTaskId: String, startTime: String, endTime: String, sceneTypeId: Int? = null): List<SubtaskVo>
 
     fun selectByTopTask2(topTaskId: String, sceneTypeId: Int? = null): List<Subtask>
+
+
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SubtaskService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SubtaskService.kt
index 0359ae8..91d5446 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SubtaskService.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SubtaskService.kt
@@ -42,5 +42,7 @@
 
     fun findByDate(date: String, userId: String): List<SubtaskVo>
 
-    fun getByTopTaskAndDate(topTaskId: String, startTime: String, endTime: String, sceneTypeId: Int? = null): List<SubtaskVo>
+    fun getByTopTaskAndDate(topTaskId: String, startTime: String?, endTime: String?, sceneTypeId: Int? = null): List<Subtask>
+
+    fun getSummary(topTaskId: String, sceneTypeId: Int? = null): List<SubTaskSummary>
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt
index bf7ef44..a56fe6a 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt
@@ -323,6 +323,12 @@
                 mediafileMapper.deleteByExample(Example(Mediafile::class.java).apply {
                     createCriteria().andEqualTo("businessguid", id)
                 })
+                //鏇存柊宸℃煡淇℃伅涓殑闂鏁伴噺
+                val inspection = inspectionMapper.selectByPrimaryKey(p.iguid)
+                if (inspection.problemcount != null && inspection.problemcount!! > 0) {
+                    inspection.problemcount = inspection.problemcount!! - 1
+                    inspectionMapper.updateByPrimaryKey(inspection)
+                }
                 BaseResponse(true, "闂鍒犻櫎鎴愬姛", data = i)
             }
         }
@@ -486,6 +492,12 @@
             }
         }
 
+        //鏇存柊宸℃煡淇℃伅鐨勯棶棰樻暟
+        if (inspection.problemcount != null) {
+            inspection.problemcount = inspection.problemcount!! + 1
+            inspectionMapper.updateByPrimaryKey(inspection)
+        }
+
         return BaseResponse(true)
     }
 
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt
index 8ea2a19..3372dde 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt
@@ -968,37 +968,60 @@
         return resultList
     }
 
-    override fun getByTopTaskAndDate(topTaskId: String, startTime: String, endTime: String, sceneTypeId: Int?): List<SubtaskVo> {
-        val startDate = dateUtil.StringToDate(startTime)
-        val endDate = dateUtil.StringToDate(endTime)
-
-        val cal = Calendar.getInstance().apply { time = startDate }
-        val _startTime = dateUtil.DateToString(cal.time, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) ?: startTime
-
-        if (endDate == null) {
-            cal.add(Calendar.MONTH, 1)
-            cal.add(Calendar.DAY_OF_MONTH, -1)
-        } else {
-            cal.time = endDate
-        }
-        cal.set(Calendar.HOUR_OF_DAY, 23)
-        cal.set(Calendar.MINUTE, 59)
-        cal.set(Calendar.SECOND, 59)
-        val _endTime = dateUtil.DateToString(cal.time, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) ?: endTime
-
-//        val resultList = mutableListOf<SubtaskVo>()
-        val resultList = subtaskMapper.selectByTopTask(topTaskId, _startTime, _endTime, sceneTypeId)
-//        subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
-//            createCriteria()
-//                    .andGreaterThanOrEqualTo("planstarttime", startDate)
-//                    .andLessThanOrEqualTo("planstarttime", endDate)
-//                    .andEqualTo("tguid", topTaskId)
-//        }).forEach {
-//            val vo = SubtaskVo()
-//            BeanUtils.copyProperties(it, vo)
-//            resultList.add(vo)
+    override fun getByTopTaskAndDate(topTaskId: String, startTime: String?, endTime: String?, sceneTypeId: Int?): List<Subtask> {
+//        val startDate = dateUtil.StringToDate(startTime)
+//        val endDate = dateUtil.StringToDate(endTime)
+//
+//        val cal = Calendar.getInstance().apply { time = startDate }
+//        val _startTime = dateUtil.DateToString(cal.time, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) ?: startTime
+//
+//        if (endDate == null) {
+//            cal.add(Calendar.MONTH, 1)
+//            cal.add(Calendar.DAY_OF_MONTH, -1)
+//        } else {
+//            cal.time = endDate
 //        }
+//        cal.set(Calendar.HOUR_OF_DAY, 23)
+//        cal.set(Calendar.MINUTE, 59)
+//        cal.set(Calendar.SECOND, 59)
+//        val _endTime = dateUtil.DateToString(cal.time, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) ?: endTime
+
+        val resultList = subtaskMapper.selectByTopTask2(topTaskId, sceneTypeId)
 
         return resultList
     }
+
+    override fun getSummary(topTaskId: String, sceneTypeId: Int?): List<SubTaskSummary> {
+        val result = mutableListOf<SubTaskSummary>()
+
+        subtaskMapper.selectByTopTask2(topTaskId, sceneTypeId).forEach {
+            val scene = scenseMapper.selectByPrimaryKey(it.scenseid)
+            var p = 0
+            var c = 0
+            var pc = 0
+            var cc = 0
+            problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
+                createCriteria().andEqualTo("stguid", it.stguid)
+            }).forEach {pro ->
+                p++
+                if (pro.ischanged == true) c++
+                if (pro.extension3 != Constant.PROBLEM_UNCHECKED) pc++
+                if (pro.extension3 == Constant.CHANGE_CHECK_PASS || pro.extension3 == Constant.CHANGE_CHECK_FAIL) cc++
+            }
+            result.add(SubTaskSummary().apply {
+                stGuid = it.stguid
+                stName = it.name
+                sceneId = it.scenseid
+                sceneName = scene.name
+                sceneType = scene.type
+                stPlanTime = it.planstarttime
+                proNum = p
+                changeNum = c
+                proCheckedNum = pc
+                changeCheckedNum = cc
+            })
+        }
+
+        return result
+    }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/SubTaskSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/SubTaskSummary.kt
new file mode 100644
index 0000000..58e7368
--- /dev/null
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/SubTaskSummary.kt
@@ -0,0 +1,18 @@
+package cn.flightfeather.supervision.lightshare.vo
+
+import java.util.*
+
+class SubTaskSummary {
+    var stGuid: String? = null
+    var stName: String? = null
+    var sceneId: String? = null
+    var sceneName: String? = null
+    var sceneType: String? = null
+    var stPlanTime: Date? = null
+
+    var proNum = 0
+    var changeNum = 0
+
+    var proCheckedNum: Int = 0
+    var changeCheckedNum: Int = 0
+}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt
index 21c7c54..69d5aa6 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt
@@ -5,6 +5,7 @@
 import cn.flightfeather.supervision.lightshare.vo.AreaVo
 import cn.flightfeather.supervision.lightshare.vo.TaskVo
 import io.swagger.annotations.Api
+import io.swagger.annotations.ApiOperation
 import org.springframework.web.bind.annotation.*
 
 @Api(tags = ["SubtaskController"], description = "宸℃煡瀛愪换鍔PI鎺ュ彛")
@@ -58,8 +59,15 @@
     @GetMapping("/getSubTask")
     fun getByTopTaskAndDate(
             @RequestParam("topTaskId") topTaskId: String,
-            @RequestParam("startTime") startTime: String,
-            @RequestParam("endTime") endTime: String,
+            @RequestParam(value = "startTime", required = false) startTime: String?,
+            @RequestParam(value = "endTime", required = false) endTime: String?,
             @RequestParam(value = "sceneTypeId", required = false) sceneTypeId: Int?
     ) = subtaskService.getByTopTaskAndDate(topTaskId, startTime, endTime, sceneTypeId)
+
+    @ApiOperation("鑾峰彇鏌愮被鍦烘櫙鐨勫贰鏌ヤ换鍔$粺璁′俊鎭�")
+    @GetMapping("/summary")
+    fun getByTopTaskAndDate(
+        @RequestParam("topTaskId") topTaskId: String,
+        @RequestParam(value = "sceneTypeId", required = false) sceneTypeId: Int?
+    ) = subtaskService.getSummary(topTaskId, sceneTypeId)
 }
\ No newline at end of file
diff --git a/src/main/resources/mapper/ds1/MonitorobjectversionMapper.xml b/src/main/resources/mapper/ds1/MonitorobjectversionMapper.xml
index 4e67a07..8418639 100644
--- a/src/main/resources/mapper/ds1/MonitorobjectversionMapper.xml
+++ b/src/main/resources/mapper/ds1/MonitorobjectversionMapper.xml
@@ -32,4 +32,16 @@
     MOV_Suitable, MOV_DisplayID, MOV_Year, MOV_Month, MOV_Day, MOV_ISCP, MOV_CustomPeriod, 
     MOV_Extension1, MOV_Extension2, MOV_Extension3, MOV_Remark
   </sql>
+
+  <select id="getSceneByType" resultType="String">
+    select
+    b.S_GUID
+    from sm_t_monitorobjectversion as a
+    left join sm_t_scense as b
+    on a.S_GUID = b.S_GUID
+    where a.T_ID = #{param1} and b.S_TypeID = #{param2}
+    <if test="param3 != null">
+      and b.S_TownCode = #{param3}
+    </if>
+  </select>
 </mapper>
\ No newline at end of file
diff --git a/src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt b/src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt
index f02583c..044758c 100644
--- a/src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt
+++ b/src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt
@@ -39,9 +39,10 @@
     @Test
     fun go() {
         autoScore.sceneType = Constant.ScenseType.TYPE1
-        autoScore.topTaskGrade("tgfMJWdUJqWE6bWo")
-//        val subtask = subtaskMapper.selectByPrimaryKey("1DxdkFdVAdQD5Mce")
+        autoScore.topTaskGrade("8QN1VzftuhBJmrF8")
+//        val subtask = subtaskMapper.selectByPrimaryKey("OPmza2ddEAKiQHqz")
 //        autoScore.sceneGrade(subtask)
+//        autoScore.sceneGradeToFile(subtask)
 //        autoScore3.go(2022, 1, 2)
 //        val t = problemlistMapper.getStatisticalResult("310116", "2021-09-01 00:00:00", "2021-09-30 00:00:00", "1")
 //        println()
diff --git a/src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt b/src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt
index 498bc47..96dd876 100644
--- a/src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt
+++ b/src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt
@@ -33,7 +33,11 @@
 
         val mode = 10
         //閲戝北2022骞�6鏈�
-        searchService.writeToFile(ExcelConfigVo("tgfMJWdUJqWE6bWo", districtCode = "310116", sceneType = 1), mode)
+        searchService.writeToFile(ExcelConfigVo(
+            "8QN1VzftuhBJmrF8",
+            districtCode = "310106",
+//            townCode = "310116113",
+            sceneType = 1), mode)
         //閲戝北2021骞�3鏈�
 //        searchService.writeToFile(ExcelConfigVo("o7jdSzr79fe0NH3I", districtCode = "310116", sceneType = 1))
     }

--
Gitblit v1.9.3