浏览代码

Merge branch 'master' of http://121.41.40.202:3000/zhuwei/bladex

huangtf 1 年之前
父节点
当前提交
9a55a51150
共有 24 个文件被更改,包括 510 次插入284 次删除
  1. 2 2
      blade-common/src/main/java/org/springblade/common/utils/AsyncConfigurer.java
  2. 1 1
      blade-ops/blade-flow/src/main/java/org/springblade/flow/business/feign/NewFlowClientImpl.java
  3. 21 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/InspectionRectifyDTO.java
  4. 2 1
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/RoutingInspectionDTO.java
  5. 12 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/InspectionRectify.java
  6. 1 1
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/RoutingInspection.java
  7. 2 1
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/RoutingInspectionVO2.java
  8. 6 0
      blade-service/blade-archive/pom.xml
  9. 148 122
      blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveAutoPdfServiceImpl.java
  10. 12 15
      blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java
  11. 1 3
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TaskBatchMapper.xml
  12. 13 10
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java
  13. 98 66
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVisaController.java
  14. 11 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TextdictInfoController.java
  15. 5 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/InspectionRectifyMapper.java
  16. 5 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/InspectionRectifyMapper.xml
  17. 1 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TextdictInfoMapper.java
  18. 11 3
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TextdictInfoMapper.xml
  19. 4 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IInspectionRectifyService.java
  20. 1 7
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java
  21. 8 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/InspectionRectifyServiceImpl.java
  22. 40 13
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/RoutingInspectionServiceImpl.java
  23. 21 9
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TextdictInfoServiceImpl.java
  24. 84 27
      blade-service/blade-manager/src/main/java/org/springblade/manager/utils/FileUtils.java

+ 2 - 2
blade-common/src/main/java/org/springblade/common/utils/AsyncConfigurer.java

@@ -15,7 +15,7 @@ public class AsyncConfigurer {
     /**
      * cpu 核心数量
      */
-    public static final int cpuNum = 6;//Runtime.getRuntime().availableProcessors();
+    public static final int cpuNum = 3;//Runtime.getRuntime().availableProcessors();
 
     /**
      * 线程池配置
@@ -25,7 +25,7 @@ public class AsyncConfigurer {
     @Bean("taskExecutor1")
     public ThreadPoolExecutor getAsyncExecutor() {
         return new ThreadPoolMonitor(cpuNum
-                , 12
+                , 6
                 , 60
                 , TimeUnit.SECONDS
                 , new LinkedBlockingQueue<>(2000)

+ 1 - 1
blade-ops/blade-flow/src/main/java/org/springblade/flow/business/feign/NewFlowClientImpl.java

@@ -70,7 +70,7 @@ public class NewFlowClientImpl implements NewFlowClient {
             }
         }
         //完成任务
-        this.taskService.complete(taskId, Kv.create());
+       // this.taskService.complete(taskId, Kv.create());
 
         return R.data(true);
     }

+ 21 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/InspectionRectifyDTO.java

@@ -0,0 +1,21 @@
+package org.springblade.manager.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.manager.entity.InspectionRectify;
+
+import java.util.List;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2023/11/3 11:45
+ **/
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class InspectionRectifyDTO extends InspectionRectify {
+
+    @ApiModelProperty(value = "检查项目集合")
+    private List<String> autoExpandKeys;
+}

+ 2 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/RoutingInspectionDTO.java

@@ -18,5 +18,6 @@ import java.util.List;
 public class RoutingInspectionDTO extends RoutingInspection {
 
     @ApiModelProperty(value = "检查项目集合")
-    private List<InspectionRectify> list;
+    private List<InspectionRectifyDTO> list;
+
 }

+ 12 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/InspectionRectify.java

@@ -46,9 +46,21 @@ public class InspectionRectify extends BaseEntity {
     @ApiModelProperty(value = "整改附件")
     private String rectifyAttachment;
 
+    @ApiModelProperty(value = "整改附件")
+    private String rectifyAttachmentName;
+
     @ApiModelProperty(value = "整改图片")
     private String rectifyPdfUrl;
 
+    @ApiModelProperty(value = "是否显示图片 0不显示1显示")
+    private String isShowImage;
+
+    @ApiModelProperty(value = "节点id")
+    private String primaryKeyId;
+
+    @ApiModelProperty(value = "检查部位")
+    private String inspectLocation;
+
 
 
 }

+ 1 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/RoutingInspection.java

@@ -37,7 +37,7 @@ public class RoutingInspection extends BaseEntity {
     private LocalDate rectifyDate;
 
     @ApiModelProperty(value = "整改人")
-    private Long rectifyUser;
+    private String rectifyUser;
 
     @ApiModelProperty(value = "检查部位")
     private String inspectLocation;

+ 2 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/RoutingInspectionVO2.java

@@ -3,6 +3,7 @@ package org.springblade.manager.vo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import org.springblade.manager.dto.InspectionRectifyDTO;
 import org.springblade.manager.entity.InspectionRectify;
 import org.springblade.manager.entity.RoutingInspection;
 
@@ -18,6 +19,6 @@ import java.util.List;
 public class RoutingInspectionVO2 extends RoutingInspection {
 
     @ApiModelProperty(value = "检查项目集合")
-    private List<InspectionRectify> list;
+    private List<InspectionRectifyDTO> list;
 
 }

+ 6 - 0
blade-service/blade-archive/pom.xml

@@ -136,6 +136,12 @@
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.pdfbox</groupId>
+            <artifactId>pdfbox</artifactId>
+            <version>2.0.20</version>
+            <scope>compile</scope>
+        </dependency>
 
     </dependencies>
 

+ 148 - 122
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveAutoPdfServiceImpl.java

@@ -8,6 +8,9 @@ import com.itextpdf.text.pdf.*;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.util.IOUtils;
 import org.springblade.archive.entity.ArchiveFormulaConfig;
@@ -58,7 +61,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
     private ArchiveFileClient archiveFileClient;
 
-    public static final  String[] ARCHIVE_NUMBER = new String[]{"r_Archives_front","r_Archives_catalog","r_Archives_spare","r_Archives_back"};
+    public static final String[] ARCHIVE_NUMBER = new String[]{"r_Archives_front", "r_Archives_catalog", "r_Archives_spare", "r_Archives_back"};
 
     public static final Map<String, String> URL_MAP = new HashMap<>();
     public static final Map<String, String> NAME_MAP = new HashMap<>();
@@ -123,7 +126,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         List<ArchiveFile> waitFiles = new ArrayList<>();
         waitFiles.add(f1);
         waitFiles.add(f2);
-        builtFilePageNo(archivesAuto,waitFiles);
+        builtFilePageNo(archivesAuto, waitFiles);
         System.out.println();
 
 
@@ -207,20 +210,21 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
         List<ArchiveFile> archiveFiles = new ArrayList<>();
 
-        for (int i = 0; i < 20;i++) {
+        for (int i = 0; i < 20; i++) {
             archiveFiles.add(archiveFile);
         }
-        buildArchiveFrontPdfs(projectId,archivesAuto,archiveFiles,true);
+        buildArchiveFrontPdfs(projectId, archivesAuto, archiveFiles, true);
     }
 
 
     /**
-     *  生成四要素
+     * 生成四要素
+     *
      * @param projectId
-     * @param archivesAuto, 会更新起始时间和结束时间,所以调用后要更新
+     * @param archivesAuto,   会更新起始时间和结束时间,所以调用后要更新
      * @param archiveFileList
      */
-    public void buildArchiveFrontPdfs(Long projectId, ArchivesAuto archivesAuto,List<ArchiveFile> archiveFileList,
+    public void buildArchiveFrontPdfs(Long projectId, ArchivesAuto archivesAuto, List<ArchiveFile> archiveFileList,
                                       boolean bBuildFront) {
 
         if (bBuildFront == false) {
@@ -248,26 +252,26 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         String secretLevel = archivesAuto.getSecretLevel();
         String storageTime = archivesAuto.getStorageTime();
 
-        Map<String,Object> variables = dataSourceBuilder(archivesAuto,archiveFileList);
+        Map<String, Object> variables = dataSourceBuilder(archivesAuto, archiveFileList);
 
         // 使用生成的档案号码字符串链表生成档案 PDF 文件
         List<String> frontUrls = new ArrayList<>();
         List<String> backUrls = new ArrayList<>();
         for (String number : numberFronts) {
             // 具体实现省略
-            buildFrontPdf(archivesAuto,number, variables,frontUrls);
+            buildFrontPdf(archivesAuto, number, variables, frontUrls);
         }
 
         for (String number : numberBacks) {
             // 具体实现省略
-            buildFrontPdf(archivesAuto,number, variables,backUrls);
+            buildFrontPdf(archivesAuto, number, variables, backUrls);
         }
 
         //将封面写入archivesAuto
         frontUrls.addAll(backUrls);
 
         //统计文件大小
-        RefreshFileSize(archivesAuto,archiveFileList,frontUrls);
+        RefreshFileSize(archivesAuto, archiveFileList, frontUrls);
 
         String joinedUrls = String.join(", ", frontUrls);
         archivesAuto.setOutUrl(joinedUrls);
@@ -277,10 +281,11 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
     /**
      * 打码
+     *
      * @param archivesAuto
      * @param waitArchiveFiles
      */
-    public void builtFilePageNo(ArchivesAuto archivesAuto,List<ArchiveFile> waitArchiveFiles){
+    public void builtFilePageNo(ArchivesAuto archivesAuto, List<ArchiveFile> waitArchiveFiles) {
 
         Long projectId = archivesAuto.getProjectId();
 
@@ -288,7 +293,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         //是否打页码
         if (!config.isPage()) {
             //不需要打页码的,把字段pdf_page_url设为null
-            for(ArchiveFile file:waitArchiveFiles){
+            for (ArchiveFile file : waitArchiveFiles) {
                 file.setPdfPageUrl("");
             }
             return;
@@ -300,17 +305,17 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         }
 
         List<String> urls = new ArrayList<>();
-        for (ArchiveFile f: waitArchiveFiles) {
+        for (ArchiveFile f : waitArchiveFiles) {
             String url = getPdfFileUrl(f);
-            if (f.getIsElement() != null && f.getIsElement()== 1) {
+            if (f.getIsElement() != null && f.getIsElement() == 1) {
                 urls.add(FileUtils.Element_FLAG + url);
             } else {
                 urls.add(url);
             }
         }
         String localPath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-        List<String> pageUrls = FileUtils.doForPageNumberUseItextpdf(urls,localPath,newIOSSClient, archivesAuto.getProjectId());
-        for(int i=0;i<waitArchiveFiles.size();i++){
+        List<String> pageUrls = FileUtils.doForPageNumberUseItextpdf(urls, localPath, newIOSSClient, archivesAuto.getProjectId());
+        for (int i = 0; i < waitArchiveFiles.size(); i++) {
             waitArchiveFiles.get(i).setPdfPageUrl(pageUrls.get(i));
         }
 
@@ -318,14 +323,12 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
     }
 
 
-
     /**
-     *
-     * @param number  四要素的表名
+     * @param number    四要素的表名
      * @param variables 参数集
-     * @param urls  返回的url
+     * @param urls      返回的url
      */
-    public void buildFrontPdf(ArchivesAuto archivesAuto,String number, Map<String,Object> variables,List<String> urls) {
+    public void buildFrontPdf(ArchivesAuto archivesAuto, String number, Map<String, Object> variables, List<String> urls) {
         // Step 1: Get the list of formulas using archiveFormulaConfigService
         List<ArchiveFormulaConfig> formulaConfigs = archiveFormulaConfigService.getByNumber(number);
 
@@ -335,7 +338,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
         ArchiveFormulaConfig multiLineconfig = null;
         //采取
-        String fileName = FileUtils.generateFilename(number,0,archivesAuto.getId());
+        String fileName = FileUtils.generateFilename(number, 0, archivesAuto.getId());
 
         for (ArchiveFormulaConfig config : formulaConfigs) {
             String coords = config.getCoords();
@@ -352,14 +355,13 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
                 }
             }*/
 
-            if(variables.containsKey("ArchiveFile") && variables.get("ArchiveFile") instanceof List
-                    && formula.indexOf("ArchiveFile") >= 0){
+            if (variables.containsKey("ArchiveFile") && variables.get("ArchiveFile") instanceof List
+                    && formula.indexOf("ArchiveFile") >= 0) {
 
                 multiLineconfig = config;
                 //handleArchiveFile(coords, formula, variables, file_path, excelUrl, dataInfo,urls);
                 continue;
-            }
-            else{
+            } else {
                 handleNonArchiveFile(config, coords, formula, variables, file_path, excelUrl, dataInfo);
             }
         }
@@ -367,11 +369,11 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         if (multiLineconfig != null) {
             String coords = multiLineconfig.getCoords();
             String formula = multiLineconfig.getFormula();
-            handleArchiveFile(coords, formula, variables, file_path, excelUrl, dataInfo,urls,fileName, archivesAuto.getProjectId());
+            handleArchiveFile(coords, formula, variables, file_path, excelUrl, dataInfo, urls, fileName, archivesAuto.getProjectId());
 
-        }else {
+        } else {
             try {
-                String url = getBussPdfInfo(fileName, dataInfo, excelUrl, file_path,OssConstant.ARCHIVE_DIRECTORY,archivesAuto.getProjectId());
+                String url = getBussPdfInfo(fileName, dataInfo, excelUrl, file_path, OssConstant.ARCHIVE_DIRECTORY, archivesAuto.getProjectId());
                 urls.add(url);
             } catch (Exception e) {
                 e.printStackTrace();
@@ -382,6 +384,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
     /**
      * 生成 卷内目录
+     *
      * @param coords
      * @param formula
      * @param variables
@@ -391,8 +394,8 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
      * @param urls
      */
     private void handleArchiveFile(String coords, String formula,
-                                   Map<String,Object> variables,String file_path,
-                                   String excelUrl, Map<String, Object> dataInfo,List<String> urls,String fileName,Long projectId){
+                                   Map<String, Object> variables, String file_path,
+                                   String excelUrl, Map<String, Object> dataInfo, List<String> urls, String fileName, Long projectId) {
         //todo  目录多页合并一页,文件名带上
 
 
@@ -403,16 +406,16 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
             DataVO dataVO2 = FormulaUtil.convertCellToIndex(coordArr[1]);
             Integer pageSize = dataVO2.getY() - dataVO1.getY() + 1;
 
-            List<Map<String,Object>> archiveFiles = (List<Map<String,Object>>)variables.get("ArchiveFile");
+            List<Map<String, Object>> archiveFiles = (List<Map<String, Object>>) variables.get("ArchiveFile");
 
             Map<String, Object> pageMap = new HashMap<>();
-            if(archiveFiles != null && archiveFiles.size() > 0){
+            if (archiveFiles != null && archiveFiles.size() > 0) {
                 int pageIndex = 0; // 当前页数
                 while (true) {
-                    List<Map<String,Object>> subList = archiveFiles.subList(pageIndex * pageSize,
+                    List<Map<String, Object>> subList = archiveFiles.subList(pageIndex * pageSize,
                             Math.min((pageIndex + 1) * pageSize, archiveFiles.size()));
 
-                    if(subList.size()==0){
+                    if (subList.size() == 0) {
                         break;
                     }
 
@@ -420,12 +423,12 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
                     pageMap.putAll(dataInfo);
 
                     int subIndex = 0;
-                    for (Map<String,Object> archiveMap : subList) {
+                    for (Map<String, Object> archiveMap : subList) {
                         // 处理archiveFile逻辑
                         int y = dataVO1.getY() + subIndex;
                         List<Object> objects = FormulaUtil.expressionParseList(formula, archiveMap);
                         int xIndex = 0;
-                        for (Object o: objects) {
+                        for (Object o : objects) {
                             if (o == null) {
                                 xIndex++;
                                 continue;
@@ -439,8 +442,8 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
                         subIndex++;
                     }
                     try {
-                        Integer fileNamenum=(pageIndex * pageSize)+subIndex;
-                        String url = getBussPdfInfo(fileName + fileNamenum, pageMap, excelUrl, file_path,OssConstant.ARCHIVE_DIRECTORY,projectId);
+                        Integer fileNamenum = (pageIndex * pageSize) + subIndex;
+                        String url = getBussPdfInfo(fileName + fileNamenum, pageMap, excelUrl, file_path, OssConstant.ARCHIVE_DIRECTORY, projectId);
                         localUrls.add(url);
                     } catch (Exception e) {
                         e.printStackTrace();
@@ -464,22 +467,23 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
             FileUtils.mergePdfPublicMethods(localUrls, localPdf);
 //            BladeFile bladeFile = this.newIOSSClient.uploadFile(fileName + ".pdf", localPdf, OssConstant.ARCHIVE_DIRECTORY,projectId);
 
-            String absoluteFileName = FileUtils.getOssPath(OssConstant.ARCHIVE_DIRECTORY,fileName,projectId);
+            String absoluteFileName = FileUtils.getOssPath(OssConstant.ARCHIVE_DIRECTORY, fileName, projectId);
             BladeFile bladeFile = newIOSSClient.uploadFile(absoluteFileName + ".pdf", localPdf);
 
 //            ByteArrayOutputStream bos = new ByteArrayOutputStream();
 //            FileUtils.PdfCopyPublicMethods(bos, localUrls);
 //            BladeFile bladeFile = newIOSSClient.updateFile(bos.toByteArray(),fileName + ".pdf");
-            if (bladeFile!= null ) {
+            if (bladeFile != null) {
                 urls.add(bladeFile.getLink());
             }
-        }else if (localUrls.size() == 1) {
+        } else if (localUrls.size() == 1) {
             urls.add(localUrls.get(0));
         }
     }
 
     /**
      * 生成 封面,备考表,脊背
+     *
      * @param config
      * @param coords
      * @param formula
@@ -489,29 +493,29 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
      * @param dataInfo  结果集
      */
     private void handleNonArchiveFile(ArchiveFormulaConfig config, String coords, String formula,
-                                      Map<String,Object> variables,String file_path,
+                                      Map<String, Object> variables, String file_path,
                                       String excelUrl, Map<String, Object> dataInfo) {
         DataVO dataVO = FormulaUtil.convertCellToIndex(coords);
         Object object = null;
         if (formula.indexOf("~") > 0) {
             String[] formulaArr = formula.split("~");
             if (formulaArr.length == 2) {
-                Object object1 = FormulaUtil.expressionParse(formulaArr[0],variables);
-                Object object2 = FormulaUtil.expressionParse(formulaArr[1],variables);
+                Object object1 = FormulaUtil.expressionParse(formulaArr[0], variables);
+                Object object2 = FormulaUtil.expressionParse(formulaArr[1], variables);
                 object = object1 + "~" + object2;
             }
-        }else {
-            object = FormulaUtil.expressionParse(formula,variables);
+        } else {
+            object = FormulaUtil.expressionParse(formula, variables);
         }
 
 
         String key = config.getId() + "__" + dataVO.getY() + "_" + dataVO.getX();
 
 
-        if("Archive['startDate']~Archive['endDate']".equals(formula)){
-            log.info("起止时间object:"+object.toString());
-            if("null~null".equals(object)){
-                object="";
+        if ("Archive['startDate']~Archive['endDate']".equals(formula)) {
+            log.info("起止时间object:" + object.toString());
+            if ("null~null".equals(object)) {
+                object = "";
             }
         }
         dataInfo.put(key, object);
@@ -524,17 +528,18 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
     /**
      * 生成单张pdf
-     * @param fileName   文件名
+     *
+     * @param fileName  文件名
      * @param DataInfo  excel和数据
      * @param excelUrl  excel模板
-     * @param localPath  本地路径
-     * @param ossPath  oss上的路径
+     * @param localPath 本地路径
+     * @param ossPath   oss上的路径
      * @param projectId 项目ID
      * @return
      * @throws Exception
      */
-    public String getBussPdfInfo(String fileName,Map<String, Object> DataInfo,String excelUrl,String localPath,
-         String ossPath, Long projectId) throws Exception{
+    public String getBussPdfInfo(String fileName, Map<String, Object> DataInfo, String excelUrl, String localPath,
+                                 String ossPath, Long projectId) throws Exception {
 
         if (fileName == null) {
             fileName = SnowFlakeUtil.getId().toString();
@@ -550,9 +555,9 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
         // 获取excel流 和 html流
         InputStream exceInp = null;
-        if ( isOssFilePath(excelUrl)){
+        if (isOssFilePath(excelUrl)) {
             exceInp = CommonUtil.getOSSInputStream(excelUrl);
-        }else {
+        } else {
             exceInp = new FileInputStream(new File(excelUrl));
         }
 
@@ -575,12 +580,12 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
                     int x2 = 0;
                     int y2 = 0;
 
-                    if (xy.length == 2 ) {
+                    if (xy.length == 2) {
                         x1 = Integer.parseInt(xy[1]);
                         y1 = Integer.parseInt(xy[0]);
                     }
 
-                    if (xy.length == 4 ) {
+                    if (xy.length == 4) {
                         x2 = Integer.parseInt(xy[3]);
                         y2 = Integer.parseInt(xy[2]);
                     }
@@ -609,11 +614,10 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
                         pict.resize(1, 1);
                         FileUtils.imageOrientation(sheet, anchor, new DataVO(x1 - 1, y1 - 1));
 
-                    }
-                    else {
-                        Row row = sheet.getRow(y1 );
+                    } else {
+                        Row row = sheet.getRow(y1);
                         if (row != null) {
-                            Cell cell = row.getCell(x1 );
+                            Cell cell = row.getCell(x1);
                             if (cell != null || ObjectUtils.isNotEmpty(cell)) {
 //                                boolean bflag = true;
 //                                if (bflag) {
@@ -633,24 +637,25 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         FileOutputStream outputStream = new FileOutputStream(excelPath);
         workbook.write(outputStream);
         FileUtils.setExcelScaleToPdf(excelPath, localPdfPath);
-        String absoluteFileName = FileUtils.getOssPath(OssConstant.ARCHIVE_DIRECTORY,fileName,projectId);
+        String absoluteFileName = FileUtils.getOssPath(OssConstant.ARCHIVE_DIRECTORY, fileName, projectId);
         BladeFile bladeFile = newIOSSClient.uploadFile(absoluteFileName + ".pdf", localPdfPath);
 
         ///BladeFile bladeFile = newIOSSClient.uploadFile(fileName + ".pdf", localPdfPath,ossPath, projectId);
         String pdfLink = "";
-        if (bladeFile!= null ){
+        if (bladeFile != null) {
             pdfLink = bladeFile.getLink();
         }
         return pdfLink;
     }
 
     /**
-     *  生成四要素的数据源
+     * 生成四要素的数据源
+     *
      * @param archive
      * @param datas
      * @return
      */
-    public static  Map<String,Object> dataSourceBuilder(ArchivesAuto archive, List<ArchiveFile> datas){
+    public static Map<String, Object> dataSourceBuilder(ArchivesAuto archive, List<ArchiveFile> datas) {
 
         //预处理
         archive.setSecretLevel(FormulaUtil.securityLevelMap.get(archive.getSecretLevel()));
@@ -662,11 +667,11 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         List<Map<String, Object>> fileMapList = new ArrayList<>();
 
         //todo  增加获取总大小
-        for (ArchiveFile file:  datas) {
+        for (ArchiveFile file : datas) {
 
-            if (file.getIsElement() != null && file.getIsElement()== 1){
+            if (file.getIsElement() != null && file.getIsElement() == 1) {
 
-            }else {
+            } else {
 
                 idx++;
                 //设置序号
@@ -679,7 +684,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
                 file.setPageNum(iStartPage.toString());
 
                 //最后一页
-                if (file.getFilePage() != null ) {
+                if (file.getFilePage() != null) {
                     iStartPage += file.getFilePage();
                 }
                 if (idx >= datas.size()) {
@@ -701,7 +706,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
         for (ArchiveFile file : datas) {
             String fileTime = file.getFileTime();
-            if(StringUtils.isNotEmpty(fileTime)){
+            if (StringUtils.isNotEmpty(fileTime)) {
                 if (minDate.isEmpty() || fileTime.compareTo(minDate) <= 0) {
                     minDate = fileTime;
                 }
@@ -712,45 +717,42 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         }
 
         // 将日期赋值给startDate和endDate
-        try {
-            if (!minDate.isEmpty()) {
-                LocalDateTime localDateTime = FormulaUtil.parseStringToLocalDateTime(minDate,"yyyyMMdd");
-                archive.setStartDate(localDateTime);
-            }
-            if (!maxDate.isEmpty()) {
-                LocalDateTime localDateTime = FormulaUtil.parseStringToLocalDateTime(maxDate,"yyyyMMdd");
-                archive.setEndDate(localDateTime);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
+        if (!minDate.isEmpty()) {
+            LocalDateTime localDateTime = FormulaUtil.parseStringToLocalDateTime(minDate, "yyyyMMdd");
+            archive.setStartDate(localDateTime);
+        }
+        if (!maxDate.isEmpty()) {
+            LocalDateTime localDateTime = FormulaUtil.parseStringToLocalDateTime(maxDate, "yyyyMMdd");
+            archive.setEndDate(localDateTime);
         }
 
         Map<String, Object> archivesAutoMap = new ObjectMapper().convertValue(archive, Map.class);
-        if (archive.getRollDate()!= null) {
-            archivesAutoMap.put("rollDate",FormulaUtil.formatLocalDateTime(archive.getRollDate(),"yyyy年MM月dd日"));
+        if (archive.getRollDate() != null) {
+            archivesAutoMap.put("rollDate", FormulaUtil.formatLocalDateTime(archive.getRollDate(), "yyyy年MM月dd日"));
         }
 
-        if (archive.getReviewDate()!= null) {
-            archivesAutoMap.put("reviewDate",FormulaUtil.formatLocalDateTime(archive.getReviewDate(),"yyyy年MM月dd日"));
+        if (archive.getReviewDate() != null) {
+            archivesAutoMap.put("reviewDate", FormulaUtil.formatLocalDateTime(archive.getReviewDate(), "yyyy年MM月dd日"));
         }
 
-        if (archive.getStartDate()!= null) {
-            archivesAutoMap.put("startDate",FormulaUtil.formatLocalDateTime(archive.getStartDate(),"yyyyMMdd"));
+        if (archive.getStartDate() != null) {
+            archivesAutoMap.put("startDate", FormulaUtil.formatLocalDateTime(archive.getStartDate(), "yyyyMMdd"));
         }
 
-        if (archive.getEndDate()!= null) {
-            archivesAutoMap.put("endDate",FormulaUtil.formatLocalDateTime(archive.getEndDate(),"yyyyMMdd"));
+        if (archive.getEndDate() != null) {
+            archivesAutoMap.put("endDate", FormulaUtil.formatLocalDateTime(archive.getEndDate(), "yyyyMMdd"));
         }
 
-        Map<String,Object> variables = new HashMap<>();
-        variables.put("Archive",archivesAutoMap);
+        Map<String, Object> variables = new HashMap<>();
+        variables.put("Archive", archivesAutoMap);
 
-        variables.put("ArchiveFile",fileMapList);
-        return  variables;
+        variables.put("ArchiveFile", fileMapList);
+        return variables;
     }
 
     /**
      * 获取四要素模板的url,这里写死,后续可以从清表的 ”归档“模板树下获取
+     *
      * @param number
      * @return
      */
@@ -762,15 +764,16 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
     /**
      * 获取指定文件的pdf文件
+     *
      * @param file
      * @return
      */
-    public String getPdfFileUrl(ArchiveFile file){
+    public String getPdfFileUrl(ArchiveFile file) {
         //
         String url = file.getPdfFileUrl();
         if (StringUtil.isEmpty(url)) {
             String fileUrl = file.getFileUrl();
-            if(fileUrl.endsWith(".pdf") || fileUrl.endsWith(".PDF")){
+            if (fileUrl.endsWith(".pdf") || fileUrl.endsWith(".PDF")) {
                 url = file.getFileUrl();
             }
         }
@@ -783,23 +786,24 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
     /**
      * 刷新文件大小
+     *
      * @param archive
      * @param datas
      * @param frontUrls
      */
-    public void RefreshFileSize(ArchivesAuto archive,List<ArchiveFile> datas,List<String> frontUrls){
+    public void RefreshFileSize(ArchivesAuto archive, List<ArchiveFile> datas, List<String> frontUrls) {
 
         List<String> fileUrls = new ArrayList<>();
-        for (ArchiveFile file: datas) {
+        for (ArchiveFile file : datas) {
             String url = getPdfFileUrl(file);
-            if(StringUtils.isEmpty(url)){
+            if (StringUtils.isEmpty(url)) {
                 continue;
             }
             fileUrls.add(url);
         }
 
         fileUrls.addAll(frontUrls);
-        List<FileSize>  fileSizes = org.springblade.common.utils.FileUtils.getOssFileSize(fileUrls);
+        List<FileSize> fileSizes = org.springblade.common.utils.FileUtils.getOssFileSize(fileUrls);
 
         double totalSize = fileSizes.stream()
                 .mapToDouble(FileSize::getFileSize)
@@ -809,9 +813,9 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
         //todo 生成相册内容,待补充
         int i = 0;
-        for (ArchiveFile file: datas) {
+        for (ArchiveFile file : datas) {
             double size = fileSizes.get(i).getFileSize();
-            if (file.getFileSize()!= null) {
+            if (file.getFileSize() != null) {
                 file.setFileSize(Math.round(size));
             }
         }
@@ -819,10 +823,11 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
     /**
      * 刷新档号
+     *
      * @param archive
      * @param fileNumber
      */
-    public boolean refreshFileNumber(ArchivesAuto archive,String fileNumber) {
+    public boolean refreshFileNumber(ArchivesAuto archive, String fileNumber) {
         //没变化则不用刷新
         if (fileNumber.equals(archive.getFileNumber())) {
             return false;
@@ -833,42 +838,44 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
         List<ArchiveFile> archiveFiles = archiveFileClient.getArchiveFileByArchiveID(archive.getId());
 
-        buildArchiveFrontPdfs(projectId,archive,archiveFiles,true);
+        buildArchiveFrontPdfs(projectId, archive, archiveFiles, true);
 
         return true;
     }
 
     /**
      * 刷新档号
+     *
      * @param archive
      * @param fileNumber
      */
-    public boolean refreshFileNumberForce(ArchivesAuto archive,String fileNumber) {
+    public boolean refreshFileNumberForce(ArchivesAuto archive, String fileNumber) {
         //没变化则不用刷新,强制刷新
         Long projectId = archive.getProjectId();
         archive.setFileNumber(fileNumber);
 
         List<ArchiveFile> archiveFiles = archiveFileClient.getArchiveFileByArchiveID(archive.getId());
 
-        buildArchiveFrontPdfs(projectId,archive,archiveFiles,true);
+        buildArchiveFrontPdfs(projectId, archive, archiveFiles, true);
 
         return true;
     }
 
     /**
      * 合并pdf并上传到oss
+     *
      * @param urlList
      * @param fileName
      * @return
      */
-    public String MergePdfAndUpload(List<String> urlList,String fileName,String filePath,Long pojectId) {
-       String url = "";
-       Long id = SnowFlakeUtil.getId();
-       String localPdf = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL) + "/pdf/" + id + ".pdf";
+    public String MergePdfAndUpload(List<String> urlList, String fileName, String filePath, Long pojectId) {
+        String url = "";
+        Long id = SnowFlakeUtil.getId();
+        String localPdf = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL) + "/pdf/" + id + ".pdf";
 
-       try {
+        try {
             //合并pdf
-            FileUtils.mergePdfPublicMethods(urlList,localPdf);
+            FileUtils.mergePdfPublicMethods(urlList, localPdf);
 
             if (StringUtils.isEmpty(filePath)) {
                 filePath = OssConstant.TEMP_DIRECTORY;
@@ -877,8 +884,8 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
             fileName += (OssConstant.SEPARATOR + id);
 
             //上传到oss
-           String absoluteFileName = FileUtils.getOssPath(OssConstant.TEMP_DIRECTORY,fileName,null);
-           BladeFile file = newIOSSClient.uploadFile(absoluteFileName + ".pdf", localPdf);
+            String absoluteFileName = FileUtils.getOssPath(OssConstant.TEMP_DIRECTORY, fileName, null);
+            BladeFile file = newIOSSClient.uploadFile(absoluteFileName + ".pdf", localPdf);
 
 
 //            BladeFile file  = newIOSSClient.uploadFile(fileName+ ".pdf", localPdf,filePath,pojectId);
@@ -890,22 +897,23 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
     }
 
     @Override
-    public String upFile(InputStream inputStream,Long projectId) {
+    public String upFile(InputStream inputStream, Long projectId) {
         String url = "";
         Long id = SnowFlakeUtil.getId();
         String localPdf = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL) + "/pdf/" + id + ".pdf";
         String fileName = id + ".pdf";
         try {
-            //合并pdf
+            //合并PDF
             byte[] bytes = FileUtils.InputStreamToBytes(inputStream);
             OutputStream outputStream = new FileOutputStream(localPdf);
             outputStream.write(bytes);
 
-            //上传到oss
-            String absoluteFileName = FileUtils.getOssPath(OssConstant.ARCHIVE_DIRECTORY,fileName,projectId);
+            //将PDF设置为A4纸大小
+            this.setPdfToA4Size(localPdf, localPdf);
 
+            //上传到OSS
+            String absoluteFileName = FileUtils.getOssPath(OssConstant.ARCHIVE_DIRECTORY, fileName, projectId);
             BladeFile file = newIOSSClient.uploadFile(absoluteFileName, localPdf);
-
             url = file.getLink();
         } catch (Exception e) {
             e.printStackTrace();
@@ -913,6 +921,24 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         return url;
     }
 
+    /**
+     * 设置pdf大小默认为A4纸大小
+     *
+     * @param inputPdfPath
+     * @param outputPdfPath
+     */
+    private void setPdfToA4Size(String inputPdfPath, String outputPdfPath) {
+        try {
+            PDDocument document = PDDocument.load(new File(inputPdfPath));
+            PDPage newPage = new PDPage(PDRectangle.A4);
+            document.removePage(0);
+            document.addPage(newPage);
+            document.save(outputPdfPath);
+            document.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 
 
 }

+ 12 - 15
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -3578,17 +3578,14 @@ public class InformationWriteQueryController extends BladeController {
                  * @author liuyc
                  * @date 2023年9月8日11:26:46
                  */
+
                 //不是工序,则查询当前节点下的所有填报节点
-                if (node.getParentId() == 0) {
-                    //当前合同段最底层节点pKeyIds
+                if (node.getParentId() == 0) { // TODO(暂不响应第一层根节点数据,数据量过多会导致响应超时)
+                    return R.fail("请从第三层级节点开始进行检索");
+
+                    /*//当前合同段最底层节点pKeyIds
                     List<WbsTreeContract> lowestNodesAll = jdbcTemplate.query("select a.p_key_id,a.id,(SELECT CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.contract_id = " + node.getContractId() + " AND b.status = 1 AND b.type = 1 AND b.is_deleted = 0) AS hasChildren from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + node.getContractId() + " HAVING hasChildren = 0", new BeanPropertyRowMapper<>(WbsTreeContract.class));
                     List<String> pKeyIds = lowestNodesAll.stream().map(WbsTreeContract::getPKeyId).map(String::valueOf).collect(Collectors.toList());
-
-                    /*TODO 暂时解决page数量过多导致响应超时问题*/
-                    if (pKeyIds.size() > 1000) {
-                        return R.fail("当前节点下子节点过多,请减少节点层级进行检索!");
-                    }
-
                     List<List<String>> partition = Lists.partition(pKeyIds, 1000);
                     for (List<String> items : partition) {
                         //获取填报节点信息
@@ -3596,20 +3593,20 @@ public class InformationWriteQueryController extends BladeController {
                         if (result.size() > 0) {
                             queryDataResult.addAll(result);
                         }
-                    }
+                    }*/
 
                     //queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractIdTwo("", contract.getContractType(), StringUtils.isNotEmpty(vo.getContractIdRelation()) ? vo.getContractIdRelation() : vo.getContractId().toString());
                 } else {
+                    //TODO 判断选择节点是否为第二层(暂不响应第二层数据,数据量过多会导致响应超时)
+                    WbsTreeContract wbsTreeContract = jdbcTemplate.query("select parent_id from m_wbs_tree_contract where is_deleted = 0 and status = 1 and type = 1 and id = " + node.getParentId() + " and contract_id = " + node.getContractId(), new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
+                    if (wbsTreeContract != null && wbsTreeContract.getParentId().equals(0L)) {
+                        return R.fail("请从第三层级节点开始进行检索");
+                    }
+
                     //获取当前选择的节点下的所有最底层节点
                     WbsTreeContractVO8 vo8 = BeanUtil.copyProperties(node, WbsTreeContractVO8.class);
                     this.lowestNodesRecursively(lowestNodes, Collections.singleton(vo8), node.getContractId());
                     List<String> pKeyIds = lowestNodes.stream().map(WbsTreeContractVO8::getPKeyId).map(String::valueOf).collect(Collectors.toList());
-
-                    /*TODO 暂时解决page数量过多导致响应超时问题*/
-                    if (pKeyIds.size() > 1000) {
-                        return R.fail("当前节点下子节点过多,请减少节点层级进行检索!");
-                    }
-
                     List<List<String>> partition = Lists.partition(pKeyIds, 1000);
                     for (List<String> items : partition) {
                         //获取填报节点信息

+ 1 - 3
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TaskBatchMapper.xml

@@ -26,9 +26,7 @@
     </delete>
 
     <select id="queryDataInfo" resultMap="taskBatchResultMap">
-        SELECT * from u_task_batch
-                 where id IN (SELECT max(id) from u_task_batch  WHERE is_deleted =0 GROUP BY JSON_EXTRACT(json_data,'$.formDataId')
-        ) LIMIT 100
+        SELECT * from u_task_batch where is_deleted not in(2,4) LIMIT 100
     </select>
 
 </mapper>

+ 13 - 10
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -63,6 +63,7 @@ import org.springframework.web.bind.annotation.RequestHeader;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.io.FileNotFoundException;
+import java.nio.file.Watchable;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -575,7 +576,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
     }
 
 
-    @Scheduled(cron = "0 */2 * * * ?")
+    @Scheduled(cron = "0 */1 * * * ?")
     public void SignInfo() {
         //执行代码
         logger.debug("扫描开始");
@@ -590,12 +591,13 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 
                 Boolean istrue = true;
                 try {
-                    Thread.sleep(200);
+                    Thread.sleep(500);
                 } catch (InterruptedException e) {
                     throw new RuntimeException(e);
                 }
+
                 Boolean aBoolean = RedisTemplate.hasKey("sign-" + taskApprovalVO.getFormDataId());
-                System.out.println(aBoolean);
+                System.out.println(taskApprovalVO.getFormDataId()+"---"+aBoolean);
                 if (aBoolean) {
                     istrue = false;
                 }
@@ -604,6 +606,8 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                     if (wtask >= 200) {
                         break;
                     }
+                    taskBatchService.update(Wrappers.<TaskBatch>update().set("is_deleted",2).eq("id",taskBatchId));
+                    RedisTemplate.opsForValue().set("sign-" + taskApprovalVO.getFormDataId(), "1", 66, TimeUnit.SECONDS);
                     CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
                         try {
                             this.checkIsExsitTaskBatch(taskApprovalVO, taskBatchId, userId, nickName);
@@ -611,14 +615,14 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                             e.printStackTrace();
                         }
                     }, executor);
-                    runAsync.join();
+
                 }
             }
-            System.out.println("队列数量" + executor.getQueue().size());
-            System.out.println("活跃数量" + executor.getActiveCount());
-            System.out.println("总共数量" + executor.getTaskCount());
-            System.out.println("完成数量" + executor.getCompletedTaskCount());
         }
+        System.out.println("队列数量" + executor.getQueue().size());
+        System.out.println("活跃数量" + executor.getActiveCount());
+        System.out.println("总共数量" + executor.getTaskCount());
+        System.out.println("完成数量" + executor.getCompletedTaskCount());
     }
 
     private void checkIsExsitTaskBatch(TaskApprovalVO taskApprovalVO, String batchId, Long userId, String nickName) throws FileNotFoundException {
@@ -626,7 +630,6 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
         taskApprovalVO.setId(batchId);
         taskApprovalVO.setUserId(userId);
         taskApprovalVO.setNickName(nickName);
-        RedisTemplate.opsForValue().set("sign-" + taskApprovalVO.getFormDataId(), "1", 125, TimeUnit.SECONDS);
 
         String pdfUrlEVisa = this.completeApprovalTask(taskApprovalVO);
 
@@ -684,7 +687,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
             } else if ("success".equals(eVisaStatus) || eVisaStatus.contains("success")) {
                 //审批通过会返回签章成功的文件,需要设置替换
                 //完成/审批当前分支流程
-                this.newFlowClient.completeApprovalTask(taskId, parallelProcessInstanceId, comment).getData();
+            //    this.newFlowClient.completeApprovalTask(taskId, parallelProcessInstanceId, comment).getData();
                 //修改分支状态,改为已完成
                 this.taskParallelService.update(Wrappers.<TaskParallel>lambdaUpdate()
                         .set(TaskParallel::getStatus, 2)

+ 98 - 66
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVisaController.java

@@ -1,21 +1,28 @@
 package org.springblade.evisa.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.springblade.business.entity.TaskBatch;
+import org.springblade.business.vo.TaskApprovalVO;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import java.io.BufferedReader;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.util.List;
 import java.util.Set;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
 
 import java.lang.management.ManagementFactory;
 import java.lang.management.OperatingSystemMXBean;
@@ -29,71 +36,96 @@ import java.lang.management.OperatingSystemMXBean;
 @AllArgsConstructor
 @RequestMapping("/evisaInfo")
 @Api(value = "电签类", tags = "电签类接口")
+@Slf4j
 public class EVisaController {
 
     @Autowired
     StringRedisTemplate RedisTemplate;
 
-    // 线程池中初始线程个数
-    private final static Integer CORE_POOL_SIZE =20;
-    // 线程池中允许的最大线程数
-    private final static Integer MAXIMUM_POOL_SIZE = 30;
-    // 当线程数大于初始线程时。终止多余的空闲线程等待新任务的最长时间
-    private final static Long KEEP_ALIVE_TIME = 10L;
-    // 任务缓存队列 ,即线程数大于初始线程数时先进入队列中等待,此数字可以稍微设置大点,避免线程数超过最大线程数时报错。或者直接用无界队列
-    private final static LinkedBlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
-    ThreadPoolExecutor threadPoolExecutor = null;
-    // 自定义线程池,开发推荐使用
-    public static ThreadPoolExecutor ITDragonThreadPoolExecutor() {
-        // 构建一个,初始线程数量为3,最大线程数据为8,等待时间10分钟 ,队列长度为5 的线程池
-        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
-                CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME, TimeUnit.MINUTES, WORK_QUEUE);
-        return threadPoolExecutor;
-    }
-
-  //  @Scheduled(cron = "0 */3 * * * ?")
-    public void StartEvisInfo() {
-        if(threadPoolExecutor==null){
-            threadPoolExecutor = ITDragonThreadPoolExecutor();
-        }
-
-        for (int i = 0; i < 10; i++) {	// 执行8个任务,若超过MAXIMUM_POOL_SIZE则会报错 RejectedExecutionException
-            RedisTemplate.opsForValue().set("sign-" + i, "1", 63, TimeUnit.SECONDS);
-        }
-        System.out.println("完成");
-    }
-
-    @Scheduled(cron = "0 */1 * * * ?")
-    public void runEvisInfo() {
-
-        Set<String> keys = RedisTemplate.keys("sign-*");
-        System.out.println(keys.size());
-    }
-
-    static class MyRunnableTest implements Runnable {
-        private Integer num;	// 正在执行的任务数
-        public MyRunnableTest(Integer num) {
-            this.num = num;
-        }
-        public void run() {
-            System.out.println("正在执行的MyRunnable " + num);
-            try {
-                Thread.sleep(1000);// 模拟执行事务需要耗时
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-            System.out.println("MyRunnable " + num + "执行完毕");
-        }
-    }
-
-
-
-
-        public static void main2(String[] args) {
-            OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
-            double cpuUsage = operatingSystemMXBean.getSystemLoadAverage();
-            System.out.println("CPU Usage: " + cpuUsage);
-        }
-
-
+    private final JdbcTemplate jdbcTemplate;
+
+    // 线程池
+    @Resource(name = "taskExecutor1")
+    private ThreadPoolExecutor executor;
+
+    // 电签主类
+//    @Scheduled(cron = "0 */1 * * * ?")
+//    public void SignInfo() {
+//        //执行代码
+//        log.info("扫描开始");
+//        String sql = "SELECT * from u_task_batch where is_deleted not in(2,4) LIMIT 100";
+//        List<TaskBatch> maps = jdbcTemplate.queryForList(sql,TaskBatch.class);
+//        if (maps != null && maps.size() >= 1) {
+//            for (TaskBatch dataInfo : maps) {
+//                String jsonData = dataInfo.getJsonData();
+//                TaskApprovalVO taskApprovalVO = JSON.parseObject(jsonData, TaskApprovalVO.class);
+//                String taskBatchId = dataInfo.getId().toString();
+//                Long userId = dataInfo.getCreateUser();
+//                String nickName = dataInfo.getNickName();
+//
+//                Boolean istrue = true;
+//                try {
+//                    Thread.sleep(500);
+//                } catch (InterruptedException e) {
+//                    throw new RuntimeException(e);
+//                }
+//
+//                Boolean aBoolean = RedisTemplate.hasKey("sign-" + taskApprovalVO.getFormDataId());
+//                System.out.println(taskApprovalVO.getFormDataId()+"---"+aBoolean);
+//                if (aBoolean) {
+//                    istrue = false;
+//                }
+//                if (istrue) {
+//                    int wtask = executor.getQueue().size();
+//                    if (wtask >= 200) {
+//                        break;
+//                    }
+//                    jdbcTemplate.execute("update u_task_batch set is_deleted=2 where id="+taskBatchId+"");
+//                    RedisTemplate.opsForValue().set("sign-" + taskApprovalVO.getFormDataId(), "1", 66, TimeUnit.SECONDS);
+//                    CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
+//                        try {
+//                            this.checkIsExsitTaskBatch(taskApprovalVO, taskBatchId, userId, nickName);
+//                        } catch (FileNotFoundException e) {
+//                            e.printStackTrace();
+//                        }
+//                    }, executor);
+//                }
+//            }
+//        }
+//    }
+//
+//    private void checkIsExsitTaskBatch(TaskApprovalVO taskApprovalVO, String batchId, Long userId, String nickName) throws FileNotFoundException {
+//        log.info("【任务审核】当前批次开始电签。批次ID:" + batchId);
+//        taskApprovalVO.setId(batchId);
+//        taskApprovalVO.setUserId(userId);
+//        taskApprovalVO.setNickName(nickName);
+//        String pdfUrlEVisa = this.completeApprovalTask(taskApprovalVO);
+//
+//        System.out.println("电签操作成功buss-----" + pdfUrlEVisa + "---batchId=" + batchId);
+//        //TODO ============== 电签成功,修改试验状态,关联工程部位信息pdf(只有电签成功,才修改) liuYc 2023-03-16 ==============
+//        if ("OK".equals(taskApprovalVO.getFlag()) && StringUtils.isNotEmpty(pdfUrlEVisa)) {
+//            //已审批
+//            this.iTrialSelfInspectionRecordService.updateTrialSelfInspectionRecordStatus(pdfUrlEVisa, taskApprovalVO);
+//            //executor删除掉对应批次
+//            this.taskBatchService.deletedById(batchId);
+//        }
+//
+//        if (!"OK".equals(taskApprovalVO.getFlag())) {
+//            //已废除
+//            this.iTrialSelfInspectionRecordService.updateTrialSelfInspectionRecordStatusFC(taskApprovalVO);
+//            //executor删除掉对应批次
+//            this.taskBatchService.deletedById(batchId);
+//        }
+//        RedisTemplate.delete("sign-" + taskApprovalVO.getFormDataId());
+//    }
+//
+//    private String completeApprovalTask(TaskApprovalVO taskApprovalVO) {
+//        if ("OK".equals(taskApprovalVO.getFlag())) { // 电签流程
+//
+//        }else { //任务废除
+//
+//        }
+//
+//        return "";
+//    }
 }

+ 11 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TextdictInfoController.java

@@ -427,7 +427,7 @@ public class TextdictInfoController extends BladeController {
         String ids = StringUtils.join(pKeyIds, ",");
 
         //删除历史数据
-        String delSql = "delete from m_textdict_info where (tab_id in(SELECT p_key_id from m_wbs_tree_private where project_id='"+wbsTreePrivate.getProjectId()+"' and excel_id='"+wbsTreePrivate.getExcelId()+"' and type=2 and is_deleted=0) or excel_id="+wbsTreePrivate.getExcelId()+") and project_id="+wbsTreePrivate.getProjectId()+" and type in(2,6) ";
+        String delSql = "delete from m_textdict_info where (tab_id in(SELECT p_key_id from m_wbs_tree_private where project_id='"+wbsTreePrivate.getProjectId()+"' and excel_id='"+wbsTreePrivate.getExcelId()+"' and type=2 and is_deleted=0) or (excel_id="+wbsTreePrivate.getExcelId()+" AND project_id='"+wbsTreePrivate.getProjectId()+"')) and project_id="+wbsTreePrivate.getProjectId()+" and type in(2,6) ";
         jdbcTemplate.execute(delSql);
 
         // ------- 查询数据库是否存在 该该电签信息 ---------
@@ -458,7 +458,15 @@ public class TextdictInfoController extends BladeController {
             textdictInfo.setPyzbx(jsonObject.getDouble("pyzbx"));
             textdictInfo.setPyzby(jsonObject.getDouble("pyzby"));
             textdictInfo.setProjectId(wbsTreePrivate.getProjectId());
-            textdictInfoService.saveOrUpdate(textdictInfo);
+
+            //由于使用联合主键
+            TextdictInfo one = textdictInfoService.getOne(Wrappers.<TextdictInfo>query().eq("id", textdictInfo.getId()).eq("project_id", textdictInfo.getProjectId()));
+            if(ObjectUtil.isNotEmpty(one)){
+                textdictInfoService.saveOrUpdate(textdictInfo);
+            }else{
+                textdictInfoService.save(textdictInfo);
+            }
+
             element.removeAttr("dqId");
             element.attr("dqId", textdictInfo.getId() + "");
             if (jsonObject.getInteger("type") == 2) { //个人签字 不能用户输入
@@ -561,6 +569,7 @@ public class TextdictInfoController extends BladeController {
             textDictBean.setColName(placeholder);
             textDictBean.setSigRoleName(textdictInfo.getTextId());
             textDictBean.setIsDeleted(0);
+            textDictBean.setProjectId(wbsTreePrivate.getProjectId());
 
             textDictInfosNew.add(textDictBean);
 

+ 5 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/InspectionRectifyMapper.java

@@ -3,11 +3,16 @@ package org.springblade.manager.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
+import org.springblade.manager.dto.InspectionRectifyDTO;
 import org.springblade.manager.entity.InspectionRectify;
 import org.springblade.manager.entity.RoutingInspection;
 
+import java.util.List;
+
 
 public interface InspectionRectifyMapper extends BaseMapper<InspectionRectify> {
 
     void deleteByInspectId(@Param("inspectId") Long inspectId);
+
+    List<InspectionRectifyDTO> getDTOList(@Param("inspectId") Long inspectId);
 }

+ 5 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/InspectionRectifyMapper.xml

@@ -6,4 +6,9 @@
         DELETE FROM m_inspection_rectify
         WHERE inspect_id = #{inspectId}
     </delete>
+    <select id="getDTOList" resultType="org.springblade.manager.dto.InspectionRectifyDTO">
+        select *
+        from m_inspection_rectify
+        where is_deleted = 0 and inspect_id = #{inspectId}
+    </select>
 </mapper>

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

@@ -46,5 +46,5 @@ public interface TextdictInfoMapper extends EasyBaseMapper<TextdictInfo> {
 
 
     List<TextdictInfoVO> selectTextdictInfoByExcelId(IPage page, TextdictInfoVO textdictInfo);
-
+    List<TextdictInfoVO> selectTextdictBYIds(@Param("ids") List<String> ids);
 }

+ 11 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TextdictInfoMapper.xml

@@ -39,8 +39,16 @@
     </select>
 
     <select id="selectTextdictInfoByExcelId" resultMap="textdictInfoResultMap">
-        select distinct * from m_textdict_info where is_deleted = 0
-        and type in('2','6')
-        and id in( SELECT max(id) from m_textdict_info where excel_id=#{param2.excelId} and type in(2,6) GROUP BY col_key )
+        SELECT a.* from m_textdict_info a,
+                        (select tab_id,count(1) from m_textdict_info where is_deleted = 0 and type in('2','6') and excel_id=#{param2.excelId} GROUP BY tab_id ORDER BY count(tab_id) desc LIMIT 1) b
+        where a.tab_id=b.tab_id and a.is_deleted = 0 and a.type in('2','6') and a.excel_id=#{param2.excelId}
+    </select>
+
+    <select id="selectTextdictBYIds" resultMap="textdictInfoResultMap">
+        SELECT a.* from m_textdict_info a
+        where id in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
     </select>
 </mapper>

+ 4 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IInspectionRectifyService.java

@@ -1,12 +1,16 @@
 package org.springblade.manager.service;
 
 import org.springblade.core.mp.base.BaseService;
+import org.springblade.manager.dto.InspectionRectifyDTO;
 import org.springblade.manager.entity.InspectionRectify;
 import org.springblade.manager.entity.RoutingInspection;
 
+import java.util.List;
+
 public interface IInspectionRectifyService extends BaseService<InspectionRectify> {
 
     //真实删除检查项目
     void deleteByInspectId(Long inspectId);
 
+    List<InspectionRectifyDTO> getDTOList(Long inspectId);
 }

+ 1 - 7
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1812,13 +1812,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         FileOutputStream outputStream = new FileOutputStream(excelPath);
         workbook.write(outputStream);
 
-        FileUtils.excelToPdf(excelPath, pdfPath);
-        //  com.spire.xls.Workbook workbook2 = new com.spire.xls.Workbook();
-
-        //  workbook2.loadFromFile(excelPath);
-        //设置转换后的PDF页面高宽适应工作表的内容大小
-        //workbook2.getConverterSetting().setSheetFitToPage(true);
-        // workbook2.saveToFile(pdfPath, FileFormat.PDF);
+        FileUtils.excel2pdf(excelPath, pdfPath);
 
         BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
 

+ 8 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/InspectionRectifyServiceImpl.java

@@ -3,6 +3,7 @@ package org.springblade.manager.service.impl;
 import lombok.AllArgsConstructor;
 import org.springblade.core.mp.base.BaseEntity;
 import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.manager.dto.InspectionRectifyDTO;
 import org.springblade.manager.entity.InspectionRectify;
 import org.springblade.manager.entity.RoutingInspection;
 import org.springblade.manager.mapper.InspectionRectifyMapper;
@@ -11,6 +12,8 @@ import org.springblade.manager.service.IInspectionRectifyService;
 import org.springblade.manager.service.IRoutingInspectionService;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 @AllArgsConstructor
 public class InspectionRectifyServiceImpl extends BaseServiceImpl<InspectionRectifyMapper, InspectionRectify> implements IInspectionRectifyService {
@@ -19,4 +22,9 @@ public class InspectionRectifyServiceImpl extends BaseServiceImpl<InspectionRect
     public void deleteByInspectId(Long inspectId) {
         baseMapper.deleteByInspectId(inspectId);
     }
+
+    @Override
+    public List<InspectionRectifyDTO> getDTOList(Long inspectId) {
+        return baseMapper.getDTOList(inspectId);
+    }
 }

+ 40 - 13
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/RoutingInspectionServiceImpl.java

@@ -1,5 +1,6 @@
 package org.springblade.manager.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -17,10 +18,7 @@ import org.springblade.core.mp.support.Query;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.constant.BladeConstant;
 import org.springblade.core.tool.utils.Func;
-import org.springblade.manager.dto.ArchiveTreeContractAutoRuleMapDTO;
-import org.springblade.manager.dto.ArchiveTreeDTO;
-import org.springblade.manager.dto.ArchiveTreeSortDTO;
-import org.springblade.manager.dto.RoutingInspectionDTO;
+import org.springblade.manager.dto.*;
 import org.springblade.manager.entity.*;
 import org.springblade.manager.mapper.ArchiveAutoRuleWbsMapper;
 import org.springblade.manager.mapper.ArchiveTreeMapper;
@@ -33,6 +31,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDate;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -46,7 +45,7 @@ public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspect
     @Transactional
     public void add(RoutingInspectionDTO dto) {
         //获取检查部位
-        List<InspectionRectify> list = dto.getList();
+        List<InspectionRectifyDTO> list = dto.getList();
         if (list == null || list.size() == 0){
             throw new ServiceException("请填写检查项目");
         }
@@ -57,15 +56,22 @@ public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspect
         inspection.setId(id);
         this.save(inspection);
         //再保存具体的巡检项目
-        list.stream().forEach(l->l.setInspectId(id));
-        rectifyService.saveBatch(list);
+        List<InspectionRectify> list1 = list.stream().map(l -> {
+            InspectionRectify rectify = new InspectionRectify();
+            BeanUtils.copyProperties(l, rectify);
+            rectify.setInspectId(id);
+            List<String> autoExpandKeys = l.getAutoExpandKeys();
+            rectify.setInspectLocation(JSON.toJSONString(autoExpandKeys));
+            return rectify;
+        }).collect(Collectors.toList());
+        rectifyService.saveBatch(list1);
     }
 
     @Override
     @Transactional
     public void Update(RoutingInspectionDTO dto) {
         //获取检查部位
-        List<InspectionRectify> list = dto.getList();
+        List<InspectionRectifyDTO> list = dto.getList();
         if (list == null || list.size() == 0){
             throw new ServiceException("请填写检查项目");
         }
@@ -74,8 +80,16 @@ public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspect
         this.updateById(inspection);
         //修改先删除,再保存
         rectifyService.deleteByInspectId(dto.getId());
-        list.stream().forEach(l->l.setInspectId(dto.getId()));
-        rectifyService.saveBatch(list);
+        //再保存具体的巡检项目
+        List<InspectionRectify> list1 = list.stream().map(l -> {
+            InspectionRectify rectify = new InspectionRectify();
+            BeanUtils.copyProperties(l, rectify);
+            rectify.setInspectId(dto.getId());
+            List<String> autoExpandKeys = l.getAutoExpandKeys();
+            rectify.setInspectLocation(JSON.toJSONString(autoExpandKeys));
+            return rectify;
+        }).collect(Collectors.toList());
+        rectifyService.saveBatch(list1);
     }
 
     @Override
@@ -97,7 +111,8 @@ public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspect
     @Override
     public RoutingInspectionVO2 detail(Long id) {
         //先查出巡检项目集合
-        List<InspectionRectify> list = rectifyService.list(new LambdaQueryWrapper<InspectionRectify>().eq(InspectionRectify::getInspectId, id));
+        List<InspectionRectifyDTO> list = rectifyService.getDTOList(id);
+        list.stream().forEach(l->l.setAutoExpandKeys(JSON.parseArray(l.getInspectLocation(),String.class)));
         //再查出巡检信息,集合设置进巡检信息
         RoutingInspection inspection = this.getById(id);
         RoutingInspectionVO2 vo2 = new RoutingInspectionVO2();
@@ -113,6 +128,7 @@ public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspect
             //复检未通过,修改复检状态为2未通过
             this.update(new LambdaUpdateWrapper<RoutingInspection>()
                     .set(RoutingInspection::getReviewInspectStatus,2)
+                    .set(RoutingInspection::getSubmitRectify,1)
                     .eq(RoutingInspection::getId,id));
         }else if (status == 2){
             //复检通过,修改复检状态为3通过,修改整改状态为2不用整改
@@ -131,10 +147,20 @@ public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspect
         //修改巡检信息状态为已经整改
         this.update(new LambdaUpdateWrapper<RoutingInspection>()
                 .set(RoutingInspection::getSubmitRectify,2)
+                .set(RoutingInspection::getActualRectifyDate, LocalDate.now())
                 .eq(RoutingInspection::getId,dto.getId()));
         //保存检查项目
-        List<InspectionRectify> list = dto.getList();
-        rectifyService.updateBatchById(list);
+        List<InspectionRectifyDTO> list = dto.getList();
+        //再保存具体的巡检项目
+        List<InspectionRectify> list1 = list.stream().map(l -> {
+            InspectionRectify rectify = new InspectionRectify();
+            BeanUtils.copyProperties(l, rectify);
+            //整改只能修改整改信息
+            List<String> autoExpandKeys = l.getAutoExpandKeys();
+            rectify.setInspectLocation(JSON.toJSONString(autoExpandKeys));
+            return rectify;
+        }).collect(Collectors.toList());
+        rectifyService.updateBatchById(list1);
     }
 
     @Override
@@ -142,6 +168,7 @@ public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspect
         //修改巡检信息为未整改
         this.update(new LambdaUpdateWrapper<RoutingInspection>()
                 .set(RoutingInspection::getSubmitRectify,1)
+                .set(RoutingInspection::getActualRectifyDate,null)
                 .eq(RoutingInspection::getId,id));
     }
 }

+ 21 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TextdictInfoServiceImpl.java

@@ -23,6 +23,7 @@ import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.support.Try;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.IoUtil;
 import org.springblade.manager.entity.TextdictInfo;
@@ -44,6 +45,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 参数信息表 服务实现类
@@ -58,20 +60,30 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
     @Override
     public IPage<TextdictInfoVO> selectTextdictInfoPage(IPage<TextdictInfoVO> page, TextdictInfoVO textdictInfo) {
         List<TextdictInfoVO> textdict = new ArrayList<>();
-
         if(textdictInfo.getType()==2){
-            WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda()
-                    .eq(WbsTreePrivate::getPKeyId, Func.toLong(textdictInfo.getTabId()))
-                    .eq(WbsTreePrivate::getIsDeleted, 0));
-            // 通过项目Id 和excel 进行匹配
-            textdictInfo.setProjectId(wbsTreePrivate.getProjectId());
-            textdict = baseMapper.selectTextdictInfoPage(page, textdictInfo);
-            if(textdict==null || textdict.size()<=0){ //用excel 进行匹配
-                textdict = baseMapper.selectTextdictInfoByExcelId(page, textdictInfo);
+            WbsTreePrivate privateInfo = wbsTreePrivateMapper.getByPKeyId(Func.toLong(textdictInfo.getTabId() + ""));
+            String htmlUrl = privateInfo.getHtmlUrl();
+            try {
+                InputStream fileInputStream = FileUtils.getInputStreamByUrl(htmlUrl);
+                String htmlString = IoUtil.readToString(fileInputStream);
+                Document doc = Jsoup.parse(htmlString);
+                Elements table = doc.getElementsByAttribute("dqid");
+                if(table.size()>=1){
+                    List<String> dqid = table.stream().map(d -> d.attr("dqid")).distinct().collect(Collectors.toList());
+                    textdict = baseMapper.selectTextdictBYIds(dqid);
+                    if(textdict==null || textdict.size()<=0){
+                        textdict = baseMapper.selectTextdictInfoByExcelId(page, textdictInfo);
+                    }
+                }else{
+                    textdict = baseMapper.selectTextdictInfoByExcelId(page, textdictInfo);
+                }
+            } catch (Exception e) {
+                throw new RuntimeException(e);
             }
         }else{
             textdict = baseMapper.selectTextdictInfoPage(page, textdictInfo);
         }
+        System.out.println("+++++++++++++++"+textdict.size());
         return page.setRecords(textdict);
     }
 

+ 84 - 27
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/FileUtils.java

@@ -1,6 +1,8 @@
 package org.springblade.manager.utils;
 
 import com.aliyun.oss.common.utils.DateUtil;
+import com.aspose.cells.License;
+import com.aspose.cells.PdfSaveOptions;
 import com.aspose.cells.SaveFormat;
 import com.aspose.cells.Workbook;
 import com.itextpdf.text.Document;
@@ -239,7 +241,7 @@ public class FileUtils {
                 sheet.setPrintGridlines(false);
                 //设置 整个工作表为一页
                 sheet.setFitToPage(true);
-
+                sheet.getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE);
             }
             outReport = new ByteArrayOutputStream();
             ss.write(outReport);
@@ -425,32 +427,6 @@ public class FileUtils {
     }
 
 
-//    public static void main(String[] args) throws Exception {
-//       String excelUrl = "/Users/hongchuangyanfa/Downloads/D10.1表-隧道总体质量检验单 (1).xlsx";
-//        String old_html = "/Users/hongchuangyanfa/Desktop/pdf/old_html.html";
-//        String old_xlsx = "/Users/hongchuangyanfa/Desktop/pdf/old_html.xlsx";
-//
-//   //     excelInfo2(excelUrl,old_xlsx,old_html);
-//        com.spire.xls.Workbook wb = new com.spire.xls.Workbook();
-//        wb.loadFromMHtml(old_xlsx);
-//        Worksheet sheet = wb.getWorksheets().get(0);
-//        CellRange[] cells = sheet.getCells();
-//        for (int i = 0; i < cells.length; i++) {
-//            CellRange oldcell = cells[i];
-//            CellRange mergedCell = sheet.getCellRange(oldcell.getRow(), oldcell.getColumn());
-//            String data = mergedCell.getDataValidation().getErrorMessage();
-//            System.out.println(oldcell.getRow()+"--=--"+oldcell.getColumn()+"--=--"+data);
-//        }
-//
-///*        String new_html = "/Users/hongchuangyanfa/Desktop/pdf/new_html.html";
-//        String new_xlsx = "/Users/hongchuangyanfa/Desktop/pdf/new_html.xlsx";
-//
-//        File data = new File(old_xlsx);
-//        InputStream inputStream = new FileInputStream(data);
-//        excelInfo(inputStream,new_xlsx,new_html,"2");*/
-//    }
-
-
     /**
      * 在线编辑excel 操作
      *
@@ -789,4 +765,85 @@ public class FileUtils {
         }
     }
 
+
+
+
+    public static boolean getLicense() {
+        boolean result = false;
+        try {
+            InputStream is = test.class.getClassLoader().getResourceAsStream("\\license.xml");
+            License aposeLic = new License();
+            aposeLic.setLicense(is);
+            result = true;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    public static void excel2pdf(String sourceFilePath, String desFilePathd ){
+        // 验证License 若不验证则转化出的pdf文档会有水印产生
+        if (!getLicense()) {
+            return;
+        }
+        try {
+            Workbook wb = new Workbook(sourceFilePath);// 原始excel路径
+
+            PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
+            pdfSaveOptions.setOnePagePerSheet(true);
+            pdfSaveOptions.setEmbedStandardWindowsFonts(true);
+
+            com.aspose.cells.Worksheet worksheet = wb.getWorksheets().get(0);
+            worksheet.getPageSetup().setPaperSize(com.aspose.cells.PaperSizeType.PAPER_A_4);
+            worksheet.getPageSetup().setLeftMargin(1.9);
+            worksheet.getPageSetup().setRightMargin(1.9);
+            int[] autoDrawSheets={3};
+            //当excel中对应的sheet页宽度太大时,在PDF中会拆断并分页。此处等比缩放。
+            autoDraw(wb,autoDrawSheets);
+
+            int[] showSheets={0};
+            //隐藏workbook中不需要的sheet页。
+            printSheetPage(wb,showSheets);
+            wb.save(desFilePathd, pdfSaveOptions);
+            System.out.println("完毕");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * 设置打印的sheet 自动拉伸比例
+     * @param wb
+     * @param page 自动拉伸的页的sheet数组
+     */
+    public static void autoDraw(Workbook wb,int[] page){
+        if(null!=page&&page.length>0){
+            for (int i = 0; i < page.length; i++) {
+                wb.getWorksheets().get(i).getHorizontalPageBreaks().clear();
+                wb.getWorksheets().get(i).getVerticalPageBreaks().clear();
+            }
+        }
+    }
+
+
+    /**
+     * 隐藏workbook中不需要的sheet页。
+     * @param wb
+     * @param page 显示页的sheet数组
+     */
+    public static void printSheetPage(Workbook wb,int[] page){
+        for (int i= 1; i < wb.getWorksheets().getCount(); i++)  {
+            wb.getWorksheets().get(i).setVisible(false);
+        }
+        if(null==page||page.length==0){
+            wb.getWorksheets().get(0).setVisible(true);
+        }else{
+            for (int i = 0; i < page.length; i++) {
+                wb.getWorksheets().get(i).setVisible(true);
+            }
+        }
+    }
+
 }