From 48c6ae93354653b13932e3653a06cace3732dc16 Mon Sep 17 00:00:00 2001 From: bin Date: Thu, 14 Jan 2021 15:11:14 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=B8=8Edocker=E9=95=9C=E5=83=8F=E6=97=B6=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 +++ src/main/resources/application.properties | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7dd97bd..fc3fdbb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,9 @@ MAINTAINER telpo VOLUME /tmp ADD target/dianxin-guizhou-forward-telpo0.0.2.jar app.jar +RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo "Asia/Shanghai" > /etc/timezone + EXPOSE 8102 ENTRYPOINT ["java","-jar", "/app.jar"] \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 5d3bb55..ebc1526 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -39,17 +39,23 @@ netty.port=8888 4g.api.token = 123Te1p0Te1p0321 # \u8D35\u5DDE\u7535\u4FE1\u53C2\u6570 guizhou.protocol=T01.4 -#guizhou.factory=telpo -#guizhou.device.model=TPS401 -#guizhou.device.version=ACB_1001 -guizhou.factory=zhizhong -guizhou.device.model=RZL600 -guizhou.device.version=RZL_2021 +guizhou.factory=telpo +guizhou.device.model=TPS401 +guizhou.device.version=ACB_1001 +#guizhou.factory=zhizhong +#guizhou.device.model=RZL600 +#guizhou.device.version=RZL_2021 #guizhou.factory=zhanneng #guizhou.device.model=TPE390 #guizhou.device.version=TPE_0056 guizhou.http.url=http://202.105.147.30:24183 +#\u5929\u6CE2 guizhou.device.testList= [{ "imei": "862622050253671","phone": "18664272743" },{ "imei": "862622050253358","phone": "" },{ "imei": "800115470000678","phone": "13500259054" }] +#\u667A\u4E2D +#guizhou.device.testList= [{ "imei": "862622050654340","phone": "18985521203" },{ "imei": "862622050317740","phone": "18985521202" }] +#\u5C55\u80FD +#guizhou.device.testList= [{ "imei": "862622050927027","phone": "19185301203" },{ "imei": "862622050925104","phone": "" }] + guizhou.device.zhizhong=862622050654340,862622050317740 guizhou.device.zhanneng=862622050925104,862622050927027 guizhou.device.tianbo=862622050253671,862622050253358,800115470000678 From ffbef483cb878ebd18ec7a7ebfc56734d6234a01 Mon Sep 17 00:00:00 2001 From: bin Date: Thu, 14 Jan 2021 16:43:13 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ssjl/zhaobiao/guizhou/quartz/QuartzConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/QuartzConfig.java b/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/QuartzConfig.java index 98bd80e..0154912 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/QuartzConfig.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/QuartzConfig.java @@ -35,7 +35,7 @@ public class QuartzConfig { @Bean public Trigger gzHeartTaskTrigger() { SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule() - .withIntervalInMinutes(1) + .withIntervalInMinutes(30) .repeatForever(); return TriggerBuilder.newTrigger() .forJob(gzHeartTask()) From 0674e66df915656e53ece1ae366872aeb5ddd127 Mon Sep 17 00:00:00 2001 From: yangl <284428564@QQ.com> Date: Thu, 14 Jan 2021 17:13:02 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guizhou/entity/GZMessage/GZUpCall.java | 82 +++++++++++++++++++ .../zhaobiao/guizhou/entity/IOT/IOTCall.java | 40 +++++++++ 2 files changed, 122 insertions(+) create mode 100644 src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java create mode 100644 src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java new file mode 100644 index 0000000..bac19db --- /dev/null +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java @@ -0,0 +1,82 @@ +package com.ssjl.zhaobiao.guizhou.entity.GZMessage; + +import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus; +import com.ssjl.zhaobiao.guizhou.entity.IMessageContent; + +public class GZUpCall implements IMessageContent { + + /** + * 手机号 + */ + private String PhoneNumber; + /** + * 通话类型 1 CallOut 0 CallIn + */ + private int CallFlag;// + /** + * 通话时间 + */ + private String DateTime ; + /** + * 通话时长 + */ + private int Duration; + + + public String getPhoneNumber() { + return PhoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + PhoneNumber = phoneNumber; + } + + public int getCallFlag() { + return CallFlag; + } + + public void setCallFlag(int callFlag) { + CallFlag = callFlag; + } + + public String getDateTime() { + return DateTime; + } + + public void setDateTime(String dateTime) { + DateTime = dateTime; + } + + public int getDuration() { + return Duration; + } + + public void setDuration(int duration) { + Duration = duration; + } + + @Override + public IMessageContent create(byte[] bytes) { + return null; + } + + @Override + public int getTag() { + return 0x21; + } + + @Override + public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) { + + + return new byte[0]; + } + + @Override + public byte[] toBytes() { + + + + return new byte[0]; + } +} diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java new file mode 100644 index 0000000..98ce5d3 --- /dev/null +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java @@ -0,0 +1,40 @@ +package com.ssjl.zhaobiao.guizhou.entity.IOT; + +public class IOTCall { + private String PhoneNumber; + private int CallFlag;//1 CallOut 0 CallIn + private String DateTime ; + private int Duration; + + public String getPhoneNumber() { + return PhoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + PhoneNumber = phoneNumber; + } + + public int getCallFlag() { + return CallFlag; + } + + public void setCallFlag(int callFlag) { + CallFlag = callFlag; + } + + public String getDateTime() { + return DateTime; + } + + public void setDateTime(String dateTime) { + DateTime = dateTime; + } + + public int getDuration() { + return Duration; + } + + public void setDuration(int duration) { + Duration = duration; + } +} From dfe3beb25d0ca6402282012dafa98639476ac139 Mon Sep 17 00:00:00 2001 From: yangl <284428564@QQ.com> Date: Thu, 14 Jan 2021 19:18:00 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E8=AF=9D=E5=8D=95=E7=AC=AC=E4=BA=8C?= =?UTF-8?q?=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guizhou/controller/IotController.java | 28 +++++++++++++ .../guizhou/entity/GZMessage/GZUpCall.java | 35 ++++++++++++++--- .../guizhou/CenterApplicationTests.java | 39 +++++++++++++++++++ 3 files changed, 96 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java b/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java index 173df35..5766a6d 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java @@ -300,4 +300,32 @@ public class IotController { List interval = GZLocationInterval.build(locationInterval); return GZLocationInterval.isIn(LocalDateTime.now(), interval); } + + + @RequestMapping("/call") + public String callHandle(@RequestBody IOTCall call, String imei) throws IOException { + + if(!checkImei(imei, "/call", JSON.toJSONString(call))){ + log.info(imei + ",wifi not in device"); + return "not in device"; + } + DianxinGzDeviceConfig gzDeviceConfig = dianxinGzDeviceConfigMapper.selectByImei(imei); + if(!isAtLocationTime(gzDeviceConfig.getLocationInterval())){ + log.info(imei + ",wifi not in time"); + return "not in time"; + } + log.info(imei + ",call ,v=" + JSON.toJSONString(call)); + GZUpCall calls=new GZUpCall(); + calls.setPhoneNumber(call.getPhoneNumber()); + calls.setDateTime(call.getDateTime()); + calls.setCallFlag(call.getCallFlag()); + call.setDuration(call.getDuration()); + byte[] res = httpUtil.send(imei, gzDeviceConfig.getPhone(), calls); + System.out.println(ByteUtil.bytesToHexString(res)); + log.info(imei + ",call 电信返回:" + ByteUtil.bytesToHexString(res)); + return "success"; + } + + + } diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java index bac19db..837f068 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java @@ -2,6 +2,8 @@ package com.ssjl.zhaobiao.guizhou.entity.GZMessage; import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus; import com.ssjl.zhaobiao.guizhou.entity.IMessageContent; +import com.ssjl.zhaobiao.guizhou.utils.ByteUtil; +import com.ssjl.zhaobiao.guizhou.utils.GZUtil; public class GZUpCall implements IMessageContent { @@ -67,16 +69,37 @@ public class GZUpCall implements IMessageContent { @Override public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) { - - return new byte[0]; } @Override public byte[] toBytes() { - - - - return new byte[0]; + byte[] list = new byte[18]; + int i=0; + list[i++] = (byte)getTag(); + byte[] phone=GZUtil.phoneToByte(PhoneNumber); + System.arraycopy(phone, 0, list, i, phone.length); + i+=phone.length; + if(CallFlag==1&&Duration>0){ + list[i++] = (byte)0x00; + } + else if(CallFlag==1&&Duration==0){ + list[i++] = (byte)0x01; + } + else if(CallFlag==0&&Duration>0){ + list[i++] = (byte)0x02; + } + else if(CallFlag==0&&Duration==0){ + list[i++] = (byte)0x03; + } + else { + list[i++] = (byte)0x04; + } + byte[] duration= ByteUtil.toByte(Duration, 2); + System.arraycopy(duration, 0, list, i, duration.length); + i+=duration.length; + byte[] time=ByteUtil.hexToByteArray(DateTime); + System.arraycopy(time, 0, list, i, time.length); + return list; } } diff --git a/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java b/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java index b4763e8..7dd4747 100644 --- a/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java +++ b/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java @@ -197,4 +197,43 @@ class CenterApplicationTests { System.out.println(in); } + @Test + public void test4(){ + int tag=0x21; + String PhoneNumber="13439301795"; + int CallFlag=1; + int Duration=30; + String DateTime="2101141805"; + + //1 CallOut 0 CallIn + + byte[] list = new byte[18]; + int i=0; + list[i++] = (byte)tag; + byte[] phone=GZUtil.phoneToByte(PhoneNumber); + System.arraycopy(phone, 0, list, i, phone.length); + i+=phone.length; + if(CallFlag==1&&Duration>0){ + list[i++] = (byte)0x00; + } + else if(CallFlag==1&&Duration==0){ + list[i++] = (byte)0x01; + } + else if(CallFlag==0&&Duration>0){ + list[i++] = (byte)0x02; + } + else if(CallFlag==0&&Duration==0){ + list[i++] = (byte)0x03; + } + else { + list[i++] = (byte)0x04; + } + byte[] duration= ByteUtil.toByte(Duration, 2); + System.arraycopy(duration, 0, list, i, duration.length); + i+=duration.length; + byte[] time=ByteUtil.hexToByteArray(DateTime); + System.arraycopy(time, 0, list, i, time.length); + System.out.println(ByteUtil.bytesToHexString(list)); + } + } From f1f0537b1c165f10cfb16d03559d3d1364436b3d Mon Sep 17 00:00:00 2001 From: bin Date: Thu, 14 Jan 2021 19:49:24 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=80=9A=E8=AE=AF?= =?UTF-8?q?=E5=BD=95=E3=80=81SOS=E3=80=81=E4=BF=AE=E6=94=B9=E5=BC=80?= =?UTF-8?q?=E6=9C=BA=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guizhou/controller/IotController.java | 17 +++- .../guizhou/handle/GZResponseHandle.java | 18 ++-- .../guizhou/quartz/job/GZHeartJob.java | 2 +- .../guizhou/quartz/job/GZSyncSetting.java | 2 +- .../guizhou/service/IGZPlatformService.java | 2 +- .../service/impl/GZPlatformCmdService.java | 14 +-- .../impl/GZPlatformSettingService.java | 97 ++++++++++++++----- .../ssjl/zhaobiao/guizhou/utils/GZUtil.java | 10 +- src/main/resources/application.properties | 3 +- 9 files changed, 110 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java b/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java index 173df35..2511378 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java @@ -98,13 +98,22 @@ public class IotController { byte[] nid = { 0x36, 0x14}; cdma.setNID(nid); + int power = 50; + GpsDeviceStatus gpsDeviceStatus = gpsDeviceStatusMapper.selectByImei(imei); + if(gpsDeviceStatus != null){ + String statusStr = gpsDeviceStatus.getDeviceStatus(); + IOTDeviceStatus status = IOTDeviceStatus.build(statusStr); + power = status.getBattery(); + } + GZDeviceStatus deviceStatus = new GZDeviceStatus(); deviceStatus.setOpenFirst(true); GZDevicePower devicePower = new GZDevicePower(); devicePower.setCharge(false); - devicePower.setPower(10); - GZAskLocation askLocation = new GZAskLocation(imei, 0,0,0,1,0,0, - 0,0,0,0, deviceStatus, devicePower, 0, 0, true, extend); + devicePower.setPower(power); + LocalDateTime time = LocalDateTime.now(); + GZAskLocation askLocation = new GZAskLocation(imei, time.getHour(),time.getMinute(),time.getSecond(),time.getDayOfMonth(),15976140,0, + 63968668,0,0,0, deviceStatus, devicePower, 0, 0, true, extend); GZRequest req = new GZRequest(); req.setImei(imei); @@ -123,7 +132,7 @@ public class IotController { System.out.println(JSON.toJSONString(rs)); log.info(imei + "激活返回:" + JSON.toJSONString(rs)); // 处理电信返回数据 - res = (byte[]) responseHandle.process(res); + res = (byte[]) responseHandle.process(imei, res); System.out.println(ByteUtil.bytesToHexString(res)); log.info(imei + "电信返回:" + ByteUtil.bytesToHexString(res)); return "success"; diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZResponseHandle.java b/src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZResponseHandle.java index 3b41500..0c7064a 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZResponseHandle.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZResponseHandle.java @@ -20,7 +20,7 @@ public class GZResponseHandle { @Autowired GZHttpUtil gzHttpUtil; - public Object process(byte[] res) throws IOException { + public Object process(String sourceImei, byte[] res) throws IOException { if(res[1] == 0xFF){ // 常规应答 @@ -39,9 +39,10 @@ public class GZResponseHandle { String deviceFlag = GZUtil.byteToDeviceFlag(imeiBytes); GZDeviceFlagType flagType = GZDeviceFlagType.IMEI; String[] flags = deviceFlag.split(","); - if(flags.length > 1){ + String phone = ""; + if(flags.length > 1 && flags[1].equals("phone")){ deviceFlag = flags[0]; - flagType = flags[1].equals("phone") ? GZDeviceFlagType.PHONE : GZDeviceFlagType.IMEI; + phone = flags[0]; } // 消息序列号 @@ -57,18 +58,13 @@ public class GZResponseHandle { IGZPlatformService service = serviceFactory.getService(msgType); Object serviceRs = new byte[0]; if(service != null){ - serviceRs = service.process(content, deviceFlag, flagType, msgIndex, status); + serviceRs = service.process(content, sourceImei, phone, msgIndex, status); } // 应答 GZResponse gzRs = new GZResponse(); gzRs.setIndex(msgIndex); - if(flagType == GZDeviceFlagType.PHONE){ - gzRs.setPhone(deviceFlag); - gzRs.setImei(""); - }else{ - gzRs.setImei(deviceFlag); - gzRs.setPhone(""); - } + gzRs.setPhone(phone); + gzRs.setImei(sourceImei); gzRs.setErrorCode(GZResponseStatus.RECEIVE_SUCCESS); log.info("应答报文:" + ByteUtil.bytesToHexString(gzRs.toBytes())); byte[] responseRs = gzHttpUtil.send(gzRs.getImei(), gzRs.getPhone(), gzRs); diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZHeartJob.java b/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZHeartJob.java index a01aa45..d4105e0 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZHeartJob.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZHeartJob.java @@ -53,7 +53,7 @@ public class GZHeartJob extends QuartzJobBean { heart.setPower(power); GZDeviceStatus gzStatus = new GZDeviceStatus(); heart.setStatus(gzStatus); - heart.setSignalIntensity(50); + heart.setSignalIntensity(70); try { byte[] res = httpUtil.send(imei, phone, heart); // System.out.println(ByteUtil.bytesToHexString(res)); diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZSyncSetting.java b/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZSyncSetting.java index b90a6bf..572c20e 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZSyncSetting.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZSyncSetting.java @@ -39,7 +39,7 @@ public class GZSyncSetting extends QuartzJobBean { try { byte[] res = httpUtil.send(device.getImei(), device.getPhone(), askSetting); // System.out.println(ByteUtil.bytesToHexString(res)); - res = (byte[]) responseHandle.process(res); + res = (byte[]) responseHandle.process(device.getImei(), res); // System.out.println(ByteUtil.bytesToHexString(res)); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformService.java b/src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformService.java index 9992d95..b9c2ad3 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformService.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformService.java @@ -8,5 +8,5 @@ import java.io.IOException; public interface IGZPlatformService { - Object process(IMessageContent msg, String deviceFlag, GZDeviceFlagType flagType, byte msgIndex, GZRequestStatus requestStatus) throws IOException; + Object process(IMessageContent msg, String imei, String phone, byte msgIndex, GZRequestStatus requestStatus) throws IOException; } diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformCmdService.java b/src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformCmdService.java index 52a2940..1c6874b 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformCmdService.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformCmdService.java @@ -1,5 +1,6 @@ package com.ssjl.zhaobiao.guizhou.service.impl; +import com.google.common.base.Strings; import com.ssjl.zhaobiao.guizhou.entity.*; import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZPlatformCmd; import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZUpDeviceConfig; @@ -35,7 +36,7 @@ public class GZPlatformCmdService implements IGZPlatformCmdService { private GZHttpUtil httpUtil; @Override - public Object process(IMessageContent msg, String deviceFlag, GZDeviceFlagType flagType, byte msgIndex, GZRequestStatus requestStatus) throws IOException { + public Object process(IMessageContent msg, String imei, String phone, byte msgIndex, GZRequestStatus requestStatus) throws IOException { GZPlatformCmd cmd = (GZPlatformCmd) msg; if(cmd.getUpLocation() != null){ // 上报位置信息 @@ -44,17 +45,16 @@ public class GZPlatformCmdService implements IGZPlatformCmdService { if(cmd.getUpSetting() != null){ // 上报设置参数 // 先查询参数 - DianxinGzDeviceConfig gzConfig = null; - if(flagType == GZDeviceFlagType.IMEI){ - gzConfig = gzDeviceConfigMapper.selectByImei(deviceFlag); + if(Strings.isNullOrEmpty(phone)){ + gzConfig = gzDeviceConfigMapper.selectByImei(imei); }else{ - gzConfig = gzDeviceConfigMapper.selectByPhone(deviceFlag); + gzConfig = gzDeviceConfigMapper.selectByPhone(phone); } if(gzConfig == null){ gzConfig = new DianxinGzDeviceConfig(); - gzConfig.setDeviceImei(flagType == GZDeviceFlagType.IMEI ? deviceFlag : ""); - gzConfig.setPhone(flagType == GZDeviceFlagType.PHONE ? deviceFlag : ""); + gzConfig.setDeviceImei(imei); + gzConfig.setPhone(phone); } GpsDeviceConfig dbConfig = configMapper.selectByPrimaryKey(gzConfig.getDeviceImei()); 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 3b687f5..5036161 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 @@ -1,6 +1,7 @@ package com.ssjl.zhaobiao.guizhou.service.impl; import com.alibaba.fastjson.JSON; +import com.google.common.base.Strings; import com.ssjl.zhaobiao.guizhou.entity.DianxinGzDeviceConfig; import com.ssjl.zhaobiao.guizhou.entity.GZDeviceFlagType; import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZLocationInterval; @@ -27,24 +28,21 @@ public class GZPlatformSettingService implements IGZPlatformSettingService { IOTApiUtil iotApiUtil; @Override - public Object process(IMessageContent msg, String deviceFlag, GZDeviceFlagType flagType, byte msgIndex, GZRequestStatus requestStatus) throws IOException { + public Object process(IMessageContent msg, String imei, String phone, byte msgIndex, GZRequestStatus requestStatus) throws IOException { GZPlatformDeviceConfig config = (GZPlatformDeviceConfig)msg; DianxinGzDeviceConfig dbConfig = null; - String imei = ""; boolean isUpdate = true; - if(flagType == GZDeviceFlagType.PHONE){ - dbConfig = configMapper.selectByPhone(deviceFlag); - - }else{ - dbConfig = configMapper.selectByImei(deviceFlag); - imei = deviceFlag; - } + dbConfig = configMapper.selectByImei(imei); +// if(!Strings.isNullOrEmpty(phone)){ +// dbConfig = configMapper.selectByPhone(phone); +// }else{ +// dbConfig = configMapper.selectByImei(imei); +// } if(dbConfig == null){ dbConfig = new DianxinGzDeviceConfig(); dbConfig.setDeviceImei(imei); + dbConfig.setPhone(phone); isUpdate = false; - }else{ - imei = dbConfig.getDeviceImei(); } boolean allSuccess = true; // 下发给iot接口 @@ -114,30 +112,76 @@ public class GZPlatformSettingService implements IGZPlatformSettingService { } } // 亲情号码 - if(dbConfig.getAffectionPhone() == null || !dbConfig.getAffectionPhone().equals(config.getAffectionPhone())){ + IotApiWhiteList whiteList = new IotApiWhiteList(); + whiteList.setSerialNo(imei); + if(dbConfig.getAffectionPhone() == null || !dbConfig.getAffectionPhone().equals(config.getAffectionPhone()) || + dbConfig.getAddressBook() == null || !dbConfig.getAddressBook().equals(config.getAddressBook())){ // if(true){ + // SOS + String sos = config.getSosPhone(); + if(!Strings.isNullOrEmpty(sos)){ + if(sos.indexOf("/") > -1){ + sos = sos.substring(0, sos.indexOf("/")); + } + for (int i = 0; i < whiteList.getWhiteList().size(); i++) { + IotApiWhiteList.IotApiWhiteListItem item = whiteList.getWhiteList().get(i); + if(item.getPhone().equals(sos)){ + item.setSos(1); + } + } + } + boolean hadSos = false; + boolean isSos = false; + String[] phones = config.getAffectionPhone().split(","); - IotApiWhiteList whiteList = new IotApiWhiteList(); - whiteList.setSerialNo(imei); + for (int i = 0; i < phones.length; i++) { - String phone = phones[i]; + String aphone = phones[i]; String relationship = ""; - if(phone.indexOf("/") > -1){ - String[] pstrs = phone.split("/"); - phone = pstrs[0]; + if(aphone.indexOf("/") > -1){ + String[] pstrs = aphone.split("/"); + aphone = pstrs[0]; relationship = UnicodeUtil.unicodeToCn(pstrs[1]); } - whiteList.addPhone(phone, relationship, String.valueOf(i + 1), i == 0 ? 1 : 0); + isSos = aphone.equals(sos); + hadSos = hadSos ? hadSos : isSos; + whiteList.addPhone(aphone, relationship , String.valueOf(i + 1), (isSos? 1 : 0)); } - IotApiResponse phoneRs = iotApiUtil.setWhiteList(whiteList); - System.out.println(JSON.toJSONString(phoneRs)); - if(checkOffline(phoneRs.getMessage())){ - allSuccess = false; + // 通讯录 + phones = config.getAddressBook().split(","); + for (int i = 0; i < phones.length; i++) { + String aphone = phones[i]; + String relationship = ""; + if(aphone.indexOf("/") > -1){ + String[] pstrs = aphone.split("/"); + aphone = pstrs[0]; + relationship = UnicodeUtil.unicodeToCn(pstrs[1]); + } + isSos = aphone.equals(sos); + hadSos = hadSos ? hadSos : isSos; + whiteList.addPhone(aphone, relationship, "", (isSos? 1 : 0)); } - } + // sos不在通讯录或亲情号码中,则另外加入白名单 + if(!hadSos){ + whiteList.addPhone(sos, "", "", 1); + } + if(whiteList.getWhiteList().size() > 0){ + IotApiResponse phoneRs = iotApiUtil.setWhiteList(whiteList); + System.out.println(JSON.toJSONString(phoneRs)); + if(checkOffline(phoneRs.getMessage())){ + allSuccess = false; + } + } + } + + + + + if(allSuccess){ // 存入数据库 + dbConfig.setDeviceImei(imei); dbConfig.setPhone(config.getDevicePhone()); dbConfig.setHttpIp(config.getHttpIp()); dbConfig.setHttpUrl(config.getHttpUrl()); @@ -161,9 +205,10 @@ public class GZPlatformSettingService implements IGZPlatformSettingService { dbConfig.setRfid(config.getRfid()); if(isUpdate){ configMapper.updateByPrimaryKey(dbConfig); - }else{ - configMapper.insert(dbConfig); } +// else{ +// configMapper.insert(dbConfig); +// } } return new byte[0]; diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZUtil.java b/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZUtil.java index 86d6666..c8f8a19 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZUtil.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZUtil.java @@ -172,14 +172,18 @@ public class GZUtil { String hex; if(phone.length() <= 15){ hex = phone + "F"; + while (hex .length() < 16){ + hex = hex + "F"; + } }else{ BigInteger num = new BigInteger(phone); hex = num.toString(16); hex += "E"; + while (hex .length() < 16){ + hex = "0" + hex; + } } - while (hex .length() < 16){ - hex = "0" + hex; - } + return ByteUtil.hexToByteArray(hex); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d8f6548..f6aa69e 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -50,7 +50,8 @@ guizhou.device.version=ACB_1001 #guizhou.device.version=TPE_0056 guizhou.http.url=http://202.105.147.30:24183 #\u5929\u6CE2 -guizhou.device.testList= [{ "imei": "862622050253671","phone": "18664272743" },{ "imei": "862622050253358","phone": "18038740596" },{ "imei": "800115470000678","phone": "13500259054" }] +#guizhou.device.testList= [{ "imei": "862622050253671","phone": "18664272743" },{ "imei": "862622050253358","phone": "18038740596" },{ "imei": "800115470000678","phone": "13500259054" }] +guizhou.device.testList= [{ "imei": "862622050253671","phone": "" }] #\u667A\u4E2D #guizhou.device.testList= [{ "imei": "862622050654340","phone": "18985521203" },{ "imei": "862622050317740","phone": "18985521202" }] #\u5C55\u80FD From f737bbaebc599302189a26950e6104919709e359 Mon Sep 17 00:00:00 2001 From: yangl <284428564@QQ.com> Date: Thu, 14 Jan 2021 19:50:10 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E8=AF=9D=E5=8D=95=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guizhou/controller/IotController.java | 5 +-- .../guizhou/entity/GZMessage/GZUpCall.java | 38 +++++++++---------- .../zhaobiao/guizhou/entity/IOT/IOTCall.java | 24 ++++++------ 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java b/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java index 5766a6d..d46fb33 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java @@ -310,10 +310,7 @@ public class IotController { return "not in device"; } DianxinGzDeviceConfig gzDeviceConfig = dianxinGzDeviceConfigMapper.selectByImei(imei); - if(!isAtLocationTime(gzDeviceConfig.getLocationInterval())){ - log.info(imei + ",wifi not in time"); - return "not in time"; - } + log.info(imei + ",call ,v=" + JSON.toJSONString(call)); GZUpCall calls=new GZUpCall(); calls.setPhoneNumber(call.getPhoneNumber()); diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java index 837f068..2b43abb 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java @@ -10,51 +10,51 @@ public class GZUpCall implements IMessageContent { /** * 手机号 */ - private String PhoneNumber; + private String phoneNumber; /** * 通话类型 1 CallOut 0 CallIn */ - private int CallFlag;// + private int callFlag;// /** * 通话时间 */ - private String DateTime ; + private String dateTime; /** * 通话时长 */ - private int Duration; + private int duration; public String getPhoneNumber() { - return PhoneNumber; + return phoneNumber; } public void setPhoneNumber(String phoneNumber) { - PhoneNumber = phoneNumber; + this.phoneNumber = phoneNumber; } public int getCallFlag() { - return CallFlag; + return callFlag; } public void setCallFlag(int callFlag) { - CallFlag = callFlag; + this.callFlag = callFlag; } public String getDateTime() { - return DateTime; + return dateTime; } public void setDateTime(String dateTime) { - DateTime = dateTime; + this.dateTime = dateTime; } public int getDuration() { - return Duration; + return duration; } public void setDuration(int duration) { - Duration = duration; + this.duration = duration; } @Override @@ -77,28 +77,28 @@ public class GZUpCall implements IMessageContent { byte[] list = new byte[18]; int i=0; list[i++] = (byte)getTag(); - byte[] phone=GZUtil.phoneToByte(PhoneNumber); + byte[] phone=GZUtil.phoneToByte(phoneNumber); System.arraycopy(phone, 0, list, i, phone.length); i+=phone.length; - if(CallFlag==1&&Duration>0){ + if(callFlag ==1&& duration >0){ list[i++] = (byte)0x00; } - else if(CallFlag==1&&Duration==0){ + else if(callFlag ==1&& duration ==0){ list[i++] = (byte)0x01; } - else if(CallFlag==0&&Duration>0){ + else if(callFlag ==0&& duration >0){ list[i++] = (byte)0x02; } - else if(CallFlag==0&&Duration==0){ + else if(callFlag ==0&& duration ==0){ list[i++] = (byte)0x03; } else { list[i++] = (byte)0x04; } - byte[] duration= ByteUtil.toByte(Duration, 2); + byte[] duration= ByteUtil.toByte(this.duration, 2); System.arraycopy(duration, 0, list, i, duration.length); i+=duration.length; - byte[] time=ByteUtil.hexToByteArray(DateTime); + byte[] time=ByteUtil.hexToByteArray(dateTime); System.arraycopy(time, 0, list, i, time.length); return list; } diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java index 98ce5d3..99c3f30 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java @@ -1,40 +1,40 @@ package com.ssjl.zhaobiao.guizhou.entity.IOT; public class IOTCall { - private String PhoneNumber; - private int CallFlag;//1 CallOut 0 CallIn - private String DateTime ; - private int Duration; + private String phoneNumber; + private int callFlag;//1 CallOut 0 CallIn + private String dateTime; + private int duration; public String getPhoneNumber() { - return PhoneNumber; + return phoneNumber; } public void setPhoneNumber(String phoneNumber) { - PhoneNumber = phoneNumber; + this.phoneNumber = phoneNumber; } public int getCallFlag() { - return CallFlag; + return callFlag; } public void setCallFlag(int callFlag) { - CallFlag = callFlag; + this.callFlag = callFlag; } public String getDateTime() { - return DateTime; + return dateTime; } public void setDateTime(String dateTime) { - DateTime = dateTime; + this.dateTime = dateTime; } public int getDuration() { - return Duration; + return duration; } public void setDuration(int duration) { - Duration = duration; + this.duration = duration; } } From 81ccb98a5d9106c7d93c61bf8ed348a92cb2d908 Mon Sep 17 00:00:00 2001 From: bin Date: Thu, 14 Jan 2021 19:59:22 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-pro1.properties | 2 +- src/main/resources/application-pro2.properties | 2 +- src/main/resources/application-pro3.properties | 2 +- src/main/resources/application.properties | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/application-pro1.properties b/src/main/resources/application-pro1.properties index 3da7080..24fde57 100644 --- a/src/main/resources/application-pro1.properties +++ b/src/main/resources/application-pro1.properties @@ -49,7 +49,7 @@ guizhou.device.version=ACB_1001 #guizhou.device.model=TPE390 #guizhou.device.version=TPE_0056 guizhou.http.url=http://202.105.147.30:24183 -guizhou.device.testList= [{ "imei": "862622050253671","phone": "18664272743" },{ "imei": "862622050253358","phone": "" },{ "imei": "800115470000678","phone": "13500259054" }] +guizhou.device.testList= [{ "imei": "862622050253671","phone": "" },{ "imei": "862622050253358","phone": "" },{ "imei": "800115470000678","phone": "" }] guizhou.device.zhizhong=862622050654340,862622050317740 guizhou.device.zhanneng=862622050925104,862622050927027 guizhou.device.tianbo=862622050253671,862622050253358,800115470000678 diff --git a/src/main/resources/application-pro2.properties b/src/main/resources/application-pro2.properties index 99e0fea..9a9bbd8 100644 --- a/src/main/resources/application-pro2.properties +++ b/src/main/resources/application-pro2.properties @@ -49,7 +49,7 @@ guizhou.factory=zhanneng guizhou.device.model=TPE390 guizhou.device.version=TPE_0056 guizhou.http.url=http://202.105.147.30:24183 -guizhou.device.testList= [{ "imei": "862622050253671","phone": "18664272743" },{ "imei": "862622050253358","phone": "" },{ "imei": "800115470000678","phone": "13500259054" }] +guizhou.device.testList= [{ "imei": "862622050925104","phone": "" },{ "imei": "862622050927027","phone": "" }] guizhou.device.zhizhong=862622050654340,862622050317740 guizhou.device.zhanneng=862622050925104,862622050927027 guizhou.device.tianbo=862622050253671,862622050253358,800115470000678 diff --git a/src/main/resources/application-pro3.properties b/src/main/resources/application-pro3.properties index a3cb65b..d4785c3 100644 --- a/src/main/resources/application-pro3.properties +++ b/src/main/resources/application-pro3.properties @@ -49,7 +49,7 @@ guizhou.device.version=RZL_2021 #guizhou.device.model=TPE390 #guizhou.device.version=TPE_0056 guizhou.http.url=http://202.105.147.30:24183 -guizhou.device.testList= [{ "imei": "862622050253671","phone": "18664272743" },{ "imei": "862622050253358","phone": "" },{ "imei": "800115470000678","phone": "13500259054" }] +guizhou.device.testList= [{ "imei": "862622050654340","phone": "" },{ "imei": "862622050317740","phone": "" }] guizhou.device.zhizhong=862622050654340,862622050317740 guizhou.device.zhanneng=862622050925104,862622050927027 guizhou.device.tianbo=862622050253671,862622050253358,800115470000678 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f6aa69e..c879574 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -50,12 +50,12 @@ guizhou.device.version=ACB_1001 #guizhou.device.version=TPE_0056 guizhou.http.url=http://202.105.147.30:24183 #\u5929\u6CE2 -#guizhou.device.testList= [{ "imei": "862622050253671","phone": "18664272743" },{ "imei": "862622050253358","phone": "18038740596" },{ "imei": "800115470000678","phone": "13500259054" }] +#guizhou.device.testList= [{ "imei": "862622050253671","phone": "" },{ "imei": "862622050253358","phone": "" },{ "imei": "800115470000678","phone": "" }] guizhou.device.testList= [{ "imei": "862622050253671","phone": "" }] #\u667A\u4E2D -#guizhou.device.testList= [{ "imei": "862622050654340","phone": "18985521203" },{ "imei": "862622050317740","phone": "18985521202" }] +#guizhou.device.testList= [{ "imei": "862622050654340","phone": "" },{ "imei": "862622050317740","phone": "" }] #\u5C55\u80FD -#guizhou.device.testList= [{ "imei": "862622050927027","phone": "19185301203" },{ "imei": "862622050925104","phone": "" }] +#guizhou.device.testList= [{ "imei": "862622050927027","phone": "" },{ "imei": "862622050925104","phone": "" }] guizhou.device.zhizhong=862622050654340,862622050317740 guizhou.device.zhanneng=862622050925104,862622050927027