feiyu02
2024-01-09 c1becf4cbd2e99601ce011c14b8742427249cfb4
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
package cn.flightfeather.supervision.business.autooutput.score.restaurant
 
import cn.flightfeather.supervision.business.autooutput.score.ScoreItem
import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule
import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule2
import cn.flightfeather.supervision.domain.ds2.entity.LedgerRecord
import cn.flightfeather.supervision.domain.ds2.entity.LedgerSubType
import cn.flightfeather.supervision.domain.ds2.mapper.LedgerRecordMapper
import cn.flightfeather.supervision.domain.ds2.mapper.LedgerSubTypeMapper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import tk.mybatis.mapper.entity.Example
import java.time.LocalDateTime
import java.time.ZoneId
import javax.annotation.PostConstruct
 
@Component
class ReScoreItem7: ScoreItem() {
    companion object {
        private lateinit var instance: ReScoreItem7
    }
 
    @PostConstruct
    fun init() {
        instance = this
    }
 
    init {
        exemption = true
    }
 
    @Autowired
    lateinit var ledgerRecordMapper: LedgerRecordMapper
 
    @Autowired
    lateinit var ledgerSubTypeMapper: LedgerSubTypeMapper
 
    override var id: String = "wfzFTlcZ3xMdj5M2"
 
    override var name: String = "台账管理"
 
    /**
     * 在线台账记录的提交类别完整性和及时性
     * 选项r如下:
     *      1.台账类别齐全、完整、及时记录更新
     *      2.台账少量缺失或未及时记录更新
     *      3.台账严重缺失或关键台账无效
     */
    override fun otherProblem(size: Int): List<Int>? {
        // TODO: 2021/3/9 找出用户类型对应的必填台账
        val time = evaluationScene.subTask.value?.planstarttime
        val lt = LocalDateTime.ofInstant(time?.toInstant(), ZoneId.systemDefault())
        val year = lt.year
        val st = lt.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0)
        val et = st.plusMonths(1)
 
        val ledgerTypeCount = ledgerSubTypeMapper.selectCountByExample(Example(LedgerSubType::class.java).apply {
            createCriteria().andEqualTo("lScenetype", "1").andEqualTo("lNeedupdate", true)
        })
        val rCount = ledgerRecordMapper.selectCountByExample(Example(LedgerRecord::class.java).apply {
            createCriteria().andEqualTo("lrYear", year)
                .andGreaterThanOrEqualTo("lrSubmitdate", st)
                .andLessThanOrEqualTo("lrSubmitdate", et)
                .andEqualTo("lrSubmitid", evaluationScene.userInfoTZ.value?.guid)
        })
        var i = 1
        if (condition1(ledgerTypeCount, rCount)) {
            if (i > size - 1) i = size - 1
        } else if (condition2(ledgerTypeCount, rCount)) {
            i = 2
            if (i > size - 1) i = size - 1
        }
        return listOf(i)
    }
 
    /**
     * @param c1 必填项台账类别数
     * @param c2 实际上传数
     * @return true  台账少量缺失或未及时记录更新
     */
    private fun condition1(c1: Int, c2: Int): Boolean {
        return (c2.toDouble() / c1.toDouble()) >= 0.8
    }
 
    /**
     * @param c1 必填项台账类别数
     * @param c2 实际上传数
     * @return true  台账严重缺失或关键台账无效
     */
    private fun condition2(c1: Int, c2: Int): Boolean {
        return (c2.toDouble() / c1.toDouble()) <= 0.3
    }
}