ard-admin/src/main/java/com/ard/web/controller/data/ArdNoFlyZoneController.java
New file @@ -0,0 +1,157 @@ package com.ard.web.controller.data; import com.alibaba.fastjson2.JSON; import com.ard.common.utils.uuid.IdUtils; import com.ard.data.noflyzone.domain.FeatureCollection; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import java.nio.charset.StandardCharsets; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import com.ard.common.annotation.Log; import com.ard.common.core.controller.BaseController; import com.ard.common.core.domain.AjaxResult; import com.ard.common.enums.BusinessType; import com.ard.data.noflyzone.domain.ArdNoFlyZone; import com.ard.data.noflyzone.service.IArdNoFlyZoneService; import com.ard.common.utils.poi.ExcelUtil; import com.ard.common.core.page.TableDataInfo; import org.springframework.web.multipart.MultipartFile; /** * 禁飞区管理Controller * * @author ruoyi * @date 2025-10-14 */ @Api(tags = "禁飞区管理") @RestController @RequestMapping("/data/noflyzone") public class ArdNoFlyZoneController extends BaseController { @Resource private IArdNoFlyZoneService ardNoFlyZoneService; /** * 查询禁飞区管理列表 */ @ApiOperation("查询禁飞区管理列表") @PreAuthorize("@ss.hasPermi('data:noflyzone:list')") @GetMapping("/list") public TableDataInfo list(ArdNoFlyZone ardNoFlyZone) { startPage(); List<ArdNoFlyZone> list = ardNoFlyZoneService.selectArdNoFlyZoneList(ardNoFlyZone); return getDataTable(list); } /** * 导出禁飞区管理列表 */ @PreAuthorize("@ss.hasPermi('data:noflyzone:export')") @Log(title = "禁飞区管理", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ArdNoFlyZone ardNoFlyZone) { List<ArdNoFlyZone> list = ardNoFlyZoneService.selectArdNoFlyZoneList(ardNoFlyZone); ExcelUtil<ArdNoFlyZone> util = new ExcelUtil<ArdNoFlyZone>(ArdNoFlyZone.class); util.exportExcel(response, list, "禁飞区管理数据"); } /** * 获取禁飞区管理详细信息 */ @ApiOperation("获取禁飞区管理详细信息") @PreAuthorize("@ss.hasPermi('data:noflyzone:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") String id) { return success(ardNoFlyZoneService.selectArdNoFlyZoneById(id)); } /** * 新增禁飞区管理 */ @ApiOperation("新增禁飞区管理") @PreAuthorize("@ss.hasPermi('data:noflyzone:add')") @Log(title = "禁飞区管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody ArdNoFlyZone ardNoFlyZone) { return toAjax(ardNoFlyZoneService.insertArdNoFlyZone(ardNoFlyZone)); } /** * 修改禁飞区管理 */ @ApiOperation("修改禁飞区管理") @PreAuthorize("@ss.hasPermi('data:noflyzone:edit')") @Log(title = "禁飞区管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody ArdNoFlyZone ardNoFlyZone) { return toAjax(ardNoFlyZoneService.updateArdNoFlyZone(ardNoFlyZone)); } /** * 删除禁飞区管理 */ @ApiOperation("删除禁飞区管理") @PreAuthorize("@ss.hasPermi('data:noflyzone:remove')") @Log(title = "禁飞区管理", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable String[] ids) { return toAjax(ardNoFlyZoneService.deleteArdNoFlyZoneByIds(ids)); } /** * 上传 GeoJSON 文件导入禁飞区 */ @ApiOperation("上传 GeoJSON 文件导入禁飞区") @PreAuthorize("@ss.hasPermi('data:noflyzone:import')") @Log(title = "禁飞区管理", businessType = BusinessType.IMPORT) @PostMapping("/import") public AjaxResult importGeoJson(@RequestPart("file") MultipartFile file) { if (file.isEmpty()) { return AjaxResult.error("上传文件为空"); } try { // 读取文件内容为字符串 String jsonStr = new String(file.getBytes(), StandardCharsets.UTF_8); // 解析成 FeatureCollection 对象 FeatureCollection featureCollection = JSON.parseObject(jsonStr, FeatureCollection.class); int successCount = 0; for (FeatureCollection.Feature feature : featureCollection.getFeatures()) { ArdNoFlyZone zone = new ArdNoFlyZone(); zone.setId(IdUtils.simpleUUID()); zone.setName(feature.getName() != null ? feature.getName() : "未命名禁飞区"); // 单独包装 FeatureCollection FeatureCollection singleFc = new FeatureCollection(); singleFc.setType("FeatureCollection"); singleFc.setName(featureCollection.getName()); singleFc.setFeatures(List.of(feature)); zone.setGeojson(singleFc); // 调用 Service 插入 ardNoFlyZoneService.insertArdNoFlyZone(zone); successCount++; } return AjaxResult.success("导入成功,共导入 " + successCount + " 条禁飞区"); } catch (Exception e) { e.printStackTrace(); return AjaxResult.error("导入失败:" + e.getMessage()); } } } ard-common/pom.xml
@@ -119,7 +119,7 @@ <artifactId>javax.servlet-api</artifactId> </dependency> <!-- ruoyi-springboot2 / mybatis-plus 配置 --> <!-- mybatis-plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> ard-system/src/main/java/com/ard/data/noflyzone/domain/ArdNoFlyZone.java
New file @@ -0,0 +1,34 @@ package com.ard.data.noflyzone.domain; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ard.common.annotation.Excel; import com.ard.common.core.domain.BaseEntity; /** * 禁飞区管理对象 ard_no_fly_zone * * @author ruoyi * @date 2025-10-14 */ @Data @NoArgsConstructor @AllArgsConstructor public class ArdNoFlyZone extends BaseEntity { private static final long serialVersionUID = 1L; /** 主键 */ private String id; /** 禁飞区名称 */ @Excel(name = "禁飞区名称") private String name; /** 数据json */ @Excel(name = "数据json") private FeatureCollection geojson; } ard-system/src/main/java/com/ard/data/noflyzone/domain/FeatureCollection.java
New file @@ -0,0 +1,26 @@ package com.ard.data.noflyzone.domain; import lombok.Data; import java.util.List; import java.util.Map; @Data public class FeatureCollection { private String type; private List<Feature> features; private String name; @Data public static class Feature { private String type; private Geometry geometry; private Map<String, Object> properties; private String name; } @Data public static class Geometry { private String type; private List<List<List<Double>>> coordinates; } } ard-system/src/main/java/com/ard/data/noflyzone/domain/FeatureCollectionTypeHandler.java
New file @@ -0,0 +1,68 @@ package com.ard.data.noflyzone.domain; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.ibatis.type.BaseTypeHandler; import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.MappedJdbcTypes; import org.apache.ibatis.type.MappedTypes; import java.sql.CallableStatement; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @MappedJdbcTypes(JdbcType.VARCHAR) @MappedTypes(FeatureCollection.class) public class FeatureCollectionTypeHandler extends BaseTypeHandler<FeatureCollection> { private static final ObjectMapper objectMapper = new ObjectMapper(); @Override public void setNonNullParameter(PreparedStatement ps, int i, FeatureCollection parameter, JdbcType jdbcType) throws SQLException { try { ps.setString(i, objectMapper.writeValueAsString(parameter)); } catch (JsonProcessingException e) { throw new SQLException("Failed to convert FeatureCollection to JSON", e); } } @Override public FeatureCollection getNullableResult(ResultSet rs, String columnName) throws SQLException { String json = rs.getString(columnName); if (json != null) { try { return objectMapper.readValue(json, FeatureCollection.class); } catch (JsonProcessingException e) { throw new SQLException("Failed to parse JSON to FeatureCollection", e); } } return null; } @Override public FeatureCollection getNullableResult(ResultSet rs, int columnIndex) throws SQLException { String json = rs.getString(columnIndex); if (json != null) { try { return objectMapper.readValue(json, FeatureCollection.class); } catch (JsonProcessingException e) { throw new SQLException("Failed to parse JSON to FeatureCollection", e); } } return null; } @Override public FeatureCollection getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { String json = cs.getString(columnIndex); if (json != null) { try { return objectMapper.readValue(json, FeatureCollection.class); } catch (JsonProcessingException e) { throw new SQLException("Failed to parse JSON to FeatureCollection", e); } } return null; } } ard-system/src/main/java/com/ard/data/noflyzone/mapper/ArdNoFlyZoneMapper.java
New file @@ -0,0 +1,61 @@ package com.ard.data.noflyzone.mapper; import java.util.List; import com.ard.data.noflyzone.domain.ArdNoFlyZone; /** * 禁飞区管理Mapper接口 * * @author ruoyi * @date 2025-10-14 */ public interface ArdNoFlyZoneMapper { /** * 查询禁飞区管理 * * @param id 禁飞区管理主键 * @return 禁飞区管理 */ public ArdNoFlyZone selectArdNoFlyZoneById(String id); /** * 查询禁飞区管理列表 * * @param ardNoFlyZone 禁飞区管理 * @return 禁飞区管理集合 */ public List<ArdNoFlyZone> selectArdNoFlyZoneList(ArdNoFlyZone ardNoFlyZone); /** * 新增禁飞区管理 * * @param ardNoFlyZone 禁飞区管理 * @return 结果 */ public int insertArdNoFlyZone(ArdNoFlyZone ardNoFlyZone); /** * 修改禁飞区管理 * * @param ardNoFlyZone 禁飞区管理 * @return 结果 */ public int updateArdNoFlyZone(ArdNoFlyZone ardNoFlyZone); /** * 删除禁飞区管理 * * @param id 禁飞区管理主键 * @return 结果 */ public int deleteArdNoFlyZoneById(String id); /** * 批量删除禁飞区管理 * * @param ids 需要删除的数据主键集合 * @return 结果 */ public int deleteArdNoFlyZoneByIds(String[] ids); } ard-system/src/main/java/com/ard/data/noflyzone/service/IArdNoFlyZoneService.java
New file @@ -0,0 +1,61 @@ package com.ard.data.noflyzone.service; import java.util.List; import com.ard.data.noflyzone.domain.ArdNoFlyZone; /** * 禁飞区管理Service接口 * * @author ruoyi * @date 2025-10-14 */ public interface IArdNoFlyZoneService { /** * 查询禁飞区管理 * * @param id 禁飞区管理主键 * @return 禁飞区管理 */ public ArdNoFlyZone selectArdNoFlyZoneById(String id); /** * 查询禁飞区管理列表 * * @param ardNoFlyZone 禁飞区管理 * @return 禁飞区管理集合 */ public List<ArdNoFlyZone> selectArdNoFlyZoneList(ArdNoFlyZone ardNoFlyZone); /** * 新增禁飞区管理 * * @param ardNoFlyZone 禁飞区管理 * @return 结果 */ public int insertArdNoFlyZone(ArdNoFlyZone ardNoFlyZone); /** * 修改禁飞区管理 * * @param ardNoFlyZone 禁飞区管理 * @return 结果 */ public int updateArdNoFlyZone(ArdNoFlyZone ardNoFlyZone); /** * 批量删除禁飞区管理 * * @param ids 需要删除的禁飞区管理主键集合 * @return 结果 */ public int deleteArdNoFlyZoneByIds(String[] ids); /** * 删除禁飞区管理信息 * * @param id 禁飞区管理主键 * @return 结果 */ public int deleteArdNoFlyZoneById(String id); } ard-system/src/main/java/com/ard/data/noflyzone/service/impl/ArdNoFlyZoneServiceImpl.java
New file @@ -0,0 +1,103 @@ package com.ard.data.noflyzone.service.impl; import java.util.List; import com.ard.common.utils.DateUtils; import com.ard.common.utils.SecurityUtils; import com.ard.common.utils.uuid.IdUtils; import com.ard.data.noflyzone.service.IArdNoFlyZoneService; import org.springframework.stereotype.Service; import com.ard.data.noflyzone.mapper.ArdNoFlyZoneMapper; import com.ard.data.noflyzone.domain.ArdNoFlyZone; import javax.annotation.Resource; /** * 禁飞区管理Service业务层处理 * * @author ruoyi * @date 2025-10-14 */ @Service public class ArdNoFlyZoneServiceImpl implements IArdNoFlyZoneService { @Resource private ArdNoFlyZoneMapper ardNoFlyZoneMapper; /** * 查询禁飞区管理 * * @param id 禁飞区管理主键 * @return 禁飞区管理 */ @Override public ArdNoFlyZone selectArdNoFlyZoneById(String id) { return ardNoFlyZoneMapper.selectArdNoFlyZoneById(id); } /** * 查询禁飞区管理列表 * * @param ardNoFlyZone 禁飞区管理 * @return 禁飞区管理 */ @Override public List<ArdNoFlyZone> selectArdNoFlyZoneList(ArdNoFlyZone ardNoFlyZone) { return ardNoFlyZoneMapper.selectArdNoFlyZoneList(ardNoFlyZone); } /** * 新增禁飞区管理 * * @param ardNoFlyZone 禁飞区管理 * @return 结果 */ @Override public int insertArdNoFlyZone(ArdNoFlyZone ardNoFlyZone) { ardNoFlyZone.setId(IdUtils.simpleUUID()); ardNoFlyZone.setCreateTime(DateUtils.getNowDate()); ardNoFlyZone.setCreateBy(SecurityUtils.getUsername()); return ardNoFlyZoneMapper.insertArdNoFlyZone(ardNoFlyZone); } /** * 修改禁飞区管理 * * @param ardNoFlyZone 禁飞区管理 * @return 结果 */ @Override public int updateArdNoFlyZone(ArdNoFlyZone ardNoFlyZone) { ardNoFlyZone.setUpdateBy(SecurityUtils.getUsername()); ardNoFlyZone.setUpdateTime(DateUtils.getNowDate()); return ardNoFlyZoneMapper.updateArdNoFlyZone(ardNoFlyZone); } /** * 批量删除禁飞区管理 * * @param ids 需要删除的禁飞区管理主键 * @return 结果 */ @Override public int deleteArdNoFlyZoneByIds(String[] ids) { return ardNoFlyZoneMapper.deleteArdNoFlyZoneByIds(ids); } /** * 删除禁飞区管理信息 * * @param id 禁飞区管理主键 * @return 结果 */ @Override public int deleteArdNoFlyZoneById(String id) { return ardNoFlyZoneMapper.deleteArdNoFlyZoneById(id); } } ard-system/src/main/resources/mapper/data/ArdNoFlyZoneMapper.xml
New file @@ -0,0 +1,79 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ard.data.noflyzone.mapper.ArdNoFlyZoneMapper"> <resultMap type="ArdNoFlyZone" id="ArdNoFlyZoneResult"> <result property="id" column="id" /> <result property="name" column="name" /> <result property="geojson" column="geojson" typeHandler="com.ard.data.noflyzone.domain.FeatureCollectionTypeHandler"/> <result property="createBy" column="create_by" /> <result property="createTime" column="create_time" /> <result property="updateBy" column="update_by" /> <result property="updateTime" column="update_time" /> </resultMap> <sql id="selectArdNoFlyZoneVo"> select id, name, geojson, create_by, create_time, update_by, update_time from ard_no_fly_zone </sql> <select id="selectArdNoFlyZoneList" parameterType="ArdNoFlyZone" resultMap="ArdNoFlyZoneResult"> <include refid="selectArdNoFlyZoneVo"/> <where> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="geojson != null and geojson != ''"> and geojson = #{geojson}</if> </where> </select> <select id="selectArdNoFlyZoneById" parameterType="String" resultMap="ArdNoFlyZoneResult"> <include refid="selectArdNoFlyZoneVo"/> where id = #{id} </select> <insert id="insertArdNoFlyZone" parameterType="ArdNoFlyZone"> insert into ard_no_fly_zone <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">id,</if> <if test="name != null">name,</if> <if test="geojson != null">geojson,</if> <if test="createBy != null">create_by,</if> <if test="createTime != null">create_time,</if> <if test="updateBy != null">update_by,</if> <if test="updateTime != null">update_time,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if> <if test="name != null">#{name},</if> <if test="geojson != null">#{geojson, typeHandler=com.ard.data.noflyzone.domain.FeatureCollectionTypeHandler},</if> <if test="createBy != null">#{createBy},</if> <if test="createTime != null">#{createTime},</if> <if test="updateBy != null">#{updateBy},</if> <if test="updateTime != null">#{updateTime},</if> </trim> </insert> <update id="updateArdNoFlyZone" parameterType="ArdNoFlyZone"> update ard_no_fly_zone <trim prefix="SET" suffixOverrides=","> <if test="name != null">name = #{name},</if> <if test="geojson != null">geojson = #{geojson},</if> <if test="createBy != null">create_by = #{createBy},</if> <if test="createTime != null">create_time = #{createTime},</if> <if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateTime != null">update_time = #{updateTime},</if> </trim> where id = #{id} </update> <delete id="deleteArdNoFlyZoneById" parameterType="String"> delete from ard_no_fly_zone where id = #{id} </delete> <delete id="deleteArdNoFlyZoneByIds" parameterType="String"> delete from ard_no_fly_zone where id in <foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach> </delete> </mapper>