bin 3年前
コミット
b010ee5a60
4個のファイルの変更212行の追加0行の削除
  1. +28
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java
  2. +105
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java
  3. +40
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTCall.java
  4. +39
    -0
      src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java

+ 28
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java ファイルの表示

@@ -309,4 +309,32 @@ 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);
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";
}



}

+ 105
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java ファイルの表示

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

+ 40
- 0
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;
}
}

+ 39
- 0
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));
}

}

読み込み中…
キャンセル
保存