liu
昨天 381e02b9eccbe953b31d09f2af1c2ce77c816140
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
package cn.iocoder.yudao.module.mes.controller.admin.safety;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard.*;
import cn.iocoder.yudao.module.mes.service.safety.SafetyHazardService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
/**
 * 安全生产 - 隐患上报与闭环(上报-分派-整改-复查)
 *
 * @author 超级管理员
 */
@Tag(name = "管理后台 - 安全生产-隐患闭环")
@RestController
@RequestMapping("/safety/hazard")
@Validated
public class SafetyHazardController {
 
    @Resource
    private SafetyHazardService hazardService;
 
    @PostMapping("/create")
    @Operation(summary = "隐患上报(支持移动端拍照上传的 photoUrls)")
    @PreAuthorize("@ss.hasPermission('safety:hazard:create')")
    public CommonResult<Long> create(@Valid @RequestBody SafetyHazardSaveReqVO reqVO) {
        return success(hazardService.createHazard(reqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "修改隐患基础信息")
    @PreAuthorize("@ss.hasPermission('safety:hazard:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody SafetyHazardSaveReqVO reqVO) {
        hazardService.updateHazard(reqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除隐患")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('safety:hazard:delete')")
    public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
        hazardService.deleteHazard(id);
        return success(true);
    }
 
    @GetMapping("/get")
    @Operation(summary = "获得隐患")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('safety:hazard:query')")
    public CommonResult<SafetyHazardRespVO> get(@RequestParam("id") Long id) {
        var hazard = hazardService.getHazard(id);
        hazardService.fillPersonNames(java.util.List.of(hazard));
        var resp = BeanUtils.toBean(hazard, SafetyHazardRespVO.class);
        SafetyHazardService.fillHazardDisplay(hazard, resp);
        return success(resp);
    }
 
    @GetMapping("/page")
    @Operation(summary = "获得隐患分页")
    @PreAuthorize("@ss.hasPermission('safety:hazard:query')")
    public CommonResult<PageResult<SafetyHazardRespVO>> page(@Valid SafetyHazardPageReqVO reqVO) {
        var page = hazardService.getHazardPage(reqVO);
        hazardService.fillPersonNames(page.getList());
        var result = BeanUtils.toBean(page, SafetyHazardRespVO.class);
        for (int i = 0; i < page.getList().size(); i++) {
            SafetyHazardService.fillHazardDisplay(page.getList().get(i), result.getList().get(i));
        }
        return success(result);
    }
 
    @PutMapping("/assign")
    @Operation(summary = "分派隐患整改责任人")
    @PreAuthorize("@ss.hasPermission('safety:hazard:assign')")
    public CommonResult<Boolean> assign(@Valid @RequestBody SafetyHazardAssignReqVO reqVO) {
        hazardService.assignHazard(reqVO);
        return success(true);
    }
 
    @PutMapping("/rectify")
    @Operation(summary = "提交隐患整改结果")
    @PreAuthorize("@ss.hasPermission('safety:hazard:rectify')")
    public CommonResult<Boolean> rectify(@Valid @RequestBody SafetyHazardRectifyReqVO reqVO) {
        hazardService.rectifyHazard(reqVO);
        return success(true);
    }
 
    @PutMapping("/recheck")
    @Operation(summary = "隐患复查(通过则闭环,不通过退回整改)")
    @PreAuthorize("@ss.hasPermission('safety:hazard:recheck')")
    public CommonResult<Boolean> recheck(@Valid @RequestBody SafetyHazardRecheckReqVO reqVO) {
        hazardService.recheckHazard(reqVO);
        return success(true);
    }
 
}