package cn.com.goldenwater.dcproj.controller.wiu; import cn.com.goldenwater.dcproj.model.BisInspWiuRgstr; import cn.com.goldenwater.dcproj.model.BisInspWiuRgstrIntInfo; import cn.com.goldenwater.dcproj.param.BisInspWiuRgstrIntInfoParam; import cn.com.goldenwater.dcproj.service.BisInspWiuRgstrIntInfoService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.service.BisInspWiuRgstrService; 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-8-9 */ @Api(value = "BIS 取水口取水及监管情况检查表管理",tags="BIS 取水口取水及监管情况检查表管理") @RestController @RequestMapping("/bis/insp/wiu/rgstr/int/info") public class BisInspWiuRgstrIntInfoController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspWiuRgstrIntInfoService bisInspWiuRgstrIntInfoService; @Autowired private BisInspWiuRgstrService wiuRgstrService; @ApiOperation(value = "添加/修改取水单位取用水情况") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspWiuRgstrIntInfo", value = "BisInspWiuRgstrIntInfo", required = true) @RequestBody BisInspWiuRgstrIntInfo bisInspWiuRgstrIntInfo) { if(StringUtils.isBlank(bisInspWiuRgstrIntInfo.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspWiuRgstrIntInfo.setId(uuid); bisInspWiuRgstrIntInfoService.insert(bisInspWiuRgstrIntInfo); }else{ bisInspWiuRgstrIntInfoService.update(bisInspWiuRgstrIntInfo); } if (StringUtils.isNotBlank(bisInspWiuRgstrIntInfo.getRgstrId())) { BisInspWiuRgstr rgstr = wiuRgstrService.get(bisInspWiuRgstrIntInfo.getRgstrId()); if (rgstr != null) { rgstr.setIntInfoStat(bisInspWiuRgstrIntInfo.getDataStat()); if (!"2".equals(rgstr.getState())) { rgstr.setState("1"); } wiuRgstrService.update(rgstr); } } return buildSuccessResponse(bisInspWiuRgstrIntInfo); } @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 = bisInspWiuRgstrIntInfoService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "根据ID获取取水单位取用水情况(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspWiuRgstrIntInfo bisInspWiuRgstrIntInfo = bisInspWiuRgstrIntInfoService.get(id); return buildSuccessResponse(bisInspWiuRgstrIntInfo); } @ApiOperation(value = "获取取水单位取用水情况(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspWiuRgstrIntInfoParam", value = "bisInspWiuRgstrIntInfoParam", required = true) @RequestBody BisInspWiuRgstrIntInfoParam bisInspWiuRgstrIntInfoParam) { List bisInspWiuRgstrIntInfoList = bisInspWiuRgstrIntInfoService.findList(bisInspWiuRgstrIntInfoParam); return buildSuccessResponse(bisInspWiuRgstrIntInfoList); } @ApiOperation(value = "获取取水单位取用水情况(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspWiuRgstrIntInfoParam", value = "bisInspWiuRgstrIntInfoParam", required = true) @RequestBody BisInspWiuRgstrIntInfoParam bisInspWiuRgstrIntInfoParam) { PageInfo bisInspWiuRgstrIntInfoList = bisInspWiuRgstrIntInfoService.findPageInfo(bisInspWiuRgstrIntInfoParam); return buildSuccessResponse(bisInspWiuRgstrIntInfoList); } @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(); } BisInspWiuRgstrIntInfoParam param = new BisInspWiuRgstrIntInfoParam(); param.setRgstrId(rgstrId); BisInspWiuRgstrIntInfo info = this.bisInspWiuRgstrIntInfoService.getBy(param); return buildSuccessResponse(info); } }