package cn.com.goldenwater.dcproj.controller.villqh; 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.dto.AttCountryDto; import cn.com.goldenwater.dcproj.dto.BisNewDcuserRelVillDto; import cn.com.goldenwater.dcproj.model.BisInspVillqhRgstr; import cn.com.goldenwater.dcproj.param.TypeParam; import cn.com.goldenwater.dcproj.service.AttAdXBaseService; import cn.com.goldenwater.dcproj.service.BisInspVillqhRgstrService; import cn.com.goldenwater.dcproj.service.OlBisInspOrgService; import cn.com.goldenwater.dcproj.utils.AdLevelUtil; import cn.com.goldenwater.target.CheckException; 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.List; /** * @author lhc * @date 2021-2-1 */ @Api(value = "农饮(青海)-登记表管理", tags = "农饮(青海)-登记表管理") @RestController @RequestMapping("/bis/insp/villqh") public class BisInspVillqhRgstrController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspVillqhRgstrService bisInspVillqhRgstrService; @Autowired private AttAdXBaseService attAdXBaseService; @Autowired private OlBisInspOrgService olBisInspOrgService; @ApiOperation(value = "修改农饮(青海)-登记表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspVillqhRgstr", value = "BisInspVillqhRgstr", required = true) @RequestBody BisInspVillqhRgstr bisInspVillqhRgstr) { if (StringUtils.isNotBlank(bisInspVillqhRgstr.getRgstrId()) && StringUtils.isBlank(bisInspVillqhRgstr.getId())) { // rgstrId 不为 空 时,传给ID bisInspVillqhRgstr.setId(bisInspVillqhRgstr.getRgstrId()); } if (StringUtils.isNotBlank(bisInspVillqhRgstr.getId())) { bisInspVillqhRgstrService.update(bisInspVillqhRgstr); return buildSuccessResponse(bisInspVillqhRgstr); } throw new CheckException("缺少登记表编码"); } @ApiOperation(value = "根据ID删除农饮(青海)-登记表") @RequestMapping(value = "delete/{id}", method = RequestMethod.POST) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = bisInspVillqhRgstrService.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) { BisInspVillqhRgstr bisInspVillqhRgstr = bisInspVillqhRgstrService.get(id); return buildSuccessResponse(bisInspVillqhRgstr); } @ApiOperation(value = "列表--分页") @RequestMapping(value = "/findPage", method = RequestMethod.POST) public BaseResponse page(@ApiParam(name = "typeParam", value = "typeParam", required = true) @RequestBody TypeParam typeParam) { typeParam.setpType(BisInspEnum.VILLQH.getValue()); typeParam.setPresId(getCurrentPersId()); if (StringUtils.isBlank(typeParam.getAdCode())) { typeParam.setAdCodes(AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(getCurrentOrgId()))); } return buildSuccessResponse(bisInspVillqhRgstrService.findObjPageByType(typeParam, null)); } @ApiOperation(value = "获取县-镇(乡)--村用水户和饮水工程列表") @RequestMapping(value = "/findNode/{code}/{regstrId}", method = RequestMethod.GET) public BaseResponse findNode( @ApiParam(name = "code", value = "code", required = true) @PathVariable String code, @ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId) { return buildSuccessResponse(bisInspVillqhRgstrService.findNode(code, regstrId)); } @ApiOperation(value = "获取督查中县-镇(乡)--村树节点") @RequestMapping(value = "/findTree/{code}/{regstrId}", method = RequestMethod.GET) public BaseResponse> findTree( @ApiParam(name = "code", value = "code", required = true) @PathVariable String code, @ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId) { //获取镇,乡 if (code.length() == 12) { code = code.substring(0, 6); } return buildSuccessResponse(attAdXBaseService.findZhenList(code, regstrId, BisInspEnum.VILLQH.getValue())); } @ApiOperation(value = "添加行政村县下镇(乡)--村树节点,code为县code") @RequestMapping(value = "/findCheckTree/{code}/{regstrId}", method = RequestMethod.GET) public BaseResponse> findCheckTree( @ApiParam(name = "code", value = "code", required = true) @PathVariable String code, @ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId ) { if (code.length() == 12) { code = code.substring(0, 6); } return buildSuccessResponse(bisInspVillqhRgstrService.findCheckTree(code, regstrId)); } }