吉安感知网项目-后端
linwei
2026-01-14 bc1a6bb5bb2803ed6a5669a976bf2b47f3dacfca
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/controller/FwDefenseZoneController.java
@@ -27,14 +27,16 @@
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;
import org.sxkj.fw.area.wrapper.FwDefenseZoneWrapper;
import org.sxkj.fw.area.service.IFwDefenseZoneService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.utils.DateUtil;
@@ -43,13 +45,14 @@
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletResponse;
/**
 * 防区管理表 控制器
 *
 * @author lw
 * @since 2026-01-07
 * @since 2026-01-08
 */
@RestController
@AllArgsConstructor
@@ -64,21 +67,27 @@
    */
   @GetMapping("/detail")
   @ApiOperationSupport(order = 1)
   @ApiOperation(value = "详情", notes = "传入fwDefenseZone")
   public R<FwDefenseZoneVO> detail(FwDefenseZoneEntity fwDefenseZone) {
      FwDefenseZoneEntity detail = fwDefenseZoneService.getOne(Condition.getQueryWrapper(fwDefenseZone));
      return R.data(FwDefenseZoneWrapper.build().entityVO(detail));
   @ApiOperation(value = "详情", notes = "传入id")
   public R<FwDefenseZoneVO> detail(@ApiParam(value = "主键id", required = true) @RequestParam Long id) {
      if (id == null) {
         return R.fail("主键不能为空");
      }
      FwDefenseZoneVO detail = fwDefenseZoneService.selectFwDefenseZoneDetail(id);
      if (detail == null) {
         return R.fail("数据不存在");
      }
      return R.data(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));
//   }
   /**
    * 防区管理表 自定义分页
@@ -86,30 +95,38 @@
   @GetMapping("/page")
   @ApiOperationSupport(order = 3)
   @ApiOperation(value = "分页", notes = "传入fwDefenseZone")
   public R<IPage<FwDefenseZoneVO>> page(FwDefenseZoneVO fwDefenseZone, Query query) {
   public R<IPage<FwDefenseZoneVO>> page(FwDefenseZoneDTO fwDefenseZone, Query query) {
      IPage<FwDefenseZoneVO> pages = fwDefenseZoneService.selectFwDefenseZonePage(Condition.getPage(query), fwDefenseZone);
      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 +134,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 +156,7 @@
   /**
    * 导出数据
    */
   @ApiIgnore
   @GetMapping("/export-fwDefenseZone")
   @ApiOperationSupport(order = 9)
   @ApiOperation(value = "导出数据", notes = "传入fwDefenseZone")
@@ -148,4 +170,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");
   }
}