package cn.com.goldenwater.dcproj.controller.svwt; import cn.com.goldenwater.dcproj.model.BisInspSvwtAreaRgstr; import cn.com.goldenwater.dcproj.model.BisInspSvwtAreaRgstrWswm; import cn.com.goldenwater.dcproj.param.BisInspSvwtAreaRgstrWswmParam; import cn.com.goldenwater.dcproj.service.BisInspSvwtAreaRgstrService; import cn.com.goldenwater.dcproj.service.BisInspSvwtAreaRgstrWswmService; 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.Date; import java.util.List; /** * @author lune * @date 2019-9-17 */ @Api(value = "BIS 节约用水管理情况检查表管理",tags="BIS 节约用水管理情况检查表管理") @RestController @RequestMapping("/bis/insp/svwt/area/rgstr/wswm") public class BisInspSvwtAreaRgstrWswmController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspSvwtAreaRgstrWswmService bisInspSvwtAreaRgstrWswmService; @Autowired private BisInspSvwtAreaRgstrService svwtAreaRgstrService; @ApiOperation(value = "添加/修改节约用水管理情况检查表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspSvwtAreaRgstrWswm", value = "BisInspSvwtAreaRgstrWswm", required = true) @RequestBody BisInspSvwtAreaRgstrWswm bisInspSvwtAreaRgstrWswm) { if(StringUtils.isBlank(bisInspSvwtAreaRgstrWswm.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspSvwtAreaRgstrWswm.setId(uuid); BisInspSvwtAreaRgstrWswmParam param = new BisInspSvwtAreaRgstrWswmParam(); param.setRgstrId(bisInspSvwtAreaRgstrWswm.getRgstrId()); List list = bisInspSvwtAreaRgstrWswmService.findList(param); if (list.size() > 0) { buildFailResponse(10010,"已存在此督查对象的检查清空"); } bisInspSvwtAreaRgstrWswm.setInTm(new Date()); bisInspSvwtAreaRgstrWswm.setUpTm(new Date()); bisInspSvwtAreaRgstrWswmService.insert(bisInspSvwtAreaRgstrWswm); }else{ bisInspSvwtAreaRgstrWswm.setUpTm(new Date()); bisInspSvwtAreaRgstrWswmService.update(bisInspSvwtAreaRgstrWswm); } if (StringUtils.isNotBlank(bisInspSvwtAreaRgstrWswm.getRgstrId())) { BisInspSvwtAreaRgstr rgstr = svwtAreaRgstrService.get(bisInspSvwtAreaRgstrWswm.getRgstrId()); if (rgstr != null) { rgstr.setWswmInfoStat(bisInspSvwtAreaRgstrWswm.getDataStat()); if (!"2".equals(rgstr.getState())) { rgstr.setState("1"); } svwtAreaRgstrService.update(rgstr); } } return buildSuccessResponse(bisInspSvwtAreaRgstrWswm); } @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 = bisInspSvwtAreaRgstrWswmService.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(); } BisInspSvwtAreaRgstrWswmParam param = new BisInspSvwtAreaRgstrWswmParam(); param.setRgstrId(rgstrId); BisInspSvwtAreaRgstrWswm info = this.bisInspSvwtAreaRgstrWswmService.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) { BisInspSvwtAreaRgstrWswm bisInspSvwtAreaRgstrWswm = bisInspSvwtAreaRgstrWswmService.get(id); return buildSuccessResponse(bisInspSvwtAreaRgstrWswm); } @ApiOperation(value = "获取节约用水管理情况检查表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspSvwtAreaRgstrWswmParam", value = "bisInspSvwtAreaRgstrWswmParam", required = true) @RequestBody BisInspSvwtAreaRgstrWswmParam bisInspSvwtAreaRgstrWswmParam) { List bisInspSvwtAreaRgstrWswmList = bisInspSvwtAreaRgstrWswmService.findList(bisInspSvwtAreaRgstrWswmParam); return buildSuccessResponse(bisInspSvwtAreaRgstrWswmList); } @ApiOperation(value = "获取节约用水管理情况检查表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspSvwtAreaRgstrWswmParam", value = "bisInspSvwtAreaRgstrWswmParam", required = true) @RequestBody BisInspSvwtAreaRgstrWswmParam bisInspSvwtAreaRgstrWswmParam) { PageInfo bisInspSvwtAreaRgstrWswmList = bisInspSvwtAreaRgstrWswmService.findPageInfo(bisInspSvwtAreaRgstrWswmParam); return buildSuccessResponse(bisInspSvwtAreaRgstrWswmList); } }