Commit d491b855 authored by yanzg's avatar yanzg

Excel导出功能

parent 0946be07
......@@ -5,6 +5,7 @@ import java.util.Date;
/**
* 内存缓存值
*
* @param <T>
* @author 颜佐光
*/
......@@ -13,7 +14,7 @@ public class MemoryCacheItem<T> {
/**
* 时间
*/
private Date date = new Date();
private long date = System.currentTimeMillis();
/**
* 名称
......@@ -29,15 +30,15 @@ public class MemoryCacheItem<T> {
* 激活数据
*/
public void active() {
date = new Date();
date = System.currentTimeMillis();
}
public Date getDate() {
return date;
return new Date(date);
}
public void setDate(Date date) {
this.date = date;
this.date = date.getTime();
}
public String getName() {
......
......@@ -41,6 +41,14 @@ public class RequestCacheResult {
return System.currentTimeMillis() - date.getTime();
}
/**
* 请求编号
* @return
*/
public String getReqID() {
return reqID;
}
/**
* 获取结果
*
......
......@@ -28,7 +28,7 @@ public final class HttpUploadHelper {
private static final Logger logger = LoggerFactory.getLogger(HttpUploadHelper.class);
public static final String tagName = "file";
public static final String TAG_NAME = "file";
public static final int CONNECT_TIME_OUT = 200000;
......@@ -53,9 +53,9 @@ public final class HttpUploadHelper {
if (responseEntity != null) {
String result = EntityUtils.toString(closeableHttpResponse.getEntity());
logger.debug("response result: {}", result);
EntityUtils.consume(responseEntity);
return result;
}
EntityUtils.consume(responseEntity);
closeableHttpResponse.close();
return JSON.toJSONString(initResponseError());
} catch (ClientProtocolException e) {
......@@ -96,7 +96,7 @@ public final class HttpUploadHelper {
private static HttpEntity initRequestEntity(String filePath) {
FileBody fileBody = new FileBody(new File(filePath));
StringBody stringBody = new StringBody("This is comment", ContentType.TEXT_PLAIN);
return MultipartEntityBuilder.create().addPart(tagName, fileBody).addPart("comment", stringBody).build();
return MultipartEntityBuilder.create().addPart(TAG_NAME, fileBody).addPart("comment", stringBody).build();
}
/**
......
package com.yanzuoguang.cloud.helper;
import com.yanzuoguang.cloud.vo.WebFileVo;
import com.yanzuoguang.util.contants.SystemContants;
import com.yanzuoguang.util.helper.StringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.FileSystemResource;
......@@ -22,6 +24,7 @@ import java.util.UUID;
/**
* 上传文件,下载文件操作类
*
* @author 颜佐光
*/
public final class WebFileHelper {
......@@ -147,8 +150,8 @@ public final class WebFileHelper {
public static WebFileVo upload(MultipartFile multipartFile, String savePath) {
String fileName = multipartFile.getOriginalFilename();
if (!savePath.endsWith("/") || !savePath.endsWith("\\")) {
savePath += "/";
if (!savePath.endsWith(SystemContants.SLASH) || !savePath.endsWith(SystemContants.UNSLASH)) {
savePath += SystemContants.SLASH;
}
webFileVo = new WebFileVo();
......@@ -210,7 +213,7 @@ public final class WebFileHelper {
private static String generateUUID() {
String str = String.valueOf(UUID.randomUUID());
while (str.indexOf(SEPARATE_HR) >= 0) {
str = str.replace(SEPARATE_HR, "");
str = str.replace(SEPARATE_HR, StringHelper.EMPTY);
}
return str;
}
......
......@@ -43,7 +43,7 @@ public abstract class BaseDaoSql {
/**
* 缓存的表结构和SQL语句
*/
protected static MemoryCache<TableSqlCache> Cache = new MemoryCache<>();
protected static MemoryCache<TableSqlCache> cache = new MemoryCache<>();
/**
* 获取数据库执行类
......@@ -67,11 +67,11 @@ public abstract class BaseDaoSql {
private void initTable() {
String cls = this.getClass().getName();
// 外检测,防止锁影响性能
this.table = Cache.get(cls);
this.table = cache.get(cls);
// 判断是否已经取到对象
if (this.table == null) {
this.table = new TableSqlCache();
Cache.put(cls, this.table);
cache.put(cls, this.table);
this.init();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment