From 9de446b0b83610055437fbc5172d216bb374900f Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 21 十一月 2024 09:22:19 +0800
Subject: [PATCH] 1. 2024.11.21 修复部分bug

---
 src/main/resources/mapper/ds1/SubtaskMapper.xml                                                |   10 ++
 src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt                  |   43 ++++++++--
 src/main/resources/mapper/ds1/ProblemlistMapper.xml                                            |   53 ++++++++-----
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ProblemlistService.kt          |    3 
 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemlistController.kt           |    3 
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt     |    3 
 src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaVo.kt                           |    3 
 src/main/resources/mapper/ds1/ScenseMapper.xml                                                 |   28 +++++++
 src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt                     |   10 +-
 src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/ProblemlistMapper.kt            |   22 +----
 src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/ProblemRep.kt               |    6 
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt |   17 ++--
 12 files changed, 128 insertions(+), 73 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 575041e..96f71fa 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
@@ -68,7 +68,7 @@
      */
     fun areaName(): String {
         val t = dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid)
-        return "${DateUtil.DateToString(t.starttime, DateUtil.DateStyle.YYYY_MM_CN)}${t.districtname}${if (area != t.districtname) area else ""}${Constant.SceneType.getDes(config.sceneType)}"
+        return "${DateUtil.DateToString(config.startTime, DateUtil.DateStyle.YYYY_MM_CN)}${t.districtname}${if (area != t.districtname) area else ""}${Constant.SceneType.getDes(config.sceneType)}"
     }
 
     /**
@@ -92,12 +92,12 @@
             if (area.isBlank()) area = it.districtname ?: ""
         }
 
-        //1. 鏌ユ壘鐗瑰畾鐨勫贰鏌ヤ换鍔℃垨鑰呮墍鏈夌殑璁″垝宸℃煡浠诲姟
-        val taskSceneIdList = dbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config.sceneType,
-            config.townCode).map { it.guid ?: "" }
-
         // 缁熻鎬讳换鍔′笅鎵�鏈夊満鏅�
         if (config.allScene) {
+            //1. 鏌ユ壘鐗瑰畾鐨勫贰鏌ヤ换鍔℃垨鑰呮墍鏈夌殑璁″垝宸℃煡浠诲姟
+            val taskSceneIdList = dbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config.sceneType,
+                config.townCode).map { it.guid ?: "" }
+
             val subTaskList = dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
                 createCriteria().apply {
                     if (taskSceneIdList.isNotEmpty()) andIn("scenseid", taskSceneIdList)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/ProblemlistMapper.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/ProblemlistMapper.kt
index b0759ad..9320bb7 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/ProblemlistMapper.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/ProblemlistMapper.kt
@@ -2,6 +2,7 @@
 
 import cn.flightfeather.supervision.domain.ds1.entity.Problemlist
 import cn.flightfeather.supervision.domain.util.MyMapper
+import cn.flightfeather.supervision.lightshare.vo.AreaVo
 import cn.flightfeather.supervision.lightshare.vo.SceneProblemSummary
 import cn.flightfeather.supervision.lightshare.vo.StatisticsVo
 import cn.flightfeather.supervision.lightshare.vo.UnChangedPro
@@ -13,18 +14,8 @@
 
     /**
      * 鑾峰彇鏌愭椂闂存鍐呫�佹煇涓尯鍘跨殑鏌愮鍦烘櫙涓嬶紝鍚勭被鍨嬬殑闂鏁伴噺缁熻
-     * @param districtCode 鍖哄幙琛屾斂缂栫爜
-     * @param startTime 寮�濮嬫椂闂�
-     * @param endTime 缁撴潫鏃堕棿
-     * @param sceneType 鍦烘櫙绫诲瀷
      */
-    fun getStatisticalResult(
-        districtCode: String?,
-        startTime: String?,
-        endTime: String?,
-        sceneType: String?,
-        sceneId: String?,
-    ): List<StatisticsVo>
+    fun getStatisticalResult(areaVo: AreaVo): List<StatisticsVo>
 
     fun getStatisticalResultById(topTaskId: String?, sceneTypeId: String?): List<Map<String, JvmType.Object>>
 
@@ -59,12 +50,7 @@
     fun getUnChangedProblem(deadLine: String): List<UnChangedPro>
 
     /**
-     * 鑾峰彇鎬讳换鍔�
+     * 鑾峰彇鍦烘櫙闂缁熻
      */
-    fun getSceneProSummary(
-        topTaskId: String,
-        sceneTypeId: String?,
-        sort: String?,
-        sortBy: String,
-    ): List<SceneProblemSummary>
+    fun getSceneProSummary(areaVo: AreaVo): List<SceneProblemSummary>
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/ProblemRep.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/ProblemRep.kt
index 1fe80a5..dea0666 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/ProblemRep.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/ProblemRep.kt
@@ -2,6 +2,7 @@
 
 import cn.flightfeather.supervision.domain.ds1.entity.Problemlist
 import cn.flightfeather.supervision.domain.ds1.mapper.ProblemlistMapper
+import cn.flightfeather.supervision.lightshare.vo.AreaVo
 import cn.flightfeather.supervision.lightshare.vo.SceneProblemSummary
 import org.springframework.stereotype.Repository
 
@@ -20,9 +21,8 @@
     /**
      * 鑾峰彇鍚勫満鏅殑闂鍜屾暣鏀规暟閲忕粺璁�
      */
-    fun selectSceneProSummary(topTaskId: String, sceneTypeId: String?, sort: String?, sortBy: String):
-            List<SceneProblemSummary> {
-        return problemlistMapper.getSceneProSummary(topTaskId, sceneTypeId, sort, sortBy)
+    fun selectSceneProSummary(areaVo: AreaVo): List<SceneProblemSummary> {
+        return problemlistMapper.getSceneProSummary(areaVo)
     }
 
     fun findOne(guid: String?): Problemlist? {
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 21133a7..22d0ebb 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
@@ -13,16 +13,33 @@
 @Repository
 class TaskRep(private val taskMapper: TaskMapper, private val monitorobjectversionMapper: MonitorobjectversionMapper) {
 
-    private fun exampleTask(areaVo: AreaVo): Task?{
+    private fun exampleTask(areaVo: AreaVo, levelNum: Int? = null): Example? {
         areaVo.starttime ?: return null
         val mStart = areaVo.starttime!!.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0)
         val mEnd = mStart.plusMonths(1).minusSeconds(1)
-        return Task().apply {
-            provincecode = areaVo.provincecode
-            citycode = areaVo.citycode
-            districtcode = areaVo.districtcode
-            starttime = Date.from(mStart.atZone(ZoneId.systemDefault()).toInstant())
-            endtime = Date.from(mEnd.atZone(ZoneId.systemDefault()).toInstant())
+//        return Task().apply {
+//            provincecode = areaVo.provincecode
+//            citycode = areaVo.citycode
+//            districtcode = areaVo.districtcode
+//            starttime = Date.from(mStart.atZone(ZoneId.systemDefault()).toInstant())
+//            endtime = Date.from(mEnd.atZone(ZoneId.systemDefault()).toInstant())
+//        }
+
+        return Example(Task::class.java).apply {
+            createCriteria()
+                .apply {
+                    if (levelNum != null) {
+                        andEqualTo("levelnum", levelNum)
+                    } else {
+                        andIsNull("levelnum")
+                    }
+                }
+                .andEqualTo("provincecode", areaVo.provincecode)
+                .andEqualTo("citycode", areaVo.citycode)
+                .andEqualTo("districtcode", areaVo.districtcode)
+                .andGreaterThanOrEqualTo("starttime", mStart)
+                .andLessThanOrEqualTo("endtime", mEnd)
+            orderBy("starttime")
         }
     }
 
@@ -34,13 +51,17 @@
      * 鏌ユ壘涓�涓�讳换鍔�
      */
     fun findOneTask(areaVo: AreaVo): Task? {
-        val example = exampleTask(areaVo) ?: return null
-        return taskMapper.selectOne(example)
+        val list = findTasks(areaVo)
+        return if (list.isEmpty()) {
+            null
+        } else {
+            list[0]
+        }
     }
 
     fun findTasks(areaVo: AreaVo): List<Task?> {
-        val example = exampleTask(areaVo) ?: return emptyList()
-        return taskMapper.select(example)
+        val example = exampleTask(areaVo, 2) ?: return emptyList()
+        return taskMapper.selectByExample(example)
     }
 
     fun findTasks(task: Task): List<Task?> {
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ProblemlistService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ProblemlistService.kt
index c872fee..dc869c1 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ProblemlistService.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ProblemlistService.kt
@@ -56,6 +56,5 @@
 
     fun getSceneByProType(areaVo: AreaVo, pType:String):List<Subtask?>
 
-    fun getSceneProSummary(areaVo: AreaVo, sortBy: String, page: Int, per_page: Int): Pair<DataHead?,
-            List<SceneProblemSummary>?>
+    fun getSceneProSummary(areaVo: AreaVo, page: Int, per_page: Int): Pair<DataHead?, List<SceneProblemSummary>?>
 }
\ 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 0a1dca0..02d7b7c 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
@@ -130,11 +130,11 @@
 
     //鏍规嵁鍖哄幙銆佸満鏅被鍨嬨�佹椂闂磋幏鍙栧悇涓棶棰樻暟閲�
     override fun getStatisticalResult(areaVo: AreaVo): List<StatisticsVo> {
-        val districtcode = areaVo.districtcode
-        val sceneType = areaVo.scensetypeid
-        val startTime = areaVo.starttime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
-        val endTime = areaVo.endtime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
-        return problemlistMapper.getStatisticalResult(districtcode, startTime, endTime, sceneType, areaVo.sceneId)
+//        val districtcode = areaVo.districtcode
+//        val sceneType = areaVo.scensetypeid
+//        val startTime = areaVo.starttime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+//        val endTime = areaVo.endtime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+        return problemlistMapper.getStatisticalResult(areaVo)
     }
 
     override fun getChargeResult(areaVo: AreaVo): ChargeInfoVo {
@@ -595,14 +595,13 @@
 
     override fun getSceneProSummary(
         areaVo: AreaVo,
-        sortBy: String,
         page: Int,
         per_page: Int,
     ): Pair<DataHead?, List<SceneProblemSummary>?> {
-        areaVo.scensetypeid ?: throw BizException("缂哄皯鍦烘櫙绫诲瀷鍙傛暟")
-        val task = taskRep.findOneTask(areaVo) ?: throw BizException("鏈壘鍒板搴旂殑宸℃煡鎬讳换鍔�")
+//        areaVo.scensetypeid ?: throw BizException("缂哄皯鍦烘櫙绫诲瀷鍙傛暟")
+//        val task = taskRep.findOneTask(areaVo) ?: throw BizException("鏈壘鍒板搴旂殑宸℃煡鎬讳换鍔�")
         val p = PageHelper.startPage<SceneProblemSummary>(page, per_page)
-        val res = problemRep.selectSceneProSummary(task.tguid!!, areaVo.scensetypeid!!, areaVo.sort, sortBy)
+        val res = problemRep.selectSceneProSummary(areaVo)
         return DataHead(p.pageNum, p.pages, p.total) to res
     }
 }
\ No newline at end of file
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 1d3bdbf..62f46fb 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
@@ -946,7 +946,8 @@
                 districtName = t.districtname
                 townCode = t.towncode
                 townName = t.townname
-                subTaskSummary = subtaskMapper.getSummary(t.tguid!!, areaVo.scensetypeid?.toIntOrNull())
+                areaVo.topTaskId = t.tguid
+                subTaskSummary = subTaskRep.findSummary(areaVo)
             }
             res.add(pro)
         }
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaVo.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaVo.kt
index 104ab39..67dcd86 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaVo.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaVo.kt
@@ -12,6 +12,9 @@
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @ApiModel("鍖哄煙鏉′欢")
 open class AreaVo {
+    @ApiModelProperty("鎬讳换鍔d")
+    var topTaskId: String? = null
+
     @ApiModelProperty("鐪佷唤缂栫爜")
     var provincecode: String? = null
 
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemlistController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemlistController.kt
index 7b6154b..0c01066 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemlistController.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemlistController.kt
@@ -146,8 +146,7 @@
     @PostMapping("/summary/scene")
     fun getSceneProSummary(
         @RequestBody areaVo: AreaVo,
-        @ApiParam(value = "鎺掑簭瀛楁", allowableValues = "pro, changePer") @RequestParam sortBy: String,
         @ApiParam(value = "椤电爜") @RequestParam(value = "page") page: Int,
         @ApiParam(value = "鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int,
-    ) = resPack { problemlistService.getSceneProSummary(areaVo, sortBy, page, perPage) }
+    ) = resPack { problemlistService.getSceneProSummary(areaVo, page, perPage) }
 }
\ No newline at end of file
diff --git a/src/main/resources/mapper/ds1/ProblemlistMapper.xml b/src/main/resources/mapper/ds1/ProblemlistMapper.xml
index ff89068..a648def 100644
--- a/src/main/resources/mapper/ds1/ProblemlistMapper.xml
+++ b/src/main/resources/mapper/ds1/ProblemlistMapper.xml
@@ -76,21 +76,27 @@
         LEFT JOIN sm_t_scense AS f ON a.S_GUID = f.S_GUID
         LEFT JOIN tm_t_subtask AS c ON a.ST_GUID = c.ST_GUID
         <where>
-        <if test="startTime != null">
-            AND c.ST_PlanStartTime >= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND c.ST_PlanStartTime &lt;= #{endTime}
-        </if>
-        <if test="districtCode != null">
-            AND f.S_DistrictCode = #{districtCode}
-        </if>
-        <if test="sceneType != null">
-            AND f.S_TypeID = #{sceneType}
-        </if>
-        <if test="sceneId != null">
-            AND a.S_GUID = #{sceneId}
-        </if>
+<!--        <if test="startTime != null">-->
+<!--            AND c.ST_PlanStartTime >= #{startTime}-->
+<!--        </if>-->
+<!--        <if test="endTime != null">-->
+<!--            AND c.ST_PlanStartTime &lt;= #{endTime}-->
+<!--        </if>-->
+<!--        <if test="districtCode != null">-->
+<!--            AND f.S_DistrictCode = #{districtCode}-->
+<!--        </if>-->
+            <if test="scensetypeid != null">
+                AND f.S_TypeID = #{scensetypeid}
+            </if>
+            <if test="sceneId != null">
+                AND a.S_GUID = #{sceneId}
+            </if>
+            <include refid="cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper.Where_Area">
+                <property name="tableAlias" value="f"/>
+            </include>
+            <include refid="cn.flightfeather.supervision.domain.ds1.mapper.SubtaskMapper.Where_Plan_Time">
+                <property name="tableAlias" value="c"/>
+            </include>
         </where>
         GROUP BY
         b.PT_TypeName
@@ -214,11 +220,18 @@
             sm_t_scense AS b
             LEFT JOIN tm_t_subtask AS a ON a.ST_ScenseID = b.S_GUID
             LEFT JOIN im_t_problemlist AS d ON a.ST_GUID = d.ST_GUID
-            WHERE
-            a.T_GUID = #{topTaskId}
-            <if test="sceneTypeId != null">
-                and b.S_TypeID = #{sceneTypeId}
-            </if>
+            <where>
+                <include refid="cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper.Where_Area">
+                    <property name="tableAlias" value="b"/>
+                </include>
+                <include refid="cn.flightfeather.supervision.domain.ds1.mapper.SubtaskMapper.Where_Plan_Time">
+                    <property name="tableAlias" value="a"/>
+                </include>
+<!--            a.T_GUID = #{topTaskId}-->
+                <if test="scensetypeid != null">
+                    and b.S_TypeID = #{scensetypeid}
+                </if>
+            </where>
             GROUP BY
             b.S_GUID
         ) as t_p
diff --git a/src/main/resources/mapper/ds1/ScenseMapper.xml b/src/main/resources/mapper/ds1/ScenseMapper.xml
index 5e1649d..6bd44be 100644
--- a/src/main/resources/mapper/ds1/ScenseMapper.xml
+++ b/src/main/resources/mapper/ds1/ScenseMapper.xml
@@ -42,6 +42,34 @@
     S_Contacts, S_CreateDate, S_UpdateDate, S_Extension1, S_Extension2, S_Index, S_Remark
   </sql>
 
+  <!-- 琛屾斂鍖哄垝鏉′欢 -->
+  <sql id="Where_Area">
+    <if test="provincecode != null">
+      AND ${tableAlias}.S_ProvinceCode = #{provincecode}
+    </if>
+    <if test="provincename != null">
+      AND ${tableAlias}.S_ProvinceName = #{provincename}
+    </if>
+    <if test="citycode != null">
+      AND ${tableAlias}.S_CityCode = #{citycode}
+    </if>
+    <if test="cityname != null">
+      AND ${tableAlias}.S_CityName = #{cityname}
+    </if>
+    <if test="districtcode != null">
+      AND ${tableAlias}.S_DistrictCode = #{districtcode}
+    </if>
+    <if test="districtname != null">
+      AND ${tableAlias}.S_DistrictName = #{districtname}
+    </if>
+    <if test="towncode != null">
+      AND ${tableAlias}.S_TownCode = #{towncode}
+    </if>
+    <if test="townname != null">
+      AND ${tableAlias}.S_TownName = #{townname}
+    </if>
+  </sql>
+
   <select id="selectNoAccountScene" resultMap="BaseResultMap">
     select a.* FROM sm_t_scense as a LEFT JOIN sm_t_userinfo as b on a.S_GUID = b.D_GUID WHERE b.UI_GUID is null
   </select>
diff --git a/src/main/resources/mapper/ds1/SubtaskMapper.xml b/src/main/resources/mapper/ds1/SubtaskMapper.xml
index e3a8cfe..1e1289b 100644
--- a/src/main/resources/mapper/ds1/SubtaskMapper.xml
+++ b/src/main/resources/mapper/ds1/SubtaskMapper.xml
@@ -403,12 +403,18 @@
     <select id="getSummaryByArea" resultMap="SubTaskSummary">
         <include refid="Sub_Task_Summary_Column_List"/>
         <where>
-            <include refid="Where_Area">
-                <property name="tableAlias" value="a"/>
+            <include refid="cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper.Where_Area">
+                <property name="tableAlias" value="b"/>
             </include>
             <include refid="Where_Plan_Time">
                 <property name="tableAlias" value="a"/>
             </include>
+            <if test="scensetypeid != null">
+                AND b.S_TypeID = #{scensetypeid}
+            </if>
+            <if test="topTaskId != null">
+                AND a.T_GUID = #{topTaskId}
+            </if>
         </where>
         GROUP BY
         a.ST_GUID

--
Gitblit v1.9.3