package cn.com.goldenwater.dcproj.controller.zhejiang; import cn.com.goldenwater.dcproj.constValue.BisInspEnum; import cn.com.goldenwater.dcproj.dao.AttAdXBaseDao; import cn.com.goldenwater.dcproj.dao.BisInspAllObjDao; import cn.com.goldenwater.dcproj.dao.BisInspPblmDao; import cn.com.goldenwater.dcproj.dto.AttCountryDto; import cn.com.goldenwater.dcproj.dto.BisNewDcuserRelVillDto; import cn.com.goldenwater.dcproj.dto.BisNewVillRgstrDto; import cn.com.goldenwater.dcproj.dto.VillAddDto; import cn.com.goldenwater.dcproj.model.*; import cn.com.goldenwater.dcproj.param.*; import cn.com.goldenwater.dcproj.service.*; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.utils.GeoUtil; import cn.com.goldenwater.id.util.UuidUtil; 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.transaction.annotation.Transactional; 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.*; /** * @author lune * @date 2020-5-11 */ @Api(value = "BIS 2020浙江农村饮水工程登记表2管理",tags="BIS 2020浙江农村饮水工程登记表2管理") @RestController @RequestMapping("/bis/zhejiang/vill/rgstr") public class BisZhejiangVillRgstrController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisZhejiangVillRgstrService bisZhejiangVillRgstrService; @Autowired private AttAdXBaseService attAdXBaseService; @Autowired private BisInspAllObjService bisInspAllObjService; @Autowired private BisZhejiangDcuserRelVillService bisZhejiangDcuserRelVillService; @Autowired private BisZhejiangCountryFeeService bisZhejiangCountryFeeService; @Autowired private BisInspAllObjDao inspAllObjDao; @Autowired private BisInspPblmDao bisInspPblmDao; @Autowired private OlBisInspOrgService olBisInspOrgService; @Autowired private AttAdXBaseDao attAdXBaseDao; @ApiOperation(value = "添加/修改2020浙江农村饮水工程登记表2") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisNewVillRgstr", value = "bisNewVillRgstr", required = true) @RequestBody BisZhejiangVillRgstr bisNewVillRgstr) { bisNewVillRgstr.setUptm(new Date()); if (bisNewVillRgstr.getLgtd() != null && bisNewVillRgstr.getLttd() !=null) { if (bisNewVillRgstr.getLgtd().intValue() != 0 && bisNewVillRgstr.getLttd().intValue() != 0) { Map map = GeoUtil.gcj02towgs84(bisNewVillRgstr.getLgtd(), bisNewVillRgstr.getLttd()); bisNewVillRgstr.setLgtdpc(map.get("long")); bisNewVillRgstr.setLttdpc(map.get("lat")); } } if(StringUtils.isBlank(bisNewVillRgstr.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid bisNewVillRgstr.setId(uuid); bisZhejiangVillRgstrService.insert(bisNewVillRgstr); }else{ bisZhejiangVillRgstrService.update(bisNewVillRgstr); } return buildSuccessResponse(bisNewVillRgstr); } @ApiOperation(value = "根据ID删除2020浙江农村饮水工程登记表2") @RequestMapping(value = "/del/{objId}", method = RequestMethod.GET) @Transactional public BaseResponse delete(@ApiParam(name = "objId", value = "objId", required = true) @PathVariable String objId) { bisInspAllObjService.delete(objId); BisZhejiangVillRgstrParam villRgstrParam=new BisZhejiangVillRgstrParam(); villRgstrParam.setObjId(objId); BisZhejiangVillRgstr villRgstr=bisZhejiangVillRgstrService.getBy(villRgstrParam); bisZhejiangVillRgstrService.deleteBy(villRgstrParam); BisZhejiangDcuserRelVillParam newDcuserRelVillParam=new BisZhejiangDcuserRelVillParam(); newDcuserRelVillParam.setRgstrId(villRgstr.getId()); bisZhejiangDcuserRelVillService.deleteBy(newDcuserRelVillParam); BisZhejiangCountryFeeParam newCountryFeeParam=new BisZhejiangCountryFeeParam(); newCountryFeeParam.setRgstrId(villRgstr.getId()); bisZhejiangCountryFeeService.deleteBy(newCountryFeeParam); BisInspPblmParam bisInspPblmParam=new BisInspPblmParam(); bisInspPblmParam.setRegid(objId); bisInspPblmParam.setRegid(villRgstr.getId()); bisInspPblmDao.deleteBy(bisInspPblmParam); return buildSuccessResponse(); } @ApiOperation(value = "2020农村饮水批量添加督查对象") @RequestMapping(value = "/addBatch", method = RequestMethod.POST) public BaseResponse addBatch(@ApiParam(name = "villAddDtoList", value = "villAddDtoList", required = true) @RequestBody List villAddDtoList) { for(VillAddDto villAddDto:villAddDtoList) { if(StringUtils.isNotBlank(villAddDto.getObjId())){ BisInspAllObjParam inspAllObjParam=new BisInspAllObjParam(); inspAllObjParam.setId(villAddDto.getId()); inspAllObjParam.setCode(villAddDto.getAdCode()); BisInspAllObj bisInspAllObjExt=bisInspAllObjService.getBy(inspAllObjParam); if(bisInspAllObjExt !=null){ continue; } } AttAdXBase attAdXBase = attAdXBaseService.get(villAddDto.getAdCode()); BisInspAllObj bisInspAllObj=new BisInspAllObj(); bisInspAllObj.setId(villAddDto.getId()); bisInspAllObj.setNm(attAdXBase.getAdName()); bisInspAllObj.setPtype(BisInspEnum.VILLZHEJIANG.getValue()); String objId=UuidUtil.uuid(); bisInspAllObj.setObjId(objId); bisInspAllObj.setCode(villAddDto.getAdCode()); bisInspAllObj.setLttdpc(attAdXBase.getLttdpc()); bisInspAllObj.setLgtdpc(attAdXBase.getLgtdpc()); bisInspAllObj.setLgtd(attAdXBase.getLgtd()); bisInspAllObj.setLttd(attAdXBase.getLttd()); bisInspAllObjService.insert(bisInspAllObj); BisZhejiangVillRgstr bisNewVillRgstr=new BisZhejiangVillRgstr(); bisNewVillRgstr.setId(UuidUtil.uuid()); bisNewVillRgstr.setPersId(getCurrentPersId()); bisNewVillRgstr.setIsPkx(attAdXBase.getIsPoveryt()); bisNewVillRgstr.setObjId(objId); bisNewVillRgstr.setRegsNm(attAdXBase.getAdName()); bisNewVillRgstr.setState("0"); bisNewVillRgstr.setLttdpc(attAdXBase.getLttdpc()); bisNewVillRgstr.setLgtdpc(attAdXBase.getLgtdpc()); bisNewVillRgstr.setLgtd(attAdXBase.getLgtd()); bisNewVillRgstr.setLttd(attAdXBase.getLttd()); bisNewVillRgstr.setAdFullName(attAdXBase.getAdFullName()); bisNewVillRgstr.setAdCode(attAdXBase.getAdCode()); bisNewVillRgstr.setUptm(new Date()); bisNewVillRgstr.setIntm(new Date()); bisZhejiangVillRgstrService.insert(bisNewVillRgstr); } return buildSuccessResponse(villAddDtoList); } @ApiOperation(value = "根据ID获取2020农村饮水工程登记表(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisZhejiangVillRgstr bisNewVillRgstr = bisZhejiangVillRgstrService.get(id); if(bisNewVillRgstr!=null) { BisInspAllObjParam inspAllObjParam = new BisInspAllObjParam(); inspAllObjParam.setObjId(bisNewVillRgstr.getObjId()); BisInspAllObj allObj = inspAllObjDao.getBy(inspAllObjParam); String planId = allObj.getId(); bisNewVillRgstr.setPlanId(planId); } return buildSuccessResponse(bisNewVillRgstr); } @ApiOperation(value = "获取2020农村饮水工程登记表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisNewVillRgstrParam", value = "bisNewVillRgstrParam", required = true) @RequestBody BisZhejiangVillRgstrParam bisNewVillRgstrParam) { List bisNewVillRgstrList = bisZhejiangVillRgstrService.findList(bisNewVillRgstrParam); return buildSuccessResponse(bisNewVillRgstrList); } @ApiOperation(value = "获取2020农村饮水工程登记表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisNewVillRgstrParam", value = "bisNewVillRgstrParam", required = true) @RequestBody BisZhejiangVillRgstrParam bisNewVillRgstrParam) { PageInfo bisNewVillRgstrList = bisZhejiangVillRgstrService.findPageInfo(bisNewVillRgstrParam); return buildSuccessResponse(bisNewVillRgstrList); } @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()>6){ code=code.substring(0,6); } // code=code.replace("00",""); List zhenDtoList=attAdXBaseDao.findXZCZhenList(code); List countryDtoList=attAdXBaseDao.findXZCCunList(code,regstrId,BisInspEnum.VILLZHEJIANG.getValue()); 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 = "/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); } List attAdXBaseList= attAdXBaseService.findZhenList(code,regstrId,BisInspEnum.VILLZHEJIANG.getValue()); return buildSuccessResponse(attAdXBaseList); } @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) { //获取镇,乡 Map map=new HashMap<>(); if(code.length()==12 && code.endsWith("000")){ code=code.substring(0,9); } BisZhejiangCountryFeeParam countryFeeParam=new BisZhejiangCountryFeeParam(); countryFeeParam.setAdCode(code); countryFeeParam.setRgstrId(regstrId); List countryFeeList=bisZhejiangCountryFeeService.findList(countryFeeParam); map.put("countryPro",countryFeeList); return buildSuccessResponse(map); } @ApiOperation(value = "查询未被督查的县") @RequestMapping(value = "/pageNotAddRegstr", method = RequestMethod.POST) public BaseResponse> pageNotAddRegstr(@ApiParam(name = "commonParam", value = "commonParam", required = true) @RequestBody CommonParam commonParam) { String adCode=commonParam.getAdCode(); if(StringUtils.isNotBlank(adCode)) { if(adCode.length()>6) { adCode = adCode.substring(0,6); } if(adCode.length()==2){ adCode=adCode+"____000000"; } if(adCode.length()==4){ adCode=adCode+"__000000"; } commonParam.setAdCode(adCode); } commonParam.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId())); PageInfo bisNewVillRgstrList = bisZhejiangVillRgstrService.pageNotAddRegstr(commonParam); return buildSuccessResponse(bisNewVillRgstrList); } @ApiOperation(value = "问题栏目:问题列表根据当前登录用户id获取需要督查问题列表") @RequestMapping(value = "/list/{persId}", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "persId", value = "persId", required = true) @PathVariable String persId , @RequestBody(required = false) PlbmParam pblmParam) { pblmParam.setPresId(persId); pblmParam.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId())); PageInfo inspPblmList = bisZhejiangVillRgstrService.findPageList(pblmParam); return buildSuccessResponse(inspPblmList); } @ApiOperation(value = "获取登记表数据pc端") @RequestMapping(value = "/findPageByType", method = RequestMethod.POST) public BaseResponse> findPageByType(@RequestBody(required = false) TypeParam typeParam) { typeParam.setPresId(getCurrentPersId()); typeParam.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId())); PageInfo villRgstrDtoPageInfo=bisZhejiangVillRgstrService.findPageByType(typeParam); return buildSuccessResponse(villRgstrDtoPageInfo); } }