package cn.com.goldenwater.dcproj.controller.mfdp; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.constValue.CommonLabel; import cn.com.goldenwater.dcproj.dao.AttAdXBaseDao; import cn.com.goldenwater.dcproj.dto.AttCountryDto; import cn.com.goldenwater.dcproj.dto.BisInspRgstrDto; import cn.com.goldenwater.dcproj.model.AttAdXBase; import cn.com.goldenwater.dcproj.model.BisInspMfdpRgstr; import cn.com.goldenwater.dcproj.model.BisInspOrg; import cn.com.goldenwater.dcproj.param.BisInspMfdpRgstrParam; import cn.com.goldenwater.dcproj.param.TypeParam; import cn.com.goldenwater.dcproj.service.BisInspMfdpRgstrService; 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.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 javax.servlet.http.HttpServletResponse; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * @author lune * @date 2020-4-26 */ @Api(value = "BIS 山洪灾害防御督查登记表管理",tags="BIS 山洪灾害防御督查登记表管理") @RestController @RequestMapping("/bis/insp/mfdp/rgstr") public class BisInspMfdpRgstrController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspMfdpRgstrService bisInspMfdpRgstrService; @Autowired private AttAdXBaseDao attAdXBaseDao; @Autowired private OlBisInspOrgService olBisInspOrgService; @ApiOperation(value = "添加/修改山洪灾害防御督查登记表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspMfdpRgstr", value = "BisInspMfdpRgstr", required = true) @RequestBody BisInspMfdpRgstr bisInspMfdpRgstr) { if(StringUtils.isBlank(bisInspMfdpRgstr.getId())) { throw new CheckException("缺少登记表编码!"); } bisInspMfdpRgstrService.update(bisInspMfdpRgstr); return buildSuccessResponse(bisInspMfdpRgstr); } @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 = bisInspMfdpRgstrService.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) { BisInspMfdpRgstr bisInspMfdpRgstr = bisInspMfdpRgstrService.get(id); AttAdXBase adXBase = attAdXBaseDao.getByCode(bisInspMfdpRgstr.getAdCode()); if (bisInspMfdpRgstr != null && adXBase != null) { bisInspMfdpRgstr.setLgtd(String.valueOf(adXBase.getLgtd())); bisInspMfdpRgstr.setLttd(String.valueOf(adXBase.getLttd())); bisInspMfdpRgstr.setGdX(String.valueOf(adXBase.getLgtdpc())); bisInspMfdpRgstr.setGdY(String.valueOf(adXBase.getLttdpc())); bisInspMfdpRgstr.setLocation(adXBase.getAdFullName()); } return buildSuccessResponse(bisInspMfdpRgstr); } @ApiOperation(value = "获取山洪灾害防御督查登记表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspMfdpRgstrParam", value = "bisInspMfdpRgstrParam", required = true) @RequestBody BisInspMfdpRgstrParam bisInspMfdpRgstrParam) { List bisInspMfdpRgstrList = bisInspMfdpRgstrService.findList(bisInspMfdpRgstrParam); return buildSuccessResponse(bisInspMfdpRgstrList); } @ApiOperation(value = "获取山洪灾害防御督查登记表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspMfdpRgstrParam", value = "bisInspMfdpRgstrParam", required = true) @RequestBody BisInspMfdpRgstrParam bisInspMfdpRgstrParam) { PageInfo bisInspMfdpRgstrList = bisInspMfdpRgstrService.findPageInfo(bisInspMfdpRgstrParam); return buildSuccessResponse(bisInspMfdpRgstrList); } @ApiOperation(value = "获取督查对象") @RequestMapping(value = "/findMfdpPage", method = RequestMethod.POST) public BaseResponse> findMfdpPage(@RequestBody TypeParam param, HttpServletResponse response){ BisInspOrg defaultOrg = olBisInspOrgService.getDefaultOrg(getCurrentOrgId()); param.setProvince(AdLevelUtil.getAddvcd(defaultOrg.getRlcode())); param.setAdCode(AdLevelUtil.getAddvcd(defaultOrg.getAdCode())); if(StringUtils.isBlank(param.getTabType())){ param.setTabType(CommonLabel.TAB_TYPE); } String nowTime=new SimpleDateFormat("yyyy-MM-dd").format(new Date()); param.setNowTime(nowTime); PageInfo pageInfo = bisInspMfdpRgstrService.findMfdpPage(param, response); return buildSuccessResponse(pageInfo); } @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 ){ code=code.replace("00",""); List zhenDtoList=attAdXBaseDao.findXZCZhenList(code); List countryDtoList=attAdXBaseDao.findXZCCunMfdpList(code,regstrId); for(AttCountryDto attCountryDto:zhenDtoList){ String adCode=attCountryDto.getAdCode().replace("000",""); List childList=new ArrayList<>(); for(AttCountryDto countryDto:countryDtoList){ if(countryDto.getAdCode().startsWith(adCode)){ childList.add(countryDto); } } attCountryDto.setAttCountryDtoList(childList); } return buildSuccessResponse(zhenDtoList); } @ApiOperation(value = "添加镇") @RequestMapping(value = "/findCountry/{code}/{regstrId}", method = RequestMethod.GET) public BaseResponse> findCountry( @ApiParam(name = "code", value = "code", required = true) @PathVariable String code, @ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId ){ code=code.replace("00",""); List zhenDtoList=attAdXBaseDao.findXZCZhenMfdpList(code,regstrId); return buildSuccessResponse(zhenDtoList); } @ApiOperation(value = "添加村") @RequestMapping(value = "/findVillage/{code}/{regstrId}", method = RequestMethod.GET) public BaseResponse> findVillage( @ApiParam(name = "code", value = "code", required = true) @PathVariable String code, @ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId ){ code=code.substring(0,9); List zhenDtoList=attAdXBaseDao.findXZCCunMfdpList(code,regstrId); return buildSuccessResponse(zhenDtoList); } }