void CInlineQueData::GetCandoQueHaveData(CStringArray& queIDArray,const CStringArray& canDoQueIDArray,UINT uWndID) { int count = canDoQueIDArray.GetCount(); for(int i = 0; i < count; i++) { CString candoQueID = canDoQueIDArray[i]; POSITION pos = m_lstInlineQue.GetHeadPosition(); while(pos) { SLZData data; POSITION posLast = pos; data = m_lstInlineQue.GetNext(pos); if(data.GetWindowId()==0)//如果没设置指定窗口 { if(candoQueID.Compare(data.GetBussinessType()) == 0) { queIDArray.Add(candoQueID); break; } } else//设置了指定窗口 { if(uWndID == data.GetWindowId()) { queIDArray.Add(data.GetBussinessType()); break; } } } } }
CString CProducePacket::ProduceSendPacket(const SLZData& data,int leftNum,SendDataType dataType,CString cardNum/* =_T */,CardType cardType/*cardNotDefine*/) { CString packet = _T("<?xml version=\"1.0\" encoding=\"UTF-8\"?><dataPacket version=\"1.0\"><headCode>hallQue</headCode>"); packet.AppendFormat(_T("<dataType>%d</dataType>"),dataType); packet.AppendFormat(_T("<orgName>%s</orgName>"),data.GetOrganName()); packet.AppendFormat(_T("<orgID>%s</orgID>"),data.GetOrganId()); packet.AppendFormat(_T("<cardType>%d</cardType>"),cardType); packet.AppendFormat(_T("<cardNum>%s</cardNum>"),cardNum); packet.AppendFormat(_T("<queID>%s</queID>"),data.GetBussinessType()); packet.AppendFormat(_T("<queNum>%s</queNum>"),data.GetQueueNumber()); CString wStrtakeNumTime = ExChangeTime(data.GetTakingNumTime()); packet.AppendFormat(_T("<enterTime>%s</enterTime>"),wStrtakeNumTime); CString wStrCallTime = ExChangeTime(data.GetCallTime()); packet.AppendFormat(_T("<callTime>%s</callTime>"),wStrCallTime); packet.AppendFormat(_T("<workerID>%s</workerID>"),data.GetStaffId()); packet.AppendFormat(_T("<windowNum>%d</windowNum>"),data.GetWindowId()); CString wStrFinishTime = ExChangeTime(data.GetFinishTime()); packet.AppendFormat(_T("<scoreTime>%s</scoreTime>"),wStrFinishTime); packet.AppendFormat(_T("<scoreLev>%d</scoreLev>"),data.GetEvaluateLevel()); // int len = CCommonConvert::CStringToChar(packet,NULL); // char* strPacket = new char[len+1]; // memset(strPacket,0,len+1); // CCommonConvert::CStringToChar(packet,strPacket); // std::string stdStrPacket(strPacket); // return stdStrPacket; return packet; }
void CCallThread::DoEvaMsg(const MSG& msg) { SLZEvaData* pEvaData = (SLZEvaData*)msg.wParam; SLZWindow Window; BOOL flag = m_rInlineQueData.m_rWindowTable.QueryWindowByEvaId(pEvaData->GetEvaluatorId(),Window); if(flag) { SLZData data; //找出正在呼叫的那条数据 if(m_rCalledQueData.GetCalledQueData(Window.GetWindowId(),data)) { data.SetEvaluateLevel(pEvaData->GetEvaLevel()); data.SetIsFinshEva(TRUE); CTime curTime = CTime::GetCurrentTime(); data.SetFinishTime(curTime); if(m_rCalledQueData.DeleteCalledQueData(data))//删除正在呼叫的那条数据 { m_rFinshQueData.Add(data);//加入完成队列 } } else//不呼叫只评价 { data.SetEvaluateLevel(pEvaData->GetEvaLevel()); data.SetIsFinshEva(TRUE); CTime curTime = CTime::GetCurrentTime(); data.SetFinishTime(curTime); data.SetWindowId(Window.GetWindowId()); data.SetWindowShowId(Window.GetShowWndId()); CString staffID = m_map_login[Window.GetWindowId()]; data.SetStaffId(staffID); CString bussinessType; /* 处理业务ID */ SLZWindow window; m_rInlineQueData.m_rWindowTable.QueryWindowById(data.GetWindowId(),window); CStringArray arrayQueID; window.GetArrayQueId(arrayQueID); if(!arrayQueID.IsEmpty()) { bussinessType = arrayQueID[0]; } else { CMap<int,int,CQueueInfo,CQueueInfo&>::CPair* pCurEva; int count = m_map_que.GetCount(); for(int i=0;i<count;i++) { pCurEva = m_map_que.PLookup(i); bussinessType = pCurEva->value.GetQueID(); break; } } //////////////////////////////// data.SetBussinessType(bussinessType); data.SetOrganId(theApp.m_logicVariables.strOrganID); data.SetOrganName(theApp.m_logicVariables.strOrganNmae); // data.SetQueSerialID(_T("1")); data.SetQueueNumber(_T("0")); data.SetCallTime(curTime); data.SetTakingNumTime(curTime); m_rFinshQueData.Add(data);//加入完成队列 } } if(pEvaData)//释放资源 delete pEvaData; }
BOOL CInlineQueData::DeleteInlineClientData(BOOL bIsUsePower,const CStringArray& queIDArray,const CString& organId,SLZData* pData) { m_mtInlineQue.Lock(); BOOL flag = FALSE; if(bIsUsePower) { if(queIDArray.GetCount() < 1) { return FALSE; } int count = queIDArray.GetCount(); for(int i = 0; i < count; i++) { POSITION pos = m_lstInlineQue.GetHeadPosition(); while(pos) { SLZData data; POSITION posLast = pos; data = m_lstInlineQue.GetNext(pos); if(data.GetWindowId()==0)//如果没设置指定窗口 { if(queIDArray[i].Compare(data.GetBussinessType()) == 0) { flag = TRUE; *pData = data; m_lstInlineQue.RemoveAt(posLast); break; } } } if(flag) { break; } } } else { /* /////////////////////////////////////////首先找到可处理队列中哪几个队列有数据 CStringArray haveDataArray; GetCandoQueHaveData(haveDataArray,queIDArray); if(haveDataArray.GetCount() == 0) { return FALSE; } /////////////////////////////////////////随机取数 int count = haveDataArray.GetCount(); time_t t; srand((unsigned) time(&t)); int nRand = rand() % count; CString strQueID = haveDataArray[nRand]; POSITION pos = m_lstInlineQue.GetHeadPosition(); while(pos) { SLZData data; POSITION posLast = pos; data = m_lstInlineQue.GetNext(pos); if(data.GetWindowId()==0)//如果没设置指定窗口 { if(strQueID.Compare(data.GetBussinessType()) == 0) { *pData = data; m_lstInlineQue.RemoveAt(posLast); flag = TRUE; break; } } } */ flag = GetFirstTakeNumData(*pData,queIDArray); if(flag) flag = RemoveFirstTakeNumData(*pData); } m_mtInlineQue.Unlock(); return flag; }
/* 获取排队 队列首个数据 */ BOOL CInlineQueData::GetInlineQueData(const UINT iWinId, SLZData& rdata) { if(m_lstInlineQue.GetCount() < 1) { return FALSE; } CStringArray arrStrQueId;//可处理队列以及优先级 SLZWindow Window; BOOL flag = m_rWindowTable.QueryWindowById(iWinId,Window); if(!flag)return FALSE; BOOL bIsUserPower = Window.GetIsUsePower();//是否使用优先级 Window.GetArrayQueId(arrStrQueId);//获取可处理队列及优先级 CString staffID = theApp.m_Controller.m_mapLoginList[Window.GetWindowId()];//获取登录STAFFID if(staffID.IsEmpty())return FALSE; if(arrStrQueId.GetCount() < 1) { return FALSE; } /////////////////////// BOOL bFind = FALSE; m_mtInlineQue.Lock(); if(bIsUserPower)//使用优先级 { int count = arrStrQueId.GetCount(); for(int i = 0; i < count; i++) { POSITION pos = m_lstInlineQue.GetHeadPosition(); while(pos) { SLZData data; POSITION posLast = pos; data = m_lstInlineQue.GetNext(pos); if(data.GetWindowId()==0)//如果没设置指定窗口 { if(arrStrQueId[i].Compare(data.GetBussinessType()) == 0) { bFind = TRUE; rdata = data; m_lstInlineQue.RemoveAt(posLast); break; } } else//设置了指定窗口优先呼叫 { if(iWinId == data.GetWindowId()) { rdata = data; m_lstInlineQue.RemoveAt(posLast); bFind = TRUE; break; } } } if(bFind) { break; } } } else//不使用优先级 { /* /////////////////////////////////////////首先找到可处理队列中哪几个队列有数据 CStringArray haveDataArray; GetCandoQueHaveData(haveDataArray,arrStrQueId,iWinId); if(haveDataArray.GetCount() == 0) { return FALSE; } /////////////////////////////////////////随机取数 int count = haveDataArray.GetCount(); time_t t; srand((unsigned) time(&t)); int nRand = rand() % count; CString strQueID = haveDataArray[nRand]; POSITION pos = m_lstInlineQue.GetHeadPosition(); while(pos) { SLZData data; POSITION posLast = pos; data = m_lstInlineQue.GetNext(pos); if(data.GetWindowId()==0)//如果没设置指定窗口 { if(strQueID.Compare(data.GetBussinessType()) == 0) { rdata = data; m_lstInlineQue.RemoveAt(posLast); bFind = TRUE; break; } } else//指定了窗口 { if(iWinId == data.GetWindowId()) { rdata = data; m_lstInlineQue.RemoveAt(posLast); bFind = TRUE; break; } } } */ bFind = GetFirstTakeNumData(rdata,arrStrQueId); if(bFind) bFind = RemoveFirstTakeNumData(rdata); } CTime currTime = CTime::GetCurrentTime(); rdata.SetCallTime(currTime);//设置呼叫时间 rdata.SetStaffId(staffID);//设置员工ID,哪个员工呼叫 rdata.SetWindowId(iWinId);//设置哪个窗口呼叫 rdata.SetWindowShowId(Window.GetShowWndId());//设置窗口编号 m_mtInlineQue.Unlock(); return bFind; }