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.BisInspWintRgstrMendLift; import cn.com.goldenwater.dcproj.model.BisInspWintuRgstr; import cn.com.goldenwater.dcproj.param.BisInspWintRgstrMendLiftParam; import cn.com.goldenwater.dcproj.service.BisInspWintRgstrMendLiftService; 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/mend/lift") public class BisInspWintRgstrMendLiftController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspWintRgstrMendLiftService bisInspWintRgstrMendLiftService; @Autowired private BisInspWintuRgstrDao bisInspWintuRgstrDao; @ApiOperation(value = "添加/修改取水口整改提升情况抽查表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspWintRgstrMendLift", value = "BisInspWintRgstrMendLift", required = true) @RequestBody BisInspWintRgstrMendLift bisInspWintRgstrMendLift) { String rgstrId = bisInspWintRgstrMendLift.getRgstrId(); bisInspWintRgstrMendLift.setUptm(new Date()); if(StringUtils.isBlank(bisInspWintRgstrMendLift.getId())) { BisInspWintRgstrMendLiftParam mendLiftParam = new BisInspWintRgstrMendLiftParam(); mendLiftParam.setRgstrId(rgstrId); List list = bisInspWintRgstrMendLiftService.findList(mendLiftParam); if(CollectionUtils.isNotEmpty(list)){ bisInspWintRgstrMendLift.setId(list.get(0).getId()); bisInspWintRgstrMendLiftService.update(bisInspWintRgstrMendLift); }else{ bisInspWintRgstrMendLift.setId(UuidUtil.uuid()); bisInspWintRgstrMendLift.setIntm(new Date()); bisInspWintRgstrMendLiftService.insert(bisInspWintRgstrMendLift); } }else{ bisInspWintRgstrMendLiftService.update(bisInspWintRgstrMendLift); } //修改登记表督查状态 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.setMendLiftStat(bisInspWintRgstrMendLift.getStatus()); bisInspWintuRgstr.setPersId(bisInspWintRgstrMendLift.getRecPersId()); bisInspWintuRgstrDao.update(bisInspWintuRgstr); } } return buildSuccessResponse(bisInspWintRgstrMendLift); } @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 = bisInspWintRgstrMendLiftService.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) { BisInspWintRgstrMendLift bisInspWintRgstrMendLift = bisInspWintRgstrMendLiftService.get(id); return buildSuccessResponse(bisInspWintRgstrMendLift); } @ApiOperation(value = "获取取水口整改提升情况抽查表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspWintRgstrMendLiftParam", value = "bisInspWintRgstrMendLiftParam", required = true) @RequestBody BisInspWintRgstrMendLiftParam bisInspWintRgstrMendLiftParam) { List bisInspWintRgstrMendLiftList = bisInspWintRgstrMendLiftService.findList(bisInspWintRgstrMendLiftParam); return buildSuccessResponse(bisInspWintRgstrMendLiftList); } @ApiOperation(value = "获取取水口整改提升情况抽查表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspWintRgstrMendLiftParam", value = "bisInspWintRgstrMendLiftParam", required = true) @RequestBody BisInspWintRgstrMendLiftParam bisInspWintRgstrMendLiftParam) { PageInfo bisInspWintRgstrMendLiftList = bisInspWintRgstrMendLiftService.findPageInfo(bisInspWintRgstrMendLiftParam); return buildSuccessResponse(bisInspWintRgstrMendLiftList); } @ApiOperation(value = "获取取水口整改提升情况抽查表(单表)") @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET) public BaseResponse getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId) { BisInspWintRgstrMendLiftParam bisInspWintRgstrMendLiftParam = new BisInspWintRgstrMendLiftParam(); bisInspWintRgstrMendLiftParam.setRgstrId(rgstrId); return buildSuccessResponse(bisInspWintRgstrMendLiftService.getBy(bisInspWintRgstrMendLiftParam)); } }