baibx hace 7 meses
padre
commit
82089e07d4

+ 8 - 5
com.sharemao.web.manager/src/main/java/test/SMD.java

@@ -192,17 +192,20 @@ public class SMD
192 192
 	public static void sim2() throws Exception
193 193
 	{
194 194
     	String filename="E:/deviceinbase/b.txt";
195
-//    	PrintWriter writer = new PrintWriter(new FileWriter("E:/deviceinbase/b.sql", true));
195
+    	PrintWriter writer = new PrintWriter(new FileWriter("E:/deviceinbase/b.sql", true));
196 196
     	BufferedReader reader = new BufferedReader(new FileReader(filename));
197 197
         String line;
198 198
         while ((line = reader.readLine()) != null) {
199 199
         	String[] cc=line.split("\t");
200
-        	String sqli="insert into smd(sn,iccid,access_number,orgid,rmode,flag) values('"+cc[0].trim()+"','"+cc[1].trim().toUpperCase()+"','"+cc[2].trim()+"',3,4,1);";
200
+            String iccid = cc[0].trim();
201
+            String appid = cc[1].trim();
202
+            String pwd = cc[2].trim();
203
+            String sqli="update `iccidtemp` set appid='"+appid+"',pwd='"+pwd+"' where iccid='"+iccid+"';";
201 204
             System.out.println(sqli);
202
-            RCPService.getBaseService().execSql(sqli);
203
-//			writer.println(sqli);
205
+//            RCPService.getBaseService().execSql(sqli);
206
+			writer.println(sqli);
204 207
         }
205
-//        writer.close();
208
+        writer.close();
206 209
         reader.close();
207 210
 	}
208 211
 

+ 69 - 0
com.sharemao.web.xw3/src/main/java/com/sharemao/web/wx/ctrl/AuthCtrl.java

@@ -690,6 +690,75 @@ public class AuthCtrl
690 690
 			return new TextView(path);
691 691
 		}
692 692
 	}
693
+
694
+	/**
695
+	 * 联网认证
696
+	 * @param context
697
+	 * @return
698
+	 */
699
+	@Path(value="/lwrz.do")
700
+	public TextView lwrz(Context context)
701
+	{
702
+		String auth2Url="http://auth2.freeco.cn/auth2/login.do?iccid=";
703
+
704
+		Map<String, String> para = context.getParas();
705
+		GzhUtil.toM3Sign(para);
706
+
707
+		HttpSession session = context.getRequest().getSession();
708
+		String devid ="";
709
+		if(session.getAttribute("cursn")!=null)
710
+			devid=(String)session.getAttribute("cursn");
711
+		else
712
+			devid=(String)session.getAttribute("defaultdev");
713
+
714
+		if(Tools.isEmpty(devid))
715
+			return new TextView("/sming.jsp?t=0");
716
+
717
+		int rmode=0;
718
+		String url=Constants.m3IntAddr + "/device/getDevRunMode.do?devid="+devid;
719
+		String result = GzhUtil.sendPost(url, para);
720
+		log.info(result);
721
+		JSONObject resJson = JSONObject.parseObject(result);
722
+		int resCode = resJson.getIntValue("code");
723
+		if(resCode == 0){
724
+			JSONObject dataJson = resJson.getJSONObject("data");
725
+			rmode=dataJson.getIntValue("rmode");
726
+		}
727
+		log.info(devid+url+",rmode="+rmode);
728
+        String iccid = "1";
729
+
730
+		//if(rmode<=2)
731
+		{
732
+			url=Constants.m3IntAddr + "/device/getIccidBySN2.do?devid="+devid+"&mode="+rmode;
733
+			log.info(devid+url);
734
+			result = GzhUtil.sendPost(url, para);
735
+
736
+			resJson = JSONObject.parseObject(result);
737
+
738
+			resCode = resJson.getIntValue("code");
739
+			if(resCode == 0)
740
+			{
741
+				String phonenum=(String)session.getAttribute("phonenum");
742
+
743
+				JSONObject dataJson = resJson.getJSONObject("data");
744
+				String iccid1 = dataJson.getString("iccid1");
745
+				String iccid2 = dataJson.getString("iccid2");
746
+				String iccid3 = dataJson.getString("iccid3");
747
+                String state1 = dataJson.getString("state1");
748
+                String state2 = dataJson.getString("state2");
749
+                String state3 = dataJson.getString("state3");
750
+				context.getRequest().setAttribute("devid", devid);
751
+
752
+				if(state1.equals("0") && !Tools.isEmpty(iccid1))
753
+					iccid=iccid1;
754
+				else if(state2.equals("0") && !Tools.isEmpty(iccid2))
755
+					iccid=iccid2;
756
+				else if(state3.equals("0") && !Tools.isEmpty(iccid3))
757
+					iccid=iccid3;
758
+			}
759
+			return new TextView(auth2Url+iccid);
760
+		}
761
+	}
693 762
 	
694 763
 	@Path(value="/guide.do")
695 764
 	public TextView guide(Context context)

+ 5 - 0
com.sharemao.web.xw3/src/main/webapp/mifi.jsp

@@ -235,6 +235,10 @@
235 235
             <div class="text">会员权益</div>
236 236
         </li>
237 237
       </c:if>
238
+        <li onclick="location='/user/lwrz.do'">
239
+            <div class="icon"><img src="/static/img/icon-nav-lwrz.png"></div>
240
+            <div class="text">联网认证</div>
241
+        </li>
238 242
     </div>
239 243
 </div>
240 244
 
@@ -442,6 +446,7 @@
442 446
 				});
443 447
 			}
444 448
 		}
449
+
445 450
 </script>
446 451
 </body>
447 452
 </html>

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 32 - 0
com.sharemao.web.xw3/src/main/webapp/nulldevid.html


BIN
com.sharemao.web.xw3/src/main/webapp/static/img/icon-nav-lwrz.png


+ 26 - 0
com.shuhaiwifi.web.auth2/src/main/java/com/shuhaiwifi/web/auth2/MacAddressGenerator.java

@@ -0,0 +1,26 @@
1
+package com.shuhaiwifi.web.auth2;
2
+
3
+import java.util.Random;
4
+
5
+public class MacAddressGenerator {
6
+    public static void main(String[] args) {
7
+        String macAddress = generateRandomMacAddress();
8
+        System.out.println("Random MAC Address: " + macAddress);
9
+    }
10
+
11
+    public static String generateRandomMacAddress() {
12
+        Random random = new Random();
13
+        StringBuilder sb = new StringBuilder();
14
+
15
+        for (int i = 0; i < 6; i++) { // 生成6个字节
16
+            int byteValue = random.nextInt(256); // 生成0到255之间的随机数
17
+            String hex = String.format("%02X", byteValue); // 转换为十六进制字符串
18
+            sb.append(hex);
19
+            if (i < 5) {
20
+                sb.append("-");
21
+            }
22
+        }
23
+
24
+        return sb.toString().toUpperCase(); // 返回大写的MAC地址字符串
25
+    }
26
+}

+ 73 - 71
com.shuhaiwifi.web.auth2/src/main/java/com/shuhaiwifi/web/auth2/ctrl/Auth2Controller.java

@@ -4,6 +4,8 @@ import java.util.HashMap;
4 4
 import java.util.List;
5 5
 import java.util.Map;
6 6
 
7
+import com.nianzai.base.mvc.view.TextView;
8
+import com.shuhaiwifi.web.auth2.MacAddressGenerator;
7 9
 import com.shuhaiwifi.web.auth2.iot.*;
8 10
 import org.apache.commons.logging.Log;
9 11
 import org.apache.commons.logging.LogFactory;
@@ -312,77 +314,77 @@ public class Auth2Controller
312 314
 		return new JsonView(mm, CodeEnum.OK.getMessage(), 0);
313 315
 	}
314 316
 
315
-//	@Path(value="/login.do")
316
-//	public TextView login(Context context)
317
-//	{
318
-//		Map<String, String> para = context.getParas();
319
-//		
320
-//		String token="";
321
-//		String iccid=para.get("iccid");
322
-//		String mac=para.get("mac");
323
-//		
324
-//		String terminalMac=para.get("terminalMac");
325
-//		
326
-//		String appid="";
327
-//		
328
-//		String client=para.get("c");
329
-//		
330
-//		logger.info("mac="+mac+",client="+client+",terminalMac="+terminalMac+",iccid="+iccid);
331
-//		
332
-//		
333
-//		mac=mac.replace(":", "-");
334
-//		terminalMac=terminalMac.replace(":", "-");
335
-//		
336
-//		String op=Iot.getOprtStr(iccid);
337
-//		String urlo="";
338
-//		if(op.equals("中国移动") || op.equals("中国电信"))
339
-//			urlo=appserver + "/device/getKasInfo.do?flag=1&iccid="+iccid;
340
-//		else
341
-//			urlo=appserver + "/device/getKasInfo.do?flag=0&iccid="+iccid;
342
-//		logger.info(urlo);
343
-//		String resulto = HttpUtil.getContent(urlo,"utf-8");
344
-//		logger.info(resulto);
345
-//		if(resulto.length()>1)
346
-//		{
347
-//			JSONObject resJsono = JSONObject.parseObject(resulto);
348
-//			//log.info(resJsono);
349
-//			JSONObject resJsond = JSONObject.parseObject(resJsono.getString("data"));
350
-//			String kas=resJsond.getString("kas");
351
-//			if(!Tools.isEmpty(kas) && kas.length()>1)
352
-//			{
353
-//				JSONObject resJsonk = JSONObject.parseObject(resJsond.getString("kas"));
354
-//				int isp=resJsonk.getIntValue("isp");
355
-//				int kasid=resJsonk.getIntValue("kasid");//卡商编号
356
-//				if(isp==3)
357
-//				{
358
-//					;
359
-//				}
360
-//				else if(isp==2)
361
-//				{
362
-//					;
363
-//				}
364
-//				else if(isp==1)
365
-//				{
366
-//					appid=resJsonk.getString("appid");
367
-//					String paswd=resJsonk.getString("pwd");
368
-//					token=CmApi.getToken(appid,paswd);
369
-//				}
370
-//				else if(isp==4)
371
-//				{
372
-//					token=ThirdToken.getToken(kasid, iccid);
373
-//					logger.info(token);
374
-//				}
375
-//			}
376
-//		}
377
-//		
378
-//		context.getRequest().setAttribute("token", token);
379
-//		context.getRequest().setAttribute("iccid", iccid);
380
-//		context.getRequest().setAttribute("mac", mac);
381
-//		context.getRequest().setAttribute("terminalMac", terminalMac);
382
-//		context.getRequest().setAttribute("appid", appid);
383
-//		
384
-//		return new TextView("/login-sms.jsp");
385
-//	}	
317
+	@Path(value="/login.do")
318
+	public TextView login(Context context)
319
+	{
320
+		Map<String, String> para = context.getParas();
321
+
322
+		String token="";
323
+		String iccid=para.get("iccid");
324
+		String mac= MacAddressGenerator.generateRandomMacAddress();
325
+
326
+		String terminalMac=MacAddressGenerator.generateRandomMacAddress();
327
+
328
+		String appid="";
329
+
330
+		String client=para.get("c");
331
+
332
+		logger.info("mac="+mac+",client="+client+",terminalMac="+terminalMac+",iccid="+iccid);
333
+
334
+
335
+		mac=mac.replace(":", "-");
336
+		terminalMac=terminalMac.replace(":", "-");
337
+
338
+		String op=Iot.getOprtStr(iccid);
339
+		String urlo="";
340
+		if(op.equals("中国移动") || op.equals("中国电信"))
341
+			urlo=appserver + "/device/getKasInfo.do?flag=1&iccid="+iccid;
342
+		else
343
+			urlo=appserver + "/device/getKasInfo.do?flag=0&iccid="+iccid;
344
+		logger.info(urlo);
345
+		String resulto = HttpUtil.getContent(urlo,"utf-8");
346
+		logger.info(resulto);
347
+		if(resulto.length()>1)
348
+		{
349
+			JSONObject resJsono = JSONObject.parseObject(resulto);
350
+			//log.info(resJsono);
351
+			JSONObject resJsond = JSONObject.parseObject(resJsono.getString("data"));
352
+			String kas=resJsond.getString("kas");
353
+			if(!Tools.isEmpty(kas) && kas.length()>1)
354
+			{
355
+				JSONObject resJsonk = JSONObject.parseObject(resJsond.getString("kas"));
356
+				int isp=resJsonk.getIntValue("isp");
357
+				int kasid=resJsonk.getIntValue("kasid");//卡商编号
358
+				if(isp==3)
359
+				{
360
+					;
361
+				}
362
+				else if(isp==2)
363
+				{
364
+					;
365
+				}
366
+				else if(isp==1)
367
+				{
368
+					appid=resJsonk.getString("appid");
369
+					String paswd=resJsonk.getString("pwd");
370
+					token=CmApi.getToken(appid,paswd);
371
+				}
372
+				else if(isp==4)
373
+				{
374
+					token=ThirdToken.getToken(kasid, iccid);
375
+					logger.info(token);
376
+				}
377
+			}
378
+		}
379
+
380
+		context.getRequest().setAttribute("token", token);
381
+		context.getRequest().setAttribute("iccid", iccid);
382
+		context.getRequest().setAttribute("mac", mac);
383
+		context.getRequest().setAttribute("terminalMac", terminalMac);
384
+		context.getRequest().setAttribute("appid", appid);
385
+
386
+		return new TextView("/login-sms.jsp");
387
+	}
386 388
 	
387 389
 	@Path(value="/sms.do")
388 390
 	public JsonView sms(Context context)

+ 3 - 3
com.shuhaiwifi.web.auth2/src/main/java/com/shuhaiwifi/web/auth2/iot/CmApi.java

@@ -24,12 +24,12 @@ public class CmApi
24 24
 	
25 25
 	public static void main(String[] args) 
26 26
 	{
27
-		String appid="C5010200A9992000969793";
28
-		String paswd="O3UPdD,uj*5K";
27
+		String appid="IOTSIM1442579794999";
28
+		String paswd="WH*r@dU6Cz.F";
29 29
 		String token=getToken(appid,paswd);
30 30
 		logger.info(token);
31 31
 	
32
-		getTerminalList(token,"898604871925C0215979","18-60-24-8F-4D-AD");
32
+		getTerminalList(token,"898608871825D0194998","18-60-24-8F-4D-AD");
33 33
         //sendSms(token,"898604871925C0215979","18-60-24-8F-4D-AD");
34 34
         //terminalAuth(token,"898604871925C0215979","18-60-24-8F-4D-AD");
35 35
 	}