Ver código fonte

Merge remote-tracking branch 'origin/develop' into develop

develop
林万龙 3 anos atrás
pai
commit
3f0b302861
18 arquivos alterados com 413 adições e 58 exclusões
  1. +1
    -0
      Dockerfile
  2. +39
    -4
      src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java
  3. +105
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java
  4. +38
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZResponse.java
  5. +40
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java
  6. +22
    -8
      src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZResponseHandle.java
  7. +1
    -1
      src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZHeartJob.java
  8. +1
    -1
      src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZSyncSetting.java
  9. +1
    -1
      src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformService.java
  10. +7
    -7
      src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformCmdService.java
  11. +71
    -26
      src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformSettingService.java
  12. +13
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java
  13. +18
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZUtil.java
  14. +1
    -1
      src/main/resources/application-pro1.properties
  15. +1
    -1
      src/main/resources/application-pro2.properties
  16. +1
    -1
      src/main/resources/application-pro3.properties
  17. +14
    -7
      src/main/resources/application.properties
  18. +39
    -0
      src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java

+ 1
- 0
Dockerfile Ver arquivo

@@ -1,4 +1,5 @@
FROM java:8

MAINTAINER king <1609724385@qq.com>
EXPOSE 8102
VOLUME /tmp


+ 39
- 4
src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java Ver arquivo

@@ -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);
@@ -113,6 +122,7 @@ public class IotController {
req.setContent(askLocation);
byte[] res = httpUtil.send(imei, "", req);
System.out.println(ByteUtil.bytesToHexString(res));

// 调用IOTAPI激活设备
log.info(imei + "激活设备");
IotApiActiveDevice active = new IotApiActiveDevice();
@@ -122,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";
@@ -299,4 +309,29 @@ public class IotController {
List<GZLocationInterval> 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);

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";
}



}

+ 105
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java Ver arquivo

@@ -0,0 +1,105 @@
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 {

/**
* 手机号
*/
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) {
this.phoneNumber = phoneNumber;
}

public int getCallFlag() {
return callFlag;
}

public void setCallFlag(int callFlag) {
this.callFlag = callFlag;
}

public String getDateTime() {
return dateTime;
}

public void setDateTime(String dateTime) {
this.dateTime = dateTime;
}

public int getDuration() {
return duration;
}

public void setDuration(int duration) {
this.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() {
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(this.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;
}
}

+ 38
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZResponse.java Ver arquivo

@@ -1,5 +1,10 @@
package com.ssjl.zhaobiao.guizhou.entity;

import com.google.common.base.Strings;
import com.ssjl.zhaobiao.guizhou.utils.GZUtil;

import java.util.Arrays;

public class GZResponse {

private byte tag;
@@ -14,11 +19,23 @@ public class GZResponse {

private byte check;

private String phone;



public GZResponse(){
tag = (byte)0x7E;
flag = (byte)0xFF;
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

public String getImei() {
return imei;
}
@@ -42,4 +59,25 @@ public class GZResponse {
public void setErrorCode(GZResponseStatus errorCode) {
this.errorCode = errorCode;
}

public byte[] toBytes(){
byte[] list = new byte[14];
int i = 0;
list[i++] = tag;
list[i++] = flag;
byte[] bytes;
if(Strings.isNullOrEmpty(imei)){
bytes = GZUtil.imeiToByte(phone);
}else{
bytes = GZUtil.imeiToByte(imei);
}
System.arraycopy(bytes, 0, list, i, bytes.length);
i += bytes.length;
list[i++] = (byte)index;
list[i++] = (byte)errorCode.getCode();
list[i++] = GZUtil.check(Arrays.copyOfRange(list, 1, 12));
list[i++] = tag;
return list;
}

}

+ 40
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java Ver arquivo

@@ -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) {
this.phoneNumber = phoneNumber;
}

public int getCallFlag() {
return callFlag;
}

public void setCallFlag(int callFlag) {
this.callFlag = callFlag;
}

public String getDateTime() {
return dateTime;
}

public void setDateTime(String dateTime) {
this.dateTime = dateTime;
}

public int getDuration() {
return duration;
}

public void setDuration(int duration) {
this.duration = duration;
}
}

+ 22
- 8
src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZResponseHandle.java Ver arquivo

@@ -1,23 +1,26 @@
package com.ssjl.zhaobiao.guizhou.handle;

import com.ssjl.zhaobiao.guizhou.entity.GZDeviceFlagType;
import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;
import com.ssjl.zhaobiao.guizhou.entity.*;
import com.ssjl.zhaobiao.guizhou.service.IGZPlatformService;
import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZHttpUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZUtil;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Slf4j
@Component
public class GZResponseHandle {
@Autowired
GZServiceFactory serviceFactory;
@Autowired
GZHttpUtil gzHttpUtil;

public Object process(byte[] res) throws IOException {
public Object process(String sourceImei, byte[] res) throws IOException {
if(res[1] == 0xFF){
// 常规应答

@@ -36,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];
}

// 消息序列号
@@ -52,10 +56,20 @@ public class GZResponseHandle {
System.arraycopy(res, 14, msgBytes, 0, msgBytes.length);
IMessageContent content = GZMessageContentFactory.build(msgType, msgBytes);
IGZPlatformService service = serviceFactory.getService(msgType);
Object serviceRs = new byte[0];
if(service != null){
return service.process(content, deviceFlag, flagType, msgIndex, status);
serviceRs = service.process(content, sourceImei, phone, msgIndex, status);
}
return new byte[0];
// 应答
GZResponse gzRs = new GZResponse();
gzRs.setIndex(msgIndex);
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);
log.info("应答回复:" + ByteUtil.bytesToHexString(responseRs));
return serviceRs;
// byte[] result = content.process(deviceFlag, flagType, msgIndex, status);

}


+ 1
- 1
src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZHeartJob.java Ver arquivo

@@ -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));


+ 1
- 1
src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZSyncSetting.java Ver arquivo

@@ -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();


+ 1
- 1
src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformService.java Ver arquivo

@@ -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;
}

+ 7
- 7
src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformCmdService.java Ver arquivo

@@ -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());



+ 71
- 26
src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformSettingService.java Ver arquivo

@@ -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];


+ 13
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java Ver arquivo

@@ -2,6 +2,7 @@ package com.ssjl.zhaobiao.guizhou.utils;

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 okhttp3.Headers;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,4 +38,16 @@ public class GZHttpUtil {
req.setStatus(GZRequestStatus.RESPONSE_ALL);
return send(imei, phone, req);
}

public byte[] send(String imei, String phone, GZResponse req) throws IOException {
Headers headers = new Headers.Builder().add("meid-id", imei).add("imsi-id", phone).build();
byte[] b = req.toBytes();
try {
byte[] res = httpUtil.postBytes(url, b, headers);
return res;
} catch (IOException e) {
e.printStackTrace();
throw e;
}
}
}

+ 18
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZUtil.java Ver arquivo

@@ -168,6 +168,24 @@ public class GZUtil {
}
return ByteUtil.hexToByteArray(hex);
}
public static byte[] phoneToByte(String phone){
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;
}
}

return ByteUtil.hexToByteArray(hex);
}

/**
* 获得终端号码,可能是手机号,也可能是IMEI


+ 1
- 1
src/main/resources/application-pro1.properties Ver arquivo

@@ -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


+ 1
- 1
src/main/resources/application-pro2.properties Ver arquivo

@@ -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


+ 1
- 1
src/main/resources/application-pro3.properties Ver arquivo

@@ -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


+ 14
- 7
src/main/resources/application.properties Ver arquivo

@@ -39,17 +39,24 @@ 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
guizhou.device.testList= [{ "imei": "862622050253671","phone": "18664272743" },{ "imei": "862622050253358","phone": "" },{ "imei": "800115470000678","phone": "13500259054" }]
#\u5929\u6CE2
#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": "" },{ "imei": "862622050317740","phone": "" }]
#\u5C55\u80FD
#guizhou.device.testList= [{ "imei": "862622050927027","phone": "" },{ "imei": "862622050925104","phone": "" }]

guizhou.device.zhizhong=862622050654340,862622050317740
guizhou.device.zhanneng=862622050925104,862622050927027
guizhou.device.tianbo=862622050253671,862622050253358,800115470000678


+ 39
- 0
src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java Ver arquivo

@@ -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));
}

}

Carregando…
Cancelar
Salvar