package cn.com.goldenwater.dcproj.controller.zhejiang; 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.BisZhejiangCountryFee; import cn.com.goldenwater.dcproj.model.BisZhejiangVillRgstr; import cn.com.goldenwater.dcproj.param.BisInspPblmParam; import cn.com.goldenwater.dcproj.param.BisZhejiangCountryFeeParam; 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.BisZhejiangCountryFeeService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.service.BisZhejiangVillRgstrService; 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 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 java.util.Date; import java.util.List; import java.util.Map; /** * @author lune * @date 2020-5-11 */ @Api(value = "BIS 浙江农村供水工程水费收缴及水质保障情况表管理",tags="BIS 浙江农村供水工程水费收缴及水质保障情况表管理") @RestController @RequestMapping("/bis/zhejiang/country/fee") public class BisZhejiangCountryFeeController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisZhejiangCountryFeeService bisZhejiangCountryFeeService; @Autowired private BisZhejiangVillRgstrService bisZhejiangVillRgstrService; @Autowired private AttCwsBaseService attCwsBaseService; @Autowired private AttAdXBaseService attAdXBaseService; @Autowired private BisInspPblmDao bisInspPblmDao; @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; BisZhejiangCountryFee newCountryFee=new BisZhejiangCountryFee(); newCountryFee.setId(UuidUtil.uuid()); newCountryFee.setCreateTime(new Date()); newCountryFee.setStatus("1"); newCountryFee.setRgstrId(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.setLgtdpc(attCwsBase.getCwsLong()); newCountryFee.setLttdpc(attCwsBase.getCwsLat()); newCountryFee.setPersId(getCurrentPersId()); newCountryFee.setUpdateTime(new Date()); bisZhejiangCountryFeeService.insert(newCountryFee); } } if(count !=0) { BisZhejiangVillRgstr bisNewVillRgstr = bisZhejiangVillRgstrService.get(cwsParam.getRegstrId()); int pronum = bisNewVillRgstr.getProNum() + count; bisNewVillRgstr.setProNum(pronum); bisZhejiangVillRgstrService.updateProSum(bisNewVillRgstr); } return buildSuccessResponse(); } @ApiOperation(value = "添加/修改浙江农村供水工程水费收缴及水质保障情况表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisZhejiangCountryFee", value = "BisZhejiangCountryFee", required = true) @RequestBody BisZhejiangCountryFee bisZhejiangCountryFee) { bisZhejiangCountryFee.setUpdateTime(new Date()); if(StringUtils.isBlank(bisZhejiangCountryFee.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid bisZhejiangCountryFee.setId(uuid); bisZhejiangCountryFee.setCreateTime(new Date()); bisZhejiangCountryFeeService.insert(bisZhejiangCountryFee); BisZhejiangVillRgstr bisNewVillRgstr = bisZhejiangVillRgstrService.get(bisZhejiangCountryFee.getRgstrId()); int pronum = bisNewVillRgstr.getProNum() +1; bisNewVillRgstr.setProNum(pronum); bisZhejiangVillRgstrService.updateProSum(bisNewVillRgstr); }else{ if (bisZhejiangCountryFee.getLgtd() != null && bisZhejiangCountryFee.getLttd() !=null) { if (bisZhejiangCountryFee.getLgtd().intValue() != 0 && bisZhejiangCountryFee.getLttd().intValue() != 0) { Map map = GeoUtil.gcj02towgs84(bisZhejiangCountryFee.getLgtd(), bisZhejiangCountryFee.getLttd()); bisZhejiangCountryFee.setLgtdpc(map.get("long")); bisZhejiangCountryFee.setLttdpc(map.get("lat")); } } bisZhejiangCountryFeeService.update(bisZhejiangCountryFee); } bisZhejiangCountryFeeService.updateWaterOrPay(bisZhejiangCountryFee.getRgstrId()); return buildSuccessResponse(bisZhejiangCountryFee); } @ApiOperation(value = "根据ID删除浙江农村供水工程水费收缴及水质保障情况表") @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisZhejiangCountryFee bisNewCountryFee=bisZhejiangCountryFeeService.get(id); if(bisNewCountryFee!=null){ BisInspPblmParam bisInspPblmParam=new BisInspPblmParam(); bisInspPblmParam.setCwsCode(id); bisInspPblmParam.setRegid(bisNewCountryFee.getRgstrId()); bisInspPblmDao.deleteBy(bisInspPblmParam); BisZhejiangVillRgstr bisNewVillRgstr = bisZhejiangVillRgstrService.get(bisNewCountryFee.getRgstrId()); int pronum = bisNewVillRgstr.getProNum() -1; bisNewVillRgstr.setProNum(pronum); bisZhejiangVillRgstrService.updateProSum(bisNewVillRgstr); } int ret = bisZhejiangCountryFeeService.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) { BisZhejiangCountryFee bisZhejiangCountryFee = bisZhejiangCountryFeeService.get(id); return buildSuccessResponse(bisZhejiangCountryFee); } @ApiOperation(value = "获取浙江农村供水工程水费收缴及水质保障情况表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisZhejiangCountryFeeParam", value = "bisZhejiangCountryFeeParam", required = true) @RequestBody BisZhejiangCountryFeeParam bisZhejiangCountryFeeParam) { List bisZhejiangCountryFeeList = bisZhejiangCountryFeeService.findList(bisZhejiangCountryFeeParam); return buildSuccessResponse(bisZhejiangCountryFeeList); } @ApiOperation(value = "获取浙江农村供水工程水费收缴及水质保障情况表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisZhejiangCountryFeeParam", value = "bisZhejiangCountryFeeParam", required = true) @RequestBody BisZhejiangCountryFeeParam bisZhejiangCountryFeeParam) { PageInfo bisZhejiangCountryFeeList = bisZhejiangCountryFeeService.findPageInfo(bisZhejiangCountryFeeParam); return buildSuccessResponse(bisZhejiangCountryFeeList); } @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())) { cwsParam.setAdCode(InspPblmUtils.getAddVCD(cwsParam.getAdCode())); } PageInfo bisNewCountryFeeList = bisZhejiangCountryFeeService.pageNotDC(cwsParam); return buildSuccessResponse(bisNewCountryFeeList); } }