feiyu02
2025-07-31 6688232eaa889eeb6c58d0d804b587699db55ec2
2025.7.31
1. 新增基础数据产品相关接口
已修改5个文件
已添加3个文件
277 ■■■■ 文件已修改
src/main/kotlin/cn/flightfeather/supervision/config/CorsConfig.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/domain/ds1/mapper/DataProductMapper.kt 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProductServiceImpl.kt 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductController.kt 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProbRecurrence.kt 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/model/dataproduct/PPListProblemChange.kt 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ds1/DataProductMapper.xml 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/cn/flightfeather/supervision/lightshare/web/DataProductControllerTest.kt 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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())
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>
}
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
    }
}
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) }
}
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
}
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
}
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>
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() {
    }
}