| | |
| | | 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.mapper.* |
| | | 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 |
| | | |
| | | @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) |
| | | |
| | |
| | | criteria.andEqualTo("erguid", erguid) |
| | | return evaluationsubruleMapper.selectByExample(example) |
| | | } |
| | | |
| | | override fun getScore(userId: String, time: String): List<EvaluationVo> { |
| | | val userinfo = userinfoMapper.selectByPrimaryKey(userId) ?: return emptyList() |
| | | val sceneType = userinfo.extension2 |
| | | //评分总规则 |
| | | 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 { |
| | | 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 |
| | | .andEqualTo("scensename", time)//评估周期,例:2020/6-6 |
| | | }) |
| | | //子规则逐条得分 |
| | | 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 |
| | | score = it.minscore?.minus(it.maxscore ?: 0) ?: 0 |
| | | |
| | | //如果有得分记录,则改变状态为选中 |
| | | 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 |
| | | score = 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 -> |
| | | 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 |
| | | group = _group++ |
| | | }) |
| | | } |
| | | r.sub1[0].sub2.add(ThirdEvaluationVo().apply { |
| | | id = it.guid |
| | | content = it.itemname |
| | | score = 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 = sr.score.plus(it.maxscore ?: 0) |
| | | //如果有得分记录,则改变状态为选中 |
| | | for (s in subRuleScores) { |
| | | if (it.guid == s.esrguid) { |
| | | select = s.extension1 == "true" |
| | | break |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return resultList |
| | | } |
| | | } |