|
@@ -9,6 +9,7 @@ import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.StringTokenizer;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -21,24 +22,15 @@ import java.io.IOException;
|
|
@Service
|
|
@Service
|
|
public class TLocationCheckServiceImpl extends ServiceImpl<TLocationCheckMapper, TLocationCheck> implements TLocationCheckService {
|
|
public class TLocationCheckServiceImpl extends ServiceImpl<TLocationCheckMapper, TLocationCheck> implements TLocationCheckService {
|
|
|
|
|
|
-
|
|
|
|
private static final String appid = "07784f5fedb508046c841b391005b7de";
|
|
private static final String appid = "07784f5fedb508046c841b391005b7de";
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String locCheckNoMsg(TLocationCheck locationCheck, String clientId, String addr) {
|
|
public String locCheckNoMsg(TLocationCheck locationCheck, String clientId, String addr) {
|
|
- String location = locationCheck.getLocation();
|
|
|
|
String country = locationCheck.getCountry();
|
|
String country = locationCheck.getCountry();
|
|
if (StringUtils.isEmpty(country)) {
|
|
if (StringUtils.isEmpty(country)) {
|
|
return "国家不能为空";
|
|
return "国家不能为空";
|
|
}
|
|
}
|
|
- // 如果 pro,city,addr 中都不包含 country 或者 location,就是异常,发短信通知
|
|
|
|
- boolean containsUserInput = true;
|
|
|
|
- // location 为空 / 不为空
|
|
|
|
- if (StringUtils.isEmpty(location)) {
|
|
|
|
- containsUserInput = addr.contains(country);
|
|
|
|
- } else {
|
|
|
|
- containsUserInput = addr.contains(country) || addr.contains(location) || location.contains(addr);
|
|
|
|
- }
|
|
|
|
|
|
+ boolean containsUserInput = isAddressInCountryList(addr, country);
|
|
|
|
|
|
if (!containsUserInput) { // 不包含,发短信通知,并拒绝审核
|
|
if (!containsUserInput) { // 不包含,发短信通知,并拒绝审核
|
|
return "fail";
|
|
return "fail";
|
|
@@ -49,22 +41,13 @@ public class TLocationCheckServiceImpl extends ServiceImpl<TLocationCheckMapper,
|
|
@Override
|
|
@Override
|
|
public String locCheckMsg(TLocationCheck locationCheck, String clientId, String addr) throws IOException {
|
|
public String locCheckMsg(TLocationCheck locationCheck, String clientId, String addr) throws IOException {
|
|
|
|
|
|
- String location = locationCheck.getLocation();
|
|
|
|
String country = locationCheck.getCountry();
|
|
String country = locationCheck.getCountry();
|
|
|
|
|
|
if (StringUtils.isEmpty(country)) {
|
|
if (StringUtils.isEmpty(country)) {
|
|
return "国家不能为空";
|
|
return "国家不能为空";
|
|
}
|
|
}
|
|
|
|
|
|
- // 如果 pro,city,addr 中都不包含 country 或者 location,就是异常,发短信通知
|
|
|
|
- boolean containsUserInput = true;
|
|
|
|
- // location 为空 / 不为空
|
|
|
|
- // country 是中国 / 不是中国
|
|
|
|
- if (StringUtils.isEmpty(location)) {
|
|
|
|
- containsUserInput = addr.contains(country);
|
|
|
|
- } else {
|
|
|
|
- containsUserInput = addr.contains(country) || addr.contains(location) || location.contains(addr);
|
|
|
|
- }
|
|
|
|
|
|
+ boolean containsUserInput = isAddressInCountryList(addr, country);
|
|
|
|
|
|
String phone = "18620242721";
|
|
String phone = "18620242721";
|
|
// String phone1 = "13631231970"; // 基哥
|
|
// String phone1 = "13631231970"; // 基哥
|
|
@@ -79,23 +62,30 @@ public class TLocationCheckServiceImpl extends ServiceImpl<TLocationCheckMapper,
|
|
return "success";
|
|
return "success";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static boolean isAddressInCountryList(String addr, String country) {
|
|
|
|
+ // 使用StringTokenizer分割国家字符串
|
|
|
|
+ StringTokenizer tokenizer = new StringTokenizer(country, "、");
|
|
|
|
+
|
|
|
|
+ // 循环遍历国家列表
|
|
|
|
+ while (tokenizer.hasMoreTokens()) {
|
|
|
|
+ String singleCountry = tokenizer.nextToken();
|
|
|
|
+ // 如果地址包含当前国家,则返回true
|
|
|
|
+ if (addr.contains(singleCountry)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 如果没有找到匹配的国家,则返回false
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public String schLocCheck(TLocationCheck locationCheck, String clientId, String addr) {
|
|
public String schLocCheck(TLocationCheck locationCheck, String clientId, String addr) {
|
|
- String location = locationCheck.getLocation();
|
|
|
|
String country = locationCheck.getCountry();
|
|
String country = locationCheck.getCountry();
|
|
|
|
|
|
if (StringUtils.isEmpty(country)) {
|
|
if (StringUtils.isEmpty(country)) {
|
|
return "国家不能为空";
|
|
return "国家不能为空";
|
|
}
|
|
}
|
|
-
|
|
|
|
- boolean containsUserInput = true;
|
|
|
|
- // location 地区为空 / 不为空
|
|
|
|
- // country 国家是中国 / 不是中国
|
|
|
|
- if (StringUtils.isEmpty(location)) {
|
|
|
|
- containsUserInput = addr.contains(country);
|
|
|
|
- } else {
|
|
|
|
- containsUserInput = addr.contains(country) || addr.contains(location) || location.contains(addr);
|
|
|
|
- }
|
|
|
|
|
|
+ boolean containsUserInput = isAddressInCountryList(addr, country);
|
|
|
|
|
|
if (!containsUserInput) { // 不包含,返回设备编号
|
|
if (!containsUserInput) { // 不包含,返回设备编号
|
|
return "{" + clientId + "}";
|
|
return "{" + clientId + "}";
|