SatisfactionReportForm.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. #include "stdafx.h"
  2. #include "ylgl.h"
  3. #include "SatisfactionReportForm.h"
  4. #include "SatisfactionDetails.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. typedef struct _SKINDKEY
  11. {
  12. int nIdx; //调查类型索引,如:部门类型
  13. int nDdjdIdx; //对应订单景点索引
  14. CString strKind; //类型
  15. _SKINDKEY(int n, int d, const CString str)
  16. {
  17. nIdx = n;
  18. nDdjdIdx = d;
  19. strKind = str;
  20. }
  21. }SKINDKEY;
  22. IMPLEMENT_DYNCREATE(SatisfactionReportForm, MyFormView)
  23. SatisfactionReportForm::SatisfactionReportForm()
  24. : MyFormView(SatisfactionReportForm::IDD)
  25. , m_nTypeIdx(0)
  26. , m_nObjIdx(0)
  27. , m_strSelOrder(_T(""))
  28. , m_nScoreModel(1)
  29. , m_strCurrSelKind(_T(""))
  30. , m_strCurrSelObj(_T(""))
  31. {
  32. }
  33. SatisfactionReportForm::~SatisfactionReportForm()
  34. {
  35. }
  36. void SatisfactionReportForm::DoDataExchange(CDataExchange* pDX)
  37. {
  38. MyFormView::DoDataExchange(pDX);
  39. DDX_Control(pDX, IDC_SURVEY_LIST, m_Surveylist);
  40. DDX_Control(pDX, IDC_DINDANSURVEY_LIST, m_DinDanSurvey);
  41. DDX_Control(pDX, IDC_SURVEYOBJ_COMBO, m_KindCombox);
  42. DDX_Control(pDX, IDC_SVROBJ_COMBO, m_ObjCombox);
  43. DDX_Control(pDX, IDC_SINGLESCORE_COMBO, m_SingleCombox);
  44. DDX_Control(pDX, IDC_TOTALSCORE_COMBO, m_TotalCombox);
  45. }
  46. BEGIN_MESSAGE_MAP(SatisfactionReportForm, MyFormView)
  47. ON_BN_CLICKED(IDC_REPORTFIND_BTN, OnFindReport)
  48. ON_BN_CLICKED(IDC_REPORTCLOSE_BTN, OnBUTclose)
  49. ON_BN_CLICKED(IDC_DETAILS_BUTTON, OnDetailsBtn)
  50. ON_CBN_SELCHANGE(IDC_SURVEYOBJ_COMBO, OnCbnSelchangeCombo1)
  51. ON_CBN_SELCHANGE(IDC_SVROBJ_COMBO, OnCbnSelchangeCombo2)
  52. ON_NOTIFY(NM_CLICK, IDC_DINDANSURVEY_LIST, OnClickList2)
  53. ON_NOTIFY(NM_DBLCLK, IDC_DINDANSURVEY_LIST, OnDblclkList2)
  54. ON_BN_CLICKED(IDC_TotalScore_RADIO, OnTotalScoreRADIO)
  55. ON_BN_CLICKED(IDC_SingleScore_RADIO, OnSingleScoreRADIO)
  56. END_MESSAGE_MAP()
  57. /////////////////////////////////////////////////////////////////////////////
  58. // SatisfactionReportForm diagnostics
  59. #ifdef _DEBUG
  60. void SatisfactionReportForm::AssertValid() const
  61. {
  62. MyFormView::AssertValid();
  63. }
  64. void SatisfactionReportForm::Dump(CDumpContext& dc) const
  65. {
  66. MyFormView::Dump(dc);
  67. }
  68. #endif
  69. void SatisfactionReportForm::OnInitialUpdate()
  70. {
  71. MyFormView::OnInitialUpdate();
  72. CMyMdi Mdi;
  73. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  74. CRect rc2;
  75. GetWindowRect(rc2);
  76. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  77. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  78. m_Surveylist.SetHeadings("服务对象,120;总服务客户,120;非常满意/百分比,120;满意/百分比,120;一般/百分比,120;不满意/百分比,120;非常不满意/百分比,120;得分,90;总分,90");
  79. m_Surveylist.LoadColumnInfo(7);
  80. #ifdef CHILD_VERSION
  81. // 16 column
  82. m_DinDanSurvey.SetHeadings("订单号,120;家长姓名,120;宝宝姓名,120;手机,120;固定电话,120;订单日期,120;总满意度,120;拨打情况,120;回访日期,120;通话时长,120;回访人员,120;备注,120");
  83. #else
  84. // 16 column
  85. m_DinDanSurvey.SetHeadings("订单号,120;男宾姓名,120;女宾姓名,120;男宾电话,120;女宾电话,120;订单日期,120;总满意度,120;拨打情况,120;回访日期,120;通话时长,120;回访人员,120;备注,120");
  86. #endif
  87. m_DinDanSurvey.LoadColumnInfo(12);
  88. ((CButton*)GetDlgItem(IDC_TotalScore_RADIO))->SetCheck(1);
  89. GetData();
  90. InitSurveyKind();
  91. }
  92. /*---------------------------------------
  93. 函数名: GetData
  94. 描述: 获取类据
  95. 参数:
  96. 返回值:
  97. ----------------------------------------*/
  98. void SatisfactionReportForm::GetData()
  99. {
  100. //获取服务类别
  101. g_sendhead.bsql = 0;
  102. g_sendhead.code[0] = 234;
  103. g_sendhead.tabcount = 1;
  104. CString filter = _T("SvrKind@");
  105. g_pMainWnd->ProcessChatMessageRequest2(filter);
  106. if(g_bSendOK == 0)
  107. return;
  108. DataToArray(&m_kindArr);
  109. //获取配置信息
  110. g_sendhead.bsql = 0;
  111. g_sendhead.code[0] = 234;
  112. g_sendhead.tabcount = 1;
  113. filter = _T("SatisfactionCfg@");
  114. g_pMainWnd->ProcessChatMessageRequest2(filter);
  115. if(g_bSendOK == 0)
  116. return;
  117. /*
  118. (_T("cfgID"));
  119. (_T("SvrKind"));
  120. (_T("KindName"));
  121. (_T("MaxScore"));
  122. (_T("TypeID"));
  123. (_T("IsEnable"));
  124. (_T("sfncfgDesc"));
  125. */
  126. DataToArray(&m_cfgArr);
  127. }
  128. /*---------------------------------------
  129. 函数名: InitSurveyKind
  130. 描述: 初始化调查类别
  131. 参数:
  132. 返回值:
  133. ----------------------------------------*/
  134. void SatisfactionReportForm::InitSurveyKind()
  135. {
  136. m_KindCombox.ResetContent();
  137. int i = 0;
  138. for(i=0; i<m_kindArr.GetSize(); i++)
  139. m_KindCombox.AddString(m_kindArr.ElementAt(i).ElementAt(1));
  140. m_KindCombox.SetCurSel(0);
  141. }
  142. /*---------------------------------------
  143. 函数名: ShowData
  144. 描述: 显示调查记录
  145. 参数:
  146. const int nSurveyKind 调查类别
  147. 返回值:
  148. ----------------------------------------*/
  149. void SatisfactionReportForm::ShowData()
  150. {
  151. m_DinDanSurvey.DeleteAllItems2();
  152. int nCount = 0;
  153. int nSize = m_DindanInfoArr.GetSize();
  154. m_DinDanSurvey.m_arLabels.SetSize(nSize, 1);
  155. int i=0;
  156. for(i=0; i<m_DinDanSurvey.m_arLabels.GetSize(); i++)
  157. {
  158. int nY(0), nM(0), nD(0);
  159. CString strOrderNum = m_DindanInfoArr.ElementAt(i).ElementAt(0);
  160. nY = _ttoi(strOrderNum.Mid(0,4));
  161. nM = _ttoi(strOrderNum.Mid(4,2));
  162. nD = _ttoi(strOrderNum.Mid(6,2));
  163. if(nY <= 0 || (nM <= 0 || nM > 12) || (nD > 31 || nD <=0))
  164. continue;
  165. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(strOrderNum); //订单号
  166. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(m_DindanInfoArr.ElementAt(i).ElementAt(1)); //家长姓名/男宾姓名
  167. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(m_DindanInfoArr.ElementAt(i).ElementAt(2)); //宝宝姓名/女宾姓名
  168. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(m_DindanInfoArr.ElementAt(i).ElementAt(3)); //手机/男宾电话
  169. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(m_DindanInfoArr.ElementAt(i).ElementAt(4)); //固定电话/女宾电话
  170. CString strDinDanTime = _T("");
  171. strDinDanTime.Format(_T("%04d-%02d-%02d"), nY, nM, nD);
  172. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(strDinDanTime); //订单时间
  173. //纺计总满意度
  174. CString strScore = _T("");
  175. StatisticsScore(&strOrderNum, strScore);
  176. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(strScore); //总满意度
  177. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(_T("")); //拨打情况
  178. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(_T("")); //回访日期
  179. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(_T("")); //通话时长
  180. CString strCS = _T("");
  181. for(int j=0; j<m_AllSurveyLogArr.GetSize(); j++)
  182. {
  183. CString strOrder = m_AllSurveyLogArr.ElementAt(j).ElementAt(5);
  184. if(strOrder == strOrderNum)
  185. {
  186. strCS = m_AllSurveyLogArr.ElementAt(j).ElementAt(11);
  187. break;
  188. }
  189. }
  190. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(strCS); //回访人员
  191. m_DinDanSurvey.m_arLabels.ElementAt(i).Add(_T("")); //备注
  192. ++nCount;
  193. }
  194. if(nCount != 0)
  195. {
  196. m_DinDanSurvey.m_LabelCount = nCount;
  197. m_DinDanSurvey.SetItemCountEx(nCount);
  198. }
  199. }
  200. void SatisfactionReportForm::ChangeColName(IN CString strName)
  201. {
  202. LVCOLUMN lov;
  203. lov.mask = LVCF_TEXT; //取字符掩码
  204. m_DinDanSurvey.GetColumn(6, &lov);
  205. lov.pszText = strName.GetBuffer(0); //设置新字符
  206. m_DinDanSurvey.SetColumn(6, &lov); //设置题头
  207. }
  208. //查询数据
  209. void SatisfactionReportForm::OnFindReport()
  210. {
  211. CTime startTime, endTime;
  212. ((CDateTimeCtrl*)GetDlgItem(IDC_REPORTSATRT_CT))->GetTime(startTime);
  213. ((CDateTimeCtrl*)GetDlgItem(IDC_REPORTEND_CT))->GetTime(endTime);
  214. CString strStartCT(_T("")), strEndCT(_T(""));
  215. strStartCT = startTime.Format(_T("%Y%m%d"));
  216. strEndCT = endTime.Format(_T("%Y%m%d"));
  217. CString filter = _T("");
  218. #ifdef LKAY_VERSION
  219. filter = _T("dindan@(dindantype<>'意向客户' or dindantype is null) and id between '") + strStartCT + _T("-000' and '") + strEndCT + _T("-999'");
  220. #else
  221. filter = _T("dindan@id between '") + strStartCT + _T("-000' and '") + strEndCT + _T("-999'");
  222. #endif
  223. g_sendhead.bsql = 0;
  224. g_sendhead.code[0] = 234; //获取dindan信息和对应的满意度记录
  225. g_sendhead.tabcount = 1;
  226. g_pMainWnd->ProcessChatMessageRequest2(filter);
  227. if (g_bSendOK == 0)
  228. return;
  229. DataToArray(&m_DindanInfoArr);
  230. //获取所有记录
  231. g_sendhead.bsql = 0;
  232. g_sendhead.code[0] = 234;
  233. g_sendhead.tabcount = 1;
  234. CString strfilter = _T("GetAllSurveyData@") + strStartCT + _T("@") + strEndCT;
  235. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  236. if(g_bSendOK == 0)
  237. return;
  238. /*
  239. _T("LogID")); //记录ID
  240. _T("cfgID")); //服务配置ID
  241. _T("KindName")); //服务类型
  242. _T("ObjID")); //对象ID
  243. _T("ObjName")); //对象名
  244. _T("OrderID")); //订单ID
  245. _T("Score")); //得分
  246. _T("MaxScore")); //最高得分
  247. _T("TypeID")); //显示得分类型
  248. _T("States")); //状态
  249. _T("SurveyTime")); //调查时间
  250. _T("SurveyCS")); //调查客服
  251. _T("sfncfgDesc")); //调查内容
  252. */
  253. DataToArray(&m_AllSurveyLogArr);
  254. //订单景点
  255. m_dindanjdArr.RemoveAll();
  256. g_sendhead.bsql = 0;
  257. g_sendhead.code[0] = 234;
  258. g_sendhead.tabcount = 1;
  259. strfilter = _T("dindanjd@") + strStartCT + _T("@") + strEndCT;
  260. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  261. if(g_bSendOK == 0)
  262. return;
  263. DataToArray(&m_dindanjdArr);
  264. ShowData();
  265. }
  266. //关闭
  267. void SatisfactionReportForm::OnBUTclose()
  268. {
  269. GetParent()->SendMessage(WM_CLOSE);
  270. }
  271. //详情
  272. void SatisfactionReportForm::OnDetailsBtn()
  273. {
  274. CString strKind = _T("");
  275. m_KindCombox.GetWindowText(strKind);
  276. CString strObj = _T("");
  277. m_ObjCombox.GetWindowText(strObj);
  278. SatisfactionDetails dlg;
  279. dlg.m_strKind = strKind;
  280. dlg.m_strObj = strObj;
  281. dlg.m_strOrder = m_strSelOrder;
  282. dlg.m_strClient1 = m_strClient1;
  283. dlg.m_strClient2 = m_strClient2;
  284. dlg.m_pcfgArr = &m_cfgArr;
  285. dlg.m_nScoreModel = m_nScoreModel;
  286. dlg.m_pAllLogArr = &m_AllSurveyLogArr;
  287. dlg.DoModal();
  288. }
  289. /*
  290. 函数名: GetScoreAndSurveyObj
  291. 描述: 获取评分
  292. 参数:
  293. CString& strScore 返回评分
  294. 返回值:
  295. */
  296. void SatisfactionReportForm::GetScoreAndSurveyObj(IN const CString& strObj, IN const CString& strOrderNum, OUT CString& strScore)
  297. {
  298. int nSegment = 0; //一条记录的总分
  299. int i(0), j(0);
  300. int nStatisticsNum = 0; //统计数量
  301. int nScore = 0;
  302. for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
  303. {
  304. if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == strOrderNum && strObj == m_AllSurveyLogArr.ElementAt(j).ElementAt(4))
  305. {
  306. CString strKindName = m_AllSurveyLogArr.ElementAt(j).ElementAt(2);
  307. for(i=0; i<m_cfgArr.GetSize(); i++)
  308. {
  309. if(m_cfgArr.ElementAt(i).ElementAt(2) == strKindName)
  310. {
  311. //获取一条记录的总分
  312. nSegment = _ttoi(m_cfgArr.ElementAt(i).ElementAt(3));
  313. break;
  314. }
  315. }
  316. }
  317. if(nSegment != 0)
  318. break;
  319. }
  320. if(nSegment == 0)
  321. return;
  322. for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
  323. {
  324. if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == strOrderNum && strObj == m_AllSurveyLogArr.ElementAt(j).ElementAt(4))
  325. {
  326. //统计满意度
  327. nScore += _ttoi(m_AllSurveyLogArr.ElementAt(j).ElementAt(6));
  328. ++nStatisticsNum;
  329. }
  330. }
  331. if(nStatisticsNum == 0)
  332. return;
  333. int nMaxScore = nSegment*nStatisticsNum;
  334. int nAve = nMaxScore/5;
  335. if(nScore < nAve)
  336. strScore = _T("非常不满意");
  337. else if(nScore < nAve*2)
  338. strScore = _T("不满意");
  339. else if(nScore < nAve*3)
  340. strScore = _T("一般");
  341. else if(nScore < nAve*4)
  342. strScore = _T("满意");
  343. else if(nScore < nAve*5)
  344. strScore = _T("非常满意");
  345. }
  346. //单击选择订单记录
  347. void SatisfactionReportForm::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  348. {
  349. LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
  350. // TODO: 在此添加控件通知处理程序代码
  351. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  352. if(pNMListView->iItem != -1)
  353. {
  354. //单击行列pNMListView->iItem, pNMListView->iSubItem
  355. int nSelIdx = pNMListView->iItem;
  356. m_strSelOrder = m_DinDanSurvey.GetItemText(pNMListView->iItem, 0);
  357. if(m_strSelOrder == _T(""))
  358. {
  359. MessageBox(_T("选择了错误订单"));
  360. return;
  361. }
  362. m_strClient1 = m_DinDanSurvey.GetItemText(pNMListView->iItem, 1);
  363. m_strClient2 = m_DinDanSurvey.GetItemText(pNMListView->iItem, 2);
  364. //获取调查类型
  365. m_strCurrSelKind = _T("");
  366. m_KindCombox.GetWindowText(m_strCurrSelKind);
  367. if(m_strCurrSelKind == _T(""))
  368. {
  369. MessageBox(_T("没有选择调查类型"));
  370. return;
  371. }
  372. //初始化服务对象
  373. m_strCurrSelObj = _T("");
  374. IntiSeviceObj(&m_strSelOrder, m_strCurrSelKind);
  375. m_ObjCombox.GetWindowText(m_strCurrSelObj);
  376. //显示满意度调查统计信息
  377. ShowStatisticsData(&m_strCurrSelKind, &m_strSelOrder, &m_strCurrSelObj);
  378. }
  379. *pResult = 0;
  380. }
  381. //双击//选择订单记录
  382. void SatisfactionReportForm::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  383. {
  384. *pResult = 0;
  385. }
  386. //选择类型
  387. void SatisfactionReportForm::OnCbnSelchangeCombo1()
  388. {
  389. m_nTypeIdx = m_KindCombox.GetCurSel();
  390. m_strCurrSelKind = _T("");
  391. m_KindCombox.GetLBText(m_nTypeIdx, m_strCurrSelKind);
  392. if(m_strCurrSelKind == _T(""))
  393. {
  394. MessageBox(_T("先选择类型!"));
  395. return;
  396. }
  397. //初始化服务对象
  398. IntiSeviceObj(&m_strSelOrder, m_strCurrSelKind);
  399. m_strCurrSelObj = _T("");
  400. if(m_ObjCombox.GetCount() > 0)
  401. m_ObjCombox.GetWindowText(m_strCurrSelObj);
  402. //显示满意度调查统计信息
  403. ShowStatisticsData(&m_strCurrSelKind, &m_strSelOrder, &m_strCurrSelObj);
  404. }
  405. //选择对象
  406. void SatisfactionReportForm::OnCbnSelchangeCombo2()
  407. {
  408. m_nObjIdx = m_ObjCombox.GetCurSel();
  409. m_strCurrSelObj = _T("");
  410. m_ObjCombox.GetLBText(m_nObjIdx, m_strCurrSelObj);
  411. if(m_strCurrSelObj == _T(""))
  412. {
  413. MessageBox(_T("先选择订单!"));
  414. return;
  415. }
  416. m_strCurrSelKind = _T("");
  417. m_KindCombox.GetWindowText(m_strCurrSelKind);
  418. //显示满意度调查统计信息
  419. ShowStatisticsData(&m_strCurrSelKind, &m_strSelOrder, &m_strCurrSelObj);
  420. }
  421. /*---------------------------------------
  422. 函数名: StatisticsScore
  423. 描述: 统计总评分
  424. 参数:
  425. const CString* pOrder, //订单号
  426. CString& strScore //返回评分(如:满意)
  427. 返回值:
  428. ----------------------------------------*/
  429. void SatisfactionReportForm::StatisticsScore(IN const CString* pOrder, OUT CString& strScore)
  430. {
  431. if(pOrder == NULL || (*pOrder) == _T(""))
  432. return;
  433. int nSegment = 0; //一条记录的总分
  434. int i(0), j(0);
  435. int nStatisticsNum = 0; //统计数量
  436. int nScore = 0;
  437. for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
  438. {
  439. if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == (*pOrder))
  440. {
  441. nSegment = _ttoi(m_AllSurveyLogArr.ElementAt(j).ElementAt(7));
  442. break;
  443. }
  444. }
  445. if(nSegment == 0)
  446. return;
  447. for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
  448. {
  449. if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == (*pOrder))
  450. {
  451. //统计满意度
  452. nScore += _ttoi(m_AllSurveyLogArr.ElementAt(j).ElementAt(6));
  453. ++nStatisticsNum;
  454. }
  455. }
  456. if(nStatisticsNum == 0)
  457. return;
  458. int nMaxScore = nSegment*nStatisticsNum;
  459. int nAve = nMaxScore/5;
  460. if(nScore <= nAve)
  461. strScore = _T("非常不满意");
  462. else if(nScore > nAve && nScore <= nAve*2)
  463. strScore = _T("不满意");
  464. else if(nScore > nAve*2 && nScore <= nAve*3)
  465. strScore = _T("一般");
  466. else if(nScore > nAve*3 && nScore <= nAve*4)
  467. strScore = _T("满意");
  468. else if(nScore > nAve*4 && nScore <= nAve*5)
  469. strScore = _T("非常满意");
  470. }
  471. /*---------------------------------------
  472. 函数名: IntiSeviceObj
  473. 描述: 初始化服务对象
  474. 参数:
  475. const CString* pOrder, //订单号
  476. const CString& strKind //服务类型
  477. 返回值:
  478. ----------------------------------------*/
  479. void SatisfactionReportForm::IntiSeviceObj(IN const CString* pOrder, IN const CString& strKind)
  480. {
  481. if(pOrder == NULL || (*pOrder) == _T(""))
  482. return;
  483. SKINDKEY szKindKey[13] =
  484. {
  485. SKINDKEY(25,0,_T("门市")),SKINDKEY(15,3,_T("摄影")),SKINDKEY(17,4,_T("化妆")),SKINDKEY(19,0,_T("选片")),SKINDKEY(21,0,_T("设计")),
  486. SKINDKEY(23,0,_T("初修")),SKINDKEY(27,0,_T("精修")),SKINDKEY(0,0,_T("形设")),SKINDKEY(0,0,_T("取件")),SKINDKEY(0,0,_T("礼服")),
  487. SKINDKEY(0,0,_T("摄影助理")),SKINDKEY(0,0,_T("化妆助理")),SKINDKEY(0,0,_T("看设计人"))
  488. };
  489. //获取订单索引和景点索引
  490. int nDdjdIdx = 0;
  491. int nIdx = 0;
  492. int i = 0;
  493. for(i=0; i<13; i++)
  494. {
  495. if(szKindKey[i].strKind == strKind)
  496. {
  497. nIdx = szKindKey[i].nIdx;
  498. nDdjdIdx = szKindKey[i].nDdjdIdx;
  499. break;
  500. }
  501. }
  502. //将订单和景点保存的对象存在对象列表里
  503. //订单信息
  504. m_ObjCombox.ResetContent();
  505. for(i = 0; i<m_DindanInfoArr.GetSize(); i++)
  506. {
  507. if(m_DindanInfoArr.ElementAt(i).ElementAt(0) == (*pOrder) && nIdx != 0)
  508. m_ObjCombox.AddString(m_DindanInfoArr.ElementAt(i).ElementAt(nIdx));
  509. }
  510. //订单景点
  511. for(i=0; i<m_dindanjdArr.GetSize(); i++)
  512. {
  513. if(m_dindanjdArr.ElementAt(i).ElementAt(0) == (*pOrder) && nDdjdIdx != 0)
  514. {
  515. CString strName = m_dindanjdArr.ElementAt(i).ElementAt(nDdjdIdx);
  516. if(!CheckNameList(strName))
  517. m_ObjCombox.AddString(strName);
  518. }
  519. }
  520. //显示默认统计数据
  521. m_nObjIdx = 0;
  522. m_ObjCombox.SetCurSel(m_nObjIdx);
  523. }
  524. /*----------------------------------------
  525. 函数名: CheckNameList
  526. 描述: 检查名字列表是否已存在同名
  527. 参数:
  528. IN CONST CString& strName
  529. 返回值: 有同名=TRUE, 没有=FALSE;
  530. ----------------------------------------*/
  531. BOOL SatisfactionReportForm::CheckNameList(IN CONST CString& strName)
  532. {
  533. CString strSelName = _T("");
  534. int nSize = m_ObjCombox.GetCount();
  535. for(int i=0; i<nSize; ++i)
  536. {
  537. m_ObjCombox.GetLBText( i, strSelName);
  538. if(strSelName == strName)
  539. return TRUE;
  540. }
  541. return FALSE;
  542. }
  543. /*---------------------------------------
  544. 函数名: ShowStatisticsData
  545. 描述: 显示统计数据
  546. 参数:
  547. IN const CString* pKind, 类型,如:员工部门(摄影、门市)
  548. IN const CString* pOrder, 订单号
  549. IN const CString* pObj 对象,如:张三、李四
  550. 返回值:
  551. ----------------------------------------*/
  552. void SatisfactionReportForm::ShowStatisticsData(IN const CString* pKind, IN const CString* pOrder, IN const CString* pObj)
  553. {
  554. if(pObj == NULL || (*pObj) == _T("") || pOrder == NULL || (*pOrder) == _T("") || pKind == NULL || (*pKind) == _T(""))
  555. return;
  556. m_Surveylist.DeleteAllItems2();
  557. std::vector<int> vSingleDindanScore; //某调查类型的所有评分
  558. int szScoreNum[5] = {0}; //各级别评分数量
  559. int nCoutCustomer = 0; //客户总数
  560. CString strOldOrder = _T("");
  561. std::vector<CStringArray*> vSelSurveyLogs; //筛选后的调查记录
  562. int i = 0;
  563. for(i=0; i<m_AllSurveyLogArr.GetSize(); i++)
  564. {
  565. switch(m_nScoreModel)
  566. {
  567. case 1:
  568. {
  569. if(m_AllSurveyLogArr.ElementAt(i).ElementAt(4) == (*pObj) && m_AllSurveyLogArr.ElementAt(i).ElementAt(2) == (*pKind))
  570. {
  571. //保存同一类型和同一调查对象的评分
  572. vSelSurveyLogs.push_back(&(m_AllSurveyLogArr.ElementAt(i)));
  573. //计算客户总数
  574. if(strOldOrder != m_AllSurveyLogArr.ElementAt(i).ElementAt(5))
  575. {
  576. strOldOrder = m_AllSurveyLogArr.ElementAt(i).ElementAt(5);
  577. ++nCoutCustomer;
  578. }
  579. }
  580. }
  581. break;
  582. case 2:
  583. {
  584. if(m_AllSurveyLogArr.ElementAt(i).ElementAt(4) == (*pObj) && m_AllSurveyLogArr.ElementAt(i).ElementAt(2) == (*pKind) && (*pOrder) == m_AllSurveyLogArr.ElementAt(i).ElementAt(5))
  585. {
  586. //保存同一类型和同一调查对象的评分
  587. vSelSurveyLogs.push_back(&(m_AllSurveyLogArr.ElementAt(i)));
  588. //计算客户总数
  589. if(strOldOrder != m_AllSurveyLogArr.ElementAt(i).ElementAt(5))
  590. {
  591. strOldOrder = m_AllSurveyLogArr.ElementAt(i).ElementAt(5);
  592. ++nCoutCustomer;
  593. }
  594. }
  595. }
  596. break;
  597. }
  598. }
  599. //统计当前调查对象的所有评分级别的数量
  600. int nSameOrderNum = 0; //相同订单号的记录数量
  601. int nOrderScore = 0; //订单评分
  602. int nCurrScore = 0; //得分
  603. int nTotalScore = 0; //总分
  604. CString strCurrOrder = _T(""); //当前订单号
  605. std::vector<CStringArray*>::iterator it = vSelSurveyLogs.begin();
  606. for(;it != vSelSurveyLogs.end(); ++it)
  607. {
  608. CStringArray* pArr = (*it);
  609. if(pArr == NULL)
  610. continue;
  611. int nSingleMaxScore = _ttoi(pArr->ElementAt(7)); //一条记录总分
  612. nTotalScore += nSingleMaxScore;
  613. strCurrOrder = pArr->ElementAt(5);
  614. nOrderScore += _ttoi(pArr->ElementAt(6)); //统计每条订单的总得分
  615. nCurrScore += _ttoi(pArr->ElementAt(6));
  616. ++nSameOrderNum;
  617. if((it+1) != vSelSurveyLogs.end())
  618. {
  619. //是否相同订单号
  620. CString strNextOrder = (*(it+1))->ElementAt(5);
  621. if(strCurrOrder != strNextOrder)
  622. {
  623. //统计当前订单的每个等级的评分次数
  624. int nAve = (nSingleMaxScore*nSameOrderNum)/5; //每个级别的平均分 = (一条记录总分 * 相同订单号的记录数量)/5个等级
  625. if(nOrderScore <= nAve)
  626. szScoreNum[4] += 1;
  627. else if(nOrderScore <= nAve*2)
  628. szScoreNum[3] += 1;
  629. else if(nOrderScore <= nAve*3)
  630. szScoreNum[2] += 1;
  631. else if(nOrderScore <= nAve*4)
  632. szScoreNum[1] += 1;
  633. else if(nOrderScore <= nAve*5)
  634. szScoreNum[0] += 1;
  635. nSameOrderNum = 0;
  636. nOrderScore = 0;
  637. }
  638. }
  639. else
  640. {
  641. //统计当前订单的每个等级的评分次数
  642. int nSingleMaxScore = _ttoi(pArr->ElementAt(7)); //一条记录总分
  643. int nAve = (nSingleMaxScore*nSameOrderNum)/5; //每个级别的平均分 = (一条记录总分 * 相同订单号的记录数量)/5个等级
  644. if(nOrderScore <= nAve)
  645. szScoreNum[4] += 1;
  646. else if(nOrderScore <= nAve*2)
  647. szScoreNum[3] += 1;
  648. else if(nOrderScore <= nAve*3)
  649. szScoreNum[2] += 1;
  650. else if(nOrderScore <= nAve*4)
  651. szScoreNum[1] += 1;
  652. else if(nOrderScore <= nAve*5)
  653. szScoreNum[0] += 1;
  654. }
  655. }
  656. //将数据填入表格里
  657. m_Surveylist.m_arLabels.SetSize(1, 1);
  658. m_Surveylist.m_arLabels.ElementAt(0).Add((*pObj)); //调查对象,如:管理员
  659. //服务总数,如:服务过2个客户
  660. CString strCustomer = _T("");
  661. strCustomer.Format(_T("%d"), nCoutCustomer);
  662. m_Surveylist.m_arLabels.ElementAt(0).Add(strCustomer);
  663. //百分比计算
  664. for(i=0; i<5; i++)
  665. {
  666. CString strScore = _T("");
  667. if(szScoreNum[i] <= 0)
  668. strScore = _T("0(0%)");
  669. else
  670. {
  671. if(nCoutCustomer <= 0)
  672. strScore = _T("0(0%)");
  673. else
  674. {
  675. //百份比 = 某一个评分级别次数 / 客户总数 * 100
  676. strScore.Format(_T("%d(%d"), szScoreNum[i], (int)(((float)szScoreNum[i]/(float)nCoutCustomer)*100));
  677. strScore += _T("%)");
  678. }
  679. }
  680. m_Surveylist.m_arLabels.ElementAt(0).Add(strScore);
  681. }
  682. CString strAllScore = _T("");
  683. strAllScore.Format(_T("%d"), nCurrScore);
  684. m_Surveylist.m_arLabels.ElementAt(0).Add(strAllScore); //得分
  685. CString strTotalScore = _T("");
  686. strTotalScore.Format(_T("%d"), nTotalScore);
  687. m_Surveylist.m_arLabels.ElementAt(0).Add(strTotalScore); //总分
  688. m_Surveylist.m_LabelCount = 1;
  689. m_Surveylist.SetItemCountEx(1);
  690. }
  691. //总评
  692. void SatisfactionReportForm::OnTotalScoreRADIO()
  693. {
  694. m_nScoreModel = 1;
  695. ShowStatisticsData(&m_strCurrSelKind, &m_strSelOrder, &m_strCurrSelObj);
  696. }
  697. //单一订单评分
  698. void SatisfactionReportForm::OnSingleScoreRADIO()
  699. {
  700. m_nScoreModel = 2;
  701. ShowStatisticsData(&m_strCurrSelKind, &m_strSelOrder, &m_strCurrSelObj);
  702. }