package cn.com.goldenwater.dcproj.controller.svwt; import cn.com.goldenwater.dcproj.model.BisInspSvwtAreaRgstr; import cn.com.goldenwater.dcproj.model.BisInspSvwtAreaRgstrWse; import cn.com.goldenwater.dcproj.param.BisInspSvwtAreaRgstrWseParam; import cn.com.goldenwater.dcproj.service.BisInspSvwtAreaRgstrService; import cn.com.goldenwater.dcproj.service.BisInspSvwtAreaRgstrWseService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.id.util.UuidUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.List; /** * @author lune * @date 2019-9-17 */ @Api(value = "BIS 节水评价情况检查表管理",tags="BIS 节水评价情况检查表管理") @RestController @RequestMapping("/bis/insp/svwt/area/rgstr/wse") public class BisInspSvwtAreaRgstrWseController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspSvwtAreaRgstrWseService bisInspSvwtAreaRgstrWseService; @Autowired private BisInspSvwtAreaRgstrService svwtAreaRgstrService; @ApiOperation(value = "添加/修改节水评价情况检查表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspSvwtAreaRgstrWse", value = "BisInspSvwtAreaRgstrWse", required = true) @RequestBody BisInspSvwtAreaRgstrWse bisInspSvwtAreaRgstrWse) { if(StringUtils.isBlank(bisInspSvwtAreaRgstrWse.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspSvwtAreaRgstrWse.setId(uuid); BisInspSvwtAreaRgstrWseParam param = new BisInspSvwtAreaRgstrWseParam(); param.setRgstrId(bisInspSvwtAreaRgstrWse.getRgstrId()); List list = bisInspSvwtAreaRgstrWseService.findList(param); if (list.size() > 0) { buildFailResponse(10010,"已存在此督查对象的检查清空"); } bisInspSvwtAreaRgstrWseService.insert(bisInspSvwtAreaRgstrWse); }else{ bisInspSvwtAreaRgstrWseService.update(bisInspSvwtAreaRgstrWse); } if (StringUtils.isNotBlank(bisInspSvwtAreaRgstrWse.getRgstrId())) { BisInspSvwtAreaRgstr rgstr = svwtAreaRgstrService.get(bisInspSvwtAreaRgstrWse.getRgstrId()); if (rgstr != null) { rgstr.setWseInfoStat2(bisInspSvwtAreaRgstrWse.getDataStat()); if (!"2".equals(rgstr.getState())) { rgstr.setState("1"); } svwtAreaRgstrService.update(rgstr); } } return buildSuccessResponse(bisInspSvwtAreaRgstrWse); } @ApiOperation(value = "根据ID删除节水评价情况检查表") @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = bisInspSvwtAreaRgstrWseService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "根据登记表id获获取取水许可审批监管情况") @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET) public BaseResponse getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId,HttpServletRequest request) { if(StringUtils.isBlank(rgstrId)) { return buildFailResponse(); } BisInspSvwtAreaRgstrWseParam param = new BisInspSvwtAreaRgstrWseParam(); param.setRgstrId(rgstrId); BisInspSvwtAreaRgstrWse info = this.bisInspSvwtAreaRgstrWseService.getBy(param); return buildSuccessResponse(info); } @ApiOperation(value = "根据ID获取节水评价情况检查表(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspSvwtAreaRgstrWse bisInspSvwtAreaRgstrWse = bisInspSvwtAreaRgstrWseService.get(id); return buildSuccessResponse(bisInspSvwtAreaRgstrWse); } @ApiOperation(value = "获取节水评价情况检查表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspSvwtAreaRgstrWseParam", value = "bisInspSvwtAreaRgstrWseParam", required = true) @RequestBody BisInspSvwtAreaRgstrWseParam bisInspSvwtAreaRgstrWseParam) { List bisInspSvwtAreaRgstrWseList = bisInspSvwtAreaRgstrWseService.findList(bisInspSvwtAreaRgstrWseParam); return buildSuccessResponse(bisInspSvwtAreaRgstrWseList); } @ApiOperation(value = "获取节水评价情况检查表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspSvwtAreaRgstrWseParam", value = "bisInspSvwtAreaRgstrWseParam", required = true) @RequestBody BisInspSvwtAreaRgstrWseParam bisInspSvwtAreaRgstrWseParam) { PageInfo bisInspSvwtAreaRgstrWseList = bisInspSvwtAreaRgstrWseService.findPageInfo(bisInspSvwtAreaRgstrWseParam); return buildSuccessResponse(bisInspSvwtAreaRgstrWseList); } }