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_7: ScoreItem() {
|
companion object {
|
private lateinit var instance: ScoreItem_7
|
}
|
|
@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> {
|
if (condition1()) {
|
return Pair(3, minScore)
|
}
|
|
val startTime = LocalDate.of(info.year, sMonth, 1).atStartOfDay(ZoneId.systemDefault())
|
val lastTime = LocalDate.of(info.year, eMonth, 1).plusMonths(1).atStartOfDay(ZoneId.systemDefault())
|
val s = Date.from(startTime.toInstant())
|
val e = Date.from(lastTime.toInstant())
|
|
var pCount = 0
|
problemMapper.selectByExample(Example(Problem::class.java).apply {
|
createCriteria().andEqualTo("prSceneId", info.userId)
|
.andGreaterThanOrEqualTo("prInspectionPeriod", s)
|
.andLessThan("prInspectionPeriod", e)
|
}).forEach {
|
pCount += it.prCount
|
}
|
return when {
|
condition2(pCount) -> {
|
Pair(2, minScore)
|
}
|
condition3(pCount) -> {
|
Pair(1, maxScore / 2)
|
}
|
else -> {
|
Pair(0, maxScore)
|
}
|
}
|
}
|
|
/**
|
* 本季度仅收到责令改正决定书或行政处罚 -10分
|
*/
|
private fun condition1(): Boolean {
|
val r5 = scoreItem5.execute(info)
|
return r5.first != 0
|
}
|
|
/**
|
* 环保主管部门或委托的第三方发现2个或以上问题 -10分
|
*/
|
private fun condition2(pCount: Int): Boolean {
|
return pCount >= 2
|
}
|
|
/**
|
* 环保主管部门或委托的第三方发现1个问题 -5分
|
*/
|
private fun condition3(pCount: Int): Boolean {
|
return pCount == 1
|
}
|
}
|