Ver código fonte

预览时pdf打不开

chenr 6 meses atrás
pai
commit
90af1fbaac

+ 2 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ContractLogMapper.xml

@@ -84,6 +84,8 @@
         from u_contract_log
         where is_deleted = 0
           and wbs_node_id = #{vo.wbsNodeId}
+          and contract_id = #{vo.contractId}
+          and pdf_url is not null
     </select>
 
     <select id="constructionLogPage" resultMap="contractLogVoResultMap">

+ 90 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -72,6 +72,7 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -1820,7 +1821,7 @@ public class ExcelTabController extends BladeController {
             @ApiImplicitParam(name = "classify", value = "填报的类型(施工或监理)", required = true),
             @ApiImplicitParam(name = "contractId", value = "合同段Id", required = true)
     })
-    public R getPdfS(String nodeId, String classify, String contractId) throws FileNotFoundException {
+    public R getPdfS(String nodeId, String classify, String contractId) throws IOException {
         String file_path = FileUtils.getSysLocalFileUrl();
         String sys_isonline = ParamCache.getValue(CommonConstant.SYS_ISONLINE);
         Boolean aBoolean = RedisTemplate.hasKey("pdf-" + nodeId + "-" + classify);
@@ -1887,15 +1888,25 @@ public class ExcelTabController extends BladeController {
                     }
                     FileUtils.mergePdfPublicMethods(datainfo, listPdf);
                     String netUrl = "";
-                    if(sys_isonline.equals("20")){
                         BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
                         if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
                             netUrl = bladeFile.getLink();
                         }
-                    }else{
-                        netUrl = FileUtils.getNetUrl(listPdf);
+                    //数字化节点附件处理
+                    String sqll="SELECT * FROM m_wbs_tree_contract WHERE p_key_id="+nodeId;
+                    WbsTreeContract wbsTreeContract = jdbcTemplate.queryForObject(sqll, new BeanPropertyRowMapper<>(WbsTreeContract.class));
+                    if(ObjectUtil.isNotEmpty(wbsTreeContract.getNodeClass())&&wbsTreeContract.getNodeClass().equals(2)){
+                        InformationQuery iq= informationQueryClient.getInfoByWbsId(wbsTreeContract.getPKeyId());
+                        if(iq.getNodePdfUrl()==null||iq.getEVisaPdfPage()==null||iq.getEVisaPdfPage()==0||iq.getEVisaPdfSize()==null||!iq.getNodePdfUrl().equals(netUrl)){
+                            String pdfPage = FileUtils.getPdfNum(netUrl);
+                            if(pdfPage!=null&&pdfPage.equals("")){
+                                pdfPage="0";
+                            }
+                            Long  pdfSize = CommonUtil.getResourceLength(netUrl);
+                            String sql1="update u_information_query set node_pdf_url='"+netUrl+"',e_visa_pdf_page="+pdfPage+" ,e_visa_pdf_size="+pdfSize+" where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id='" + contractId + "'";
+                            jdbcTemplate.execute(sql1);
+                        }
                     }
-                    jdbcTemplate.execute(" update  u_information_query set node_pdf_url='"+netUrl+"' where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id='" + contractId + "'");
                     return R.data(netUrl);
                 } else {
                     jdbcTemplate.execute(" update  u_information_query set node_pdf_url='"+pdfUrl+"' where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id='" + contractId + "'");
@@ -4106,6 +4117,51 @@ public class ExcelTabController extends BladeController {
         }
     }
 
+    //手动处理数字化节点pdf地址,evisaPage,evIsaSize
+    //@Scheduled(fixedDelay = 10000000)
+    public void checkNodeFile() throws IOException {
+        String sql="SELECT * from m_table_file WHERE tab_id IN (SELECT p_key_id FROM m_wbs_tree_contract WHERE node_class=2 AND is_deleted=0)";
+        String sql1="SELECT * from u_information_query where wbs_id IN (SELECT p_key_id FROM m_wbs_tree_contract WHERE node_class=2 AND is_deleted=0)";
+        List<TableFile> tableFiles = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TableFile.class));
+        List<InformationQuery> querys = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(InformationQuery.class));
+
+        Map<String, List<TableFile>> tableFileMap = tableFiles.stream().collect(Collectors.groupingBy(TableFile::getTabId));
+        for (InformationQuery query : querys) {
+            if(query.getNodePdfUrl()==null||query.getEVisaPdfPage()==null||query.getEVisaPdfPage().equals(0)||query.getEVisaPdfSize()==null){
+                List<TableFile> tableFiles1 = tableFileMap.get(query.getWbsId()+"");
+                if(tableFiles1==null){
+                    continue;
+                }
+                if(!tableFiles1.isEmpty()){
+                    List<String> datainfo = new ArrayList<>();
+                    for (TableFile tableFile : tableFiles1) {
+                        datainfo.add(tableFile.getDomainPdfUrl());
+                    }
+                    String file_path = FileUtils.getSysLocalFileUrl();
+                    String listPdf = file_path + "/nodePDF/" + query.getWbsId() + ".pdf";
+                    File tabpdf2 = ResourceUtil.getFile(listPdf);
+                    if (tabpdf2.exists()) {
+                        tabpdf2.delete();
+                    }
+                    FileUtils.mergePdfPublicMethods(datainfo, listPdf);
+                    String netUrl = "";
+                    BladeFile bladeFile = this.newIOSSClient.uploadFile(query.getWbsId() + ".pdf", listPdf);
+                    if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                        netUrl = bladeFile.getLink();
+                    }
+                    String pdfPage = FileUtils.getPdfNum(netUrl);
+                    Long  pdfSize = CommonUtil.getResourceLength(netUrl);
+                    query.setNodePdfUrl(netUrl);
+                    query.setEVisaPdfPage(Integer.parseInt(pdfPage));
+                    query.setEVisaPdfSize(pdfSize);
+                    informationQueryClient.update(query);
+                }
+            }
+        }
+        System.out.println("检查完毕");
+
+
+    }
 
     /**
      * 质检附件追加
@@ -4145,6 +4201,29 @@ public class ExcelTabController extends BladeController {
                 fileList.add(tableFile);
             }
             tableFileService.saveOrUpdateBatch(fileList);
+            String file_path = FileUtils.getSysLocalFileUrl();
+            String sys_isonline = ParamCache.getValue(CommonConstant.SYS_ISONLINE);
+            List<TableFileVO> data = tableFileService.selectTableFileListByTen(Long.valueOf(nodeId + ""), Integer.valueOf(classify));
+            List<String> datainfo = new ArrayList<>();
+                for (TableFileVO tabsx : data) {
+                    datainfo.add(tabsx.getUrl());
+                }
+                String listPdf = file_path + "/nodePDF/" + nodeId + ".pdf";
+                File tabpdf2 = ResourceUtil.getFile(listPdf);
+                if (tabpdf2.exists()) {
+                    tabpdf2.delete();
+                }
+                FileUtils.mergePdfPublicMethods(datainfo, listPdf);
+                String netUrl = "";
+                BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
+                if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                    netUrl = bladeFile.getLink();
+                }
+                String pdfPage = FileUtils.getPdfNum(netUrl);
+                Long  pdfSize = CommonUtil.getResourceLength(netUrl);
+                if(ObjectUtil.isNotEmpty(pdfPage)&&pdfPage.equals("")){
+                    pdfPage="0";
+                }
             String sql="SELECT * FROM m_wbs_tree_contract WHERE p_key_id="+nodeId;
             WbsTreeContract wbsTreeContract = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
             if(ObjectUtil.isNotEmpty(wbsTreeContract.getNodeClass())){
@@ -4161,6 +4240,9 @@ public class ExcelTabController extends BladeController {
                     iq.setFileUserIdAndName(b.getUserId()+"-"+b.getUserName());
                     iq.setType(1);
                     iq.setSourceType(2);
+                    iq.setEVisaPdfPage(pdfPage.equals("")?0:Integer.parseInt(pdfPage));
+                    iq.setEVisaPdfSize(pdfSize);
+                    iq.setNodePdfUrl(netUrl);
                     iq.setCreateUser(wbsTreeContract.getCreateUser());
                     iq.setCreateTime(new Date());
                     iq.setUpdateUser(b.getUserId());
@@ -4169,6 +4251,9 @@ public class ExcelTabController extends BladeController {
                     iq.setIsDeleted(0);
                     informationQueryClient.insert(iq);
                 }else {
+                    iq.setEVisaPdfPage(pdfPage.equals("")?0:Integer.parseInt(pdfPage));
+                    iq.setEVisaPdfSize(pdfSize);
+                    iq.setNodePdfUrl(netUrl);
                     iq.setUpdateTime(new Date());
                     iq.setUpdateUser(b.getUserId());
                     informationQueryClient.update(iq);

+ 18 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/FileUtils.java

@@ -13,6 +13,7 @@ import com.spire.xls.core.spreadsheet.HTMLOptions;
 import com.sun.image.codec.jpeg.JPEGCodec;
 import com.sun.image.codec.jpeg.JPEGImageEncoder;
 import org.apache.commons.lang.StringUtils;
+import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
 import org.apache.poi.ss.usermodel.ClientAnchor;
 import org.apache.poi.ss.usermodel.PrintSetup;
@@ -995,4 +996,21 @@ public class FileUtils {
         }
     }
 
+    public static String getPdfNum(String url) {
+        try {
+            if (url.isEmpty() || url.equals("")) {
+                return "0";
+            }
+            InputStream pdfInputStream = CommonUtil.getOSSInputStream(url);
+            //获取这份文件的页数并设置签章策略
+            //获取PDF文件
+            PDDocument document = PDDocument.load(pdfInputStream);
+            int page = document.getPages().getCount();
+            return page + "";
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
 }