riku
2022-06-17 3a5c011d9509d3bc0367921f463676c81ff2e374
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
package cn.flightfeather.supervision.business.fume.item
 
import cn.flightfeather.supervision.business.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.ZoneId
import java.util.*
import javax.annotation.PostConstruct
 
@Component
class ScoreItem_10: ScoreItem() {
    companion object {
        private lateinit var instance: ScoreItem_10
    }
 
    @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): Int? {
        val s = Date.from(info.sTime.atZone(ZoneId.systemDefault()).toInstant())
        val e = Date.from(info.eTime.atZone(ZoneId.systemDefault()).toInstant())
 
        var i = 1
        when {
            condition3(s, e) -> {
                i = 3
                if (i > size - 1) i = size - 1
                return i
            }
            condition2(s, e) -> {
                i = 2
                if (i > size - 1) i = size - 1
                return i
            }
            condition1(s, e) -> {
                i = 1
                if (i > size - 1) i = size - 1
                return i
            }
            else -> return null
        }
    }
 
    /**
     * @return true  收到责令改正决定书
     */
    private fun condition1(s: Date, e: Date): Boolean {
        val p = punishmentMapper.selectByExample(Example(Punishment::class.java).apply {
            createCriteria().andEqualTo("pmSceneId", info.tzUserId)
                .andEqualTo("pmExtension1", "1")
                .andGreaterThanOrEqualTo("pmTime", s)
                .andLessThan("pmTime", e)
        })
        return p.isNotEmpty()
    }
 
    /**
     * @return true  收到执法意见书
     */
    private fun condition2(s: Date, e: Date): Boolean {
        return false
    }
 
    /**
     * @return true  有环境违法行为且受到行政处罚
     */
    private fun condition3(s: Date, e: Date): Boolean {
        val p = punishmentMapper.selectByExample(Example(Punishment::class.java).apply {
            createCriteria().andEqualTo("pmSceneId", info.tzUserId)
                .andEqualTo("pmExtension1", "0")
                .andGreaterThanOrEqualTo("pmTime", s)
                .andLessThan("pmTime", e)
        })
        return p.isNotEmpty()
    }
}