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_4: ScoreItem() {
|
companion object {
|
private lateinit var instance: ScoreItem_4
|
}
|
|
@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 = 10
|
|
override fun calScore(): Pair<Int, Int> {
|
val result = mutableListOf<Int>()
|
val originSMonth = sMonth
|
|
// FIXME: 2021/4/26 手动调整起始月份,同时将起始月份之前的月份默认为“台账全部完整提交”
|
// sMonth = 3
|
// repeat(sMonth - originSMonth) { result.add(0)}
|
|
//必填台账
|
val required = mutableListOf<LedgerSubType>()
|
// TODO: 2021/3/9 找出用户类型对应的必填台账
|
val ledgerTypes = ledgerSubTypeMapper.selectByExample(Example(LedgerSubType::class.java).apply {
|
createCriteria().andEqualTo("lScenetype", info.sceneType.value)
|
}).onEach { l ->
|
if (l.getlNeedupdate())
|
required.add(l)
|
}
|
|
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 比对
|
when {
|
// 台账必填项全无
|
condition1(required, ledgers) -> {
|
result.add(2)
|
}
|
// 必填项台账部分缺失
|
condition2(ledgerTypes, ledgers) -> {
|
result.add(1)
|
}
|
// 台账提交完整
|
else -> {
|
result.add(0)
|
}
|
}
|
}
|
|
return when (result.sum()) {
|
0 -> Pair(0, maxScore)
|
2 * result.size -> Pair(2, minScore)
|
else -> Pair(1, maxScore / 2)
|
}
|
|
// return Pair(2, minScore)
|
// return Pair(1, maxScore / 2)
|
// //台账提交完整
|
// return Pair(0, maxScore)
|
}
|
|
/**
|
* 季度内存在任何一月台账必填项全无 -10分
|
* @return true 必填项台账全部缺失; false 必填项台账部分缺失或完整
|
*/
|
private fun condition1(ledgerTypes: List<LedgerSubType>, ledgers: List<Int>): Boolean {
|
for (l in ledgerTypes) {
|
if (ledgers.contains(l.lsSubtypeid)) {
|
return false
|
}
|
}
|
return true
|
}
|
|
/**
|
* 季度内存在任何一月未完整提交台账(必填项不完整) -5分
|
* @return true 必填项台账部分缺失; false 必填项台账完整
|
*/
|
private fun condition2(ledgerTypes: List<LedgerSubType>, ledgers: List<Int>): Boolean {
|
for (l in ledgerTypes) {
|
if (!ledgers.contains(l.lsSubtypeid)) {
|
return true
|
}
|
}
|
return false
|
}
|
}
|