📄 moengineone.java
字号:
package orderapp;/** * Title: * Description:Mo处理线程 * Copyright: Copyright (c) 2002 * Company: * @author * @version 1.0 */import utilities.*;import data.*;import xml.getLabel;import java.sql.*;import java.util.StringTokenizer;public class moEngineOne extends Engine { public String tmp; public String str; public String subcode; public StringTokenizer st; //public ConnectionPool data; public getLabel getLabelString; public XmlString xml; public String submit; public getContent pushSubmit; public String sqlMo; //第三方手机 public long thirdNum; public StringTokenizer thirdStNum,StTemp; public String GatewayName; public ThirdGatewayName thirdGatewayName; public moEngineOne() { setDaemon(true); //data=new ConnectionPool(); getLabelString=new getLabel(); xml=new XmlString(); pushSubmit=new getContent(); } public void run(){ while(true){ if(!Config.mo_queue.isEmpty()){ thirdNum=0; GatewayName=null; str=(String)Config.mo_queue.pop(); //加入Mo统计池 Config.MoStatistics.push(str); xml.destination_id=getLabelString.getString("cmpp_deliver/destination_id",str); xml.msg_fmt=getLabelString.getString("cmpp_deliver/msg_fmt",str); xml.msg_content=getLabelString.getString("cmpp_deliver/msg_content",str); xml.src_terminal_id=getLabelString.getString("cmpp_deliver/src_terminal_id",str); //字符转换 String content=toLowerCaseString(xml.msg_content,15).trim(); System.out.println(content); //如果是给第三方点播 StTemp=new StringTokenizer(content," "); content=content.trim(); int i=StTemp.countTokens(); System.out.println(i); if(content.indexOf(" ")!=0 && i==2 && xml.destination_id.length() >=6){//二级代码型 1 13111111111 Config.service_code = (xml.destination_id).substring(0,xml.destination_id.length()); thirdStNum=new StringTokenizer(content," "); try{ //content=(String)thirdStNum.nextElement(); //subcode=(String)thirdStNum.nextElement(); //System.out.println(subcode+"===="); content =(String)thirdStNum.nextElement();//取得msg_id System.out.println(content+"===="); //System.out.println((String)thirdStNum.nextElement()); tmp=(String)thirdStNum.nextElement();// thirdNum=Long.parseLong(tmp); if(tmp.length()>13){ thirdNum=-1;//第三放手迹好大于long型 } } catch(Exception e){thirdNum=-1;} //获得第三方网关名 try{ thirdGatewayName=null; thirdGatewayName=new ThirdGatewayName(); GatewayName=thirdGatewayName.getGatewayName(thirdNum); System.out.println(GatewayName+"==="); }catch(Exception e){ } } else if(content.indexOf(" ")!=0 && i==3 && xml.destination_id.length() >=6){ Config.service_code = (xml.destination_id).substring(0,xml.destination_id.length()); thirdStNum=new StringTokenizer(content," "); try{ //content=(String)thirdStNum.nextElement(); subcode=(String)thirdStNum.nextElement(); System.out.println(subcode+"===="); content =(String)thirdStNum.nextElement(); System.out.println(content+"===="); //System.out.println((String)thirdStNum.nextElement()); tmp=(String)thirdStNum.nextElement(); thirdNum=Long.parseLong(tmp); if(tmp.length()>13){ thirdNum=-1;//第三放手迹好大于long型 } } catch(Exception e){thirdNum=-1;} //获得第三方网关名 try{ thirdGatewayName=null; thirdGatewayName=new ThirdGatewayName(); GatewayName=thirdGatewayName.getGatewayName(thirdNum); System.out.println(GatewayName+"==="); }catch(Exception e){ } }else if(xml.destination_id.length() >=6){ Config.service_code = (xml.destination_id).substring(0,(xml.destination_id.length()-2)); //thirdStNum=new StringTokenizer(content," "); try{ //content=(String)thirdStNum.nextElement(); //subcode=(String)thirdStNum.nextElement(); //System.out.println(subcode+"===="); //content =(String)xml.msg_content;//取得msg_id System.out.println(content+"===="); //System.out.println((String)thirdStNum.nextElement()); //tmp=(String)thirdStNum.nextElement();// //thirdNum=Long.parseLong(tmp); //if(tmp.length()>13){ // thirdNum=-1;//第三放手迹好大于long型 //} } catch(Exception e){thirdNum=-1;} //获得第三方网关名 try{ //thirdGatewayName=null; //hirdGatewayName=new ThirdGatewayName(); //GatewayName=thirdGatewayName.getGatewayName(thirdNum); System.out.println(GatewayName+"==="); }catch(Exception e){ } ///////////////////////////////////////////////// //GatewayName=null; //thirdNum=Long.parseLong(xml.src_terminal_id); } xml.msg_id=getLabelString.getString("cmpp_deliver/msg_id",str); xml.registered_delivery=getLabelString.getString("cmpp_deliver/registered_delivery",str); xml.source_name=getLabelString.getString("cmpp_deliver/source/name",str); if(xml.destination_id.startsWith("0") && xml.destination_id.length()==7){ subcode=(xml.destination_id).substring(5); Config.service_code=(xml.destination_id).substring(0,5); }else if(!xml.destination_id.startsWith("0") && xml.destination_id.length()==6){ subcode=(xml.destination_id).substring(4); Config.service_code=(xml.destination_id).substring(0,4); }else if(xml.destination_id.length() <= 5 && i==2){ //非二级代码 5988 a 11 try{ st=new StringTokenizer(content," "); subcode = (String)st.nextElement(); content = (String) st.nextElement(); //thirdNum=Long.parseLong((String)st.nextElement()) ; //GatewayName=(xml.destination_id).substring(0,xml.destination_id.length()); Config.service_code = (xml.destination_id).substring(0,xml.destination_id.length()); }catch(Exception e){ } } else if(xml.destination_id.length() <= 5 && i==3){ //非二级代码 5988 a 11 13111111111 System.out.println("5988 a 11 13111111111"); try{ st=new StringTokenizer(content," "); subcode = (String)st.nextElement(); content = (String) st.nextElement(); tmp=(String)st.nextElement(); thirdNum=Long.parseLong(tmp); //thirdNum=Long.parseLong("13111111"); //System.out.println(thirdNum+"VV"); thirdGatewayName=null; thirdGatewayName=new ThirdGatewayName(); GatewayName=thirdGatewayName.getGatewayName(thirdNum); //GatewayName="standard"; Config.service_code = (xml.destination_id).substring(0,xml.destination_id.length()); }catch(Exception e){ e.printStackTrace() ; } }/// if(GatewayName==null&& xml.destination_id !=null){ //GatewayName=xml.source_name; } System.out.println(content+"msg_id"); System.out.println(subcode+"subcode"); System.out.println(thirdNum+"thirdNum"); System.out.println(GatewayName+"GatewayName"); //从mobile_content 表中提取内容生成submit包压入submit池 //for(int jj=0;jj<500;jj++){ pushSubmit.getParameter(GatewayName,thirdNum,content,subcode,"mt",xml.msg_id,xml.src_terminal_id,xml.registered_delivery,xml.source_name,xml.msg_fmt); pushSubmit.insertSubmit(); //} } try{ //Thread.sleep(Config.sleep_time); Thread.sleep(10); } catch(Exception e){ e.printStackTrace(); } } } public String toLowerCaseString(String hexStr,int msg_fmt){ String result=""; String temp; int len=hexStr.length(); if (hexStr.startsWith("00")){ len=len/4; for (int i=0;i<len;i++){ temp=hexStr.substring(i*4+2,i*4+4); if (Integer.parseInt(temp,16) > 0x7a) return result; result+=(char)Byte.parseByte(temp,16); } }else{ len=len/2; for (int i=0;i<len;i++){ temp=hexStr.substring(i*2,i*2+2); if (Integer.parseInt(temp,16) > 0x7a) return result; result+=(char)Byte.parseByte(temp,16); } } return result.toLowerCase(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -