fix: 新增默认地图数据接口,地图组件的地图信息不再直接通过文件链接访问;地图组件新增部分属性,优化地图显示、配置

main
hong.yang 1 year ago
parent 1f19b28995
commit d18deb85e2

@ -104,6 +104,24 @@ public class ScreenMapChart extends Chart {
@ApiModelProperty(notes = "中心点y轴位置")
private Integer center2;
@ApiModelProperty(notes = "悬浮框数值标题")
private String tooltipTitle;
@ApiModelProperty(notes = "是否显示打点数值")
private Boolean showScatterValue;
@ApiModelProperty(notes = "打点图形")
private String scatterSymbol;
@ApiModelProperty(notes = "打点大小")
private Integer scatterSize;
@ApiModelProperty(notes = "高亮颜色")
private String emphasisColor;
}

@ -3,23 +3,28 @@ package com.gccloud.dataroom.core.module.map.controller;
import com.gccloud.common.permission.ApiPermission;
import com.gccloud.common.utils.BeanConvertUtils;
import com.gccloud.common.vo.R;
import com.gccloud.dataroom.core.module.map.dto.DataRoomMapRepeatDTO;
import com.gccloud.dataroom.core.module.map.vo.DataRoomMapDataVO;
import com.gccloud.dataroom.core.module.map.vo.DataRoomMapVO;
import com.gccloud.dataroom.core.module.map.vo.MapChildVO;
import com.gccloud.dataroom.core.module.map.dto.DataRoomMapDTO;
import com.gccloud.dataroom.core.module.map.dto.DataRoomMapRepeatDTO;
import com.gccloud.dataroom.core.module.map.dto.MapSearchDTO;
import com.gccloud.dataroom.core.module.map.entity.DataRoomMapEntity;
import com.gccloud.dataroom.core.module.map.service.IDataRoomMapService;
import com.gccloud.dataroom.core.module.map.vo.DataRoomMapDataVO;
import com.gccloud.dataroom.core.module.map.vo.DataRoomMapVO;
import com.gccloud.dataroom.core.module.map.vo.MapChildVO;
import com.gccloud.dataroom.core.permission.Permission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiSort;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
@ -156,5 +161,36 @@ public class DataRoomMapController {
}
@ApiPermission(permissions = {Permission.Map.VIEW})
@GetMapping("/default/{path}/{name}")
@ApiOperation(value = "默认地图", position = 130, notes = "从静态资源读取默认地图数据", produces = MediaType.APPLICATION_JSON_VALUE)
public String defaultMap(@PathVariable String path, @PathVariable String name) {
if (path.contains(".")) {
path = path.replaceAll("\\.", "/");
}
String filePath = "static/" + path + "/" + name + ".json";
// 从静态资源中获取默认地图
String json;
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
try {
org.springframework.core.io.Resource[] resources = resolver.getResources(filePath);
org.springframework.core.io.Resource resource = resources[0];
if (!resource.exists()) {
return "";
}
// 获得文件流因为在jar文件中不能直接通过文件资源路径拿到文件但是可以在jar包中拿到文件流
InputStream stream = resource.getInputStream();
StringBuilder buffer = new StringBuilder();
byte[] bytes = new byte[1024];
for (int n; (n = stream.read(bytes)) != -1; ) {
buffer.append(new String(bytes, 0, n));
}
json = buffer.toString();
} catch (IOException e) {
log.error(ExceptionUtils.getStackTrace(e));
return "";
}
return json;
}
}

Loading…
Cancel
Save