From 6688232eaa889eeb6c58d0d804b587699db55ec2 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 31 七月 2025 17:32:22 +0800
Subject: [PATCH] 2025.7.31 1. 新增基础数据产品相关接口

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductController.kt           |   13 ++
 src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProblemChange.kt          |   49 +++++----
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProductServiceImpl.kt |   27 +++++
 src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProbRecurrence.kt         |   43 +++-----
 src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/DataProductMapper.kt            |   16 +++
 src/main/resources/mapper/ds1/DataProductMapper.xml                                            |   79 +++++++++++++++
 src/main/kotlin/cn/flightfeather/supervision/config/CorsConfig.kt                              |    4 
 src/test/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductControllerTest.kt       |   46 +++++++++
 8 files changed, 222 insertions(+), 55 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/config/CorsConfig.kt b/src/main/kotlin/cn/flightfeather/supervision/config/CorsConfig.kt
index 0b07853..50a22c2 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/config/CorsConfig.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/config/CorsConfig.kt
@@ -6,7 +6,7 @@
 import org.springframework.web.cors.UrlBasedCorsConfigurationSource
 import org.springframework.web.filter.CorsFilter
 
-//@Configuration
+@Configuration
 class CorsConfig {
 
     private fun buildConfig(): CorsConfiguration {
@@ -18,7 +18,7 @@
         }
     }
 
-//    @Bean
+    @Bean
     fun corsFilter(): CorsFilter {
         val source = UrlBasedCorsConfigurationSource().apply {
             registerCorsConfiguration("/**", buildConfig())
diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/DataProductMapper.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/DataProductMapper.kt
new file mode 100644
index 0000000..448251f
--- /dev/null
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/DataProductMapper.kt
@@ -0,0 +1,16 @@
+package cn.flightfeather.supervision.domain.ds1.mapper
+
+import cn.flightfeather.supervision.model.dataproduct.DataProdOption
+import cn.flightfeather.supervision.model.dataproduct.PPListProblemChange
+import org.apache.ibatis.annotations.Mapper
+
+/**
+ *
+ * @date 2025/7/31
+ * @author feiyu02
+ */
+@Mapper
+interface DataProductMapper {
+
+    fun problemChangeList(option: DataProdOption): List<PPListProblemChange>
+}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProductServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProductServiceImpl.kt
index 63d3578..5441142 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProductServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProductServiceImpl.kt
@@ -7,6 +7,7 @@
 import cn.flightfeather.supervision.business.report.file.ReportThree
 import cn.flightfeather.supervision.business.report.file.ReportTwo
 import cn.flightfeather.supervision.common.exception.BizException
+import cn.flightfeather.supervision.domain.ds1.mapper.DataProductMapper
 import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
 import cn.flightfeather.supervision.lightshare.service.DataProductService
 import cn.flightfeather.supervision.lightshare.vo.AreaVo
@@ -14,6 +15,7 @@
 import cn.flightfeather.supervision.model.dataproduct.DataProdOption
 import cn.flightfeather.supervision.model.dataproduct.PPListProbRecurrence
 import cn.flightfeather.supervision.model.dataproduct.PPListProblemChange
+import org.springframework.beans.BeanUtils
 import org.springframework.beans.factory.annotation.Value
 import org.springframework.http.HttpHeaders
 import org.springframework.http.MediaType
@@ -33,6 +35,7 @@
     private val dbMapper: DbMapper,
     @Value("\${filePath}") private val filePath: String,
     private val reportTaskCtrl: ReportTaskCtrl,
+    private val dataProductMapper: DataProductMapper,
 ) : DataProductService {
 
     override fun downloadProduct(
@@ -83,10 +86,30 @@
     }
 
     override fun problemChangeList(option: DataProdOption): List<PPListProblemChange> {
-        TODO("Not yet implemented")
+        return dataProductMapper.problemChangeList(option)
     }
 
     override fun problemRecurrence(option: DataProdOption): List<PPListProbRecurrence> {
-        TODO("Not yet implemented")
+        val res = mutableListOf<PPListProbRecurrence>()
+        problemChangeList(option).forEach {pcl ->
+            val r = res.find {
+                it.sceneName == pcl.sceneName && it.problemName == pcl.problemName
+            }
+            if (r == null) {
+                val probRec = PPListProbRecurrence()
+                BeanUtils.copyProperties(pcl, probRec)
+                probRec.apply {
+                    proNum = 1
+                    changeNum += pcl.changeSum
+                }
+                res.add(probRec)
+            } else {
+                r.apply {
+                    proNum++
+                    changeNum += pcl.changeSum
+                }
+            }
+        }
+        return res
     }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductController.kt
index a76f7f4..d36ec3e 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductController.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductController.kt
@@ -3,6 +3,7 @@
 import cn.flightfeather.supervision.lightshare.service.DataProductService
 import cn.flightfeather.supervision.lightshare.vo.AreaVo
 import cn.flightfeather.supervision.lightshare.vo.ExcelConfigVo
+import cn.flightfeather.supervision.model.dataproduct.DataProdOption
 import io.swagger.annotations.Api
 import io.swagger.annotations.ApiOperation
 import io.swagger.annotations.ApiParam
@@ -29,4 +30,16 @@
         @ApiParam("鏄惁寮哄埗鐢熸垚鏂扮殑鎶ュ憡") @RequestParam forceUpdate: Boolean,
         @ApiIgnore response: HttpServletResponse,
     ) = resPack { dataProductService.downloadProduct(areaVo, type, forceUpdate, response) }
+
+    @ApiOperation(value = "鑾峰彇闂鏁存敼娓呭崟")
+    @PostMapping("/problemChange")
+    fun problemChangeList(
+        @ApiParam("鏌ヨ鏉′欢") @RequestBody option: DataProdOption,
+    ) = resPack { dataProductService.problemChangeList(option) }
+
+    @ApiOperation(value = "鑾峰彇闂澶嶅彂鎯呭喌")
+    @PostMapping("/problemRecurrence")
+    fun problemRecurrence(
+        @ApiParam("鏌ヨ鏉′欢") @RequestBody option: DataProdOption,
+    ) = resPack { dataProductService.problemRecurrence(option) }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProbRecurrence.kt b/src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProbRecurrence.kt
index 1013740..22f1cc3 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProbRecurrence.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProbRecurrence.kt
@@ -1,7 +1,5 @@
 package cn.flightfeather.supervision.model.dataproduct
 
-import cn.flightfeather.supervision.domain.ds1.entity.Scense
-
 /**
  * 鍒濈骇鏁版嵁浜у搧
  * 闂澶嶅彂鎯呭喌
@@ -10,33 +8,22 @@
  */
 class PPListProbRecurrence {
 
-    /**
-     * 鍦烘櫙淇℃伅
-     */
-    var scene: Scense? = null
-
-    /**
-     * 闂绫诲瀷id
-     */
-    var ptGuid: String? = null
-
-    /**
-     * 闂绫诲瀷鍚嶇О
-     */
-    var pTName: String? = null
-
-    /**
-     * 闂鍚嶇О
-     */
+    // 鍦烘櫙鍞竴缂栧彿
+    var index: Int? = null
+    // 鍦烘櫙鍚嶇О
+    var sceneName: String? = null
+    // 鍦烘櫙绫诲瀷
+    var sceneType: String? = null
+    var provinceName: String? = null
+    var cityName: String? = null
+    var districtName: String? = null
+    var townName: String? = null
+    // 闂绫诲瀷
+    var problemType: String? = null
+    // 闂鍚嶇О
     var problemName: String? = null
-
-    /**
-     * 闂鏁�
-     */
+    // 闂鏁�
     var proNum: Int = 0
-
-    /**
-     * 鏁存敼鏁�
-     */
+    // 鏁存敼鏁�
     var changeNum: Int = 0
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProblemChange.kt b/src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProblemChange.kt
index d587397..a560fcb 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProblemChange.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProblemChange.kt
@@ -1,9 +1,7 @@
 package cn.flightfeather.supervision.model.dataproduct
 
-import cn.flightfeather.supervision.domain.ds1.entity.Problemlist
-import cn.flightfeather.supervision.domain.ds1.entity.Problemtype
-import cn.flightfeather.supervision.domain.ds1.entity.Scense
-import cn.flightfeather.supervision.domain.ds1.entity.Subtask
+import java.util.*
+
 
 /**
  * 鍒濈骇鏁版嵁浜у搧
@@ -13,23 +11,28 @@
  */
 class PPListProblemChange {
 
-    /**
-     * 闂淇℃伅
-     */
-    var problem: Problemlist? = null
-
-    /**
-     * 鍦烘櫙淇℃伅
-     */
-    var scene: Scense? = null
-
-    /**
-     * 宸℃煡淇℃伅
-     */
-    var subTask: Subtask? = null
-
-    /**
-     * 闂绫诲瀷
-     */
-    var problemType: Problemtype? = null
+    // 鍦烘櫙鍞竴缂栧彿
+    var index: Int? = null
+    // 鍦烘櫙鍚嶇О
+    var sceneName: String? = null
+    // 鍦烘櫙绫诲瀷
+    var sceneType: String? = null
+    var provinceName: String? = null
+    var cityName: String? = null
+    var districtName: String? = null
+    var townName: String? = null
+    // 宸℃煡鏃堕棿
+    var inspectionTime: Date? = null
+    // 闂绫诲瀷
+    var problemType: String? = null
+    // 闂鍚嶇О
+    var problemName: String? = null
+    // 闂鍖哄煙
+    var location: String? = null
+    var problemTime: Date? = null
+    // 闂鏄惁鏁存敼
+    var hasChanged: Boolean = false
+    // 鏁存敼鏁�
+    var changeSum: Int = 0
+    var changedTime: Date? = null
 }
\ No newline at end of file
diff --git a/src/main/resources/mapper/ds1/DataProductMapper.xml b/src/main/resources/mapper/ds1/DataProductMapper.xml
new file mode 100644
index 0000000..55cc518
--- /dev/null
+++ b/src/main/resources/mapper/ds1/DataProductMapper.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="cn.flightfeather.supervision.domain.ds1.mapper.DataProductMapper">
+    <!-- 琛屾斂鍖哄垝鏉′欢 -->
+    <sql id="Where_Area">
+        <if test="provinceCode != null">
+            AND ${pCode} = #{provinceCode}
+        </if>
+        <if test="cityCode != null">
+            AND ${cCode} = #{cityCode}
+        </if>
+        <if test="districtCode != null">
+            AND ${dCode} = #{districtCode}
+        </if>
+        <if test="townCode != null">
+            AND ${tCode} = #{townCode}
+        </if>
+    </sql>
+    <!-- 鏃堕棿鏉′欢 -->
+    <sql id="Where_Time">
+        <if test="startTime != null">
+            AND ${sTime} >= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND ${eTime} &lt;= #{endTime}
+        </if>
+    </sql>
+    <!-- 鍦烘櫙淇℃伅鏉′欢 -->
+    <sql id="Where_Scene">
+        <if test="sceneId != null">
+            AND ${sId} = #{sceneId}
+        </if>
+        <if test="sceneTypeId != null">
+            AND ${typeId} = #{sceneTypeId}
+        </if>
+    </sql>
+
+    <!--  鏌ヨ闂鏁存敼娓呭崟-->
+    <select id="problemChangeList" resultType="cn.flightfeather.supervision.model.dataproduct.PPListProblemChange">
+        SELECT
+        b.S_Index as `index`,
+        a.PL_SenseName as sceneName,
+        b.S_Type as sceneType,
+        b.S_ProvinceName as provinceName,
+        b.S_CityName as cityName,
+        b.S_DistrictName as districtName,
+        b.S_TownName as townName,
+        c.ST_PlanStartTime as inspectionTime,
+        d.PT_TypeName as problemType,
+        d.PT_Name as problemName,
+        a.PL_Location as location,
+        a.PL_Time as problemTime,
+        a.PL_IsChanged as hasChanged,
+        a.PL_IsChanged as changeSum,
+        a.PL_ChangedTime as changedTime
+        FROM
+        im_t_problemlist AS a
+        LEFT JOIN sm_t_scense AS b ON a.S_GUID = b.S_GUID
+        LEFT JOIN tm_t_subtask as c on a.ST_GUID = c.ST_GUID
+        LEFT JOIN sm_t_problemtype as d on a.PT_GUID = d.PT_GUID
+        <where>
+            <include refid="Where_Area">
+                <property name="pCode" value="b.S_ProvinceCode"/>
+                <property name="cCode" value="b.S_CityCode"/>
+                <property name="dCode" value="b.S_DistrictCode"/>
+                <property name="tCode" value="b.S_TownCode"/>
+            </include>
+            <include refid="Where_Time">
+                <property name="sTime" value="a.PL_Time"/>
+                <property name="eTime" value="a.PL_Time"/>
+            </include>
+            <include refid="Where_Scene">
+                <property name="sId" value="b.S_GUID"/>
+                <property name="typeId" value="b.S_TypeID"/>
+            </include>
+        </where>
+        ORDER BY a.PL_SenseName, c.ST_PlanStartTime, d.PT_TypeName, a.PL_Time ASC
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/src/test/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductControllerTest.kt b/src/test/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductControllerTest.kt
new file mode 100644
index 0000000..7889fc4
--- /dev/null
+++ b/src/test/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductControllerTest.kt
@@ -0,0 +1,46 @@
+package cn.flightfeather.supervision.lightshare.web
+
+import cn.flightfeather.supervision.common.utils.Constant
+import cn.flightfeather.supervision.lightshare.service.DataProductService
+import cn.flightfeather.supervision.model.dataproduct.DataProdOption
+import org.junit.Test
+import org.junit.jupiter.api.extension.ExtendWith
+import org.junit.runner.RunWith
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.test.context.junit.jupiter.SpringExtension
+import org.springframework.test.context.junit4.SpringRunner
+import java.time.LocalDateTime
+
+@RunWith(SpringRunner::class)
+@ExtendWith(SpringExtension::class)
+@SpringBootTest
+class DataProductControllerTest {
+
+    @Autowired
+    lateinit var dataProductController: DataProductController
+
+    @Autowired
+    lateinit var dataProductService: DataProductService
+
+    private val option = DataProdOption().apply {
+        provinceCode = "31"
+        cityCode = "3100"
+        districtCode = "310106"
+        townCode
+        startTime = LocalDateTime.of(2025, 1, 1, 0, 0, 0)
+        endTime = LocalDateTime.of(2025, 7, 31, 23, 59, 59)
+        sceneId
+        sceneTypeId = Constant.SceneType.TYPE1.value.toInt()
+    }
+
+    @Test
+    fun problemChangeList() {
+        val result = dataProductService.problemChangeList(option)
+        println(result)
+    }
+
+    @Test
+    fun problemRecurrence() {
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.3