道路线索应急巡查系统服务后台
feiyu02
2025-04-25 79bd8ea222cc3518ec91dce3dfb30fcf387cf96d
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
package com.flightfeather.grid.web
 
import com.flightfeather.grid.domain.ds1.entity.Clue
import com.flightfeather.grid.domain.ds1.entity.ClueInternal
import com.flightfeather.grid.service.ClueService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.web.bind.annotation.*
import java.net.URLEncoder
import javax.servlet.http.HttpServletResponse
 
@Api(tags = ["ClueController"], description = "下发线索API接口")
@RestController
@RequestMapping("/clue")
class ClueController(val clueService: ClueService) {
 
    @ApiOperation("获取下发线索")
    @GetMapping("/fetch")
    fun getClue(
        @ApiParam("起始时间") @RequestParam(required = false) sTime: String?,
        @ApiParam("结束时间") @RequestParam(required = false) eTime: String?,
        @ApiParam("页码") @RequestParam(required = false) pageNum: Int?,
        @ApiParam("单页数据量") @RequestParam(required = false) pageSize: Int?,
    ) = resPack { clueService.getClue(sTime, eTime, pageNum, pageSize) }
 
    @ApiOperation("查询下发线索")
    @PostMapping("/search")
    fun searchClue(
        @ApiParam("查询条件") @RequestBody clue: Clue,
    ) = resPack { clueService.searchClue(clue) }
 
    @ApiOperation("从远程数据源拉取下发线索")
    @GetMapping("/fetch/remote")
    fun fetchRemoteClue(
        @ApiParam("下发时间") @RequestParam updateTime: String,
    ) = resPack { clueService.fetchRemoteClue(updateTime) }
 
    @ApiOperation("从远程数据源获取线索文件")
    @GetMapping("/fetch/remote/file")
    fun fetchRemoteClueFile(@ApiParam("线索id") @RequestParam clueId: String, response: HttpServletResponse) {
        val res = clueService.getClueFile(clueId)
        val fileName = URLEncoder.encode(res.first, "utf-8")
        response.apply {
            setHeader("Content-Disposition", "attachment;filename=${fileName}")
            setHeader("fileName", fileName)
            addHeader("Access-Control-Expose-Headers", "fileName")
            contentType = "application/pdf;charset=UTF-8"
            setHeader("Pragma", "no-cache")
            setHeader("Cache-Control", "no-cache")
            setDateHeader("Expires", 0)
        }
        res.second.m.entity.writeTo(response.outputStream)
    }
 
    @ApiOperation("推送线索至第三方")
    @PostMapping("/push")
    fun pushClue(
        @ApiParam("线索id") @RequestParam clueId: String,
    ) = resPack { clueService.pushClue(clueId) }
}