📄 tracesmresult.java
字号:
package ffcs.lbp.trace;
import java.nio.ByteBuffer;
import ffcs.lbp.ProtocolException;
import ffcs.lbp.le.message.LeMessage;
/*
* <p>Title: 流程追踪协议解析抽象基类</p>
* <p>Description: 流程追踪协议解析抽象基类</p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: 福富软件</p>
* @author chenxin
* @version 1.0 $Date 2007-11-02
*/
public class TraceSmResult extends TraceMsg {
static final String DATA_FORMAT="yyyyMMddHHmmssSSS";
/**
* 流程追踪的时候,根据来源实体区分消息是从外部实体,还是从收发模块来,
* 进行消息ID转换
*/
public final static int ForwardSMReq_In = 0x00003082;
public final static int ForwardSMRsp_In = 0x80003082;
public final static int ForwardSRReq_In = 0x00003083;
public final static int ForwardSRRsp_In = 0x80003083;
public final static int QueryServiceReq_In =0x00003081 ;
public final static int QueryServiceRsp_In =0x80003081 ;
public final static int ForwardSMReq_Out = 0x00003092;
public final static int ForwardSMRsp_Out = 0x80003092;
public final static int ForwardSRReq_Out = 0x00003093;
public final static int ForwardSRRsp_Out = 0x80003093;
public final static int QueryServiceReq_Out= 0x00003091;
public final static int QueryServiceRsp_Out= 0x80003091;
int moduleType;
int moduleNo;
int entitySrc;//实体编号
String entityName;//实体名称
//最后统计时间YYYYMMDDHHMISS***(*为毫秒),默认为系统当前时间
String lastTime;
//追踪标志 1 预设追踪(默认) 2 随机追踪3 拨测追踪
byte traceFlag=1;
//追踪序列号
int traceSeqNo;
//追踪主叫号码
String traceMsisdnSrc;
//追踪被叫号码
String traceMsisdnDest;
//流程步骤序号(每个消息都从1递增)
int traceStepNo=1;
//消息编号
int msgNo;
//拨测消息类别0--未知 1--本网本地 2--本网异地
byte msgBizType=0;
//主叫号码
String msisdnSrc;
//被叫号码
String msisdnDest;
//消息状态 0-代表未知
byte status=0;
//编码,默认为15-GBK 0-ASCII 8-UNICODE
byte dataCoding=15;
//短信长度
int smlength;
//短信内容(最大255)
byte[] shorttMsg;
//消息长度
int msgLength;
//原始消息(二进制数值)
String msgText;
//描述\0结尾的字符串
String desc;
public TraceSmResult(){
super(TRACE_SM_RESULT);
lastTime = dateConvertToStr(DATA_FORMAT);
}
/**
* 暂时没实现
*/
public boolean readBody(ByteBuffer buf) throws ProtocolException {
/**
* 暂时没实现
*/
return true;
}
/**
* 得到包体的长度
* @return int
*/
protected int getBodyLength() {
int length = 146;//为定长字符串
length+=this.getSmlength();
length+=this.getMsgLength();
try{
length += (desc==null) ? 0 : desc.getBytes("GBK").length;
}catch(Exception e){
e.printStackTrace();
}
length +=1;//1个字段为CString类型 "\0"结尾
return length;
}
public int getPackLength(){
return LeMessage.HEADER_LENGTH+getBodyLength();
}
/**
* 写入消息
* @param buf 把消息写入到该BUF
* @return true-写入成功 false-写入失败
*/
public boolean writeBody(ByteBuffer buf) {
buf.putInt(moduleType);
buf.putInt(moduleNo);
buf.putInt(entitySrc);
writeOString(buf,entityName,12);
writeOString(buf,lastTime,18);
buf.put(traceFlag);
buf.putInt(traceSeqNo);
writeOString(buf,traceMsisdnSrc,20);
writeOString(buf,traceMsisdnDest,20);
buf.putInt(traceStepNo);
buf.putInt(msgNo);
buf.put(msgBizType);
writeOString(buf,msisdnSrc,20);
writeOString(buf,msisdnDest,20);
buf.put(status);
buf.put(dataCoding);
buf.putInt(getSmlength());
if(shorttMsg!=null){
buf.put(shorttMsg);
}
buf.putInt(getMsgLength());
if(msgText!=null){
buf.put(msgText.getBytes());
}
//可变长字段
writeCString(buf,desc);
return true;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public int getEntitySrc() {
return entitySrc;
}
public void setEntitySrc(int entitySrc) {
this.entitySrc = entitySrc;
}
public String getLastTime() {
return lastTime;
}
public void setLastTime(String lastTime) {
this.lastTime = lastTime;
}
public int getModuleNo() {
return moduleNo;
}
public void setModuleNo(int moduleNo) {
this.moduleNo = moduleNo;
}
public int getModuleType() {
return moduleType;
}
public void setModuleType(int moduleType) {
this.moduleType = moduleType;
}
public byte getMsgBizType() {
return msgBizType;
}
public void setMsgBizType(byte msgBizType) {
this.msgBizType = msgBizType;
}
public int getMsgLength() {
return (msgText==null) ? 0 : msgText.getBytes().length;
}
public void setMsgLength(int msgLength) {
this.msgLength = msgLength;
}
public int getMsgNo() {
return msgNo;
}
public void setMsgNo(int msgNo) {
this.msgNo = msgNo;
}
public String getMsgText() {
return msgText;
}
/**
* 设置原始的二进制消息,并把原始的消息转为16进制的格式字符串
* @param msgText
*/
public void setMsgText(byte[] msgText) {
this.msgText = byteTohexString(msgText);
}
public String getMsisdnDest() {
return msisdnDest;
}
public void setMsisdnDest(String msisdnDest) {
this.msisdnDest = msisdnDest;
}
public String getMsisdnSrc() {
return msisdnSrc;
}
public void setMsisdnSrc(String msisdnSrc) {
this.msisdnSrc = msisdnSrc;
}
public byte[] getShorttMsg() {
return shorttMsg;
}
public void setShorttMsg(byte[] shorttMsg) {
this.shorttMsg = shorttMsg;
}
public int getSmlength() {
return (shorttMsg==null) ? 0 : shorttMsg.length;
}
public void setSmlength(int smlength) {
this.smlength = smlength;
}
public byte getStatus() {
return status;
}
public void setStatus(byte status) {
this.status = status;
}
public int getTraceFlag() {
return traceFlag;
}
public void setTraceFlag(byte traceFlag) {
this.traceFlag = traceFlag;
}
public String getTraceMsisdnDest() {
return traceMsisdnDest;
}
public void setTraceMsisdnDest(String traceMsisdnDest) {
this.traceMsisdnDest = traceMsisdnDest;
}
public String getTraceMsisdnSrc() {
return traceMsisdnSrc;
}
public void setTraceMsisdnSrc(String traceMsisdnSrc) {
this.traceMsisdnSrc = traceMsisdnSrc;
}
public int getTraceSeqNo() {
return traceSeqNo;
}
public void setTraceSeqNo(int traceSeqNo) {
this.traceSeqNo = traceSeqNo;
}
public int getTraceStepNo() {
return traceStepNo;
}
public void setTraceStepNo(int traceStepNo) {
this.traceStepNo = traceStepNo;
}
public String getEntityName() {
return entityName;
}
public void setEntityName(String entityName) {
this.entityName = entityName;
}
public byte getDataCoding() {
return dataCoding;
}
public void setDataCoding(byte dataCoding) {
this.dataCoding = dataCoding;
}
public String toString() {
StringBuffer sb=new StringBuffer(100);
sb.append(super.toString());
/*sb.append(" msgTextLen:"+getMsgLength());
sb.append(" msgText:"+byte2hexString(msgText));*/
return sb.toString();
}
public static String byteTohexString(byte[] bytes) {
if (bytes == null) {
return null;
}
StringBuffer buf = new StringBuffer(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
if (((int) bytes[i] & 0xff) < 0x10) {
buf.append("0");
}
buf.append(Long.toString((int) bytes[i] & 0xff, 16));
}
return buf.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -