| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- package cn.com.goldenwater.dcproj.controller.rsvr;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.model.BisInspSafeExtApp;
- import cn.com.goldenwater.dcproj.model.BisInspSafeExtManage;
- import cn.com.goldenwater.dcproj.param.BisInspSafeExtManageParam;
- import cn.com.goldenwater.dcproj.service.BisInspRsvrRgstrService;
- import cn.com.goldenwater.dcproj.service.BisInspSafeExtManageService;
- import cn.com.goldenwater.dcproj.utils.Builder;
- 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 org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.Date;
- /**
- * @author lune
- * @date 2019-2-18
- */
- @Api(value = "APP 水库安全运行管理情况", tags = "APP 水库安全运行管理情况")
- @RestController
- @RequestMapping("/dc/insp/safeExtManage")
- public class BisInspSafeExtManageController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private BisInspSafeExtManageService bisInspSafeExtManageService;
- @Autowired
- private BisInspRsvrRgstrService bisInspRsvrRgstrService;
- @ApiOperation(value = "添加安全运行管理")
- @RequestMapping(value = "", method = RequestMethod.POST)
- public BaseResponse<BisInspSafeExtManage> insert(@ApiParam(name = "bisInspSafeExtManage", value = "BisInspSafeExtManage", required = true) @RequestBody BisInspSafeExtManage bisInspSafeExtManage) {
- BisInspSafeExtManage safeExtManage = bisInspSafeExtManageService.getBy(Builder
- .of(BisInspSafeExtManageParam::new)
- .with(BisInspSafeExtManageParam::setRgstrId, bisInspSafeExtManage.getRgstrId())
- .build()
- );
- if (safeExtManage == null) {
- bisInspSafeExtManageService.insert(bisInspSafeExtManage);
- } else {
- bisInspSafeExtManageService.update(bisInspSafeExtManage);
- }
- bisInspRsvrRgstrService.updateRsvr(bisInspSafeExtManage.getRgstrId(), bisInspSafeExtManage.getStatus(), "safe");
- return buildSuccessResponse(bisInspSafeExtManage);
- }
- @ApiOperation(value = "添加安全运行管理")
- @RequestMapping(value = "/insert", method = RequestMethod.POST)
- public BaseResponse<BisInspSafeExtManage> insertDam(@ApiParam(name = "bisInspSafeExtManage", value = "BisInspSafeExtManage", required = true) @RequestBody BisInspSafeExtManage bisInspSafeExtManage) {
- bisInspSafeExtManage.setUpdateTime(new Date());
- BisInspSafeExtManageParam safeExtManageParam = new BisInspSafeExtManageParam();
- safeExtManageParam.setRgstrId(bisInspSafeExtManage.getRgstrId());
- BisInspSafeExtManage safeExtManage = bisInspSafeExtManageService.getBy(safeExtManageParam);
- if (safeExtManage == null) {
- String uuid = UuidUtil.uuid();
- bisInspSafeExtManage.setMngrnId(uuid);
- bisInspSafeExtManage.setCreateTime(new Date());
- bisInspSafeExtManageService.insert(bisInspSafeExtManage);
- } else {
- bisInspSafeExtManage.setMngrnId(safeExtManage.getMngrnId());
- bisInspSafeExtManageService.update(bisInspSafeExtManage);
- }
- bisInspRsvrRgstrService.updateRsvr(bisInspSafeExtManage.getRgstrId(), bisInspSafeExtManage.getStatus(), "dam");
- return buildSuccessResponse(bisInspSafeExtManage);
- }
- @ApiOperation(value = "根据ID删除安全运行管理")
- @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- int ret = bisInspSafeExtManageService.delete(id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据督查登记表获取安全运行管理信息")
- @RequestMapping(value = "/get/{rgstrId}", method = RequestMethod.GET)
- public BaseResponse<BisInspSafeExtManage> getByRgstrId(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId) {
- BisInspSafeExtManageParam safeExtManageParam = new BisInspSafeExtManageParam();
- safeExtManageParam.setRgstrId(rgstrId);
- BisInspSafeExtManage bisInspSafeExtManage = bisInspSafeExtManageService.getBy(safeExtManageParam);
- return buildSuccessResponse(bisInspSafeExtManage);
- }
- @ApiOperation(value = "根据安全运行管理id获取精简版数据,手机专用接口")
- @RequestMapping(value = "/getApp/{id}", method = RequestMethod.GET)
- public BaseResponse<BisInspSafeExtApp> getApp(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- BisInspSafeExtApp bisInspSafeExtManage = bisInspSafeExtManageService.getApp(id);
- return buildSuccessResponse(bisInspSafeExtManage);
- }
- @ApiOperation(value = "更新安全运行管理信息")
- @RequestMapping(value = "/update", method = RequestMethod.POST)
- public BaseResponse update(@ApiParam(name = "bisInspSafeExtManage", value = "BisInspSafeExtManage", required = true) @RequestBody BisInspSafeExtManage bisInspSafeExtManage) {
- bisInspSafeExtManage.setUpdateTime(new Date());
- if (StringUtils.isBlank(bisInspSafeExtManage.getMngrnId())) {
- if (StringUtils.isNotBlank(bisInspSafeExtManage.getRgstrId())) {
- BisInspSafeExtManageParam safeExtManageParam = new BisInspSafeExtManageParam();
- safeExtManageParam.setRgstrId(bisInspSafeExtManage.getRgstrId());
- BisInspSafeExtManage bisInspSafeExtManageReg = bisInspSafeExtManageService.getBy(safeExtManageParam);
- if (bisInspSafeExtManageReg != null) {
- bisInspSafeExtManageReg.setMngrnId(bisInspSafeExtManageReg.getMngrnId());
- }
- }
- }
- int ret = bisInspSafeExtManageService.update(bisInspSafeExtManage);
- bisInspRsvrRgstrService.updateRsvr(bisInspSafeExtManage.getRgstrId(), bisInspSafeExtManage.getStatus(), "safe");
- return buildSuccessResponse(bisInspSafeExtManage);
- }
- @ApiOperation(value = "根据ID获取安全运行管理(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<BisInspSafeExtManage> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- BisInspSafeExtManage bisInspSafeExtManage = bisInspSafeExtManageService.get(id);
- return buildSuccessResponse(bisInspSafeExtManage);
- }
- }
|