本地的手机号码归属地查询-oracle数据

最近做的项目中,有个功能是手机归属地查询,因为项目要在内网下运行,所以不能用提供的webservice,只好在网上找手机归属地的数据,很多都是access的,我们的项目是用oracle,只好自己转吧,转过来的提供到网上,方便大家使用。数据还是比较新的,是2014年的。

下面是部分代码,如果需要全部代码,可以直接下载。

TabMobileServiceImpl.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package   com.zhouyu.service.impl;
 
import   java.util.List;
 
import   org.springframework.beans.factory.annotation.Autowired;
import   org.springframework.stereotype.Service;
 
import   com.zhouyu.dao.BaseDaoI;
import   com.zhouyu.model.TabMobile;
import   com.zhouyu.service.TabMobileServiceI;
 
@Service ( "tabMobileService" )
public   class   TabMobileServiceImpl implements   TabMobileServiceI
{
     private   BaseDaoI<TabMobile> tabMobileDao;
     @Autowired
     public   void   setTabMobileDao(BaseDaoI<TabMobile> tabMobileDao)
     {
         this .tabMobileDao = tabMobileDao;
     }
 
     @Override
     public   String getMobileArea(Long mobileNumber)
     {
         // TODO Auto-generated method stub
         String area = "" ;
         String hql = "from TabMobile m where m.mobileNumber = '" +mobileNumber+ "'" ;
         List<TabMobile> list = tabMobileDao.find(hql);
         if (list.size()> 0 )
         {
             area = list.get( 0 ).getMobileArea() + "  --  "   + list.get( 0 ).getMobileType();
         }
         return   area;
     }
}

 MobileAction.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package   com.zhouyu.action;
 
import   org.apache.struts2.convention.annotation.Action;
import   org.apache.struts2.convention.annotation.Result;
import   org.springframework.beans.factory.annotation.Autowired;
 
import   com.opensymphony.xwork2.ModelDriven;
import   com.zhouyu.pageModel.Mobile;
import   com.zhouyu.service.TabMobileServiceI;
 
@Action (value = "mobileAction" , results = { @Result (name = "goMobile" , location = "/wnl/mobile.jsp" )})
public   class   MobileAction extends   BaseAction implements   ModelDriven<Mobile>
{
     private   Mobile mobile = new   Mobile();
     private   TabMobileServiceI tabMobileService;
     @Autowired
     public   void   setTabMobileService(TabMobileServiceI tabMobileService)
     {
         this .tabMobileService = tabMobileService;
     }
 
     @Override
     public   Mobile getModel()
     {
         // TODO Auto-generated method stub
         return   mobile;
     }
     
     public   String goMobile()
     {
         return   "goMobile" ;
     }
     
     public   void   getArea() throws   Exception
     {
         String area = tabMobileService.getMobileArea(mobile.getMobileNumber());
         super .writeJson(area);
     }
}

mobile.jsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<%@ page contentType= "text/html; charset=utf-8" %>
 
<!DOCTYPE html>
<html>
<head>
<jsp:include page= "../inc.jsp" ></jsp:include>
<style type= "text/css" >
.input {
     width: 260px;
     height: 30px;
     font-size: 28px;
     text-align:center;
     border-top: 1px solid # 404040 ;
     border-left: 1px solid # 404040 ;
     border-right: 1px solid #D4D0C8;
     border-bottom: 1px solid #D4D0C8;
}
 
.STYLE1 {
     font-size: 36px;
     color: #FF0000;
}
 
</style>
<script type= "text/javascript" >
document.onkeyup=function(){
     var s = document.getElementById( "dd" ).value;
 
            document.getElementById( "a" ).innerHTML= s
            if (s.length > 11 )
             {
                 document.getElementById( "a" ).innerHTML= "输入的号码超出11位" ;
             }
     }
     function testzy(obj)
     {
         obj.value = obj.value.replace(/[^\d.]/g, "" );
         var d = $( '#dd' ).val();
         if (d.length == 7 )
         {
             $.ajax({
                 type: "POST" , //使用get方法访问后台或者post
                 dataType: "json" , //返回json格式的数据
                 url: "mobileAction!getArea.action?mobileNumber=" +d, //要访问的后台地址
                 contentType: "application/x-www-form-urlencoded; charset=utf-8" ,
                 success: function(data){ //成功时会允许下面的函数,data为返回的数据,为数组类型
                     $( "#cc" ).html(data);
                 }
             });
         }
         if (d.length > 7   && d.length <= 11 )
         {
             var str = d.substr( 0 , 7 );
             $.ajax({
                 type: "POST" , //使用get方法访问后台或者post
                 dataType: "json" , //返回json格式的数据
                 url: "mobileAction!getArea.action?mobileNumber=" +str, //要访问的后台地址
                 contentType: "application/x-www-form-urlencoded; charset=utf-8" ,
                 success: function(data){ //成功时会允许下面的函数,data为返回的数据,为数组类型
                     $( "#cc" ).html(data);
                 }
             });
         }
         if (d.length > 11 )
         {
             document.getElementById( "a" ).innerHTML= "输入的号码超出11位" ;
         }
     }
     
     function aaa()
     {
         $( "#dd" ).val( '' );
     }
</script>
</head>
   
<body>
     <h2>手机号码归属地查询</h2>
     <input type= "text"   id= "dd"   class = "input"   onkeyup= "testzy(this)"   />    <input id= "btn"   type= "button"   value= "清空"   onclick= "aaa()"   />    <span id= "a"   class = "STYLE1" ></span><br />
     <div id= "cc"   class = "STYLE1" ></div>
</body>
</html>

  

 

全部代码及数据库文件请到这里下载

http://download.csdn.net/detail/zyaizz/8145759

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值