package cn.flightfeather.supervision.common.score.item
|
|
import cn.flightfeather.supervision.common.score.ScoreItem
|
import cn.flightfeather.supervision.domain.entity.LedgerRecord
|
import cn.flightfeather.supervision.domain.entity.LedgerSubType
|
import cn.flightfeather.supervision.domain.mapper.LedgerRecordMapper
|
import cn.flightfeather.supervision.domain.mapper.LedgerSubTypeMapper
|
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.stereotype.Component
|
import tk.mybatis.mapper.entity.Example
|
import javax.annotation.PostConstruct
|
|
@Component
|
class ScoreItem_3: ScoreItem() {
|
companion object {
|
private lateinit var instance: ScoreItem_3
|
}
|
|
@PostConstruct
|
fun init() {
|
instance = this
|
}
|
|
@Autowired
|
lateinit var ledgerRecordMapper: LedgerRecordMapper
|
|
@Autowired
|
lateinit var ledgerSubTypeMapper: LedgerSubTypeMapper
|
|
override var id: String = ""
|
|
override var name: String="台账及时性"
|
|
override var maxScore: Int = 5
|
|
override fun calScore(): Pair<Int, Int> {
|
return check()
|
}
|
|
private fun check(): Pair<Int, Int> {
|
// sMonth = 3
|
return when {
|
condition1() -> {
|
Pair(2, minScore)
|
}
|
condition2() -> {
|
Pair(1, minScore)
|
}
|
else -> {
|
Pair(0, maxScore)
|
}
|
}
|
}
|
|
/**
|
* 季度内存在任何一月必填项不完整 -5分
|
*/
|
private fun condition1(): Boolean {
|
// TODO: 2021/3/9 找出用户类型对应的必填台账
|
val ledgerTypes = ledgerSubTypeMapper.selectByExample(Example(LedgerSubType::class.java).apply {
|
createCriteria().andEqualTo("lScenetype", info.sceneType.value).andEqualTo("lNeedupdate", true)
|
})
|
for (i in sMonth..eMonth) {
|
// TODO: 2021/3/9 找出当月用户提交的台账
|
val ledgers = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
|
createCriteria().andEqualTo("lrYear", info.year).andEqualTo("lrMonth", i)
|
.andEqualTo("lrSubmitid", info.userId)
|
}).map {
|
it.lsSubtypeid
|
}
|
// TODO: 2021/3/9 比对
|
for (l in ledgerTypes) {
|
if (!ledgers.contains(l.lsSubtypeid)) {
|
return true
|
}
|
}
|
}
|
return false
|
}
|
|
/**
|
* 季度内存在任何一月未及时提交台账 -5分
|
*/
|
private fun condition2(): Boolean {
|
val r = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
|
createCriteria().andEqualTo("lrYear", info.year)
|
.andGreaterThanOrEqualTo("lrMonth", sMonth)
|
.andLessThanOrEqualTo("lrMonth", eMonth)
|
.andEqualTo("lrSubmitid", info.userId)
|
.andEqualTo("lrIssubmitontime", false)
|
})
|
return r.isNotEmpty()
|
}
|
}
|