Selaa lähdekoodia

Merge remote-tracking branch 'origin/dev' into dev

LHB 2 kuukautta sitten
vanhempi
commit
c754b9d993

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/ArchiveFileServiceImpl.java

@@ -177,10 +177,10 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
                 }
             }
             //循环查看是否把需要审批改为不需要审批,  不可能把不需要审批改为需要审批 ,0不需要,1需要
-            if (vo.getStatus() == 0 && vo.getIsApproval() == 0) {
+            if (vo.getStatus() != null && vo.getStatus() == 0 && vo.getIsApproval() != null &&  vo.getIsApproval() == 0) {
                 vo.setStatus(2);
             }
-            if(vo.getIsApproval() == 1){
+            if(vo.getIsApproval() != null && vo.getIsApproval() == 1){
                 Set<String> aopParamsSet = new HashSet<>();
                 //判断现在的数据是否是待审批数据,只有上报状态、未认证状态的数据才能撤销
                 ArchiveFile archiveFile = jdbcTemplate.queryForObject("select * from u_archive_file where id = " + vo.getId(), new BeanPropertyRowMapper<>(ArchiveFile.class));

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.xml

@@ -913,7 +913,7 @@
         update m_wbs_tree_private
         set is_add_conceal = #{private.isAddConceal}
         where project_id = #{private.projectId}
-            and FIND_IN_SET(#{pId},ancestors) > 0
+            and FIND_IN_SET(#{pId},ancestors_p_id) > 0
     </update>
     <update id="updatePrivatePid">
         UPDATE m_wbs_tree_private a

+ 1 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -165,8 +165,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                 }
             }
             int row = baseMapper.updateByPKeyId(pKeyId, wbsTreePrivate);
-            Long pId = baseMapper.getByPKeyId(wbsTreePrivate.getPKeyId()).getPId();
-            baseMapper.batchUpdateIsAddConceal(wbsTreePrivate, pId);
+            baseMapper.batchUpdateIsAddConceal(wbsTreePrivate, wbsTreePrivate.getPKeyId());
             if (row > 0) {
                 WbsTreePrivate wbsTreePrivate1 = baseMapper.getByPKeyId(pKeyId);
                 wbsTreePrivate1.setFullName(wbsTreePrivate1.getNodeName());

+ 50 - 0
blade-service/blade-repair/src/main/java/org/springblade/repair/controller/CheckAndRepairController.java

@@ -6,12 +6,15 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.SystemUtils;
+import org.springblade.business.entity.InformationQuery;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.manager.entity.ExcelTab;
+import org.springblade.manager.entity.TableFile;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.repair.util.ExcelInfoUtils;
@@ -20,6 +23,7 @@ import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.SingleColumnRowMapper;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -31,6 +35,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -418,4 +423,49 @@ public class CheckAndRepairController {
         }
         System.out.println("检查完毕,更新了"+i+"条记录");
     }
+
+    @GetMapping("/checkNodePdfByClsssify")
+    //@Scheduled(cron = "00 10 17 * * ?")
+    public void checkNodePdfByClsssify() throws FileNotFoundException {
+        String sql="select id,wbs_id,classify,pdf_url,e_visa_pdf_url FROM u_information_query WHERE project_id in(1750070685257990145,1795277868551389185) AND is_deleted=0 AND node_pdf_url is NOT NULL AND status in(0,1,2)";
+        List<InformationQuery> informationQueryList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(InformationQuery.class));
+        System.out.println("一共有"+informationQueryList.size()+"条数据");
+         int i=1;
+        for (InformationQuery informationQuery : informationQueryList) {
+            List<String> pdfs=new ArrayList<>();
+          String sql1="select domain_pdf_url from m_table_file where tab_id="+informationQuery.getWbsId()+" and classify="+informationQuery.getClassify()+" and  domain_pdf_url is not null and is_deleted=0 order by sort ASC";
+          List<String> tableFileList = jdbcTemplate.query(sql1,new SingleColumnRowMapper<>(String.class));
+          tableFileList=tableFileList.stream().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
+          if(!tableFileList.isEmpty()){
+              String informationQueryPdf=StringUtils.isNotEmpty(informationQuery.getEVisaPdfUrl())?informationQuery.getEVisaPdfUrl():informationQuery.getPdfUrl();
+              pdfs.add(informationQueryPdf);
+              pdfs.addAll(tableFileList);
+              String file_path = FileUtils.getSysLocalFileUrl();
+              String listPdf = file_path + "/nodePDF/" + informationQuery.getWbsId() + ".pdf";
+              File tabpdf2 = ResourceUtil.getFile(listPdf);
+              if (tabpdf2.exists()) {
+                  tabpdf2.delete();
+              }
+              try {
+                  FileUtils.mergePdfPublicMethods(pdfs, listPdf);
+                  BladeFile bladeFile = this.newIOSSClient.uploadFile(informationQuery.getWbsId() + ".pdf", listPdf);
+                  if(bladeFile!=null && StringUtils.isNotEmpty(bladeFile.getLink())){
+                      String update="update u_information_query set node_pdf_url="+"'"+bladeFile.getLink()+"'"+" where id="+informationQuery.getId();
+                      System.out.println("合并后======================================"+update);
+                      jdbcTemplate.update(update);
+                  }
+              }catch (Exception e){
+                  System.out.println("合并pdf失败!informationQueryID:"+informationQuery.getId());
+                  continue;
+              }
+          }else {
+              String informationQueryPdf=StringUtils.isNotEmpty(informationQuery.getEVisaPdfUrl())?informationQuery.getEVisaPdfUrl():informationQuery.getPdfUrl();
+              String update="update u_information_query set node_pdf_url="+"'"+informationQueryPdf+"'"+" where id="+informationQuery.getId();
+              System.out.println(update);
+              jdbcTemplate.update(update);
+          }
+            System.out.println("已处理"+i+"条数据,还剩下条"+(informationQueryList.size()-i)+"数据:"+informationQuery.getId());
+          i++;
+        }
+    }
 }

+ 46 - 0
blade-service/blade-repair/src/main/java/org/springblade/repair/util/FileUtils.java

@@ -1,11 +1,16 @@
 package org.springblade.repair.util;
 
+import com.itextpdf.text.Document;
+import com.itextpdf.text.pdf.PdfCopy;
+import com.itextpdf.text.pdf.PdfReader;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SystemUtils;
 import org.springblade.system.cache.ParamCache;
 
 import java.io.*;
+import java.util.List;
+import java.util.Objects;
 
 public class FileUtils {
     // 获取本地 或 远程工作流ParamCache
@@ -104,4 +109,45 @@ public class FileUtils {
         }
         return file_path;
     }
+
+    public static void mergePdfPublicMethods(List<String> urlList, String localImgUrl) {
+        PdfReader reader = null;
+
+        Document doc = new Document();
+        PdfCopy pdfCopy = null;
+        try {
+            pdfCopy = new PdfCopy(doc, new FileOutputStream(localImgUrl));
+            int pageCount;
+            doc.open();
+
+            for (String urlStr : urlList) {
+                try {
+                    //获取OSS文件输入流
+                    reader = new PdfReader(Objects.requireNonNull(CommonUtil.getOSSInputStream(urlStr)));
+                    PdfReader.unethicalreading = true;
+                    pageCount = reader.getNumberOfPages();
+
+                    for (int i = 0; i < pageCount; ++i) {
+                        int is = i + 1;
+                        pdfCopy.addPage(pdfCopy.getImportedPage(reader, is));
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    if (reader != null) {
+                        reader.close();
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (pdfCopy != null) {
+                pdfCopy.flush();
+                pdfCopy.close();
+            }
+            doc.close();
+        }
+    }
 }