feiyu02
2022-11-15 23bd719cebe5feeff4e48fde925b0b39755eea93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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()
    }
}