feiyu02
2025-09-19 7cbe1610b87da19ed8a146a09b1117f92d9d3d98
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package cn.flightfeather.supervision.lightshare.web
 
import cn.flightfeather.supervision.common.log.BizLog
import cn.flightfeather.supervision.common.log.WorkStreamLogInfo
import cn.flightfeather.supervision.domain.ds1.entity.Problemlist
import cn.flightfeather.supervision.lightshare.service.ProblemlistService
import cn.flightfeather.supervision.lightshare.service.SubtaskService
import cn.flightfeather.supervision.lightshare.vo.*
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
 
@Api(tags = ["ProblemlistController"], description = "监管问题API接口")
@RestController
@RequestMapping("/problemlist")
class ProblemlistController(
    val problemlistService: ProblemlistService,
    val subtaskService: SubtaskService, private val bizLog: BizLog,
) {
    @GetMapping
    fun getAll() = problemlistService.findAll()
 
    @PutMapping
    fun add(@RequestBody problemlist: Problemlist) = problemlistService.save(problemlist)
 
    @PostMapping
    fun update(@RequestBody problemlist: Problemlist):Int{
        val res = problemlistService.update(problemlist)
        problemlist.stguid?.let {
            val subtask = subtaskService.findByID(it)
            val event = "在${subtask.scensename}新增一个问题"
            bizLog.info(WorkStreamLogInfo(subtask.executorguids, subtask.executorrealtimes, event))
        }
        return res
    }
 
    @GetMapping("/{id}")
    fun getById(@PathVariable id: String) = problemlistService.findByID(id)
 
    @DeleteMapping("/{id}")
    fun delete(@PathVariable id: String) = problemlistService.delete(id)
 
    @PostMapping("/{id}")
    fun setDeleteStatus(@PathVariable id: String) = problemlistService.setDeleteStatus(id)
 
    @PostMapping("/add")
    fun addProblem(@RequestBody problemlistVo: ProblemListVo) {
        problemlistService.addProblem(problemlistVo)
    }
 
    @PostMapping("/getbyarea")
    fun getByArea(@RequestBody areaVo: AreaVo): List<ProblemListVo> = problemlistService.getByArea(areaVo)
 
    @GetMapping("/getbytoptask")
    fun getByTopTask(@RequestParam(value = "tguid", required = true) tguid: String): List<ProblemListVo> =
        problemlistService.getByTopTask(tguid)
 
    @PostMapping("/getStatisticalResult")
    fun getStatisticalResult(@RequestBody areaVo: AreaVo): List<StatisticsVo> =
        problemlistService.getStatisticalResult(areaVo)
 
    @PostMapping("/getStatisticalResultById")
    fun getStatisticalResult(
        @RequestParam(value = "id", required = true) topTaskId: String,
        @RequestParam(value = "curSceneTypeId", required = true) sceneTypeId: String,
    ): List<StatisticsVo> = problemlistService.getStatisticalResultById(topTaskId, sceneTypeId)
 
    @PostMapping("/getChargeResult")
    fun getChargeResult(@RequestBody areaVo: AreaVo): ChargeInfoVo = problemlistService.getChargeResult(areaVo)
 
    @GetMapping("/getProblemsByScene")
    fun getProblemsByScene(
        @RequestParam(value = "sceneId", required = true) sceneId: String,
        @RequestParam date: String,
    ): List<ProblemListVo> = problemlistService.getProblemByScene(sceneId, date)
 
    @GetMapping("/month_anlysis")
    fun getMonthProblemsById(
        @RequestParam(value = "taskId", required = true) taskId: String,
        @RequestParam(value = "sceneType", required = false) sceneType: Int?,
    ): List<MonthProblemVo> = problemlistService.findMonthProblemById(taskId, sceneType)
 
    @ApiOperation(value = "对问题进行审核操作", notes = "包括问题的提交审核和整改审核两种")
    @PostMapping("/check")
    fun checkProblem(
        @ApiParam(value = "问题id主键") @RequestParam("pId") pId: String,
        @ApiParam(value = "审核操作, 0: 审核通过;1: 审核不通过;2: 整改通过;3: 整改不通过;4:问题审核撤回;5:整改审核撤回") @RequestParam("action") action: Byte,
        @ApiParam(value = "审核备注") @RequestParam("remark") remark: String,
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String,
        @ApiParam(value = "用户名") @RequestParam("userName") userName: String,
    ) = problemlistService.check(pId, action, remark, userId, userName)
 
    @ApiOperation(value = "新增一个问题", notes = "简化上传所需问题信息,将大部分操作交由后台完成")
    @PostMapping("/newProblem")
    fun newProblem(
        @ApiParam("问题信息json") @RequestParam("problemVo") problemVo: String,
        @ApiParam("问题图片") @RequestPart("images") files: Array<MultipartFile>,
    ) = problemlistService.newProblem(problemVo, files)
 
    @ApiOperation("更新一个问题")
    @PostMapping("/updateProblem")
    fun updateProblem(
        @ApiParam("问题信息json") @RequestParam("problem") problem: String,
        @ApiParam("删除的问题图片id") @RequestParam("deleteImg") deleteImg: List<String>,
        @ApiParam("问题图片") @RequestPart("images") images: Array<MultipartFile>,
    ) = resPack {
        val problemVo = ObjectMapper().readValue(problem, object : TypeReference<ProblemListVo>() {})
        problemlistService.updateProblem(problemVo, deleteImg, images)
    }
 
    @ApiOperation(value = "整改一个问题", notes = "简化上传所需问题信息,将大部分操作交由后台完成")
    @PostMapping("/changeProblem")
    fun changeProblem(
        @RequestParam("problemId") problemId: String,
        @RequestPart("images") files: Array<MultipartFile>,
    ) = problemlistService.changeProblem(problemId, files)
 
    @ApiOperation("更新一个问题整改")
    @PostMapping("/updateChange")
    fun updateChange(
        @ApiParam("问题id") @RequestParam problemId: String,
        @ApiParam("删除的整改图片id") @RequestParam("deleteImg") deleteImg: List<String>,
        @ApiParam("新增整改图片") @RequestPart("images") images: Array<MultipartFile>,
    ) = resPack { problemlistService.updateChange(problemId, deleteImg, images) }
 
    @ApiOperation(value = "通过任务查找问题")
    @GetMapping("/subtask")
    fun getBySubTask(
        @RequestParam("stGuid") stGuid: String,
        @ApiParam(value = "是否获取未审核及审核不通过的问题") @RequestParam(required = false) all:Boolean?
    ) = problemlistService.getBySubTask(stGuid, all)
 
    @ApiOperation(value = "查找发现了某种问题类型的所有巡查子任务")
    @PostMapping("/type/subtask")
    fun getSceneByProType(
        @RequestBody areaVo: AreaVo,
        @RequestParam pType: String,
    ) = resPack { problemlistService.getSceneByProType(areaVo, pType) }
 
    @ApiOperation(value = "查询某总任务下各场景的问题数量统计")
    @PostMapping("/summary/scene")
    fun getSceneProSummary(
        @RequestBody areaVo: AreaVo,
        @ApiParam(value = "页码") @RequestParam(value = "page") page: Int,
        @ApiParam(value = "单页数据量") @RequestParam(value = "per_page") perPage: Int,
    ) = resPack { problemlistService.getSceneProSummary(areaVo, page, perPage) }
}