/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.sxkj.fw.area.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import lombok.AllArgsConstructor; import javax.validation.Valid; import org.springblade.core.secure.BladeUser; 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.Func; 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.dto.FwAreaDivideSubmitDTO; import org.sxkj.fw.area.dto.FwAreaDivideStatisticsDTO; import org.sxkj.fw.area.entity.FwAreaDivideEntity; import org.sxkj.fw.area.vo.FwAreaDivideVO; import org.sxkj.fw.area.vo.FwAreaDivideStatisticsVO; import org.sxkj.fw.area.excel.FwAreaDivideExcel; 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 org.springframework.format.annotation.DateTimeFormat; import springfox.documentation.annotations.ApiIgnore; import java.util.Map; import java.util.List; import java.time.LocalDateTime; import javax.servlet.http.HttpServletResponse; /** * 区域划分表 控制器 * * @author lw * @since 2026-01-07 */ @RestController @AllArgsConstructor @RequestMapping("area/fwAreaDivide") @Api(value = "区域划分表", tags = "区域划分表接口") public class FwAreaDivideController extends BladeController { private final IFwAreaDivideService fwAreaDivideService; /** * 区域划分表 详情 */ @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入id") public R 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 = "传入filterSelected或sceneId或areaTypeKeys或isSetSceneManage或flyTime") public R> list( @ApiParam(value = "是否过滤已被选择的数据(1过滤 0不过滤)") @RequestParam(required = false) Integer filterSelected, @ApiParam(value = "场景id") @RequestParam(required = false) Long sceneId, @ApiParam(value = "区域类型key集合(逗号分隔)") @RequestParam(required = false) String areaTypeKeys, @ApiParam(value = "是否按场景管理过滤(1是 0或空否)") @RequestParam(required = false) Integer isSetSceneManage, @ApiParam(value = "时间筛选(yyyy-MM-dd HH:mm:ss)") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime flyTime) { List list = fwAreaDivideService.selectFwAreaDivideList(filterSelected, sceneId, areaTypeKeys, isSetSceneManage, flyTime); return R.data(list); } /** * 区域划分表 自定义分页 */ @GetMapping("/page") @ApiOperationSupport(order = 3) @ApiOperation(value = "分页", notes = "传入fwAreaDivide") public R> page(FwAreaDivideDTO fwAreaDivide, Query query) { IPage pages = fwAreaDivideService.selectFwAreaDividePage(Condition.getPage(query), fwAreaDivide); return R.data(pages); } /** * 区域划分统计 分页 */ @GetMapping("/divideStatisticsPage") @ApiOperationSupport(order = 4) @ApiOperation(value = "统计分页", notes = "传入统计条件") public R> divideStatisticsPage(FwAreaDivideStatisticsDTO fwAreaDivideStatistics, Query query) { IPage pages = fwAreaDivideService.selectFwAreaDivideStatisticsPage(Condition.getPage(query), fwAreaDivideStatistics); return R.data(pages); } /** * 区域划分统计 详情 */ @GetMapping("/statisticsDetail") @ApiOperationSupport(order = 5) @ApiOperation(value = "统计详情", notes = "传入id") public R statisticsDetail(FwAreaDivideStatisticsDTO fwAreaDivideStatistics) { if (fwAreaDivideStatistics == null || fwAreaDivideStatistics.getId() == null) { return R.fail("主键不能为空"); } FwAreaDivideStatisticsVO detail = fwAreaDivideService.selectFwAreaDivideStatisticsDetail(fwAreaDivideStatistics); if (detail == null) { return R.fail("数据不存在"); } return R.data(detail); } /** * 区域划分表 新增 */ // @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("/submit") @ApiOperationSupport(order = 6) @ApiOperation(value = "新增或修改", notes = "传入主表对象与扩展面列表") public R submit(@Valid @RequestBody FwAreaDivideSubmitDTO fwAreaDivideSubmit) { if (fwAreaDivideSubmit == null || fwAreaDivideSubmit.getAreaDivide() == null) { return R.fail("区域信息不能为空"); } FwAreaDivideEntity fwAreaDivideEntity = fwAreaDivideSubmit.getAreaDivide(); return R.status(fwAreaDivideService.saveOrUpdateWithExt(fwAreaDivideEntity, fwAreaDivideSubmit.getAreaDivideExtList())); } /** * 区域划分表 删除 */ @PostMapping("/remove") @ApiOperationSupport(order = 7) @ApiOperation(value = "逻辑删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(fwAreaDivideService.removeBatchByIds(Func.toLongList(ids))); } /** * 导出数据 */ @ApiIgnore @GetMapping("/export-fwAreaDivide") @ApiOperationSupport(order = 9) @ApiOperation(value = "导出数据", notes = "传入fwAreaDivide") public void exportFwAreaDivide(@ApiIgnore @RequestParam Map fwAreaDivide, BladeUser bladeUser, HttpServletResponse response) { QueryWrapper queryWrapper = Condition.getQueryWrapper(fwAreaDivide, FwAreaDivideEntity.class); //if (!AuthUtil.isAdministrator()) { // queryWrapper.lambda().eq(FwAreaDivide::getTenantId, bladeUser.getTenantId()); //} queryWrapper.lambda().eq(FwAreaDivideEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED); List list = fwAreaDivideService.exportFwAreaDivide(queryWrapper); ExcelUtil.export(response, "区域划分表数据" + DateUtil.time(), "区域划分表数据表", list, FwAreaDivideExcel.class); } }