package cn.flightfeather.supervision.common.score.item
|
|
import cn.flightfeather.supervision.common.score.ScoreItem
|
import cn.flightfeather.supervision.domain.entity.Problem
|
import cn.flightfeather.supervision.domain.mapper.ProblemMapper
|
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.stereotype.Component
|
import tk.mybatis.mapper.entity.Example
|
import java.time.LocalDate
|
import java.time.ZoneId
|
import java.util.*
|
import javax.annotation.PostConstruct
|
|
@Component
|
class ScoreItem_8: ScoreItem() {
|
companion object {
|
private lateinit var instance: ScoreItem_8
|
}
|
|
@PostConstruct
|
fun init() {
|
instance = this
|
}
|
|
@Autowired
|
lateinit var problemMapper: ProblemMapper
|
|
@Autowired
|
lateinit var scoreItem5: ScoreItem_5
|
|
override var id: String = ""
|
|
override var name: String="问题整改"
|
|
override var maxScore: Int = 10
|
|
override fun calScore(): Pair<Int, Int> {
|
val startTime = LocalDate.of(info.year, sMonth, 1).atStartOfDay(ZoneId.systemDefault())
|
val lastTime = LocalDate.of(info.year, eMonth + 1, 1).atStartOfDay(ZoneId.systemDefault())
|
val s = Date.from(startTime.toInstant())
|
val e = Date.from(lastTime.toInstant())
|
|
val list = problemMapper.selectByExample(Example(Problem::class.java).apply {
|
createCriteria().andEqualTo("prSceneId", info.userId)
|
.andGreaterThanOrEqualTo("prInspectionPeriod", s)
|
.andLessThan("prInspectionPeriod", e)
|
})
|
|
val r5 = scoreItem5.execute(info)
|
|
return if (condition1(list) || condition4(r5)) {
|
Pair(3, minScore)
|
}else if (condition2(r5)) {
|
Pair(2, 4)
|
}else if (condition3(list)) {
|
Pair(1, 4)
|
} else {
|
Pair(0, maxScore)
|
}
|
}
|
|
/**
|
* 完全未整改 -10分
|
*/
|
private fun condition1(list:List<Problem>): Boolean {
|
list.forEach {
|
if (it.prCount > 0 &&
|
(it.prChangedCount ==0)
|
) {
|
return true
|
}
|
}
|
return false
|
}
|
|
/**
|
* 收到行政处罚 -10分
|
* @return true 收到行政处罚; false 未收到行政处罚
|
*/
|
private fun condition4(r: Pair<Int, Int>): Boolean {
|
|
return r.first == 2
|
}
|
|
/**
|
* 责令改正决定书无明确整改说明的 -6分(现阶段均无说明,即收到责令改正决定书 -6分)
|
* @return true 收到责令改正决定书; false 未收到责令改正决定书
|
*/
|
private fun condition2(r: Pair<Int, Int>): Boolean {
|
return r.first == 1
|
}
|
|
/**
|
* 未按时或不完全整改 -6分
|
*/
|
private fun condition3(list: List<Problem>): Boolean {
|
list.forEach {
|
if (it.prCount > 0 &&
|
(it.prChangedCount < it.prCount)) {
|
return true
|
}
|
}
|
return false
|
}
|
}
|