⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmsmobean.java

📁 彩信发送源代码,实现mm7接口
💻 JAVA
字号:
/**
 * <pre>
 *                这里说明修改记录,包括修改人,修改时间和修改目的和内容
 *                ---修改时间---修改人---修改目的和内容----------------------
 *                
 * </pre>
 */
package com.sxit.mms;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * 从mmsmo里面取数据出来.提供如下功能:<br>
 * 1、从mo表里面取出1条数据 <br>
 * 2、删除掉mo里面的1条数据,根据关键字moid <br>
 * 3、从里面取出并删除一条<br>
 * 4、从mo标里面取出1批数据,无任何条件的<br>
 * 5、删除掉mo表里面的1批数据,根据关键字moid <br>
 * 6、从里面取出并删除一批 <br>
 * 7、根据每页显示的个数以及页码和相应条件,取出一批数据
 * 
 * @author HuaFeng
 * @version 1.0 (2006-3-1 17:44:05)
 * 
 */
public class MMSMOBean {
	/**
	 * number(10) primary key not null, --接收mo的序列号
	 */
	private long moID;// 

	public void setMOID(long moid) {
		this.moID = moid;
	}

	public long getMOID() {
		return this.moID;
	}

	/**
	 * 彩信在mmsc中的id,soap方式接收为空
	 */
	private String messgeID;// varchar(20), --

	public void setMessgeID(String messageid) {
		this.messgeID = messageid;
	}

	public String getMessgeIDD() {
		return this.messgeID;
	}

	/**
	 * 彩信中心序列号
	 */
	private String mmscID;// varchar2(10), --彩信中心序列号

	public void setMMSCID(String moid) {
		this.mmscID = moid;
	}

	public String getMMSCID() {
		return this.mmscID;
	}

	private String linkedID;// varchar2(10), --

	public void setLinkedID(String LinkedID) {
		this.linkedID = LinkedID;
	}

	public String getLinkedID() {
		return this.linkedID;
	}

	/**
	 * 发送方号码
	 */
	private String sender;// varchar2(15), --发送方号码

	public void setSender(String sender) {
		this.sender = sender;
	}

	public String getSender() {
		return this.sender;
	}

	/**
	 * 接收方号码
	 */
	private String destination;// varchar2(15),--接收方号码

	public void setDestination(String destination) {
		this.destination = destination;
	}

	public String getDestination() {
		return this.destination;
	}

	/**
	 * 发送类别,1为to,2为cc,3为bcc
	 */
	private int sendType;// number(2),--

	public void setSendType(int sendtype) {
		this.sendType = sendtype;
	}

	public long getSendType() {
		return this.sendType;
	}

	/**
	 * mo发送时间
	 */
	private Timestamp sendDate;// ,--

	public void setSendDate(Timestamp sendDate) {
		this.sendDate = sendDate;
	}

	public Timestamp getSendDate() {
		return this.sendDate;
	}

	/**
	 * 计费号码
	 */
	private String replyChargingID;// varchar2(15),--

	public void setReplyChargingID(String replyChargingID) {
		this.replyChargingID = replyChargingID;
	}

	public String getReplyChargingID() {
		return this.replyChargingID;
	}

	/**
	 * 级别
	 */
	private int priority;// number(2),--,

	public void setPriority(int priority) {
		this.priority = priority;
	}

	public int getPriority() {
		return this.priority;
	}

	/**
	 * 主题
	 */
	private String subject;// varchar2(50),--

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getSubject() {
		return this.subject;
	}

	/**
	 * 处理序列号
	 */
	private String transactionID;// varchar2(40),--

	public void setTransactionID(String transactionID) {
		this.transactionID = transactionID;
	}

	public String getTransactionID() {
		return this.transactionID;
	}

	/**
	 * mo消息插入到存储到数据库的时间
	 */
	private Timestamp accepDate;// date default sysdate not null,--

	public void setAcceptDate(Timestamp accepDate) {
		this.accepDate = accepDate;
	}

	public Timestamp getAcceptDate() {
		return this.accepDate;
	}

	/**
	 * 上传后的彩信存储地,目录排列为/year/month/day/moid
	 */
	private String mmdir;// varchar2(100) --

	public void setMMDir(String mmdir) {
		this.mmdir = mmdir;
	}

	public String getMMDir() {
		return this.mmdir;
	}

	/**
	 * 获取一条mo数据
	 * 
	 * @param con
	 */
	public void createOneMO(Connection con) throws SQLException {
		PreparedStatement stmt = null;
		ResultSet rs = null;
		String sql = "select moid,messgeid,mmscid,LinkedID,sender,destination,sendtype,TimeStamp,ReplyChargingID,Priority,subject,transactionid,accepdate,mmdir from mmsmo where rownum=1";
		try {
			stmt = con.prepareStatement(sql);
			rs = stmt.executeQuery();
			if (rs.next()) {
				this.setMOID(rs.getLong("moid"));
				this.setMessgeID(rs.getString("messgeid"));
				this.setMMSCID(rs.getString("mmscid"));
				this.setLinkedID(rs.getString("linkedid"));
				this.setSender(rs.getString("sender"));
				this.setDestination(rs.getString("destination"));
				this.setSendType(rs.getInt("sendtype"));
				this.setSendDate(rs.getTimestamp("timestamp"));
				this.setReplyChargingID(rs.getString("ReplyChargingID"));
				this.setPriority(rs.getInt("priority"));
				this.setSubject(rs.getString("subject"));
				this.setTransactionID(rs.getString("transactionid"));
				this.setAcceptDate(rs.getTimestamp("acceptdate"));
				this.setMMDir(rs.getString("mmdir"));

			}

		}
		finally {
			if (rs != null)
				rs.close();
			if (stmt != null)
				stmt.close();
		}

	}

	/**
	 * 删除一条mo数据,根据关键字moid
	 * 
	 * @param con
	 * @param moid
	 */
	public void deleteOneMO(Connection con, long moid) throws SQLException {
		PreparedStatement stmt = null;
		String sql = "delete from mmsmo where moid=?";
		try {
			stmt = con.prepareStatement(sql);
			stmt.setLong(1, moid);
			stmt.executeUpdate();

		}
		finally {
			if (stmt != null)
				stmt.close();
		}

	}

	/**
	 * 从mmsmo中取出一条数据,然后删除之
	 * 
	 * @param con
	 * @throws SQLException
	 */
	public void exportOneMO(Connection con) throws SQLException {
		MMSMOBean mmsmo = new MMSMOBean();
		try {
			con.setAutoCommit(false);
			mmsmo.createOneMO(con);
			// 如果没有取出数据,则mmsmo.getMOID()的值为0
			mmsmo.deleteOneMO(con, mmsmo.getMOID());
			con.commit();
			con.setAutoCommit(true);
		}
		catch (SQLException e) {
			con.rollback();
			System.out.println("MO表导出一条数据失败:" + e);
		}
	}

	/**
	 * 获取一批mo数据,但是不删除
	 * 
	 * @param con
	 * @param batchCount
	 *            一次性取出数据的个数.
	 * @return
	 */
	public static List createBatchMO(Connection con, int batchCount) throws SQLException {
		List result = new ArrayList();
		PreparedStatement stmt = null;
		ResultSet rs = null;
		String sql = "select moid,messgeid,mmscid,LinkedID,sender,destination,sendtype,TimeStamp,ReplyChargingID,Priority,subject,transactionid,accepdate,mmdir from mmsmo where rownum<=?";
		try {
			stmt = con.prepareStatement(sql);
			stmt.setInt(1, batchCount);
			stmt.setFetchSize(50);
			rs = stmt.executeQuery();
			while (rs.next()) {
				MMSMOBean mmsmo = new MMSMOBean();
				mmsmo.setMOID(rs.getLong("moid"));
				mmsmo.setMessgeID(rs.getString("messgeid"));
				mmsmo.setMMSCID(rs.getString("mmscid"));
				mmsmo.setLinkedID(rs.getString("linkedid"));
				mmsmo.setSender(rs.getString("sender"));
				mmsmo.setDestination(rs.getString("destination"));
				mmsmo.setSendType(rs.getInt("sendtype"));
				mmsmo.setSendDate(rs.getTimestamp("timestamp"));
				mmsmo.setReplyChargingID(rs.getString("ReplyChargingID"));
				mmsmo.setPriority(rs.getInt("priority"));
				mmsmo.setSubject(rs.getString("subject"));
				mmsmo.setTransactionID(rs.getString("transactionid"));
				mmsmo.setAcceptDate(rs.getTimestamp("acceptdate"));
				mmsmo.setMMDir(rs.getString("mmdir"));
				result.add(mmsmo);
			}
		}
		finally {
			if (rs != null)
				rs.close();
			if (stmt != null)
				stmt.close();
		}
		return result;
	}

	/**
	 * 根据关键字删除一批数据
	 * 
	 * @param con
	 * @param moids
	 * @throws SQLException
	 */
	public static void deleteBatchMO(Connection con, long[] moids) throws SQLException {
		// MMSMOBean mmsmo = new MMSMOBean();
		PreparedStatement stmt = null;
		String sql = "delete from mmsmo where moid=?";
		try {
			con.setAutoCommit(false);
			stmt = con.prepareStatement(sql);
			for (int i = 0; i < moids.length; i++) {
				stmt.setLong(1, moids[i]);
				stmt.addBatch();
			}
			stmt.executeBatch();
			con.commit();

		}
		catch (SQLException e) {
			con.rollback();
			System.out.println("删除一批MO数据失败:" + e);
		}
		finally {
			con.setAutoCommit(true);
			if (stmt != null)
				stmt.close();
		}
	}

	/**
	 * 取出并删除一批数据,batchCount为一次性取出的个数
	 * 
	 * @param con
	 * @param batchCount
	 * @throws SQLException
	 */
	public static void exportBatchMO(Connection con, int batchCount) throws SQLException {
		MMSMOBean bean = null;
		try {
			con.setAutoCommit(false);
			List list = createBatchMO(con, batchCount);
			long[] moids = new long[list.size()];

			for (int i = 0; i < moids.length; i++) {
				bean = (MMSMOBean) list.get(i);
				moids[i] = bean.getMOID();

			}
			deleteBatchMO(con, moids);
			con.commit();
			con.setAutoCommit(true);
		}
		catch (SQLException e) {
			con.rollback();

			System.out.println("MO表导出一条数据失败:" + e);
		}
		finally {
			con.setAutoCommit(true);

		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -