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
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_7: ScoreItem() {
    companion object {
        private lateinit var instance: ScoreItem_7
    }
 
    @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> {
        if (condition1()) {
            return Pair(3, minScore)
        }
 
        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())
 
        var pCount = 0
        problemMapper.selectByExample(Example(Problem::class.java).apply {
            createCriteria().andEqualTo("prSceneId", info.userId)
                    .andGreaterThanOrEqualTo("prInspectionPeriod", s)
                    .andLessThan("prInspectionPeriod", e)
        }).forEach {
            pCount += it.prCount
        }
        return when {
            condition2(pCount) -> {
                Pair(2, minScore)
            }
            condition3(pCount) -> {
                Pair(1, maxScore / 2)
            }
            else -> {
                Pair(0, maxScore)
            }
        }
    }
 
    /**
     * 本季度仅收到责令改正决定书或行政处罚 -10分
     */
    private fun condition1(): Boolean {
        val r5 = scoreItem5.execute(info)
        return r5.first != 0
    }
 
    /**
     * 环保主管部门或委托的第三方发现2个或以上问题 -10分
     */
    private fun condition2(pCount: Int): Boolean {
        return pCount >= 2
    }
 
    /**
     * 环保主管部门或委托的第三方发现1个问题 -5分
     */
    private fun condition3(pCount: Int): Boolean {
        return pCount == 1
    }
}