📄 messagecount.java
字号:
statMsg[msgNo]=new StatMsg();
//--
Integer key = (Integer) iterator.next();
Message tempMsg = ((Message) msg[i].get(key));
if(tempMsg==null){
// 统计
statMsg[msgNo]=new StatMsg();
// System.out.println("key.intValue():"+key.intValue());
statMsg[msgNo].setIMsgNo(key.intValue());
statMsg[msgNo].setIAllNumRecv(0);
statMsg[msgNo].setIAllNumRecvFail(0);
statMsg[msgNo].setIAllNumRecvSucc(0);
statMsg[msgNo].setIAllNumSend(0);
statMsg[msgNo].setIAllNumSendFail(0);
statMsg[msgNo].setIAllNumSendSucc(0);
statMsg[msgNo].setILastNumRecv(0);
statMsg[msgNo].setILastNumRecvFail(0);
statMsg[msgNo].setILastNumRecvSucc(0);
statMsg[msgNo].setILastNumSend(0);
statMsg[msgNo].setILastNumSendFail(0);
statMsg[msgNo].setILastNumSendSucc(0);
msgNo++;
continue;
}
int receCounter = tempMsg.receCounter;
int sendCounter = tempMsg.sendCounter;
int lastRece = receCounter - tempMsg.receNum;
int lastSend = sendCounter - tempMsg.sendNum;
tempMsg.lastRece=lastRece;
tempMsg.lastSend=lastSend;
tempMsg.receNum=receCounter;
tempMsg.sendNum=sendCounter;
//统计
statMsg[msgNo]=new StatMsg();
statMsg[msgNo].setIMsgNo(key.intValue());
statMsg[msgNo].setIAllNumRecv(receCounter);
statMsg[msgNo].setIAllNumRecvFail(0);
statMsg[msgNo].setIAllNumRecvSucc(receCounter);
statMsg[msgNo].setIAllNumSend(sendCounter);
statMsg[msgNo].setIAllNumSendFail(0);
statMsg[msgNo].setIAllNumSendSucc(sendCounter);
statMsg[msgNo].setILastNumRecv(lastRece);
statMsg[msgNo].setILastNumRecvFail(0);
statMsg[msgNo].setILastNumRecvSucc(lastRece);
statMsg[msgNo].setILastNumSend(lastSend);
statMsg[msgNo].setILastNumSendFail(0);
statMsg[msgNo].setILastNumSendSucc(lastSend);
msgNo++;
}
// 统计
statRst.setStatMsg(statMsg);
statRst.setIReserved1(0);
statRst.setIReserved2(0);
if (statFlag) {
ByteBuffer bf = ByteBuffer.allocate(statRst.getCommandLength());
statRst.writeMsg(bf);
byte[] arr = bf.array();
try {
udpClient.sendMsg(arr,Constant.UDP_SERVER_IP,Constant.UDP_TRACE_PORT);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
*/
/* public String toString() {
//统计
StatRst statRst=new StatRst();
statRst.setSequence(0);
statRst.setCommandStatus(0);
//--
StringBuffer sb = new StringBuffer(300);
sb.append(title);
sb.append(":");
for (int i = 0; i < msg.length; i++) {
if (msg[i].size() == 0) {
continue;
}
//统计
statRst.setIModuleType(moduleType);
statRst.setIModuleNo(moduleNo);
statRst.setIEntitySrc(i);
statRst.setSzEntitySrcName("");
statRst.setSzLastTime(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
statRst.setIMsgNum(msgMap.size());
StatMsg statMsg[]=new StatMsg[msgMap.size()];
int msgNo=0;
//--
sb.append("\r\nID:" + i);
sb.append("\r\n" );
sb.append(lpad("msg type",20,' '));
sb.append(lpad("last receive",15,' '));
sb.append(lpad("receive count",15,' '));
sb.append(lpad("last send" ,15,' '));
sb.append(lpad("send count",15,' '));
Iterator iterator = msgMap.keySet().iterator();
while (iterator.hasNext()) {
//统计
statMsg[msgNo]=new StatMsg();
//--
Integer key = (Integer) iterator.next();
Message tempMsg = ((Message) msg[i].get(key));
if(tempMsg==null){
sb.append("\r\n");
sb.append(lpad(msgMap.get(key).toString()+":",20,' '));
sb.append(lpad("0" ,15,' '));
sb.append(lpad(String.valueOf(0) ,15,' '));
sb.append(lpad("0" ,15,' '));
sb.append(lpad("0" ,15,' '));
// 统计
statMsg[msgNo]=new StatMsg();
// System.out.println("key.intValue():"+key.intValue());
statMsg[msgNo].setIMsgNo(key.intValue());
statMsg[msgNo].setIAllNumRecv(0);
statMsg[msgNo].setIAllNumRecvFail(0);
statMsg[msgNo].setIAllNumRecvSucc(0);
statMsg[msgNo].setIAllNumSend(0);
statMsg[msgNo].setIAllNumSendFail(0);
statMsg[msgNo].setIAllNumSendSucc(0);
statMsg[msgNo].setILastNumRecv(0);
statMsg[msgNo].setILastNumRecvFail(0);
statMsg[msgNo].setILastNumRecvSucc(0);
statMsg[msgNo].setILastNumSend(0);
statMsg[msgNo].setILastNumSendFail(0);
statMsg[msgNo].setILastNumSendSucc(0);
msgNo++;
//--
continue;
}
int receCounter = tempMsg.receCounter;
int sendCounter = tempMsg.sendCounter;
int lastRece = receCounter - tempMsg.lastRece;
int lastSend = sendCounter - tempMsg.lastSend;
tempMsg.lastRece=receCounter;
tempMsg.lastSend=sendCounter;
//
sb.append("\r\n");
sb.append(lpad(msgMap.get(key).toString(),20,' '));
sb.append(lpad(String.valueOf(lastRece) ,15,' '));
sb.append(lpad(String.valueOf(receCounter) ,15,' '));
sb.append(lpad(String.valueOf(lastSend) ,15,' '));
sb.append(lpad(String.valueOf(sendCounter) ,15,' '));
//统计
statMsg[msgNo]=new StatMsg();
statMsg[msgNo].setIMsgNo(key.intValue());
statMsg[msgNo].setIAllNumRecv(receCounter);
statMsg[msgNo].setIAllNumRecvFail(0);
statMsg[msgNo].setIAllNumRecvSucc(receCounter);
statMsg[msgNo].setIAllNumSend(sendCounter);
statMsg[msgNo].setIAllNumSendFail(0);
statMsg[msgNo].setIAllNumSendSucc(sendCounter);
statMsg[msgNo].setILastNumRecv(lastRece);
statMsg[msgNo].setILastNumRecvFail(0);
statMsg[msgNo].setILastNumRecvSucc(lastRece);
statMsg[msgNo].setILastNumSend(lastSend);
statMsg[msgNo].setILastNumSendFail(0);
statMsg[msgNo].setILastNumSendSucc(lastSend);
msgNo++;
}
// 统计
statRst.setStatMsg(statMsg);
statRst.setIReserved1(0);
statRst.setIReserved2(0);
//System.out.println(statRst.toString());
ByteBuffer bf =ByteBuffer.allocate(statRst.getCommandLength());
statRst.writeMsg(bf);
byte[] arr=bf.array();
try {
udpClient.sendMsg(arr);
} catch (Exception e) {
e.printStackTrace();
}
}
return sb.toString();
}*/
public String toString() {
StringBuffer sb = new StringBuffer(300);
sb.append(title);
sb.append(":");
for (int i = 0; i < msg.length; i++) {
if (msg[i].size() == 0) {
continue;
}
sb.append("\r\nID:" + i);
sb.append("\r\n" );
sb.append(lpad("msg type",20,' '));
sb.append(lpad("last receive",15,' '));
sb.append(lpad("receive count",15,' '));
sb.append(lpad("last send" ,15,' '));
sb.append(lpad("send count",15,' '));
Iterator iterator = msgMap.keySet().iterator();
while (iterator.hasNext()) {
Integer key = (Integer) iterator.next();
Message tempMsg = ((Message) msg[i].get(key));
if(tempMsg==null){
sb.append("\r\n");
sb.append(lpad(msgMap.get(key).toString()+":",20,' '));
sb.append(lpad("0" ,15,' '));
sb.append(lpad(String.valueOf(0) ,15,' '));
sb.append(lpad("0" ,15,' '));
sb.append(lpad("0" ,15,' '));
continue;
}
int receCounter = tempMsg.receNum;
int sendCounter = tempMsg.sendNum;
int lastRece = tempMsg.lastRece;
int lastSend = tempMsg.lastSend;
//
sb.append("\r\n");
sb.append(lpad(msgMap.get(key).toString(),20,' '));
sb.append(lpad(String.valueOf(lastRece) ,15,' '));
sb.append(lpad(String.valueOf(receCounter) ,15,' '));
sb.append(lpad(String.valueOf(lastSend) ,15,' '));
sb.append(lpad(String.valueOf(sendCounter) ,15,' '));
}
}
return sb.toString();
}
public static String lpad(String s,int length,char c){
String result =s;
int count =length -s.length();
for(int i=0;i<count;i++){
result += c;
}
return result;
}
public static void main(String[] args)throws Exception{
MessageCount mc = getSmscMsgCount();
while(true){
// System.out.println(mc);
for(int i=0;i<1000;i++){
mc.incrementReceive(2,0x80006004);
mc.incrementSend(2,0x6004);
}
Thread.sleep(1000);
}
// System.out.println(new Integer(-2147459068).intValue());
}
public int getModuleNo() {
return moduleNo;
}
public void setModuleNo(int moduleNo) {
this.moduleNo = moduleNo;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -