From 09f57bf762c09dbf63ee701191aef994d9a716f3 Mon Sep 17 00:00:00 2001 From: bin Date: Thu, 14 Jan 2021 21:48:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=81=E8=AE=B8=E5=91=BC?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/IOT/Api/IotApiWhiteList.java | 13 ++++++++++++- .../impl/GZPlatformSettingService.java | 19 +++++++++++++------ .../zhaobiao/guizhou/utils/GZHttpUtil.java | 3 +++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiWhiteList.java b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiWhiteList.java index 2e11568..7ac7877 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiWhiteList.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiWhiteList.java @@ -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() { diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformSettingService.java b/src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformSettingService.java index 5036161..9b5a9b8 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformSettingService.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformSettingService.java @@ -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); diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java b/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java index d72b881..37844bc 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java @@ -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; }