package cn.com.goldenwater.dcproj.controller.rdwsp; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.constValue.SplitValue; import cn.com.goldenwater.dcproj.model.AttAdXBase; import cn.com.goldenwater.dcproj.model.AttCwsBase; import cn.com.goldenwater.dcproj.model.BisBisRdwspRgstrFee; import cn.com.goldenwater.dcproj.model.BisRdwspRgstr; import cn.com.goldenwater.dcproj.param.BisBisRdwspRgstrFeeParam; import cn.com.goldenwater.dcproj.param.CwsParam; import cn.com.goldenwater.dcproj.service.AttAdXBaseService; import cn.com.goldenwater.dcproj.service.AttCwsBaseService; import cn.com.goldenwater.dcproj.service.BisBisRdwspRgstrFeeService; import cn.com.goldenwater.dcproj.service.BisRdwspRgstrService; import cn.com.goldenwater.target.CheckException; 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.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-10-9 */ @Api(value = "BIS 农村供水工程暗访情况表管理",tags="BIS 农村供水工程暗访情况表管理") @RestController @RequestMapping("/bis/bis/rdwsp/rgstr/fee") public class BisBisRdwspRgstrFeeController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisBisRdwspRgstrFeeService bisBisRdwspRgstrFeeService; @Autowired private AttAdXBaseService attAdXBaseService; @Autowired private AttCwsBaseService attCwsBaseService; @Autowired private BisRdwspRgstrService bisRdwspRgstrService; @ApiOperation(value = "添加/修改农村供水工程暗访情况表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisBisRdwspRgstrFee", value = "BisBisRdwspRgstrFee", required = true) @RequestBody BisBisRdwspRgstrFee bisBisRdwspRgstrFee) { if(StringUtils.isBlank(bisBisRdwspRgstrFee.getId())) { // 生成uuid String uuid = UuidUtil.uuid(); bisBisRdwspRgstrFee.setId(uuid); bisBisRdwspRgstrFeeService.insert(bisBisRdwspRgstrFee); }else{ bisBisRdwspRgstrFeeService.update(bisBisRdwspRgstrFee); } if (StringUtils.isNotBlank(bisBisRdwspRgstrFee.getRegstrId())) { BisRdwspRgstr rgstr = bisRdwspRgstrService.get(bisBisRdwspRgstrFee.getRegstrId()); if (!Constant.STRING_TWO.equals(rgstr.getState())) { rgstr.setUptm(new Date()); rgstr.setState(Constant.STRING_ONE); rgstr.setFeeState(bisBisRdwspRgstrFee.getStatus()); bisRdwspRgstrService.update(rgstr); } } return buildSuccessResponse(bisBisRdwspRgstrFee); } @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 = bisBisRdwspRgstrFeeService.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) { BisBisRdwspRgstrFee bisBisRdwspRgstrFee = bisBisRdwspRgstrFeeService.get(id); return buildSuccessResponse(bisBisRdwspRgstrFee); } @ApiOperation(value = "获取农村供水工程暗访情况表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisBisRdwspRgstrFeeParam", value = "bisBisRdwspRgstrFeeParam", required = true) @RequestBody BisBisRdwspRgstrFeeParam bisBisRdwspRgstrFeeParam) { List bisBisRdwspRgstrFeeList = bisBisRdwspRgstrFeeService.findList(bisBisRdwspRgstrFeeParam); return buildSuccessResponse(bisBisRdwspRgstrFeeList); } @ApiOperation(value = "获取农村供水工程暗访情况表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisBisRdwspRgstrFeeParam", value = "bisBisRdwspRgstrFeeParam", required = true) @RequestBody BisBisRdwspRgstrFeeParam bisBisRdwspRgstrFeeParam) { PageInfo bisBisRdwspRgstrFeeList = bisBisRdwspRgstrFeeService.findPageInfo(bisBisRdwspRgstrFeeParam); return buildSuccessResponse(bisBisRdwspRgstrFeeList); } @ApiOperation(value = "获取未被督查的供水工程(添加供水工程列表)") @RequestMapping(value = "/pageNotDC", method = RequestMethod.POST) public BaseResponse> pageNotDC(@ApiParam(name = "cwsParam", value = "cwsParam", required = true) @RequestBody CwsParam cwsParam) { if(StringUtils.isNotBlank(cwsParam.getAdCode())) { String adCode = cwsParam.getAdCode().substring(0, 6); cwsParam.setAdCode(adCode); } PageInfo bisNewCountryFeeList = bisBisRdwspRgstrFeeService.pageNotDC(cwsParam); return buildSuccessResponse(bisNewCountryFeeList); } @ApiOperation(value = "添加/修改农村供水工程水费收缴及水质保障情况表") @RequestMapping(value = "addBatch", method = RequestMethod.POST) public BaseResponse addBatch(@ApiParam(name = "cwsParam", value = "cwsParam", required = true) @RequestBody CwsParam cwsParam) { String cwsIds=cwsParam.getCwsIds(); if(StringUtils.isBlank(cwsIds)){ throw new CheckException("批量添加供水工程失败!!"); } String[] arrays=cwsIds.split(SplitValue.DOUHAO_SPLIT); for(String arr:arrays){ AttCwsBase attCwsBase=attCwsBaseService.get(arr); if(attCwsBase!=null){ BisBisRdwspRgstrFee newCountryFee=new BisBisRdwspRgstrFee(); newCountryFee.setId(UuidUtil.uuid()); newCountryFee.setIntm(new Date()); newCountryFee.setUptm(new Date()); newCountryFee.setStatus("1"); newCountryFee.setRegstrId(cwsParam.getRegstrId()); newCountryFee.setAdCode(cwsParam.getAdCode()); if(StringUtils.isNotBlank(cwsParam.getAdCode())){ AttAdXBase attAdXBase=attAdXBaseService.get(cwsParam.getAdCode()); if(attAdXBase!=null){ newCountryFee.setAdFullName(attAdXBase.getAdFullName()); } } newCountryFee.setPrjId(attCwsBase.getCwsCode()); newCountryFee.setPrjNm(attCwsBase.getCwsName()); newCountryFee.setPrjType(attCwsBase.getEngType()); newCountryFee.setGdX(attCwsBase.getCenterXGd()); newCountryFee.setGdY(attCwsBase.getCenterYGd()); newCountryFee.setAdName(attCwsBase.getCwsLoc()); newCountryFee.setAdFullName(attCwsBase.getCwsLoc()); newCountryFee.setCenterX(attCwsBase.getCwsLong()); newCountryFee.setCenterY(attCwsBase.getCwsLat()); bisBisRdwspRgstrFeeService.insert(newCountryFee); } } return buildSuccessResponse(); } }