소스 검색

实名相关

baibx 4 달 전
부모
커밋
c71692ca3b

+ 16 - 32
com.sharemao.core.task/src/main/java/com/sharemao/core/task/iot2/ct/RealNameV2.java

@@ -1,10 +1,13 @@
1 1
 package com.sharemao.core.task.iot2.ct;
2 2
 
3 3
 import com.nianzai.base.dao.util.DAOHelper;
4
+import com.nianzai.util.DateTimeUtil;
4 5
 import com.sharemao.core.task.iot.bw.BW;
5 6
 import org.apache.commons.logging.Log;
6 7
 import org.apache.commons.logging.LogFactory;
7 8
 
9
+import java.time.LocalDateTime;
10
+import java.time.format.DateTimeFormatter;
8 11
 import java.util.List;
9 12
 import java.util.Map;
10 13
 import java.util.Objects;
@@ -23,9 +26,8 @@ public class RealNameV2 {
23 26
 	{
24 27
 	 	String sql="select * from iccid_to_realname";
25 28
 	   	List<Map<String,Object>> simlist=DAOHelper.find("mifi", sql);
26
-		if(simlist!=null && simlist.size()>0)
29
+		if(simlist!=null && !simlist.isEmpty())
27 30
 		{
28
-			int k=0;
29 31
 			for(Map<String,Object> m:simlist)
30 32
 			{
31 33
 				String iccid=m.get("iccid").toString();
@@ -38,46 +40,28 @@ public class RealNameV2 {
38 40
 				String status;
39 41
                 if (kasid==59){
40 42
                     status = CTAPI.zysm(iccid,resettm);
41
-                } else if(kasid==23 || kasid==25 || kasid==26 || kasid==46 || kasid==47 || kasid==50 || kasid==66 || kasid==67){
43
+                } else if(kasid==23 || kasid==25 || kasid==26 || kasid==46 || kasid==47 || kasid==50 || kasid==66 || kasid==67 || kasid==89 || kasid==90){
42 44
                     status = BW.getRealname(iccid,resettm);
43 45
                 } else {
44 46
                     status =CTAPI.sm(token, iccid,kasid,resettm);
45 47
                 }
46 48
 
47
-				int i=0;
48
-				while("TOKEN不存在或已过期,请重新获取".equals(status))
49
-				{
50
-					i+=1;
51
-					try {
52
-						Thread.sleep(30000);
53
-					} catch (InterruptedException e) {
54
-						e.printStackTrace();
55
-					}
56
-					token=CTAPI.getToken(kasid);
57
-                    if (kasid==59){
58
-                        status = CTAPI.zysm(iccid,resettm);
59
-                    } else if(kasid==23 || kasid==25 || kasid==26 || kasid==46 || kasid==47 || kasid==50 || kasid==66 || kasid==67 || kasid==89 || kasid==90){
60
-                        status = BW.getRealname(iccid,resettm);
61
-                    } else {
62
-                        status = CTAPI.sm(token, iccid, kasid, resettm);
63
-                    }
64
-					if (i==10) {
65
-						break;
66
-					}
67
-				}
68
-
69 49
 				log.info("kasid="+kasid+",iccid="+iccid+",status="+status);
70 50
 
71
-				if(!"TOKEN不存在或已过期,请重新获取".equals(status)) {
51
+				if("已实名".equals(status)) {
72 52
 					String up="update iccidtemp set realstate='"+status+"' where iccid='"+iccid+"'";
73 53
 					DAOHelper.execute("ufiiccid", up);
74
-                    if ("已实名".equals(status)) {
75
-                        String del = "delete from iccid_to_realname where iccid='" + iccid + "'";
76
-                        DAOHelper.execute("mifi", del);
77
-                    }
78
-				}
79
-				k++;
54
+                    String del = "delete from iccid_to_realname where iccid='" + iccid + "'";
55
+                    DAOHelper.execute("mifi", del);
56
+                }
80 57
 			}
58
+
59
+//            LocalDateTime now = LocalDateTime.now();
60
+//            LocalDateTime before2Hours = now.minusHours(2);
61
+//            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
62
+//            String formattedTime = before2Hours.format(formatter);
63
+//            String del = "delete from iccid_to_realname where crttm<'" + formattedTime + "'";
64
+//            DAOHelper.execute("mifi", del);
81 65
 		}
82 66
 	}
83 67
 }

+ 71 - 6
com.sharemao.web.fe/src/main/java/ink/mifi/fe/tools/CTAPI.java

@@ -1,10 +1,17 @@
1 1
 package ink.mifi.fe.tools;
2 2
 
3
+import java.io.BufferedReader;
4
+import java.io.DataOutputStream;
5
+import java.io.IOException;
6
+import java.io.InputStreamReader;
7
+import java.net.URL;
3 8
 import java.security.MessageDigest;
4 9
 import java.security.NoSuchAlgorithmException;
5 10
 import java.util.*;
6 11
 import java.util.Map.Entry;
7 12
 
13
+import com.alibaba.fastjson.JSON;
14
+import com.nianzai.util.CodecUtil;
8 15
 import org.apache.commons.codec.digest.DigestUtils;
9 16
 import org.apache.commons.logging.Log;
10 17
 import org.apache.commons.logging.LogFactory;
@@ -15,6 +22,8 @@ import com.nianzai.util.DateTimeUtil;
15 22
 
16 23
 import cn.hutool.http.HttpUtil;
17 24
 
25
+import javax.net.ssl.HttpsURLConnection;
26
+
18 27
 public class CTAPI 
19 28
 {
20 29
 
@@ -22,12 +31,7 @@ public class CTAPI
22 31
 
23 32
 	public static void main(String[] args)
24 33
 	{
25
-        String token=getToken(80);
26
-        String content=quicksm(token,"898604431625D1665436",80,"1");
27
-        System.out.println(content);
28
-
29
-//		String content=zyquicksm("898604F61925C0225986");
30
-//		System.out.println(content);
34
+        bwquicksm("89860441192580181043");
31 35
 	}
32 36
 	
33 37
 	public static String getToken(int index)
@@ -432,4 +436,65 @@ public class CTAPI
432 436
         }
433 437
 		return re;
434 438
 	}
439
+	//北纬快速实名
440
+	public static String bwquicksm(String iccid)
441
+	{
442
+        String re="";
443
+        String url="https://ntf-oc.hb-vpc-prod.bwae.org/open-api/query/getRealNameUrl";
444
+        String timestamp=DateTimeUtil.longtime();
445
+        String appid="ju5duzoyvjne8kro";
446
+        String secret="buwl34s7zot82j2n";
447
+        String sign= CodecUtil.str2md5(appid+secret+timestamp);
448
+        Map<String,Object> m=new HashMap<String,Object>();
449
+        m.put("cardType", "0");
450
+        m.put("cardId", iccid);
451
+        String param= JSON.toJSONString(m);;
452
+        String content="";
453
+        try {
454
+            content = getContentByPost(url, param, timestamp, appid, sign);
455
+        } catch (IOException e) {
456
+            e.printStackTrace();
457
+        }
458
+        log.info(url+"===>"+content);
459
+        JSONObject resJson = JSONObject.parseObject(content);
460
+        JSONObject respStatus = JSONObject.parseObject(resJson.getString("respStatus"));
461
+        String resCode = respStatus.getString("code");
462
+        if(resCode.equals("0000"))
463
+        {
464
+            JSONObject respBody = JSONObject.parseObject(resJson.getString("respBody"));
465
+            re=respBody.getString("realNameUrl");
466
+        }
467
+		return re;
468
+	}
469
+    public static String getContentByPost(String urlStr,String param,String timestamp,String appid,String sign) throws IOException
470
+    {
471
+        URL url = new URL(urlStr);
472
+        HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
473
+        conn.setRequestProperty("User-Agent","Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
474
+        conn.setDoOutput(true);
475
+        conn.setDoInput(true);
476
+        conn.setRequestMethod("POST");
477
+        conn.setRequestProperty("Content-Type", "application/json");
478
+        conn.setRequestProperty("timestamp", timestamp);
479
+        conn.setRequestProperty("appid", appid);
480
+        conn.setRequestProperty("sign", sign);
481
+
482
+        conn.connect();
483
+        DataOutputStream out = new DataOutputStream(conn.getOutputStream());
484
+        out.write(param.getBytes());
485
+        out.flush();
486
+        out.close();
487
+        BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(),"utf-8"));
488
+        StringBuilder tempStr = new StringBuilder();
489
+        String fileLine="";
490
+        while((fileLine=br.readLine())!=null)
491
+        {
492
+            tempStr.append(fileLine);
493
+            tempStr.append("\r\n");
494
+        }
495
+        br.close();
496
+        conn.disconnect();
497
+
498
+        return new String(tempStr);
499
+    }
435 500
 }

+ 4 - 1
com.sharemao.web.fe/src/main/java/ink/mifi/fe/tools/RealController.java

@@ -117,7 +117,10 @@ public class RealController
117 117
                             if (kid == 59){
118 118
                                 cturl = CTAPI.zyquicksm(iccid1);
119 119
                                 log.info("kid="+kid+",iccid1="+iccid1+",key="+key+",cturl="+cturl);
120
-                            } else {
120
+                            } else if (kid == 46 || kid == 25 || kid == 66 || kid == 89 || kid == 90){
121
+                                cturl = CTAPI.bwquicksm(iccid1);
122
+                                log.info("kid="+kid+",iccid1="+iccid1+",key="+key+",cturl="+cturl);
123
+                            }  else {
121 124
                                 if (kid == 57 || kid == 60) {
122 125
                                     token = screct;
123 126
                                 } else {