riku
2022-06-09 9867f6d5c5bccfe52b878c344c536905dd6b309e
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
95
96
97
98
99
100
101
102
103
104
105
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_8: ScoreItem() {
    companion object {
        private lateinit var instance: ScoreItem_8
    }
 
    @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> {
        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())
 
        val list = problemMapper.selectByExample(Example(Problem::class.java).apply {
            createCriteria().andEqualTo("prSceneId", info.userId)
                .andGreaterThanOrEqualTo("prInspectionPeriod", s)
                .andLessThan("prInspectionPeriod", e)
        })
 
        val r5 = scoreItem5.execute(info)
 
        return if (condition1(list) || condition4(r5)) {
            Pair(3, minScore)
        }else if (condition2(r5)) {
            Pair(2, 4)
        }else if (condition3(list)) {
            Pair(1, 4)
        } else {
            Pair(0, maxScore)
        }
    }
 
    /**
     * 完全未整改 -10分
     */
    private fun condition1(list:List<Problem>): Boolean {
        list.forEach {
            if (it.prCount > 0 &&
                (it.prChangedCount ==0)
            ) {
                return true
            }
        }
        return false
    }
 
    /**
     * 收到行政处罚 -10分
     * @return true 收到行政处罚; false 未收到行政处罚
     */
    private fun condition4(r: Pair<Int, Int>): Boolean {
 
        return r.first == 2
    }
 
    /**
     * 责令改正决定书无明确整改说明的 -6分(现阶段均无说明,即收到责令改正决定书 -6分)
     * @return true 收到责令改正决定书; false 未收到责令改正决定书
     */
    private fun condition2(r: Pair<Int, Int>): Boolean {
        return r.first == 1
    }
 
    /**
     * 未按时或不完全整改 -6分
     */
    private fun condition3(list: List<Problem>): Boolean {
        list.forEach {
            if (it.prCount > 0 &&
                    (it.prChangedCount < it.prCount)) {
                return true
            }
        }
        return false
    }
}