全部
This commit is contained in:
@ -14,7 +14,7 @@ import javax.annotation.Resource;
|
||||
|
||||
|
||||
@Tag(name = "业务配置管理")
|
||||
@CheckAuth
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/businessConfig")
|
||||
public class BusinessConfigController {
|
||||
|
||||
@ -45,7 +45,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "文件数据管理")
|
||||
@CheckAuth
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/fileInfo")
|
||||
public class FileInfoController {
|
||||
|
||||
@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -27,7 +28,6 @@ public class GdalController {
|
||||
@Operation(summary = "导入矢量数据")
|
||||
@PostMapping("/import")
|
||||
public void importDataStreamGzip(@Parameter(description = "矢量文件路径", required = true) @RequestParam("path") String path, HttpServletResponse response) throws IOException {
|
||||
|
||||
// 解析矢量文件、得到JSON数据
|
||||
String jsonData = GdalJsonConverter.convertToJson(path);
|
||||
|
||||
@ -38,8 +38,7 @@ public class GdalController {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
// 使用GZIP压缩并输出
|
||||
try (OutputStream outputStream = response.getOutputStream();
|
||||
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputStream)) {
|
||||
try (OutputStream outputStream = response.getOutputStream(); GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputStream)) {
|
||||
gzipOutputStream.write(jsonData.getBytes(StandardCharsets.UTF_8));
|
||||
gzipOutputStream.finish();
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@Data
|
||||
@Slf4j
|
||||
@Tag(name = "路径规划管理")
|
||||
@CheckAuth
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/graphhopper")
|
||||
public class GraphHopperController {
|
||||
@ -58,7 +58,7 @@ public class GraphHopperController {
|
||||
|
||||
@Operation(summary = "加载地图数据")
|
||||
@PostMapping("/loadMap")
|
||||
@CheckAuth
|
||||
|
||||
public ApiResponse loadMap(@Parameter(description = "文件路径") @RequestParam String path) {
|
||||
File osmFile = new File(path);
|
||||
if (!osmFile.exists()) {
|
||||
@ -108,7 +108,7 @@ public class GraphHopperController {
|
||||
|
||||
@Operation(summary = "清除地图服务")
|
||||
@PostMapping("/clearMap")
|
||||
@CheckAuth
|
||||
|
||||
public ApiResponse clearMap() {
|
||||
// 防止并发操作(与加载操作互斥)
|
||||
if (isLoading.get()) {
|
||||
@ -146,11 +146,14 @@ public class GraphHopperController {
|
||||
|
||||
@Operation(summary = "路径规划")
|
||||
@PostMapping("/route")
|
||||
@CheckAuth
|
||||
|
||||
public ApiResponse calculateRoute(@RequestBody RouteRequest request) {
|
||||
// 校验地图是否加载完成 + 实例是否可用
|
||||
// 区分未加载地图和加载中两种状态
|
||||
if (isLoading.get()) {
|
||||
return ApiResponse.failure("地图正在加载中,请稍后再试");
|
||||
}
|
||||
if (!isLoaded.get() || currentHopper == null) {
|
||||
return ApiResponse.failure("地图未加载完成");
|
||||
return ApiResponse.failure("地图未加载,请先加载地图");
|
||||
}
|
||||
try {
|
||||
// 构建路径点列表
|
||||
@ -203,8 +206,20 @@ public class GraphHopperController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取地图加载状态")
|
||||
@GetMapping("/status")
|
||||
public ApiResponse getMapStatus() {
|
||||
if (isLoading.get()) {
|
||||
return ApiResponse.success("地图正在加载中");
|
||||
} else if (isLoaded.get() && currentHopper != null) {
|
||||
return ApiResponse.success("地图已加载完成");
|
||||
} else {
|
||||
return ApiResponse.success("地图未加载");
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取交通方式")
|
||||
@CheckAuth
|
||||
|
||||
@PostMapping("/profiles")
|
||||
public ApiResponse profiles() {
|
||||
return ApiResponse.success(graphHopperProperties.getProfiles());
|
||||
|
||||
@ -42,7 +42,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Tag(name = "图标数据管理")
|
||||
@CheckAuth
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/iconLibrary")
|
||||
public class IconLibraryController {
|
||||
|
||||
@ -28,8 +28,17 @@ public class MatterController {
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "添加物资")
|
||||
public ApiResponse add(@RequestBody AddMatterDto addMatterDto) {
|
||||
// 获取名称
|
||||
String name = addMatterDto.getName();
|
||||
// 判断名称是否存在
|
||||
if (matterService.exists(new LambdaQueryWrapper<Matter>().eq(Matter::getName, name))) {
|
||||
return ApiResponse.failure("物资已存在");
|
||||
}
|
||||
Matter matter = new Matter();
|
||||
BeanUtils.copyProperties(addMatterDto, matter);
|
||||
if (matter.getNum() == null) {
|
||||
matter.setNum(0);
|
||||
}
|
||||
matterService.save(matter);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
@ -61,7 +70,7 @@ public class MatterController {
|
||||
@PostMapping("/list")
|
||||
public ApiResponse list(@Parameter(description = "分页数量") @RequestParam(value = "pageNum") Integer pageNum,
|
||||
@Parameter(description = "分页大小") @RequestParam(value = "pageSize") Integer pageSize,
|
||||
@Parameter(description = "物资名称") @RequestParam(value = "name") String name) {
|
||||
@Parameter(description = "物资名称") @RequestParam(value = "name", required = false) String name) {
|
||||
LambdaQueryWrapper<Matter> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
queryWrapper.like(Matter::getName, name);
|
||||
|
||||
@ -42,7 +42,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Tag(name = "军标数据管理")
|
||||
@CheckAuth
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/militaryLibrary")
|
||||
public class MilitaryLibraryController {
|
||||
|
||||
@ -42,7 +42,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Tag(name = "模型数据管理")
|
||||
@CheckAuth
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/modelLibrary")
|
||||
public class ModelLibraryController {
|
||||
@ -543,7 +543,7 @@ public class ModelLibraryController {
|
||||
// 先将当前分类ID加入结果列表(确保包含自身)
|
||||
resultList.add(currentTypeId);
|
||||
|
||||
// 查询当前分类的「直接子分类」(按 tree_index 排序、保持树形结构原有顺序)
|
||||
// 查询当前分类的「直接子分类」
|
||||
String childSql = "SELECT id FROM model_type WHERE parent_id = ? ORDER BY tree_index ASC";
|
||||
List<Object> childParams = new ArrayList<>();
|
||||
childParams.add(currentTypeId);
|
||||
@ -578,5 +578,4 @@ public class ModelLibraryController {
|
||||
}
|
||||
return str.startsWith(".") ? str.substring(1) : str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,15 +5,15 @@ import com.yj.earth.vo.PoiVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.Data;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.sql.*;
|
||||
import java.io.File;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -21,15 +21,20 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/poi")
|
||||
public class PoiController {
|
||||
private static Connection connection;
|
||||
private static final Logger logger = LoggerFactory.getLogger(PoiController.class);
|
||||
|
||||
static {
|
||||
try {
|
||||
@Value("${poi.global.enabled:false}")
|
||||
private boolean poiEnabled;
|
||||
|
||||
private Connection connection;
|
||||
|
||||
// 初始化数据库连接的方法
|
||||
private void initConnection() throws SQLException, ClassNotFoundException {
|
||||
if (connection == null || connection.isClosed()) {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
String dbPath = System.getProperty("user.dir") + File.separator + "poi" + File.separator + "poi.db";
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + dbPath);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("SQLite连接初始化失败", e);
|
||||
logger.info("POI数据库连接初始化成功,路径:{}", dbPath);
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +43,16 @@ public class PoiController {
|
||||
public ApiResponse data(@Parameter(description = "分页页码") Integer pageNum,
|
||||
@Parameter(description = "分页大小") Integer pageSize,
|
||||
@Parameter(description = "名称搜索") String name) {
|
||||
// 检查功能是否开启
|
||||
if (!poiEnabled) {
|
||||
return ApiResponse.failure("全国POI搜索功能已关闭");
|
||||
}
|
||||
|
||||
// 检查分页参数合法性
|
||||
if (pageNum == null || pageSize == null || pageNum < 1 || pageSize < 1) {
|
||||
return ApiResponse.failure("无效的分页参数");
|
||||
}
|
||||
|
||||
int offset = (pageNum - 1) * pageSize;
|
||||
StringBuilder dataSql = new StringBuilder("SELECT id, name, lng, lat FROM data WHERE 1=1");
|
||||
List<Object> params = new ArrayList<>();
|
||||
@ -51,8 +66,10 @@ public class PoiController {
|
||||
// 添加分页条件
|
||||
dataSql.append(" LIMIT ? OFFSET ?");
|
||||
try {
|
||||
// 初始化连接(如果未初始化)
|
||||
initConnection();
|
||||
|
||||
List<PoiVo> poiList = new ArrayList<>();
|
||||
long dataStartTime = System.currentTimeMillis();
|
||||
try (PreparedStatement dataPs = connection.prepareStatement(dataSql.toString())) {
|
||||
int paramIndex = 1;
|
||||
for (Object param : params) {
|
||||
@ -74,7 +91,11 @@ public class PoiController {
|
||||
}
|
||||
return ApiResponse.success(poiList);
|
||||
} catch (SQLException e) {
|
||||
logger.error("POI数据查询失败", e);
|
||||
return ApiResponse.failure("POI数据查询失败:" + e.getMessage());
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.error("POI数据库驱动加载失败", e);
|
||||
return ApiResponse.failure("POI功能初始化失败:驱动未找到");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Tag(name = "角色数据管理")
|
||||
@CheckAuth
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
public class RoleController {
|
||||
|
||||
@ -22,7 +22,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Tag(name = "角色资源管理")
|
||||
@CheckAuth
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/roleSource")
|
||||
public class RoleSourceController {
|
||||
|
||||
@ -36,7 +36,7 @@ import static com.yj.earth.common.constant.GlobalConstant.SHOW;
|
||||
|
||||
@Slf4j
|
||||
@Tag(name = "树形结构管理")
|
||||
@CheckAuth
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/source")
|
||||
public class SourceController {
|
||||
|
||||
@ -177,7 +177,7 @@ public class SystemController {
|
||||
source.setSourceType(resultSet.getString("source_type"));
|
||||
source.setSourcePath(resultSet.getString("source_path"));
|
||||
|
||||
// 关键修改:读取原始parent_id,而非覆盖为新父节点ID
|
||||
// 关键修改:读取原始parent_id、而非覆盖为新父节点ID
|
||||
source.setParentId(resultSet.getString("parent_id"));
|
||||
|
||||
Integer treeIndex = resultSet.getObject("tree_index") != null
|
||||
|
||||
@ -25,6 +25,8 @@ public class Matter implements Serializable {
|
||||
private String name;
|
||||
@Schema(description = "数量")
|
||||
private Integer num;
|
||||
@Schema(description = "单位")
|
||||
private String unit;
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.yj.earth.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@ -23,7 +25,9 @@ public class PoiInfo implements Serializable {
|
||||
@Schema(description = "是否启用")
|
||||
private Integer isEnable;
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.yj.earth.business.service.impl;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.drew.imaging.ImageMetadataReader;
|
||||
import com.drew.lang.Rational;
|
||||
import com.drew.metadata.Metadata;
|
||||
@ -8,14 +9,10 @@ import com.drew.metadata.exif.GpsDirectory;
|
||||
import com.yj.earth.business.domain.FileInfo;
|
||||
import com.yj.earth.business.mapper.FileInfoMapper;
|
||||
import com.yj.earth.business.service.FileInfoService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yj.earth.datasource.DatabaseManager;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
Reference in New Issue
Block a user