From 7cd8d2a1e96de3d173bf5af64b4adc29c497db2a Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期六, 12 十月 2024 17:38:07 +0800
Subject: [PATCH] 1. 新增评估结果批量修改相关接口(完成)

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ItemevaluationServiceImpl.kt |   94 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 87 insertions(+), 7 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 ce0ce30..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,22 +1,39 @@
 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
     override fun updatelist(itemevaluationlist: List<Itemevaluation>): Int {
         //寰幆淇敼
         itemevaluationlist.forEach {
-            itemevaluationMapper.updateByPrimaryKey(it)
+            itemevaluationMapper.updateByPrimaryKeySelective(it)
         }
         return itemevaluationlist.size
     }
@@ -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.updateByPrimaryKey(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