道路线索应急巡查系统服务后台
feiyu02
2025-09-30 84569abda51ecf6c5549dec4cadee8d043422379
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.flightfeather.grid.service.impl
 
import com.flightfeather.grid.config.exception.BizException
import com.flightfeather.grid.constant.ConstantHttp
import com.flightfeather.grid.domain.ds1.entity.ClueTask
import com.flightfeather.grid.domain.ds1.mapper.ClueInternalMapper
import com.flightfeather.grid.domain.ds1.mapper.ClueTaskMapper
import com.flightfeather.grid.service.ClueTaskService
import com.flightfeather.grid.vo.ClueInternalTaskVo
import com.flightfeather.grid.vo.ClueTaskOptions
import com.flightfeather.grid.vo.ClueTaskSummaryVo
import com.flightfeather.grid.vo.DataHead
import com.flightfeather.grid.web.responsePack
import com.github.pagehelper.PageHelper
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import tk.mybatis.mapper.entity.Example
import java.util.*
 
/**
 *
 * @date 2025/4/18
 * @author feiyu02
 */
@Service
class ClueTaskServiceImpl(
    private val clueTaskMapper: ClueTaskMapper,
    private val clueInternalMapper: ClueInternalMapper,
) : ClueTaskService {
 
    @Transactional
    override fun createInternalClueTask(clueInternalTaskVo: ClueInternalTaskVo): Int {
        clueInternalTaskVo.clueInternal?.cReleaseTime = Date()
        clueInternalTaskVo.clueInternal?.cCreateTime = Date()
        clueInternalTaskVo.clueInternal?.cUploaded = false
        clueInternalMapper.insert(clueInternalTaskVo.clueInternal)
 
        //
        clueInternalTaskVo.clueTask?.clueId = clueInternalTaskVo.clueInternal?.cId
        if (clueInternalTaskVo.clueTask?.guid == null) {
            clueInternalTaskVo.clueTask?.guid = UUID.randomUUID().toString()
        }
        if (clueInternalTaskVo.clueTask?.hasUav == null) {
            clueInternalTaskVo.clueTask?.hasUav = false
        }
        clueInternalTaskVo.clueTask?.createTime = Date()
        clueInternalTaskVo.clueTask?.updateTime = Date()
        clueInternalTaskVo.clueTask?.internalTask = true
        clueInternalTaskVo.clueTask?.finished = false
        return clueTaskMapper.insert(clueInternalTaskVo.clueTask)
    }
 
    override fun createClueTask(clueTask: ClueTask): Int {
        if (clueTask.guid == null) {
            clueTask.guid = UUID.randomUUID().toString()
        }
        clueTask.createTime = Date()
        clueTask.updateTime = Date()
        clueTask.internalTask = false
        clueTask.finished = false
        return clueTaskMapper.insert(clueTask)
    }
 
    override fun updateClueTask(clueTask: ClueTask): Int {
        if (clueTask.guid == null) throw BizException("更新线索任务失败,缺失主键id")
        clueTask.updateTime = Date()
        clueTaskMapper.selectByPrimaryKey(clueTask.guid) ?: throw BizException("更新线索任务失败,任务不存在")
        return clueTaskMapper.updateByPrimaryKeySelective(clueTask)
    }
 
    override fun getClueTask(clueTask: ClueTask): List<ClueTask?> {
        return clueTaskMapper.select(clueTask)
    }
 
    override fun searchClueTask(options: ClueTaskOptions, page: Int?, perPage: Int?): Pair<DataHead, List<ClueTask?>> {
        val p = PageHelper.startPage<ClueTask>(
            page ?: ConstantHttp.DEFAULT_PAGE_NUM,
            perPage ?: ConstantHttp.DEFAULT_PAGE_SIZE
        )
        clueTaskMapper.selectByExample(Example(ClueTask::class.java).apply {
            createCriteria().apply {
                andEqualTo("internalTask", options.internal)
                andGreaterThanOrEqualTo("taskTime", options.startTime)
                andLessThanOrEqualTo("taskTime", options.endTime)
                andEqualTo("provinceCode", options.provinceCode)
                andEqualTo("provinceName", options.provinceName)
                andEqualTo("cityCode", options.cityCode)
                andEqualTo("cityName", options.cityName)
                andEqualTo("districtCode", options.districtCode)
                andEqualTo("districtName", options.districtName)
                andEqualTo("townCode", options.townCode)
                andEqualTo("townName", options.townName)
                andEqualTo("finished", options.finished)
            }
            orderBy(options.sortBy ?: "taskTime").apply { if (options.sort == "desc") desc() else asc() }
        })
 
        return responsePack(p)
    }
 
    override fun deleteClueTask(clueTask: ClueTask): Int {
        clueTask.guid ?: throw BizException("删除线索任务失败,缺少任务主键guid")
        return clueTaskMapper.delete(clueTask)
    }
 
    override fun getClueTaskSummary(options: ClueTaskOptions): ClueTaskSummaryVo {
        return clueTaskMapper.selectSummaryCount(options)
    }
 
    override fun finishClueTask(clueTaskId: String): Int {
        return clueTaskMapper.updateByPrimaryKeySelective(ClueTask().apply {
            guid = clueTaskId
            finished = true
        })
    }
}