From 196bb14112448857a885e32dc4149e308e00b01a Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 15 八月 2024 11:57:15 +0800 Subject: [PATCH] 2024.8.15 各项修正 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/EvaluationsubruleServiceImpl.kt | 201 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 199 insertions(+), 2 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 65bf182..7abce00 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,13 +1,29 @@ package cn.flightfeather.supervision.lightshare.service.Impl +import cn.flightfeather.supervision.domain.entity.Evaluation +import cn.flightfeather.supervision.domain.entity.Evaluationrule import cn.flightfeather.supervision.domain.entity.Evaluationsubrule -import cn.flightfeather.supervision.domain.mapper.EvaluationsubruleMapper +import cn.flightfeather.supervision.domain.entity.Itemevaluation +import cn.flightfeather.supervision.domain.enumeration.AssessmentRuleType +import cn.flightfeather.supervision.domain.enumeration.SceneType +import cn.flightfeather.supervision.domain.mapper.* +import cn.flightfeather.supervision.infrastructure.utils.DateUtil 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 org.springframework.stereotype.Service import tk.mybatis.mapper.entity.Example +import java.time.LocalDateTime @Service -class EvaluationsubruleServiceImpl (val evaluationsubruleMapper: EvaluationsubruleMapper):EvaluationsubruleService { +class EvaluationsubruleServiceImpl( + val evaluationsubruleMapper: EvaluationsubruleMapper, + private val userinfoMapper: UserinfoMapper, + private val evaluationruleMapper: EvaluationruleMapper, + private val evaluationMapper: EvaluationMapper, + private val itemevaluationMapper: ItemevaluationMapper +):EvaluationsubruleService { override fun findOne(id: String): Evaluationsubrule = evaluationsubruleMapper.selectByPrimaryKey(id) @@ -25,4 +41,185 @@ criteria.andEqualTo("erguid", erguid) return evaluationsubruleMapper.selectByExample(example) } + + override fun getScore(userId: String, time: String, platform:String?): List<EvaluationVo> { + val list = time.split("-") + var endM = list[1].toInt() + val list2 = list[0].split("/") + val year = list2[0].toInt() + var startM = list2[1].toInt() + var st = LocalDateTime.of(year, startM, 1, 0, 0, 0, 0) + var et = LocalDateTime.of(year, endM, 1, 0, 0, 0, 0).plusMonths(1) + + val userinfo = userinfoMapper.selectByPrimaryKey(userId) ?: return emptyList() + var sceneType = userinfo.extension2 + // FIXME: 2022/11/8 涓存椂娣诲姞杩囧害鍔熻兘锛屾彁渚涘井淇″皬绋嬪簭鍓嶇姹戒慨绫诲瀷鐨勫満鏅崟鐙殑璇勪及娓呭崟 锛屽満鏅被鍨嬩负 -7 + if (platform == "weixin" && sceneType == SceneType.VehicleRepair.value.toString()) { + sceneType = "-7" + } + //璇勫垎鎬昏鍒� + val rules = evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply { + createCriteria().andEqualTo("scensetypeid", sceneType) +// .andEqualTo("ruletype", "1") + .andIsNull("tasktypeid") + }) + if (rules.isEmpty()) return emptyList() + + val rIdList = mutableListOf<String?>() + rules.forEach { + // 鎵惧埌鎬昏鍒� + if (it.ruletype == AssessmentRuleType.Total.value.toString()) { + val rulePeriod = it.scensesubtypeid?.toInt() ?: 1 + DateUtil.getStartMonthByPeriod(startM, rulePeriod)?.let {s -> + startM = s + endM = startM + rulePeriod - 1 + st = LocalDateTime.of(year, startM, 1, 0, 0, 0, 0) + et = LocalDateTime.of(year, endM, 1, 0, 0, 0, 0).plusMonths(1) + } + } + rIdList.add(it.guid) + } + + //鎬昏鍒欏搴旂殑璇勫垎瀛愯鍒� + val subRules = mutableListOf<Evaluationsubrule>() + val sr = evaluationsubruleMapper.selectByExample(Example(Evaluationsubrule::class.java).apply { + createCriteria().andIn("erguid", rIdList) + orderBy("ertype") + orderBy("displayid") + }) + subRules.addAll(sr) + + //鎬昏鍒欑殑寰楀垎 + val ruleScore = evaluationMapper.selectByExample(Example(Evaluation::class.java).apply { + createCriteria().andIn("stguid", rIdList)//瑙勫垯id + .andEqualTo("evaluatorguid", userId)//鐢ㄦ埛id + and( + createCriteria().orEqualTo("scensename", time)//璇勪及鍛ㄦ湡锛屼緥锛�2020/6-6 + .orBetween("createdate", st, et) + ) + orderBy("createdate").desc() + }) + //瀛愯鍒欓�愭潯寰楀垎 + val subRuleScores = if (ruleScore.isEmpty()) { + mutableListOf<Itemevaluation>() + } else { + val scoreIds = mutableListOf<String?>() + ruleScore.forEach { scoreIds.add(it.guid) } + itemevaluationMapper.selectByExample(Example(Itemevaluation::class.java).apply { + createCriteria().andIn("sguid", scoreIds) + }) + } + + val resultList = mutableListOf<EvaluationVo>() + + var _group = 0 + subRules.forEach { + when (it.ertype) { + 2 -> resultList.add(EvaluationVo().apply { + id = it.guid + title1 = it.itemname + scoreMode = it.extension1 + gradeMode = it.extension2 + 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 + } + 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.sub1.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.sub1.isEmpty()) { + r.sub1.add(SubEvaluationVo().apply { + placeholder = true + id = it.guid + title2 = r.title1 + score = r.score + gradeMode = r.gradeMode + selectMode = r.selectMode + group = _group++ + }) + } + r.sub1[0].sub2.add(ThirdEvaluationVo().apply { + id = it.guid + content = it.itemname + score = when (r.sub1[0].gradeMode) { + "minus_mode" -> r.score.plus(it.maxscore ?: 0) + "add_mode" -> it.maxscore ?: 0 + else -> r.score.plus(it.maxscore ?: 0) + } + //濡傛灉鏈夊緱鍒嗚褰曪紝鍒欐敼鍙樼姸鎬佷负閫変腑 + for (s in subRuleScores) { + if (it.guid == s.esrguid) { + select = s.extension1 == "true" + break + } + } + }) + } else { + r.sub1.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 + } + } + }) + } + } + } + } + } + } + } + + return resultList + } } \ No newline at end of file -- Gitblit v1.9.3