From 0516cba27e632f20efac2752787f38f0c87baafa Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期三, 25 九月 2024 09:24:05 +0800 Subject: [PATCH] 1. 新增自动评估添加和更新接口 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ItemevaluationServiceImpl.kt | 64 +++++++++++++++++++++++++++++--- 1 files changed, 58 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..4ea547f 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,28 @@ 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.lightshare.service.ItemevaluationService -import cn.flightfeather.supervision.lightshare.vo.ItemevaluationVo +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, +) : ItemevaluationService { //鎵归噺淇敼鍗曢」璇勪及 @Transactional @@ -32,13 +45,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 +64,46 @@ 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("鍑虹幇绯荤粺鍐呴儴閿欒") + } + } } \ No newline at end of file -- Gitblit v1.9.3