From 274bc2d0f7fe8fe7525196e4d7d6ece1cafe2c6c Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期日, 04 二月 2024 17:32:14 +0800
Subject: [PATCH] 1. 新增静安50分制评估结果转换逻辑; 2. 新增根据坐标圆心和半径查询范围内场景逻辑;
---
src/main/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearby.kt | 29 +++++++--
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt | 4
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ScenseService.kt | 2
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ScenseServiceImpl.kt | 22 ++++--
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/construction/JAScore.kt | 9 +--
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AutoScoreResultVo.kt | 1
src/main/resources/mapper/ds1/EvaluationMapper.xml | 2
src/test/kotlin/cn/flightfeather/supervision/business/bgtask/JingAnScoreTaskCtrlTest.kt | 28 +++++++++
src/main/kotlin/cn/flightfeather/supervision/business/bgtask/JingAnScoreTaskCtrl.kt | 41 +++++++++++++
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ScenseController.kt | 7 ++
10 files changed, 122 insertions(+), 23 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/construction/JAScore.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/construction/JAScore.kt
index dda636a..def18ff 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/construction/JAScore.kt
+++ b/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 {
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/bgtask/JingAnScoreTaskCtrl.kt b/src/main/kotlin/cn/flightfeather/supervision/business/bgtask/JingAnScoreTaskCtrl.kt
new file mode 100644
index 0000000..56a0f47
--- /dev/null
+++ b/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) }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearby.kt b/src/main/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearby.kt
index 5719d4e..c8fb9bc 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/location/LocationRoadNearby.kt
+++ b/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 {
-//
-// }
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ScenseService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ScenseService.kt
index 7a19ffd..4a3e1e0 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ScenseService.kt
+++ b/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>
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt
index 22a8fea..7549c48 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt
+++ b/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())
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ScenseServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ScenseServiceImpl.kt
index 19e54ff..ea2e3be 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ScenseServiceImpl.kt
+++ b/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
@@ -16,13 +17,14 @@
@Service
class ScenseServiceImpl(
- val scenseMapper: ScenseMapper,
- val sceneConstructionSiteMapper: SceneConstructionSiteMapper,
- val sceneDeviceMapper: SceneDeviceMapper,
- val sceneMixingPlantMapper: SceneMixingPlantMapper,
- val sceneStorageYardMapper: SceneStorageYardMapper,
- val sceneWharfMapper: SceneWharfMapper,
- val userinfoService: UserinfoService
+ val scenseMapper: ScenseMapper,
+ val sceneConstructionSiteMapper: SceneConstructionSiteMapper,
+ val sceneDeviceMapper: SceneDeviceMapper,
+ val sceneMixingPlantMapper: SceneMixingPlantMapper,
+ val sceneStorageYardMapper: SceneStorageYardMapper,
+ val sceneWharfMapper: SceneWharfMapper,
+ 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)
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AutoScoreResultVo.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AutoScoreResultVo.kt
index 335e3e1..4ff51a7 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AutoScoreResultVo.kt
+++ b/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
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ScenseController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ScenseController.kt
index c1415b5..138e9fe 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ScenseController.kt
+++ b/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) }
}
\ No newline at end of file
diff --git a/src/main/resources/mapper/ds1/EvaluationMapper.xml b/src/main/resources/mapper/ds1/EvaluationMapper.xml
index cc53dd8..2be5553 100644
--- a/src/main/resources/mapper/ds1/EvaluationMapper.xml
+++ b/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,
diff --git a/src/test/kotlin/cn/flightfeather/supervision/business/bgtask/JingAnScoreTaskCtrlTest.kt b/src/test/kotlin/cn/flightfeather/supervision/business/bgtask/JingAnScoreTaskCtrlTest.kt
new file mode 100644
index 0000000..6672ec5
--- /dev/null
+++ b/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)
+ }
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.3