feiyu02
2022-11-15 909fd8929d7906f1dca68acc05e36e29b0b9192c
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
package cn.flightfeather.supervision.business.storage.item
 
import cn.flightfeather.supervision.business.ScoreItem
import cn.flightfeather.supervision.domain.ds1.entity.DustDataResult
import cn.flightfeather.supervision.domain.ds1.mapper.DustDataResultMapper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import tk.mybatis.mapper.entity.Example
import java.time.LocalDateTime
import java.time.ZoneId
import javax.annotation.PostConstruct
 
/**
 * Date 2022/1/20 16:14
 * Created by feiyu
 * 工地
 */
@Component
class CsScoreItem_2:ScoreItem() {
 
    companion object {
        private lateinit var instance: CsScoreItem_2
    }
 
    @PostConstruct
    fun init() {
        instance = this
    }
 
    override var id: String = "dCQbQ8ibc6nexiJo"
 
    override var name: String = "扬尘在线监测数据量级"
 
    @Autowired
    lateinit var dustDataResultMapper: DustDataResultMapper
 
    /**
     * 扬尘在线监测数据量级
     * 选项如下:
     *      1.监测数据出现单日及以上有效超标
     *      2.监测数据月均值超区域月均值20%以上或数据明显异常
     */
    override fun otherProblem(size: Int): Int? {
        val time = info.subTask?.planstarttime
        val lt = LocalDateTime.ofInstant(time?.toInstant(), ZoneId.systemDefault())
        val st = lt.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0)
        val et = st.plusMonths(1)
        val r = dustDataResultMapper.selectByExample(Example(DustDataResult::class.java).apply {
            createCriteria().andGreaterThanOrEqualTo("drTime", st)
                .andLessThan("drTime", et)
                .andEqualTo("drSceneId", info.sceneId)
        })
 
        var result: Int? = null
        r.forEach {
            if (it.drExceedTimes > 0) {
                result = 0
            }
            if (it.drOverAvgPer > 0) {
                result = 1
            }
        }
 
        return result
    }
}