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.model.BisInspMfdpRgstr; import cn.com.goldenwater.dcproj.model.BisInspMfdpRgstrObj; import cn.com.goldenwater.dcproj.param.BisInspMfdpRgstrObjParam; import cn.com.goldenwater.dcproj.service.BisInspMfdpRgstrObjService; import cn.com.goldenwater.dcproj.service.BisInspMfdpRgstrService; 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.ArrayList; import java.util.List; /** * @author lune * @date 2020-4-26 */ @Api(value = "BIS 山洪灾害防御督查对象表管理",tags="BIS 山洪灾害防御督查对象表管理") @RestController @RequestMapping("/bis/insp/mfdp/rgstr/obj") public class BisInspMfdpRgstrObjController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspMfdpRgstrObjService bisInspMfdpRgstrObjService; @Autowired private BisInspMfdpRgstrService bisInspMfdpRgstrService; @ApiOperation(value = "添加/修改山洪灾害防御督查对象表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspMfdpRgstrObj", value = "BisInspMfdpRgstrObj", required = true) @RequestBody BisInspMfdpRgstrObj bisInspMfdpRgstrObj) { if(StringUtils.isBlank(bisInspMfdpRgstrObj.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspMfdpRgstrObj.setId(uuid); bisInspMfdpRgstrObjService.insert(bisInspMfdpRgstrObj); }else{ bisInspMfdpRgstrObjService.update(bisInspMfdpRgstrObj); } if (StringUtils.isNotBlank(bisInspMfdpRgstrObj.getRgstrId()) && StringUtils.isNotBlank(bisInspMfdpRgstrObj.getInspObjType())) { BisInspMfdpRgstr rgstr = bisInspMfdpRgstrService.get(bisInspMfdpRgstrObj.getRgstrId()); switch (bisInspMfdpRgstrObj.getInspObjType()) { case "1": rgstr.setSitroMsNum(rgstr.getSitroMsNum() + 1); break; case "2": rgstr.setSitroRxNum(rgstr.getSitroRxNum() + 1); break; case "3": rgstr.setSitroTownNum(rgstr.getSitroTownNum() + 1); break; case "4": rgstr.setSitroVlgNum(rgstr.getSitroVlgNum() + 1); break; } bisInspMfdpRgstrService.update(rgstr); } return buildSuccessResponse(bisInspMfdpRgstrObj); } @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 = bisInspMfdpRgstrObjService.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) { BisInspMfdpRgstrObj bisInspMfdpRgstrObj = bisInspMfdpRgstrObjService.get(id); return buildSuccessResponse(bisInspMfdpRgstrObj); } @ApiOperation(value = "获取山洪灾害防御督查对象表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspMfdpRgstrObjParam", value = "bisInspMfdpRgstrObjParam", required = true) @RequestBody BisInspMfdpRgstrObjParam bisInspMfdpRgstrObjParam) { List bisInspMfdpRgstrObjList = bisInspMfdpRgstrObjService.findList(bisInspMfdpRgstrObjParam); return buildSuccessResponse(bisInspMfdpRgstrObjList); } @ApiOperation(value = "根据测站类型获取山洪灾害防御督查对象表(列表所有)") @RequestMapping(value = "/list/type", method = RequestMethod.POST) public BaseResponse> listType(@ApiParam(name = "bisInspMfdpRgstrObjParam", value = "bisInspMfdpRgstrObjParam", required = true) @RequestBody BisInspMfdpRgstrObjParam bisInspMfdpRgstrObjParam) { List bisInspMfdpRgstrObjList = new ArrayList<>(); BisInspMfdpRgstrObjParam param = new BisInspMfdpRgstrObjParam(); param.setRgstrId(bisInspMfdpRgstrObjParam.getRgstrId()); param.setInspObjName(bisInspMfdpRgstrObjParam.getInspObjName()); if (bisInspMfdpRgstrObjParam.getInspObjType().contains("县级及")){ bisInspMfdpRgstrObjList.addAll(bisInspMfdpRgstrObjService.findList(param)); }else if (bisInspMfdpRgstrObjParam.getInspObjType().contains("站点")) { param.setInspObjType("1"); bisInspMfdpRgstrObjList.addAll(bisInspMfdpRgstrObjService.findList(param)); } else if ("乡、村级".equals(bisInspMfdpRgstrObjParam.getInspObjType())) { param.setInspObjType("3"); bisInspMfdpRgstrObjList.addAll(bisInspMfdpRgstrObjService.findList(param)); param.setInspObjType("4"); bisInspMfdpRgstrObjList.addAll(bisInspMfdpRgstrObjService.findList(param)); } else if (bisInspMfdpRgstrObjParam.getInspObjType().contains("接收端")) { param.setInspObjType("2"); bisInspMfdpRgstrObjList.addAll(bisInspMfdpRgstrObjService.findList(param)); } else if (bisInspMfdpRgstrObjParam.getInspObjType().contains("乡")) { param.setInspObjType("3"); bisInspMfdpRgstrObjList.addAll(bisInspMfdpRgstrObjService.findList(param)); } else if (bisInspMfdpRgstrObjParam.getInspObjType().contains("村")) { param.setInspObjType("4"); bisInspMfdpRgstrObjList.addAll(bisInspMfdpRgstrObjService.findList(param)); } return buildSuccessResponse(bisInspMfdpRgstrObjList); } @ApiOperation(value = "获取山洪灾害防御督查对象表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspMfdpRgstrObjParam", value = "bisInspMfdpRgstrObjParam", required = true) @RequestBody BisInspMfdpRgstrObjParam bisInspMfdpRgstrObjParam) { PageInfo bisInspMfdpRgstrObjList = bisInspMfdpRgstrObjService.findPageInfo(bisInspMfdpRgstrObjParam); return buildSuccessResponse(bisInspMfdpRgstrObjList); } }