📄 cmpp2structconverter.java
字号:
package com.gctech.sms.gateway.sdcmpp;
import com.gctech.sms.msg.MTInfo;
import com.gctech.sms.msg.MOInfo;
import com.gctech.cmpp.msg.*;
import com.gctech.sms.core.IsReply;
import org.apache.log4j.Logger;
import com.gctech.cmpp.msg.SubmitRequest;
import com.gctech.sms.gateway.basic.ReportStatus;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: gctech</p>
* @author 王红宝
* @version $Id: CMPP2StructConverter.java,v 1.2 2004/07/26 08:51:58 lijz Exp $
*/
public class CMPP2StructConverter {
public CMPP2StructConverter() {
}
/**
* 将CMPP的上行信息转换成通用的上行信息。
* */
public static MOInfo Deliver2MOInfo(DeliverRequest msg){
MOInfo info = new MOInfo();
System.out.println("msg.getMsgContent()----------------"+msg.getMsgContent());
info.content = msg.getMsgContent();
info.srcPhoneNo = msg.getSrcId();
info.destTermId = msg.getDestId();
info.strMsgID = new String(msg.getMsgId());
info.IsReply = msg.getRegisteredDelivery();
//如果是状态报告,找到对应MT的MSGID
if ( info.IsReply == IsReply.IS_REPLY.getValue() ){
info.linkMtMsgId = msg.getMsgContent().substring(0, 8);
logger.debug(""+ info.linkMtMsgId.length());
String key = msg.getMsgContent().substring(8, 15);
logger.debug(key);
ReportStatus re = ReportStatus.get(key);
if (re == null)
info.status = ReportStatus.CA_XXXX.getValue();
else
info.status = re.getValue();
}
return info;
}
/**
* 将通用下行信息转换成CNGP下行信息。
* */
public static SubmitRequest MTInfo2Submit(MTInfo info){
SubmitRequest msg = new SubmitRequest();
msg.setDestNum(info.bDestNo);
msg.setFeeUserType(info.bFeeUserType);
msg.setMsgFmt(info.bMsgFmt);
msg.setMsgLength((short)info.content.getBytes().length);
msg.setMsgLevel(info.bMsgLevel);
msg.setRegisteredDelivery(info.bNeedReply);
msg.setAtTime(info.AtTime);
msg.setDestTermId(info.sDestPhone);
msg.setFeeCode(info.FeeCode);
msg.setFeeTermId(info.FeeterminalId);
msg.setFeeType(convertToCmppFeeType(info.FeeType));
msg.setMsgContent(info.content);
msg.setServiceId(info.ServiceID);
msg.setSrcId(info.srcPhone);
// msg.setsu
// msg.subType = info.bSubType;
//时间格式需要转换
msg.setValidTime(info.ValidTime);
//msg.sValidTime = info.ValidTime;*/
return msg;
}
public static void main(String[] args) {
System.out.println(3+11+4+4+6+4+12+11+10+11+5);
}
/**
* 将平台计费类型转化成CMPP协议的计费类型
*
* @param srcFeeType平台的计费类型
* @return CMPP计费类型
*/
protected static String convertToCmppFeeType(String srcFeeType){
String returnFeeType = null;
System.out.println("srcFeeType is "+srcFeeType);
if(srcFeeType.equals("00"))
{
returnFeeType = "01" ;
}
else if(srcFeeType.equals("01"))
returnFeeType = "02";
else if(srcFeeType.equals("02"))
returnFeeType = "03";
else if(srcFeeType.equals("03"))
returnFeeType = "04";
else if(srcFeeType.equals("04"))
returnFeeType = "05";
else
{
throw new IllegalArgumentException("错误的FeeType:"+srcFeeType);
}
return returnFeeType;
}
static final Logger logger = Logger.getLogger(CMPP2StructConverter.class);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -