|
@@ -1,5 +1,7 @@
|
|
|
package com.fd.server.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -196,19 +198,24 @@ public class VectorServerImpl extends BaseServerImpl implements VectorServer {
|
|
|
|
|
|
|
|
|
// 判断目录重名
|
|
|
- List<FileEntity> en = fileRepository.findByDirectoryAndResStatus(directoryName, 0);
|
|
|
+// List<FileEntity> en = fileRepository.findByDirectoryAndResStatus(directoryName, 0);
|
|
|
+//
|
|
|
+// if (en.size() > 0) {
|
|
|
+// return new R(51007, MsgCode.E51007);
|
|
|
+// }
|
|
|
|
|
|
- if (en.size() > 0) {
|
|
|
- return new R(51007, MsgCode.E51007);
|
|
|
- }
|
|
|
+ // 拼接唯一文件名
|
|
|
+// long timeMillis = System.currentTimeMillis();
|
|
|
+ String time = DateUtil.format(new DateTime(), "yyyyMMdd_HHmmssSSS");
|
|
|
|
|
|
// 创建目录路径
|
|
|
- String filePath = INPUT_FILE_PATH + directoryName + File.separator;
|
|
|
+ String filePath = INPUT_FILE_PATH + time + File.separator;
|
|
|
FileUtils.createDir(filePath);
|
|
|
|
|
|
FileEntity entity = new FileEntity();
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
+ StringBuilder sbTimeName = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
@@ -219,22 +226,25 @@ public class VectorServerImpl extends BaseServerImpl implements VectorServer {
|
|
|
// 记录shp 信息
|
|
|
boolean shpFlag = false;
|
|
|
String shpName = "";
|
|
|
+ String shpTimeName = "";
|
|
|
+
|
|
|
+ String timeName = null;
|
|
|
|
|
|
if (files != null && files.length > 0) {
|
|
|
for (MultipartFile f : files) {
|
|
|
String filename = f.getOriginalFilename();
|
|
|
-
|
|
|
// 文件是否包含中文字符
|
|
|
- if (RegexUtils.regexChinese(filename)) {
|
|
|
- return new R(51005, MsgCode.E51005);
|
|
|
- }
|
|
|
+// if (RegexUtils.regexChinese(filename)) {
|
|
|
+// return new R(51005, MsgCode.E51005);
|
|
|
+// }
|
|
|
|
|
|
log.info("fileName : {}", filename);
|
|
|
- String s = StringUtils.substringAfterLast(filename, ".");
|
|
|
+ // 后缀名
|
|
|
+ String suffix = StringUtils.substringAfterLast(filename, ".");
|
|
|
|
|
|
// 判断后缀名,需要包含这以下四个
|
|
|
String [] suffixCheck = {"dbf","shp","shx","prj"};
|
|
|
- if (Arrays.asList(suffixCheck).contains(s)) {
|
|
|
+ if (Arrays.asList(suffixCheck).contains(suffix)) {
|
|
|
suffixCheckInt += 1;
|
|
|
|
|
|
// 判断前缀名字是否一致
|
|
@@ -244,17 +254,19 @@ public class VectorServerImpl extends BaseServerImpl implements VectorServer {
|
|
|
|
|
|
|
|
|
|
|
|
- if ("shp".equals(s)) {
|
|
|
+ timeName = time + "." + suffix;
|
|
|
+ if ("shp".equals(suffix)) {
|
|
|
shpFlag = true;
|
|
|
shpName = filename;
|
|
|
+ shpTimeName = timeName;
|
|
|
}
|
|
|
-
|
|
|
try {
|
|
|
- FileUtils.bigFileWrite(f.getInputStream(), filePath + filename);
|
|
|
+ FileUtils.bigFileWrite(f.getInputStream(), filePath + timeName);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
sb.append(filename).append(",");
|
|
|
+ sbTimeName.append(timeName).append(",");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -278,9 +290,10 @@ public class VectorServerImpl extends BaseServerImpl implements VectorServer {
|
|
|
|
|
|
OutputFileEntity outputFile = new OutputFileEntity();
|
|
|
if (shpFlag) {
|
|
|
- entity.setDirectory(directoryName);
|
|
|
- entity.setFileName(sb.toString());
|
|
|
- entity.setFileUrl(filePath + shpName);
|
|
|
+ entity.setDirectory(time);
|
|
|
+ entity.setOriginalName(sb.toString());
|
|
|
+ entity.setFileName(sbTimeName.toString());
|
|
|
+ entity.setFileUrl(filePath + shpTimeName);
|
|
|
entity.setCreateTime(new Date());
|
|
|
entity.setUpdateTime(new Date());
|
|
|
entity.setType(TypeCode.FILE_TYPE_VECTOR);
|
|
@@ -291,7 +304,8 @@ public class VectorServerImpl extends BaseServerImpl implements VectorServer {
|
|
|
outputFile.setUploadId(entity.getId());
|
|
|
outputFile.setUploadPath(entity.getFileUrl());
|
|
|
outputFile.setDirectory(entity.getDirectory());
|
|
|
- outputFile.setFileName(shpName);
|
|
|
+ outputFile.setFileName(shpTimeName);
|
|
|
+ outputFile.setOriginalName(shpName);
|
|
|
outputFile.setStatus(2);
|
|
|
outputFile.setType(TypeCode.FILE_TYPE_VECTOR);
|
|
|
outputFile.setCoord(entity.getCoord());
|