int MonitorFlow::MonitorVirement(int iBillingCycleID,int mStart) { if (!m_bConnect) { getDefaultLogin(); m_bConnect = true; } char sSql[1024]; Date runDate; long m_StatID = getNextStatSeq(); try{ if(mStart == 1 ) { char temp_DIMENSIONS[128]; sprintf(temp_DIMENSIONS,"JF_CZ_FW_04;%d",iBillingCycleID); TOCIQuery qry(&gpDBLinkMF); sprintf(sSql, " select count(*) cnt from stat_interface " " where kpi_code = '%s' and substr(dimensions,0,18) = '%s'","JF_FLOW_CZ_TIME",temp_DIMENSIONS); qry.setSQL( sSql ); qry.open();qry.next(); int m_Cnt = qry.field(0).asInteger();//这里简单的从表里面取锁了 if ( m_Cnt > 0) { qry.close(); return 0; } sprintf(m_DIMENSIONS,"JF_CZ_FW_04;%d;%s;1;%s",iBillingCycleID,m_sAreaCode,runDate.toString()); sprintf(sSql, " insert into stat_interface(stat_id,kpi_code,value,stat_begin_date,stat_end_date,state, " " area_code,create_date,deal_flag,module_id,dimensions, " " dimension_flag,stat_date_flag,db_source_id) " " values(%d, '%s', '1', sysdate, sysdate, '0', '%s', sysdate, 1, 1, '%s', 1, 2, 1)", m_StatID,"JF_FLOW_CZ_TIME",m_sAreaCode,m_DIMENSIONS); qry.close(); qry.setSQL(sSql); qry.execute(); qry.commit(); qry.close(); return 0; } else if (mStart == 2) { sleep(1); int cnt = -2; //redirectDB ("BILL"); //需要连到计费库 if ( (strcmp(m_sAreaCode,"0513") != 0) && (strcmp(m_sAreaCode,"0511") != 0 ) ) //南通镇江特殊处理 { DEFINE_QUERY (qry) ; sprintf(sSql,"select count(*) cnt from b_redo_log where CUR_STATUS_ID <> 2 and INT_PARAM1 = %d",iBillingCycleID); qry.setSQL(sSql); qry.open(); qry.next(); cnt = qry.field(0).asInteger(); qry.close(); } if(cnt > 0) { return 0; } else { sprintf(m_DIMENSIONS,"JF_CZ_FW_04;%d;%s;2;%s",iBillingCycleID,m_sAreaCode,runDate.toString()); char sSql[1024]; TOCIQuery qry1(&gpDBLinkMF); sprintf(sSql, " insert into stat_interface(stat_id,kpi_code,value,stat_begin_date,stat_end_date,state, " " area_code,create_date,deal_flag,module_id,dimensions, " " dimension_flag,stat_date_flag,db_source_id) " " values(%d, '%s', '1', sysdate, sysdate, '0', '%s', sysdate, 1, 1, '%s', 1, 2, 1)", m_StatID,"JF_FLOW_CZ_TIME",m_sAreaCode,m_DIMENSIONS); qry1.setSQL(sSql); qry1.execute(); qry1.commit(); qry1.close(); } } return 0; } catch (...) { cout << "执行insert into stat_interface错误,检查统计库表" << endl; } }
void MyClient::readyRead(){ QStringList list; QString temp=this->socket->readAll(); qDebug()<<temp; try{ list = temp.split(this->splitstring); }catch(...){ } if(list.length()>=3&&(list.length()%3-1==0)){ if(!this->logincheck){ if(!logincheckf(list[1],list[2])){ QByteArray Buffer; Buffer.append("0"+this->splitstring+"Login Fail"+this->splitstring+"waat"+this->splitstring); this->socket->write(Buffer); this->socket->close(); }else{ this->logincheck=true; QByteArray Buffer; Buffer.append("0"+this->splitstring+"Login Successful!"+this->splitstring+"waat"+this->splitstring); this->socket->write(Buffer); //this->msgchekertimer->start(10000); if(this->db->isOpen()){ }else{ this->db->open(); } QSqlQuery qry1(*db); QString query; query = "SELECT count(*) FROM `online_user` WHERE `name`='"+this->cname+"'"; qry1.exec(query); qry1.first(); if(qry1.value(0)==0){ QSqlQuery qry(*db); QString query_1; query_1 = "INSERT INTO `online_user`( `name`) VALUES ('"+this->cname+"')"; qry.exec(query_1); } } }else{ for(int x=0;(list.length()/3)>x;x++){ if(list[0+x*3]=="10"){ taske10(list[1+x*3]); } } } }else{ this->socket->close(); } }