Jelajahi Sumber

电签检测程序优化

lvy 2 minggu lalu
induk
melakukan
e0dbbe8144

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

@@ -50,7 +50,7 @@ public class ChekSignData {
     @Scheduled(cron = "0/10 * * * * ?")
     public void SignInfo() {
         // 质检SQL
-        String sql = "SELECT a.id ,a.e_visa_pdf_url,b.process_instance_id,a.contract_id,a.project_id,c.remark_type from u_information_query a ,u_task b ,m_project_info c where  c.id=a.project_id  and a.`status` in(1,2) and a.is_deleted=0 and a.e_visa_pdf_url is not null  and b.form_data_id = a.id and b.`status` in(1,2) and a.chek_status=1 LIMIT 30";
+        String sql = "SELECT a.id ,a.e_visa_pdf_url,b.process_instance_id,a.contract_id,a.project_id,c.remark_type from u_information_query a ,u_task b ,m_project_info c where  c.id=a.project_id  and a.`status` = 2 and a.is_deleted=0 and a.e_visa_pdf_url is not null  and b.form_data_id = a.id and b.`status` = 2 and a.chek_status=1 LIMIT 30";
 
         List<ScrSignInfoVO> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ScrSignInfoVO.class));
         if (query != null && query.size() >= 1 ) {

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

@@ -679,7 +679,7 @@ public class ScrDataServiceImpl implements ScrDataService {
     }
 
     /**
-     * 获取所有电签关键字的位置
+     * 获取电签关键字的位置
      */
     public Map<String, float[]> getKeyPositions(SignKeyVO pdfSignIds,byte[] pdfData) throws Exception {
         if (pdfSignIds == null) {
@@ -709,6 +709,7 @@ public class ScrDataServiceImpl implements ScrDataService {
             Map<String, String> dataMap = pdfSignIds.getDataMap();
             String keyWord = String.join(",", positions);
             List<String> sucessList = new ArrayList<>();
+            Map<String, List<Map<String, Object>>> signatureDataMap = getSignatureData(taskApp.getId() + "", taskApp.getRemarkType(), keyWord);
             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++) {
@@ -735,6 +736,22 @@ public class ScrDataServiceImpl implements ScrDataService {
                                 float keyh = pageHeight - keyY * pageHeight;
                                 float pyzbx = 0.0f;
                                 float pyzby = 0.0f;
+                                List<Map<String, Object>> maps = signatureDataMap.get(pkeyid);
+                                if (maps != null && !maps.isEmpty()) {
+                                    boolean flag = false;
+                                    for (Map<String, Object> map : maps) {
+                                        Float pyzbx1 = Func.toFloat(map.get("pyzbx"));
+                                        Float pyzby1 = Func.toFloat(map.get("pyzby"));
+                                        if (Math.abs(imgX - keyw - pyzbx1) <= threshold && Math.abs(imgY - keyh - pyzby1) <= threshold) {
+                                            sucessList.add(pkeyid);
+                                            flag = true;
+                                            break;
+                                        }
+                                    }
+                                    if (flag) {
+                                        break;
+                                    }
+                                }
                                 if (taskApp.getRemarkType().equals("3")) { //东方中讯
                                     if (imgH >= 100) {
                                         // 签章
@@ -784,4 +801,16 @@ public class ScrDataServiceImpl implements ScrDataService {
             return dataUserMap;
         }
     }
+
+    private Map<String, List<Map<String, Object>>> getSignatureData(String queryId, String signType, String ids) {
+        List<Map<String, Object>> mapList = jdbcTemplate.queryForList("select text_id as keyword, type, pyzbx, pyzby from m_sign_data where query_id = " + queryId);
+        if (ids != null && !ids.isEmpty()) {
+            List<Map<String, Object>> list = jdbcTemplate.queryForList("select text_id as keyword, type, pyzbx, pyzby from m_sign_data where query_id = -1 and user_id = -1 and text_id in (" + ids + ") and sign_type = " + signType);
+            mapList.addAll(list);
+        }
+        if (!mapList.isEmpty()) {
+            return mapList.stream().collect(Collectors.groupingBy(item -> (Func.toStr(item.get("keyword")))));
+        }
+        return new HashMap<>();
+    }
 }