Administrator
2023-06-19 49588f5a462ae7425e7eb030438a35fd80c246fa
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package com.gk.firework.Controller;
 
import com.gk.firework.Controller.Base.BaseController;
import com.gk.firework.Domain.SelfCheckReport;
import com.gk.firework.Domain.Utils.JsonUtils;
import com.gk.firework.Domain.Utils.Msg;
import com.gk.firework.Domain.Vo.SelfCheckReportSearchVo;
import com.gk.firework.Domain.Vo.SelfCheckReportVo;
import com.gk.firework.Service.SelfCheckReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Api(tags = "隐患自查情况报送接口")
@RequestMapping("/selfcheckreport")
@RestController
public class SelfCheckReportController extends BaseController {
 
    @Autowired
    private SelfCheckReportService selfCheckReportService;
 
    @ApiOperation(value = "创建新的报告",httpMethod="POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "yhlevel",value = "隐患等级,1-一般隐患,2-重大隐患",defaultValue = "1",required = true),
            @ApiImplicitParam(name = "status",value = "隐患状态,1-未整改,2-已整改",defaultValue = "1",required = true),
            @ApiImplicitParam(name = "price",value = "整改资金,单位(RMB元),支持小数点后2位(RMB分)",defaultValue = "0.00",required = true),
            @ApiImplicitParam(name = "chargeperson",value = "责任人名字",defaultValue = "",required = true),
            @ApiImplicitParam(name = "endtime",value = "整改期限,YY-MM-DD HH:MM:SS",required = true),
            @ApiImplicitParam(name = "yhdesc",value = "隐患描述",required = true),
            @ApiImplicitParam(name = "solution",value = "整改措施",required = true)
    })
    @PostMapping( "/new")
    public Object newReport(@RequestBody SelfCheckReportVo reportVo){
        Msg msg = new Msg();
        msg.setCode("400");
        Long companyId = getUser().getCompanyid();
        if(companyId > 0){
            reportVo.setEid(companyId);
            if(selfCheckReportService.createNewReport(reportVo) > 0){
                msg.setCode("200");
                msg.setResult(1);
            }else {
                msg.setCode("301");
                msg.setMessage("新增报送记录出错");
            }
        }else {
            msg.setCode("301");
            msg.setMessage("权限错误");
        }
        return msg;
    }
 
    @ApiOperation(value = "根据隐患ID查找报告",httpMethod="GET")
    @ApiImplicitParam(name = "id",value = "隐患ID",required = true,defaultValue = "0")
    @RequestMapping(value = "/find/one",method = RequestMethod.GET)
    public Object findById(@RequestParam(name = "id",required = true) Long id){
        Msg msg = new Msg();
        msg.setCode("400");
        SelfCheckReport report = selfCheckReportService.getSelfCheckReportById(id);
        if(report!=null){
            if(getUser().getCompanyid()==null || getUser().getCompanyid().longValue()<=0 || getUser().getCompanyid().equals(report.getEid())){
                msg.setResult(report);
                msg.setCode("200");
            }else {
                msg.setMessage("权限错误");
            }
        }else {
            msg.setMessage("未找到记录");
        }
        return msg;
    }
 
    @ApiOperation(value = "查找报告列表",httpMethod="POST",notes = "查询条件优先级别:企业ID查找 > 企业名称查找 > 省市区查找")
    @RequestMapping(value = "/find/list",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "eid",value = "企业ID",required = false),
            @ApiImplicitParam(name = "ename",value = "企业名称",required = false),
            @ApiImplicitParam(name = "status",value = "隐患状态,1-未整改,2-已整改",required = false,defaultValue = "0"),
            @ApiImplicitParam(name = "yhlevel",value = "隐患等级,1-一般隐患,2-重大隐患",required = false,defaultValue = "0"),
            @ApiImplicitParam(name = "startTime",value = "查询起始时间 YY-MM-DD HH:MM:SS",required = false),
            @ApiImplicitParam(name = "endTime",value = "查询截止时间 YY-MM-DD HH:MM:SS",required = false),
            @ApiImplicitParam(name = "province",value = "省份",required = false),
            @ApiImplicitParam(name = "city",value = "市",required = false),
            @ApiImplicitParam(name = "district",value = "区",required = false),
            @ApiImplicitParam(name = "street",value = "街道",required = false),
            @ApiImplicitParam(name = "committee",value = "居委会",required = false),
            @ApiImplicitParam(name = "page",value = "当前页码",required = true,defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize",value = "每页条目数",required = true,defaultValue = "20")
    })
    public Object findList(@RequestBody SelfCheckReportSearchVo searchVo){
        Msg msg = new Msg();
        msg.setCode("400");
        //参数校验
        if(searchVo.getStartTime() != null && searchVo.getEndTime() != null){
            if(searchVo.getStartTime().after(searchVo.getEndTime()) ){
                msg.setMessage("时间区间错误");
                return msg;
            }
        }
        if(searchVo.getStatus() == null || searchVo.getStatus() <0 || searchVo.getStatus() >2) {
            searchVo.setStatus((byte)0);
        }
        if(searchVo.getYhlevel() == null ||searchVo.getYhlevel() <0 ||searchVo.getYhlevel() >2){
            searchVo.setYhlevel((byte)0);
        }
        //企业用户登录查自己
        if(getUser().getCompanyid()!= null && getUser().getCompanyid().longValue()>0){
            searchVo.setEid(getUser().getCompanyid());
        }
        List<SelfCheckReport> list = selfCheckReportService.findSelfCheckReportListWithAllCondition(searchVo);
        if(list!=null && list.size()>0){
            msg.setCode("200");
            msg.setResult(list);
            Map<String,Object> rs = new HashMap();
            rs.put("totalCount",searchVo.getTotalCount());
            rs.put("page",searchVo.getPage());
            rs.put("pageSize",searchVo.getPageSize());
            msg.setMessage(JsonUtils.toJson(rs));
        }else {
            msg.setCode("200");
            msg.setMessage("未找到结果");
        }
        return msg;
    }
 
    @ApiOperation(value = "更新报告",httpMethod="POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "隐患ID",required = true),
            @ApiImplicitParam(name = "yhlevel",value = "隐患等级,1-一般隐患,2-重大隐患",defaultValue = "1",required = false),
            @ApiImplicitParam(name = "status",value = "隐患状态,1-未整改,2-已整改",defaultValue = "1",required = false),
            @ApiImplicitParam(name = "price",value = "整改资金,单位(RMB元),支持小数点后2位(RMB分)",defaultValue = "0.00",required = false),
            @ApiImplicitParam(name = "chargeperson",value = "责任人名字",defaultValue = "",required = false),
            @ApiImplicitParam(name = "endtime",value = "整改期限,YY-MM-DD HH:MM:SS",required = false),
            @ApiImplicitParam(name = "yhdesc",value = "隐患描述",required = false),
            @ApiImplicitParam(name = "solution",value = "整改措施",required = false)
    })
    @PostMapping("/update")
    public Object updateReport(@RequestBody SelfCheckReportVo reportVo){
        Msg msg = new Msg();
        msg.setCode("400");
        if(getUser().getCompanyid()!=null && getUser().getCompanyid().longValue() != reportVo.getEid().longValue()){
            msg.setMessage("权限错误");
            return msg;
        }
        if(reportVo.getEid().longValue()>0 && reportVo.getId().longValue() >0){
            int updateResult = selfCheckReportService.updateSelfCheckReport(reportVo);
            if(updateResult > 0){
                msg.setCode("200");
            }else {
                msg.setMessage("参数错误");
            }
        }else {
            msg.setMessage("参数缺失");
        }
        return msg;
    }
 
}