|
|
@@ -12,6 +12,7 @@ import com.siwei.apply.service.cadastre.impl.FzssFxrwrzHandleService;
|
|
|
import com.siwei.apply.utils.MdbUtil;
|
|
|
import com.siwei.apply.utils.ServiceFileUtil;
|
|
|
import com.siwei.common.core.exception.ServiceException;
|
|
|
+import com.siwei.common.core.utils.DateUtils;
|
|
|
import com.siwei.common.core.utils.uuid.IdUtils;
|
|
|
import com.vividsolutions.jts.geom.Geometry;
|
|
|
import com.vividsolutions.jts.geom.MultiPolygon;
|
|
|
@@ -109,32 +110,26 @@ public class ConvergeServiceImpl implements ConvergeService {
|
|
|
@Override
|
|
|
public void downConvergeFile(HttpServletResponse response, String ywh) {
|
|
|
try {
|
|
|
- // 1. 创建临时目录
|
|
|
- String tempDir = System.getProperty("java.io.tmpdir") + File.separator + IdUtils.fastSimpleUUID();
|
|
|
- File dir = new File(tempDir);
|
|
|
- if (!dir.exists()) dir.mkdirs();
|
|
|
- String shpName = "test"+IdUtils.fastSimpleUUID();
|
|
|
- File zipFile = new File(tempDir + File.separator + shpName + ".zip");
|
|
|
-
|
|
|
- File file1 = new File(tempDir + File.separator + shpName + ".shp");
|
|
|
- File file2 = new File(tempDir + File.separator + shpName + ".shx");
|
|
|
- if(!file1.exists()){
|
|
|
- file1.createNewFile();
|
|
|
+ String id = ywh;
|
|
|
+ Converge converge = convergeMapper.get(id);
|
|
|
+ if(Objects.isNull(converge)){
|
|
|
+ throw new ServiceException("获取不到当前任务:"+id);
|
|
|
}
|
|
|
- if(!file2.exists()){
|
|
|
- file2.createNewFile();
|
|
|
+ String path = converge.getFilePath();
|
|
|
+ Path dirPath = Paths.get(path);
|
|
|
+ if(!Files.exists(dirPath)){
|
|
|
+ throw new ServiceException("找不到汇交文件生成目录:"+id);
|
|
|
+ }
|
|
|
+ File zipFile = new File(dirPath + ".zip");
|
|
|
+ if(!zipFile.exists()){
|
|
|
+ ServiceFileUtil.zipByDir(dirPath.toFile(),null, zipFile);
|
|
|
}
|
|
|
-
|
|
|
- List<File> filesToZip = Arrays.asList(
|
|
|
- file1,
|
|
|
- file2
|
|
|
- );
|
|
|
- ServiceFileUtil.zipFiles(filesToZip, zipFile);
|
|
|
|
|
|
// 4. 设置响应头并下载
|
|
|
+ String downName = converge.getName()+IdUtils.fastSimpleUUID();
|
|
|
response.setContentType("application/zip");
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
- String fileName = shpName + ".zip";
|
|
|
+ String fileName = downName + ".zip";
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
|
|
|
|
|
try (FileInputStream fis = new FileInputStream(zipFile)) {
|
|
|
@@ -152,6 +147,7 @@ public class ConvergeServiceImpl implements ConvergeService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void operationConverge(String batch,String type) {
|
|
|
@@ -160,9 +156,9 @@ public class ConvergeServiceImpl implements ConvergeService {
|
|
|
throw new ServiceException("汇交入参,类型错误"+type);
|
|
|
}
|
|
|
if (StringUtils.isBlank(batch)) {
|
|
|
- batch = "123";
|
|
|
+ batch = DateUtils.dateTimeNow(DateUtils.YYYYMMDDHH);
|
|
|
+ //batch = "123";
|
|
|
}
|
|
|
-
|
|
|
Converge converge = new Converge();
|
|
|
converge.generateId();
|
|
|
String convergeId = converge.getId();
|
|
|
@@ -179,6 +175,7 @@ public class ConvergeServiceImpl implements ConvergeService {
|
|
|
fzssFxrwrzHandleService.insertFxrwrz(convergeId, "地籍库管理", "汇交任务创建", "info");
|
|
|
fzssFxrwrzHandleService.insertFxrwrz(convergeId, "地籍库管理", "汇交数据执行开始。。。", "info");
|
|
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
//todo 1.做一个vo类型的javabean 2.查询所有的表数据,进行判断去除空表数据。3.区分是否矢量。4.把当前文件处理成其它。
|
|
|
List<ConvergeRes> convergeTableList = new ArrayList<>();
|
|
|
Arrays.stream(ConvergeTableEnum.values()).forEach(e -> {
|
|
|
@@ -200,6 +197,8 @@ public class ConvergeServiceImpl implements ConvergeService {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ fzssFxrwrzHandleService.insertFxrwrz(convergeId, "地籍库管理", "数据已完成提取。。。。", "info");
|
|
|
+
|
|
|
String basePath = convergedir + converge.getName()+"/"+"012345赣江新区"+"/";
|
|
|
List<ConvergeRes> subConvergeTableList = new ArrayList<>();//衍生出的数据
|
|
|
|
|
|
@@ -238,12 +237,24 @@ public class ConvergeServiceImpl implements ConvergeService {
|
|
|
if(!subConvergeTableList.isEmpty()){
|
|
|
convergeTableList.addAll(subConvergeTableList);
|
|
|
}
|
|
|
+
|
|
|
+ fzssFxrwrzHandleService.insertFxrwrz(convergeId, "地籍库管理", "数据已完成目录构建。。。。", "info");
|
|
|
//这里进行数据汇交
|
|
|
try {
|
|
|
operationFileStrategy(convergeTableList);
|
|
|
} catch (Exception e) {
|
|
|
throw new ServiceException("汇交失败,数据错误"+e);
|
|
|
}
|
|
|
+
|
|
|
+ //更新状态
|
|
|
+ ConvergeUpdateVo updateVo = new ConvergeUpdateVo();
|
|
|
+ updateVo.setId(convergeId);
|
|
|
+ updateVo.setFilePath(convergedir + converge.getName());
|
|
|
+ updateVo.setFileCostTime(String.valueOf((System.currentTimeMillis()-startTime)/1000));
|
|
|
+ updateVo.setStatus("1");
|
|
|
+ updateVo.setReadMessage("创建成功");
|
|
|
+ convergeMapper.update(updateVo);
|
|
|
+ fzssFxrwrzHandleService.insertFxrwrz(convergeId, "地籍库管理", "汇交数据文件创建成功。", "info");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -467,5 +478,4 @@ public class ConvergeServiceImpl implements ConvergeService {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|