From 52a0c16de9b0955a5f092560b73f16e41684f97b Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 31 十二月 2024 10:13:35 +0800 Subject: [PATCH] 1. 环信码生成时,如果在线场景当期没有评估(未巡查)结果,则延用历史最新一次的结果; 2. 新增跨时间跨月度的历史整改记录查询逻辑 3. 优化获取顶层任务和日任务的获取逻辑 --- 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