1550076451 %!s(int64=2) %!d(string=před) roky
rodič
revize
fbbf8c6aa1

+ 122 - 3
zxkf-api/src/main/java/api/controller/call/MobileController.java

@@ -13,6 +13,7 @@ import api.util.enums.BusinessType;
13 13
 import api.util.helper.StringHelper;
14 14
 import io.swagger.annotations.Api;
15 15
 import io.swagger.annotations.ApiOperation;
16
+import lombok.var;
16 17
 import org.springframework.beans.factory.annotation.Autowired;
17 18
 import org.springframework.web.bind.annotation.*;
18 19
 import java.util.Arrays;
@@ -28,7 +29,7 @@ public class MobileController extends BaseController {
28 29
     @Log(title = "查询手机号归属地表列表",businessType = BusinessType.QUERY)
29 30
     @GetMapping
30 31
     public AjaxResult getList(Mobile input, PageInput pageInput) {
31
-        LambdaQueryWrapper<Mobile> qw = new LambdaQueryWrapper();
32
+        LambdaQueryWrapper<Mobile> qw = new LambdaQueryWrapper<>();
32 33
         qw.eq(input.getMobileId() != null && input.getMobileId() > 0, Mobile::getMobileId, input.getMobileId());
33 34
         qw.like(!StringHelper.isEmpty(input.getMobilePrefix()), Mobile::getMobilePrefix, input.getMobilePrefix());
34 35
         qw.like(!StringHelper.isEmpty(input.getLocationCode()), Mobile::getLocationCode, input.getLocationCode());
@@ -54,7 +55,7 @@ public class MobileController extends BaseController {
54 55
     @Log(title = "新增手机号归属地表",businessType = BusinessType.INSERT)
55 56
     @PostMapping
56 57
     public AjaxResult add(@RequestBody Mobile input) {
57
-        LambdaQueryWrapper<Mobile> qw = new LambdaQueryWrapper();
58
+        LambdaQueryWrapper<Mobile> qw = new LambdaQueryWrapper<>();
58 59
         qw.eq( Mobile::getMobilePrefix, input.getMobilePrefix());
59 60
         if(mobileService.getCount(qw)>0){
60 61
             return Error("此号码已经存在");
@@ -71,7 +72,7 @@ public class MobileController extends BaseController {
71 72
     @Log(title = "编辑手机号归属地表",businessType = BusinessType.UPDATE)
72 73
     @PutMapping
73 74
     public AjaxResult edit(@RequestBody Mobile input)  {
74
-        LambdaQueryWrapper<Mobile> qw = new LambdaQueryWrapper();
75
+        LambdaQueryWrapper<Mobile> qw = new LambdaQueryWrapper<>();
75 76
         qw.ne(Mobile::getMobileId,input.getMobileId());
76 77
         qw.eq(Mobile::getMobilePrefix, input.getMobilePrefix());
77 78
         if(mobileService.getCount(qw)>0){
@@ -96,5 +97,123 @@ public class MobileController extends BaseController {
96 97
             return Error("删除失败");
97 98
         }
98 99
     }
100
+    @ApiOperation("号码前缀")
101
+    @Log(title = "查询号码前缀",businessType = BusinessType.QUERY)
102
+    @GetMapping("/{phone}")
103
+    public AjaxResult GetCallOutprefix(@PathVariable String phone)
104
+    {
105
+        String phone1= phone.trim();
106
+        String tophone =phone1;
107
+        String fix = ""; String bfix = "9"; String wfix = "90";
108
+        String zipcode = "0371";
109
+        int zip = GetZipCodeByPhone(phone1, zipcode);
110
+        if (zip == 1)
111
+        {
112
+            fix = bfix;
113
+        }
114
+        else if (zip == 2)
115
+        {
116
+            fix = wfix;
117
+        }
118
+        else
119
+        {
120
+            char firstChar = phone1.charAt(0); // 获取第一个字符
121
+            if (firstChar == '0') {
122
+                tophone= phone1.substring(1); // 从索引为1开始提取子字符串(不包含第一个字符)
123
+                }
124
+            if (zip == 3)
125
+            {//本地固话去0加9 比如:988888517,937188888517
126
+                fix = bfix;
127
+            }
128
+            else if (zip == 4)
129
+            {//外地固话前加9 比如:9037188888517
130
+                fix = wfix;
131
+            }
132
+        }
133
+            var obj = new String[]
134
+                    {
135
+                            phone = fix + tophone,
136
+                            fix = fix
137
+                    };
138
+            return Success("成功",obj);
139
+
140
+
99 141
 
142
+    }
143
+
144
+    /// <summary>
145
+    /// 根据号码和区号判断号码是否为归属地号码
146
+    /// 返回0为分机号或特殊号码
147
+    /// 返回1为本地号码
148
+    /// 返回2为外地号码
149
+    /// </summary>
150
+    /// <param name="phone"></param>
151
+    /// <param name="zipcode"></param>
152
+    /// <returns></returns>
153
+    private int GetZipCodeByPhone(String phone,String zipcode)
154
+    {
155
+        int res = 0;
156
+        if (phone.length() >= 7)
157
+        {
158
+            //7位及7位以上是固定电话或手机
159
+            //判断是否手机
160
+            if (phone.length() == 11 && phone.charAt(0) == '1')
161
+            {//号码为11位,首位是1,为手机号
162
+                LambdaQueryWrapper<Mobile> qw = new LambdaQueryWrapper<>();
163
+                qw.eq( Mobile::getMobilePrefix, phone.substring(0,7));
164
+                var mobileModel=mobileService.getEntity(qw);
165
+                if (mobileModel != null)
166
+                {
167
+                    if (mobileModel.getLocationCode().equals(zipcode))
168
+                    {
169
+                        res = 1;
170
+                    }
171
+                    else
172
+                    {
173
+                        res = 2;
174
+                    }
175
+                }
176
+            }
177
+            else
178
+            {
179
+                if (phone.length()== 11 && phone.substring(0, 3).equals(zipcode))
180
+                {//号码为11位
181
+                    //截取前三位区号判断是否本地
182
+                    boolean resbd3 = phone.substring(0, 3).equals(zipcode);
183
+                    //截取前四位区号判断是否本地
184
+                    boolean resbd4 = phone.substring(0, 4).equals(zipcode);
185
+                    if (resbd3 || resbd4)
186
+                    {
187
+                        res = 3;
188
+                    }
189
+                    else
190
+                    {
191
+                        res = 4;
192
+                    }
193
+                }
194
+                else if (phone.length() < 11)
195
+                {//号码小于11位,为本地
196
+                    if (phone.substring(0, 1).equals("0"))
197
+
198
+                    {
199
+                        if (phone.substring(0, 4).equals(zipcode))
200
+                            res = 3;
201
+                        else
202
+                            res = 4;
203
+                    }
204
+                    else
205
+                        res = 3;
206
+                }
207
+                else if (phone.length() > 11 && phone.substring(0, 4).equals(zipcode))
208
+                {//号码大于11位,截取前四位区号判断是否本地
209
+                    res = 3;
210
+                }
211
+                else
212
+                {
213
+                    res = 4;
214
+                }
215
+            }
216
+        }
217
+        return res;
218
+    }
100 219
 }

+ 1 - 1
zxkf-api/src/main/java/api/controller/system/CustomerController.java

@@ -107,7 +107,7 @@ public class CustomerController extends BaseController {
107 107
         }
108 108
         else
109 109
         {
110
-            return Error("该客户不存在");
110
+            return Success("该客户不存在");
111 111
         }
112 112
 
113 113
     }