From 82baf5d28ce79aa4d3b64956207d247596726924 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期二, 10 十二月 2024 11:21:33 +0800
Subject: [PATCH] 1. BgTaskStatus状态属性序列化
---
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ItemevaluationServiceImpl.kt | 92 +++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 86 insertions(+), 6 deletions(-)
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 4c1645c..29475cb 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
@@ -1,15 +1,32 @@
package cn.flightfeather.supervision.lightshare.service.impl
+import cn.flightfeather.supervision.business.autooutput.AopOutput
+import cn.flightfeather.supervision.business.autooutput.datasource.AopDataSource
+import cn.flightfeather.supervision.business.autooutput.datasource.AopDbMapper
+import cn.flightfeather.supervision.business.autooutput.datasource.AopSceneTypeCheck
+import cn.flightfeather.supervision.business.autooutput.score.ScoreUtil
+import cn.flightfeather.supervision.common.exception.BizException
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.ItemevaluationVo
+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
import org.springframework.transaction.annotation.Transactional
@Service
-class ItemevaluationServiceImpl(val itemevaluationMapper: ItemevaluationMapper) : ItemevaluationService {
+class ItemevaluationServiceImpl(
+ private val itemevaluationMapper: ItemevaluationMapper,
+ private val aopDbMapper: AopDbMapper,
+ private val aopOutput: AopOutput,
+ private val aopSceneTypeCheck: AopSceneTypeCheck,
+ private val subTaskRep: SubTaskRep,
+ private val taskRep: TaskRep,
+) : ItemevaluationService {
//鎵归噺淇敼鍗曢」璇勪及
@Transactional
@@ -32,13 +49,13 @@
}
//鏍规嵁瀛愪换鍔D鑾峰彇鍗曢」璇勪及鍒楄〃
- override fun findBySubTaskID(subTaskID: String): List<ItemevaluationVo> {
- val itemvaluationVoList = mutableListOf<ItemevaluationVo>()
+ override fun findBySubTaskID(subTaskID: String): List<ItemEvaluationVo> {
+ val itemvaluationVoList = mutableListOf<ItemEvaluationVo>()
val itemvaluation = Itemevaluation()
itemvaluation.stguid = subTaskID
val itemvaluationList = itemevaluationMapper.select(itemvaluation)
itemvaluationList.forEach {
- val itemvaluationVo = ItemevaluationVo()
+ val itemvaluationVo = ItemEvaluationVo()
BeanUtils.copyProperties(it, itemvaluationVo)
itemvaluationVoList.add(itemvaluationVo)
}
@@ -51,7 +68,70 @@
override fun save(itemevaluation: Itemevaluation): Int = itemevaluationMapper.insert(itemevaluation)
- override fun update(itemevaluation: Itemevaluation): Int = itemevaluationMapper.updateByPrimaryKeySelective(itemevaluation)
+ override fun update(itemevaluation: Itemevaluation): Int =
+ itemevaluationMapper.updateByPrimaryKeySelective(itemevaluation)
override fun delete(id: String): Int = itemevaluationMapper.deleteByPrimaryKey(id)
+
+ @Transactional
+ override fun createItemEvaluation(subTaskId: String, ruleId: String?, itemList: List<String>): Boolean {
+ val source = AopDataSource(aopDbMapper, aopSceneTypeCheck)
+ val subTask = subTaskRep.findOne(subTaskId) ?: throw BizException("宸℃煡浠诲姟涓嶅瓨鍦�")
+ source.setResource(subTask)
+ try {
+ source.runBySubTask { _, evaluationScene ->
+ if (evaluationScene.noRecord()) throw BizException("宸℃煡浠诲姟涓嶅瓨鍦�")
+ // 灏嗗垎鏁拌祴鍊煎埌瀵瑰簲鐨勮瘎浼拌鍒欎笅锛屽苟涓旇嚜鍔ㄨ绠楀叾浣欒鍒欑殑寰楀垎
+ ScoreUtil.scoreAssign(evaluationScene, itemList)
+ // 鑾峰彇鎬诲垎鍜屽瓙椤瑰緱鍒嗘暟鎹簱琛ㄧ粨鏋勪綋锛屽苟鍏ュ簱
+ ScoreUtil.genEvaRecord(evaluationScene)?.let { aopOutput.toDbEvaluation(evaluationScene, it) }
+ }
+ return true
+ } catch (e: Exception) {
+ throw BizException("鍑虹幇绯荤粺鍐呴儴閿欒")
+ }
+ }
+
+ @Transactional
+ override fun updateItemEvaluation(subTaskId: String, ruleId: String?, itemList: List<String>): Boolean {
+ val source = AopDataSource(aopDbMapper, aopSceneTypeCheck)
+ val subTask = subTaskRep.findOne(subTaskId) ?: throw BizException("宸℃煡浠诲姟涓嶅瓨鍦�")
+ source.setResource(subTask)
+ try {
+ source.runBySubTask { _, 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("鍑虹幇绯荤粺鍐呴儴閿欒")
+ }
+ }
+
+ 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("宸℃煡浠诲姟涓嶅瓨鍦�")
+ evaVo.subTaskEvaList?.find {
+ it.subTaskId == evaluationScene.subTask.value?.stguid
+ }?.let {stEva ->
+ // 灏嗗垎鏁拌祴鍊煎埌瀵瑰簲鐨勮瘎浼拌鍒欎笅锛屽苟涓旇嚜鍔ㄨ绠楀叾浣欒鍒欑殑寰楀垎
+ ScoreUtil.scoreAssignSelected(evaluationScene, stEva.subRule)
+ // 鑾峰彇鎬诲垎鍜屽瓙椤瑰緱鍒嗘暟鎹簱琛ㄧ粨鏋勪綋锛屽苟鍏ュ簱
+ ScoreUtil.updateEvaRecord(evaluationScene)?.let { aopOutput.updateDbEvaluation(evaluationScene, it) }
+ }
+ }
+ return true
+ } catch (e: Exception) {
+ throw BizException("鍑虹幇绯荤粺鍐呴儴閿欒")
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3