Просмотр исходного кода

试验检测文件下载整份下载文件名优化

lvy 2 дней назад
Родитель
Сommit
5d4e5f302d

+ 23 - 4
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -310,7 +310,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
      * @throws FileNotFoundException
      */
     private String getMergePdfToTrialNew(Long contractId, Long nodeId, Integer type) throws FileNotFoundException {
-        String sql = "select pdf_url,e_visa_pdf_url from u_information_query where wbs_id='" + nodeId + "' and status in(0,1,2) and contract_id ='" + contractId + "' and classify = '" + type + "'";
+        String sql = "select pdf_url,e_visa_pdf_url from u_information_query where wbs_id='" + nodeId + "' and status in(0,1,2) and contract_id ='" + contractId + "' and classify = '" + type + "' order by status desc";
         List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
         if (maps.size() >= 1) {
             Map<String, Object> stringObjectMap = maps.get(0);
@@ -2589,7 +2589,16 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                     try {
                         String pdf = this.getMergePdfToTrialNew(record.getContractId(), record.getId(), classify);
                         if (StringUtil.hasText(pdf)) {
-                            tempUrls.add(pdf + "@@@" + record.getRecordNo().replaceAll("\\\\", "_").replaceAll("/", "_"));
+
+                            String name = "";
+                            if(StringUtils.isNotEmpty(record.getReportNo())){
+                                name = "[" + record.getReportNo() + "]";
+                            }
+                            if(StringUtils.isNotEmpty(record.getTrialProjectName())){
+                                name = name + record.getTrialProjectName();
+                            }
+                            name = name + "试验检测报告及附件";
+                            tempUrls.add(pdf + "@@@" + name.replaceAll("\\\\", "_").replaceAll("/", "_"));
                             deletedFileUrls.add(pdf);
                         }
                     } catch (FileNotFoundException e) {
@@ -2610,8 +2619,18 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                     throw new ServiceException("未找到委托单记录");
                 }
                 List<EntrustInfo> entrustInfoList = entrustInfoService.listByIds(entrustIds);
-                pdfList = entrustInfoList.stream().filter(item -> item.getEntrustEPdf() != null && StringUtil.hasText(item.getEntrustEPdf()))
-                        .map(item -> item.getEntrustEPdf() + "@@@" + item.getEntrustNo().replaceAll("\\\\", "_").replaceAll("/", "_")).collect(Collectors.toList());
+                pdfList = entrustInfoList.stream()
+                        .map(item -> {
+                            String url = "";
+                            if (item.getEntrustEPdf() != null && StringUtil.hasText(item.getEntrustEPdf())) {
+                                url = item.getEntrustEPdf();
+                            } else if (item.getEntrustPdf() != null && StringUtil.hasText(item.getEntrustPdf())) {
+                                url = item.getEntrustPdf();
+                            } else {
+                                return  "";
+                            }
+                            return url + "@@@" + item.getEntrustNo().replaceAll("\\\\", "_").replaceAll("/", "_");
+                        }).filter(StringUtil::hasText).collect(Collectors.toList());
             }
             if (pdfList == null || pdfList.isEmpty()) {
                 if (type == 1) {