CollIVRServer.java 17.1 KB
package com.sitech.ismp.coll.i2000;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;

import org.apache.log4j.Logger;

import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import com.sitech.ismp.coll.i2000.db.nmsguest.CTINECONNECT;
import com.sitech.ismp.coll.i2000.db.nmsguest.CTINECONNECTDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CRM_ACCEPT;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CRM_ACCEPTDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CRM_ADVICE;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CRM_ADVICEDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CRM_BOOKING;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CRM_BOOKINGDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CRM_ISSUE;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CRM_ISSUEDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CRM_QUERY;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CRM_QUERYDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_AGCTR;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_AGCTRDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_AGHPSUM;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_AGHPSUMDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_IVRCINF;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_IVRCINFDao;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_IVRCTR;
import com.sitech.ismp.coll.i2000.db.nmsguest.TBL_PERF_CTI_IVRCTRDao;

public class CollIVRServer implements CollIVRServerMBean{
	Logger logger = Logger.getLogger("I2000");
	//private String current_unit_id = "test_unit_id";
	private String current_unit_id = "01-17-12";
	
	public Vector getPerformance_One_Minute(HashMap params)throws Exception
	{
		Vector collResult = new Vector();
		String DevIPAddr = (String)params.get("DevIPAddr");
		Integer devip =new Integer(Integer.parseInt(DevIPAddr));
		HashMap params1 = new HashMap();
		params1.put("devip",devip);
		logger.info("= CollIVRServer getPerformance_One_Minute = ");
		//PM-02-17-012-01	����״̬	�������ڲ����ʱIVR��ϵͳ�������м��������֮�������״̬	1����	
		//CTINeConnect��cnstat�ֶ�,������豸nodeid��Ϣ���Դ�nodeid�л�ȡ
		//lianlian 2006-11-12
		
		CTINECONNECTDao ctineconnectdao = new CTINECONNECTDao();
		List list_ctineconnectdao = ctineconnectdao.getCTILINKSTATUS();
		if(list_ctineconnectdao==null||list_ctineconnectdao.size()==0)
		{
			System.out.println("@i2000 error, no getCTILINKSTATUS info got by i2000 in CollIVRServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_ctineconnectdao.size();i++)
			{
				CTINECONNECT obj = (CTINECONNECT)list_ctineconnectdao.get(i);
				String nodeid = obj.getNODEID();
				String cnnodeid = obj.getCNNODEID();
				String cnstat = obj.getCNSTAT();
				this.setResult(collResult,current_unit_id + ":" + nodeid + "-" + cnnodeid,"PM-02-17-012-01",cnstat,new Date());
			}
		}
		
		
		//PM-02-17-014-01	��ǰ���еȴ����	�ڲ����ʱ�ͻ������˹����񣬴����Ŷ�״̬��δ��ͨ�ĺ��и������	1����
		//tbl_perf_cti_aghpsum��callwaitnums
		//lianlian 2006-11-13
		TBL_PERF_CTI_AGHPSUMDao tbl_perf_cti_aghpsumdao = new TBL_PERF_CTI_AGHPSUMDao();
		List list_aghpsumdao = tbl_perf_cti_aghpsumdao.getCURRENTCALLWAITNUMS();
		if(list_aghpsumdao==null||list_aghpsumdao.size()==0)
		{
			logger.error("@i2000 error, no getCURRENTCALLWAITNUMS info got by i2000 in CollIVRServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_aghpsumdao.size();i++)
			{
				TBL_PERF_CTI_AGHPSUM obj = (TBL_PERF_CTI_AGHPSUM)list_aghpsumdao.get(i);
				int intdevip = obj.getDEVIP();
				int vdnid = obj.getVDNID();
				int subccno = obj.getSUBCCNO();
				int callwaitnums = obj.getCALLWAITNUMS();
				Date time = obj.getTIME();
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + vdnid + "-" + subccno,"PM-02-17-014-01",String.valueOf(callwaitnums),time);
			}
		}
		
		return collResult;
	}
	public Vector getPerformance_One_Hour(HashMap params)throws Exception
	{
		Vector collResult = new Vector();
		String DevIPAddr = (String)params.get("DevIPAddr");
		Integer devip =new Integer(Integer.parseInt(DevIPAddr));
		HashMap params1 = new HashMap();
		params1.put("devip",devip);
		
		//PM-02-17-012-02	����ɹ���	��һ������������IVR�ڴ������ʱ�ijɹ��ʣ�100%��	1Сʱ
		//tbl_perf_cti_ivrcinf��100*connectednum/incallnum(���Ծ�ȷ��ij��Vdn���,�������ı��),��λΪ%
		//lianlian 2006-11-12
		logger.info("= CollIVRServer getPerformance_One_Hour = ");
		TBL_PERF_CTI_IVRCINFDao ctiivrcinfdao = new TBL_PERF_CTI_IVRCINFDao();
		List list_ctiivrcinfdao = ctiivrcinfdao.getDISPOSALSUCCESS();
		if(list_ctiivrcinfdao==null||list_ctiivrcinfdao.size()==0)
		{
			System.out.println("@i2000 error, no getDISPOSALSUCCESS info got by i2000 in CollIVRServer "+new Date());
		}
		else
		{
			int intresult = 0;
			for(int i=0;i<list_ctiivrcinfdao.size();i++)
			{
				TBL_PERF_CTI_IVRCINF obj = (TBL_PERF_CTI_IVRCINF)list_ctiivrcinfdao.get(i);
				int intdevip = obj.getDEVIP();
				int vdnid = obj.getVDNID();
				int subccno = obj.getSUBCCNO();
				int connectednum = obj.getCONNECTEDNUM();
				int incallnum = obj.getINCALLNUM();
				if(incallnum>0)
				{
					intresult = 100*connectednum/incallnum;
				}
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + vdnid + "-" + subccno,"PM-02-17-012-02",String.valueOf(intresult),new Date());
			}
		}
		
		//PM-02-17-013-01	��ǰ������	��һ������������IVR�ϱ��к���Ϊ1860/1861�ĺ��������	1Сʱ
		//tbl_perf_cti_ivrctr��autoincallnum
		//PM-02-17-013-02	��ǰ��ͨ��	��һ������������IVR�ϱ��к���Ϊ1860/1861�Ľ�ͨ�ʣ�100%��	1Сʱ
		//tbl_perf_cti_ivrctr��100*autoansnum/autoincallnum ���%
		//lianlian 2006-11-13
		
		TBL_PERF_CTI_IVRCTRDao tbl_perf_cti_ivrctrdao = new TBL_PERF_CTI_IVRCTRDao();
		List list_ivrctrdao = tbl_perf_cti_ivrctrdao.getCURRENTAUTOCALLCOUNT();
		if(list_ivrctrdao==null||list_ivrctrdao.size()==0)
		{
			logger.error("@i2000 error, no getCURRENTAUTOCALLCOUNT info got by i2000 in CollIVRServer "+new Date());
		}
		else
		{
			int intvalue = 0;
			for(int i=0;i<list_ivrctrdao.size();i++)
			{
				TBL_PERF_CTI_IVRCTR obj = (TBL_PERF_CTI_IVRCTR)list_ivrctrdao.get(i);
				int intdevip = obj.getDEVIP();
				int vdnid = obj.getVDNID();
				int subccno = obj.getSUBCCNO();
				int autoincallnum = obj.getAUTOINCALLNUM();
				int autoansnum = obj.getAUTOANSNUM();
				Date time = obj.getTIME();
				if(autoincallnum>0)
				{
					intvalue = 100*autoansnum/autoincallnum;
				}
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + vdnid + "-" + subccno,"PM-02-17-013-01",String.valueOf(autoincallnum),time);
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + vdnid + "-" + subccno,"PM-02-17-013-02",String.valueOf(intvalue),time);
			}
		}
		
		//PM-02-17-014-02	��ǰ������	��һ�����������ڣ��ۼƵ������˹�������������	1Сʱ
		//tbl_perf_cti_agctr��connectednum+calllostnum
		//PM-02-17-014-03	��ͨ��	��һ�����������������˹�������еĽ�ͨ�ʣ�100%��	1Сʱ
		//tbl_perf_cti_agctr�� 100*connectednum/(connectednum+calllostnum),��λΪ%  
		//lianlian 2006-11-13
		
		TBL_PERF_CTI_AGCTRDao tbl_perf_cti_agctrdao = new TBL_PERF_CTI_AGCTRDao();
		List list_agctrdao = tbl_perf_cti_agctrdao.getMANUALCALLCOUNT();
		if(list_agctrdao==null||list_agctrdao.size()==0)
		{
			logger.error("@i2000 error, no getMANUALCALLCOUNT info got by i2000 in CollIVRServer "+new Date());
		}
		else
		{
			int callnum = 0;
			int switch_on = 0;
			for(int i=0;i<list_agctrdao.size();i++)
			{
				TBL_PERF_CTI_AGCTR obj = (TBL_PERF_CTI_AGCTR)list_agctrdao.get(i);
				int intdevip = obj.getDEVIP();
				int vdnid = obj.getVDNID();
				int subccno = obj.getSUBCCNO();
				int connectednum = obj.getCONNECTEDNUM();
				int calllostnum = obj.getCALLLOSTNUM();
				Date time = obj.getTIME();
				callnum = connectednum+calllostnum;
				if(callnum>0)
				{
					switch_on = 100*connectednum/callnum;
				}
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + vdnid + "-" + subccno,"PM-02-17-014-02",String.valueOf(callnum),time);
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-" + vdnid + "-" + subccno,"PM-02-17-014-03",String.valueOf(switch_on),time);
			}
		}
		
		return collResult;
	}
	
	
	public Vector getPerformance_One_Day(HashMap params)throws Exception
	{
		Vector collResult = new Vector();
		String DevIPAddr = (String)params.get("DevIPAddr");
		Integer devip =new Integer(Integer.parseInt(DevIPAddr));
		HashMap params1 = new HashMap();
		params1.put("devip",devip);
		logger.info("= CollIVRServer getPerformance_One_Day = ");
		//PM-02-17-016-01	�ͻ���ѯ������	һ�����������ڣ��ͻ���ѯҵ��������	1��
		//tbl_perf_crm_query��querynumber
		//lianlian 2006-11-13
		TBL_PERF_CRM_QUERYDao tbl_perf_crm_querydao = new TBL_PERF_CRM_QUERYDao();
		List list_querydao = tbl_perf_crm_querydao.getCUSTOMERQUERYINFO();
		//û��selectȨ�ޣ�������Ȩ�޿���ֱ��ʹ��
		if(list_querydao==null||list_querydao.size()==0)
		{
			System.out.println("@i2000 error, no getCUSTOMERQUERYINFO info got by i2000 in CollIVRServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_querydao.size();i++)
			{
				TBL_PERF_CRM_QUERY obj = (TBL_PERF_CRM_QUERY)list_querydao.get(i);
				int intdevip = obj.getDEVIP();
				int querynumber = obj.getQUERYNUMBER();
				Date time = obj.getTIME();
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-016-01",String.valueOf(querynumber),time);
			}
		}
		
		//PM-02-17-017-01	ҵ��������	һ�����������ڣ�1860��1861����ҵ��ı������	1��
		//tbl_perf_crm_accept��acceptnumber
		//lianlian 2006-11-13
		TBL_PERF_CRM_ACCEPTDao tbl_perf_crm_acceptdao = new TBL_PERF_CRM_ACCEPTDao();
		List list_acceptdao = tbl_perf_crm_acceptdao.getCRMACCEPT();
		//û��selectȨ�ޣ�������Ȩ�޿���ֱ��ʹ�á�
		if(list_acceptdao==null||list_acceptdao.size()==0)
		{
			System.out.println("@i2000 error, no getCRMACCEPT info got by i2000 in CollIVRServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_acceptdao.size();i++)
			{
				TBL_PERF_CRM_ACCEPT obj = (TBL_PERF_CRM_ACCEPT)list_acceptdao.get(i);
				int intdevip = obj.getDEVIP();
				int acceptnumber = obj.getACCEPTNUMBER();
				Date time = obj.getTIME();
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-017-01",String.valueOf(acceptnumber),time);
			}
		}
		
		//PM-02-17-018-01	�ɵ������	һ�����������ڣ����ܵĿͻ�Ͷ���뽨��������	1��
		//tbl_perf_crm_advice��advicesend
		//PM-02-17-018-02	�ɵ��ظ���	һ�����������ڣ��ɳ�ȥ�Ĺ����ظ�����������	1��
		//tbl_perf_crm_advice��advicereturn
		//lianlian 2006-11-13
		TBL_PERF_CRM_ADVICEDao tbl_perf_crm_advicedao = new TBL_PERF_CRM_ADVICEDao();
		List list_advicedao = tbl_perf_crm_advicedao.getCRMADVICE();
		//û��selectȨ�ޣ�������Ȩ�޿���ֱ��ʹ�á�
		if(list_advicedao==null||list_advicedao.size()==0)
		{
			System.out.println("@i2000 error, no getCRMADVICE info got by i2000 in CollIVRServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_advicedao.size();i++)
			{
				TBL_PERF_CRM_ADVICE obj = (TBL_PERF_CRM_ADVICE)list_advicedao.get(i);
				int intdevip = obj.getDEVIP();
				int advicesend = obj.getADVICESEND();
				int advicereturn = obj.getADVICERETURN();
				Date time = obj.getTIME();
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-018-01",String.valueOf(advicesend),time);
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-018-02",String.valueOf(advicereturn),time);
			}
		}
		
		//PM-02-17-019-01	ԤԼ������	һ�����������ڣ�����ԤԼ����Ĵ������	1��
		//tbl_perf_crm_booking��bookingacc
		//PM-02-17-019-02	ԤԼ�ɵ���	һ�����������ڣ�ԤԼ������ɳ���������������	1��
		//tbl_perf_crm_booking��bookingsend
		//PM-02-17-019-03	ԤԼ�ظ���	һ�����������ڣ�ԤԼ�����ɳ������Ļظ���������	1��
		//tbl_perf_crm_booking��bookingreturn
		//lianlian 2006-11-13
		TBL_PERF_CRM_BOOKINGDao tbl_perf_crm_bookingdao = new TBL_PERF_CRM_BOOKINGDao();
		List list_bookingdao = tbl_perf_crm_bookingdao.getCRMBOOKING();
		//û��selectȨ�ޣ�������Ȩ�޿���ֱ��ʹ�á�
		if(list_bookingdao==null||list_bookingdao.size()==0)
		{
			logger.error("@i2000 error, no getCRMBOOKING info got by i2000 in CollIVRServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_bookingdao.size();i++)
			{
				TBL_PERF_CRM_BOOKING obj = (TBL_PERF_CRM_BOOKING)list_bookingdao.get(i);
				int intdevip = obj.getDEVIP();
				int bookingacc = obj.getBOOKINGACC();
				int bookingsend = obj.getBOOKINGSEND();
				int bookingreturn = obj.getBOOKINGRETURN();
				Date time = obj.getTIME();
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-019-01",String.valueOf(bookingacc),time);
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-019-02",String.valueOf(bookingsend),time);
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-019-03",String.valueOf(bookingreturn),time);
			}
		}
		
		//PM-02-17-020-01	��Ϣ������	��һ�����������ڣ���������Ϣ��������	1��
		//tbl_perf_crm_issue��issuesend
		//PM-02-17-020-02	����Ϣ��	�ڲ����ʱ���ȴ����Ϣ��������	1��
		//tbl_perf_crm_issue��issuewaitting
		//PM-02-17-020-03	������Ϣ����	��һ���ڷ�����Ϣ������������	1��
		//tbl_perf_crm_issue��sendall
		//lianlian 2006-11-13
		TBL_PERF_CRM_ISSUEDao tbl_perf_crm_issuedao = new TBL_PERF_CRM_ISSUEDao();
		List list_issuedao = tbl_perf_crm_issuedao.getCRMISSUE();
		//û��selectȨ�ޣ�������Ȩ�޾Ϳ���ֱ��ʹ�á�
		if(list_issuedao==null||list_issuedao.size()==0)
		{
			System.out.println("@i2000 error, no getCRMISSUE info got by i2000 in CollIVRServer "+new Date());
		}
		else
		{
			for(int i=0;i<list_issuedao.size();i++)
			{
				TBL_PERF_CRM_ISSUE obj = (TBL_PERF_CRM_ISSUE)list_issuedao.get(i);
				int intdevip = obj.getDEVIP();
				int issuesend = obj.getISSUESEND();
				int issuewaitting = obj.getISSUEWAITTING();
				int sendall = obj.getSENDALL();
				Date time = obj.getTIME();
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-020-01",String.valueOf(issuesend),time);
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-020-02",String.valueOf(issuewaitting),time);
				this.setResult(collResult,current_unit_id + ":" + intdevip + "-total","PM-02-17-020-03",String.valueOf(sendall),time);
			}
		}
		return collResult;
	}
	public Vector getConfiguration(HashMap params)throws Exception
	{
		Vector collResult = new Vector();
		return collResult;
	}
	
	private void setResult(Vector result,  String unitID, String kpiID , String value,Date cll_time) {
		try {
			TblATO_KPIDETAIL record;
			record = new TblATO_KPIDETAIL();
			record.setCLL_TIME(new Date());
			record.setKPI_ID(kpiID);
			record.setKPI_VALUE(value);
			record.setUNIT_ID(unitID);
			record.setCLL_TIME(cll_time);
			result.add(record);
		} catch (Exception e) {

			e.printStackTrace();
		}
	}
	
	public static void main(String args[])throws Exception
	{
		String DevIPAddr = "1000";
		HashMap params = new HashMap();
		params.put("DevIPAddr",DevIPAddr);
		Vector collResult = new Vector();
		CollIVRServer aa = new CollIVRServer();
		CollIVRServerMBean MBean = new CollIVRServer();
		collResult.addAll(MBean.getPerformance_One_Minute(params));
		collResult.addAll(MBean.getPerformance_One_Hour(params));
		collResult.addAll(MBean.getPerformance_One_Day(params));
		aa.logger.info("= main = ");
		String temp [][] = CheckKPIHelper.CheckIVRServerKPI(collResult);
		for(int i=0;i<temp.length;i++)
		{
			System.out.println("KPI_ID : " + temp[i][0] + "---" + temp[i][1]);
		}
		
		//String filename = "IVRServerKPIValue.xls";
		//CheckKPIHelper.WriteKPIValue2File(collResult,filename);
	}
}