?? cmppsubmitmessage.java
字號:
package com.huawei.insa2.comm.cmpp.message;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.huawei.insa2.comm.cmpp.CMPPConstant;
import com.huawei.insa2.util.TypeConvert;
public class CMPPSubmitMessage extends CMPPMessage {
private String outStr;
public CMPPSubmitMessage(byte[] data_buff) {
int len = data_buff.length + 8;
super.buf = new byte[len];
TypeConvert.int2byte(len, super.buf, 0);
TypeConvert.int2byte(CMPPConstant.Submit_Command_Id, super.buf, 4);
System.arraycopy(data_buff, 0, super.buf, 8, data_buff.length);
super.sequence_Id = TypeConvert.byte2int(data_buff, 0);
}
/**
* CMPP_SUBMIT操作的目的是SP在與ISMG建立應用層連接后向ISMG提交短信。
*
* @param pk_Total
* 相同Msg_Id的信息總條數,從1開始
* @param pk_Number
* 相同Msg_Id的信息序號,從1開始
* @param registered_Delivery
* 是否要求返回狀態確認報告
* <ul>
* <li>0:不需要
* <li>1:需要
* <li>2:產生SMC話單(該類型短信僅供網關計費使用,不發送給目的終端)
* </ul>
* @param msg_Level
* 信息級別
* @param service_Id
* 業務類型,是數字、字母和符號的組合。
* @param fee_UserType
* 計費用戶類型字段
* <ul>
* <li>0:對目的終端MSISDN計費;
* <li>1:對源終端MSISDN計費;
* <li>2:對SP計費;
* <li>3:表示本字段無效,對誰計費參見Fee_terminal_Id字段。
* </ul>
* @param fee_Terminal_Id
* 被計費用戶的號碼(如本字節填空,則表示本字段無效,對誰計費參見Fee_UserType字段,本字段與Fee_UserType字段互斥)
* @param tp_Pid
* GSM協議類型。
* @param tp_Udhi
* GSM協議類型。詳細是解釋請參考GSM03.40中的9.2.3.23,僅使用1位,右對齊
* @param msg_Fmt
* 信息格式
* <ul>
* <li>0:ASCII串
* <li>3:短信寫卡操作
* <li>4:二進制信息
* <li>8:UCS2編碼
* <li>15:含GB漢字
* </ul>
* @param msg_Src
* 信息內容來源(SP_Id)
* @param fee_Type
* 資費類別
* <ul>
* <li>01:對“計費用戶號碼”免費
* <li>02:對“計費用戶號碼”按條計信息費
* <li>03:對“計費用戶號碼”按包月收取信息費
* <li>04:對“計費用戶號碼”的信息費封頂
* <li>05:對“計費用戶號碼”的收費是由SP實現
* </ul>
* @param fee_Code
* 資費代碼(以分為單位)
* @param valid_Time
* 存活有效期,格式遵循SMPP3.3協議
* @param at_Time
* 定時發送時間,格式遵循SMPP3.3協議
* @param src_Terminal_Id
* 源號碼。SP的服務代碼或前綴為服務代碼的長號碼,
* 網關將該號碼完整的填到SMPP協議Submit_SM消息相應的source_addr字段,該號碼最終在用戶手機上顯示為短消息的主叫號碼
* @param dest_Terminal_Id
* 接收短信的MSISDN號碼
* @param msg_Content
* 信息內容
* @param reserve
* 保留
* @throws IllegalArgumentException
*/
public CMPPSubmitMessage(int pk_Total, int pk_Number,
int registered_Delivery, int msg_Level, String service_Id,
int fee_UserType, String fee_Terminal_Id, int tp_Pid, int tp_Udhi,
int msg_Fmt, String msg_Src, String fee_Type, String fee_Code,
Date valid_Time, Date at_Time, String src_Terminal_Id,
String[] dest_Terminal_Id, byte[] msg_Content, String reserve)
throws IllegalArgumentException {
this(0, pk_Total, pk_Number, registered_Delivery, msg_Level,
service_Id, fee_UserType, fee_Terminal_Id, tp_Pid, tp_Udhi,
msg_Fmt, msg_Src, fee_Type, fee_Code, valid_Time, at_Time,
src_Terminal_Id, dest_Terminal_Id, msg_Content, reserve);
}
/**
* CMPP_SUBMIT操作的目的是SP在與ISMG建立應用層連接后向ISMG提交短信。
*
* @param msg_Id
* 信息標識,由SP側短信網關本身產生,本處填空。
* @param pk_Total
* 相同Msg_Id的信息總條數,從1開始
* @param pk_Number
* 相同Msg_Id的信息序號,從1開始
* @param registered_Delivery
* 是否要求返回狀態確認報告
* <ul>
* <li>0:不需要
* <li>1:需要
* <li>2:產生SMC話單(該類型短信僅供網關計費使用,不發送給目的終端)
* </ul>
* @param msg_Level
* 信息級別
* @param service_Id
* 業務類型,是數字、字母和符號的組合。
* @param fee_UserType
* 計費用戶類型字段
* <ul>
* <li>0:對目的終端MSISDN計費;
* <li>1:對源終端MSISDN計費;
* <li>2:對SP計費;
* <li>3:表示本字段無效,對誰計費參見Fee_terminal_Id字段。
* </ul>
* @param fee_Terminal_Id
* 被計費用戶的號碼(如本字節填空,則表示本字段無效,對誰計費參見Fee_UserType字段,本字段與Fee_UserType字段互斥)
* @param tp_Pid
* GSM協議類型。
* @param tp_Udhi
* GSM協議類型。詳細是解釋請參考GSM03.40中的9.2.3.23,僅使用1位,右對齊
* @param msg_Fmt
* 信息格式
* <ul>
* <li>0:ASCII串
* <li>3:短信寫卡操作
* <li>4:二進制信息
* <li>8:UCS2編碼
* <li>15:含GB漢字
* </ul>
* @param msg_Src
* 信息內容來源(SP_Id)
* @param fee_Type
* 資費類別
* <ul>
* <li>01:對“計費用戶號碼”免費
* <li>02:對“計費用戶號碼”按條計信息費
* <li>03:對“計費用戶號碼”按包月收取信息費
* <li>04:對“計費用戶號碼”的信息費封頂
* <li>05:對“計費用戶號碼”的收費是由SP實現
* </ul>
* @param fee_Code
* 資費代碼(以分為單位)
* @param valid_Time
* 存活有效期,格式遵循SMPP3.3協議
* @param at_Time
* 定時發送時間,格式遵循SMPP3.3協議
* @param src_Terminal_Id
* 源號碼。SP的服務代碼或前綴為服務代碼的長號碼,
* 網關將該號碼完整的填到SMPP協議Submit_SM消息相應的source_addr字段,該號碼最終在用戶手機上顯示為短消息的主叫號碼
* @param dest_Terminal_Id
* 接收短信的MSISDN號碼
* @param msg_Content
* 信息內容
* @param reserve
* 保留
* @throws IllegalArgumentException
*/
public CMPPSubmitMessage(long msg_Id, int pk_Total, int pk_Number,
int registered_Delivery, int msg_Level, String service_Id,
int fee_UserType, String fee_Terminal_Id, int tp_Pid, int tp_Udhi,
int msg_Fmt, String msg_Src, String fee_Type, String fee_Code,
Date valid_Time, Date at_Time, String src_Terminal_Id,
String[] dest_Terminal_Id, byte[] msg_Content, String reserve)
throws IllegalArgumentException {
validate(pk_Total, pk_Number, registered_Delivery, msg_Level,
service_Id, fee_UserType, fee_Terminal_Id, tp_Pid, tp_Udhi,
msg_Fmt, msg_Src, fee_Type, fee_Code, src_Terminal_Id,
dest_Terminal_Id, msg_Content, reserve);
int len = 138 + 21 * dest_Terminal_Id.length + msg_Content.length;
super.buf = new byte[len];
TypeConvert.int2byte(len, super.buf, 0);
TypeConvert.int2byte(4, super.buf, 4);
TypeConvert.long2byte(msg_Id, super.buf, 12);
super.buf[20] = (byte) pk_Total;
super.buf[21] = (byte) pk_Number;
super.buf[22] = (byte) registered_Delivery;
super.buf[23] = (byte) msg_Level;
System.arraycopy(service_Id.getBytes(), 0, super.buf, 24, service_Id
.length());
super.buf[34] = (byte) fee_UserType;
System.arraycopy(fee_Terminal_Id.getBytes(), 0, super.buf, 35,
fee_Terminal_Id.length());
super.buf[56] = (byte) tp_Pid;
super.buf[57] = (byte) tp_Udhi;
super.buf[58] = (byte) msg_Fmt;
System
.arraycopy(msg_Src.getBytes(), 0, super.buf, 59, msg_Src
.length());
System.arraycopy(fee_Type.getBytes(), 0, super.buf, 65, fee_Type
.length());
System.arraycopy(fee_Code.getBytes(), 0, super.buf, 67, fee_Code
.length());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMddHHmmss");
if (valid_Time != null) {
String tmpTime = String.valueOf(
String.valueOf(dateFormat.format(valid_Time))).concat(
"032+");
System.arraycopy(tmpTime.getBytes(), 0, super.buf, 73, 16);
}
if (at_Time != null) {
String tmpTime = String.valueOf(
String.valueOf(dateFormat.format(at_Time))).concat("032+");
System.arraycopy(tmpTime.getBytes(), 0, super.buf, 90, 16);
}
System.arraycopy(src_Terminal_Id.getBytes(), 0, super.buf, 107,
src_Terminal_Id.length());
super.buf[128] = (byte) dest_Terminal_Id.length;
int i = 0;
for (i = 0; i < dest_Terminal_Id.length; i++)
System.arraycopy(dest_Terminal_Id[i].getBytes(), 0, super.buf,
129 + i * 21, dest_Terminal_Id[i].length());
int loc = 129 + i * 21;
super.buf[loc] = (byte) msg_Content.length;
System
.arraycopy(msg_Content, 0, super.buf, loc + 1,
msg_Content.length);
loc = loc + 1 + msg_Content.length;
System.arraycopy(reserve.getBytes(), 0, super.buf, loc, reserve
.length());
outStr = ",msg_id=" + this.getMessageId();
outStr = outStr + ",pk_Total=" + pk_Total;
outStr = outStr + ",pk_Number=" + pk_Number;
outStr = outStr + ",registered_Delivery=" + registered_Delivery;
outStr = outStr + ",msg_Level=" + msg_Level;
outStr = outStr + ",service_Id=" + service_Id;
outStr = outStr + ",fee_UserType=" + fee_UserType;
outStr = outStr + ",fee_Terminal_Id=" + fee_Terminal_Id;
outStr = outStr + ",tp_Pid=" + tp_Pid;
outStr = outStr + ",tp_Udhi=" + tp_Udhi;
outStr = outStr + ",msg_Fmt=" + msg_Fmt;
outStr = outStr + ",msg_Src=" + msg_Src;
outStr = outStr + ",fee_Type=" + fee_Type;
outStr = outStr + ",fee_Code=" + fee_Code;
if (valid_Time != null) {
outStr = outStr + ",valid_Time=" + dateFormat.format(valid_Time);
} else {
outStr = outStr + ",valid_Time=null";
}
if (at_Time != null) {
outStr = outStr + ",at_Time=" + dateFormat.format(at_Time);
} else {
outStr = outStr + ",at_Time=null";
}
outStr = outStr + ",src_Terminal_Id=" + src_Terminal_Id;
outStr = outStr + ",destusr_Tl=" + dest_Terminal_Id.length;
for (int t = 0; t < dest_Terminal_Id.length; t++) {
outStr = outStr + ",dest_Terminal_Id[" + t + "]="
+ dest_Terminal_Id[t];
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -