|
@@ -30,6 +30,7 @@ import java.sql.PreparedStatement;
|
|
|
import java.sql.Statement;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -52,30 +53,38 @@ public class ArchiveOfflineVersionInfoServiceImpl extends BaseServiceImpl<Archiv
|
|
|
@Override
|
|
|
@Async
|
|
|
public void packData(Long projectId) throws Exception {
|
|
|
- String localUrl = "/www/wwwroot/localClient/local_archives/alilib";
|
|
|
- String packUrl = "/www/wwwroot/localClient";
|
|
|
- String zipUrl = "/www/wwwroot/localClient.zip";
|
|
|
+// String localUrl = "/www/wwwroot/localClient/local_archives/alilib";
|
|
|
+// String packUrl = "/www/wwwroot/localClient";
|
|
|
+// String zipUrl = "/www/wwwroot/localClient.zip";
|
|
|
+ String localUrl = "/www/wwwroot/Users/hongchuangyanfa/Desktop/localArchive/localClient/local_archives/alilib";
|
|
|
+ String packUrl = "/www/wwwroot/Users/hongchuangyanfa/Desktop/localArchive/localClient";
|
|
|
+ String zipUrl = "/www/wwwroot/Users/hongchuangyanfa/Desktop/localArchive/"+projectId;
|
|
|
//清空url的文件夹
|
|
|
CommonUtil.deleteDir(localUrl);
|
|
|
//导入档案到sqlite
|
|
|
this.autoToSqlite(projectId);
|
|
|
+ System.out.println("导入档案到sqlite");
|
|
|
//导入归档树到sqlite
|
|
|
this.contractToSqlite(projectId);
|
|
|
+ System.out.println("导入归档树到sqlite");
|
|
|
//导入档案文件
|
|
|
this.fileToSqlite(projectId);
|
|
|
+ System.out.println("导入档案文件");
|
|
|
//打包文件
|
|
|
- CommonUtil.packageZip(packUrl);
|
|
|
+ CommonUtil.packageZip(packUrl,zipUrl);
|
|
|
+ System.out.println("打包文件");
|
|
|
//上传文件
|
|
|
- File zipFile = ResourceUtil.getFile(zipUrl);
|
|
|
+// File zipFile = ResourceUtil.getFile(zipUrl);
|
|
|
//BladeFile bladeFile = ossBuilder.template().putFile("localClient.zip",new FileInputStream(zipFile));
|
|
|
- BladeFile bladeFile = newIOSSClient.uploadFile("localClient.zip", zipUrl);
|
|
|
+// BladeFile bladeFile = newIOSSClient.uploadFile("localClient.zip", zipUrl);
|
|
|
ArchiveOfflineVersionInfo info = new ArchiveOfflineVersionInfo();
|
|
|
info.setId(SnowFlakeUtil.getId());
|
|
|
- info.setFileUrl(bladeFile.getLink());
|
|
|
- info.setFileName(bladeFile.getOriginalName());
|
|
|
+ info.setFileUrl("http://fileinfo.hczcxx.cn/localArchive/"+projectId+"/localArchive.zip");
|
|
|
+ info.setFileName("localArchive.zip");
|
|
|
info.setUploadDate(LocalDateTime.now());
|
|
|
info.setProjectId(projectId);
|
|
|
- info.setFileSize(CommonUtil.getResourceLength(bladeFile.getLink()) + "");
|
|
|
+ File file = new File(zipUrl+"/localArchive.zip");
|
|
|
+ info.setFileSize(file.length()+"");
|
|
|
infoMapper.insert(info);
|
|
|
|
|
|
}
|
|
@@ -83,7 +92,7 @@ public class ArchiveOfflineVersionInfoServiceImpl extends BaseServiceImpl<Archiv
|
|
|
public void fileToSqlite(Long projectId) throws Exception {
|
|
|
List<ArchiveFile> list = fileClient.getListByProjectId(projectId);
|
|
|
if (list != null && list.size() > 0) {
|
|
|
- String localUrl = "/www/wwwroot/localClient/local_archives/alilib/";
|
|
|
+ String localUrl = "/www/wwwroot/Users/hongchuangyanfa/Desktop/localArchive/localClient/local_archives/alilib/";
|
|
|
for (ArchiveFile file : list) {
|
|
|
if (StringUtil.isNotBlank(file.getFileUrl())) {
|
|
|
String fileUrl = file.getFileUrl();
|
|
@@ -111,8 +120,8 @@ public class ArchiveOfflineVersionInfoServiceImpl extends BaseServiceImpl<Archiv
|
|
|
statement.execute("DELETE FROM u_archive_file");
|
|
|
statement.close();
|
|
|
//导入最新数据
|
|
|
- String sql = "INSERT INTO u_archive_file (id, project_id, node_id, file_number, file_name, file_time, file_url, pdf_file_url, status, is_deleted, archive_id,create_time)" +
|
|
|
- " VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
+ String sql = "INSERT INTO u_archive_file (id, project_id, node_id, file_number, file_name, file_time, file_url, pdf_file_url, status, is_deleted, archive_id,create_time,duty_user)" +
|
|
|
+ " VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
PreparedStatement pstm = conn.prepareStatement(sql);
|
|
|
//pstm 绑定数据
|
|
|
int i = 0;
|
|
@@ -130,6 +139,7 @@ public class ArchiveOfflineVersionInfoServiceImpl extends BaseServiceImpl<Archiv
|
|
|
pstm.setInt(10, file.getIsDeleted());
|
|
|
pstm.setLong(11, file.getArchiveId() == null ? -1 : file.getArchiveId());
|
|
|
pstm.setString(12, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(file.getCreateTime()));
|
|
|
+ pstm.setString(12, file.getDutyUser());
|
|
|
//添加批处理
|
|
|
pstm.addBatch();
|
|
|
if (i % 1000 == 0) {
|
|
@@ -193,7 +203,7 @@ public class ArchiveOfflineVersionInfoServiceImpl extends BaseServiceImpl<Archiv
|
|
|
public void autoToSqlite(Long projectId) {
|
|
|
List<ArchivesAutoDTO> list = autoMapper.getListByProjectId(projectId);
|
|
|
if (list != null && list.size() > 0) {
|
|
|
- String localUrl = "/www/wwwroot/localClient/local_archives/alilib/";
|
|
|
+ String localUrl = "/www/wwwroot/Users/hongchuangyanfa/Desktop/localArchive/localClient/local_archives/alilib/";
|
|
|
//拼接档案里文件的pdf设置allPdf
|
|
|
for (ArchivesAutoDTO dto : list) {
|
|
|
List<ArchiveFile> files = fileClient.getArchiveFileByArchivesId(dto.getId() + "", "");
|
|
@@ -219,8 +229,8 @@ public class ArchiveOfflineVersionInfoServiceImpl extends BaseServiceImpl<Archiv
|
|
|
statement.execute("DELETE FROM u_archives_auto");
|
|
|
statement.close();
|
|
|
//导入数据
|
|
|
- String sql = "INSERT INTO u_archives_auto (id, project_id, name, file_number, unit,storage_time, is_archive,node_id, status, is_deleted,create_time,all_file_pdf)" +
|
|
|
- "VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
+ String sql = "INSERT INTO u_archives_auto (id, project_id, name, file_number, unit,storage_time, is_archive,node_id, status, is_deleted,create_time,all_file_pdf,file_size,tree_sort,start_date,end_date,secret_level)" +
|
|
|
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
PreparedStatement pstm = conn.prepareStatement(sql);
|
|
|
//pstm 绑定数据
|
|
|
int i = 0;
|
|
@@ -238,6 +248,11 @@ public class ArchiveOfflineVersionInfoServiceImpl extends BaseServiceImpl<Archiv
|
|
|
pstm.setInt(10, auto.getIsDeleted());
|
|
|
pstm.setString(11, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(auto.getCreateTime()));
|
|
|
pstm.setString(12, auto.getAllFilePdf() == null ? "" : auto.getAllFilePdf());
|
|
|
+ pstm.setLong(13, auto.getFileSize() == null ? 0L : auto.getFileSize());
|
|
|
+ pstm.setString(14, auto.getTreeSort() == null ? "" : auto.getTreeSort());
|
|
|
+ pstm.setString(15, auto.getStartDate() == null ? "" : auto.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ pstm.setString(16, auto.getEndDate() == null ? "" : auto.getEndDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ pstm.setString(17, auto.getSecretLevel());
|
|
|
|
|
|
//添加批处理
|
|
|
pstm.addBatch();
|