| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.sxkj.common.utils.GeomUtils; |
| | | import org.sxkj.fw.area.dto.FwDefenseZoneDTO; |
| | | import org.sxkj.fw.area.entity.FwDefenseZoneEntity; |
| | | import org.sxkj.fw.area.vo.FwAreaDivideVO; |
| | | 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; |
| | |
| | | if (id == null) { |
| | | return R.fail("主键不能为空"); |
| | | } |
| | | FwDefenseZoneEntity detail = fwDefenseZoneService.getById(id); |
| | | return R.data(FwDefenseZoneWrapper.build().entityVO(detail)); |
| | | FwDefenseZoneVO detail = fwDefenseZoneService.selectFwDefenseZoneDetail(id); |
| | | if (detail == null) { |
| | | return R.fail("数据不存在"); |
| | | } |
| | | return R.data(detail); |
| | | } |
| | | |
| | | /** |
| | | * 根据防区id获取区域列表 |
| | | */ |
| | | @GetMapping("/areaList") |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "区域列表", notes = "传入防区id") |
| | | public R<List<FwAreaDivideVO>> areaList(@ApiParam(value = "防区id", required = true) @RequestParam Long zoneId) { |
| | | if (zoneId == null) { |
| | | return R.fail("防区id不能为空"); |
| | | } |
| | | List<FwAreaDivideVO> list = fwDefenseZoneService.selectFwAreaDivideListByZoneId(zoneId); |
| | | if (list == null) { |
| | | return R.fail("防区不存在"); |
| | | } |
| | | return R.data(list); |
| | | } |
| | | // /** |
| | | // * 防区管理表 分页 |
| | |
| | | @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); |
| | | } |
| | |
| | | @ApiOperation(value = "新增或修改", notes = "传入fwDefenseZone") |
| | | public R submit(@Valid @RequestBody FwDefenseZoneDTO fwDefenseZone) { |
| | | FwDefenseZoneEntity entity = Objects.requireNonNull(BeanUtil.copy(fwDefenseZone, FwDefenseZoneEntity.class)); |
| | | if (isGeomInvalid(entity.getGeom())) { |
| | | if (GeomUtils.isGeomInvalid(entity.getGeom())) { |
| | | return R.fail("几何数据格式不正确"); |
| | | } |
| | | return R.status(fwDefenseZoneService.saveOrUpdate(entity)); |
| | |
| | | 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"); |
| | | } |
| | | |
| | | } |