Bläddra i källkod

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

cr 2 veckor sedan
förälder
incheckning
81bd683526

+ 41 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/ChekPdfVo.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 视图实体类
+ *
+ * @author BladeX
+ * @since 2022-07-08
+ */
+@Data
+public class ChekPdfVo {
+    private static final long serialVersionUID = 1L;
+
+
+    @ApiModelProperty("1:节点添加 2:文件添加")
+    private String type;
+
+    @ApiModelProperty("ids")
+    private String ids;
+
+    @ApiModelProperty("1施工2监理")
+    private String classify;
+}

+ 3 - 4
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -5393,7 +5393,7 @@ public R<Object> customAddContractNode(@RequestBody CustomAddContractNodeDTO dto
      *
      * @return 结果
      */
-    @GetMapping("/updateCheckPdfInfo")
+    @PostMapping("/updateCheckPdfInfo")
     @ApiOperationSupport(order = 40)
     @ApiOperation(value = "添加pdf检查接口")
     @ApiImplicitParams(value = {
@@ -5401,9 +5401,8 @@ public R<Object> customAddContractNode(@RequestBody CustomAddContractNodeDTO dto
             @ApiImplicitParam(name = "classify", value = "1施工2监理",required = true),
             @ApiImplicitParam(name = "ids", value = "多个用,拼接", required = true)
     })
-    public  R updateCheckPdfInfo(@RequestParam String type, @RequestParam String ids,@RequestParam String classify) {
-        R r = informationQueryService.updateCheckPdfInfo(type, ids, classify);
-        return R.success("操作成功");
+    public  R updateCheckPdfInfo(@RequestBody ChekPdfVo chekPdfVo) {
+        return informationQueryService.updateCheckPdfInfo(chekPdfVo.getType(), chekPdfVo.getIds(), chekPdfVo.getClassify());
     }
 
     /**

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

@@ -1114,7 +1114,7 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
     }
 
     @Override
-    @Async
+//    @Async
     public R updateCheckPdfInfo(String type, String ids,String classify) {
         if(type==null || Func.isNull(type)){
             return R.fail("type不能weinull");

+ 98 - 23
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/impl/ScrDataServiceImpl.java

@@ -12,6 +12,7 @@ import org.springblade.common.utils.CommonUtil;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.CollectionUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.evisa.service.ScrDataService;
 import org.springblade.evisa.utils.PdfAddimgUtil;
 import org.springblade.evisa.vo.SignKeyVO;
@@ -230,16 +231,14 @@ public class ScrDataServiceImpl implements ScrDataService {
 
     // 添加电签策略 -- 安心签
     public List<Map<String, Object>> getStrategyListByAXQ(ScrSignInfoVO task, String ids) {
-        String sql = "select task_user,count(1) as total,initiative,status,(select  count(1) from u_task_parallel where process_instance_id = '" + task.getProcessInstanceId() + "' and initiative=2 and status=2) as pCount from u_task_parallel where process_instance_id = '" + task.getProcessInstanceId() + "'";
+        String sql = "select task_user,initiative,status,(select  count(1) from u_task_parallel where process_instance_id = '" + task.getProcessInstanceId() + "' and initiative=2 and status=2) as pCount from u_task_parallel where process_instance_id = '" + task.getProcessInstanceId() + "'";
         List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
         ArrayList<String> strArray = new ArrayList();
-        int total = 0;
         int pCount = 0;
         if (mapList != null && mapList.size() >= 1) {
             for (int i = 0; i < mapList.size(); i++) {
                 Map<String, Object> map = mapList.get(i);
                 if(i==0){
-                    total = Func.toInt(map.get("total"));
                     pCount = Func.toInt(map.get("pCount"));
                 }
                 if((map.get("initiative")+"").equals("2") && (map.get("status")+"").equals("2")){
@@ -270,8 +269,8 @@ public class ScrDataServiceImpl implements ScrDataService {
             for (int i = 0; i < strArray.size(); i++) {
                 List<Map<String, Object>> maps2 = null;
                 if (dqIds.length() > 0) {
-                    String sqlinfo = " SELECT * from ( SELECT a.id as keyWord,a.project_id,a.pyzbx ,a.pyzby,(SELECT acc_code from blade_user where id='" + strArray.get(i) + "' and is_deleted=0  ) as sealId from m_textdict_info a where  a.type =2 and a.id in (" + dqIds + ")  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=" + strArray.get(i) + " and c.is_deleted=0 ) ) x where x.sealId is not null ";
-                    System.out.println("东方中讯--签字--" + sqlinfo);
+                    String sqlinfo = " SELECT * from ( SELECT a.id as keyWord,a.project_id,a.pyzbx ,a.pyzby,(SELECT signature_file_url from m_sign_pfx_file where is_register=1 and certificate_user_id='" + strArray.get(i) + "' and is_deleted=0  ) as signature_file_url, '1' as type from m_textdict_info a where  a.type =2 and a.id in (" + dqIds + ")  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=" + strArray.get(i) + " and c.is_deleted=0 ) ) x where x.signature_file_url is not null ";
+                    System.out.println("安心签--签字--" + sqlinfo);
                     maps2 = jdbcTemplate.queryForList(sqlinfo);
                 }
                 if(CollectionUtil.isNotEmpty(maps2)) {
@@ -295,13 +294,19 @@ public class ScrDataServiceImpl implements ScrDataService {
                             maps.add(keyList.get(0));
                         }
                     }
+                } else {
+                    // 查询 sign_data 表
+                    List<Map<String, Object>> list = jdbcTemplate.queryForList("SELECT * from m_sign_data where query_id = ? and text_id in (?) and user_id = ? and type = 1", task.getId(), dqIds, strArray.get(i));
+                    if (!list.isEmpty()) {
+                        System.out.println("1111111111111111111");
+                    }
                 }
             }
 
 
 
-            String sqlinfo = "SELECT a.id as keyWord,a.pyzbx,a.pyzby,b.certificate_number as sealId 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(" + dqIds + ")";
-            System.out.println("东方中讯--签章--" + sqlinfo);
+            String sqlinfo = "SELECT a.id as keyWord,a.pyzbx,a.pyzby,b.certificate_number as sealId, '2' as type 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(" + dqIds + ")";
+            System.out.println("安心签--签章--" + sqlinfo);
             List<Map<String, Object>> maps2 = jdbcTemplate.queryForList(sqlinfo);
             if(CollectionUtil.isNotEmpty(maps2)) {
                 Map<String, List<Map<String, Object>>> peopleByAge = maps2.stream()
@@ -324,6 +329,8 @@ public class ScrDataServiceImpl implements ScrDataService {
                         maps.add(keyList.get(0));
                     }
                 }
+            } else {
+                System.out.println("22222222222222222222");
             }
         }
         return maps;
@@ -409,6 +416,16 @@ public class ScrDataServiceImpl implements ScrDataService {
             List<String> positions = pdfSignIds.getEVisaConfigList();
             Map<String, String> dataMap = pdfSignIds.getDataMap();
 
+            Map<String, String> dataMap1 = checkSignByPdf(taskApp, pdfSignIds, pdfData);
+            if (dataMap1 != null && !dataMap1.isEmpty()) {
+                dataMap = dataMap1;
+            } else {
+                String sql2 = "UPDATE u_information_query set chek_status=2 where id='" + taskApp.getId() + "'";
+                jdbcTemplate.execute(sql2);
+                RedisTemplate.delete("chek-" + taskApp.getId());
+                return;
+            }
+
             List<String> sucessUser = new ArrayList<>();
             List<String> sucessCompan = new ArrayList<>();
             String ids = String.join(",", positions);
@@ -603,22 +620,6 @@ public class ScrDataServiceImpl implements ScrDataService {
                 }
             }
 
-//            boolean isSign1 = true;
-//            //判断个人是否签完
-//            List<String> userList = strategyListByDFZX.stream().filter(item -> item.get("type").equals("1")).map(map -> map.get("keyWord").toString()).collect(Collectors.toList());
-//            if (!userList.isEmpty()) {
-//                Set<String> differentElements = new HashSet<>(userList);
-//                sucessUser.forEach(differentElements::remove);
-//                if (!differentElements.isEmpty()) {
-//                    isSign1 = false;
-//                    StringBuilder sb = new StringBuilder();
-//                    sb.append("id = ").append(taskApp.getId()).append(", 人总共:").append(userList.size()).append(", 剩下:").append(differentElements.size());
-//                    for (String element : differentElements) {
-//                        sb.append(", ").append(element);
-//                    }
-//                    System.err.println(sb);
-//                }
-//            }
             if(!sucessUser.isEmpty() && isSign){
                 for(String user:sucessUser){
                     for(String mapkey:dataMap.keySet()){
@@ -632,6 +633,7 @@ public class ScrDataServiceImpl implements ScrDataService {
                     for(String mapkey:dataMap.keySet()){
                         String mapval = dataMap.get(mapkey);
                         if(mapval != null && (mapval.equals(company) || mapval.equals(company+"\r"))){
+//                        if(mapval != null && mapval.contains(company)){
                             dataUserMap.remove(mapkey) ;
                         }
                     }
@@ -651,4 +653,77 @@ public class ScrDataServiceImpl implements ScrDataService {
             RedisTemplate.delete("chek-" + taskApp.getId());
         }
     }
+
+    public Map<String, String> checkSignByPdf(ScrSignInfoVO taskApp,SignKeyVO pdfSignIds,byte[] pdfData) throws Exception {
+        int threshold = 5;
+        //转换
+        try (PDDocument document = PDDocument.load(pdfData);) {
+            List<String> positions = pdfSignIds.getEVisaConfigList();
+            Map<String, String> dataMap = pdfSignIds.getDataMap();
+            String keyWord = String.join(",", positions);
+            List<String> sucessList = new ArrayList<>();
+            List<PDFIndexInfo> pdfIndexInfo = PdfAddimgUtil.findKeywordPostions(pdfData, keyWord);
+            Map<String, List<PDFIndexInfo>> groupBy = pdfIndexInfo.stream().collect(Collectors.groupingBy(da -> Func.toStr(da.getDataInfo()[0])));
+            for (int i = 0; i < document.getPages().getCount(); i++) {
+                PDPage page = document.getPage(i);
+                List<PDAnnotation> annotations = page.getAnnotations();
+                for (PDAnnotation annotation : annotations) {
+                    if (annotation instanceof PDAnnotationWidget) {
+                        PDRectangle rect = annotation.getRectangle();
+                        float imgW = rect.getWidth();
+                        float imgH = rect.getHeight();
+                        float imgX = rect.getLowerLeftX() + imgW / 2;
+                        float imgY = rect.getLowerLeftY() + imgH / 2;
+                        List<PDFIndexInfo> pdfIndexInfos = groupBy.get((i + 1) + ".0");
+                        if (pdfIndexInfos != null && !pdfIndexInfos.isEmpty()) {
+                            for (PDFIndexInfo pdfInfo : pdfIndexInfos) {
+                                String pkeyid = pdfInfo.getPkeyid();
+                                float[] dataInfo = pdfInfo.getDataInfo();
+                                float keyX = dataInfo[1];
+                                float keyY = dataInfo[2];
+                                float pageHeight = page.getMediaBox().getHeight();
+                                float pageWidth = page.getMediaBox().getWidth();
+
+                                float keyw = keyX * pageWidth;
+                                float keyh = pageHeight - keyY * pageHeight;
+                                float pyzbx = 0.0f;
+                                float pyzby = 0.0f;
+                                if (taskApp.getRemarkType().equals("3")) { //东方中讯
+
+                                } else if (taskApp.getRemarkType().equals("2")) { //东方中讯
+
+                                } else {
+                                    keyw = keyw + pyzbx + 5;
+                                    keyh = keyh + pyzby;
+                                }
+                                if (pkeyid.length() < 19) {
+                                    keyw = keyw - (float) (10 - pkeyid.length() / 2.0);
+                                }
+                                if (Math.abs(imgX - keyw) <= threshold && Math.abs(imgY - keyh) <= threshold) {
+                                    sucessList.add(pkeyid);
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            Map<String, String> dataUserMap = new HashMap<>(dataMap);
+            //判断章是否签完
+            if (!sucessList.isEmpty()) {
+                for (String user : sucessList) {
+                    for (String mapkey : dataMap.keySet()) {
+                        String mapval = dataMap.get(mapkey);
+                        if (mapval.contains(user)) {
+                            dataUserMap.remove(mapkey);
+                        }
+                    }
+                }
+                if (!dataUserMap.isEmpty()) {
+                    return dataUserMap;
+                }
+            }
+        }
+        return null;
+    }
 }

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

@@ -410,6 +410,12 @@ public class PdfAddimgUtil {
 
             for(int k=0;k<lines.length;k++){
                 String textStr = lines[k];
+                if (!textStr.contains("\r") && k + 1 < lines.length) {
+                    if (textStr.matches("[0-9* ✹|]{8,}") && lines[k + 1].matches("[0-9* ✹|]{8,}") && text.contains(textStr + " " + lines[k + 1])) {
+                        textStr = textStr + "*" + lines[k + 1];
+                        k++;
+                    }
+                }
                 int index = textStr.indexOf("*");
                 if(index>=0 && textStr.lastIndexOf("*")+1 < textStr.length() && textStr.charAt(index+1) != '✹'){
                     textStr = textStr.substring(textStr.lastIndexOf("*")+1,textStr.length());