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/EvaluationsubruleServiceImpl.kt | 140 +++++++--------------------------------------- 1 files changed, 21 insertions(+), 119 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationsubruleServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationsubruleServiceImpl.kt index e9d5732..e972031 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationsubruleServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationsubruleServiceImpl.kt @@ -1,15 +1,16 @@ package cn.flightfeather.supervision.lightshare.service.impl import cn.flightfeather.supervision.common.exception.BizException -import cn.flightfeather.supervision.domain.ds1.entity.* +import cn.flightfeather.supervision.domain.ds1.entity.Evaluationrule +import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule +import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule2 import cn.flightfeather.supervision.domain.ds1.mapper.EvaluationruleMapper import cn.flightfeather.supervision.domain.ds1.mapper.EvaluationsubruleMapper import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRep import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRuleRep +import cn.flightfeather.supervision.domain.ds1.repository.SceneRep import cn.flightfeather.supervision.lightshare.service.EvaluationsubruleService -import cn.flightfeather.supervision.lightshare.vo.EvaluationVo -import cn.flightfeather.supervision.lightshare.vo.SubEvaluationVo -import cn.flightfeather.supervision.lightshare.vo.ThirdEvaluationVo +import cn.flightfeather.supervision.lightshare.vo.ScoreDetail import org.springframework.stereotype.Service import tk.mybatis.mapper.entity.Example @@ -19,6 +20,7 @@ val evaluationruleMapper: EvaluationruleMapper, private val evaluationRep: EvaluationRep, private val evaluationRuleRep: EvaluationRuleRep, + private val sceneRep: SceneRep, ) : EvaluationsubruleService { override fun findOne(id: String): Evaluationsubrule = evaluationsubruleMapper.selectByPrimaryKey(id) @@ -32,12 +34,8 @@ override fun delete(id: String): Int = evaluationsubruleMapper.deleteByPrimaryKey(id) - override fun findByRuleId(erguid: String): List<Evaluationsubrule> { - val example = Example(Evaluationsubrule::class.java) - val criteria = example.createCriteria() - criteria.andEqualTo("erguid", erguid) - example.orderBy("extension1").desc() - return evaluationsubruleMapper.selectByExample(example) + override fun findByRuleId(erguid: String): List<Evaluationsubrule2> { + return evaluationRuleRep.findSubRule(erguid) } override fun search(districtCode: String, sceneTypeId: String, version: String?): List<Evaluationsubrule> { @@ -56,125 +54,29 @@ return result } - override fun getAutoScore(subTaskId: String): List<EvaluationVo> { + override fun getAutoScore(subTaskId: String): ScoreDetail { + //鍦烘櫙淇℃伅 + val scene = sceneRep.findBySubTask(subTaskId) + //鎬诲垎 + val evaluation = evaluationRep.findBySubtask(subTaskId) //瀛愯鍒欓�愭潯寰楀垎 val subRuleScores = evaluationRep.findItemEvaluation(subTaskId) + if (subRuleScores.isEmpty()) throw BizException("鏃犺瘎浼拌褰�") //璇勫垎鎬昏鍒� val rule = evaluationRuleRep.findAutoEvaluationRule(subTaskId) ?: throw BizException("鏈壘鍒扮浉鍏宠嚜鍔ㄨ瘎浼拌鍒�") //鎬昏鍒欏搴旂殑璇勫垎瀛愯鍒� val subRules = evaluationRuleRep.findSubRule(rule.guid) //鏌ヨ缁撴灉 - val resultList = mutableListOf<EvaluationVo>() + val result = ScoreDetail() + result.status = if (scene?.extension1.equals("1")) "鍦ㄥ缓" else "瀹屽伐" - var _group = 0 + result.updateTime = evaluation?.updatedate subRules.forEach { - when (it.ertype) { - 2 -> resultList.add(EvaluationVo().apply { - id = it.guid - title = it.itemname - scoreMode = it.extension1 - gradeMode = it.extension2 - maxScore = when (gradeMode) { - "minus_mode" -> it.minscore?.minus(it.maxscore ?: 0) ?: 0 - "add_mode" -> it.maxscore ?: 0 - else -> it.minscore?.minus(it.maxscore ?: 0) ?: 0 - } - selectMode = it.extension3 - - //濡傛灉鏈夊緱鍒嗚褰曪紝鍒欐敼鍙樼姸鎬佷负閫変腑 - for (s in subRuleScores) { - if (it.guid == s.esrguid) { - select = s.extension1 == "true" - break - } - } - }) - 3 -> { - for (r in resultList) { - if (it.fatherid == r.id) { - r.subList.add(SubEvaluationVo().apply { - id = it.guid - title2 = it.itemname - gradeMode = it.extension2 - selectMode = it.extension3 - score = when (gradeMode) { - "minus_mode" -> it.minscore?.minus(it.maxscore ?: 0) ?: 0 - "add_mode" -> it.maxscore ?: 0 - else -> it.minscore?.minus(it.maxscore ?: 0) ?: 0 - } - group = _group++ - - //濡傛灉鏈夊緱鍒嗚褰曪紝鍒欐敼鍙樼姸鎬佷负閫変腑 - for (s in subRuleScores) { - if (it.guid == s.esrguid) { - select = s.extension1 == "true" - break - } - } - }) - break - } - } - } - 4 -> { - resultList.forEach{ r -> - //4绾х殑璇勪及椤圭洿鎺ラ檮灞炰簬2绾ц瘎浼伴」 - if (r.id == it.fatherid) { - if (r.subList.isEmpty()) { - r.subList.add(SubEvaluationVo().apply { - placeholder = true - id = it.guid - title2 = r.title - score = r.maxScore - gradeMode = r.gradeMode - selectMode = r.selectMode - group = _group++ - }) - } - r.subList[0].sub2.add(ThirdEvaluationVo().apply { - id = it.guid - content = it.itemname - score = when (r.subList[0].gradeMode) { - "minus_mode" -> r.maxScore.plus(it.maxscore ?: 0) - "add_mode" -> it.maxscore ?: 0 - else -> r.maxScore.plus(it.maxscore ?: 0) - } - //濡傛灉鏈夊緱鍒嗚褰曪紝鍒欐敼鍙樼姸鎬佷负閫変腑 - for (s in subRuleScores) { - if (it.guid == s.esrguid) { - select = s.extension1 == "true" - break - } - } - }) - } else { - r.subList.forEach { sr -> - if (sr.id == it.fatherid){ - sr.sub2.add(ThirdEvaluationVo().apply { - id = it.guid - content = it.itemname - score = when (sr.gradeMode) { - "minus_mode" -> sr.score.plus(it.maxscore ?: 0) - "add_mode" -> it.maxscore ?: 0 - else -> sr.score.plus(it.maxscore ?: 0) - } - //濡傛灉鏈夊緱鍒嗚褰曪紝鍒欐敼鍙樼姸鎬佷负閫変腑 - for (s in subRuleScores) { - if (it.guid == s.esrguid) { - select = s.extension1 == "true" - break - } - } - }) - } - } - } - } - } - } + it.ertype ?: return@forEach + result.addDetail(result.details, it, it.ertype!! - 1, subRuleScores, false) } + result.calScore() - return resultList - + return result } } \ No newline at end of file -- Gitblit v1.9.3