| | |
| | | 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.FwAreaDivideDTO; |
| | | import org.sxkj.fw.area.entity.FwAreaDivideEntity; |
| | | import org.sxkj.fw.area.vo.FwAreaDivideVO; |
| | | import org.sxkj.fw.area.excel.FwAreaDivideExcel; |
| | | import org.sxkj.fw.area.wrapper.FwAreaDivideWrapper; |
| | | import org.sxkj.fw.area.service.IFwAreaDivideService; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.sxkj.fw.record.entity.FwDroneAlarmRecordEntity; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入fwAreaDivide") |
| | | public R<FwAreaDivideVO> detail(FwAreaDivideEntity fwAreaDivide) { |
| | | FwAreaDivideEntity detail = fwAreaDivideService.getOne(Condition.getQueryWrapper(fwAreaDivide)); |
| | | return R.data(FwAreaDivideWrapper.build().entityVO(detail)); |
| | | @ApiOperation(value = "详情", notes = "传入id") |
| | | public R<FwAreaDivideVO> detail(@ApiParam(value = "主键id", required = true) @RequestParam Long id) { |
| | | if (id == null) { |
| | | return R.fail("主键不能为空"); |
| | | } |
| | | FwAreaDivideVO detail = fwAreaDivideService.selectFwAreaDivideDetail(id); |
| | | if (detail == null) { |
| | | return R.fail("数据不存在"); |
| | | } |
| | | return R.data(detail); |
| | | } |
| | | /** |
| | | * 区域划分表 分页 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "分页", notes = "传入fwAreaDivide") |
| | | public R<IPage<FwAreaDivideVO>> list(@ApiIgnore @RequestParam Map<String, Object> fwAreaDivide, Query query) { |
| | | IPage<FwAreaDivideEntity> pages = fwAreaDivideService.page(Condition.getPage(query), Condition.getQueryWrapper(fwAreaDivide, FwAreaDivideEntity.class)); |
| | | return R.data(FwAreaDivideWrapper.build().pageVO(pages)); |
| | | } |
| | | // @GetMapping("/list") |
| | | // @ApiOperationSupport(order = 2) |
| | | // @ApiOperation(value = "分页", notes = "传入fwAreaDivide") |
| | | // public R<IPage<FwAreaDivideVO>> list(@ApiIgnore @RequestParam Map<String, Object> fwAreaDivide, Query query) { |
| | | // IPage<FwAreaDivideEntity> pages = fwAreaDivideService.page(Condition.getPage(query), Condition.getQueryWrapper(fwAreaDivide, FwAreaDivideEntity.class)); |
| | | // return R.data(FwAreaDivideWrapper.build().pageVO(pages)); |
| | | // } |
| | | |
| | | /** |
| | | * 区域划分表 自定义分页 |
| | |
| | | @GetMapping("/page") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入fwAreaDivide") |
| | | public R<IPage<FwAreaDivideVO>> page(FwAreaDivideVO fwAreaDivide, Query query) { |
| | | public R<IPage<FwAreaDivideVO>> page(FwAreaDivideDTO fwAreaDivide, Query query) { |
| | | IPage<FwAreaDivideVO> pages = fwAreaDivideService.selectFwAreaDividePage(Condition.getPage(query), fwAreaDivide); |
| | | return R.data(pages); |
| | | } |
| | |
| | | /** |
| | | * 区域划分表 新增 |
| | | */ |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入fwAreaDivide") |
| | | public R save(@Valid @RequestBody FwAreaDivideEntity fwAreaDivide) { |
| | | return R.status(fwAreaDivideService.save(fwAreaDivide)); |
| | | } |
| | | // @PostMapping("/save") |
| | | // @ApiOperationSupport(order = 4) |
| | | // @ApiOperation(value = "新增", notes = "传入fwAreaDivide") |
| | | // public R save(@Valid @RequestBody FwAreaDivideEntity fwAreaDivide) { |
| | | // return R.status(fwAreaDivideService.save(fwAreaDivide)); |
| | | // } |
| | | |
| | | /** |
| | | * 区域划分表 修改 |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入fwAreaDivide") |
| | | public R update(@Valid @RequestBody FwAreaDivideEntity fwAreaDivide) { |
| | | return R.status(fwAreaDivideService.updateById(fwAreaDivide)); |
| | | } |
| | | // /** |
| | | // * 区域划分表 修改 |
| | | // */ |
| | | // @PostMapping("/update") |
| | | // @ApiOperationSupport(order = 5) |
| | | // @ApiOperation(value = "修改", notes = "传入fwAreaDivide") |
| | | // public R update(@Valid @RequestBody FwAreaDivideEntity fwAreaDivide) { |
| | | // return R.status(fwAreaDivideService.updateById(fwAreaDivide)); |
| | | // } |
| | | |
| | | /** |
| | | * 区域划分表 新增或修改 |
| | |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入fwAreaDivide") |
| | | public R submit(@Valid @RequestBody FwAreaDivideEntity fwAreaDivide) { |
| | | return R.status(fwAreaDivideService.saveOrUpdate(fwAreaDivide)); |
| | | public R submit(@Valid @RequestBody FwAreaDivideDTO fwAreaDivide) { |
| | | FwAreaDivideEntity fwAreaDivideEntity = Objects.requireNonNull(BeanUtil.copy(fwAreaDivide, FwAreaDivideEntity.class)); |
| | | if (isGeomInvalid(fwAreaDivideEntity.getGeom())) { |
| | | return R.fail("几何数据格式不正确"); |
| | | } |
| | | return R.status(fwAreaDivideService.saveOrUpdate(fwAreaDivideEntity)); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 导出数据 |
| | | */ |
| | | @ApiIgnore |
| | | @GetMapping("/export-fwAreaDivide") |
| | | @ApiOperationSupport(order = 9) |
| | | @ApiOperation(value = "导出数据", notes = "传入fwAreaDivide") |
| | |
| | | ExcelUtil.export(response, "区域划分表数据" + DateUtil.time(), "区域划分表数据表", list, FwAreaDivideExcel.class); |
| | | } |
| | | |
| | | private boolean isGeomInvalid(String geom) { |
| | | if (StringUtil.isBlank(geom)) { |
| | | return false; |
| | | } |
| | | String upper = geom.trim().toUpperCase(); |
| | | return !upper.contains("POLYGON"); |
| | | } |
| | | |
| | | } |