| | |
| | | import cn.flightfeather.supervision.domain.entity.Evaluationrule |
| | | import cn.flightfeather.supervision.domain.entity.Evaluationsubrule |
| | | 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( |
| | |
| | | return evaluationsubruleMapper.selectByExample(example) |
| | | } |
| | | |
| | | override fun getScore(userId: String, time: String): List<EvaluationVo> { |
| | | 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() |
| | | val sceneType = userinfo.extension2 |
| | | 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) |
| | |
| | | |
| | | 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 ruleScore = evaluationMapper.selectByExample(Example(Evaluation::class.java).apply { |
| | | createCriteria().andIn("stguid", rIdList)//规则id |
| | | .andEqualTo("evaluatorguid", userId)//用户id |
| | | .andEqualTo("scensename", time)//评估周期,例:2020/6-6 |
| | | and( |
| | | createCriteria().orEqualTo("scensename", time)//评估周期,例:2020/6-6 |
| | | .orBetween("createdate", st, et) |
| | | ) |
| | | orderBy("createdate").desc() |
| | | }) |
| | | //子规则逐条得分 |
| | | val subRuleScores = if (ruleScore.isEmpty()) { |
| | |
| | | 2 -> resultList.add(EvaluationVo().apply { |
| | | id = it.guid |
| | | title1 = it.itemname |
| | | score = it.minscore?.minus(it.maxscore ?: 0) ?: 0 |
| | | 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) { |
| | |
| | | r.sub1.add(SubEvaluationVo().apply { |
| | | id = it.guid |
| | | title2 = it.itemname |
| | | score = it.minscore?.minus(it.maxscore ?: 0) ?: 0 |
| | | 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++ |
| | | |
| | | //如果有得分记录,则改变状态为选中 |
| | |
| | | } |
| | | 4 -> { |
| | | resultList.forEach{ r -> |
| | | //4级的评估项直接附属于2级评估项 |
| | | if (r.id == it.fatherid) { |
| | | if (r.sub1.isEmpty()) { |
| | | r.sub1.add(SubEvaluationVo().apply { |
| | |
| | | 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 = r.score.plus(it.maxscore ?: 0) |
| | | 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) { |
| | |
| | | sr.sub2.add(ThirdEvaluationVo().apply { |
| | | id = it.guid |
| | | content = it.itemname |
| | | score = sr.score.plus(it.maxscore ?: 0) |
| | | 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) { |