Browse Source

增加允许呼入

develop
bin 3 years ago
parent
commit
09f57bf762
3 changed files with 28 additions and 7 deletions
  1. +12
    -1
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiWhiteList.java
  2. +13
    -6
      src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformSettingService.java
  3. +3
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java

+ 12
- 1
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiWhiteList.java View File

@@ -23,7 +23,18 @@ public class IotApiWhiteList {
item.setPressKey(key);
item.setSos(isSos);
whiteList.add(item);

}
public void addPhone(String phone, String relationship, String key, int inComing, int callOut, int isSos){
IotApiWhiteListItem item = new IotApiWhiteListItem();
item.setRelationship(relationship);
item.setPhone(phone);
item.setCallOut(callOut);
item.setInComing(inComing);
item.setLevel(1);
item.setOuttime("");
item.setPressKey(key);
item.setSos(isSos);
whiteList.add(item);
}

public String getSerialNo() {


+ 13
- 6
src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformSettingService.java View File

@@ -115,7 +115,8 @@ public class GZPlatformSettingService implements IGZPlatformSettingService {
IotApiWhiteList whiteList = new IotApiWhiteList();
whiteList.setSerialNo(imei);
if(dbConfig.getAffectionPhone() == null || !dbConfig.getAffectionPhone().equals(config.getAffectionPhone()) ||
dbConfig.getAddressBook() == null || !dbConfig.getAddressBook().equals(config.getAddressBook())){
dbConfig.getAddressBook() == null || !dbConfig.getAddressBook().equals(config.getAddressBook()) ||
dbConfig.getWhitePhone() == null || !dbConfig.getWhitePhone().equals(config.getWhiteList())){
// if(true){
// SOS
String sos = config.getSosPhone();
@@ -161,6 +162,17 @@ public class GZPlatformSettingService implements IGZPlatformSettingService {
hadSos = hadSos ? hadSos : isSos;
whiteList.addPhone(aphone, relationship, "", (isSos? 1 : 0));
}
// 允许呼入
String whitePhone = config.getWhiteList();
phones = whitePhone.split(",");
for (int i = 0; i < phones.length; i++) {
String aphone = phones[i];
if(!Strings.isNullOrEmpty(aphone) && aphone.indexOf("*") < 0){
isSos = aphone.equals(sos);
hadSos = hadSos ? hadSos : isSos;
whiteList.addPhone(aphone, "", "", 2, 3, (isSos? 1 : 0));
}
}
// sos不在通讯录或亲情号码中,则另外加入白名单
if(!hadSos){
whiteList.addPhone(sos, "", "", 1);
@@ -174,11 +186,6 @@ public class GZPlatformSettingService implements IGZPlatformSettingService {
}
}






if(allSuccess){
// 存入数据库
dbConfig.setDeviceImei(imei);


+ 3
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java View File

@@ -4,6 +4,7 @@ import com.ssjl.zhaobiao.guizhou.entity.GZRequest;
import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.GZResponse;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Headers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -11,6 +12,7 @@ import org.springframework.stereotype.Component;

import java.io.IOException;

@Slf4j
@Component
public class GZHttpUtil {
@Autowired
@@ -46,6 +48,7 @@ public class GZHttpUtil {
byte[] res = httpUtil.postBytes(url, b, headers);
return res;
} catch (IOException e) {
log.info("目标地址:" + url);
e.printStackTrace();
throw e;
}


Loading…
Cancel
Save