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
package cn.flightfeather.supervision.common.score.item
 
import cn.flightfeather.supervision.common.score.ScoreItem
import cn.flightfeather.supervision.domain.entity.Punishment
import cn.flightfeather.supervision.domain.mapper.PunishmentMapper
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.LocalDateTime
import java.time.ZoneId
import java.util.*
import javax.annotation.PostConstruct
 
@Component
class ScoreItem_5: ScoreItem() {
    companion object {
        private lateinit var instance: ScoreItem_5
    }
 
    @Autowired
    lateinit var punishmentMapper: PunishmentMapper
 
    @PostConstruct
    fun init() {
        instance = this
    }
 
    override var id: String = ""
 
    override var name: String="行政处罚"
 
    override var maxScore: Int = 15
 
    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())
        LocalDateTime.now()
        val s = Date.from(startTime.toInstant())
        val e = Date.from(lastTime.toInstant())
 
        return if (condition1(s, e)) {
            Pair(2, minScore)
        } else if (condition2(s, e)) {
            Pair(1, maxScore * 2 / 3)
        } else {
            Pair(0, maxScore)
        }
    }
 
    /**
     * 本季度受到行政处罚 -15分
     */
    private fun condition1(s: Date, e: Date): Boolean {
        val p = punishmentMapper.selectByExample(Example(Punishment::class.java).apply {
            createCriteria().andEqualTo("pmSceneId", info.userId)
                .andEqualTo("pmExtension1", "0")
                .andGreaterThanOrEqualTo("pmTime", s)
                .andLessThan("pmTime", e)
        })
        return p.isNotEmpty()
    }
 
    /**
     * 本季度仅收到责令改正决定书 -5分
     */
    private fun condition2(s: Date, e: Date): Boolean {
        val p = punishmentMapper.selectByExample(Example(Punishment::class.java).apply {
            createCriteria().andEqualTo("pmSceneId", info.userId)
                .andEqualTo("pmExtension1", "1")
                .andGreaterThanOrEqualTo("pmTime", s)
                .andLessThan("pmTime", e)
        })
        return p.isNotEmpty()
    }
}