123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797 |
- #include "stdafx.h"
- #include "ylgl.h"
- #include "SatisfactionReportForm.h"
- #include "SatisfactionDetails.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- typedef struct _SKINDKEY
- {
- int nIdx; //调查类型索引,如:部门类型
- int nDdjdIdx; //对应订单景点索引
- CString strKind; //类型
- _SKINDKEY(int n, int d, const CString str)
- {
- nIdx = n;
- nDdjdIdx = d;
- strKind = str;
- }
- }SKINDKEY;
- IMPLEMENT_DYNCREATE(SatisfactionReportForm, MyFormView)
- SatisfactionReportForm::SatisfactionReportForm()
- : MyFormView(SatisfactionReportForm::IDD)
- , m_nTypeIdx(0)
- , m_nObjIdx(0)
- , m_strSelOrder(_T(""))
- , m_nScoreModel(1)
- , m_strCurrSelKind(_T(""))
- , m_strCurrSelObj(_T(""))
- {
- }
- SatisfactionReportForm::~SatisfactionReportForm()
- {
- }
- void SatisfactionReportForm::DoDataExchange(CDataExchange* pDX)
- {
- MyFormView::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_SURVEY_LIST, m_Surveylist);
- DDX_Control(pDX, IDC_DINDANSURVEY_LIST, m_DinDanSurvey);
- DDX_Control(pDX, IDC_SURVEYOBJ_COMBO, m_KindCombox);
- DDX_Control(pDX, IDC_SVROBJ_COMBO, m_ObjCombox);
- DDX_Control(pDX, IDC_SINGLESCORE_COMBO, m_SingleCombox);
- DDX_Control(pDX, IDC_TOTALSCORE_COMBO, m_TotalCombox);
- }
- BEGIN_MESSAGE_MAP(SatisfactionReportForm, MyFormView)
- ON_BN_CLICKED(IDC_REPORTFIND_BTN, OnFindReport)
- ON_BN_CLICKED(IDC_REPORTCLOSE_BTN, OnBUTclose)
- ON_BN_CLICKED(IDC_DETAILS_BUTTON, OnDetailsBtn)
-
- ON_CBN_SELCHANGE(IDC_SURVEYOBJ_COMBO, OnCbnSelchangeCombo1)
- ON_CBN_SELCHANGE(IDC_SVROBJ_COMBO, OnCbnSelchangeCombo2)
- ON_NOTIFY(NM_CLICK, IDC_DINDANSURVEY_LIST, OnClickList2)
- ON_NOTIFY(NM_DBLCLK, IDC_DINDANSURVEY_LIST, OnDblclkList2)
- ON_BN_CLICKED(IDC_TotalScore_RADIO, OnTotalScoreRADIO)
- ON_BN_CLICKED(IDC_SingleScore_RADIO, OnSingleScoreRADIO)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // SatisfactionReportForm diagnostics
- #ifdef _DEBUG
- void SatisfactionReportForm::AssertValid() const
- {
- MyFormView::AssertValid();
- }
- void SatisfactionReportForm::Dump(CDumpContext& dc) const
- {
- MyFormView::Dump(dc);
- }
- #endif
- void SatisfactionReportForm::OnInitialUpdate()
- {
- MyFormView::OnInitialUpdate();
- CMyMdi Mdi;
- Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
- EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
- m_Surveylist.SetHeadings("服务对象,120;总服务客户,120;非常满意/百分比,120;满意/百分比,120;一般/百分比,120;不满意/百分比,120;非常不满意/百分比,120;得分,90;总分,90");
- m_Surveylist.LoadColumnInfo(7);
- #ifdef CHILD_VERSION
- // 16 column
- m_DinDanSurvey.SetHeadings("订单号,120;家长姓名,120;宝宝姓名,120;手机,120;固定电话,120;订单日期,120;总满意度,120;拨打情况,120;回访日期,120;通话时长,120;回访人员,120;备注,120");
- #else
- // 16 column
- m_DinDanSurvey.SetHeadings("订单号,120;男宾姓名,120;女宾姓名,120;男宾电话,120;女宾电话,120;订单日期,120;总满意度,120;拨打情况,120;回访日期,120;通话时长,120;回访人员,120;备注,120");
- #endif
- m_DinDanSurvey.LoadColumnInfo(12);
- ((CButton*)GetDlgItem(IDC_TotalScore_RADIO))->SetCheck(1);
- GetData();
- InitSurveyKind();
- }
- /*---------------------------------------
- 函数名: GetData
- 描述: 获取类据
- 参数:
- 返回值:
- ----------------------------------------*/
- void SatisfactionReportForm::GetData()
- {
- //获取服务类别
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- CString filter = _T("SvrKind@");
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if(g_bSendOK == 0)
- return;
- DataToArray(&m_kindArr);
- //获取配置信息
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- filter = _T("SatisfactionCfg@");
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if(g_bSendOK == 0)
- return;
- /*
- (_T("cfgID"));
- (_T("SvrKind"));
- (_T("KindName"));
- (_T("MaxScore"));
- (_T("TypeID"));
- (_T("IsEnable"));
- (_T("sfncfgDesc"));
- */
- DataToArray(&m_cfgArr);
- }
- /*---------------------------------------
- 函数名: InitSurveyKind
- 描述: 初始化调查类别
- 参数:
- 返回值:
- ----------------------------------------*/
- void SatisfactionReportForm::InitSurveyKind()
- {
- m_KindCombox.ResetContent();
- int i = 0;
- for(i=0; i<m_kindArr.GetSize(); i++)
- m_KindCombox.AddString(m_kindArr.ElementAt(i).ElementAt(1));
- m_KindCombox.SetCurSel(0);
- }
- /*---------------------------------------
- 函数名: ShowData
- 描述: 显示调查记录
- 参数:
- const int nSurveyKind 调查类别
- 返回值:
- ----------------------------------------*/
- void SatisfactionReportForm::ShowData()
- {
- m_DinDanSurvey.DeleteAllItems2();
- int nCount = 0;
- int nSize = m_DindanInfoArr.GetSize();
- m_DinDanSurvey.m_arLabels.SetSize(nSize, 1);
- int i=0;
- for(i=0; i<m_DinDanSurvey.m_arLabels.GetSize(); i++)
- {
- int nY(0), nM(0), nD(0);
- CString strOrderNum = m_DindanInfoArr.ElementAt(i).ElementAt(0);
- nY = _ttoi(strOrderNum.Mid(0,4));
- nM = _ttoi(strOrderNum.Mid(4,2));
- nD = _ttoi(strOrderNum.Mid(6,2));
- if(nY <= 0 || (nM <= 0 || nM > 12) || (nD > 31 || nD <=0))
- continue;
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(strOrderNum); //订单号
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(m_DindanInfoArr.ElementAt(i).ElementAt(1)); //家长姓名/男宾姓名
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(m_DindanInfoArr.ElementAt(i).ElementAt(2)); //宝宝姓名/女宾姓名
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(m_DindanInfoArr.ElementAt(i).ElementAt(3)); //手机/男宾电话
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(m_DindanInfoArr.ElementAt(i).ElementAt(4)); //固定电话/女宾电话
- CString strDinDanTime = _T("");
- strDinDanTime.Format(_T("%04d-%02d-%02d"), nY, nM, nD);
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(strDinDanTime); //订单时间
- //纺计总满意度
- CString strScore = _T("");
- StatisticsScore(&strOrderNum, strScore);
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(strScore); //总满意度
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(_T("")); //拨打情况
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(_T("")); //回访日期
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(_T("")); //通话时长
- CString strCS = _T("");
- for(int j=0; j<m_AllSurveyLogArr.GetSize(); j++)
- {
- CString strOrder = m_AllSurveyLogArr.ElementAt(j).ElementAt(5);
- if(strOrder == strOrderNum)
- {
- strCS = m_AllSurveyLogArr.ElementAt(j).ElementAt(11);
- break;
- }
- }
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(strCS); //回访人员
- m_DinDanSurvey.m_arLabels.ElementAt(i).Add(_T("")); //备注
- ++nCount;
- }
- if(nCount != 0)
- {
- m_DinDanSurvey.m_LabelCount = nCount;
- m_DinDanSurvey.SetItemCountEx(nCount);
- }
- }
- void SatisfactionReportForm::ChangeColName(IN CString strName)
- {
- LVCOLUMN lov;
- lov.mask = LVCF_TEXT; //取字符掩码
- m_DinDanSurvey.GetColumn(6, &lov);
- lov.pszText = strName.GetBuffer(0); //设置新字符
- m_DinDanSurvey.SetColumn(6, &lov); //设置题头
- }
- //查询数据
- void SatisfactionReportForm::OnFindReport()
- {
- CTime startTime, endTime;
- ((CDateTimeCtrl*)GetDlgItem(IDC_REPORTSATRT_CT))->GetTime(startTime);
- ((CDateTimeCtrl*)GetDlgItem(IDC_REPORTEND_CT))->GetTime(endTime);
-
- CString strStartCT(_T("")), strEndCT(_T(""));
- strStartCT = startTime.Format(_T("%Y%m%d"));
- strEndCT = endTime.Format(_T("%Y%m%d"));
- CString filter = _T("");
-
- #ifdef LKAY_VERSION
- filter = _T("dindan@(dindantype<>'意向客户' or dindantype is null) and id between '") + strStartCT + _T("-000' and '") + strEndCT + _T("-999'");
- #else
- filter = _T("dindan@id between '") + strStartCT + _T("-000' and '") + strEndCT + _T("-999'");
- #endif
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234; //获取dindan信息和对应的满意度记录
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if (g_bSendOK == 0)
- return;
- DataToArray(&m_DindanInfoArr);
- //获取所有记录
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- CString strfilter = _T("GetAllSurveyData@") + strStartCT + _T("@") + strEndCT;
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if(g_bSendOK == 0)
- return;
- /*
- _T("LogID")); //记录ID
- _T("cfgID")); //服务配置ID
- _T("KindName")); //服务类型
- _T("ObjID")); //对象ID
- _T("ObjName")); //对象名
- _T("OrderID")); //订单ID
- _T("Score")); //得分
- _T("MaxScore")); //最高得分
- _T("TypeID")); //显示得分类型
- _T("States")); //状态
- _T("SurveyTime")); //调查时间
- _T("SurveyCS")); //调查客服
- _T("sfncfgDesc")); //调查内容
- */
- DataToArray(&m_AllSurveyLogArr);
- //订单景点
- m_dindanjdArr.RemoveAll();
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- strfilter = _T("dindanjd@") + strStartCT + _T("@") + strEndCT;
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if(g_bSendOK == 0)
- return;
- DataToArray(&m_dindanjdArr);
- ShowData();
- }
- //关闭
- void SatisfactionReportForm::OnBUTclose()
- {
- GetParent()->SendMessage(WM_CLOSE);
- }
- //详情
- void SatisfactionReportForm::OnDetailsBtn()
- {
- CString strKind = _T("");
- m_KindCombox.GetWindowText(strKind);
- CString strObj = _T("");
- m_ObjCombox.GetWindowText(strObj);
-
- SatisfactionDetails dlg;
- dlg.m_strKind = strKind;
- dlg.m_strObj = strObj;
- dlg.m_strOrder = m_strSelOrder;
- dlg.m_strClient1 = m_strClient1;
- dlg.m_strClient2 = m_strClient2;
- dlg.m_pcfgArr = &m_cfgArr;
- dlg.m_nScoreModel = m_nScoreModel;
- dlg.m_pAllLogArr = &m_AllSurveyLogArr;
- dlg.DoModal();
- }
- /*
- 函数名: GetScoreAndSurveyObj
- 描述: 获取评分
- 参数:
- CString& strScore 返回评分
- 返回值:
- */
- void SatisfactionReportForm::GetScoreAndSurveyObj(IN const CString& strObj, IN const CString& strOrderNum, OUT CString& strScore)
- {
- int nSegment = 0; //一条记录的总分
- int i(0), j(0);
- int nStatisticsNum = 0; //统计数量
- int nScore = 0;
- for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
- {
- if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == strOrderNum && strObj == m_AllSurveyLogArr.ElementAt(j).ElementAt(4))
- {
- CString strKindName = m_AllSurveyLogArr.ElementAt(j).ElementAt(2);
- for(i=0; i<m_cfgArr.GetSize(); i++)
- {
- if(m_cfgArr.ElementAt(i).ElementAt(2) == strKindName)
- {
- //获取一条记录的总分
- nSegment = _ttoi(m_cfgArr.ElementAt(i).ElementAt(3));
- break;
- }
- }
- }
- if(nSegment != 0)
- break;
- }
-
- if(nSegment == 0)
- return;
- for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
- {
- if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == strOrderNum && strObj == m_AllSurveyLogArr.ElementAt(j).ElementAt(4))
- {
- //统计满意度
- nScore += _ttoi(m_AllSurveyLogArr.ElementAt(j).ElementAt(6));
- ++nStatisticsNum;
- }
- }
- if(nStatisticsNum == 0)
- return;
- int nMaxScore = nSegment*nStatisticsNum;
- int nAve = nMaxScore/5;
- if(nScore < nAve)
- strScore = _T("非常不满意");
- else if(nScore < nAve*2)
- strScore = _T("不满意");
- else if(nScore < nAve*3)
- strScore = _T("一般");
- else if(nScore < nAve*4)
- strScore = _T("满意");
- else if(nScore < nAve*5)
- strScore = _T("非常满意");
- }
- //单击选择订单记录
- void SatisfactionReportForm::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
- // TODO: 在此添加控件通知处理程序代码
- NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
- if(pNMListView->iItem != -1)
- {
- //单击行列pNMListView->iItem, pNMListView->iSubItem
- int nSelIdx = pNMListView->iItem;
- m_strSelOrder = m_DinDanSurvey.GetItemText(pNMListView->iItem, 0);
- if(m_strSelOrder == _T(""))
- {
- MessageBox(_T("选择了错误订单"));
- return;
- }
-
- m_strClient1 = m_DinDanSurvey.GetItemText(pNMListView->iItem, 1);
- m_strClient2 = m_DinDanSurvey.GetItemText(pNMListView->iItem, 2);
- //获取调查类型
- m_strCurrSelKind = _T("");
- m_KindCombox.GetWindowText(m_strCurrSelKind);
- if(m_strCurrSelKind == _T(""))
- {
- MessageBox(_T("没有选择调查类型"));
- return;
- }
- //初始化服务对象
- m_strCurrSelObj = _T("");
- IntiSeviceObj(&m_strSelOrder, m_strCurrSelKind);
- m_ObjCombox.GetWindowText(m_strCurrSelObj);
- //显示满意度调查统计信息
- ShowStatisticsData(&m_strCurrSelKind, &m_strSelOrder, &m_strCurrSelObj);
- }
- *pResult = 0;
- }
- //双击//选择订单记录
- void SatisfactionReportForm::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- *pResult = 0;
- }
- //选择类型
- void SatisfactionReportForm::OnCbnSelchangeCombo1()
- {
- m_nTypeIdx = m_KindCombox.GetCurSel();
- m_strCurrSelKind = _T("");
- m_KindCombox.GetLBText(m_nTypeIdx, m_strCurrSelKind);
- if(m_strCurrSelKind == _T(""))
- {
- MessageBox(_T("先选择类型!"));
- return;
- }
- //初始化服务对象
- IntiSeviceObj(&m_strSelOrder, m_strCurrSelKind);
- m_strCurrSelObj = _T("");
- if(m_ObjCombox.GetCount() > 0)
- m_ObjCombox.GetWindowText(m_strCurrSelObj);
- //显示满意度调查统计信息
- ShowStatisticsData(&m_strCurrSelKind, &m_strSelOrder, &m_strCurrSelObj);
- }
- //选择对象
- void SatisfactionReportForm::OnCbnSelchangeCombo2()
- {
- m_nObjIdx = m_ObjCombox.GetCurSel();
- m_strCurrSelObj = _T("");
- m_ObjCombox.GetLBText(m_nObjIdx, m_strCurrSelObj);
- if(m_strCurrSelObj == _T(""))
- {
- MessageBox(_T("先选择订单!"));
- return;
- }
- m_strCurrSelKind = _T("");
- m_KindCombox.GetWindowText(m_strCurrSelKind);
- //显示满意度调查统计信息
- ShowStatisticsData(&m_strCurrSelKind, &m_strSelOrder, &m_strCurrSelObj);
- }
- /*---------------------------------------
- 函数名: StatisticsScore
- 描述: 统计总评分
- 参数:
- const CString* pOrder, //订单号
- CString& strScore //返回评分(如:满意)
- 返回值:
- ----------------------------------------*/
- void SatisfactionReportForm::StatisticsScore(IN const CString* pOrder, OUT CString& strScore)
- {
- if(pOrder == NULL || (*pOrder) == _T(""))
- return;
- int nSegment = 0; //一条记录的总分
- int i(0), j(0);
- int nStatisticsNum = 0; //统计数量
- int nScore = 0;
- for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
- {
- if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == (*pOrder))
- {
- nSegment = _ttoi(m_AllSurveyLogArr.ElementAt(j).ElementAt(7));
- break;
- }
- }
-
- if(nSegment == 0)
- return;
- for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
- {
- if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == (*pOrder))
- {
- //统计满意度
- nScore += _ttoi(m_AllSurveyLogArr.ElementAt(j).ElementAt(6));
- ++nStatisticsNum;
- }
- }
- if(nStatisticsNum == 0)
- return;
- int nMaxScore = nSegment*nStatisticsNum;
- int nAve = nMaxScore/5;
- if(nScore <= nAve)
- strScore = _T("非常不满意");
- else if(nScore > nAve && nScore <= nAve*2)
- strScore = _T("不满意");
- else if(nScore > nAve*2 && nScore <= nAve*3)
- strScore = _T("一般");
- else if(nScore > nAve*3 && nScore <= nAve*4)
- strScore = _T("满意");
- else if(nScore > nAve*4 && nScore <= nAve*5)
- strScore = _T("非常满意");
- }
- /*---------------------------------------
- 函数名: IntiSeviceObj
- 描述: 初始化服务对象
- 参数:
- const CString* pOrder, //订单号
- const CString& strKind //服务类型
- 返回值:
- ----------------------------------------*/
- void SatisfactionReportForm::IntiSeviceObj(IN const CString* pOrder, IN const CString& strKind)
- {
- if(pOrder == NULL || (*pOrder) == _T(""))
- return;
- SKINDKEY szKindKey[13] =
- {
- SKINDKEY(25,0,_T("门市")),SKINDKEY(15,3,_T("摄影")),SKINDKEY(17,4,_T("化妆")),SKINDKEY(19,0,_T("选片")),SKINDKEY(21,0,_T("设计")),
- SKINDKEY(23,0,_T("初修")),SKINDKEY(27,0,_T("精修")),SKINDKEY(0,0,_T("形设")),SKINDKEY(0,0,_T("取件")),SKINDKEY(0,0,_T("礼服")),
- SKINDKEY(0,0,_T("摄影助理")),SKINDKEY(0,0,_T("化妆助理")),SKINDKEY(0,0,_T("看设计人"))
- };
- //获取订单索引和景点索引
- int nDdjdIdx = 0;
- int nIdx = 0;
- int i = 0;
- for(i=0; i<13; i++)
- {
- if(szKindKey[i].strKind == strKind)
- {
- nIdx = szKindKey[i].nIdx;
- nDdjdIdx = szKindKey[i].nDdjdIdx;
- break;
- }
- }
- //将订单和景点保存的对象存在对象列表里
- //订单信息
- m_ObjCombox.ResetContent();
- for(i = 0; i<m_DindanInfoArr.GetSize(); i++)
- {
- if(m_DindanInfoArr.ElementAt(i).ElementAt(0) == (*pOrder) && nIdx != 0)
- m_ObjCombox.AddString(m_DindanInfoArr.ElementAt(i).ElementAt(nIdx));
- }
- //订单景点
- for(i=0; i<m_dindanjdArr.GetSize(); i++)
- {
- if(m_dindanjdArr.ElementAt(i).ElementAt(0) == (*pOrder) && nDdjdIdx != 0)
- {
- CString strName = m_dindanjdArr.ElementAt(i).ElementAt(nDdjdIdx);
- if(!CheckNameList(strName))
- m_ObjCombox.AddString(strName);
- }
- }
- //显示默认统计数据
- m_nObjIdx = 0;
- m_ObjCombox.SetCurSel(m_nObjIdx);
- }
- /*----------------------------------------
- 函数名: CheckNameList
- 描述: 检查名字列表是否已存在同名
- 参数:
- IN CONST CString& strName
- 返回值: 有同名=TRUE, 没有=FALSE;
- ----------------------------------------*/
- BOOL SatisfactionReportForm::CheckNameList(IN CONST CString& strName)
- {
- CString strSelName = _T("");
- int nSize = m_ObjCombox.GetCount();
- for(int i=0; i<nSize; ++i)
- {
- m_ObjCombox.GetLBText( i, strSelName);
- if(strSelName == strName)
- return TRUE;
- }
- return FALSE;
- }
- /*---------------------------------------
- 函数名: ShowStatisticsData
- 描述: 显示统计数据
- 参数:
- IN const CString* pKind, 类型,如:员工部门(摄影、门市)
- IN const CString* pOrder, 订单号
- IN const CString* pObj 对象,如:张三、李四
- 返回值:
- ----------------------------------------*/
- void SatisfactionReportForm::ShowStatisticsData(IN const CString* pKind, IN const CString* pOrder, IN const CString* pObj)
- {
- if(pObj == NULL || (*pObj) == _T("") || pOrder == NULL || (*pOrder) == _T("") || pKind == NULL || (*pKind) == _T(""))
- return;
- m_Surveylist.DeleteAllItems2();
- std::vector<int> vSingleDindanScore; //某调查类型的所有评分
- int szScoreNum[5] = {0}; //各级别评分数量
- int nCoutCustomer = 0; //客户总数
- CString strOldOrder = _T("");
- std::vector<CStringArray*> vSelSurveyLogs; //筛选后的调查记录
- int i = 0;
- for(i=0; i<m_AllSurveyLogArr.GetSize(); i++)
- {
- switch(m_nScoreModel)
- {
- case 1:
- {
- if(m_AllSurveyLogArr.ElementAt(i).ElementAt(4) == (*pObj) && m_AllSurveyLogArr.ElementAt(i).ElementAt(2) == (*pKind))
- {
- //保存同一类型和同一调查对象的评分
- vSelSurveyLogs.push_back(&(m_AllSurveyLogArr.ElementAt(i)));
-
- //计算客户总数
- if(strOldOrder != m_AllSurveyLogArr.ElementAt(i).ElementAt(5))
- {
- strOldOrder = m_AllSurveyLogArr.ElementAt(i).ElementAt(5);
- ++nCoutCustomer;
- }
- }
- }
- break;
- case 2:
- {
- if(m_AllSurveyLogArr.ElementAt(i).ElementAt(4) == (*pObj) && m_AllSurveyLogArr.ElementAt(i).ElementAt(2) == (*pKind) && (*pOrder) == m_AllSurveyLogArr.ElementAt(i).ElementAt(5))
- {
- //保存同一类型和同一调查对象的评分
- vSelSurveyLogs.push_back(&(m_AllSurveyLogArr.ElementAt(i)));
-
- //计算客户总数
- if(strOldOrder != m_AllSurveyLogArr.ElementAt(i).ElementAt(5))
- {
- strOldOrder = m_AllSurveyLogArr.ElementAt(i).ElementAt(5);
- ++nCoutCustomer;
- }
- }
- }
- break;
- }
-
- }
- //统计当前调查对象的所有评分级别的数量
- int nSameOrderNum = 0; //相同订单号的记录数量
- int nOrderScore = 0; //订单评分
- int nCurrScore = 0; //得分
- int nTotalScore = 0; //总分
- CString strCurrOrder = _T(""); //当前订单号
- std::vector<CStringArray*>::iterator it = vSelSurveyLogs.begin();
- for(;it != vSelSurveyLogs.end(); ++it)
- {
- CStringArray* pArr = (*it);
- if(pArr == NULL)
- continue;
- int nSingleMaxScore = _ttoi(pArr->ElementAt(7)); //一条记录总分
- nTotalScore += nSingleMaxScore;
- strCurrOrder = pArr->ElementAt(5);
- nOrderScore += _ttoi(pArr->ElementAt(6)); //统计每条订单的总得分
- nCurrScore += _ttoi(pArr->ElementAt(6));
- ++nSameOrderNum;
- if((it+1) != vSelSurveyLogs.end())
- {
- //是否相同订单号
- CString strNextOrder = (*(it+1))->ElementAt(5);
- if(strCurrOrder != strNextOrder)
- {
- //统计当前订单的每个等级的评分次数
- int nAve = (nSingleMaxScore*nSameOrderNum)/5; //每个级别的平均分 = (一条记录总分 * 相同订单号的记录数量)/5个等级
- if(nOrderScore <= nAve)
- szScoreNum[4] += 1;
- else if(nOrderScore <= nAve*2)
- szScoreNum[3] += 1;
- else if(nOrderScore <= nAve*3)
- szScoreNum[2] += 1;
- else if(nOrderScore <= nAve*4)
- szScoreNum[1] += 1;
- else if(nOrderScore <= nAve*5)
- szScoreNum[0] += 1;
- nSameOrderNum = 0;
- nOrderScore = 0;
- }
- }
- else
- {
- //统计当前订单的每个等级的评分次数
- int nSingleMaxScore = _ttoi(pArr->ElementAt(7)); //一条记录总分
- int nAve = (nSingleMaxScore*nSameOrderNum)/5; //每个级别的平均分 = (一条记录总分 * 相同订单号的记录数量)/5个等级
- if(nOrderScore <= nAve)
- szScoreNum[4] += 1;
- else if(nOrderScore <= nAve*2)
- szScoreNum[3] += 1;
- else if(nOrderScore <= nAve*3)
- szScoreNum[2] += 1;
- else if(nOrderScore <= nAve*4)
- szScoreNum[1] += 1;
- else if(nOrderScore <= nAve*5)
- szScoreNum[0] += 1;
- }
- }
- //将数据填入表格里
- m_Surveylist.m_arLabels.SetSize(1, 1);
- m_Surveylist.m_arLabels.ElementAt(0).Add((*pObj)); //调查对象,如:管理员
- //服务总数,如:服务过2个客户
- CString strCustomer = _T("");
- strCustomer.Format(_T("%d"), nCoutCustomer);
- m_Surveylist.m_arLabels.ElementAt(0).Add(strCustomer);
- //百分比计算
- for(i=0; i<5; i++)
- {
- CString strScore = _T("");
- if(szScoreNum[i] <= 0)
- strScore = _T("0(0%)");
- else
- {
- if(nCoutCustomer <= 0)
- strScore = _T("0(0%)");
- else
- {
- //百份比 = 某一个评分级别次数 / 客户总数 * 100
- strScore.Format(_T("%d(%d"), szScoreNum[i], (int)(((float)szScoreNum[i]/(float)nCoutCustomer)*100));
- strScore += _T("%)");
- }
- }
- m_Surveylist.m_arLabels.ElementAt(0).Add(strScore);
- }
- CString strAllScore = _T("");
- strAllScore.Format(_T("%d"), nCurrScore);
- m_Surveylist.m_arLabels.ElementAt(0).Add(strAllScore); //得分
- CString strTotalScore = _T("");
- strTotalScore.Format(_T("%d"), nTotalScore);
- m_Surveylist.m_arLabels.ElementAt(0).Add(strTotalScore); //总分
- m_Surveylist.m_LabelCount = 1;
- m_Surveylist.SetItemCountEx(1);
- }
- //总评
- void SatisfactionReportForm::OnTotalScoreRADIO()
- {
- m_nScoreModel = 1;
- ShowStatisticsData(&m_strCurrSelKind, &m_strSelOrder, &m_strCurrSelObj);
- }
- //单一订单评分
- void SatisfactionReportForm::OnSingleScoreRADIO()
- {
- m_nScoreModel = 2;
- ShowStatisticsData(&m_strCurrSelKind, &m_strSelOrder, &m_strCurrSelObj);
- }
|