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.StateEnum; import cn.com.goldenwater.dcproj.model.BisNewCountryLaw; import cn.com.goldenwater.dcproj.model.BisNewVillRgstr; import cn.com.goldenwater.dcproj.param.BisNewCountryLawParam; import cn.com.goldenwater.dcproj.param.GwComFileParam; import cn.com.goldenwater.dcproj.service.BisNewCountryLawService; import cn.com.goldenwater.dcproj.service.BisNewVillRgstrService; import cn.com.goldenwater.dcproj.service.GwComFileService; import cn.com.goldenwater.target.CheckException; 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-3-27 */ @Api(value = "BIS 农村供水工程水价相关政策制度制定情况表",tags="BIS 农村供水工程水价相关政策制度制定情况表管理") @RestController @RequestMapping("/bis/new/country/law") public class BisNewCountryLawController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisNewCountryLawService bisNewCountryLawService; @Autowired private BisNewVillRgstrService bisNewVillRgstrService; @Autowired private GwComFileService comFileService; @ApiOperation(value = "添加/修改农村供水工程水价相关政策制度制定情况表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisNewCountryLaw", value = "BisNewCountryLaw", required = true) @RequestBody BisNewCountryLaw bisNewCountryLaw) { if(StringUtils.isBlank(bisNewCountryLaw.getRegstrId())){ throw new CheckException("登记表id不能为空"); } bisNewCountryLaw.setUpdateTime(new Date()); if(StringUtils.isBlank(bisNewCountryLaw.getId())) { bisNewCountryLaw.setCreateTime(new Date()); String uuid = UuidUtil.uuid(); // 生成uuid bisNewCountryLaw.setId(uuid); bisNewCountryLawService.insert(bisNewCountryLaw); }else{ bisNewCountryLawService.update(bisNewCountryLaw); } //其他是否制定 GwComFileParam comFileParam=new GwComFileParam(); comFileParam.setBizId(bisNewCountryLaw.getId()); if("2".equals(bisNewCountryLaw.getZcOtherIsMake())){ comFileParam.setBizType("zcOtherIsMake"); comFileService.deleteBy(comFileParam); } if("2".equals(bisNewCountryLaw.getZcWaterIsMake())){ comFileParam.setBizType("zcWaterIsMake"); comFileService.deleteBy(comFileParam); } if("2".equals(bisNewCountryLaw.getZcBuzhuIsMake())){ comFileParam.setBizType("zcBuzhuIsMake"); comFileService.deleteBy(comFileParam); } BisNewVillRgstr villRgstr=new BisNewVillRgstr(); villRgstr.setId(bisNewCountryLaw.getRegstrId()); villRgstr.setIsPkx(bisNewCountryLaw.getIsPkx()); villRgstr.setIsFoOver(bisNewCountryLaw.getIsFoOver()); villRgstr.setWaterPriceIsMade(bisNewCountryLaw.getStatus()); villRgstr.setState(StateEnum.EXWASTSTATE.getKey()); bisNewVillRgstrService.update(villRgstr); return buildSuccessResponse(bisNewCountryLaw); } @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 = bisNewCountryLawService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "根据regstrId获取农村供水工程水价相关政策制度制定情况表(单表)") @RequestMapping(value = "/{regstrId}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId) { BisNewCountryLawParam countryLawParam=new BisNewCountryLawParam(); countryLawParam.setRegstrId(regstrId); BisNewCountryLaw bisNewCountryLaw = bisNewCountryLawService.getBy(countryLawParam); if(bisNewCountryLaw==null){ BisNewVillRgstr villRgstr=bisNewVillRgstrService.get(regstrId); bisNewCountryLaw=new BisNewCountryLaw(); bisNewCountryLaw.setId(UuidUtil.uuid()); bisNewCountryLaw.setCreateTime(new Date()); bisNewCountryLaw.setRegstrId(regstrId); bisNewCountryLaw.setUpdateTime(new Date()); bisNewCountryLaw.setAdCode(villRgstr.getAdCode()); bisNewCountryLaw.setPersId(getCurrentPersId()); bisNewCountryLaw.setIsPkx(villRgstr.getIsPkx()); bisNewCountryLaw.setStatus("0"); bisNewCountryLaw.setIsFoOver(villRgstr.getIsFoOver()); bisNewCountryLawService.insert(bisNewCountryLaw); }else{ GwComFileParam comFileParam=new GwComFileParam(); comFileParam.setBizId(bisNewCountryLaw.getId()); if("1".equals(bisNewCountryLaw.getZcOtherIsMake())){ comFileParam.setBizType("zcOtherIsMake"); bisNewCountryLaw.setZcOtherIsMakeFiles(comFileService.findList(comFileParam)); } if("1".equals(bisNewCountryLaw.getZcWaterIsMake())){ comFileParam.setBizType("zcWaterIsMake"); bisNewCountryLaw.setZcWaterIsMakeFiles(comFileService.findList(comFileParam)); } if("1".equals(bisNewCountryLaw.getZcBuzhuIsMake())){ comFileParam.setBizType("zcBuzhuIsMake"); bisNewCountryLaw.setZcBuzhuIsMakeFiles(comFileService.findList(comFileParam)); } } return buildSuccessResponse(bisNewCountryLaw); } @ApiOperation(value = "获取农村供水工程水价相关政策制度制定情况表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisNewCountryLawParam", value = "bisNewCountryLawParam", required = true) @RequestBody BisNewCountryLawParam bisNewCountryLawParam) { List bisNewCountryLawList = bisNewCountryLawService.findList(bisNewCountryLawParam); return buildSuccessResponse(bisNewCountryLawList); } @ApiOperation(value = "获取农村供水工程水价相关政策制度制定情况表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisNewCountryLawParam", value = "bisNewCountryLawParam", required = true) @RequestBody BisNewCountryLawParam bisNewCountryLawParam) { PageInfo bisNewCountryLawList = bisNewCountryLawService.findPageInfo(bisNewCountryLawParam); return buildSuccessResponse(bisNewCountryLawList); } }