From bda3bf8923acb5216f6f46b5d903cac24c842143 Mon Sep 17 00:00:00 2001
From: Riku <risaku@163.com>
Date: 星期六, 28 九月 2024 22:25:29 +0800
Subject: [PATCH] 1. 新增监测数据得分批量更新接口(待完成)
---
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ItemevaluationService.kt | 4 ++
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationUpdateVo.kt | 22 +++++++++++
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt | 7 +++
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt | 9 +++-
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaEvaVo.kt | 2
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ItemevaluationServiceImpl.kt | 24 ++++++++++++
6 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
index 23bcf93..e8f9e4e 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
@@ -7,6 +7,7 @@
import cn.flightfeather.supervision.domain.ds2.entity.LedgerSubType
import cn.flightfeather.supervision.domain.ds2.entity.UserMap
import cn.flightfeather.supervision.domain.ds2.entity.UserinfoTZ
+import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.EvaluationSubRuleVo
import org.springframework.beans.BeanUtils
import tk.mybatis.mapper.entity.Example
@@ -39,6 +40,12 @@
}
}
+// fun setResource(areaVo: AreaVo) {
+// val task = taskRep.findOneTask(areaVo)
+// val taskId = task?.tguid
+// val sceneType = areaVo.scensetypeid?.toInt() ?: throw BizException("鍦烘櫙绫诲瀷鏈缃紝鏃犳硶璇勪及")
+// }
+
fun setResource(config: AopDataConfig) {
config.sceneType ?: return
evaluationScene.config = config
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ItemevaluationService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ItemevaluationService.kt
index 48c0bf3..e160f2a 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ItemevaluationService.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/ItemevaluationService.kt
@@ -1,6 +1,8 @@
package cn.flightfeather.supervision.lightshare.service
import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
+import cn.flightfeather.supervision.lightshare.vo.AreaVo
+import cn.flightfeather.supervision.lightshare.vo.EvaluationUpdateVo
import cn.flightfeather.supervision.lightshare.vo.ItemEvaluationVo
@@ -29,4 +31,6 @@
fun createItemEvaluation(subTaskId: String, ruleId: String?, itemList: List<String>): Boolean
fun updateItemEvaluation(subTaskId: String, ruleId: String?, itemList: List<String>): Boolean
+
+ fun updateMonitorDataEva(evaVo: EvaluationUpdateVo): Boolean
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ItemevaluationServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ItemevaluationServiceImpl.kt
index 4ea547f..b3d99bc 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ItemevaluationServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ItemevaluationServiceImpl.kt
@@ -9,7 +9,10 @@
import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
import cn.flightfeather.supervision.domain.ds1.mapper.ItemevaluationMapper
import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep
+import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.lightshare.service.ItemevaluationService
+import cn.flightfeather.supervision.lightshare.vo.AreaVo
+import cn.flightfeather.supervision.lightshare.vo.EvaluationUpdateVo
import cn.flightfeather.supervision.lightshare.vo.ItemEvaluationVo
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service
@@ -22,6 +25,7 @@
private val aopOutput: AopOutput,
private val aopSceneTypeCheck: AopSceneTypeCheck,
private val subTaskRep: SubTaskRep,
+ private val taskRep: TaskRep,
) : ItemevaluationService {
//鎵归噺淇敼鍗曢」璇勪及
@@ -106,4 +110,24 @@
throw BizException("鍑虹幇绯荤粺鍐呴儴閿欒")
}
}
+
+ override fun updateMonitorDataEva(evaVo: EvaluationUpdateVo): Boolean {
+ val task = taskRep.findOneTask(evaVo)
+ val taskId = task?.tguid
+ val sceneType = evaVo.scensetypeid?.toInt() ?: throw BizException("鍦烘櫙绫诲瀷鏈缃紝鏃犳硶鏇存柊鍒嗘暟")
+ val source = AopDataSource(aopDbMapper, aopSceneTypeCheck)
+ source.setResource(taskId, sceneType, null, null)
+ try {
+ source.loop() { _, evaluationScene ->
+ if (evaluationScene.noRecord()) throw BizException("宸℃煡浠诲姟涓嶅瓨鍦�")
+ // 灏嗗垎鏁拌祴鍊煎埌瀵瑰簲鐨勮瘎浼拌鍒欎笅锛屽苟涓旇嚜鍔ㄨ绠楀叾浣欒鍒欑殑寰楀垎
+ ScoreUtil.scoreAssign(evaluationScene, itemList)
+ // 鑾峰彇鎬诲垎鍜屽瓙椤瑰緱鍒嗘暟鎹簱琛ㄧ粨鏋勪綋锛屽苟鍏ュ簱
+ ScoreUtil.updateEvaRecord(evaluationScene)?.let { aopOutput.updateDbEvaluation(evaluationScene, it) }
+ }
+ return true
+ } catch (e: Exception) {
+ throw BizException("鍑虹幇绯荤粺鍐呴儴閿欒")
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaEvaVo.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaEvaVo.kt
index 50bf37d..cd749f2 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaEvaVo.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaEvaVo.kt
@@ -6,7 +6,7 @@
* 璇勪及瑙勫垯鏌ヨ鏉′欢
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
-class AreaEvaVo : AreaVo() {
+open class AreaEvaVo : AreaVo() {
// 璇勪及瑙勫垯绫诲瀷锛�1锛氬贰鏌ユ儏鍐佃瘎浼帮紱99锛氳嚜鍔ㄨ瘎浼�
var taskTypeId: Int = 1
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationUpdateVo.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationUpdateVo.kt
new file mode 100644
index 0000000..75f1f1a
--- /dev/null
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationUpdateVo.kt
@@ -0,0 +1,22 @@
+package cn.flightfeather.supervision.lightshare.vo
+
+import io.swagger.annotations.ApiModel
+import io.swagger.annotations.ApiModelProperty
+
+/**
+ * 宸℃煡浠诲姟鐩戞祴鏁版嵁寮傚父鎵e垎
+ * @date 2024/9/28
+ * @author feiyu02
+ */
+@ApiModel("宸℃煡浠诲姟鐩戞祴鏁版嵁寮傚父鎵e垎")
+class EvaluationUpdateVo : AreaEvaVo() {
+
+ @ApiModelProperty("宸℃煡浠诲姟涓婚敭")
+ var subTaskId: String? = null
+
+ @ApiModelProperty("璇勪及瑙勫垯id")
+ var ruleId: String? = null
+
+ @ApiModelProperty("鍏蜂綋璇勪及鏉$洰鏄惁鍕鹃��", notes = "瀵硅薄缁撴瀯涓鸿瘎浼版潯鐩殑涓婚敭鍜屾槸鍚﹀嬀閫夊舰鎴愮殑閿�煎鍒楄〃")
+ var subRule: List<Pair<String, Boolean>>? = null
+}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt
index bd4c0fd..c6c9a34 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt
@@ -3,12 +3,11 @@
import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
import cn.flightfeather.supervision.lightshare.service.ItemevaluationService
import cn.flightfeather.supervision.lightshare.vo.AreaVo
+import cn.flightfeather.supervision.lightshare.vo.EvaluationUpdateVo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.web.bind.annotation.*
-import springfox.documentation.annotations.ApiIgnore
-import javax.servlet.http.HttpServletResponse
@Api(tags = ["ItemevaluationController"], description = "璇勪及瀛愰」寰楀垎API鎺ュ彛")
@RestController
@@ -55,4 +54,10 @@
@RequestParam(required = false) ruleId: String?,
@ApiParam(value = "鍏蜂綋鎵e垎鏉$洰涓婚敭锛堝彧浼犳渶灏忕骇鍒殑璇勪及椤癸級") @RequestBody itemList: List<String>,
) = resPack { itemevaluationService.updateItemEvaluation(subTaskId, ruleId, itemList) }
+
+ @ApiOperation(value = "鎵归噺鏇存柊璇勪及缁撴灉")
+ @PostMapping("/update/multiple")
+ fun updateMonitorDataEva(
+ @ApiParam("寰楀垎淇敼缁嗚妭") @RequestBody evaVo: EvaluationUpdateVo,
+ ) = resPack { itemevaluationService.updateMonitorDataEva(evaVo) }
}
\ No newline at end of file
--
Gitblit v1.9.3