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;
|
}
|
|
}
|