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

📄 cmppsubmit.java

📁 采用JAVA开发
💻 JAVA
字号:
package com.gctech.cmpp3.msg;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import com.gctech.util.CmppSocket;
import com.gctech.util.IOUtility;
import com.gctech.util.Tools;

public class CmppSubmit {

	public CmppSubmit(CmppSocket conn) {
		DestUsrTl = 1;
		pos = 323;
		bodyBaseLen = 183;
		byte temp_chn[] = null;
		bodybytes = new byte[343];
		headbytes = new byte[12];
		pos = 323;
		CommandID = 4;
		TotalLength = 355;
		this.conn = conn;
		SequenceId = 0;
		PkTotal = 0;
		PkNumber = 0;
		RegisteredDelivery = 1;
		MsgLevel = 1;
		ServiceId = "";
		FeeUserType = 1;
		feeterminalid = "";
		FeeTerminalType = 0;
		tppid = 0;
		tpudhi = 0;
		MsgFmt = 8;
		MsgSrc = "";
		FeeType = "";
		FeeCode = "";
		ValidTime = "";
		AtTime = "";
		SrcTerminalId = "";
		DestUsrTl = 1;
		DestTerminalId = "";
		DestTerminalType = 0;
		MsgLength = 160;
		MsgContent = new byte[160];
		LinkID = "";
		Tools.BytesCopy(Tools.IntToBytes4(TotalLength), headbytes, 0, 3, 0);
		Tools.BytesCopy(Tools.IntToBytes4(CommandID), headbytes, 0, 3, 4);
		Tools.BytesCopy(Tools.IntToBytes4(SequenceId), headbytes, 0, 3, 8);
		int cur_pos = 0;
		MsgId = new byte[8];
		Tools.BytesCopy(MsgId, bodybytes, 0, 7, cur_pos);
		cur_pos += 8;
		bodybytes[cur_pos] = (byte) PkTotal;
		cur_pos++;
		bodybytes[cur_pos] = (byte) PkNumber;
		cur_pos++;
		bodybytes[cur_pos] = (byte) RegisteredDelivery;
		cur_pos++;
		bodybytes[cur_pos] = (byte) MsgLevel;
		cur_pos++;
		byte tempbytes[] = new byte[10];
		ServiceId.getBytes(0, ServiceId.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 9, cur_pos);
		cur_pos += 10;
		bodybytes[cur_pos] = (byte) FeeUserType;
		cur_pos++;
		tempbytes = new byte[32];
		feeterminalid.getBytes(0, feeterminalid.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 31, cur_pos);
		cur_pos += 32;
		bodybytes[cur_pos] = (byte) FeeTerminalType;
		cur_pos++;
		bodybytes[cur_pos] = (byte) tppid;
		cur_pos++;
		bodybytes[cur_pos] = (byte) tpudhi;
		cur_pos++;
		bodybytes[cur_pos] = (byte) MsgFmt;
		cur_pos++;
		tempbytes = new byte[6];
		MsgSrc.getBytes(0, MsgSrc.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 5, cur_pos);
		cur_pos += 6;
		tempbytes = new byte[2];
		FeeType.getBytes(0, FeeType.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 1, cur_pos);
		cur_pos += 2;
		tempbytes = new byte[6];
		FeeCode.getBytes(0, FeeCode.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 5, cur_pos);
		cur_pos += 6;
		tempbytes = new byte[17];
		ValidTime.getBytes(0, ValidTime.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 16, cur_pos);
		cur_pos += 17;
		tempbytes = new byte[17];
		AtTime.getBytes(0, AtTime.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 16, cur_pos);
		cur_pos += 17;
		tempbytes = new byte[21];
		SrcTerminalId.getBytes(0, SrcTerminalId.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 20, cur_pos);
		cur_pos += 21;
		bodybytes[cur_pos] = (byte) DestUsrTl;
		cur_pos++;
		int len = 32 * DestUsrTl;
		tempbytes = new byte[len];
		DestTerminalId.getBytes(0, DestTerminalId.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, len - 1, cur_pos);
		cur_pos += len;
		bodybytes[cur_pos] = (byte) DestTerminalType;
		cur_pos++;
		bodybytes[cur_pos] = (byte) MsgLength;
		cur_pos++;
		bodyBaseLen = cur_pos + 20;
		Tools.BytesCopy(MsgContent, bodybytes, 0, MsgLength - 1, cur_pos);
		cur_pos += MsgLength;
	}

	public int sendCmppSubmit() {
		int i;
		label0 : {
			i = 0;
			byte byte0;
			synchronized (conn) {
				try {
					try {
						File file = new File("out2.txt");
						file.createNewFile();
						IOUtility.copy(headbytes, new FileOutputStream(file));
						IOUtility.copy(bodybytes, new FileOutputStream(file));
					} catch (Exception e) {
						e.printStackTrace();
					}
					conn.bout.write(headbytes);
					byte tmp[] = new byte[TotalLength - 12];
					Tools.BytesCopy(bodybytes, tmp, 0, TotalLength - 13, 0);
					conn.bout.write(tmp);
					conn.bout.flush();
					break label0;
				} catch (IOException e) {
					System.out.println(e.toString());
					i = -5;
					int j = i;
					return j;
				} catch (NullPointerException npe) {
					i = -5;
					byte0 = -5;
				}
			}
			return byte0;
		}
		return i;
	}

	public void setSequenceId(int SequenceId) {
		this.SequenceId = SequenceId;
		Tools.BytesCopy(Tools.IntToBytes4(SequenceId), headbytes, 0, 3, 8);
	}

	public void setMsgId(byte MsgId[]) {
		this.MsgId = MsgId;
		Tools.BytesCopy(MsgId, bodybytes, 0, 7, 0);
	}

	public void setPkTotal(int PkTotal) {
		this.PkTotal = PkTotal;
		bodybytes[8] = (byte) PkTotal;
	}

	public void setPkNumber(int PkNumber) {
		this.PkNumber = PkNumber;
		bodybytes[9] = (byte) PkNumber;
	}

	public void setRegisteredDelivery(int RegisteredDelivery) {
		this.RegisteredDelivery = RegisteredDelivery;
		bodybytes[10] = (byte) RegisteredDelivery;
	}

	public void setMsgLevel(int MsgLevel) {
		this.MsgLevel = MsgLevel;
		bodybytes[11] = (byte) MsgLevel;
	}

	public void setServiceId(String ServiceId) {
		this.ServiceId = ServiceId;
		byte tempbytes[] = new byte[10];
		ServiceId.getBytes(0, ServiceId.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 9, 12);
	}

	public void setFeeUserType(int FeeUserType) {
		this.FeeUserType = FeeUserType;
		bodybytes[22] = (byte) FeeUserType;
	}

	public void setFeeterminalid(String feeterminalid) {
		this.feeterminalid = feeterminalid;
		byte tempbytes[] = new byte[32];
		feeterminalid.getBytes(0, feeterminalid.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 31, 23);
	}

	public void setFeeTerminalType(int ftType) {
		FeeTerminalType = ftType;
		bodybytes[55] = (byte) ftType;
	}

	public void setTppid(int tppid) {
		this.tppid = tppid;
		bodybytes[56] = (byte) tppid;
	}

	public void setTpudhi(int tpudhi) {
		this.tpudhi = tpudhi;
		bodybytes[57] = (byte) tpudhi;
	}

	public void setMsgFmt(int MsgFmt) {
		this.MsgFmt = MsgFmt;
		bodybytes[58] = (byte) MsgFmt;
	}

	public void setMsgSrc(String MsgSrc) {
		this.MsgSrc = MsgSrc;
		byte tempbytes[] = new byte[6];
		MsgSrc.getBytes(0, MsgSrc.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 5, 59);
	}

	public void setFeeType(String FeeType) {
		this.FeeType = FeeType;
		byte tempbytes[] = new byte[2];
		FeeType.getBytes(0, FeeType.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 1, 65);
	}

	public void setFeeCode(String FeeCode) {
		this.FeeCode = FeeCode;
		byte tempbytes[] = new byte[6];
		FeeCode.getBytes(0, FeeCode.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 5, 67);
	}

	public void setValidTime(String ValidTime) {
		this.ValidTime = ValidTime;
		byte tempbytes[] = new byte[17];
		ValidTime.getBytes(0, ValidTime.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 16, 73);
	}

	public void setAtTime(String AtTime) {
		this.AtTime = AtTime;
		byte tempbytes[] = new byte[17];
		AtTime.getBytes(0, AtTime.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 16, 90);
	}

	public void setSrcTerminalId(String SrcTerminalId) {
		this.SrcTerminalId = SrcTerminalId;
		byte tempbytes[] = new byte[21];
		SrcTerminalId.getBytes(0, SrcTerminalId.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 20, 107);
	}

	public void setDestTerminalType(int dtType) {
		DestTerminalType = dtType;
		bodybytes[161] = (byte) dtType;
	}

	public void setRequiredItems(String DestTerminalId, int MsgLength, byte MsgContent[]) {
		byte temp_chn[] = null;
		byte tempbytes[] = null;
		this.MsgContent = MsgContent;
		this.MsgLength = MsgContent.length;
		this.DestTerminalId = DestTerminalId;
		byte tmp_con[] = new byte[MsgContent.length];
		for (int i = 0; i < MsgContent.length; i++)
			tmp_con[i] = MsgContent[i];

		TotalLength = bodyBaseLen + MsgLength + 12;
		Tools.BytesCopy(Tools.IntToBytes4(TotalLength), headbytes, 0, 3, 0);
		tempbytes = new byte[32];
		DestTerminalId.getBytes(0, DestTerminalId.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 31, 129);
		bodybytes[162] = (byte) MsgLength;
		Tools.BytesCopy(tmp_con, bodybytes, 0, MsgLength - 1, 163);
		tempbytes = new byte[20];
		LinkID.getBytes(0, LinkID.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 19, 163 + MsgLength);
		pos = 163 + MsgLength;
	}

	public void setLinkID(String linkid) {
		LinkID = linkid;
		int cur_pos = pos;
		byte tempbytes[] = new byte[20];
		LinkID.getBytes(0, LinkID.length(), tempbytes, 0);
		Tools.BytesCopy(tempbytes, bodybytes, 0, 19, cur_pos);
	}

	public int getTotalLength() {
		return TotalLength;
	}

	byte MsgId[];
	int PkTotal;
	int PkNumber;
	int RegisteredDelivery;
	int MsgLevel;
	String ServiceId;
	int FeeUserType;
	String feeterminalid;
	int FeeTerminalType;
	int tppid;
	int tpudhi;
	int MsgFmt;
	String MsgSrc;
	String FeeType;
	String FeeCode;
	String ValidTime;
	String AtTime;
	String SrcTerminalId;
	int DestUsrTl;
	String DestTerminalId;
	int DestTerminalType;
	int MsgLength;
	byte MsgContent[];
	String LinkID;
	private int TotalLength;
	private int CommandID;
	private int SequenceId;
	public byte bodybytes[];
	public byte headbytes[];
	CmppSocket conn;
	int pos;
	int bodyBaseLen;
}

⌨️ 快捷键说明

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