Эх сурвалжийг харах

基本离线档案字段映射

qianxb 2 жил өмнө
parent
commit
e03e171497

+ 7 - 3
blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java

@@ -112,7 +112,7 @@ public class CommonUtil {
      */
     public static InputStream getOSSInputStream(String urlStr) throws Exception {
         //获取OSS文件流
-        urlStr = replaceOssUrl(urlStr);
+//        urlStr = replaceOssUrl(urlStr);
         URL imageUrl = new URL(urlStr);
         try {
             HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
@@ -312,10 +312,14 @@ public class CommonUtil {
      * @param filesPath
      * @throws Exception
      */
-    public static void packageZip(String filesPath) throws Exception {
+    public static void packageZip(String filesPath,String zipUrl) throws Exception {
         // 要被压缩的文件夹
         File file = new File(filesPath);   //需要压缩的文件夹
-        File zipFile = new File(filesPath + ".zip");  //放于和需要压缩的文件夹同级目录
+        File folder = new File(zipUrl);
+        if (!folder.exists() && !folder.isDirectory()) {
+            folder.mkdirs();
+        }
+        File zipFile = new File(zipUrl+"/" + "localArchive.zip");  //放于和需要压缩的文件夹同级目录
         ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile));
         isDirectory(file, zipOut, "", true);   //判断是否为文件夹
         zipOut.close();

+ 2 - 1
blade-service/blade-archive/src/main/java/org/springblade/archive/config/sqliteConfig.java

@@ -14,7 +14,8 @@ import javax.sql.DataSource;
 public class sqliteConfig {
     public DataSource dataSource() {
         DruidDataSource ds = new DruidDataSource();
-        ds.setUrl("jdbc:sqlite:/www/wwwroot/localClient/data");
+//        ds.setUrl("jdbc:sqlite:/www/wwwroot/localClient/data");
+        ds.setUrl("jdbc:sqlite:/www/wwwroot/Users/hongchuangyanfa/Desktop/localArchive/localClient/data");
         ds.setDriverClassName("org.sqlite.JDBC");
         return ds;
     }

+ 1 - 12
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.xml

@@ -405,18 +405,7 @@
     </select>
 
     <select id="getListByProjectId" resultType="org.springblade.archive.dto.ArchivesAutoDTO">
-        select id,
-               project_id   as projectId,
-               name,
-               file_number  as fileNumber,
-               unit,
-               storage_time as storageTime,
-               node_id      as nodeId,
-               tree_sort    as treeSort,
-               status,
-               is_deleted   as isDeleted,
-               is_lock      as isLock,
-               create_time  as createTime
+        select *
         from u_archives_auto
         where project_id = #{projectId} and is_deleted = 0;
     </select>

+ 30 - 15
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveOfflineVersionInfoServiceImpl.java

@@ -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();

+ 1 - 12
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ArchiveFileMapper.xml

@@ -321,18 +321,7 @@
         order by sort,create_time
     </select>
     <select id="getListByProjectId" resultType="org.springblade.business.entity.ArchiveFile">
-        select id,
-               project_id   as projectId,
-               node_id      as nodeId,
-               file_number  as fileNumber,
-               file_name    as fileName,
-               file_time    as fileTime,
-               file_url     as fileUrl,
-               pdf_file_url as pdfFileUrl,
-               archive_id   as archiveId,
-               status,
-               is_deleted   as isDeleted,
-               create_time  as createTime
+        select *
         from u_archive_file
         where project_id = #{projectId} and is_deleted = 0;
     </select>

+ 1 - 1
blade-service/blade-control/src/main/java/org/springblade/control/service/impl/DepartmentPlanLogImpl.java

@@ -170,7 +170,7 @@ public class DepartmentPlanLogImpl extends BaseServiceImpl<DepartmentPlanLogMapp
         DepartmentPlanLogVO vo = new DepartmentPlanLogVO();
         //先判断日期是否超过35天
         if (log.getOpenPlanStartTime().until(log.getOpenPlanEndTime(), ChronoUnit.DAYS) > 35) {
-            throw new ServiceException("请不要制定超过一个月的临时计划");
+            throw new ServiceException("请不要制定超过一个月的固定计划");
         }
         //计算中途开启的工作日
         int planDays = CommonUtil.getWorkDays(log.getOpenPlanStartTime(), log.getOpenPlanEndTime());

+ 4 - 4
blade-service/blade-control/src/main/java/org/springblade/control/service/impl/ProjectCostBudgetServiceImpl.java

@@ -325,7 +325,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
                         vo2.setPlanDays(new BigDecimal(endDate.compareTo(startDate) + 1));
                     }else {
                         if (startDate.until(endDate,ChronoUnit.DAYS) > 35){
-                            throw new ServiceException("请不要制定超过一个月的临时计划");
+                            throw new ServiceException("请不要制定超过一个月的固定计划");
 //                            //工作天数,工具只能获取50天之内的
 //                            int i = 0;
 //                            while (endDate.compareTo(startDate) > 0){
@@ -1034,7 +1034,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
             vo2.setPlanDays(new BigDecimal(vo2.getPlanStartTime().until(vo2.getPlanEndTime(),ChronoUnit.DAYS) + 1));
         }else {
             if (vo2.getPlanStartTime().until(vo2.getPlanEndTime(),ChronoUnit.DAYS) > 35){
-                throw new ServiceException("请不要制定超过一个月的临时计划");
+                throw new ServiceException("请不要制定超过一个月的固定计划");
 //                //工作天数,工具只能获取50天之内的
 //                LocalDate startDate = vo2.getPlanStartTime();
 //                LocalDate endDate = vo2.getPlanEndTime();
@@ -1120,7 +1120,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
                         l.setPlanDays(new BigDecimal(l.getPlanStartTime().until(l.getPlanEndTime(),ChronoUnit.DAYS) + 1));
                     } else {
                         if (l.getPlanStartTime().until(l.getPlanEndTime(), ChronoUnit.DAYS) > 35) {
-                            throw new ServiceException("请不要制定超过一个月的临时计划");
+                            throw new ServiceException("请不要制定超过一个月的固定计划");
                         }else {
                             l.setPlanDays(new BigDecimal(CommonUtil.getWorkDays(budgetVO2.getPlanStartTime(), budgetVO2.getPlanEndTime())));
                         }
@@ -1170,7 +1170,7 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
                 vo2.setPlanDays(new BigDecimal(startDate.until(endDate,ChronoUnit.DAYS)+ 1));
             }else {
                 if (startDate.until(endDate,ChronoUnit.DAYS) > 35){
-                    throw new ServiceException("请不要制定超过一个月的临时计划");
+                    throw new ServiceException("请不要制定超过一个月的固定计划");
 //                    //工作天数,工具只能获取50天之内的
 //                    int i = 0;
 //                    while (endDate.compareTo(startDate) > 0){