Преглед изворни кода

话单第二次提交

master
杨雷 пре 3 година
родитељ
комит
dfe3beb25d
3 измењених фајлова са 96 додато и 6 уклоњено
  1. +28
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java
  2. +29
    -6
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpCall.java
  3. +39
    -0
      src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java

+ 28
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java Прегледај датотеку

@@ -300,4 +300,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";
}



}

+ 29
- 6
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;
}
}

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

}

Loading…
Откажи
Сачувај