package cn.com.goldenwater.dcproj.controller.vill2020; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.constValue.BisInspEnum; import cn.com.goldenwater.dcproj.constValue.SplitValue; import cn.com.goldenwater.dcproj.dao.BisInspPblmDao; import cn.com.goldenwater.dcproj.model.AttAdXBase; import cn.com.goldenwater.dcproj.model.AttCwsBase; import cn.com.goldenwater.dcproj.model.BisNewCountryFee; import cn.com.goldenwater.dcproj.model.BisNewVillRgstr; import cn.com.goldenwater.dcproj.param.BisInspPblmParam; import cn.com.goldenwater.dcproj.param.BisNewCountryFeeParam; 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.BisNewCountryFeeService; import cn.com.goldenwater.dcproj.service.BisNewVillRgstrService; import cn.com.goldenwater.target.CheckException; import cn.com.goldenwater.dcproj.utils.GeoUtil; import cn.com.goldenwater.id.util.UuidUtil; import cn.com.goldenwater.util.common.InspPblmUtils; 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; import java.util.Map; /** * @author lune * @date 2020-3-27 */ @Api(value = "BIS 农村供水工程水费收缴及水质保障情况表管理",tags="BIS 农村供水工程水费收缴及水质保障情况表管理") @RestController @RequestMapping("/bis/new/country/fee") public class BisNewCountryFeeController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisNewCountryFeeService bisNewCountryFeeService; @Autowired private AttCwsBaseService attCwsBaseService; @Autowired private BisNewVillRgstrService bisNewVillRgstrService; @Autowired private AttAdXBaseService attAdXBaseService; @Autowired private BisInspPblmDao bisInspPblmDao; @ApiOperation(value = "添加/修改农村供水工程水费收缴及水质保障情况表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisNewCountryFee", value = "BisNewCountryFee", required = true) @RequestBody BisNewCountryFee bisNewCountryFee) { bisNewCountryFee.setUpdateTime(new Date()); if("4".equals(bisNewCountryFee.getFeeType())){ bisNewCountryFee.setIsGudingFee("1"); }else{ bisNewCountryFee.setIsJiliangFee("1"); } if(StringUtils.isBlank(bisNewCountryFee.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid bisNewCountryFee.setId(uuid); bisNewCountryFee.setCreateTime(new Date()); bisNewCountryFeeService.insert(bisNewCountryFee); BisNewVillRgstr bisNewVillRgstr = bisNewVillRgstrService.get(bisNewCountryFee.getRegstrId()); int pronum = bisNewVillRgstr.getProNum() +1; bisNewVillRgstr.setProNum(pronum); bisNewVillRgstrService.updateProSum(bisNewVillRgstr); }else{ if (bisNewCountryFee.getLgtd() != null && bisNewCountryFee.getLttd() !=null) { if (bisNewCountryFee.getLgtd().intValue() != 0 && bisNewCountryFee.getLttd().intValue() != 0) { Map map = GeoUtil.gcj02towgs84(bisNewCountryFee.getLgtd(), bisNewCountryFee.getLttd()); bisNewCountryFee.setLgtdpc(map.get("long")); bisNewCountryFee.setLttdpc(map.get("lat")); } } bisNewCountryFeeService.update(bisNewCountryFee); } bisNewVillRgstrService.updateWaterOrPay(bisNewCountryFee.getRegstrId()); return buildSuccessResponse(bisNewCountryFee); } @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); int count = 0; for(String arr:arrays){ AttCwsBase attCwsBase=attCwsBaseService.get(arr); if(attCwsBase!=null){ count=count+1; BisNewCountryFee newCountryFee=new BisNewCountryFee(); newCountryFee.setId(UuidUtil.uuid()); newCountryFee.setCreateTime(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.setCwsCode(attCwsBase.getCwsCode()); newCountryFee.setFinishTime(attCwsBase.getCompDate()); newCountryFee.setProjectNm(attCwsBase.getCwsName()); newCountryFee.setProjectType(attCwsBase.getEngType()); newCountryFee.setLgtd(attCwsBase.getCenterXGd()); newCountryFee.setLttd(attCwsBase.getCenterYGd()); newCountryFee.setLocation(attCwsBase.getCwsLoc()); newCountryFee.setLgtdpc(attCwsBase.getCwsLong()); newCountryFee.setLttdpc(attCwsBase.getCwsLat()); newCountryFee.setDesignWaterSupply(String.valueOf(attCwsBase.getDesWasuScal())); bisNewCountryFeeService.insert(newCountryFee); } } if(count !=0) { BisNewVillRgstr bisNewVillRgstr = bisNewVillRgstrService.get(cwsParam.getRegstrId()); int pronum = bisNewVillRgstr.getProNum() + count; bisNewVillRgstr.setProNum(pronum); bisNewVillRgstrService.updateProSum(bisNewVillRgstr); } return buildSuccessResponse(); } @ApiOperation(value = "根据ID删除农村供水工程水费收缴及水质保障情况表") @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisNewCountryFee bisNewCountryFee=bisNewCountryFeeService.get(id); if(bisNewCountryFee!=null){ BisInspPblmParam bisInspPblmParam=new BisInspPblmParam(); bisInspPblmParam.setCwsCode(id); bisInspPblmParam.setRegid(bisNewCountryFee.getRegstrId()); bisInspPblmDao.deleteBy(bisInspPblmParam); BisNewVillRgstr bisNewVillRgstr = bisNewVillRgstrService.get(bisNewCountryFee.getRegstrId()); int pronum = bisNewVillRgstr.getProNum() -1; bisNewVillRgstr.setProNum(pronum); bisNewVillRgstrService.updateProSum(bisNewVillRgstr); } int ret = bisNewCountryFeeService.delete(id); return buildSuccessResponse(ret); } @ApiOperation(value = "根据ID获取农村供水工程水费收缴及水质保障情况表(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisNewCountryFee bisNewCountryFee = bisNewCountryFeeService.get(id); return buildSuccessResponse(bisNewCountryFee); } @ApiOperation(value = "获取农村供水工程水费收缴及水质保障情况表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisNewCountryFeeParam", value = "bisNewCountryFeeParam", required = true) @RequestBody BisNewCountryFeeParam bisNewCountryFeeParam) { List bisNewCountryFeeList = bisNewCountryFeeService.findList(bisNewCountryFeeParam); return buildSuccessResponse(bisNewCountryFeeList); } @ApiOperation(value = "获取农村供水工程水费收缴及水质保障情况表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisNewCountryFeeParam", value = "bisNewCountryFeeParam", required = true) @RequestBody BisNewCountryFeeParam bisNewCountryFeeParam) { PageInfo bisNewCountryFeeList = bisNewCountryFeeService.findPageInfo(bisNewCountryFeeParam); return buildSuccessResponse(bisNewCountryFeeList); } @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(InspPblmUtils.getAddVCD(cwsParam.getAdCode())); } cwsParam.setType(BisInspEnum.VILL2020.getValue()); PageInfo bisNewCountryFeeList = bisNewCountryFeeService.pageNotDC(cwsParam); return buildSuccessResponse(bisNewCountryFeeList); } }