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

📄 resendmonthmessage.java

📁 SP最新短信计费系统
💻 JAVA
字号:
package com.sungoal.charge;

import java.sql.*;
import javax.sql.RowSet;
import com.sungoal.database.*;

import com.sungoal.sms.message.MTInfo;
import com.sungoal.sms.util.MySocket;
import com.sungoal.sms.message.MTAck;
import com.sungoal.sms.common.*;

/** 功能:包月用户收费,不定期执行,对包月收费失败的订阅重试扣费.*/

public class ReSendMonthMessage {

  /*内部类启动多线程,对相应网关用户收费*/
  class SendEachGateway
      extends Thread {
    int gateway = 0;
    String strSQL = "";
    public SendEachGateway(int gateway) { //构造函数
      this.gateway = gateway;

      /*不定期执行收费,条件:
       1) 本月收费没返回状态报告及错误状态报告的订阅.
       2) 一些免费代码.
       */
      /*CMPP(中国移动)协议的字段值.*/
      int isSMT=2;
      String rightReport ="DELIVRD";
      if(gateway==7 )
      {
        /*SGIP(中国联通)协议的字段值.*/
        isSMT = 3;
        rightReport = "0";
      }

      strSQL =
          "select Distinct PRODUCTID,RECNUM as phoneno,GATEWAY,REPORT from mtrecord_stat"
          + " where issmt="+isSMT
          + " And ENDTIME>=to_date(to_char(SYSDATE,'yyyy-mm'),'yyyy-mm')"
//          + " And PRODUCTID!=226 And ENDTIME>=to_date('2004-03-01','yyyy-mm-dd')"
          + " and report!='"+rightReport+"'"
          + " And STATUS!=-1"
          + " and GATEWAY='" + gateway+"'";
      System.out.println("strSQL:" + strSQL);
    }

    public void run() {
      try {
        RowSet rs = DBManager.executeQuery(strSQL);
        while (rs.next()) {
          MTInfo mtInfo = new MTInfo();
          //MTMethods.sendSMC(gateway,rs.getString("phoneno"),rs.getInt("PRODUCTID"));
          mtInfo.destPhone.add(rs.getString("phoneno"));
          mtInfo.srcPhone = "";
          mtInfo.gateway = gateway;
          mtInfo.productID = rs.getInt("PRODUCTID");

          mtInfo.content = "SMC";
          mtInfo.registededDelivery = 2;
          Thread.sleep(2);
          MTAck mtack = (MTAck) MySocket.sendMsg(mtInfo, 0);
          System.out.println(gateway + "\t" + rs.getInt("PRODUCTID") + "\t"+
                             rs.getString("phoneno") + '\t'
                             //);
                             + mtack.getStatus());
        }
        System.out.println("网关收费总数:\t" + gateway + "\t" + rs.getRow());
        rs.close();
      }
      catch (Exception e) {
        e.printStackTrace();
      }
    }
  }

  /**依次对各网关启动线程*/
  public void sendMain() {
    SendEachGateway sendEachGateway = null;

    for (int i = 1; i <= 7; i++) {
      //if (i != 3 && i != 6)
      {

        sendEachGateway = new SendEachGateway(i);
        sendEachGateway.start();
      }
    }
  }

  public static void main(String[] args) {
    ReSendMonthMessage sendMonthMessage = new ReSendMonthMessage();
    sendMonthMessage.sendMain();
  }
}

⌨️ 快捷键说明

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