Satisfaction.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. // Satisfaction.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "Satisfaction.h"
  6. #include "MyMdi.H"
  7. #include "SelBrunDevice.h"
  8. #include "SatisfactionSurvey.h"
  9. #include "SatisfactionCfg.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. SatisfactionSurvey* g_Surveydlg = NULL;
  16. IMPLEMENT_DYNCREATE(Satisfaction, MyFormView)
  17. Satisfaction::Satisfaction() : MyFormView(Satisfaction::IDD)
  18. , m_nCurSelIdx(-1)
  19. , m_strStartTimer(_T(""))
  20. , m_strEndTimer(_T(""))
  21. , m_nShowType(0)
  22. {
  23. memset(m_szColName, 0, sizeof(TCHAR)*64);
  24. }
  25. Satisfaction::~Satisfaction()
  26. {
  27. if(g_Surveydlg)
  28. g_Surveydlg->SendMessage(WM_CLOSE);
  29. g_Surveydlg = NULL;
  30. }
  31. void Satisfaction::DoDataExchange(CDataExchange* pDX)
  32. {
  33. MyFormView::DoDataExchange(pDX);
  34. DDX_Control(pDX, IDC_LIST2, m_List1);
  35. }
  36. BEGIN_MESSAGE_MAP(Satisfaction, MyFormView)
  37. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  38. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  39. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  40. ON_BN_CLICKED(IDC_OpenSurvey_Btn, OnOpenSurveyBtn)
  41. ON_BN_CLICKED(IDC_OrderToday_Btn, OnOrderTodayBtn)
  42. ON_BN_CLICKED(IDC_Configuration_Btn, OnConfigurationBtn)
  43. ON_BN_CLICKED(IDC_TodayPhotograph_Btn, OnTodayPhotographBtn)
  44. ON_BN_CLICKED(IDC_ChoosePhotos_Btn, OnChoosePhotosBtn)
  45. ON_BN_CLICKED(IDC_LookSample_Btn, OnLookSampleBtn)
  46. ON_BN_CLICKED(IDC_CollectToday_Btn, OnCollectTodayBtn)
  47. ON_BN_CLICKED(IDC_WeddingToday_Btn, OnWeddingTodayBtn)
  48. ON_BN_CLICKED(IDC_SetSurveyItem_Btn, OnSetSurveyCfg)
  49. END_MESSAGE_MAP()
  50. #ifdef _DEBUG
  51. void Satisfaction::AssertValid() const
  52. {
  53. MyFormView::AssertValid();
  54. }
  55. void Satisfaction::Dump(CDumpContext& dc) const
  56. {
  57. MyFormView::Dump(dc);
  58. }
  59. #endif
  60. void Satisfaction::OnInitialUpdate()
  61. {
  62. MyFormView::OnInitialUpdate();
  63. CMyMdi Mdi;
  64. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  65. if(IsHasRights2new(19)==0)
  66. GetDlgItem(IDC_SetSurveyItem_Btn)->EnableWindow(0);
  67. CRect rc2;
  68. GetWindowRect(rc2);
  69. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  70. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  71. #ifdef CHILD_VERSION
  72. // 16 column
  73. m_List1.SetHeadings("订单号,120;家长姓名,120;宝宝姓名,120;手机,120;固定电话,120;订单日期,120;门市,120;满意度,120;拨打情况,120;回访日期,120;通话时长,120;回访人员,120;备注,120");
  74. #else
  75. // 16 column
  76. m_List1.SetHeadings("订单号,120;男宾姓名,120;女宾姓名,120;男宾电话,120;女宾电话,120;订单日期,120;门市,120;满意度,120;拨打情况,120;回访日期,120;通话时长,120;回访人员,120;备注,120");
  77. #endif
  78. m_List1.LoadColumnInfo(250);
  79. ScreenToClient(rc2);
  80. rc2.bottom += 200;
  81. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  82. GetData();
  83. }
  84. //------------------------------------------------
  85. /*
  86. 函数名: FillGrid
  87. 描述: 填表
  88. 参数:
  89. const int nTimeType 按时间类型显示数据
  90. 返回值:
  91. */
  92. //------------------------------------------------
  93. void Satisfaction::FillGrid(const int nTimeType)
  94. {
  95. //获取时间
  96. CTime startTime, endTime;
  97. ((CDateTimeCtrl*)GetDlgItem(IDC_Date_Start))->GetTime(startTime);
  98. ((CDateTimeCtrl*)GetDlgItem(IDC_Date_End))->GetTime(endTime);
  99. m_List1.DeleteAllItems2();
  100. int nCount = 0;
  101. int nSize = m_List1array.GetSize();
  102. m_List1.m_arLabels.SetSize(nSize, 1);
  103. int i=0;
  104. for(i=0; i<m_List1array.GetSize(); i++)
  105. {
  106. CString strtmp = _T(""); //时间日期
  107. int nY(0), nM(0), nD(0);
  108. int nObjIdx = 0; //对象索引
  109. switch(nTimeType)
  110. {
  111. case 0:
  112. case 1:
  113. case 6:
  114. strtmp = m_List1array.ElementAt(i).ElementAt(5); //订单
  115. nObjIdx = 25; //接单
  116. break;
  117. case 2:
  118. strtmp = m_List1array.ElementAt(i).ElementAt(6);
  119. nObjIdx = 15; //摄影
  120. break;
  121. case 3:
  122. strtmp = m_List1array.ElementAt(i).ElementAt(8);
  123. nObjIdx = 19; //选片
  124. break;
  125. case 4:
  126. strtmp = m_List1array.ElementAt(i).ElementAt(10);
  127. nObjIdx = 29; //看样/看设计
  128. break;
  129. case 5:
  130. strtmp = m_List1array.ElementAt(i).ElementAt(11);
  131. nObjIdx = 17; //化妆
  132. break;
  133. }
  134. if(strtmp == _T(""))
  135. continue;
  136. nY = _ttoi(strtmp.Mid(0,4));
  137. nM = _ttoi(strtmp.Mid(5,2));
  138. nD = _ttoi(strtmp.Mid(8,2));
  139. if(nY <= 0 || (nM <= 0 || nM > 12) || (nD > 31 || nD <=0))
  140. continue;
  141. CString strDinDanTime = _T("");
  142. CTime tm(nY, nM, nD, 0, 0, 0);
  143. /*
  144. if(tm >= startTime && tm <= endTime)
  145. {
  146. */
  147. CString strOrderNum = m_List1array.ElementAt(i).ElementAt(0);
  148. m_List1.m_arLabels.ElementAt(nCount).Add(strOrderNum); //订单号
  149. m_List1.m_arLabels.ElementAt(nCount).Add(m_List1array.ElementAt(i).ElementAt(1)); //家长姓名/男宾姓名
  150. m_List1.m_arLabels.ElementAt(nCount).Add(m_List1array.ElementAt(i).ElementAt(2)); //宝宝姓名/女宾姓名
  151. m_List1.m_arLabels.ElementAt(nCount).Add(m_List1array.ElementAt(i).ElementAt(3)); //手机/男宾电话
  152. m_List1.m_arLabels.ElementAt(nCount).Add(m_List1array.ElementAt(i).ElementAt(4)); //固定电话/女宾电话
  153. strtmp = m_List1array.ElementAt(nCount).ElementAt(0);
  154. nY = atoi(strtmp.Mid(0,4));
  155. nM = atoi(strtmp.Mid(4,2));
  156. nD = atoi(strtmp.Mid(6,2));
  157. strDinDanTime.Format(_T("%04d-%02d-%02d"), nY, nM, nD);
  158. m_List1.m_arLabels.ElementAt(nCount).Add(strDinDanTime); //订单时间
  159. CString strObjName = m_List1array.ElementAt(i).ElementAt(nObjIdx);
  160. m_List1.m_arLabels.ElementAt(nCount).Add(strObjName); //访问对象
  161. //获取满意度
  162. CString strScore = _T("");
  163. GetScoreAndSurveyObj(strObjName, strOrderNum, strScore);
  164. m_List1.m_arLabels.ElementAt(nCount).Add(strScore); //满意度
  165. m_List1.m_arLabels.ElementAt(nCount).Add(_T("")); //拨打情况
  166. m_List1.m_arLabels.ElementAt(nCount).Add(_T("")); //回访日期
  167. m_List1.m_arLabels.ElementAt(nCount).Add(_T("")); //通话时长
  168. CString strCS = _T("");
  169. for(int j=0; j<m_AllSurveyLogArr.GetSize(); j++)
  170. {
  171. CString strOrder = m_AllSurveyLogArr.ElementAt(j).ElementAt(5);
  172. if(strOrder == strOrderNum)
  173. {
  174. strCS = m_AllSurveyLogArr.ElementAt(j).ElementAt(11);
  175. break;
  176. }
  177. }
  178. m_List1.m_arLabels.ElementAt(nCount).Add(strCS); //回访人员
  179. m_List1.m_arLabels.ElementAt(nCount).Add(_T("")); //备注
  180. ++nCount;
  181. /*
  182. }
  183. */
  184. }
  185. if(nCount != 0)
  186. {
  187. m_List1.m_LabelCount = nCount;
  188. m_List1.SetItemCountEx(nCount);
  189. }
  190. }
  191. void Satisfaction::OnBUTclose() // 关闭按钮;
  192. {
  193. GetParent()->SendMessage(WM_CLOSE);
  194. }
  195. BOOL Satisfaction::PreTranslateMessage(MSG* pMsg)
  196. {
  197. try
  198. {
  199. if (pMsg->message == WM_KEYDOWN)
  200. {
  201. switch (pMsg->wParam)
  202. {
  203. case VK_RETURN:
  204. OnButton1();
  205. return 1;
  206. case 0x43: // copy
  207. if ((GetKeyState(VK_CONTROL) & 0x80))
  208. {
  209. GetFocus()->SendMessage(WM_COPY);
  210. return TRUE;
  211. }
  212. break;
  213. case 0x56: //Ctrl + V:
  214. if ((GetKeyState(VK_CONTROL) & 0x80))
  215. {
  216. GetFocus()->SendMessage(WM_PASTE);
  217. return TRUE;
  218. }
  219. break;
  220. case 0x58: // cut
  221. if ((GetKeyState(VK_CONTROL) & 0x80))
  222. {
  223. GetFocus()->SendMessage(WM_CUT);
  224. return TRUE;
  225. }
  226. break;
  227. case 0x5A: //undo
  228. case 0x59: //redo
  229. if ((GetKeyState(VK_CONTROL) & 0x80))
  230. {
  231. GetFocus()->SendMessage(WM_UNDO);
  232. return TRUE;
  233. }
  234. break;
  235. }
  236. }
  237. }
  238. catch (...)
  239. {
  240. }
  241. return MyFormView::PreTranslateMessage(pMsg);
  242. }
  243. void Satisfaction::OnButton1() // 查询按钮;
  244. {
  245. CTime startTime, endTime;
  246. ((CDateTimeCtrl*)GetDlgItem(IDC_Date_Start))->GetTime(startTime);
  247. ((CDateTimeCtrl*)GetDlgItem(IDC_Date_End))->GetTime(endTime);
  248. CString strStartCT(_T("")), strEndCT(_T(""));
  249. strStartCT = startTime.Format(_T("%Y%m%d"));
  250. strEndCT = endTime.Format(_T("%Y%m%d"));
  251. CString filter = _T("");
  252. m_List1array.RemoveAll();
  253. #ifdef LKAY_VERSION
  254. filter = _T("dindan@(dindantype<>'意向客户' or dindantype is null) and id between '") + strStartCT + _T("-000' and '") + strEndCT + _T("-999'");
  255. #else
  256. filter = _T("dindan@id between '") + strStartCT + _T("-000' and '") + strEndCT + _T("-999'");
  257. #endif
  258. g_sendhead.bsql = 0;
  259. g_sendhead.code[0] = 234; //获取dindan信息和对应的满意度记录
  260. g_sendhead.tabcount = 1;
  261. g_pMainWnd->ProcessChatMessageRequest2(filter);
  262. if (g_bSendOK == 0)
  263. return;
  264. DataToArray(&m_List1array);
  265. m_AllSurveyLogArr.RemoveAll();
  266. //获取所有记录
  267. g_sendhead.bsql = 0;
  268. g_sendhead.code[0] = 234;
  269. g_sendhead.tabcount = 1;
  270. CString strfilter = _T("GetAllSurveyData@") + strStartCT + _T("@") + strEndCT;
  271. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  272. if(g_bSendOK == 0)
  273. return;
  274. DataToArray(&m_AllSurveyLogArr);
  275. OnOrderTodayBtn();
  276. }
  277. void Satisfaction::GetData()
  278. {
  279. m_ScoreTypeArr.RemoveAll();
  280. //获取分数类型
  281. g_sendhead.bsql = 0;
  282. g_sendhead.code[0] = 234;
  283. g_sendhead.tabcount = 1;
  284. CString strfilter = _T("GetScoreType@");
  285. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  286. if(g_bSendOK == 0)
  287. return;
  288. DataToArray(&m_ScoreTypeArr);
  289. m_kindArr.RemoveAll();
  290. //获取服务类别
  291. g_sendhead.bsql = 0;
  292. g_sendhead.code[0] = 234;
  293. g_sendhead.tabcount = 1;
  294. strfilter = _T("SvrKind@");
  295. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  296. if(g_bSendOK == 0)
  297. return;
  298. DataToArray(&m_kindArr);
  299. m_cfgArr.RemoveAll();
  300. //获取配置信息
  301. g_sendhead.bsql = 0;
  302. g_sendhead.code[0] = 234;
  303. g_sendhead.tabcount = 1;
  304. strfilter = _T("SatisfactionCfg@");
  305. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  306. if (g_bSendOK == 0)
  307. return;
  308. DataToArray(&m_cfgArr);
  309. FillGrid(0);
  310. }
  311. void Satisfaction::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  312. {
  313. LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
  314. // TODO: 在此添加控件通知处理程序代码
  315. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  316. if(pNMListView->iItem != -1)
  317. {
  318. //单击行列pNMListView->iItem, pNMListView->iSubItem
  319. m_nCurSelIdx = pNMListView->iItem;
  320. }
  321. *pResult = 0;
  322. }
  323. //打开调查项
  324. void Satisfaction::OnOpenSurveyBtn()
  325. {
  326. if(m_nCurSelIdx == -1)
  327. {
  328. MessageBox(_T("请选择订单!"));
  329. return;
  330. }
  331. CTime startTime, endTime;
  332. ((CDateTimeCtrl*)GetDlgItem(IDC_Date_Start))->GetTime(startTime);
  333. ((CDateTimeCtrl*)GetDlgItem(IDC_Date_End))->GetTime(endTime);
  334. CString strStartCT(_T("")), strEndCT(_T(""));
  335. strStartCT = startTime.Format(_T("%Y%m%d"));
  336. strEndCT = endTime.Format(_T("%Y%m%d"));
  337. int i = 0;
  338. CString strOrderNum = m_List1.GetItemText(m_nCurSelIdx, 0);
  339. CStringArray* pCurrDinDan = NULL;
  340. for(i=0; i<m_List1array.GetSize(); i++)
  341. {
  342. if(m_List1array.ElementAt(i).ElementAt(0) == strOrderNum)
  343. pCurrDinDan = &m_List1array.ElementAt(i);
  344. }
  345. if(pCurrDinDan == NULL)
  346. {
  347. MessageBox(_T("请选择订单!"));
  348. return;
  349. }
  350. if(g_Surveydlg)
  351. {
  352. g_Surveydlg->SendMessage(WM_CLOSE);
  353. g_Surveydlg = NULL;
  354. }
  355. //进入调查界面
  356. SatisfactionSurvey dlg;
  357. g_Surveydlg = &dlg;
  358. dlg.m_strOrderNum = strOrderNum; //订单号
  359. dlg.m_pCurrDindan = pCurrDinDan; //当前选择的订单
  360. dlg.m_pkindArr = &m_kindArr; //所有类型
  361. dlg.m_pCfgArr = &m_cfgArr; //相对应的调查配置表
  362. dlg.DoModal();
  363. //调查结束后需更新所有记录
  364. //获取所有记录
  365. m_AllSurveyLogArr.RemoveAll();
  366. g_sendhead.bsql = 0;
  367. g_sendhead.code[0] = 234;
  368. g_sendhead.tabcount = 1;
  369. CString strfilter = _T("GetAllSurveyData@") + strStartCT + _T("@") + strEndCT;
  370. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  371. if(g_bSendOK == 0)
  372. return;
  373. DataToArray(&m_AllSurveyLogArr);
  374. //更新显示数据
  375. FillGrid(m_nShowType);
  376. m_nCurSelIdx = -1;
  377. g_Surveydlg = NULL;
  378. GetData();
  379. OnButton1();
  380. }
  381. //订单
  382. void Satisfaction::OnOrderTodayBtn()
  383. {
  384. ChangeColName(_T("接单"));
  385. m_nShowType = 0;
  386. FillGrid(m_nShowType);
  387. }
  388. //形设
  389. void Satisfaction::OnConfigurationBtn()
  390. {
  391. ChangeColName(_T("接单"));
  392. m_nShowType = 1;
  393. FillGrid(m_nShowType);
  394. }
  395. //拍照
  396. void Satisfaction::OnTodayPhotographBtn()
  397. {
  398. ChangeColName(_T("摄影"));
  399. m_nShowType = 2;
  400. FillGrid(m_nShowType);
  401. }
  402. //选片
  403. void Satisfaction::OnChoosePhotosBtn()
  404. {
  405. ChangeColName(_T("选片"));
  406. m_nShowType = 3;
  407. FillGrid(m_nShowType);
  408. }
  409. //看样
  410. void Satisfaction::OnLookSampleBtn()
  411. {
  412. ChangeColName(_T("看样"));
  413. m_nShowType = 4;
  414. FillGrid(m_nShowType);
  415. }
  416. //化妆
  417. void Satisfaction::OnCollectTodayBtn()
  418. {
  419. ChangeColName(_T("化妆"));
  420. m_nShowType = 5;
  421. FillGrid(m_nShowType);
  422. }
  423. //婚庆
  424. void Satisfaction::OnWeddingTodayBtn()
  425. {
  426. ChangeColName(_T("接单"));
  427. m_nShowType = 6;
  428. FillGrid(m_nShowType);
  429. }
  430. void Satisfaction::ChangeColName(LPSTR lpName)
  431. {
  432. LVCOLUMN lov;
  433. lov.mask = LVCF_TEXT; //取字符掩码
  434. lov.pszText = m_szColName;
  435. lov.cchTextMax = MAX_PATH;
  436. m_List1.GetColumn(6, &lov);
  437. memset(m_szColName, 0, sizeof(TCHAR)*64);
  438. #ifdef VC60
  439. _tcscpy(m_szColName, lpName);
  440. #else
  441. _tcscpy_s(m_szColName, 64, lpName);
  442. #endif
  443. m_List1.SetColumn(6, &lov);
  444. }
  445. //------------------------------------------------------
  446. /*
  447. 函数名: GetScore
  448. 描述: 获取评分
  449. 参数:
  450. CString& strScore 返回评分
  451. 返回值:
  452. */
  453. //------------------------------------------------------
  454. void Satisfaction::GetScoreAndSurveyObj(const CString& strObj, const CString& strOrderNum, CString& strScore)
  455. {
  456. int nSegment = 0; //一条记录的总分
  457. int i(0), j(0);
  458. int nStatisticsNum = 0; //统计数量
  459. int nScore = 0;
  460. for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
  461. {
  462. if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == strOrderNum && strObj == m_AllSurveyLogArr.ElementAt(j).ElementAt(4))
  463. {
  464. CString strKindName = m_AllSurveyLogArr.ElementAt(j).ElementAt(2);
  465. for(i=0; i<m_cfgArr.GetSize(); i++)
  466. {
  467. if(m_cfgArr.ElementAt(i).ElementAt(2) == strKindName)
  468. {
  469. //获取一条记录的总分
  470. nSegment = _ttoi(m_cfgArr.ElementAt(i).ElementAt(3));
  471. break;
  472. }
  473. }
  474. }
  475. if(nSegment != 0)
  476. break;
  477. }
  478. if(nSegment == 0)
  479. return;
  480. for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
  481. {
  482. if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == strOrderNum && strObj == m_AllSurveyLogArr.ElementAt(j).ElementAt(4))
  483. {
  484. //统计满意度
  485. nScore += _ttoi(m_AllSurveyLogArr.ElementAt(j).ElementAt(6));
  486. ++nStatisticsNum;
  487. }
  488. }
  489. if(nStatisticsNum == 0)
  490. return;
  491. int nMaxScore = nSegment*nStatisticsNum; //总分
  492. int nAve = nMaxScore/5; //
  493. if(nScore <= nAve)
  494. strScore = _T("非常不满意");
  495. else if(nScore > nAve && nScore <= nAve*2)
  496. strScore = _T("不满意");
  497. else if(nScore > nAve*2 && nScore <= nAve*3)
  498. strScore = _T("一般");
  499. else if(nScore > nAve*3 && nScore <= nAve*4)
  500. strScore = _T("满意");
  501. else if(nScore > nAve*4 && nScore <= nAve*5)
  502. strScore = _T("非常满意");
  503. }
  504. void Satisfaction::OnSetSurveyCfg()
  505. {
  506. SatisfactionCfg dlg;
  507. dlg.DoModal();
  508. }