Browse Source

数据修改1

zhuwei 2 months ago
parent
commit
89f6b802a2
20 changed files with 539 additions and 678 deletions
  1. 1 1
      blade-common/src/main/java/org/springblade/common/utils/AsyncConfigurer.java
  2. 22 1
      blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java
  3. 6 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TaskSignInfoVO.java
  4. 1 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java
  5. 2 1
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVController.java
  6. 1 1
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVisaController.java
  7. 0 135
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVisaJLController.java
  8. 256 90
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/impl/EVDataServiceImpl.java
  9. 67 0
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/FileUtils.java
  10. 57 2
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PDFUtils.java
  11. 0 76
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/ThreadPoolDemo.java
  12. 1 139
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java
  13. 1 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/TableElementConverter.java
  14. 59 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java
  15. 0 213
      blade-service/blade-manager/src/main/java/org/springblade/manager/utils/CreateDashedLine.java
  16. 1 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/utils/PdfAddimgUtil.java
  17. 1 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.xml
  18. 6 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MiddleMeterApplyServiceImpl.java
  19. 56 14
      blade-service/blade-meter/src/main/java/org/springblade/meter/utils/PdfAddimgUtil.java
  20. 1 0
      blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleMapper.xml

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

@@ -24,7 +24,7 @@ public class AsyncConfigurer {
     @Bean("taskExecutor1")
     public ThreadPoolExecutor getAsyncExecutor() {
         return new ThreadPoolMonitor(cpuNum
-                , 6
+                , 5
                 , 180
                 , TimeUnit.SECONDS
                 , new LinkedBlockingQueue<>(2000)

+ 22 - 1
blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java

@@ -46,8 +46,8 @@ import org.springframework.util.ResourceUtils;
  *
  * @author Chill
  */
-public class CommonUtil {
 
+public class CommonUtil {
     public static Boolean checkBigDecimal(Object value) {
         try {
             if (value != null && StringUtils.isNotEmpty(value.toString())) {
@@ -112,6 +112,27 @@ public class CommonUtil {
         return pattern.matcher(value);
     }
 
+    /**
+     * 文件流转化为File
+     */
+    public static void convert(InputStream inputStream, String targetFile) throws IOException {
+        // 创建文件输出流
+        FileOutputStream outputStream = new FileOutputStream(targetFile);
+
+        // 创建缓冲区
+        byte[] buffer = new byte[1024];
+        int bytesRead;
+
+        // 从输入流读取数据并写入输出流
+        while ((bytesRead = inputStream.read(buffer)) != -1) {
+            outputStream.write(buffer, 0, bytesRead);
+        }
+
+        // 关闭流
+        outputStream.close();
+        inputStream.close();
+    }
+
     /**
      * 根据OSS文件路径获取文件输入流
      */

+ 6 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TaskSignInfoVO.java

@@ -57,6 +57,12 @@ public class TaskSignInfoVO {
     @ApiModelProperty("电签格式")
     private String signFormat;
 
+    @ApiModelProperty("pdf上的时间")
+    private String pdfDate;
+
+    @ApiModelProperty("数据类型 ")
+    private String pdfDataType;
+
     /**
      * 获取是否通过
      */

+ 1 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -589,6 +589,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                 .set(TaskParallel::getEVisaContent, "当前等待电签的批次较多,请等待几分钟后刷新页面查看........")
                 .set(TaskParallel::getStatus, 1)
                 .set(TaskParallel::getEVisaStatus, 0)
+                        .set(TaskParallel::getInitiative, 1)
                 .in(TaskParallel::getParallelProcessInstanceId, taskIds));
 
         List<TaskBatch> taskList = new ArrayList<>();

+ 2 - 1
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVController.java

@@ -60,7 +60,8 @@ public class EVController {
     public void SignInfo() {
         //执行代码
         log.info("扫描开始");
-        String sql = "SELECT * from u_task_batch where is_deleted=5 and id in(SELECT max(id) as id from u_task_batch where is_deleted=5 GROUP BY JSON_EXTRACT(json_data, '$.formDataId')) LIMIT 10 ";
+        String sql = "SELECT * from u_task_batch where is_deleted=0 and id in(SELECT max(id) as id from u_task_batch where JSON_EXTRACT(json_data, '$.approvalType')=1 and  is_deleted=0 GROUP BY JSON_EXTRACT(json_data, '$.formDataId')) LIMIT 10 ";
+
         List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
         if (maps != null && maps.size() >= 1 ) {
             for (Map<String, Object> dataInfo : maps) {

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

@@ -65,7 +65,7 @@ public class EVisaController {
     public void SignInfo() {
         //执行代码
         log.info("扫描开始");
-        String sql = "SELECT * from u_task_batch where is_deleted=0 and JSON_EXTRACT(json_data, '$.taskId')=1858792664296587264 and id in(SELECT max(id) as id from u_task_batch where is_deleted=0 GROUP BY JSON_EXTRACT(json_data, '$.formDataId')) LIMIT 10 ";
+        String sql = "SELECT * from u_task_batch where is_deleted=0  and id in(SELECT max(id) as id from u_task_batch where is_deleted=0 GROUP BY JSON_EXTRACT(json_data, '$.formDataId')) LIMIT 10 ";
         //String sql = "SELECT * from u_task_batch where is_deleted=5 and `status`=2";
         List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
         if (maps != null && maps.size() >= 1 && SystemUtils.isLinux()) {//&& SystemUtils.isLinux()

+ 0 - 135
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVisaJLController.java

@@ -1,135 +0,0 @@
-package org.springblade.evisa.controller;
-
-import io.swagger.annotations.Api;
-import lombok.AllArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springblade.business.feign.TaskClient;
-import org.springblade.business.vo.TaskApprovalVO;
-import org.springblade.common.utils.CommonUtil;
-import org.springblade.evisa.service.EVisaService;
-import org.springblade.evisa.utils.FileUtils;
-import org.springblade.evisa.utils.PdfAddimgUtil;
-import org.springblade.manager.vo.PDFIndexInfo;
-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.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Pattern;
-
-
-/**
- * 清表基础数据表 控制器
- *
- * @author BladeX
- * @since 2022-05-18
- */
-@RestController
-@AllArgsConstructor
-@RequestMapping("/evisaInfo")
-@Api(value = "电签类", tags = "电签类接口")
-@Slf4j
-public class EVisaJLController {
-
-    @Autowired
-    StringRedisTemplate RedisTemplate;
-    // jdbc
-    private final JdbcTemplate jdbcTemplate;
-
-    //电签服务类
-    private final EVisaService eVisaService;
-
-    // 线程池
-    @Resource(name = "taskExecutor1")
-    private ThreadPoolExecutor executor;
-
-    // 电签主类
-    //@Scheduled(cron = "0/10 * * * * ?")
-    public void SignInfo() {
-        //执行代码
-        log.info("扫描开始");
-       // String sql = "SELECT a.* from u_information_query a where a.wbs_id in(SELECT p_key_id from m_wbs_tree_contract where project_id=1630011899725201410) and a.business_time is null and (a.pdf_url is not null or e_visa_pdf_url is not null) and `status` in(1,2) and is_deleted=0 limit 100";
-        String sql = "SELECT * FROM u_archive_file where project_id=1630011899725201410 and LENGTH(file_time)<=0 and is_deleted<>2  limit 100";
-        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
-        if (maps != null && maps.size() >= 1 ) {//&& SystemUtils.isLinux()
-            for (Map<String, Object> dataInfo : maps) {
-                if (executor.getQueue().size()<=100 ) {
-
-
-                    TaskApprovalVO taskApprovalVO = new TaskApprovalVO();
-
-                    String id = dataInfo.get("id") + "";
-                    String pdfUrl = dataInfo.get("pdf_file_url") + "";
-                    String eVisaPdfUrl = dataInfo.get("e_visa_pdf_url") + "";
-
-                    Boolean aBoolean = RedisTemplate.hasKey("sign-" + id);
-                    taskApprovalVO.setId(id);
-                    taskApprovalVO.setComment(pdfUrl);
-                    taskApprovalVO.setNickName(eVisaPdfUrl);
-
-                    if (!aBoolean) {
-                        RedisTemplate.opsForValue().set("sign-" + taskApprovalVO.getId(), "1",100, TimeUnit.SECONDS);
-                        CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
-                            try {
-                                /*===============执行批量任务===============*/
-                                this.checkIsExsitTaskBatch(taskApprovalVO);
-                            } catch (Exception e) {
-                                e.printStackTrace();
-                            }
-                        }, executor);
-                    }
-                }
-            }
-        }
-        System.out.println("队列数量" + executor.getQueue().size());
-        System.out.println("活跃数量" + executor.getActiveCount());
-        System.out.println("总共数量" + executor.getTaskCount());
-        System.out.println("完成数量" + executor.getCompletedTaskCount());
-    }
-
-    @Transactional
-    public void checkIsExsitTaskBatch(TaskApprovalVO task) throws Exception {
-
-        String pdfUrl = task.getComment();
-        InputStream inputStream = FileUtils.getInputStreamByUrl(pdfUrl);
-        //转换
-        byte[] bytes = CommonUtil.InputStreamToBytes(inputStream);
-        List<PDFIndexInfo> allwordPostions = PdfAddimgUtil.findAllwordPostions(bytes);
-        PDFIndexInfo pdfIndex = allwordPostions.get(0);
-        String context = pdfIndex.getPkeyid();
-        String regex = "\\d{4}年\\d{2}月\\d{2}日";
-
-        char[] data = context.toCharArray();
-        for(int i=0;i<data.length;i++) {
-            String dataChar = data[i]+"";
-            if(dataChar.equals("日")){
-                String date = context.substring(i-15,i+1).trim();
-                if(date.indexOf("年")>=0 && date.indexOf("月")>=0 && date.indexOf("日")>=0 ){
-                    String data2 =date.substring(date.indexOf("年")-4,date.length());
-
-                    if(Pattern.matches(regex, data2)){
-                        // 判断字符串是否匹配日期格式
-                        System.out.println(data2);
-                        jdbcTemplate.execute("UPDATE u_archive_file set file_time='"+data2+"',is_deleted=2 where id='"+task.getId()+"'");
-                        return;
-                    }
-                }
-            }
-        }
-
-        jdbcTemplate.execute("UPDATE u_archive_file set is_deleted=2 where id='"+task.getId()+"'");
-
-        RedisTemplate.delete("sign-" + task.getId());
-    }
-
-}

+ 256 - 90
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/impl/EVDataServiceImpl.java

@@ -5,17 +5,28 @@ import cfca.paperless.base.util.Base64;
 
 
 import cn.hutool.core.io.file.FileReader;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
+import org.springblade.business.entity.ArchiveFile;
+import org.springblade.business.entity.ContractLog;
+import org.springblade.business.entity.InformationQuery;
+import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.feign.TaskClient;
+import org.springblade.business.vo.TaskApprovalVO;
 import org.springblade.business.vo.TaskSignInfoVO;
+import org.springblade.business.vo.TrialRawMaterialSelfRecord;
+import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.constant.EVisaConstant;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.launch.StartEventListener;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.evisa.service.EVDataService;
 import org.springblade.evisa.service.EVisaService;
 import org.springblade.evisa.utils.FileUtils;
@@ -25,8 +36,10 @@ import org.springblade.evisa.vo.*;
 import org.springblade.manager.entity.ProjectInfo;
 import org.springblade.manager.feign.ProjectClient;
 import org.springblade.resource.feign.NewIOSSClient;
+import org.springblade.system.cache.ParamCache;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -49,6 +62,8 @@ public class EVDataServiceImpl implements EVDataService {
 
     @Autowired
     StringRedisTemplate RedisTemplate;
+    @Autowired
+    private StartEventListener startEventListener;
 
     /**
      * 电签主要流程
@@ -62,38 +77,46 @@ public class EVDataServiceImpl implements EVDataService {
         if (taskApp.getSigState() != 1) {
             return;
         }
-
+        String sql = "SELECT a.* from u_task_parallel a where a.process_instance_id=(SELECT process_instance_id from u_task_parallel b where  b.parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "') and is_deleted=0 and initiative<>2 ";
         String fileUrl = CommonUtil.replaceOssUrl(taskApp.getSignPdfUrl());
-        List<String> eVisaConfigList = PDFUtils.getPdfSignIds(fileUrl);
+        List<String> eVisaConfigList = PDFUtils.getPdfSignIds(fileUrl,taskApp);
         String ids = String.join(",", eVisaConfigList);
-        if (taskApp.getRemarkType().equals("1")) { //安心签
-            //添加电签策略
-            List<SealStrategyVO> strategyListByAXQ = getStrategyListByAXQ(taskApp, ids);
-            if (taskApp.getSigState() != 1) {
-                return;
-            }
-            //调用签字逻辑
-            signTaskBatchByAXQZ(strategyListByAXQ, taskApp);
-            if (taskApp.getSigState() != 1) {
+        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
+        if(maps!=null && maps.size()>=1) {
+            if (eVisaConfigList == null || eVisaConfigList.size() == 0) {
+                //没有电签配置,默认当前任务为不签字审批,返回成功
+                taskApp.setSigState(2);
+                taskApp.setSignSmg("pdf未获取到关键字Id");
+                SignBackPdfInfo(taskApp);
                 return;
             }
-            // 回归处理
-            SignBackPdfInfo(taskApp);
-            if (taskApp.getSigState() != 1) {
-                return;
+            if (taskApp.getRemarkType().equals("1")) { //安心签
+                //添加电签策略
+                List<SealStrategyVO> strategyListByAXQ = getStrategyListByAXQ(taskApp, ids);
+                if (taskApp.getSigState() != 1) {
+                    return;
+                }
+                //调用签字逻辑
+                signTaskBatchByAXQZ(strategyListByAXQ, taskApp);
+                if (taskApp.getSigState() != 1) {
+                    return;
+                }
+                // 回归处理
+                SignBackPdfInfo(taskApp);
+                if (taskApp.getSigState() != 1) {
+                    return;
+                }
+            } else if (taskApp.getRemarkType().equals("2")) { //东方中讯
+                //添加电签策略
+                List<Map<String, Object>> strategyListByDFZX = getStrategyListByDFZX(taskApp, ids);
+                //调用签字逻辑
+                signTaskBatchByDFZX(strategyListByDFZX, fileUrl);
+                // 回归处理
+                SignBackPdfInfo(taskApp);
             }
-        } else if (taskApp.getRemarkType().equals("2")) { //东方中讯
-            //添加电签策略
-            List<Map<String, Object>> strategyListByDFZX = getStrategyListByDFZX(taskApp, ids);
-            //调用签字逻辑
-            signTaskBatchByDFZX(strategyListByDFZX, fileUrl);
-            // 回归处理
-            SignBackPdfInfo(taskApp);
         }
-
         // 判断签章信息
-        String sql = "SELECT a.* from u_task_parallel a where a.process_instance_id=(SELECT process_instance_id from u_task_parallel b where  b.parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "') and is_deleted=0 and initiative<>2 ";
-        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
+        maps = jdbcTemplate.queryForList(sql);
         if (maps == null || maps.size() == 0) {
             taskApp.setSigType(2);
             if (taskApp.getRemarkType().equals("1")) { //安心签
@@ -108,7 +131,7 @@ public class EVDataServiceImpl implements EVDataService {
                 //添加电签策略
                 List<Map<String, Object>> strategyListByDFZX = getStrategyListByDFZX(taskApp, ids);
                 //调用签字逻辑
-                signTaskBatchByDFZX(strategyListByDFZX, fileUrl);
+                signTaskBatchByDFZX(strategyListByDFZX, taskApp.getLastFilePdfUrl());
                 // 回归处理
                 SignBackPdfInfo(taskApp);
             }
@@ -123,50 +146,146 @@ public class EVDataServiceImpl implements EVDataService {
         //档案:4档案数据 ,
         //计量: 5中间计量申请,6材料计量单 ,7开工预付款计量单, 8变更令
         try {
-            if (taskApp.getApprovalType() == 1) {
-                if (taskApp.getSigType() == 2) {
-                    this.jdbcTemplate.execute("update u_information_query set e_visa_pdf_url='" + taskApp.getLastFilePdfUrl() + "',status=2,update_time=SYSDATE() where id='" + taskApp.getFormDataId() + "' ");
-                    this.jdbcTemplate.execute("update u_task set status=2,update_time=SYSDATE() where id=" + taskApp.getId());
-                } else {
-                    this.jdbcTemplate.execute("update u_information_query set e_visa_pdf_url='" + taskApp.getLastFilePdfUrl() + "', update_time=SYSDATE() where id='" + taskApp.getFormDataId() + "'");
-                    this.jdbcTemplate.execute("update u_task_parallel set status=2,initiative=2 ,update_time=SYSDATE() where parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "'");
-                    this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
-                    RedisTemplate.delete("sign-" + taskApp.getFormDataId());
-                }
-
-            } else if (taskApp.getApprovalType() == 2) {
-
-            } else if (taskApp.getApprovalType() == 3) {
-
-            } else if (taskApp.getApprovalType() == 4) {
+            //电签成功
+            if (taskApp.getSigState() == 1) { //签字成功
+                String updateSql = "";
+                if(taskApp.getApprovalType() == 1 ){ //
+                    //
+                    String sys_isonline = ParamCache.getValue(CommonConstant.SYS_ISONLINE);
+                    String pdfPage = "";
+                    Long pdfSize = 0L;
+                    String nodePdfUrl = "";
+
+                    List<Map<String, Object>> mapList = jdbcTemplate.queryForList("select *,domain_url as url from m_table_file where is_deleted = 0 and type in (10,11,12) and tab_id = (select wbs_id from u_information_query WHERE id = + "+taskApp.getFormDataId()+")");
+                    if(Func.isNotEmpty(mapList)&&mapList.size()>=1) {
+                        String file_path = FileUtils.getSysLocalFileUrl();
+                        List<String> datainfo = new ArrayList<>();
+                        datainfo.add(taskApp.getLastFilePdfUrl());
+                        for (Map<String, Object> tabsx : mapList) {
+                            datainfo.add(tabsx.get("url") + "");
+                        }
+                        String listPdf = file_path + "/nodePDF/" + taskApp.getFormDataId() + ".pdf";
+                        File tabpdf2 = ResourceUtil.getFile(listPdf);
+                        if (tabpdf2.exists()) {
+                            tabpdf2.delete();
+                        }
+
+                        FileUtils.mergePdfPublicMethods(datainfo, listPdf);
+                        if (sys_isonline.equals("20")) {
+                            BladeFile bladeFile = this.newIOSSClient.uploadFile(taskApp.getFormDataId() + ".pdf", listPdf);
+                            if (bladeFile != null && Func.isNotEmpty(bladeFile.getLink())) {
+                                nodePdfUrl = bladeFile.getLink();
+                            }
+                        } else {
+                            nodePdfUrl = FileUtils.getNetUrl(listPdf);
+                        }
+
+                    }else{
+                        nodePdfUrl = taskApp.getLastFilePdfUrl();
+                    }
 
-            } else if (taskApp.getApprovalType() == 5) {
-                if (taskApp.getSigState() == 1) { //成功
-                    this.jdbcTemplate.execute("update s_interim_pay_certificate set approve_status=" + taskApp.getSigType() + ",update_time=SYSDATE(), raw_url='" + taskApp.getLastFilePdfUrl() + "' where contract_period_id = " + taskApp.getFormDataId());
-                    this.jdbcTemplate.execute("update u_task_parallel set e_visa_status=1,e_visa_content='" + taskApp.getSignSmg() + "' , status=2 , initiative=2 ,update_time=SYSDATE() where parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "'");
-                    this.jdbcTemplate.execute("update u_task set status=" + taskApp.getSigType() + " ,update_time=SYSDATE() where id='" + taskApp.getTaskId() + "'");
-                    this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
-                } else {
-                    this.jdbcTemplate.execute("update s_interim_pay_certificate set approve_status=1,update_time=SYSDATE() where contract_period_id = " + taskApp.getFormDataId());
-                    this.jdbcTemplate.execute("update u_task_parallel set exe_count=(exe_count+1), e_visa_status=99,e_visa_content='" + taskApp.getSignSmg() + "' ,update_time=SYSDATE() where parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "'");
-                    this.jdbcTemplate.execute("update u_task set status=1 ,update_time=SYSDATE() where id='" + taskApp.getTaskId() + "'");
-                    if(totalCount>=3){
-                        this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
+                    pdfPage = FileUtils.getPdfNum(nodePdfUrl);
+                    pdfSize = CommonUtil.getResourceLength(nodePdfUrl);
+
+                    // 实验时
+                    String pdfTrialUrlPosition = "";
+                    if("2".equals(taskApp.getPdfDataType())){
+                        String taskStatus = "";
+                        if(taskApp.getSigState()==1){
+                            taskStatus = "待审批";
+                        } else if (taskApp.getSigState()==2) {
+                            taskStatus = "已审批";
+                        } else if (taskApp.getSigState()==3) {
+                            taskStatus = "已废除";
+                        }
+                        String updTrial = "update u_trial_self_inspection_record set task_status="+taskStatus +",pdf_url='"+taskApp.getLastFilePdfUrl()+"' where id=(select b.trial_self_inspection_record_id from u_task b,u_task_parallel c where b.process_instance_id=c.process_instance_id and b.is_deleted=0 and c.is_deleted=0 and b.status in(1,2) and parallel_process_instance_id="+taskApp.getParallelProcessInstanceId()+")";
+                        jdbcTemplate.execute(updTrial);
+
+                        /**
+                        * 在资料填报工序-预览全部pdf时再拼接合并显示,当前只做储存(如果当前资料填报工序节点有其他多个试验记录pdf关联信息,那么合并存储,否则直接存储)
+                        */
+
+                        String redoe = " select * from  u_trial_self_inspection_record where id=(select b.trial_self_inspection_record_id from u_task b,u_task_parallel c where b.process_instance_id=c.process_instance_id and b.is_deleted=0 and c.is_deleted=0 and b.status in(1,2) and parallel_process_instance_id="+taskApp.getParallelProcessInstanceId()+")";
+                        TrialSelfInspectionRecord record = jdbcTemplate.query(redoe, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class)).stream().findAny().orElse(null);
+                        if (("已审批").equals(record.getTaskStatus()) && (new Integer(1)).equals(record.getDetectionResult()) && (new Integer(1)).equals(record.getDetectionCategory())) {
+                            if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(record.getProjectPosition())) {
+                                //有pdf的节点
+                                String sqlNodeAll = "select wbs_id from u_information_query where wbs_id in(" + record.getProjectPosition() + ") and contract_id = " + record.getContractId();
+                                List<Long> collect = jdbcTemplate.query(sqlNodeAll, new BeanPropertyRowMapper<>(InformationQuery.class)).stream().map(InformationQuery::getWbsId).collect(Collectors.toList());
+                                if (collect.size() > 0) {
+                                    //删除当前记录关联记录
+                                    jdbcTemplate.execute("delete from u_trial_self_quality_project where self_id = "+record.getId()+"");
+                                    for (Long pKeyId : collect) {
+                                        //新增当前记录关联信息
+                                        jdbcTemplate.execute("insert into u_trial_self_quality_project(id,self_id,quality_node_id) values("+SnowFlakeUtil.getId()+","+record.getId()+","+pKeyId+") ");
+
+                                        //获取当前工程部位节点最新的关联试验记录ids
+                                        String sqlIds = "select self_id from u_trial_self_quality_project where quality_node_id = "+pKeyId+"";
+                                        List<Map<String, Object>> trialRecordIds = jdbcTemplate.queryForList(sqlNodeAll);
+
+
+                                        //如果当前工程部位节点的关联试验记录id只有一条,且等于当前关联试验记录id,那么不合并,直接存储该条试验记录的pdf
+                                        if (trialRecordIds.size() == 1 && (trialRecordIds.get(0).get("self_id")).equals(record.getId().toString())) {
+                                            //修改当前试验pdf到质检树节点的pdf_trial_url_position上存储
+                                            pdfTrialUrlPosition = record.getPdfUrl() ;
+                                            continue;
+                                        }
+
+                                        //如果当前工程部位节点的关联试验记录id有多条,那么合并
+                                        String dataSql = "select * from  u_trial_self_inspection_record where id in(select self_id from u_trial_self_quality_project where quality_node_id = "+pKeyId+")";
+                                        List<TrialSelfInspectionRecord> pdfUrlList = jdbcTemplate.queryForList(redoe, TrialSelfInspectionRecord.class);
+                                        List<String> pdfS = pdfUrlList.stream().filter(f -> com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
+                                        if (ObjectUtil.isNotEmpty(pdfS) && pdfS.size() > 0) {
+                                            String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                                            String listPdf = filePath + "/pdf/" + pKeyId + ".pdf";
+                                            File tabPDF = ResourceUtil.getFile(listPdf);
+                                            if (tabPDF.exists()) {
+                                                tabPDF.delete();
+                                            }
+
+                                            FileUtils.mergePdfPublicMethods(pdfS, listPdf);
+                                            BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
+                                            if (bladeFile != null) {
+                                                //修改合并的试验pdf到质检树节点的pdf_trial_url_position上存储
+                                                pdfTrialUrlPosition = bladeFile.getLink();
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
                     }
+                    updateSql = "update u_information_query set pdf_trial_url_position='"+pdfTrialUrlPosition+"',business_time='"+taskApp.getPdfDate()+"',node_pdf_url='"+nodePdfUrl+"',e_visa_pdf_page="+pdfPage+",e_visa_pdf_size="+pdfSize+",e_visa_pdf_url='" + taskApp.getLastFilePdfUrl() + "',status='" + taskApp.getSigType() + "',update_time=SYSDATE() where id='" + taskApp.getFormDataId() + "' " ;
+                } else if (taskApp.getApprovalType() == 2) {
+                   updateSql = "update u_archive_file set e_visa_file='" + taskApp.getLastFilePdfUrl() + "',status='" + taskApp.getSigType() + "',update_time=SYSDATE() where id='" + taskApp.getFormDataId() + "' " ;
+                } else if (taskApp.getApprovalType() == 3) { // 日志
+                    updateSql = "update u_contract_log set e_visa_pdf_url='" + taskApp.getLastFilePdfUrl() + "',status='" + taskApp.getSigType() + "',update_time=SYSDATE() where id='" + taskApp.getFormDataId() + "' " ;
+                } else if (taskApp.getApprovalType() == 5) { //中期计量支付证书
+                    updateSql = "update s_interim_pay_certificate set approve_status=" + taskApp.getSigType() + ",update_time=SYSDATE(), raw_url='" + taskApp.getLastFilePdfUrl() + "' where contract_period_id = " + taskApp.getFormDataId();
+                } else if (taskApp.getApprovalType() == 6 || taskApp.getApprovalType() == 7) {
+                    updateSql = "update s_material_start_statement set raw_url='" + taskApp.getLastFilePdfUrl() + "' where meter_period_id = " + taskApp.getFormDataId();
+                } else if (taskApp.getApprovalType() == 8){
+                    if (taskApp.getSigType() == 2) {
+                        this.jdbcTemplate.execute("update u_entrust_info set sample_status=2,status=" + (taskApp.getSigType() + 1) + ",entrust_e_pdf='" + taskApp.getLastFilePdfUrl() + "' where id=(SELECT wbs_id from u_information_query where id='" + taskApp.getFormDataId() + "')");
+                    }
+                    updateSql = "update u_information_query set e_visa_pdf_url='" + taskApp.getLastFilePdfUrl() + "',status=" + taskApp.getSigType() + " where id='" + taskApp.getFormDataId() + "'";
                 }
-                RedisTemplate.delete("sign-" + taskApp.getFormDataId());
-            } else if (taskApp.getApprovalType() == 6 || taskApp.getApprovalType() == 7) {
-                this.jdbcTemplate.execute("update s_material_start_statement set raw_url='" + taskApp.getLastFilePdfUrl() + "' where meter_period_id = " + taskApp.getFormDataId());
-                this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
-                RedisTemplate.delete("sign-" + taskApp.getFormDataId());
-            } else if (taskApp.getApprovalType() == 8) {
-                if (taskApp.getSigType() == 2) {
-                    this.jdbcTemplate.execute("update u_entrust_info set sample_status=2,status=" + (taskApp.getSigType() + 1) + ",entrust_e_pdf='" + taskApp.getLastFilePdfUrl() + "' where id=(SELECT wbs_id from u_information_query where id='" + taskApp.getFormDataId() + "')");
+                this.jdbcTemplate.execute(updateSql);
+                this.jdbcTemplate.execute("update u_task_parallel set e_visa_status=1,e_visa_content='" + taskApp.getSignSmg() + "' , status=2 , initiative=2 ,update_time=SYSDATE() where parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "'");
+                this.jdbcTemplate.execute("update u_task set status=" + taskApp.getSigType() + " ,update_time=SYSDATE() where id='" + taskApp.getTaskId() + "'");
+                if(taskApp.getSigType()==2){
+                    this.jdbcTemplate.execute("delete from u_task_batch where JSON_EXTRACT(json_data, '$.taskId')=" + taskApp.getTaskId());
+                }else{
+                    this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
+                }
+            }else{ //签字失败
+                this.jdbcTemplate.execute("update u_task_parallel set exe_count=(exe_count+1), e_visa_status=99,e_visa_content='" + taskApp.getSignSmg() + "' ,update_time=SYSDATE() where parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "'");
+                this.jdbcTemplate.execute("update u_task set status=1 ,update_time=SYSDATE() where id='" + taskApp.getTaskId() + "'");
+                if(totalCount>=3){
+                    this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
                 }
-                jdbcTemplate.execute("update u_information_query set e_visa_pdf_url='" + taskApp.getLastFilePdfUrl() + "',status=" + taskApp.getSigType() + " where id='" + taskApp.getFormDataId() + "'");
-                this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
-                RedisTemplate.delete("sign-" + taskApp.getFormDataId());
             }
+            RedisTemplate.delete("sign-" + taskApp.getFormDataId());
         } catch (Exception e) {
             taskApp.setSigState(2);
             taskApp.setSignSmg("修改业务数据异常-请联系开发人员");
@@ -175,7 +294,6 @@ public class EVDataServiceImpl implements EVDataService {
         }
     }
 
-
     // 获取pdf 文件
     public void getSignPdfInfo(TaskSignInfoVO taskApp) {
         //上报类型: 1填报资料,2工程文件,3日志资料
@@ -185,40 +303,75 @@ public class EVDataServiceImpl implements EVDataService {
         taskApp.setSigState(1);
         Map<String, Object> map = new HashMap<>();
         try {
-            if (taskApp.getApprovalType() == 1) {
+            if (taskApp.getApprovalType() == 1 || taskApp.getApprovalType() == 8) {
                 map = this.jdbcTemplate.queryForMap("select * from u_information_query where  is_deleted=0 and id = " + taskApp.getFormDataId());
-                String url = StringUtils.isNotEmpty(map.get("e_visa_pdf_url") + "") ? map.get("e_visa_pdf_url") + "" : map.get("pdf_url") + "";
-                taskApp.setSignPdfUrl(url);
-                taskApp.setContractId(map.get("contract_id") + "");
-                taskApp.setProjectId(map.get("project_id") + "");
-            } else if (taskApp.getApprovalType() == 2) {
-                map = this.jdbcTemplate.queryForMap("select * from u_information_query where  is_deleted=0 and id = " + taskApp.getFormDataId());
-                String url = StringUtils.isNotEmpty(map.get("e_visa_pdf_url") + "") ? map.get("e_visa_pdf_url") + "" : map.get("pdf_url") + "";
-                taskApp.setSignPdfUrl(url);
-                taskApp.setContractId(map.get("contract_id") + "");
-                taskApp.setProjectId(map.get("project_id") + "");
+                String pdfTrialUrlPosition = map.get("pdf_trial_url_position")+""; //关联工程部位信息后合并的pdf路径
+                String pdfTrialUrl = map.get("pdf_trial_url")+""; //pdf路径,引用试验记录后合并的pdf
+                String eVisaPdfUrl = map.get("e_visa_pdf_url")+""; //签字的PDF路径
+                String pdfUrl = map.get("pdf_url")+""; //合并后的PDF路径
+                String type = map.get("type")+""; //资料类型,1资料填报,2试验,3首件
+                taskApp.setPdfDataType(type);
+                if (StringUtils.isNotEmpty(pdfTrialUrlPosition) || StringUtils.isNotEmpty(pdfTrialUrl)|| StringUtils.isNotEmpty(eVisaPdfUrl)|| StringUtils.isNotEmpty(pdfUrl)) {
+                    if("1".equals(type)){
+                        String approvalPdf = eVisaPdfUrl.length()>=10 ? eVisaPdfUrl : pdfUrl;
+                         approvalPdf = pdfTrialUrl.length()>=10 ? pdfTrialUrl : approvalPdf;
+                         approvalPdf = pdfTrialUrl.length()>=10 ? pdfTrialUrlPosition : approvalPdf;
+                         taskApp.setSignPdfUrl(getHppsToHttp(approvalPdf));
+                    } else if ("2".equals(type)) {
+                        if (StringUtils.isNotEmpty(eVisaPdfUrl) || StringUtils.isNotEmpty(pdfUrl)) {
+                            //试验原始pdf
+                            String approvalPdf = StringUtils.isNotEmpty(eVisaPdfUrl) ? eVisaPdfUrl : pdfUrl;
+                            taskApp.setSignPdfUrl(getHppsToHttp(approvalPdf));
+
+                            //试验关联的原材料检测报告合并pdf (wbsId=试验记录id)TrialSelfInspectionRecord
+                            String sqlRecord = "select old_pdf_url from u_trial_raw_material_self_record where self_record_id =" + map.get("wbs_id");
+                            TrialRawMaterialSelfRecord recordObj = jdbcTemplate.query(sqlRecord, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
+                            if (recordObj != null) {
+                                if (StringUtils.isNotEmpty(recordObj.getOldPdfUrl())) {
+                                    taskApp.setSignPdfUrl(getHppsToHttp(approvalPdf));
+                                }
+                            }
+                        }
+                    } else if ("3".equals(type)) {
+                        //首件,首件的资料由三个部分组成:封面、关联资料、总结报告
+                        if (StringUtils.isNotEmpty(eVisaPdfUrl) || StringUtils.isNotEmpty(pdfUrl)) {
+                            String url = StringUtils.isNotEmpty(eVisaPdfUrl) ? eVisaPdfUrl : pdfUrl;
+                            String s = getHppsToHttp(url);
+                            taskApp.setSignPdfUrl(s);
+                        }
+                    }
+                }
+            } else if (taskApp.getApprovalType() == 2) { //档案
+                map = this.jdbcTemplate.queryForMap("select * from u_archive_file where is_deleted=0 and id =("+taskApp.getFormDataId()+")");
+                String eVisaPdfUrl = map.get("pdf_file_url")+""; //签字的PDF路径
+                String pdfUrl = map.get("file_url")+""; //合并后的PDF路径
+                if (StringUtils.isNotEmpty(eVisaPdfUrl) || StringUtils.isNotEmpty(pdfUrl)) {
+                    String url = StringUtils.isNotEmpty(eVisaPdfUrl) ? eVisaPdfUrl : pdfUrl;
+                    taskApp.setSignPdfUrl(url);
+                }
             } else if (taskApp.getApprovalType() == 3) {
-                map = this.jdbcTemplate.queryForMap("select * from u_information_query where  is_deleted=0 and id = " + taskApp.getFormDataId());
-                String url = StringUtils.isNotEmpty(map.get("e_visa_pdf_url") + "") ? map.get("e_visa_pdf_url") + "" : map.get("pdf_url") + "";
-                taskApp.setSignPdfUrl(url);
-                taskApp.setContractId(map.get("contract_id") + "");
-                taskApp.setProjectId(map.get("project_id") + "");
-            } else if (taskApp.getApprovalType() == 4) {
+                map = this.jdbcTemplate.queryForMap("select * from u_contract_log where  is_deleted=0 and id = " + taskApp.getFormDataId());
+                String eVisaPdfUrl = map.get("e_visa_pdf_url")+""; //签字的PDF路径
+                String pdfUrl = map.get("pdf_url")+""; //合并后的PDF路径
+                if (StringUtils.isNotEmpty(eVisaPdfUrl) || StringUtils.isNotEmpty(pdfUrl)) {
+                    String url = StringUtils.isNotEmpty(eVisaPdfUrl) ? eVisaPdfUrl : pdfUrl;
+                    taskApp.setSignPdfUrl(url);
+                }
+            } else if (taskApp.getApprovalType() == 4) { //档案走自定义 搓章的问题
 
             } else if (taskApp.getApprovalType() == 5) {
                 map = this.jdbcTemplate.queryForMap("select * from s_interim_pay_certificate where  is_deleted=0 and contract_period_id = " + taskApp.getFormDataId());
                 taskApp.setSignPdfUrl(map.get("raw_url") + "");
-                taskApp.setContractId(map.get("contract_id") + "");
-                taskApp.setProjectId(map.get("project_id") + "");
+
             } else if (taskApp.getApprovalType() == 6 || taskApp.getApprovalType() == 7) {
                 map = this.jdbcTemplate.queryForMap("select * from  s_material_start_statement where is_deleted=0 and meter_period_id = " + taskApp.getFormDataId());
                 taskApp.setSignPdfUrl(map.get("raw_url") + "");
-                taskApp.setContractId(map.get("contract_id") + "");
-                taskApp.setProjectId(map.get("project_id") + "");
-            } else if (taskApp.getApprovalType() == 8) {
-
             }
 
+
+            // 验证数据
+            taskApp.setContractId(map.get("contract_id") + "");
+            taskApp.setProjectId(map.get("project_id") + "");
             if (taskApp.getSignPdfUrl() == null || taskApp.getSignPdfUrl() == "" || Func.isEmpty(taskApp.getSignPdfUrl()) || taskApp.getSignPdfUrl().length() <= 10) {
                 taskApp.setSigState(2);
                 taskApp.setSignSmg("未获取到PDF信息");
@@ -299,6 +452,7 @@ public class EVDataServiceImpl implements EVDataService {
         String sqlinfo = "SELECT * from ( SELECT DISTINCT a.id,a.pyzbx ,a.pyzby,a.project_id,(SELECT signature_file_url from m_sign_pfx_file where is_register=1 and certificate_user_id='" + task.getUserId() + "' and is_deleted=0  ) as signature_file_url from m_textdict_info a where  a.type =2 and a.id in (" + ids + ") and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id=" + task.getContractId() + " and user_id=" + task.getUserId() + " and c.is_deleted=0 ) ) x where x.signature_file_url is not null ";
         if (task.getSigType() == 2) {
             sqlinfo = "SELECT a.id,a.pyzbx,a.pyzby,b.signature_file_url,b.id as sfId,a.project_id,b.certificate_password,b.certificate_user_name,b.certificate_number from m_textdict_info a ,m_sign_pfx_file b where a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + task.getContractId() + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + ids + ")";
+            System.out.println("签字Sql="+sqlinfo);
         }
 
         List<Map<String, Object>> maps2 = jdbcTemplate.queryForList(sqlinfo);
@@ -440,7 +594,9 @@ public class EVDataServiceImpl implements EVDataService {
 
     // 安心签 - 关键字策略
     public void signTaskBatchByAXQZ(List<SealStrategyVO> list, TaskSignInfoVO taskApp) {
-        String pdfUrl = taskApp.getSignPdfUrl();
+
+        String pdfUrl = Func.notNull(taskApp.getLastFilePdfUrl())?taskApp.getLastFilePdfUrl():taskApp.getSignPdfUrl();
+
         if (Func.isEmpty(pdfUrl) || list == null) {
             taskApp.setLastFilePdfUrl(pdfUrl);
         }
@@ -475,6 +631,8 @@ public class EVDataServiceImpl implements EVDataService {
             SignFtpUtil.FTPCreateDir(outUrl);
             String locPdfUrl = inUrl + "/" + filecode + ".pdf";
             String OutPdfUrl = outUrl + "/" + filecode + ".pdf";
+            SignFtpUtil.FTPDeleteDir(locPdfUrl);
+            SignFtpUtil.FTPDeleteDir(OutPdfUrl);
 
             InputStream inputStream = new ByteArrayInputStream(fileByte);
             int i = SignFtpUtil.uploadFile(locPdfUrl, inputStream);
@@ -526,4 +684,12 @@ public class EVDataServiceImpl implements EVDataService {
             }
         }
     }
+
+    public String getHppsToHttp(String url) {
+        String sys_isonline = ParamCache.getValue(CommonConstant.SYS_ISONLINE);
+        if (url.contains("https:") && sys_isonline.equals("20")) {
+            return url.replace("https:", "http:");
+        }
+        return url;
+    }
 }

+ 67 - 0
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/FileUtils.java

@@ -2,6 +2,10 @@ package org.springblade.evisa.utils;
 
 
 
+import com.itextpdf.text.Document;
+import com.itextpdf.text.pdf.PdfCopy;
+import com.itextpdf.text.pdf.PdfReader;
+import org.apache.pdfbox.pdmodel.PDDocument;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
 
@@ -10,6 +14,7 @@ import org.springblade.common.utils.SystemUtils;
 import org.springblade.system.cache.ParamCache;
 
 import java.io.*;
+import java.util.List;
 
 
 public class FileUtils {
@@ -48,4 +53,66 @@ 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(CommonUtil.getOSSInputStream(urlStr));
+
+                    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();
+        }
+    }
+
+
+    public static String getPdfNum(String url) {
+        try {
+            if (url.isEmpty() || url.equals("")) {
+                return "";
+            }
+            InputStream pdfInputStream = CommonUtil.getOSSInputStream(url);
+            //获取这份文件的页数并设置签章策略
+            //获取PDF文件
+            PDDocument document = PDDocument.load(pdfInputStream);
+            int page = document.getPages().getCount();
+            return page + "";
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
 }

+ 57 - 2
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PDFUtils.java

@@ -2,17 +2,22 @@ package org.springblade.evisa.utils;
 
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.text.PDFTextStripper;
+import org.springblade.business.vo.TaskSignInfoVO;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.core.tool.utils.Func;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
 import java.util.List;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
-
 public class PDFUtils {
-    public static List<String>  getPdfSignIds(String pdfUrl) {
+    public static List<String>  getPdfSignIds(String pdfUrl, TaskSignInfoVO taskApp) {
         List<String> eVisaConfigList = new ArrayList<>();
         try  {
             InputStream inputStream = CommonUtil.getOSSInputStream(pdfUrl);
@@ -20,6 +25,50 @@ public class PDFUtils {
             PDFTextStripper stripper = new PDFTextStripper();
             String text = stripper.getText(document);
             String[] lines = text.split("[ \\n]+");
+            String regex = "^\\d{4}年\\d{2}月\\d{2}日$";
+
+            for(int k=0;k<lines.length;k++){
+                String textStr = lines[k];
+                if(textStr.indexOf("*")>=0){
+                    textStr = textStr.substring(textStr.lastIndexOf("*")+1,textStr.length());
+                }
+
+                String[] textS = Func.toStrArray("\\|\\|",textStr);
+                for(String txt : textS){
+                    for (int i = 0; i < txt.length(); i++) {
+                        if (!Character.isDigit(txt.charAt(i))) {
+                            txt=txt.substring(0,i);
+                        }
+                    }
+                    if (txt.length() >= 15 && Func.isNumeric(txt)) {
+                        eVisaConfigList.add(txt);
+                    }
+
+                    Pattern pattern = Pattern.compile(regex);
+                    if(pattern.matcher(txt).matches()){
+                        taskApp.setPdfDate(txt);
+                    }
+                }
+            }
+
+            List<String> unique = eVisaConfigList.stream().distinct().collect(Collectors.toList());
+            document.close();
+            return unique;
+        }catch (Exception e){
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+
+    public static List<String>  getPdfSignIds(String pdfUrl) {
+        List<String> eVisaConfigList = new ArrayList<>();
+        try  {
+            InputStream inputStream =new FileInputStream(new File(pdfUrl));// CommonUtil.getOSSInputStream(pdfUrl);
+            PDDocument document = PDDocument.load(inputStream);
+            PDFTextStripper stripper = new PDFTextStripper();
+            String text = stripper.getText(document);
+            String[] lines = text.split("[ \\n]+");
             for(int k=0;k<lines.length;k++){
                 String textStr = lines[k];
                 if(textStr.indexOf("*")>=0){
@@ -27,7 +76,13 @@ public class PDFUtils {
                 }
                 String[] textS = Func.toStrArray("\\|\\|",textStr);
                 for(String txt : textS){
+                    for (int i = 0; i < txt.length(); i++) {
+                        if (!Character.isDigit(txt.charAt(i))) {
+                            txt=txt.substring(0,i);
+                        }
+                    }
                     if (txt.length() >= 15 && Func.isNumeric(txt)) {
+                        System.out.println(txt);
                         eVisaConfigList.add(txt);
                     }
                 }

+ 0 - 76
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/ThreadPoolDemo.java

@@ -1,76 +0,0 @@
-package org.springblade.evisa.utils;
-import com.alibaba.fastjson.JSON;
-import org.springblade.business.vo.TaskApprovalVO;
-import org.springframework.scheduling.annotation.Scheduled;
-
-import java.io.FileNotFoundException;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.*;
-
-public class ThreadPoolDemo {
-
-    ThreadPoolDemo(){
-        System.out.println("-----------------------");
-        System.out.println("----------启动-------------");
-        System.out.println("-----------------------");
-    }
-
-
-
-    public static void main11(String[] args) throws InterruptedException {
-
-        // 准备创建线程池所需要的7个参数
-        int corePoolSize = 3;
-        int maximumPoolSize = 3;
-        int keepLiveTime = 0;
-        TimeUnit timeUnit = TimeUnit.SECONDS;
-        ThreadFactory threadFactory = Executors.defaultThreadFactory();
-        ArrayBlockingQueue queue = new ArrayBlockingQueue<>(30);
-
-        RejectedExecutionHandler policy =
-                new ThreadPoolExecutor.DiscardOldestPolicy();
-        // 创建线程池对象
-        ThreadPoolExecutor myThreadPool = new ThreadPoolExecutor(
-                corePoolSize,
-                maximumPoolSize,
-                keepLiveTime,
-                timeUnit,
-                queue,
-                threadFactory,
-                policy);
-
-        for (int i=0;i<10;i++){
-            final int index = i;
-            String index2 = "1";
-            if(i%3==0){
-                index2="2";
-            }
-
-
-            String finalIndex = index2;
-            myThreadPool.execute(new Runnable() {
-
-                @Override
-                public void run() {
-                    try {
-                        synchronized (finalIndex) {
-                            System.out.println(index+"------"+finalIndex);
-                            if(finalIndex.equals("2")){
-                                System.out.println(index+"--2--开始");
-                                Thread.sleep(20000);
-                                System.out.println(index+"--2--结束");
-                            }else{
-                                Thread.sleep(1000);
-                            }
-                        }
-                    } catch (InterruptedException e) {
-                        // TODO Auto-generated catch block
-                        e.printStackTrace();
-                    }
-                }
-            });
-        }
-    }
-
-}

+ 1 - 139
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -1865,7 +1865,7 @@ public class ExcelTabController extends BladeController {
              if(ObjectUtil.isEmpty(nodeClass)){
                  nodeClass=1;
              }
-             if ((StringUtils.isEmpty(pdfUrl) || pdfUrl.equals("null"))&&!nodeClass.equals(2)) {
+             if ((StringUtils.isEmpty(pdfUrl) || pdfUrl.equals("null")) && !nodeClass.equals(2)) {
                     return R.fail("暂无PDF数据");
              } else {
                 // 由于独立附件 需要追加最后
@@ -4423,143 +4423,5 @@ public class ExcelTabController extends BladeController {
                  }
             }
         }
-   /* @Scheduled(cron = "0/20 * * * * ?")
-    public void SignInfo() {
-        //执行代码
-        String sql = "SELECT a.* from u_information_query a,m_wbs_tree_contract b  where a.wbs_id=b.p_key_id and  a.project_id='1681859557657550850' and  a.create_dept=100 LIMIT 5";
-        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
-        if (maps != null && maps.size() >= 1) {
-            for (Map<String, Object> dataInfo : maps) {
-                if (executor.getQueue().size()<=40 ) {
-                    String idkey = dataInfo.get("id")+"";
-                    Boolean aBoolean = RedisTemplate.hasKey("sign-" + idkey);
-                    if(!aBoolean){
-                        RedisTemplate.opsForValue().set("sign-" + idkey, "1",30, TimeUnit.SECONDS);
-                        CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
-                            try {
-                                *//*===============执行批量任务===============*//*
-                                this.checkIsExsitTaskBatch(dataInfo);
-                            } catch (Exception e) {
-                                e.printStackTrace();
-                            }
-                        }, executor);
-                    }
-
-                }
-            }
-        }
-        System.out.println("队列数量" + executor.getQueue().size());
-        System.out.println("活跃数量" + executor.getActiveCount());
-        System.out.println("总共数量" + executor.getTaskCount());
-        System.out.println("完成数量" + executor.getCompletedTaskCount());
-    }*/
-
-
 
-
- /*   public void checkIsExsitTaskBatch(Map<String, Object> dataInfo) {
-        // 数据
-        String file_path = "/Users/hongchuangyanfa/Desktop/";
-        String nodeId = dataInfo.get("wbs_id")+"";
-        String classify = dataInfo.get("classify")+"";
-        String contractId = dataInfo.get("contract_id")+"";
-        String projectId = dataInfo.get("project_id")+"";
-        String pdfUrl = dataInfo.get("pdf_url") + "";
-        try {
-
-            if (dataInfo.get("e_visa_pdf_url") != null) {
-                //优先使用电签的pdf
-                pdfUrl = dataInfo.get("e_visa_pdf_url") + "";
-            }
-
-            if (dataInfo.get("pdf_trial_url") != null || dataInfo.get("pdf_trial_url_position") != null) {
-                //合并试验关联文件、试验工程部位信息的pdf
-                pdfUrl = this.mergePdfShow(pdfUrl, dataInfo) + "";
-            }
-
-            if (StringUtils.isEmpty(pdfUrl) || pdfUrl.equals("null")) {
-                System.out.println("");
-            } else {
-                // 由于独立附件 需要追加最后
-                List<TableFileVO> data = tableFileService.selectTableFileListByTen(Long.valueOf(nodeId + ""));
-                List<String> datainfo = new ArrayList<>();
-                datainfo.add(pdfUrl);
-                if (data != null && data.size() >= 1) {
-                    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();
-                    }
-                }
-            }
-
-
-            List<String> list = Arrays.asList(nodeId.split(","));
-            Long userId = 1777156889464066049L;
-            String dateInfo = "";
-            for (String iId : list) {
-                //获取
-                if(StringUtils.isNotBlank(dataInfo.get("file_user_id_and_name")+"")){
-                    String userIdAndName = dataInfo.get("file_user_id_and_name")+"";
-                    String[] split = userIdAndName.split("-");
-                    userId = Long.parseLong(split[0]);
-                }
-
-                List<AppWbsTreeContractVO> WbsTreeContract = wbsTreeContractService.searchNodeAllTable(nodeId+":"+userId, classify, contractId, projectId ,null);
-
-                Map<String, String> idMap = new HashMap<>();
-                String wbsSql  = "select * from m_tab_busstime_info where is_deleted = 0 and tab_en_name IN('111111'";
-
-                for (AppWbsTreeContractVO appWbsTreeContractVO : WbsTreeContract) {
-
-                    wbsSql+=",'"+appWbsTreeContractVO.getInitTableName()+"'";
-                    idMap.put(appWbsTreeContractVO.getInitTableName(), appWbsTreeContractVO.getPKeyId() + "");
-                }
-                wbsSql+=")";
-                List<Map<String, Object>> tabussTimeInfo = jdbcTemplate.queryForList(wbsSql);
-
-
-                if (tabussTimeInfo != null && tabussTimeInfo.size() >= 1) {
-                    Map<String, Object> tabBusstimeInfo = tabussTimeInfo.get(0);
-
-                    String querySql = "select " + tabBusstimeInfo.get("col_key") + " from " + tabBusstimeInfo.get("tab_en_name") + " where p_key_id=" + idMap.get(tabBusstimeInfo.get("tab_en_name"));
-                    Map<String, Object> maps = jdbcTemplate.queryForMap(querySql);
-                    if (maps != null) {
-                        String keyData = maps.get(tabBusstimeInfo.get("col_key")) + "";
-                        if (StringUtils.isNotEmpty(keyData)) {
-                            dateInfo = keyData.split("_\\^_")[0];
-                            if (dateInfo.indexOf("年") >= 0) {
-                                dateInfo = dateInfo.replace("年", "-");
-                            }
-                            if (dateInfo.indexOf("月") >= 0) {
-                                dateInfo = dateInfo.replace("月", "-");
-                            }
-                            if (dateInfo.indexOf("日") >= 0) {
-                                dateInfo = dateInfo.replace("日", "");
-                            }
-                        }
-                    }
-                }
-            }
-
-            if(pdfUrl!=null && pdfUrl.length()>=20){
-                String pdfPage = commonFileClient.getPdfNum(pdfUrl);
-                long  pdfSize = CommonUtil.getResourceLength(pdfUrl);
-                jdbcTemplate.execute(" update  u_information_query set e_visa_pdf_size="+pdfSize+",e_visa_pdf_page="+pdfPage+", node_pdf_url='" + pdfUrl + "',create_dept=11 where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id='" + contractId + "'");
-            }
-        }catch (Exception e) {
-             throw new RuntimeException(e);
-        }
-    }*/
 }

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/TableElementConverter.java

@@ -428,7 +428,7 @@ public class TableElementConverter implements ITableElementConverter {
                                 }
                             }
                             LinkedHashMap<Integer, List<ElementData>> pages = elementDataList.stream().collect(Collectors.groupingBy(ElementData::getIndex, LinkedHashMap::new, Collectors.toList()));
-                            if("ZHIZUO".equals(fd.getFormula().getNumber())){
+                            if( Func.isNotEmpty(fd.getFormula()) && Func.isNull(fd.getFormula()) && "ZHIZUO".equals(fd.getFormula().getNumber())){
                                 HashMap<Long, String> map = RandomNumberHolder.getRandomNumber();
                                 if(!map.entrySet().isEmpty()){
                                     String nodeName = map.entrySet().iterator().next().getValue();

+ 59 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -7,6 +7,7 @@ import cn.hutool.core.util.HashUtil;
 import cn.hutool.log.StaticLog;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -1156,7 +1157,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         for(FormData fd:tec.formDataList){
             if(fd.verify()){
                 Formula formula =fd.getFormula();
-                if(formula.getId()==1575013024912113671l){
+                System.out.println(formula.getId()+":"+fd.getEName());
+                if(fd.getId()==1575037732017668109L){
                     System.out.println("");
                 }
                 String f=formula.getFormula();
@@ -1219,7 +1221,62 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                             /*错位计算偏移量重置*/
                             ele.stream().filter(s->s.getOffset()>0).forEach(FormData::restore);
                         }else{
-                            Object data =Expression.parse(formula.getFormula()).calculate(currentMap);
+                            // 做特殊监抽检76 现浇墩、台帽或盖梁抽检记录 特殊处理
+                            Object data;
+                            if(f.contains("G8") && f.contains("dx")){
+                               String data2 ="";
+                                String map = formula.getMap();
+                                JSONObject jsonObject = JSON.parseObject(map);
+                                String tabKey =jsonObject.keySet().stream().toArray()[0]+"";
+                                String[] split = tabKey.split(":");
+
+                                List<NodeTable> tableList = tec.getTableAll();
+                                List<Map<String, String>> dataMap = new ArrayList<>();
+                                List<TableInfo> tableAll = tec.getTableInfoList();
+
+                                for(NodeTable appwbsTree : tableList){
+                                    if(appwbsTree.getInitTableName().equals(split[0])){
+                                        String p_key= appwbsTree.getPKeyId()+"";
+                                        for(TableInfo nodeTable:tableAll){
+                                            if(p_key.contains(nodeTable.getPkeyId())){
+                                                System.out.println(appwbsTree.getNodeName());
+                                                dataMap.add(nodeTable.getDataMap());
+                                            }
+                                        }
+                                    }
+                                }
+                                List<KeyMapper> keyMappers = tec.getKeyMappers();
+                                // 高程偏差 key
+                                String dataKeyVal = "key_3";
+                                /*for(KeyMapper datakey:keyMappers){
+                                    if(datakey.getEName().indexOf("高程偏差")>=0 && split[0].equals(datakey.getTableName()) && p_key.contains(datakey.getPkId()+"")){
+                                        dataKeyVal = datakey.getField();
+                                    }
+                                }*/
+
+                                //
+                                for(Map<String, String> dataMa:dataMap){
+                                    String dataVal = dataMa.get(split[1]);
+                                    String[] split1 = dataVal.split("☆");
+                                    Arrays.sort(split1, Comparator.comparingInt(valu -> Integer.parseInt(((valu+"").split("_\\^_")[1]).split("_")[0])));
+                                    String dataVal2 = dataMa.get(dataKeyVal);
+                                    String[] split2 = dataVal2.split("☆");
+                                    Arrays.sort(split2, Comparator.comparingInt(valu -> Integer.parseInt(((valu+"").split("_\\^_")[1]).split("_")[0])));
+                                    for(String s:split1){
+                                        if(s.indexOf("K")>=0){
+                                            String s1 = "_^_"+s.split("_\\^_")[1].split("_")[0];
+                                            for(String s2:split2){
+                                                if(s2.indexOf(s1)>=0){
+                                                    data2 = data2 + s2.split("_\\^_")[0] + ",";
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                                data = data2.substring(0,data2.length()-1);
+                            }else{
+                                data =Expression.parse(formula.getFormula()).calculate(currentMap);
+                            }
                             write(tec,fd,data);
                         }
                     }catch (Exception e){

+ 0 - 213
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/CreateDashedLine.java

@@ -1,213 +0,0 @@
-package org.springblade.manager.utils;
-
-import com.spire.ms.System.Collections.ArrayList;
-import com.sun.xml.bind.v2.util.FlattenIterator;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
-import org.apache.pdfbox.pdmodel.PDPageContentStream;
-import org.apache.pdfbox.pdmodel.graphics.PDLineDashPattern;
-import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
-import org.apache.pdfbox.pdmodel.interactive.measurement.PDViewportDictionary;
-import org.apache.pdfbox.text.PDFTextStripper;
-import org.apache.pdfbox.text.PDFTextStripperByArea;
-import org.apache.pdfbox.text.TextPosition;
-import org.springblade.common.utils.CommonUtil;
-import org.springblade.common.utils.FileUtils;
-import org.springblade.core.tool.utils.Func;
-import org.springblade.core.tool.utils.ResourceUtil;
-import org.springblade.manager.vo.PDFIndexInfo;
-
-import java.awt.geom.Point2D;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.*;
-
-public class CreateDashedLine {
-
-    public static void mai1n(String[] args) throws Exception {
-        // 获取值的坐标
-      //  List<String> s_data39 = new java.util.ArrayList<>();
-
-        List<String> s_data34 = new java.util.ArrayList<>();
-        s_data34.add("2.8");
-        s_data34.add("7.66");
-/*        s_data34.add("14.03");
-        s_data34.add("14.56");
-        s_data34.add("16.28");
-        s_data34.add("");
-        s_data34.add("16.42");
-        s_data34.add("16.57");
-        s_data34.add("16.73");
-        s_data34.add("16.9");
-        s_data34.add("17.07");
-        s_data34.add("17.26");*/
-
-        String pdfUrl = "/Users/hongchuangyanfa/Desktop/excel/1750071431349174274.pdf";
-
-      //  getPDFInfo(pdfUrl,s_data39,"1");
-        getPDFInfo(pdfUrl,s_data34,"2");
-
-        System.out.println("");
-    }
-
-
-    public static void getPDFInfo(String pdfUrl,List<String> s_data,String type) throws Exception {
-        PDDocument document = PDDocument.load(new File(pdfUrl));
-        //获取文件流
-        InputStream inputStream = new FileInputStream(new File(pdfUrl));
-        //转换
-        byte[] bytes = CommonUtil.InputStreamToBytes(inputStream);
-        List<PDFIndexInfo> keywordPostions = PdfAddimgUtil.findKeywordPostions(bytes, "累计%");
-
-        // 获取  实际完成=累计% 的坐标
-        PDFIndexInfo pdfIndexInfo = keywordPostions.get(0);
-        float s_with = pdfIndexInfo.getDataInfo()[1];
-        float s_heiht = pdfIndexInfo.getDataInfo()[2];
-
-        // 获取  计划完成 = 累计% 的坐标
-        PDFIndexInfo jPdf = keywordPostions.get(1);
-        float j_with = jPdf.getDataInfo()[1];
-        float j_heiht = jPdf.getDataInfo()[2];
-
-        System.out.println(s_with+"__"+s_heiht);
-        System.out.println(j_with+"__"+j_heiht);
-
-        List<PDFIndexInfo> allwordPostions = PdfAddimgUtil.findAllwordPostions(bytes);
-        PDFIndexInfo pdfIndex = allwordPostions.get(0);
-        List<float[]> listData = pdfIndex.getListData();
-        String context = pdfIndex.getPkeyid();
-
-        // 获取月份的y轴
-        int moth_y = context.indexOf("1234567891011121");
-        float[] moth = listData.get(moth_y);
-        System.out.println(moth[2]);
-        List<PDFIndexInfo> bf_list = PdfAddimgUtil.findKeywordPostions(bytes, "%");
-         float bf_x = 0f;
-         float bf_y = 0f;
-        for(PDFIndexInfo bf:bf_list){
-           if(bf.getDataInfo()[2]==moth[2]){
-               bf_x =   bf.getDataInfo()[1];
-               bf_y =   bf.getDataInfo()[2];
-               break;
-           }
-        }
-        System.out.println("百分"+bf_x);
-        System.out.println("百分"+bf_y);
-
-        Map<String , float[]> data = new HashMap<>();
-        for(int i=20 ; i>=0 ; i--){
-            //测试数据
-            String key = i * 5 +"";
-            List<String> strList = Func.toStrList(key);
-            for (String text : strList) {
-                for (int pos = 0; pos < context.length(); ) {
-                    int positionIndex = context.indexOf(text, pos);
-                    if (positionIndex == -1) {
-                        break;
-                    }
-                    float[] postions = listData.get(positionIndex);
-                    if((postions[1]==bf_x || Math.abs(postions[1]-bf_x)<=0.002) && postions[2]>bf_y){
-                        data.put(key,postions);
-                        bf_y =postions[2];
-                        break;
-                    }
-                    pos = positionIndex + 1;
-                }
-            }
-        }
-
-
-
-        Map<String , float[]> s_data_xy = new HashMap<>();
-
-        for(String sval:s_data){
-            //测试数据
-            List<String> strList = Func.toStrList(sval);
-            for (String text : strList) {
-                for (int pos = 0; pos < context.length(); ) {
-                    int positionIndex = context.indexOf(text, pos);
-                    if (positionIndex == -1) {
-                        break;
-                    }
-                    float[] postions = listData.get(positionIndex);
-                    if("1".equals(type)){
-                        if((postions[2]==s_heiht || Math.abs(postions[2]-s_heiht)<=0.002 ) && postions[1]>s_with){
-                            s_data_xy.put(sval,postions);
-                            s_with = postions[1];
-                            break;
-                        }
-                    }
-                    if("2".equals(type)){
-                        if((postions[2]==j_heiht || Math.abs(postions[2]-j_heiht)<=0.002 ) && postions[1]>s_with){
-                            s_data_xy.put(sval,postions);
-                            s_with = postions[1];
-                            break;
-                        }
-                    }
-                    pos = positionIndex + 1;
-                }
-            }
-        }
-
-        float pageHeight = document.getPage(0).getMediaBox().getHeight();
-        float pageWidth = document.getPage(0).getMediaBox().getWidth();
-        float oney = (data.get("0")[2] -data.get("5")[2])/5 * pageHeight;
-        //实线坐标
-        List<Float> points = new ArrayList();
-        for(String sval:s_data){
-            float[] floats = s_data_xy.get(sval);
-            if(floats!=null){
-                points.add( pageWidth * (floats[1])+2);
-                Double floor = Math.floor(Func.toDouble(sval) / 5)*5;
-
-                float add = (float) ((Func.toDouble(sval)-floor ) * oney);
-
-                String da2 = floor.intValue()+"";
-                float[] floats1 = data.get(da2);
-                points.add( pageHeight- pageHeight * (floats1[2]) + add );
-            }
-        }
-        PDFFill(points,pdfUrl,type);
-    }
-
-    public static void PDFFill(List<Float> points,String fileUrl,String type) throws Exception {
-        // 创建一个PDF文档
-        PDDocument document = PDDocument.load(new File(fileUrl));
-
-        // 创建一个页面
-        PDPage page = document.getPage(0);
-        // 纸张大小
-
-        try (PDPageContentStream contentStream = new PDPageContentStream(document, page,PDPageContentStream.AppendMode.APPEND, true, true)) {
-            // 设置线宽和颜色
-            PDExtendedGraphicsState extendedGraphicsState = new PDExtendedGraphicsState();
-            extendedGraphicsState.setLineWidth(1f);
-            contentStream.setGraphicsStateParameters(extendedGraphicsState);
-            float[] a={4,2};
-            contentStream.setLineDashPattern(a, 2);
-
-            // 定义点集合,表示折线上的点
-            List<Point2D.Float> points1 = new java.util.ArrayList<>();
-            for (int i = 0; i < points.size(); i += 2) {
-                points1.add(new Point2D.Float(points.get(i), points.get(i + 1)));
-            }
-
-            // 绘制折线
-            Point2D.Float current = null;
-            for (Point2D.Float point : points1) {
-                if (current != null) {
-                    contentStream.drawLine(current.x, current.y, point.x, point.y);
-                }
-                current = point;
-            }
-        }
-
-        document.save("/Users/hongchuangyanfa/Desktop/excel/test_info.pdf");
-        document.close();
-        System.out.println("完成");
-    }
-}

+ 1 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/PdfAddimgUtil.java

@@ -7,6 +7,7 @@ import com.itextpdf.text.Rectangle;
 import com.itextpdf.text.pdf.*;
 import com.itextpdf.text.pdf.parser.*;
 import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.CommonUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.manager.entity.TextdictInfo;
 import org.springblade.manager.vo.PDFIndexInfo;

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.xml

@@ -303,7 +303,7 @@
     <select id="getNodeData" resultType="org.springblade.meter.vo.WbsFileVO">
         select name as dataName,pdf_url as pdfUrl,e_visa_pdf_url as eVisaPdfUrl, uiq.id as selectId,
                (select node_type from m_wbs_tree_contract wtc where wtc.p_key_id = uiq.wbs_id) as nodeType,
-               (select ancestors from m_wbs_tree_contract wtc where wtc.p_key_id = uiq.wbs_id) as ancestors,
+               (select IFNULL(ancestors,wtc.id) from m_wbs_tree_contract wtc where wtc.p_key_id = uiq.wbs_id) as ancestors,
                (select node_name from m_wbs_tree_contract wtc where wtc.p_key_id = uiq.wbs_id) as nodeName,
                (select parent_id from m_wbs_tree_contract wtc where wtc.p_key_id = uiq.wbs_id) as parentId,
                (CASE when status = 0 then '未上报' when status = 1 then '待审批' when status = 2 then '已审批'

+ 6 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MiddleMeterApplyServiceImpl.java

@@ -925,7 +925,12 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
             if (voList.size() != 0) {
                 StringBuilder str = new StringBuilder();
                 for (WbsFileVO vo : voList) {
-                    str.append(vo.getAncestors() + ",");
+                    if(Func.isNotEmpty(vo.getAncestors())){
+                        str.append(vo.getAncestors() + ",");
+                    }else{
+                        str.append(vo.getSelectId() + ",");
+                    }
+
                 }
                 str.deleteCharAt(str.length() - 1);
                 List<Long> longs = Func.toLongList(str.toString());

+ 56 - 14
blade-service/blade-meter/src/main/java/org/springblade/meter/utils/PdfAddimgUtil.java

@@ -6,23 +6,27 @@ import com.itextpdf.text.Image;
 import com.itextpdf.text.Rectangle;
 import com.itextpdf.text.pdf.*;
 import com.itextpdf.text.pdf.parser.*;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.text.PDFTextStripper;
 import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.utils.IDUtils;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.manager.entity.TextdictInfo;
 import org.springblade.manager.vo.PDFIndexInfo;
 import org.springblade.system.cache.ParamCache;
 
 import java.io.*;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 public class PdfAddimgUtil {
 
-    public static void pdfAddImgInfo(String pdfUrl, String keyword, Map<Long, TextdictInfo> textMap) throws Exception {
-        String file_path = FileUtils.getSysLocalFileUrl();
-        String signImg = file_path+"/print/241dc221f83929a87d55ce700d6a4cd7.png";
-
+    public static void pdfAddImgInfo(String pdfUrl, List<Map<String, Object>> data) throws Exception {
         File pdfFile = new File(pdfUrl);
         byte[] pdfData = new byte[(int) pdfFile.length()];
         FileInputStream inputStream = null;
@@ -41,6 +45,9 @@ public class PdfAddimgUtil {
             }
         }
 
+        String keyword = data.stream().map(map -> map.get("id")+"").collect(Collectors.joining(","));
+        //根据map中的key分组
+        Map<Object, List<Map<String, Object>>> map = data.stream().collect(Collectors.groupingBy(item -> item.get("id")));
 
         List<PDFIndexInfo> positions = findKeywordPostions(pdfData, keyword);
 
@@ -48,17 +55,17 @@ public class PdfAddimgUtil {
         if (positions != null && positions.size() > 0) {
 
             for (int i = 0; i < positions.size(); i++) {
-
                 PDFIndexInfo pdfIndexInfo = positions.get(i);
                 float[] position = pdfIndexInfo.getDataInfo();
-                TextdictInfo textdictInfo = textMap.get(Func.toLong(pdfIndexInfo.getPkeyid()));
+                List<Map<String, Object>> textdictInfo= map.get(Func.toLong(pdfIndexInfo.getPkeyid()));
                 float pyzbx = 0;
                 float pyzby = 0;
                 String type ="2";
+                String signImg = "";
                 if(textdictInfo!=null){
-                    pyzbx = Func.toFloat(textdictInfo.getPyzbx());
-                    pyzby = Func.toFloat(textdictInfo.getPyzby());
-                    type = textdictInfo.getType()+"";
+                    pyzbx = Func.toFloat(textdictInfo.get(0).get("pyzbx"));
+                    pyzby = Func.toFloat(textdictInfo.get(0).get("pyzby"));
+                    signImg = textdictInfo.get(0).get("signature_file_url")+"";
                 }
                 gaizhang(pdfFile, new File(pdfUrl), (int) position[0], position[1], position[2], signImg,pyzbx,pyzby,type);
             }
@@ -67,20 +74,19 @@ public class PdfAddimgUtil {
 
     public static void gaizhang(File src, File dest, int page, float x, float y, String imagePath,float pyzbx,float pyzby,String type) throws Exception {
         // 读取模板文件
-        String sysLocalFileUrl = FileUtils.getSysLocalFileUrl();
         InputStream input = new FileInputStream(src);
         PdfReader reader = new PdfReader(input);
         PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
-        Rectangle pageSize = reader.getPageSize(1);
+        Rectangle pageSize = reader.getPageSize(page);
         float height = pageSize.getHeight();
         float width = pageSize.getWidth();
         if(type.equals("6")){
             x = width * x - 27+pyzbx;
             y = height - height * y - 30+pyzby;
-            imagePath = sysLocalFileUrl + "/print/ht1234567890.png";
+            imagePath = "/Users/hongchuangyanfa/Desktop/print/ht1234567890.png";
         }else{
-            x = width * x - 20+pyzbx;
-            y = height - height * y - 8+pyzby;
+            x = width * x - 33+pyzbx;
+            y = height - height * y - 12+pyzby;
         }
 
         // 读图片
@@ -383,4 +389,40 @@ public class PdfAddimgUtil {
         String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "");
         return path;
     }
+
+    public static List<String>  getPdfSignIds(String pdfUrl) {
+        List<String> eVisaConfigList = new ArrayList<>();
+        try  {
+            InputStream inputStream = CommonUtil.getOSSInputStream(pdfUrl);
+            PDDocument document = PDDocument.load(inputStream);
+            PDFTextStripper stripper = new PDFTextStripper();
+            String text = stripper.getText(document);
+            String[] lines = text.split("[ \\n]+");
+            for(int k=0;k<lines.length;k++){
+                String textStr = lines[k];
+                if(textStr.indexOf("*")>=0){
+                    textStr = textStr.substring(textStr.lastIndexOf("*")+1,textStr.length());
+                }
+                String[] textS = Func.toStrArray("\\|\\|",textStr);
+                for(String txt : textS){
+                    for (int i = 0; i < txt.length(); i++) {
+                        if (!Character.isDigit(txt.charAt(i))) {
+                            txt=txt.substring(0,i);
+                        }
+                    }
+                    if (txt.length() >= 15 && Func.isNumeric(txt)) {
+                        System.out.println(txt);
+                        eVisaConfigList.add(txt);
+                    }
+                }
+            }
+
+            List<String> unique = eVisaConfigList.stream().distinct().collect(Collectors.toList());
+            document.close();
+            return unique;
+        }catch (Exception e){
+            e.printStackTrace();
+            return null;
+        }
+    }
 }

+ 1 - 0
blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleMapper.xml

@@ -104,6 +104,7 @@
         from blade_role
         where is_deleted = 0
           and parent_id = #{ParentId}
+        order sort Asc
     </select>
 
     <select id="getRoleDeptInfoByParentId" resultMap="roleResultMap">