package bshark.servlet.mkthailand;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import bshark.entity.message.Drmessage;
import bshark.util.Constants;
import uk.ltd.getahead.dwr.util.Logger;
public class ReceiveMKThailandDN extends HttpServlet{
private static final long serialVersionUID = 5730527920096762378L;
/*
* 日志对象
*/
public final Logger logger = Logger.getLogger(this.getClass());
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
Drmessage drmessage = new Drmessage();
int states =-1;
response.setContentType("text/html;charset=utf-8");
try{
String url = request.getRequestURL().toString();
String urlParamters=request.getQueryString();
String mtId = request.getParameter("mtid");//MT ID
String moId = request.getParameter("moid");//MO ID
String dateTime = request.getParameter("datetime");//同步时间
String msisdn = request.getParameter("msisdn");//手机号码
String shortcode = request.getParameter("shortcode");//短号
String telcoid = request.getParameter("telcoid");//网关
String countryId = request.getParameter("countryid"); //国家id
String status = request.getParameter("status");//DN状态
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyyMMddHHmmss");
Date date = new Date();
String receivetime = dateFormat.format(date);
logger.info("收到泰国DN信息:"+mtId+"moid:"+moId+"datetime:"
+dateTime+"dateTime:"+"msisdn:"+msisdn+"shortcode:"+shortcode+
"telcoid:"+telcoid+"countryId:"+countryId+"status:"+status+"MK泰国请求url:"+url+urlParamters);
drmessage.setMsgId(mtId);
drmessage.setStr_argz1(moId);
drmessage.setStr_argz2(mtId);
drmessage.setSyncTime(dateTime);
drmessage.setPhone(msisdn);
drmessage.setShortcode(shortcode);
drmessage.setOpertorName(telcoid);
drmessage.setCountryCode(countryId);
if(status!=null&&status.toUpperCase().equals("4")
||status.toUpperCase().equals("SENT_DELIVERED: 000")
||status.toUpperCase().equals("RETRIEVED|EXTERNAL:DELIVRD")){
drmessage.setReceiveState("1");
}else{
drmessage.setReceiveState("-1");
}
drmessage.setSyncState("1");
drmessage.setReceiveTime(receivetime == null ? " " : receivetime);
drmessage.setDescription("Macrokiosk" + "网关" + (new Date()) + "时间接受了一条来次"
+ this.getClass().getSimpleName() + "DR");
drmessage.setCountry("Thailand");
drmessage.setGatewayName("Macrokiosk");
drmessage.setCompanyName("Macrokiosk");
//存库
Constants.drmsgVector.add(drmessage);
}catch(Exception e){
logger.error(e.getMessage());
logger.info("mk泰国数据异常");
}finally{
logger.info("MK泰国 DN QUERY STRING - PIN:");
logger.info("MK泰国 DN Parameter - PIN:="
+"phone="+drmessage.getPhone()+","
+"companyName="+drmessage.getCompanyName()+","
+"gatewayName="+drmessage.getGatewayName()+","
+"msgId="+drmessage.getMsgId()+","
+"shortcode="+drmessage.getShortcode()+","
+"mtid="+drmessage.getStr_argz1()+","
+"description="+drmessage.getDescription()+","
+"telcoid="+drmessage.getOpertorName()+","
+"country="+drmessage.getCountry()+",");
out.println(states); //respone 相应get请求的参数
out.flush();
out.close();
}
}
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
super.doPost(req, resp);
}
}