package cn.flightfeather.supervision.common.score.item
|
|
import cn.flightfeather.supervision.common.score.ScoreItem
|
import cn.flightfeather.supervision.domain.entity.Punishment
|
import cn.flightfeather.supervision.domain.mapper.PunishmentMapper
|
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.LocalDateTime
|
import java.time.ZoneId
|
import java.util.*
|
import javax.annotation.PostConstruct
|
|
@Component
|
class ScoreItem_5: ScoreItem() {
|
companion object {
|
private lateinit var instance: ScoreItem_5
|
}
|
|
@Autowired
|
lateinit var punishmentMapper: PunishmentMapper
|
|
@PostConstruct
|
fun init() {
|
instance = this
|
}
|
|
override var id: String = ""
|
|
override var name: String="行政处罚"
|
|
override var maxScore: Int = 15
|
|
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).plusMonths(1).atStartOfDay(ZoneId.systemDefault())
|
LocalDateTime.now()
|
val s = Date.from(startTime.toInstant())
|
val e = Date.from(lastTime.toInstant())
|
|
return if (condition1(s, e)) {
|
Pair(2, minScore)
|
} else if (condition2(s, e)) {
|
Pair(1, maxScore * 2 / 3)
|
} else {
|
Pair(0, maxScore)
|
}
|
}
|
|
/**
|
* 本季度受到行政处罚 -15分
|
*/
|
private fun condition1(s: Date, e: Date): Boolean {
|
val p = punishmentMapper.selectByExample(Example(Punishment::class.java).apply {
|
createCriteria().andEqualTo("pmSceneId", info.userId)
|
.andEqualTo("pmExtension1", "0")
|
.andGreaterThanOrEqualTo("pmTime", s)
|
.andLessThan("pmTime", e)
|
})
|
return p.isNotEmpty()
|
}
|
|
/**
|
* 本季度仅收到责令改正决定书 -5分
|
*/
|
private fun condition2(s: Date, e: Date): Boolean {
|
val p = punishmentMapper.selectByExample(Example(Punishment::class.java).apply {
|
createCriteria().andEqualTo("pmSceneId", info.userId)
|
.andEqualTo("pmExtension1", "1")
|
.andGreaterThanOrEqualTo("pmTime", s)
|
.andLessThan("pmTime", e)
|
})
|
return p.isNotEmpty()
|
}
|
}
|