提交 e7586d80 authored 作者: 张航's avatar 张航

添加了前端页面,下载器基本功能完成,后续继续完善

上级 33c32c64
...@@ -59,6 +59,12 @@ ...@@ -59,6 +59,12 @@
<version>1.7.25</version> <version>1.7.25</version>
</dependency> </dependency>
<!-- websocket -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
......
package com.comleader.ldmapdownload; package com.comleader.ldmapdownload;
import com.comleader.ldmapdownload.application.DownMapLv3; import com.comleader.ldmapdownload.config.WebSocketConfig;
import com.comleader.ldmapdownload.socket.DownLoadMapWebSocket;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication @SpringBootApplication
public class LdmapDownloadApplication { public class LdmapDownloadApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(LdmapDownloadApplication.class, args); ConfigurableApplicationContext run = SpringApplication.run(LdmapDownloadApplication.class, args);
// 解决WebSocket不能注入的问题
DownLoadMapWebSocket.setApplicationContext(run);
} }
} }
package com.comleader.ldmapdownload.bean;
import com.comleader.ldmapdownload.util.OperationTypeEnum;
import java.io.Serializable;
import java.util.Map;
/**
* @ClassName ResultData
* @Description: Socket交互类
* @Author zhanghang
* @Date 2020/4/10
* @Version V1.0
**/
public class SocketResultData implements Serializable {
private int type; // 数据类型
private String message; // 信息
private String status; // 状态
private Map<String,Object> body; // body信息
public SocketResultData(OperationTypeEnum operationTypeEnum) {
this.type = operationTypeEnum.getType();
this.status = operationTypeEnum.getStatus();
}
public SocketResultData(OperationTypeEnum operationTypeEnum,Map<String,Object> body) {
this.type = operationTypeEnum.getType();
this.status = operationTypeEnum.getStatus();
this.body = body;
}
public SocketResultData(OperationTypeEnum operationTypeEnum,String message,Map<String,Object> body) {
this.type = operationTypeEnum.getType();
this.status = operationTypeEnum.getStatus();
this.message = message;
this.body = body;
}
public SocketResultData(int type, String message, String status, Map<String, Object> body) {
this.type = type;
this.message = message;
this.status = status;
this.body = body;
}
public SocketResultData() {
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getStatus() {
return status;
}
public void setStatus(String staus) {
this.status = staus;
}
public Map<String, Object> getBody() {
return body;
}
public void setBody(Map<String, Object> body) {
this.body = body;
}
}
package com.comleader.ldmapdownload.config;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* @ClassName WebSocketConfig
* @Description: WebSocket配置类
* @Author zhanghang
* @Date 2020/3/31
* @Version V1.0
**/
@Component
public class WebSocketConfig {
/**
* @descrip: WebSoeckt配置类
* @param: []
* @return: org.springframework.web.com.comleader.ldmapdownload.socket.server.standard.ServerEndpointExporter
* @author: zhanghang
* @date: 2020/3/31
**/
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}
package com.comleader.ldmapdownload.application; package com.comleader.ldmapdownload.service;
import com.comleader.ldmapdownload.util.CLStringUtil; import com.comleader.ldmapdownload.util.CLStringUtil;
import com.comleader.ldmapdownload.util.HttpUtil; import com.comleader.ldmapdownload.util.HttpUtil;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
import java.util.concurrent.Future;
/** /**
* @ClassName DownMapLv1 * @ClassName DownMapLv1
......
package com.comleader.ldmapdownload.application; package com.comleader.ldmapdownload.service;
import com.comleader.ldmapdownload.util.CLStringUtil; import com.comleader.ldmapdownload.util.CLStringUtil;
import com.comleader.ldmapdownload.util.HttpUtil; import com.comleader.ldmapdownload.util.HttpUtil;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
......
package com.comleader.ldmapdownload.application; package com.comleader.ldmapdownload.service;
import com.comleader.ldmapdownload.util.CLStringUtil; import com.comleader.ldmapdownload.util.CLStringUtil;
import com.comleader.ldmapdownload.util.HttpUtil; import com.comleader.ldmapdownload.util.HttpUtil;
......
package com.comleader.ldmapdownload.application; package com.comleader.ldmapdownload.service;
import com.comleader.ldmapdownload.util.CLStringUtil; import com.comleader.ldmapdownload.util.CLStringUtil;
import com.comleader.ldmapdownload.util.HttpUtil; import com.comleader.ldmapdownload.util.HttpUtil;
......
package com.comleader.ldmapdownload.application; package com.comleader.ldmapdownload.service;
import com.comleader.ldmapdownload.util.CLStringUtil;
import com.comleader.ldmapdownload.util.HttpUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
...@@ -10,12 +8,6 @@ import org.springframework.context.annotation.PropertySource; ...@@ -10,12 +8,6 @@ import org.springframework.context.annotation.PropertySource;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.*;
/** /**
* @ClassName DownMap * @ClassName DownMap
* @Description: 下载地图的启动类 * @Description: 下载地图的启动类
......
package com.comleader.ldmapdownload.socket;
import cn.hutool.json.JSONUtil;
import com.comleader.ldmapdownload.bean.SocketResultData;
import com.comleader.ldmapdownload.service.DownMapService;
import com.comleader.ldmapdownload.util.CLStringUtil;
import com.comleader.ldmapdownload.util.HttpUtil;
import com.comleader.ldmapdownload.util.OperationTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
/**
* @ClassName WebSocket
* @Description: WebSocket服务类,统一功能: 0: 代表请求下载文件校验信息,1代表
* @Author zhanghang
* @Date 2020/3/31
* @Version V1.0
**/
/**
* @ServerEndpoint 这个注解有什么作用?
* <p>
* 这个注解用于标识作用在类上,它的主要功能是把当前类标识成一个WebSocket的服务端
* 注解的值用户客户端连接访问的URL地址
*/
@Slf4j
@Component
@ServerEndpoint("/downLoadMapSocket/{name}")
public class DownLoadMapWebSocket {
private Session session;// 与某个客户端连接对话,需要通过他来向客户端发送消息
private String name; // 当前连接的客户端的用户名
/*
* @description: websocket无法通过@Autowried注入Service,需要通过如下方式进行解决
**/
//此处是解决无法注入的关键
private static ApplicationContext applicationContext;
//要注入的service
private DownMapService downMapService;
public static void setApplicationContext(ApplicationContext applicationContext) {
DownLoadMapWebSocket.applicationContext = applicationContext;
}
/**
* @param session
* @param name
* @description: OnOpen连接打开时触发的方法
* @return: void
* @author: zhanghang
* @date: 2020/4/1
**/
@OnOpen
public void OnOpen(Session session, @PathParam(value = "name") String name) {
this.session = session;
this.name = name;
initDownLoad();
DownMapService.isBusy = false;
// 通过applicationContext注入bean
this.downMapService = applicationContext.getBean(DownMapService.class);
// name是用来表示唯一客户端,如果需要指定发送,需要指定发送通过name来区分
SocketResultData socketResultData = new SocketResultData(OperationTypeEnum.SYS_SUCCESS, "WebSocket连接成功", null);
AppointSending(JSONUtil.toJsonStr(socketResultData));
// 发送基本信息
SocketResultData resultData = new SocketResultData(OperationTypeEnum.DOWNLOAD_BASEPATH, CLStringUtil.BASE_PATH, null);
AppointSending(JSONUtil.toJsonStr(resultData));
log.info("[WebSocket] 连接成功,当前连接用户:={}");
}
/**
* @param
* @description: 断开连接触发的方法
* @return: void
* @author: zhanghang
* @date: 2020/4/1
**/
@OnClose
public void OnClose() {
DownMapService.stoped = true;
log.info("[WebSocket] 退出成功");
}
/**
* @param message: 格式 json: { type : 0 , body: {}}
* @description: 接收消息
* @return: void
* @author: zhanghang
* @date: 2020/4/1
**/
@OnMessage
public void OnMessage(String message) {
try {
log.info("[WebSocket] 收到消息:{}", message);
// 执行下载的专用线程
Thread thread = null;
SocketResultData socketData = JSONUtil.toBean(message, SocketResultData.class);
// 校验下载信息(操作类型为0)
if (socketData.getType() == OperationTypeEnum.DOWNLOAD_READY.getType()) {
if (DownMapService.isBusy){
// 线程未执行完成
return;
}
AppointSending(JSONUtil.toJsonStr(new SocketResultData(OperationTypeEnum.SYS_SUCCESS,"准备下载",null)));
Map<String, Object> body = downMapService.readyDownLoad(socketData.getBody());
// 校验信息结果
SocketResultData resultData = new SocketResultData(OperationTypeEnum.DOWNLOAD_READY,body);
// 返回结果
AppointSending(JSONUtil.toJsonStr(resultData));
}
// 停止下载(5)
if (socketData.getType() == OperationTypeEnum.DOWNLOAD_STOP.getType()) {
if (!DownMapService.isBusy){
// 线程未执行完成
AppointSending(JSONUtil.toJsonStr(new SocketResultData(OperationTypeEnum.SYS_SUCCESS, "暂无下载任务", null)));
return;
}
AppointSending(JSONUtil.toJsonStr(new SocketResultData(OperationTypeEnum.SYS_SUCCESS, "正在停止...", null)));
DownMapService.stoped = true;
DownMapService.finished = true;
SocketResultData resultData = new SocketResultData(OperationTypeEnum.SYS_SUCCESS, "停止下载...", null);
// 返回结果
AppointSending(JSONUtil.toJsonStr(resultData));
}
// 操作类型为1,开始下载
if (socketData.getType() == OperationTypeEnum.DOWNLOAD_MAP.getType()){
if (DownMapService.isBusy){
// 线程未执行完成
return;
}
initDownLoad();
// 下载和发送地图(由于是单机,只有一个session,所以需要开启一个线程执行,否则执行期间服务器接收不到其他命令)
thread = new Thread(() -> {
try {
downLoadMap(socketData,session);
} catch (Exception e) {
e.printStackTrace();
AppointSending(JSONUtil.toJsonStr(new SocketResultData(OperationTypeEnum.SYS_ERROR,"系统异常!!",null)));
}
});
thread.start();
}
} catch (Exception e) {
AppointSending(JSONUtil.toJsonStr(new SocketResultData(OperationTypeEnum.SYS_ERROR,"系统异常!!",null)));
e.printStackTrace();
}
}
private void downLoadMap(SocketResultData socketData, Session session) throws Exception {
// 创建定时任务向前端发送速度\进度
Timer speedTimer = new Timer();
// 每隔三秒汇报一次
speedTimer.schedule(new TimerTask() {
@Override
public void run() {
// 发送了停止命令或者已经完成
if (DownMapService.stoped || DownMapService.finished){
speedTimer.cancel();
return;
}
// 发送速度
SocketResultData speed = new SocketResultData(OperationTypeEnum.SYS_SUCCESS, "下载速度"+DownMapService.speed + "张/s", null);
AppointSending(JSONUtil.toJsonStr(speed));
}
},1000,1000);
// 创建定时任务向前端发送进度
Timer scheduleTimer = new Timer();
// 每隔0.2秒汇报一次
scheduleTimer.schedule(new TimerTask() {
@Override
public void run() {
// 发送了停止命令或者已经完成
if (DownMapService.stoped || DownMapService.finished){
DownMapService.isBusy = false;
SocketResultData schedule = new SocketResultData(OperationTypeEnum.DOWNLOAD_SCHEDULE, 100+"", null);
AppointSending(JSONUtil.toJsonStr(schedule));
scheduleTimer.cancel();
return;
}
// 发送进度
SocketResultData schedule = new SocketResultData(OperationTypeEnum.DOWNLOAD_SCHEDULE, DownMapService.schedule+"", null);
AppointSending(JSONUtil.toJsonStr(schedule));
}
},200,200);
// 发送执行结果(这里是异步阻塞的,会等待downLoad执行完成)
Map<String, Object> resBody = downMapService.downLoad(socketData.getBody(),session);
String msg = "下载完成,总用时"+resBody.get("totalTime")+",总大小"+ resBody.get("totalSize")+
",总用时"+resBody.get("totalTime")+",失败个数"+resBody.get("falidNum")+"(可选择非覆盖重新下载!)";
SocketResultData resultData = new SocketResultData(OperationTypeEnum.SYS_SUCCESS, msg, null);
AppointSending(JSONUtil.toJsonStr(resultData));
// 通知下载完成
AppointSending(JSONUtil.toJsonStr(new SocketResultData(OperationTypeEnum.DOWNLOAD_FINISHED)));
}
private static void initDownLoad() {
HttpUtil.totalSize = 0;
DownMapService.finished =false;
DownMapService.stoped =false;
DownMapService.speed = 0;
DownMapService.schedule = 0;
DownMapService.countSuccessFile = 0;
DownMapService.isBusy = true;
}
/**
* @param message
* @description: 指定发送
* @return: void
* @author: zhanghang
* @date: 2020/3/31
**/
private void AppointSending(String message) {
try {
session.getBasicRemote().sendText(message);
} catch (IOException e) {
e.printStackTrace();
}
}
public Session getSession() {
return session;
}
}
...@@ -2,6 +2,9 @@ package com.comleader.ldmapdownload.util; ...@@ -2,6 +2,9 @@ package com.comleader.ldmapdownload.util;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.math.MathUtil; import cn.hutool.core.math.MathUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.datatype.jsr310.DecimalUtils; import com.fasterxml.jackson.datatype.jsr310.DecimalUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
...@@ -10,6 +13,7 @@ import org.springframework.stereotype.Component; ...@@ -10,6 +13,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.io.File; import java.io.File;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Map;
/** /**
* @ClassName LDStringUtil * @ClassName LDStringUtil
...@@ -40,7 +44,7 @@ public class CLStringUtil { ...@@ -40,7 +44,7 @@ public class CLStringUtil {
//当容器实例化当前受管Bean时@PostConstruct注解的方法会被自动触发,借此来实现静态变量初始化 //当容器实例化当前受管Bean时@PostConstruct注解的方法会被自动触发,借此来实现静态变量初始化
@PostConstruct @PostConstruct
public void init(){ public void init() {
this.BASE_PATH = BASE_PATH_CONFIG; this.BASE_PATH = BASE_PATH_CONFIG;
this.BASE_URL = BASE_URL_CONFIG; this.BASE_URL = BASE_URL_CONFIG;
this.MAP_TYPE = MAP_TYPE_CONFIG; this.MAP_TYPE = MAP_TYPE_CONFIG;
...@@ -58,10 +62,10 @@ public class CLStringUtil { ...@@ -58,10 +62,10 @@ public class CLStringUtil {
**/ **/
public static File getFullFile(Integer z, Integer x, Integer y) { public static File getFullFile(Integer z, Integer x, Integer y) {
String fullFileName; String fullFileName;
if (MAP_TYPE == "ArcGIS"){ if (MAP_TYPE == "ArcGIS") {
fullFileName = getArcGISFullFile(z,x,y); fullFileName = getArcGISFullFile(z, x, y);
}else { } else {
fullFileName = BASE_PATH + z + File.separator + x + File.separator + y + ".png"; fullFileName = BASE_PATH + File.separator + z + File.separator + x + File.separator + y + ".png";
} }
return FileUtil.file(fullFileName); return FileUtil.file(fullFileName);
} }
...@@ -77,13 +81,13 @@ public class CLStringUtil { ...@@ -77,13 +81,13 @@ public class CLStringUtil {
**/ **/
public static File getFullFileNotExist(Integer z, Integer x, Integer y) { public static File getFullFileNotExist(Integer z, Integer x, Integer y) {
String fullFileName; String fullFileName;
if (MAP_TYPE == "ArcGIS"){ if (MAP_TYPE == "ArcGIS") {
fullFileName = getArcGISFullFile(z,x,y); fullFileName = getArcGISFullFile(z, x, y);
}else { } else {
fullFileName = BASE_PATH + z + File.separator + x + File.separator + y + ".png"; fullFileName = BASE_PATH + File.separator + z + File.separator + x + File.separator + y + ".png";
} }
File file = new File(fullFileName); File file = new File(fullFileName);
if (file.exists()){ if (file.exists()) {
return null; return null;
} }
return FileUtil.file(fullFileName); return FileUtil.file(fullFileName);
...@@ -100,23 +104,23 @@ public class CLStringUtil { ...@@ -100,23 +104,23 @@ public class CLStringUtil {
* @date: 2020/4/2 * @date: 2020/4/2
**/ **/
private static String getArcGISFullFile(Integer z, Integer x, Integer y) { private static String getArcGISFullFile(Integer z, Integer x, Integer y) {
String l = "L" + String.format("%02d",z); String l = "L" + String.format("%02d", z);
String r = "R" + makePath(y); String r = "R" + makePath(y);
String c = "C" + makePath(x); String c = "C" + makePath(x);
String fullFileName = BASE_PATH + l + File.separator + r + File.separator + c + ".png"; String fullFileName = BASE_PATH + File.separator + l + File.separator + r + File.separator + c + ".png";
return fullFileName; return fullFileName;
} }
/** /**
* @description: getImgUrl * @param z
* @param z * @param x
* @param x * @param y
* @param y * @description: getImgUrl
* @return: java.lang.String * @return: java.lang.String
* @author: zhanghang * @author: zhanghang
* @date: 2020/4/2 * @date: 2020/4/2
**/ **/
public static String getImgUrl(Integer z, Integer x, Integer y) { public static String getImgUrl(Integer z, Integer x, Integer y) {
String url = BASE_URL.replaceAll("\\{x\\}", String.valueOf(x)).replaceAll("\\{y\\}", String.valueOf(y)) String url = BASE_URL.replaceAll("\\{x\\}", String.valueOf(x)).replaceAll("\\{y\\}", String.valueOf(y))
.replaceAll("\\{z\\}", String.valueOf(z)); .replaceAll("\\{z\\}", String.valueOf(z));
...@@ -127,42 +131,104 @@ public class CLStringUtil { ...@@ -127,42 +131,104 @@ public class CLStringUtil {
private static String makePath(int num) { private static String makePath(int num) {
String str = Integer.toHexString(num); String str = Integer.toHexString(num);
//ArcGIS行列都是8位长度 //ArcGIS行列都是8位长度
while(str.length() < 8) { while (str.length() < 8) {
str = "0" + str; str = "0" + str;
} }
return str; return str;
} }
/** /**
* @description: 下载文件的M级大小 * @param
* @param * @description: 下载文件的字节大小
* @return: java.lang.String * @return: java.lang.String
* @author: zhanghang * @author: zhanghang
* @date: 2020/4/9 * @date: 2020/4/9
**/ **/
public static String getDownTotalSizeUnitsM(){ public static String getDownTotalSize() {
File file = FileUtil.file(BASE_PATH); double size = HttpUtil.totalSize / 1024.0;
if (file != null){ if (size < 1024) {
long size = FileUtil.size(file); return new DecimalFormat("#,##").format(size) + "K";
return new DecimalFormat("#.00").format(size/1024.0/1024.0) + " M"; } else if (size < 1024 * 1024) {
size = size / 1024.0;
return new DecimalFormat("#,##").format(size) + "M";
} else if (size < 1024 * 1024 * 1024) {
size = size / 1024.0 / 1024.0;
return new DecimalFormat("#,##").format(size) + "G";
} else {
size = size / 1024.0 / 1024.0 / 1024.0;
return new DecimalFormat("#,##").format(size) + "T";
} }
return null;
} }
/** /**
* @description: 下载文件的字节大小 * @param body
* @param * @description: 计算出文件总个数
* @return: java.lang.String * @return: int
* @author: zhanghang * @author: zhanghang
* @date: 2020/4/9 * @date: 2020/4/10
**/ **/
public static String getDownTotalSizeUnitsB(){ public static int countFileNum(Map<String, Object> body) {
File file = FileUtil.file(BASE_PATH); JSONObject jsonParam = JSONUtil.parseFromMap(body);
if (file != null){ JSONArray level = jsonParam.getJSONArray("level");
long size = FileUtil.size(file); Double minLng = jsonParam.getDouble("minLng");
return new DecimalFormat("#,###").format(size) + " 字节"; Double minLat = jsonParam.getDouble("minLat");
Double maxLng = jsonParam.getDouble("maxLng");
Double maxLat = jsonParam.getDouble("maxLat");
int count = 0;
for (int i = 0; i < level.size(); i++) {
Integer z = Integer.valueOf(level.get(i).toString());
//四个坐标划定了一个矩形区域
int minY = getOSMTileYFromLatitude(maxLat, z);
int maxY = getOSMTileYFromLatitude(minLat, z);
int minX = getOSMTileXFromLongitude(minLng, z);
int maxX = getOSMTileXFromLongitude(maxLng, z);
count += (maxX - minX) * (maxY - minY);
} }
return null; return count;
}
/**
* @param countFileNum
* @description: 预估文件总大小
* @return: int
* @author: zhanghang
* @date: 2020/4/10
**/
public static String countFileSize(int countFileNum) {
// 平均每个图片20K
long countSize = countFileNum * 20;
if (countSize < 1024) {
return countSize + "K";
} else if (countSize < 1024 * 1024) {
countSize = countSize / 1024;
return countSize + "M";
} else {
countSize = countSize / 1024 / 1024;
return countSize + "G";
}
}
/**
* 根据经度获取切片规范下的行号
*
* @param lon
* @param zoom
* @return
*/
public static int getOSMTileXFromLongitude(double lon, int zoom) {
return (int) (Math.floor((lon + 180) / 360 * Math.pow(2, zoom)));
}
/**
* 根据纬度获取切片规范下的列号
*
* @param lat
* @param zoom
* @return
*/
public static int getOSMTileYFromLatitude(double lat, int zoom) {
return (int) (Math.floor((1 - Math.log(Math.tan(lat * Math.PI / 180) + 1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, zoom)));
} }
} }
...@@ -37,6 +37,8 @@ public class HttpUtil { ...@@ -37,6 +37,8 @@ public class HttpUtil {
// 自定义一个静态载体,用来承载Spring管理的类 // 自定义一个静态载体,用来承载Spring管理的类
private static RequestConfig staticRequestConfig; private static RequestConfig staticRequestConfig;
public static volatile int totalSize = 0;
//当容器实例化当前受管Bean时@PostConstruct注解的方法会被自动触发,借此来实现静态变量初始化 //当容器实例化当前受管Bean时@PostConstruct注解的方法会被自动触发,借此来实现静态变量初始化
@PostConstruct @PostConstruct
...@@ -73,6 +75,8 @@ public class HttpUtil { ...@@ -73,6 +75,8 @@ public class HttpUtil {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
// 累加总文件大小
totalSize += FileUtil.size(file);
} }
} }
......
package com.comleader.ldmapdownload.util;
/**
* @ClassName OperationType
* @Description: 操作类型枚举
* @Author zhanghang
* @Date 2020/4/10
* @Version V1.0
**/
public enum OperationTypeEnum {
DOWNLOAD_READY(0, "success"), // 下载内容信息确认
DOWNLOAD_MAP(1, "success"), // 开始下载
SYS_SUCCESS(2, "success"), // 系统交互的消息(成功)
SYS_ERROR(2, "error"), // 系统交互的消息(失败)
DOWNLOAD_SCHEDULE(3, "success"), // 下载的进度
DOWNLOAD_FINISHED(4, "success"), // 通知下载完成
DOWNLOAD_STOP(5, "success"), // 停止下载的命令
DOWNLOAD_BASEPATH(6, "success"); // 停止下载的命令
Integer type;
String status;
OperationTypeEnum(Integer type, String status) {
this.type = type;
this.status = status;
}
public Integer getType() {
return type;
}
public String getStatus() {
return status;
}}
server: server:
port: 8081 port: 9000
\ No newline at end of file \ No newline at end of file
# 下载地图的保存路径 # 下载地图的保存路径
file.basepath=E:/gaode-map/jinshui/ file.basepath=E:/em-downloadmap
# 下载地图的地址 # 下载地图的地址
#天地图服务器t0-t8间选一个 #天地图服务器t0-t8间选一个
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论