Browse Source

修改电签流程查询,增加通过key进行电签

lvy 1 month ago
parent
commit
60da1c9257

+ 30 - 3
blade-service/blade-business/src/main/java/org/springblade/business/controller/EVisaTaskCheckController.java

@@ -844,9 +844,36 @@ public class EVisaTaskCheckController {
             if (ids == null || ids.size() == 0) {
                 return null;
             }
-            String sql = "select * from m_textdict_info where id in(" + StringUtils.join(ids, ",") + ") ";
-            List<TextdictInfo> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TextdictInfo.class));
-            jsonList = JSONArray.parseArray(JSONObject.toJSONString(query), JSONObject.class);
+        Map<String, List<String>> groupMap = ids.stream().collect(Collectors.groupingBy(str -> {
+            if (str.contains("✹")) {
+                return "sign";
+            }
+            return "dqid";
+        }));
+        List<String> dqIds = groupMap.get("dqid");
+        List<TextdictInfo> query = null;
+        if (dqIds != null && !dqIds.isEmpty()) {
+            String sql = "select * from m_textdict_info where id in(" + StringUtils.join(dqIds, ",") + ") ";
+            query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TextdictInfo.class));
+        }
+        List<String> signList = groupMap.get("sign");
+        if (signList != null && !signList.isEmpty()) {
+            String signIds = signList.stream().map(sign -> sign.replace("✹", "")).collect(Collectors.joining(","));
+            String sql = "SELECT distinct conf_id,relation_id from m_sign_config_relation WHERE conf_id in ( " + signIds + ") and type = 1 and is_deleted = 0";
+            List<SignConfigRelation> signConfigRelationList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(SignConfigRelation.class));
+            if (!signConfigRelationList.isEmpty()) {
+                if (query == null) {
+                    query = new ArrayList<>();
+                }
+                for (SignConfigRelation relation : signConfigRelationList) {
+                    TextdictInfo textdictInfo = new TextdictInfo();
+                    textdictInfo.setId(relation.getConfId());
+                    textdictInfo.setSigRoleId(relation.getRelationId() + "");
+                    query.add(textdictInfo);
+                }
+            }
+        }
+        jsonList = JSONArray.parseArray(JSONObject.toJSONString(query), JSONObject.class);
 //        }
         return jsonList;
     }

+ 47 - 1
blade-service/blade-business/src/main/java/org/springblade/business/utils/PDFUtil.java

@@ -104,7 +104,8 @@ public class PDFUtil {
             String[] lines = text.split("[ \\n]+");
             for(int k=0;k<lines.length;k++){
                 String textStr = lines[k];
-                if(textStr.indexOf("*")>=0){
+                int index = textStr.indexOf("*");
+                if(index>=0 && textStr.charAt(index+1) != '✹'){
                     textStr = textStr.substring(textStr.lastIndexOf("*")+1,textStr.length());
                 }
 
@@ -119,6 +120,17 @@ public class PDFUtil {
                         eVisaConfigList.add(txt);
                     }
                 }
+                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);
+                    }
+                }
 
                 // 特殊处理
                 if(textStr.indexOf("1")>=0){
@@ -128,6 +140,40 @@ public class PDFUtil {
                         eVisaConfigList.add(txt);
                     }
                 }
+                if (textStr.contains("✹")) {
+                    String textString = textStr.substring(textStr.indexOf("✹") + 1);
+                    if (textString.contains("||✹")) {
+                        String[] textS1 = Func.toStrArray("\\|\\|✹",textString);
+                        for(String txt : textS1){
+                            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)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
+                                eVisaConfigList.add("✹" + txt);
+                            }
+                        }
+                    }
+                    if (textString.contains("*✹")) {
+                        String[] textS1 = Func.toStrArray("\\*✹",textString);
+                        for(String txt : textS1){
+                            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)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
+                                eVisaConfigList.add("✹" + txt);
+                            }
+                        }
+                    }
+                    if(textString.startsWith("1")){
+                        if (textString.length() >= 15 && Func.isNumeric(textString)) {
+                            eVisaConfigList.add("✹" + textString);
+                        }
+                    }
+                }
             }
 
             List<String> unique = eVisaConfigList.stream().distinct().collect(Collectors.toList());

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

@@ -511,11 +511,27 @@ public class EVDataServiceImpl implements EVDataService {
         String[] strArray = Func.toStrArray(task.getUserId());
         String[] userNames = Func.toStrArray(task.getNickName());
         List<Map<String, Object>> maps = new ArrayList<>();
+        String[] split = ids.split(",");
+        StringBuilder dqIds = new StringBuilder();
+        StringBuilder signIds = new StringBuilder();
+        for (String id : split) {
+            if (id != null && id.contains("✹")) {
+                signIds.append(id.substring(1)).append( ",");
+            } else {
+                dqIds.append(id).append( ",");
+            }
+        }
+        if (dqIds.length()>0) {
+            dqIds.deleteCharAt(dqIds.length()-1);
+        }
+        if (signIds.length()>0) {
+            signIds.deleteCharAt(signIds.length()-1);
+        }
         if(strArray!=null && strArray.length>0) {
             for (int i = 0; i < strArray.length; i++) {
-                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[i] + "' and is_deleted=0  ) as sealId 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=" + strArray[i] + " and c.is_deleted=0 ) ) x where x.sealId is not null ";
+                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[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[i] + " and c.is_deleted=0 ) ) x where x.sealId is not null ";
                 if (task.getSigType() == 2) {
-                    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(" + ids + ")";
+                    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);
                 } else {
                     System.out.println("东方中讯--签字--" + sqlinfo);
@@ -543,6 +559,25 @@ public class EVDataServiceImpl implements EVDataService {
                         }
                     }
                 }
+                if (signIds.length() > 0 && task.getSigType() != 2) {
+                    String sql = "SELECT * from ( SELECT a.conf_id as keyWord,a.project_id,a.pyzbx ,a.pyzby,(SELECT acc_code from blade_user where id = " + strArray[i] + " and is_deleted=0  ) as sealId " +
+                            "from m_sign_config_relation a where a.type = 1 and a.is_deleted = 0 and a.conf_id in (" + signIds + ") " +
+                            "and a.relation_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id= " + task.getContractId() + " and user_id= " + strArray[i] + " and c.is_deleted=0 ) ) x where x.sealId is not null ";
+                    List<Map<String, Object>> maps3 = jdbcTemplate.queryForList(sql);
+                    System.out.println("东方中讯--签字--key =" + sql);
+                    if (!maps3.isEmpty()) {
+                        Map<String, List<Map<String, Object>>> peopleByAge = maps2.stream()
+                                .collect(Collectors.groupingBy(hada -> (Func.toStr(hada.get("keyWord")))));
+                        for (String keyId : peopleByAge.keySet()) {
+                            List<Map<String, Object>> keyList = peopleByAge.get(keyId);
+                            if (keyList != null && !keyList.isEmpty()) {
+                                Map<String, Object> map = keyList.get(0);
+                                map.put("keyWord", "✹" + map.get("keyWord"));
+                                maps.add(map);
+                            }
+                        }
+                    }
+                }
             }
         }
         return maps;
@@ -555,19 +590,33 @@ public class EVDataServiceImpl implements EVDataService {
         String[] userNames = Func.toStrArray(task.getNickName());
         List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
 
-
+        String[] split = ids.split(",");
+        StringBuilder dqIds = new StringBuilder();
+        StringBuilder signIds = new StringBuilder();
+        for (String id : split) {
+            if (id != null && id.contains("✹")) {
+                signIds.append(id.substring(1)).append( ",");
+            } else {
+                dqIds.append(id).append( ",");
+            }
+        }
+        if (dqIds.length()>0) {
+            dqIds.deleteCharAt(dqIds.length()-1);
+        }
+        if (signIds.length()>0) {
+            signIds.deleteCharAt(signIds.length()-1);
+        }
         if(strArray!=null && strArray.length>0){
             for (int i =0 ;i < strArray.length;i++) {
                 String userId =strArray[i];
-                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='" + userId + "' and is_deleted=0  ) as signature_file_url, (SELECT wide from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as wide ,(SELECT high from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as high 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=" + userId + " and c.is_deleted=0 ) ) x where x.signature_file_url is not null ";
+                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='" + userId + "' and is_deleted=0  ) as signature_file_url, (SELECT wide from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as wide ,(SELECT high from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as high 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=" + userId + " 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 ,b.wide,b.high 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 + ") ";
+                    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 ,b.wide,b.high 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);
                 } else {
                     System.out.println("安心签--签字--=" + sqlinfo);
                 }
                 List<Map<String, Object>> maps2 = jdbcTemplate.queryForList(sqlinfo);
-
                 if (maps2 != null && maps2.size() > 0) {
                     List<Map<String, Object>> maps = new ArrayList<>();
                     Map<String, List<Map<String, Object>>> peopleByAge = maps2.stream()
@@ -576,22 +625,42 @@ public class EVDataServiceImpl implements EVDataService {
                     for (String keyId : peopleByAge.keySet()) {
                         int exId = 0;
                         List<Map<String, Object>> keyList = peopleByAge.get(keyId);
-                        if (keyList != null && keyList.size() == 1) {
+                        if (keyList != null && keyList.size() == 1 && keyList.get(0).get("signature_file_url") != null) {
                             maps.addAll(keyList);
                             exId = 1;
                         } else if (keyList != null && keyList.size() >= 2) {
                             for (Map<String, Object> datax : keyList) {
-                                if ((datax.get("project_id") + "").equals(task.getProjectId())) {
+                                if ((datax.get("project_id") + "").equals(task.getProjectId()) && datax.get("signature_file_url") != null) {
                                     maps.add(datax);
                                     exId = 1;
                                 }
                             }
                         }
-                        if (exId == 0) {
+                        if (exId == 0 && keyList != null) {
                             maps.add(keyList.get(0));
                         }
                     }
-
+                    if (signIds.length() > 0 && task.getSigType() != 2) {
+                        String sql = "SELECT * from ( SELECT DISTINCT a.conf_id as id,0.0 as pyzbx ,0.0 as pyzby,(SELECT signature_file_url from m_sign_pfx_file where is_register=1 and certificate_user_id='"
+                                + userId + "' and is_deleted=0  ) as signature_file_url, (SELECT wide from m_sign_pfx_file where is_register=1 and certificate_user_id='"
+                                + userId + "' and is_deleted=0  ) as wide ,(SELECT high from m_sign_pfx_file where is_register=1 and certificate_user_id='"
+                                + userId + "' and is_deleted=0  ) as high from m_sign_config_relation a where a.type = 1 and a.is_deleted = 0 and a.conf_id in (" + signIds + ") and a.relation_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id="
+                                + task.getContractId() + " and user_id=" + userId + " and c.is_deleted=0 ) ) x where x.signature_file_url is not null ";
+                        List<Map<String, Object>> maps3 = jdbcTemplate.queryForList(sql);
+                        System.out.println("安心签--签章--key =" + sql);
+                        if (!maps3.isEmpty()) {
+                            Map<String, List<Map<String, Object>>> peopleByAges = maps3.stream()
+                                    .collect(Collectors.groupingBy(hada -> (Func.toStr(hada.get("id")))));
+                            for (String keyId : peopleByAges.keySet()) {
+                                List<Map<String, Object>> keyList = peopleByAges.get(keyId);
+                                if (keyList != null && !keyList.isEmpty()) {
+                                    Map<String, Object> map = keyList.get(0);
+                                    map.put("id", "✹" + map.get("id"));
+                                    maps.add(map);
+                                }
+                            }
+                        }
+                    }
                     if (maps == null || maps.size() <= 0) {
                         break;
                     }

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

@@ -30,7 +30,8 @@ public class PDFUtils {
 
             for(int k=0;k<lines.length;k++){
                 String textStr = lines[k];
-                if(textStr.indexOf("*")>=0){
+                int index = textStr.indexOf("*");
+                if(index>=0 && textStr.charAt(index+1) != '✹'){
                     textStr = textStr.substring(textStr.lastIndexOf("*")+1,textStr.length());
                 }
 
@@ -41,25 +42,70 @@ public class PDFUtils {
                             txt=txt.substring(0,i);
                         }
                     }
-                    if (txt.length() >= 15 && Func.isNumeric(txt)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
+                    if (txt.length() >= 15 && Func.isNumeric(txt)) {
                         eVisaConfigList.add(txt);
                     }
-                    if (taskApp.getPdfDate() == null || taskApp.getPdfDate().isEmpty()) {
-                        Matcher matcher = pattern.matcher(txt);
-                        if(matcher.matches()){
-                            taskApp.setPdfDate(matcher.group(1));
+                }
+                if (taskApp.getPdfDate() == null || taskApp.getPdfDate().isEmpty()) {
+                    Matcher matcher = pattern.matcher(textStr);
+                    if(matcher.matches()){
+                        taskApp.setPdfDate(matcher.group(1));
+                    }
+                }
+                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);
+                    }
                 }
 
                 // 特殊处理
                 if(textStr.indexOf("1")>=0){
                     String txt = textStr.substring(textStr.indexOf("1"));
-                    if (txt.length() >= 15 && Func.isNumeric(txt)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
+                    if (txt.length() >= 15 && Func.isNumeric(txt)) {
                         System.out.println(txt);
                         eVisaConfigList.add(txt);
                     }
                 }
+                if (textStr.contains("✹")) {
+                    String textString = textStr.substring(textStr.indexOf("✹") + 1);
+                    if (textString.contains("||✹")) {
+                        String[] textS1 = Func.toStrArray("\\|\\|✹",textString);
+                        for(String txt : textS1){
+                            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)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
+                                eVisaConfigList.add("✹" + txt);
+                            }
+                        }
+                    }
+                    if (textString.contains("*✹")) {
+                        String[] textS1 = Func.toStrArray("\\*✹",textString);
+                        for(String txt : textS1){
+                            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)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
+                                eVisaConfigList.add("✹" + txt);
+                            }
+                        }
+                    }
+                    if(textString.startsWith("1")){
+                        if (textString.length() >= 15 && Func.isNumeric(textString)) {
+                            eVisaConfigList.add("✹" + textString);
+                        }
+                    }
+                }
             }
 
 
@@ -86,11 +132,10 @@ 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){
+                int index = textStr.indexOf("*");
+                if(index>=0 && textStr.charAt(index+1) != '✹'){
                     textStr = textStr.substring(textStr.lastIndexOf("*")+1,textStr.length());
                 }
 
@@ -105,6 +150,17 @@ public class PDFUtils {
                         eVisaConfigList.add(txt);
                     }
                 }
+                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);
+                    }
+                }
 
                 // 特殊处理
                 if(textStr.indexOf("1")>=0){
@@ -114,6 +170,40 @@ public class PDFUtils {
                         eVisaConfigList.add(txt);
                     }
                 }
+                if (textStr.contains("✹")) {
+                    String textString = textStr.substring(textStr.indexOf("✹") + 1);
+                    if (textString.contains("||✹")) {
+                        String[] textS1 = Func.toStrArray("\\|\\|✹",textString);
+                        for(String txt : textS1){
+                            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)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
+                                eVisaConfigList.add("✹" + txt);
+                            }
+                        }
+                    }
+                    if (textString.contains("*✹")) {
+                        String[] textS1 = Func.toStrArray("\\*✹",textString);
+                        for(String txt : textS1){
+                            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)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
+                                eVisaConfigList.add("✹" + txt);
+                            }
+                        }
+                    }
+                    if(textString.startsWith("1")){
+                        if (textString.length() >= 15 && Func.isNumeric(textString)) {
+                            eVisaConfigList.add("✹" + textString);
+                        }
+                    }
+                }
             }