package cn.com.goldenwater.dcproj.controller.wintu; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.dao.BisInspWintuRgstrDao; import cn.com.goldenwater.dcproj.model.BisInspWintRgstrChkIn; import cn.com.goldenwater.dcproj.model.BisInspWintuRgstr; import cn.com.goldenwater.dcproj.param.BisInspWintRgstrChkInParam; import cn.com.goldenwater.dcproj.service.BisInspWintRgstrChkInService; import cn.com.goldenwater.dcproj.utils.Constant; import cn.com.goldenwater.id.util.UuidUtil; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Date; import java.util.List; /** * @author lune * @date 2020-7-15 */ @Api(value = "BIS 取水口核查登记情况抽查表管理",tags="BIS 取水口核查登记情况抽查表管理") @RestController @RequestMapping("/bis/insp/wint/rgstr/chk/in") public class BisInspWintRgstrChkInController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspWintRgstrChkInService bisInspWintRgstrChkInService; @Autowired private BisInspWintuRgstrDao bisInspWintuRgstrDao; @ApiOperation(value = "添加/修改取水口核查登记情况抽查表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspWintRgstrChkIn", value = "BisInspWintRgstrChkIn", required = true) @RequestBody BisInspWintRgstrChkIn bisInspWintRgstrChkIn) { String rgstrId = bisInspWintRgstrChkIn.getRgstrId(); bisInspWintRgstrChkIn.setUptm(new Date()); if(StringUtils.isBlank(bisInspWintRgstrChkIn.getId())) { BisInspWintRgstrChkInParam chkInParam = new BisInspWintRgstrChkInParam(); chkInParam.setRgstrId(rgstrId); List bisInspWintRgstrChkInList = bisInspWintRgstrChkInService.findList(chkInParam); if(CollectionUtils.isNotEmpty(bisInspWintRgstrChkInList)){ bisInspWintRgstrChkIn.setId(bisInspWintRgstrChkInList.get(0).getId()); bisInspWintRgstrChkInService.update(bisInspWintRgstrChkIn); }else { bisInspWintRgstrChkIn.setId(UuidUtil.uuid()); bisInspWintRgstrChkIn.setIntm(new Date()); bisInspWintRgstrChkInService.insert(bisInspWintRgstrChkIn); } }else{ bisInspWintRgstrChkInService.update(bisInspWintRgstrChkIn); } //修改登记表督查状态 if(StringUtils.isNotBlank(rgstrId)) { BisInspWintuRgstr bisInspWintuRgstr = bisInspWintuRgstrDao.get(rgstrId); if (!Constant.STRING_TWO.equals(bisInspWintuRgstr.getState())) { bisInspWintuRgstr.setUpTm(new Date()); bisInspWintuRgstr.setState(Constant.STRING_ONE); bisInspWintuRgstr.setChkInStat(bisInspWintRgstrChkIn.getStatus()); bisInspWintuRgstr.setPersId(bisInspWintRgstrChkIn.getRecPersId()); bisInspWintuRgstrDao.update(bisInspWintuRgstr); } } return buildSuccessResponse(bisInspWintRgstrChkIn); } @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 = bisInspWintRgstrChkInService.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) { BisInspWintRgstrChkIn bisInspWintRgstrChkIn = bisInspWintRgstrChkInService.get(id); return buildSuccessResponse(bisInspWintRgstrChkIn); } @ApiOperation(value = "获取取水口核查登记情况抽查表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspWintRgstrChkInParam", value = "bisInspWintRgstrChkInParam", required = true) @RequestBody BisInspWintRgstrChkInParam bisInspWintRgstrChkInParam) { List bisInspWintRgstrChkInList = bisInspWintRgstrChkInService.findList(bisInspWintRgstrChkInParam); return buildSuccessResponse(bisInspWintRgstrChkInList); } @ApiOperation(value = "获取取水口核查登记情况抽查表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspWintRgstrChkInParam", value = "bisInspWintRgstrChkInParam", required = true) @RequestBody BisInspWintRgstrChkInParam bisInspWintRgstrChkInParam) { PageInfo bisInspWintRgstrChkInList = bisInspWintRgstrChkInService.findPageInfo(bisInspWintRgstrChkInParam); return buildSuccessResponse(bisInspWintRgstrChkInList); } @ApiOperation(value = "获取取水口核查登记情况抽查表(单标)") @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET) public BaseResponse getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId) { BisInspWintRgstrChkInParam bisInspWintRgstrChkInParam = new BisInspWintRgstrChkInParam(); bisInspWintRgstrChkInParam.setRgstrId(rgstrId); return buildSuccessResponse(bisInspWintRgstrChkInService.getBy(bisInspWintRgstrChkInParam)); } }