1078-设置电话本+电话回拨

This commit is contained in:
648540858
2024-05-02 05:21:50 +08:00
parent 16bc3dabd6
commit 734f0c7e04
8 changed files with 305 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
package com.genersoft.iot.vmp.jt1078.bean;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.swagger.v3.oas.annotations.media.Schema;
import java.nio.charset.Charset;
@Schema(description = "电话本联系人")
public class JTPhoneBookContact {
@Schema(description = "1:呼入,2:呼出,3:呼入/呼出")
private int sign;
@Schema(description = "电话号码")
private String phoneNumber;
@Schema(description = "联系人")
private String contactName;
public ByteBuf encode(){
ByteBuf buffer = Unpooled.buffer();
buffer.writeByte(sign);
buffer.writeByte(phoneNumber.getBytes().length);
buffer.writeCharSequence(phoneNumber, Charset.forName("GBK"));
buffer.writeByte(contactName.getBytes().length);
buffer.writeCharSequence(contactName, Charset.forName("GBK"));
return buffer;
}
public int getSign() {
return sign;
}
public void setSign(int sign) {
this.sign = sign;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getContactName() {
return contactName;
}
public void setContactName(String contactName) {
this.contactName = contactName;
}
@Override
public String toString() {
return "JTPhoneBookContact{" +
"sign=" + sign +
", phoneNumber='" + phoneNumber + '\'' +
", contactName='" + contactName + '\'' +
'}';
}
}

View File

@@ -27,6 +27,8 @@ public class JT1078Template {
private static final String H8203 = "8203";
private static final String H8204 = "8204";
private static final String H8300 = "8300";
private static final String H8400 = "8400";
private static final String H8401 = "8401";
private static final String H9101 = "9101";
private static final String H9102 = "9102";
private static final String H9201 = "9201";
@@ -408,4 +410,26 @@ public class JT1078Template {
.build();
return SessionManager.INSTANCE.request(cmd, timeOut);
}
public Object telephoneCallback(String devId, J8400 j8400, int timeOut) {
Cmd cmd = new Cmd.Builder()
.setDevId(devId)
.setPackageNo(randomInt())
.setMsgId(H8400)
.setRespId(H0001)
.setRs(j8400)
.build();
return SessionManager.INSTANCE.request(cmd, timeOut);
}
public Object setPhoneBook(String devId, J8401 j8401, int timeOut) {
Cmd cmd = new Cmd.Builder()
.setDevId(devId)
.setPackageNo(randomInt())
.setMsgId(H8401)
.setRespId(H0001)
.setRs(j8401)
.build();
return SessionManager.INSTANCE.request(cmd, timeOut);
}
}

View File

@@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.jt1078.bean.*;
import com.genersoft.iot.vmp.jt1078.controller.bean.ConfirmationAlarmMessageParam;
import com.genersoft.iot.vmp.jt1078.controller.bean.ConnectionControlParam;
import com.genersoft.iot.vmp.jt1078.controller.bean.SetPhoneBookParam;
import com.genersoft.iot.vmp.jt1078.controller.bean.TextMessageParam;
import com.genersoft.iot.vmp.jt1078.proc.request.J1205;
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
@@ -431,5 +432,39 @@ public class JT1078Controller {
}
}
@Operation(summary = "电话回拨", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备编号", required = true)
@Parameter(name = "sign", description = "标志: 0:普通通话,1:监听", required = true)
@Parameter(name = "phoneNumber", description = "电话号码", required = true)
@GetMapping("/telephone-callback")
public WVPResult<Integer> telephoneCallback(String deviceId, Integer sign, String phoneNumber){
logger.info("[1078-电话回拨] deviceId: {}, sign: {}, phoneNumber: {},", deviceId, sign, phoneNumber);
int result = service.telephoneCallback(deviceId, sign, phoneNumber);
if (result == 0) {
return WVPResult.success(result);
}else {
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
fail.setData(result);
return fail;
}
}
@Operation(summary = "设置电话本", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "setPhoneBookParam", description = "设置电话本参数", required = true)
@PostMapping("/set-phone-book")
public WVPResult<Integer> setPhoneBook(@RequestBody SetPhoneBookParam setPhoneBookParam){
logger.info("[1078-设置电话本] setPhoneBookParam: {}", setPhoneBookParam);
int result = service.setPhoneBook(setPhoneBookParam.getDeviceId(), setPhoneBookParam.getType(), setPhoneBookParam.getPhoneBookContactList());
if (result == 0) {
return WVPResult.success(result);
}else {
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
fail.setData(result);
return fail;
}
}
}

View File

@@ -0,0 +1,57 @@
package com.genersoft.iot.vmp.jt1078.controller.bean;
import com.genersoft.iot.vmp.jt1078.bean.JTPhoneBookContact;
import com.genersoft.iot.vmp.jt1078.bean.JTTextSign;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
@Schema(description = "设置电话本")
public class SetPhoneBookParam {
@Schema(description = "设备")
private String deviceId;
@Schema(description = "设置类型:\n" +
"0: 删除终端上所有存储的联系人,\n" +
"1: 表示更新电话本$ 删除终端中已有全部联系人并追加消 息中的联系人,\n" +
"2: 表示追加电话本,\n" +
"3: 表示修改电话本$以联系人为索引")
private int type;
@Schema(description = "联系人")
private List<JTPhoneBookContact> phoneBookContactList;
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public List<JTPhoneBookContact> getPhoneBookContactList() {
return phoneBookContactList;
}
public void setPhoneBookContactList(List<JTPhoneBookContact> phoneBookContactList) {
this.phoneBookContactList = phoneBookContactList;
}
@Override
public String toString() {
return "SetPhoneBookParam{" +
"deviceId='" + deviceId + '\'' +
", type=" + type +
", phoneBookContactList=" + phoneBookContactList +
'}';
}
}

View File

@@ -0,0 +1,49 @@
package com.genersoft.iot.vmp.jt1078.proc.response;
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
import com.genersoft.iot.vmp.jt1078.bean.JTTextSign;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.nio.charset.Charset;
/**
* 电话回拨
*/
@MsgId(id = "8400")
public class J8400 extends Rs {
/**
* 标志, 0'普通通话,1'监听
*/
private int sign;
/**
* 电话号码
*/
private String phoneNumber;
@Override
public ByteBuf encode() {
ByteBuf buffer = Unpooled.buffer();
buffer.writeByte(sign);
buffer.writeCharSequence(phoneNumber, Charset.forName("GBK"));
return buffer;
}
public int getSign() {
return sign;
}
public void setSign(int sign) {
this.sign = sign;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
}

View File

@@ -0,0 +1,57 @@
package com.genersoft.iot.vmp.jt1078.proc.response;
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
import com.genersoft.iot.vmp.jt1078.bean.JTPhoneBookContact;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.nio.charset.Charset;
import java.util.List;
/**
* 设置电话本
*/
@MsgId(id = "8401")
public class J8401 extends Rs {
/**
* 设置类型:
* 0: 删除终端上所有存储的联系人,
* 1: 表示更新电话本$ 删除终端中已有全部联系人并追加消 息中的联系人,
* 2: 表示追加电话本,
* 3: 表示修改电话本$以联系人为索引
*/
private int type;
/**
* 联系人
*/
private List<JTPhoneBookContact> phoneBookContactList;
@Override
public ByteBuf encode() {
ByteBuf buffer = Unpooled.buffer();
buffer.writeByte(type);
buffer.writeByte(phoneBookContactList.size());
for (JTPhoneBookContact jtPhoneBookContact : phoneBookContactList) {
buffer.writeBytes(jtPhoneBookContact.encode());
}
return buffer;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public List<JTPhoneBookContact> getPhoneBookContactList() {
return phoneBookContactList;
}
public void setPhoneBookContactList(List<JTPhoneBookContact> phoneBookContactList) {
this.phoneBookContactList = phoneBookContactList;
}
}

View File

@@ -63,4 +63,9 @@ public interface Ijt1078Service {
int linkDetection(String deviceId);
int textMessage(String deviceId,JTTextSign sign, int textType, String content);
int telephoneCallback(String deviceId, Integer sign, String phoneNumber);
int setPhoneBook(String deviceId, int type, List<JTPhoneBookContact> phoneBookContactList);
}

View File

@@ -583,4 +583,19 @@ public class jt1078ServiceImpl implements Ijt1078Service {
return (int)jt1078Template.textMessage(deviceId, j8300, 6);
}
@Override
public int telephoneCallback(String deviceId, Integer sign, String phoneNumber) {
J8400 j8400 = new J8400();
j8400.setSign(sign);
j8400.setPhoneNumber(phoneNumber);
return (int)jt1078Template.telephoneCallback(deviceId, j8400, 6);
}
@Override
public int setPhoneBook(String deviceId, int type, List<JTPhoneBookContact> phoneBookContactList) {
J8401 j8401 = new J8401();
j8401.setType(type);
j8401.setPhoneBookContactList(phoneBookContactList);
return (int)jt1078Template.setPhoneBook(deviceId, j8401, 6);
}
}