SatisfactionReportForm.cpp 22 KB

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