| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- package cn.com.goldenwater.dcproj.controller.rsfco;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.model.BisInspRsfcoRgstr;
- import cn.com.goldenwater.dcproj.model.BisInspRsfcoRgstrBase;
- import cn.com.goldenwater.dcproj.param.BisInspRsfcoRgstrBaseParam;
- import cn.com.goldenwater.dcproj.service.BisInspRsfcoRgstrBaseService;
- import cn.com.goldenwater.dcproj.service.BisInspRsfcoRgstrService;
- 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 javax.servlet.http.HttpServletRequest;
- import java.util.Date;
- import java.util.List;
- /**
- * @author lune
- * @date 2020-4-22
- */
- @Api(value = "BIS 水库防洪调度总体情况管理",tags="BIS 水库防洪调度总体情况管理")
- @RestController
- @RequestMapping("/bis/insp/rsfco/rgstr/base")
- public class BisInspRsfcoRgstrBaseController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private BisInspRsfcoRgstrBaseService bisInspRsfcoRgstrBaseService;
- @Autowired
- private BisInspRsfcoRgstrService bisInspRsfcoRgstrService;
- @ApiOperation(value = "添加/修改水库防洪调度总体情况")
- @RequestMapping(value = "", method = RequestMethod.POST)
- public BaseResponse<BisInspRsfcoRgstrBase> insert(@ApiParam(name = "bisInspRsfcoRgstrBase", value = "BisInspRsfcoRgstrBase", required = true) @RequestBody BisInspRsfcoRgstrBase bisInspRsfcoRgstrBase) {
- Date date = new Date();
- bisInspRsfcoRgstrBase.setUptm(date);
- if(StringUtils.isBlank(bisInspRsfcoRgstrBase.getId())) {
- BisInspRsfcoRgstrBaseParam baseParam = new BisInspRsfcoRgstrBaseParam();
- baseParam.setRgstrId(bisInspRsfcoRgstrBase.getRgstrId());
- List<BisInspRsfcoRgstrBase> baseList = bisInspRsfcoRgstrBaseService.findList(baseParam);
- if (baseList != null && !baseList.isEmpty()) {
- bisInspRsfcoRgstrBase.setId(baseList.get(0).getId());
- bisInspRsfcoRgstrBaseService.update(bisInspRsfcoRgstrBase);
- } else {
- String uuid = UuidUtil.uuid(); // 生成uuid
- bisInspRsfcoRgstrBase.setId(uuid);
- bisInspRsfcoRgstrBase.setIntm(date);
- bisInspRsfcoRgstrBaseService.insert(bisInspRsfcoRgstrBase);
- }
- }else{
- bisInspRsfcoRgstrBaseService.update(bisInspRsfcoRgstrBase);
- }
- if (StringUtils.isNotBlank(bisInspRsfcoRgstrBase.getRgstrId())) {
- BisInspRsfcoRgstr rgstr = bisInspRsfcoRgstrService.get(bisInspRsfcoRgstrBase.getRgstrId());
- if (rgstr != null){
- rgstr.setPresState(bisInspRsfcoRgstrBase.getStatus());
- if (!"2".equals(rgstr.getState())) {
- rgstr.setState("1");
- }
- bisInspRsfcoRgstrService.update(rgstr);
- }
- }
- return buildSuccessResponse(bisInspRsfcoRgstrBase);
- }
- @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 = bisInspRsfcoRgstrBaseService.delete(id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据ID获取水库防洪调度总体情况(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<BisInspRsfcoRgstrBase> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- BisInspRsfcoRgstrBase bisInspRsfcoRgstrBase = bisInspRsfcoRgstrBaseService.get(id);
- return buildSuccessResponse(bisInspRsfcoRgstrBase);
- }
- @ApiOperation(value = "获取水库防洪调度总体情况(列表所有)")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- public BaseResponse<List<BisInspRsfcoRgstrBase>> list(@ApiParam(name = "bisInspRsfcoRgstrBaseParam", value = "bisInspRsfcoRgstrBaseParam", required = true) @RequestBody BisInspRsfcoRgstrBaseParam bisInspRsfcoRgstrBaseParam) {
- List<BisInspRsfcoRgstrBase> bisInspRsfcoRgstrBaseList = bisInspRsfcoRgstrBaseService.findList(bisInspRsfcoRgstrBaseParam);
- return buildSuccessResponse(bisInspRsfcoRgstrBaseList);
- }
- @ApiOperation(value = "获取水库防洪调度总体情况(列表--分页)")
- @RequestMapping(value = "/page", method = RequestMethod.POST)
- public BaseResponse<PageInfo<BisInspRsfcoRgstrBase>> page(@ApiParam(name = "bisInspRsfcoRgstrBaseParam", value = "bisInspRsfcoRgstrBaseParam", required = true) @RequestBody BisInspRsfcoRgstrBaseParam bisInspRsfcoRgstrBaseParam) {
- PageInfo<BisInspRsfcoRgstrBase> bisInspRsfcoRgstrBaseList = bisInspRsfcoRgstrBaseService.findPageInfo(bisInspRsfcoRgstrBaseParam);
- return buildSuccessResponse(bisInspRsfcoRgstrBaseList);
- }
- @ApiOperation(value = "根据登记表id获获取取水许可审批监管情况")
- @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET)
- public BaseResponse<BisInspRsfcoRgstrBase> getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId, HttpServletRequest request) {
- if(StringUtils.isBlank(rgstrId)) {
- return buildFailResponse();
- }
- BisInspRsfcoRgstrBaseParam param = new BisInspRsfcoRgstrBaseParam();
- param.setRgstrId(rgstrId);
- BisInspRsfcoRgstrBase info = this.bisInspRsfcoRgstrBaseService.getBy(param);
- return buildSuccessResponse(info);
- }
- }
|