图标库

This commit is contained in:
ZZX9599
2025-09-26 13:46:24 +08:00
parent 8479d174be
commit 26af321271
37 changed files with 751 additions and 23 deletions

View File

@ -72,6 +72,6 @@ public class AuthGenerator {
}
public static void main(String[] args) {
System.out.println(generateAuth("标准版", 1000, 30, "DAC653349FD15F1E6DB2F9322AD628F4"));
System.out.println(generateAuth("标准版", 1000, 30, "25F429FDA965007B72BB7A6B2C03535A"));
}
}

View File

@ -102,7 +102,6 @@ public class SourceController {
return ApiResponse.success(source);
}
@Operation(summary = "新增其他资源")
@PostMapping("/addOtherSource")
public ApiResponse addOtherSource(@RequestBody AddOtherSourceDto addOtherSourceDto) throws JsonProcessingException {
@ -126,7 +125,6 @@ public class SourceController {
return ApiResponse.success(source);
}
@Operation(summary = "更新资源信息")
@PostMapping("/update")
public ApiResponse updateSource(@RequestBody UpdateSourceDto updateSourceDto) {
@ -146,7 +144,6 @@ public class SourceController {
sourceType,
updateSourceDto.getParams()
);
System.out.println("更新的数据:" + validatedParams);
source.setParams(MapUtil.mapToString(updateSourceDto.getParams()));
}
// 保存更新
@ -160,6 +157,36 @@ public class SourceController {
return ApiResponse.success(sourceService.getSourceListByUserId(StpUtil.getLoginIdAsString()));
}
@Operation(summary = "拖动资源")
@PostMapping("/dragSource")
public ApiResponse drag(@RequestBody List<DragSourceDto> dragSourceDtoList) {
for (DragSourceDto dragSourceDto : dragSourceDtoList) {
LambdaQueryWrapper<Source> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Source::getId, dragSourceDto.getId());
Source source = sourceService.getOne(queryWrapper);
source.setTreeIndex(dragSourceDto.getTreeIndex());
source.setParentId(dragSourceDto.getParentId());
sourceService.updateById(source);
}
return ApiResponse.success(null);
}
@Operation(summary = "更新层级")
@PostMapping("/updateLevel")
public ApiResponse updateLevel(@RequestBody List<UpdateLevelDto> updateLevelDtoList) {
for (UpdateLevelDto updateLevelDto : updateLevelDtoList) {
LambdaQueryWrapper<Source> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Source::getId, updateLevelDto.getId());
Source source = sourceService.getOne(queryWrapper);
String params = source.getParams();
// 修改这个 JSON 的值
params = JsonUtil.modifyJsonValue(params, "layerIndex", updateLevelDto.getLayerIndex());
source.setParams(params);
sourceService.updateById(source);
}
return ApiResponse.success(null);
}
@Operation(summary = "删除资源数据")
@PostMapping("/delete")
public ApiResponse delete(@RequestBody DeleteSourceDto deleteSourceDto) {

View File

@ -0,0 +1,30 @@
package com.yj.earth.business.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Icon {
@Schema(description = "主键")
private String id;
@Schema(description = "图标类型ID")
private String iconTypeId;
@Schema(description = "图标名称")
private String iconName;
@Schema(description = "图标类型")
private String iconType;
@Schema(description = "图标数据")
private String data;
@Schema(description = "图标视图")
private String view;
@Schema(description = "创建时间")
private LocalDateTime createdAt;
@Schema(description = "更新时间")
private LocalDateTime updatedAt;
}

View File

@ -0,0 +1,22 @@
package com.yj.earth.business.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class IconType {
@Schema(description = "主键")
private String id;
@Schema(description = "图标类型名称")
private String name;
@Schema(description = "父级节点ID")
private String parentId;
@Schema(description = "树形索引")
private Integer treeIndex;
@Schema(description = "创建时间")
private LocalDateTime createdAt;
@Schema(description = "更新时间")
private LocalDateTime updatedAt;
}

View File

@ -13,15 +13,15 @@ import java.time.LocalDateTime;
public class Military {
@Schema(description = "主键")
private String id;
@Schema(description = "模型类型ID")
private String modelTypeId;
@Schema(description = "模型名称")
private String modelName;
@Schema(description = "模型类型")
private String modelType;
@Schema(description = "模型数据")
@Schema(description = "军标类型ID")
private String militaryTypeId;
@Schema(description = "军标名称")
private String militaryName;
@Schema(description = "军标类型")
private String militaryType;
@Schema(description = "军标数据")
private String data;
@Schema(description = "模型视图")
@Schema(description = "军标视图")
private String view;
@Schema(description = "创建时间")
private LocalDateTime createdAt;

View File

@ -9,10 +9,12 @@ import java.time.LocalDateTime;
public class MilitaryType {
@Schema(description = "主键")
private String id;
@Schema(description = "模型类型名称")
@Schema(description = "军标类型名称")
private String name;
@Schema(description = "父级节点ID")
private String parentId;
@Schema(description = "树形索引")
private Integer treeIndex;
@Schema(description = "创建时间")
private LocalDateTime createdAt;
@Schema(description = "更新时间")

View File

@ -13,6 +13,8 @@ public class ModelType {
private String name;
@Schema(description = "父级节点ID")
private String parentId;
@Schema(description = "树状索引")
private Integer treeIndex;
@Schema(description = "创建时间")
private LocalDateTime createdAt;
@Schema(description = "更新时间")

View File

@ -34,7 +34,7 @@ public class CodeUtil {
}
// 传入需要生成代码的表名
Generation("military_library");
Generation("icon_library");
}
public static void Generation(String... tableName) {

View File

@ -41,7 +41,8 @@ public class JsonUtil {
}
try {
return objectMapper.readValue(json, new TypeReference<Map<String, Object>>() {});
return objectMapper.readValue(json, new TypeReference<Map<String, Object>>() {
});
} catch (Exception e) {
log.error("JSON转Map失败、JSON内容: {}", json, e);
return new HashMap<>(0);
@ -67,7 +68,7 @@ public class JsonUtil {
}
try {
// 使用ObjectMapperMap转换为指定类型对象
// 使用 ObjectMapperMap 转换为指定类型对象
return objectMapper.convertValue(map, clazz);
} catch (IllegalArgumentException e) {
log.error("Map转对象失败、目标类型: {}, Map内容: {}", clazz.getName(), map, e);
@ -86,4 +87,49 @@ public class JsonUtil {
return null;
}
}
/**
* 修改JSON字符串中指定键的值
*/
public static String modifyJsonValue(String json, String key, Object value) {
if (json == null || json.trim().isEmpty() || key == null || key.trim().isEmpty()) {
return json;
}
// 将JSON转换为Map
Map<String, Object> map = jsonToMap(json);
if (map == null) {
return json;
}
// 解析键、支持嵌套
String[] keyParts = key.split("\\.");
Map<String, Object> currentMap = map;
// 遍历键的各个部分、处理嵌套结构
for (int i = 0; i < keyParts.length; i++) {
String part = keyParts[i];
// 如果是最后一个部分、直接设置值
if (i == keyParts.length - 1) {
currentMap.put(part, value);
break;
}
// 如果不是最后一个部分、检查是否存在该键且对应的值是Map
Object nextObj = currentMap.get(part);
if (nextObj instanceof Map) {
currentMap = (Map<String, Object>) nextObj;
} else {
// 如果不存在或不是 Map、创建新的 Map
Map<String, Object> newMap = new HashMap<>();
currentMap.put(part, newMap);
currentMap = newMap;
}
}
// 将修改后的 Map 转换回 JSON
String result = mapToJson(map);
return result != null ? result : json;
}
}

View File

@ -305,6 +305,7 @@ public class SQLiteUtil {
"id" TEXT,
"name" TEXT,
"parent_id" TEXT,
"tree_index" INTEGER,
"created_at" TEXT,
"updated_at" TEXT,
PRIMARY KEY ("id")
@ -341,6 +342,7 @@ public class SQLiteUtil {
"id" TEXT,
"name" TEXT,
"parent_id" TEXT,
"tree_index" INTEGER,
"created_at" TEXT,
"updated_at" TEXT,
PRIMARY KEY ("id")
@ -365,4 +367,35 @@ public class SQLiteUtil {
executeDDL(modelPath, sql);
}
public static void initializationIcon(String iconPath) {
// 创建图标类型表
String sql = """
CREATE TABLE "icon_type" (
"id" TEXT,
"name" TEXT,
"parent_id" TEXT,
"tree_index" INTEGER,
"created_at" TEXT,
"updated_at" TEXT,
PRIMARY KEY ("id")
);
""";
executeDDL(iconPath, sql);
// 创建图标表
sql = """
CREATE TABLE "icon" (
"id" TEXT,
"icon_type_id" TEXT,
"icon_name" TEXT,
"icon_type" TEXT,
"data" TEXT,
"view" TEXT,
"created_at" TEXT,
"updated_at" TEXT,
PRIMARY KEY ("id")
);
""";
executeDDL(iconPath, sql);
}
}

View File

@ -49,6 +49,7 @@ public class DatabaseManager {
classes.add(FileInfo.class);
classes.add(ModelLibrary.class);
classes.add(MilitaryLibrary.class);
classes.add(IconLibrary.class);
classes.add(BusinessConfig.class);
ENTITY_CLASSES = Collections.unmodifiableList(classes);
}

View File

@ -0,0 +1,22 @@
package com.yj.earth.design;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class IconLibrary {
@Schema(description = "主键")
private String id;
@Schema(description = "图标库路径")
private String path;
@Schema(description = "图标库名称")
private String name;
@Schema(description = "是否启用")
private Integer isEnable;
@Schema(description = "创建时间")
private LocalDateTime createdAt;
@Schema(description = "更新时间")
private LocalDateTime updatedAt;
}

View File

@ -0,0 +1,12 @@
package com.yj.earth.dto.iconLibrary;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class AddIconTypeDto {
@Schema(description = "图标类型名称")
private String name;
@Schema(description = "父级节点ID")
private String parentId;
}

View File

@ -0,0 +1,12 @@
package com.yj.earth.dto.iconLibrary;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class CreateIconLibraryDto {
@Schema(description = "图标库文件名称")
private String name;
@Schema(description = "生成文件夹路径")
private String path;
}

View File

@ -0,0 +1,14 @@
package com.yj.earth.dto.iconLibrary;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class DragIconTypeDto {
@Schema(description = "图标类型ID")
private String id;
@Schema(description = "父级节点ID")
private String parentId;
@Schema(description = "树状索引")
private String treeIndex;
}

View File

@ -0,0 +1,12 @@
package com.yj.earth.dto.iconLibrary;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class UpdateIconTypeNameDto {
@Schema(description = "图标类型ID")
private String id;
@Schema(description = "图标类型名称")
private String name;
}

View File

@ -0,0 +1,14 @@
package com.yj.earth.dto.militaryLibrary;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class DragMilitaryTypeDto {
@Schema(description = "军标类型ID")
private String id;
@Schema(description = "父级节点ID")
private String parentId;
@Schema(description = "树状索引")
private String treeIndex;
}

View File

@ -0,0 +1,12 @@
package com.yj.earth.dto.militaryLibrary;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class UpdateMilitaryTypeNameDto {
@Schema(description = "军标类型ID")
private String id;
@Schema(description = "军标类型名称")
private String name;
}

View File

@ -0,0 +1,14 @@
package com.yj.earth.dto.modelLibrary;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class DragModelTypeDto {
@Schema(description = "模型类型ID")
private String id;
@Schema(description = "父级节点ID")
private String parentId;
@Schema(description = "树状索引")
private String treeIndex;
}

View File

@ -0,0 +1,12 @@
package com.yj.earth.dto.modelLibrary;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class UpdateModelTypeNameDto {
@Schema(description = "模型类型ID")
private String id;
@Schema(description = "模型类型名称")
private String name;
}

View File

@ -0,0 +1,12 @@
package com.yj.earth.dto.source;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class UpdateLevelDto {
@Schema(description = "资源ID")
private String id;
@Schema(description = "层级索引")
private Integer layerIndex;
}

View File

@ -0,0 +1,60 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
@SourceType("entityWall")
public class EntityWall {
private String id;
private String name;
private List<Position> positions;
private Map<String, Object> customView;
private boolean show;
private String color;
private double width;
private boolean noseToTail;
private double extrudedHeight;
private int cornerType;
private int material;
private Label label;
private Attribute attribute;
private String richTextContent;
@Data
public static class Position {
private double lng;
private double lat;
private double alt;
}
@Data
public static class Label {
private String text;
private boolean show;
private int fontSize;
private int fontFamily;
private String color;
private int lineWidth;
private int pixelOffset;
private List<String> backgroundColor;
private String lineColor;
private boolean scaleByDistance;
private int near;
private int far;
}
@Data
public static class Attribute {
private Link link;
}
@Data
public static class Link {
private List<Object> content;
}
}

View File

@ -0,0 +1,25 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.Map;
@Data
@SourceType("explosion")
public class Explosion {
private String id;
private String name;
private Position position;
private Map<String, Object> customView;
private boolean show;
private int size;
private boolean scaleByDistance;
@Data
public static class Position {
private double lng;
private double lat;
private double alt;
}
}

View File

@ -0,0 +1,28 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.Map;
@Data
@SourceType("fire")
public class Fire {
private String id;
private String name;
private Map<String, Object> customView;
private double lng;
private double lat;
private double alt;
private boolean show;
private String startColor;
private String endColor;
private double startScale;
private double endScale;
private int minimumParticleLife;
private int maximumParticleLife;
private double minimumSpeed;
private double maximumSpeed;
private int emissionRate;
private double particleSize;
}

View File

@ -0,0 +1,32 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
@SourceType("flyLine")
public class FlyLine {
private String id;
private String name;
private List<Position> positions;
private Map<String, Object> customView;
private boolean show;
private int pointNumber;
private int height;
private int heightDifference;
private int width;
private int duration;
private String color;
private double lineBackAlpha;
@Data
public static class Position {
private double lng;
private double lat;
private double alt;
}
}

View File

@ -0,0 +1,28 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.Map;
@Data
@SourceType("fountain")
public class Fountain {
private String id;
private String name;
private Map<String, Object> customView;
private double lng;
private double lat;
private double alt;
private boolean show;
private String startColor;
private String endColor;
private double startScale;
private double endScale;
private int minimumParticleLife;
private int maximumParticleLife;
private double minimumSpeed;
private double maximumSpeed;
private int emissionRate;
private double particleSize;
}

View File

@ -11,4 +11,5 @@ public class Layer {
private Boolean show;
private Integer alpha;
private Integer brightness;
private Integer layerIndex;
}

View File

@ -0,0 +1,66 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.List;
@Data
@SourceType("military")
public class Military {
private String id;
private String url;
private Position position;
private String host;
private boolean show;
private String name;
private String color;
private String richTextContent;
private int angle;
private Scale scale;
private Flipe flipe;
private Attribute attribute;
private String attributeType;
private Text text;
@Data
public static class Position {
private double lng;
private double lat;
private double alt;
}
@Data
public static class Scale {
private double x;
private double y;
}
@Data
public static class Flipe {
private boolean x;
private boolean y;
}
@Data
public static class Attribute {
private Link link;
}
@Data
public static class Link {
private List<Object> content;
}
@Data
public static class Text {
private String value;
private boolean show;
private int fontSize;
private String color;
private boolean scaleByDistance;
private int near;
private int far;
private Position position;
}
}

View File

@ -3,7 +3,7 @@ package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.Map;
import java.util.List;
@Data
@SourceType("model")
@ -12,12 +12,17 @@ public class Model {
private Position position;
private String name;
private boolean show;
private Rotate scale;
private String url;
private double maximumScale;
private Scale scale;
private String host;
private String url;
private int maximumScale;
private Rotate rotate;
private Map<String, Object> label;
private Label label;
private String color;
private int minimumPixelSize;
private boolean scaleByDistance;
private Attribute attribute;
private String richTextContent;
@Data
public static class Position {
@ -26,10 +31,43 @@ public class Model {
private double alt;
}
@Data
public static class Scale {
private double x;
private double y;
private double z;
}
@Data
public static class Rotate {
private double x;
private double y;
private double z;
}
@Data
public static class Label {
private String text;
private boolean show;
private int fontSize;
private int fontFamily;
private String color;
private int lineWidth;
private int pixelOffset;
private List<String> backgroundColor;
private String lineColor;
private boolean scaleByDistance;
private int near;
private int far;
}
@Data
public static class Attribute {
private Link link;
}
@Data
public static class Link {
private List<Object> content;
}
}

View File

@ -0,0 +1,28 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.Map;
@Data
@SourceType("smoke")
public class Smoke {
private String id;
private String name;
private Map<String, Object> customView;
private double lng;
private double lat;
private double alt;
private boolean show;
private String startColor;
private String endColor;
private double startScale;
private double endScale;
private int minimumParticleLife;
private int maximumParticleLife;
private double minimumSpeed;
private double maximumSpeed;
private int emissionRate;
private double particleSize;
}

View File

@ -4,6 +4,7 @@ import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.List;
import java.util.Map;
@SourceType("wallStereoscopic")
@Data
@ -20,6 +21,8 @@ public class WallStereoscopic {
private Label label;
private String instruct;
private String operatingPoint;
private String richTextContent;
private CustomView customView;
private Attribute attribute;
@Data
@ -53,5 +56,25 @@ public class WallStereoscopic {
public static class Link {
private List<Object> content;
}
@Data
public static class CustomView {
private AttackArrow.CustomView.Orientation orientation;
private AttackArrow.CustomView.RelativePosition relativePosition;
@Data
public static class Orientation {
private double heading;
private double pitch;
private double roll;
}
@Data
public static class RelativePosition {
private double lng;
private double lat;
private double alt;
}
}
}

View File

@ -0,0 +1,35 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.Map;
@Data
@SourceType("waterL")
public class WaterL {
private String id;
private String name;
private Map<String, Object> customView;
private Position start;
private Position end;
private boolean show;
private String startColor;
private String endColor;
private double startScale;
private double endScale;
private int minimumParticleLife;
private int maximumParticleLife;
private int emissionRate;
private double particleSize;
private double heading;
private double pitch;
private double speed;
@Data
public static class Position {
private double lng;
private double lat;
private double alt;
}
}

View File

@ -0,0 +1,47 @@
package com.yj.earth.vo;
import com.yj.earth.business.domain.IconType;
import com.yj.earth.business.domain.ModelType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class IconTypeVo {
@Schema(description = "主键")
private String id;
@Schema(description = "图标类型名称")
private String name;
@Schema(description = "父级节点ID")
private String parentId;
@Schema(description = "树形结构索引")
private Integer treeIndex;
@Schema(description = "创建时间")
private LocalDateTime createdAt;
@Schema(description = "更新时间")
private LocalDateTime updatedAt;
@Schema(description = "子节点列表")
private List<IconTypeVo> children = new ArrayList<>();
public IconTypeVo(IconType iconType) {
this.id = iconType.getId();
this.name = iconType.getName();
this.parentId = iconType.getParentId();
this.treeIndex = iconType.getTreeIndex();
this.createdAt = iconType.getCreatedAt();
this.updatedAt = iconType.getUpdatedAt();
}
}

View File

@ -0,0 +1,10 @@
package com.yj.earth.vo;
import com.yj.earth.business.domain.Icon;
import com.yj.earth.business.domain.Military;
import lombok.Data;
@Data
public class IconVo extends Icon {
private String iconTypeName;
}

View File

@ -18,12 +18,15 @@ public class MilitaryTypeVo {
@Schema(description = "主键")
private String id;
@Schema(description = "模型类型名称")
@Schema(description = "军标类型名称")
private String name;
@Schema(description = "父级节点ID")
private String parentId;
@Schema(description = "树形结构索引")
private Integer treeIndex;
@Schema(description = "创建时间")
private LocalDateTime createdAt;
@ -36,6 +39,7 @@ public class MilitaryTypeVo {
this.id = militaryType.getId();
this.name = militaryType.getName();
this.parentId = militaryType.getParentId();
this.treeIndex = militaryType.getTreeIndex();
this.createdAt = militaryType.getCreatedAt();
this.updatedAt = militaryType.getUpdatedAt();
}

View File

@ -6,5 +6,5 @@ import lombok.Data;
@Data
public class MilitaryVo extends Military {
private String modelTypeName;
private String militaryTypeName;
}

View File

@ -22,6 +22,9 @@ public class ModelTypeVo {
@Schema(description = "父级节点ID")
private String parentId;
@Schema(description = "树形结构索引")
private Integer treeIndex;
@Schema(description = "创建时间")
private LocalDateTime createdAt;
@ -34,6 +37,7 @@ public class ModelTypeVo {
this.id = modelType.getId();
this.name = modelType.getName();
this.parentId = modelType.getParentId();
this.treeIndex = modelType.getTreeIndex();
this.createdAt = modelType.getCreatedAt();
this.updatedAt = modelType.getUpdatedAt();
}