吉安感知网项目-后端
rain
2026-01-09 3ae46f2a59f9d4e751f78d8dc1a896ceba5ca495
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/controller/FwDefenseZoneController.java
@@ -27,10 +27,13 @@
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.sxkj.fw.area.dto.FwDefenseZoneDTO;
import org.sxkj.fw.area.entity.FwDefenseZoneEntity;
import org.sxkj.fw.area.vo.FwDefenseZoneVO;
import org.sxkj.fw.area.excel.FwDefenseZoneExcel;
@@ -43,6 +46,7 @@
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletResponse;
/**
@@ -64,21 +68,24 @@
    */
   @GetMapping("/detail")
   @ApiOperationSupport(order = 1)
   @ApiOperation(value = "详情", notes = "传入fwDefenseZone")
   public R<FwDefenseZoneVO> detail(FwDefenseZoneEntity fwDefenseZone) {
      FwDefenseZoneEntity detail = fwDefenseZoneService.getOne(Condition.getQueryWrapper(fwDefenseZone));
   @ApiOperation(value = "详情", notes = "传入id")
   public R<FwDefenseZoneVO> detail(@ApiParam(value = "主键id", required = true) @RequestParam Long id) {
      if (id == null) {
         return R.fail("主键不能为空");
      }
      FwDefenseZoneEntity detail = fwDefenseZoneService.getById(id);
      return R.data(FwDefenseZoneWrapper.build().entityVO(detail));
   }
   /**
    * 防区管理表 分页
    */
   @GetMapping("/list")
   @ApiOperationSupport(order = 2)
   @ApiOperation(value = "分页", notes = "传入fwDefenseZone")
   public R<IPage<FwDefenseZoneVO>> list(@ApiIgnore @RequestParam Map<String, Object> fwDefenseZone, Query query) {
      IPage<FwDefenseZoneEntity> pages = fwDefenseZoneService.page(Condition.getPage(query), Condition.getQueryWrapper(fwDefenseZone, FwDefenseZoneEntity.class));
      return R.data(FwDefenseZoneWrapper.build().pageVO(pages));
   }
//   /**
//    * 防区管理表 分页
//    */
//   @GetMapping("/list")
//   @ApiOperationSupport(order = 2)
//   @ApiOperation(value = "分页", notes = "传入fwDefenseZone")
//   public R<IPage<FwDefenseZoneVO>> list(@ApiIgnore @RequestParam Map<String, Object> fwDefenseZone, Query query) {
//      IPage<FwDefenseZoneEntity> pages = fwDefenseZoneService.page(Condition.getPage(query), Condition.getQueryWrapper(fwDefenseZone, FwDefenseZoneEntity.class));
//      return R.data(FwDefenseZoneWrapper.build().pageVO(pages));
//   }
   /**
    * 防区管理表 自定义分页
@@ -91,25 +98,33 @@
      return R.data(pages);
   }
   /**
    * 防区管理表 新增
    */
   @PostMapping("/save")
   @ApiOperationSupport(order = 4)
   @ApiOperation(value = "新增", notes = "传入fwDefenseZone")
   public R save(@Valid @RequestBody FwDefenseZoneEntity fwDefenseZone) {
      return R.status(fwDefenseZoneService.save(fwDefenseZone));
   }
   /**
    * 防区管理表 修改
    */
   @PostMapping("/update")
   @ApiOperationSupport(order = 5)
   @ApiOperation(value = "修改", notes = "传入fwDefenseZone")
   public R update(@Valid @RequestBody FwDefenseZoneEntity fwDefenseZone) {
      return R.status(fwDefenseZoneService.updateById(fwDefenseZone));
   }
//   /**
//    * 防区管理表 新增
//    */
//   @PostMapping("/save")
//   @ApiOperationSupport(order = 4)
//   @ApiOperation(value = "新增", notes = "传入fwDefenseZone")
//   public R save(@Valid @RequestBody FwDefenseZoneDTO fwDefenseZone) {
//      FwDefenseZoneEntity entity = Objects.requireNonNull(BeanUtil.copy(fwDefenseZone, FwDefenseZoneEntity.class));
//      if (isGeomInvalid(entity.getGeom())) {
//         return R.fail("几何数据格式不正确");
//      }
//      return R.status(fwDefenseZoneService.save(entity));
//   }
//
//   /**
//    * 防区管理表 修改
//    */
//   @PostMapping("/update")
//   @ApiOperationSupport(order = 5)
//   @ApiOperation(value = "修改", notes = "传入fwDefenseZone")
//   public R update(@Valid @RequestBody FwDefenseZoneDTO fwDefenseZone) {
//      FwDefenseZoneEntity entity = Objects.requireNonNull(BeanUtil.copy(fwDefenseZone, FwDefenseZoneEntity.class));
//      if (isGeomInvalid(entity.getGeom())) {
//         return R.fail("几何数据格式不正确");
//      }
//      return R.status(fwDefenseZoneService.updateById(entity));
//   }
   /**
    * 防区管理表 新增或修改
@@ -117,8 +132,12 @@
   @PostMapping("/submit")
   @ApiOperationSupport(order = 6)
   @ApiOperation(value = "新增或修改", notes = "传入fwDefenseZone")
   public R submit(@Valid @RequestBody FwDefenseZoneEntity fwDefenseZone) {
      return R.status(fwDefenseZoneService.saveOrUpdate(fwDefenseZone));
   public R submit(@Valid @RequestBody FwDefenseZoneDTO fwDefenseZone) {
      FwDefenseZoneEntity entity = Objects.requireNonNull(BeanUtil.copy(fwDefenseZone, FwDefenseZoneEntity.class));
      if (isGeomInvalid(entity.getGeom())) {
         return R.fail("几何数据格式不正确");
      }
      return R.status(fwDefenseZoneService.saveOrUpdate(entity));
   }
   /**
@@ -135,6 +154,7 @@
   /**
    * 导出数据
    */
   @ApiIgnore
   @GetMapping("/export-fwDefenseZone")
   @ApiOperationSupport(order = 9)
   @ApiOperation(value = "导出数据", notes = "传入fwDefenseZone")
@@ -148,4 +168,12 @@
      ExcelUtil.export(response, "防区管理表数据" + DateUtil.time(), "防区管理表数据表", list, FwDefenseZoneExcel.class);
   }
   private boolean isGeomInvalid(String geom) {
      if (StringUtil.isBlank(geom)) {
         return false;
      }
      String upper = geom.trim().toUpperCase();
      return !upper.contains("POLYGON");
   }
}