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
94
95
package cn.flightfeather.supervision.business.autooutput.score.restaurant
 
import cn.flightfeather.supervision.business.autooutput.score.ScoreItem
import cn.flightfeather.supervision.domain.ds2.entity.Punishment
import cn.flightfeather.supervision.domain.ds2.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 ReScoreItem10: ScoreItem() {
    companion object {
        private lateinit var instance: ReScoreItem10
    }
 
    @PostConstruct
    fun init() {
        instance = this
    }
 
    @Autowired
    lateinit var punishmentMapper: PunishmentMapper
 
    override var id: String = "dlALSsoF63Z2FOz0"
 
    override var name: String = "行政处罚"
 
    /**
     * 季度内行政处罚记录规格化导入
     * 选项如下:
     *      1.无责令整改、执法意见和行政处罚
     *      2.收到责令改正决定书
     *      3.收到执法意见书
     *      4.有环境违法行为且受到行政处罚
     */
    override fun otherProblem(size: Int): List<Int>? {
        val time = evaluationScene.subTask.value?.planstarttime
        val lt = LocalDateTime.ofInstant(time?.toInstant(), ZoneId.systemDefault())
        val s = lt.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0)
        val e = s.plusMonths(1)
 
        var i = 1
        when {
            condition3(s, e) -> {
                i = 3
            }
            condition2(s, e) -> {
                i = 2
            }
            condition1(s, e) -> {
                i = 1
            }
        }
        if (i > size - 1) i = size - 1
        return listOf(i)
    }
 
    /**
     * @return true  收到责令改正决定书
     */
    private fun condition1(s: LocalDateTime, e: LocalDateTime): Boolean {
        val p = punishmentMapper.selectByExample(Example(Punishment::class.java).apply {
            createCriteria().andEqualTo("pmSceneId", evaluationScene.userInfoTZ.value?.guid)
                .andEqualTo("pmExtension1", "1")
                .andGreaterThanOrEqualTo("pmTime", s)
                .andLessThan("pmTime", e)
        })
        return p.isNotEmpty()
    }
 
    /**
     * @return true  收到执法意见书
     */
    private fun condition2(s: LocalDateTime, e: LocalDateTime): Boolean {
        return false
    }
 
    /**
     * @return true  有环境违法行为且受到行政处罚
     */
    private fun condition3(s: LocalDateTime, e: LocalDateTime): Boolean {
        val p = punishmentMapper.selectByExample(Example(Punishment::class.java).apply {
            createCriteria().andEqualTo("pmSceneId", evaluationScene.userInfoTZ.value?.guid)
                .andEqualTo("pmExtension1", "0")
                .andGreaterThanOrEqualTo("pmTime", s)
                .andLessThan("pmTime", e)
        })
        return p.isNotEmpty()
    }
}