feiyu02
2024-09-25 0516cba27e632f20efac2752787f38f0c87baafa
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
package cn.flightfeather.supervision.domain.ds1.repository
 
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.domain.ds1.entity.Subtask
import cn.flightfeather.supervision.domain.ds1.mapper.SubtaskMapper
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.SubTaskSummary
import org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
import java.time.LocalDateTime
 
@Repository
class SubTaskRep(private val subtaskMapper: SubtaskMapper) {
 
    fun update(subtask: Subtask): Int {
        return subtaskMapper.updateByPrimaryKey(subtask)
    }
 
    fun findOne(primaryKey:String): Subtask? {
        return subtaskMapper.selectByPrimaryKey(primaryKey)
    }
 
    fun findAll(subtask: Subtask): List<Subtask?> {
        return subtaskMapper.select(subtask)
    }
 
    /**
     * 根据总任务、场景类型、问题类型,获取发现该种类问题的场景信息
     */
    fun findSubtasks(topTaskId: String, sceneTypeId:String, proType: String): List<Subtask?> {
        return subtaskMapper.findSubTasksByProType(topTaskId, sceneTypeId, proType)
    }
 
    /**
     * 查找正在执行的巡查任务
     */
    fun findByStatus(status: Constant.TaskProgress): List<Subtask?> {
        return subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
            createCriteria().andEqualTo("status", status.text)
        })
    }
 
    fun findByTime(sT: LocalDateTime, eT: LocalDateTime): List<Subtask?> {
        return subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
            createCriteria().andBetween("planstarttime", sT, eT)
        })
    }
 
    fun findByTime(year: Int, month: Int): List<Subtask?> {
        val sT = LocalDateTime.of(year, month, 1, 0, 0, 0)
        val eT = sT.plusMonths(1).minusSeconds(1)
        return findByTime(sT, eT)
    }
 
 
    // 巡查任务问题整改详情统计相关
    fun findSummary(areaVo: AreaVo): List<SubTaskSummary> {
        return subtaskMapper.getSummaryByArea(areaVo)
    }
}