1. 新增静安50分制评估结果转换逻辑;
2. 新增根据坐标圆心和半径查询范围内场景逻辑;
已修改8个文件
已添加2个文件
133 ■■■■ 文件已修改
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/construction/JAScore.kt 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/bgtask/JingAnScoreTaskCtrl.kt 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearby.kt 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ScenseService.kt 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ScenseServiceImpl.kt 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AutoScoreResultVo.kt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ScenseController.kt 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ds1/EvaluationMapper.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/cn/flightfeather/supervision/business/bgtask/JingAnScoreTaskCtrlTest.kt 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/construction/JAScore.kt
@@ -15,12 +15,9 @@
 * æ ¹æ®è‡ªåŠ¨è¯„åˆ†ç»“æžœè¿›è¡Œè½¬æ¢å¾—å‡º
 */
@Component
class JAScore {
class JAScore(private val scoreMapper: ScoreMapper) {
    @Autowired
    lateinit var scoreMapper: ScoreMapper
    fun toDb(e: Evaluation, info: Info) {
    fun toDb(e: Evaluation, isEnable: Boolean) {
        val time = LocalDateTime.ofInstant(e.evaluatetime?.toInstant(), ZoneId.systemDefault())
        val scoreVo = Score().apply {
            sceneId = e.sguid
@@ -30,7 +27,7 @@
            districtCode = e.districtcode
            districtName = e.districtname
            score = transform(e.resultscorebef?.toIntOrNull() ?: 0)
            completion = !info.online
            completion = !isEnable
        }
        val res = scoreMapper.selectByExample(Example(Score::class.java).apply {
src/main/kotlin/cn/flightfeather/supervision/business/bgtask/JingAnScoreTaskCtrl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,41 @@
package cn.flightfeather.supervision.business.bgtask
import cn.flightfeather.supervision.business.autooutput.score.construction.JAScore
import cn.flightfeather.supervision.common.executor.BackgroundTaskCtrl
import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRep
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import org.springframework.stereotype.Component
import java.time.LocalDateTime
/**
 * é™å®‰åŒº50分制评分转换任务
 */
@Component
class JingAnScoreTaskCtrl(
    private val backgroundTaskCtrl: BackgroundTaskCtrl,
    private val jaScore: JAScore,
    private val evaluationRep: EvaluationRep
) {
    /**
     * é™å®‰å·¥åœ°åˆ†æ•°è½¬æ¢ä»»åŠ¡
     */
    fun startTaskJingAn(startTime: LocalDateTime) {
        startTask("31", "3100", "310106", startTime)
    }
    fun startTask(pCode: String, cCode: String, dCode: String, startTime: LocalDateTime) {
        val areaVo = AreaVo().apply {
            provincecode = pCode
            citycode = cCode
            districtcode = dCode
            starttime = startTime
            scensetypeid = "1"
        }
        evaluationRep.findAutoScore(areaVo)?.forEach {
            it?.let {
                it.evaluation?.let { e-> jaScore.toDb(e, it.isEnable) }
            }
        }
    }
}
src/main/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearby.kt
@@ -3,12 +3,14 @@
import cn.flightfeather.supervision.common.utils.ExcelUtil
import cn.flightfeather.supervision.domain.ds1.entity.Scense
import cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper
import org.springframework.stereotype.Component
import tk.mybatis.mapper.entity.Example
import kotlin.math.PI
/**
 * è·¯æ®µå‘¨è¾¹æŸ¥è¯¢
 */
@Component
class LocationRoadNearby(private val scenseMapper: ScenseMapper) {
    private val utilFile = UtilFile()
@@ -55,6 +57,26 @@
    }
    /**
     * æ ¹æ®åœ†å¿ƒå’ŒåŠå¾„查询范围内监测点(当前简化操作,改为以直径为边长的正方形范围)
     * @param center åœ†å¿ƒ
     * @param radius åŠå¾„(单位:米)
     * @return åœºæ™¯åˆ—表
     */
    fun searchByRadius(center: Pair<Double, Double>, radius: Double): List<Scense> {
        // æ±‚经度的最小值
        val minLng = CoordinateUtil.getPointByLen(center, radius, PI * 1.5).first
        // æ±‚经度的最大值
        val maxLng = CoordinateUtil.getPointByLen(center, radius, PI * 0.5).first
        // æ±‚纬度的最小值
        val minLat = CoordinateUtil.getPointByLen(center, radius, PI).second
        // æ±‚纬度的最大值
        val maxLat = CoordinateUtil.getPointByLen(center, radius, .0).second
        val list = listOf(minLng, maxLng, minLat, maxLat)
        return getSceneFromDb(list)
    }
    /**
     * èŒƒå›´é™å®š
     * æ ¹æ®è·¯æ®µçš„始末点坐标和查询半径,计算最大可能的范围矩形,得出经纬度的最大最小值
     */
@@ -88,11 +110,4 @@
                .orIsNull("extension1"))
        })
    }
    /**
     * ç²¾ç¡®è®¡ç®—
     */
//    private fun checkDistance(scense: Scense):Boolean {
//
//    }
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ScenseService.kt
@@ -41,4 +41,6 @@
    fun updateSceneDetail(typeId: Int, sceneDetailStr: SceneDetailStr): BaseResponse<String>
    fun searchScene(areaVo: AreaVo, page: Int?, perPage: Int?): BaseResponse<List<Scense>>
    fun searchByCoordinate(lng: Double, lat: Double, radius: Double): List<Scense>
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt
@@ -310,8 +310,8 @@
        val p = "$filePath/autoscore/"
        val file = File(p + fileName)
        if (config.forceUpdate || !file.exists()) {
            val downloadUrl = "/autoscore/${fileName}"
            reportTaskCtrl.startTask(t, downloadUrl)
//            val downloadUrl = "/autoscore/${fileName}"
//            reportTaskCtrl.startTask(t, downloadUrl)
            return false
        } else {
            val fName = Base64.getEncoder().encodeToString(fileName.toByteArray())
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ScenseServiceImpl.kt
@@ -1,8 +1,9 @@
package cn.flightfeather.supervision.lightshare.service.impl
import cn.flightfeather.supervision.business.location.LocationRoadNearby
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.domain.ds1.entity.*
import cn.flightfeather.supervision.domain.ds1.mapper.*
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.lightshare.service.*
import cn.flightfeather.supervision.lightshare.vo.*
import com.github.pagehelper.PageHelper
@@ -22,7 +23,8 @@
        val sceneMixingPlantMapper: SceneMixingPlantMapper,
        val sceneStorageYardMapper: SceneStorageYardMapper,
        val sceneWharfMapper: SceneWharfMapper,
        val userinfoService: UserinfoService
    val userinfoService: UserinfoService,
    private val locationRoadNearby: LocationRoadNearby,
) : ScenseService {
    @Autowired
@@ -384,4 +386,8 @@
        })
        return BaseResponse(true, head = DataHead(p.pageNum, p.pages, p.total), data = list)
    }
    override fun searchByCoordinate(lng: Double, lat: Double, radius: Double): List<Scense> {
        return locationRoadNearby.searchByRadius(Pair(lng, lat), radius)
    }
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AutoScoreResultVo.kt
@@ -11,6 +11,7 @@
class AutoScoreResultVo {
    var userId: String? = null
    var userName: String? = null
    var isEnable: Boolean = true
    var sceneId: String? = null
    var sceneName: String? = null
    var pName: String? = null
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ScenseController.kt
@@ -81,4 +81,11 @@
        @RequestParam("per_page", required = false) perPage: Int?
    ) = scenseService.searchScene(areaVo, page, perPage)
    @ApiOperation(value = "根据圆心和半径找到范围内的场景")
    @PostMapping("/find/coor")
    fun searchByCoordinate(
        @RequestParam("lng") lng: Double,
        @RequestParam("lat") lat: Double,
        @RequestParam("radius") radius: Double,
    ) = resPack { scenseService.searchByCoordinate(lng, lat, radius) }
}
src/main/resources/mapper/ds1/EvaluationMapper.xml
@@ -56,6 +56,7 @@
  <resultMap id="AutoScoreResultMap" type="cn.flightfeather.supervision.lightshare.vo.AutoScoreResultVo">
    <result column="userId" jdbcType="VARCHAR" property="userId"/>
    <result column="userName" jdbcType="VARCHAR" property="userName"/>
    <result column="isEnable" jdbcType="BIT" property="isEnable"/>
    <result column="sceneId" jdbcType="VARCHAR" property="sceneId"/>
    <result column="sceneName" jdbcType="VARCHAR" property="sceneName"/>
    <result column="pName" jdbcType="VARCHAR" property="pName"/>
@@ -71,6 +72,7 @@
    SELECT
    c.UI_GUID AS userId,
    c.UI_RealName AS userName,
    c.UI_IsEnable AS isEnable,
    b.S_GUID AS sceneId,
    b.S_Name AS sceneName,
    b.S_ProvinceName AS pName,
src/test/kotlin/cn/flightfeather/supervision/business/bgtask/JingAnScoreTaskCtrlTest.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
package cn.flightfeather.supervision.business.bgtask
import org.junit.Test
import org.junit.jupiter.api.Assertions.*
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 JingAnScoreTaskCtrlTest() {
    @Autowired
    lateinit var jingAnScoreTaskCtrl: JingAnScoreTaskCtrl
    @Test
    fun startTask() {
        var time = LocalDateTime.of(2023, 10, 1, 0, 0, 0)
        repeat(4) {
            jingAnScoreTaskCtrl.startTaskJingAn(time)
            time = time.plusMonths(1)
        }
    }
}