DSRH0701F.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "WindowMsgF.h"
  8. #include "ITS_OPLibF.h"
  9. #pragma hdrstop
  10. #include "DSRH0701F.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  14. #pragma link "cxCalc"
  15. #pragma link "cxCheckBox"
  16. #pragma link "cxClasses"
  17. #pragma link "cxContainer"
  18. #pragma link "cxControls"
  19. #pragma link "cxCustomData"
  20. #pragma link "cxData"
  21. #pragma link "cxDataStorage"
  22. #pragma link "cxEdit"
  23. #pragma link "cxFilter"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxGrid"
  26. #pragma link "cxGridCustomTableView"
  27. #pragma link "cxGridCustomView"
  28. #pragma link "cxGridLevel"
  29. #pragma link "cxGridTableView"
  30. #pragma link "cxLabel"
  31. #pragma link "cxLookAndFeelPainters"
  32. #pragma link "cxLookAndFeels"
  33. #pragma link "cxSplitter"
  34. #pragma link "cxStyles"
  35. #pragma link "cxTextEdit"
  36. #pragma link "dxSkinBlack"
  37. #pragma link "dxSkinBlue"
  38. #pragma link "dxSkinsCore"
  39. #pragma link "dxSkinscxPCPainter"
  40. #pragma link "dxSkinMcSkin"
  41. #pragma resource "*.dfm"
  42. TDSRH0701 *DSRH0701 = NULL;
  43. //---------------------------------------------------------------------------
  44. __fastcall TDSRH0701::TDSRH0701(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList, int nStat)
  45. : TForm(Owner)
  46. {
  47. LangTrans->Translate(this, ITSDb_GetConnection());
  48. ITSSkin_Load(this);
  49. CMM_LoadForm(g_sFormsDir, this);
  50. FParent = hHandle;
  51. FStDateTime = sFrom;
  52. FEdDateTime = sTo;
  53. FIdList = sIdList;
  54. FSTAT = nStat;
  55. //Caption = "DSRC OBU 수집 통계";
  56. }
  57. //---------------------------------------------------------------------------
  58. __fastcall TDSRH0701::~TDSRH0701(void)
  59. {
  60. }
  61. //--------------------------------------------------------------------------
  62. void __fastcall TDSRH0701::FormInit()
  63. {
  64. ADOQry->Connection = ITSDb_GetConnection();
  65. m_pGDC = TvList->DataController;
  66. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<DSRC OBU 수집 통계 정보>";
  67. cxSplitter1->Visible = false;
  68. PnlChart->Visible = false;
  69. #if 0
  70. FRAMEChart1->FTitle = "DSRC OBU 수집 통계";
  71. FRAMEChart1->SetChartLegend("수집시각", "개수");
  72. FRAMEChart1->ChartValueDisplay(FRAMEChart1->ChkDisplayVal->Checked);
  73. FRAMEChart1->TvChart->ToolBox->CustomizeButton = true;
  74. FRAMEChart1->TvChart->Legend->Position = cppDefault;
  75. FRAMEChart1->TvChart->DiagramStackedBar->Enabled = true;
  76. FRAMEChart1->TvChart->DiagramStackedColumn->Enabled = true;
  77. FRAMEChart1->TvChart->DiagramStackedColumn->Active = true;
  78. #endif
  79. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TDSRH0701::FormShow(TObject *Sender)
  83. {
  84. FormInit();
  85. Refresh();
  86. TmrShow->Enabled = true;
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TDSRH0701::CommClose()
  90. {
  91. CMM_SaveForm(g_sFormsDir, this);
  92. //DSRH0701 = NULL;
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TDSRH0701::TmrShowTimer(TObject *Sender)
  96. {
  97. TmrShow->Enabled = false;
  98. Application->ProcessMessages();
  99. SelHistory();
  100. }
  101. //---------------------------------------------------------------------------
  102. void __fastcall TDSRH0701::ChkExpandClick(TObject *Sender)
  103. {
  104. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  105. }
  106. //---------------------------------------------------------------------------
  107. void __fastcall TDSRH0701::SelHistory()
  108. {
  109. TSqlCursor sqlCrs;
  110. String sQry;
  111. String sTable;
  112. TADOQuery *pADO = ADOQry;
  113. switch(FSTAT)
  114. {
  115. case 0: sTable = "TB_RSE_OBU_CLCT_HH_STAT";
  116. break;
  117. case 1: sTable = "TB_RSE_OBU_CLCT_DD_STAT";
  118. break;
  119. default: return;
  120. }
  121. sQry = "SELECT M.ID, M.RSE_ID, M.ISTL_LCTN_NM, H.STAT_DT AS COLL_DT, \r\n"
  122. " TO_DATE(H.STAT_DT, 'YYYYMMDDHH24MISS') AS COLL_DT2, \r\n"
  123. " H.STAT_DT, H.DAY_TYPE_CD, H.CLCT_NUM, \r\n"
  124. " C.DAY_TYPE_CDNM \r\n"
  125. " FROM TB_RSE_MSTR M, \r\n"
  126. " " + sTable + " H, \r\n"
  127. " (SELECT CMMN_CD AS DAY_TYPE_CD, CMMN_CD_KOR_NM AS DAY_TYPE_CDNM \r\n"
  128. " FROM TB_CMMN_CD \r\n"
  129. " WHERE CMMN_CLSF_CD = 'DTW') C \r\n"
  130. " WHERE M.ID IN (" + FIdList + ") \r\n"
  131. " AND M.ID = H.ID \r\n"
  132. " AND H.STAT_DT BETWEEN :p01 AND :p02 \r\n"
  133. " AND H.DAY_TYPE_CD = C.DAY_TYPE_CD \r\n"
  134. " ORDER BY M.ID, H.STAT_DT \r\n";
  135. try
  136. {
  137. ITSDb_SQLText(pADO, sQry);
  138. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  139. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  140. ITSDb_SQLOpen(pADO);
  141. DspHistory();
  142. }
  143. catch(EDatabaseError &E)
  144. {
  145. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  146. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  147. throw Exception(String(E.ClassName()) + E.Message);
  148. }
  149. catch(Exception &exception)
  150. {
  151. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  152. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  153. throw Exception(String(exception.ClassName()) + exception.Message);
  154. }
  155. }
  156. //---------------------------------------------------------------------------
  157. void __fastcall TDSRH0701::DspHistory()
  158. {
  159. TADOQuery *pADO = ADOQry;
  160. TcxGridChartView *TvChart = FRAMEChart1->TvChart;
  161. try
  162. {
  163. #if 0
  164. TcxGridChartSeries *pChart1 = NULL;
  165. TcxGridChartSeries *pChart2 = NULL;
  166. TcxGridChartSeries *pChart3 = NULL;
  167. TcxGridChartSeries *pChart4 = NULL;
  168. TcxGridChartSeries *pChart5 = NULL;
  169. TcxGridChartSeries *pChart6 = NULL;
  170. TvChart->ClearSeries();
  171. FRAMEChart1->ChartValueDisplay(FRAMEChart1->ChkDisplayVal->Checked);
  172. #endif
  173. CMM_ClearGridTableView(TvList);
  174. int nRow = 0;
  175. int nDataCnt = 0;
  176. try {
  177. TvList->BeginUpdate();
  178. nDataCnt = pADO->RecordCount;
  179. m_pGDC->RecordCount = nDataCnt;
  180. #if 0
  181. TvChart->BeginUpdate();
  182. TvChart->DataController->RecordCount = nDataCnt;
  183. pChart1 = TvChart->CreateSeries();
  184. pChart1->DataBinding->ValueType = "Integer";
  185. pChart1->DisplayText = "원활";
  186. pChart2 = TvChart->CreateSeries();
  187. pChart2->DataBinding->ValueType = "Integer";
  188. pChart2->DisplayText = "지체";
  189. pChart3 = TvChart->CreateSeries();
  190. pChart3->DataBinding->ValueType = "Integer";
  191. pChart3->DisplayText = "정체";
  192. pChart4 = TvChart->CreateSeries();
  193. pChart4->DataBinding->ValueType = "Integer";
  194. pChart4->DisplayText = "정보없음";
  195. #endif
  196. String sTimeFormat = STR_DATE;
  197. if (FSTAT == 0) sTimeFormat = STR_DATEHOUR;
  198. for( ; !pADO->Eof; pADO->Next(), nRow++)
  199. {
  200. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("ID")->AsString;
  201. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("RSE_ID")->AsString;
  202. m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("ISTL_LCTN_NM")->AsString;
  203. String sDbDate = pADO->FieldByName("COLL_DT")->AsString;
  204. //m_pGDC->Values[nRow][Column04->Index] = ITSUtil_FormatStr(sDbDate, sTimeFormat);
  205. m_pGDC->Values[nRow][Column04->Index] = ITSUtil_StrToDateTime(sDbDate).FormatString(sTimeFormat);
  206. m_pGDC->Values[nRow][Column05->Index] = pADO->FieldByName("DAY_TYPE_CDNM")->AsString;
  207. m_pGDC->Values[nRow][Column06->Index] = pADO->FieldByName("CLCT_NUM")->AsInteger;
  208. #if 0
  209. pChart1->Values[nRow] = m_pGDC->Values[nRow][Column04->Index];
  210. pChart2->Values[nRow] = m_pGDC->Values[nRow][Column05->Index];
  211. pChart3->Values[nRow] = m_pGDC->Values[nRow][Column06->Index];
  212. pChart4->Values[nRow] = m_pGDC->Values[nRow][Column07->Index];
  213. TvChart->Categories->Values[nRow] = pADO->FieldByName("STAT_DT")->AsString.SubString(1,12);
  214. #endif
  215. }
  216. }
  217. __finally
  218. {
  219. if (pADO)
  220. {
  221. pADO->Close();
  222. }
  223. #if 0
  224. TvChart->EndUpdate();
  225. #endif
  226. TvList->EndUpdate();
  227. //CxList->SetFocus();
  228. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  229. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  230. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  231. }
  232. }
  233. catch(EDatabaseError &E)
  234. {
  235. throw Exception(String(E.ClassName()) + E.Message);
  236. }
  237. catch(...)
  238. {
  239. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  240. }
  241. }
  242. //---------------------------------------------------------------------------
  243. void __fastcall TDSRH0701::OnMessage(TMessage &Msg)
  244. {
  245. switch (Msg.Msg)
  246. {
  247. case WM_PARAM_DATABASE:
  248. if (WP_DB_SELECT_OK == Msg.WParam)
  249. {
  250. //ShowMessage("Select Ok");
  251. }
  252. break;
  253. }
  254. }
  255. //---------------------------------------------------------------------------
  256. void __fastcall TDSRH0701::BtnExlSaveClick(TObject *Sender)
  257. {
  258. TcxGrid *pGrid = CxList;
  259. TcxGridTableView *pView = TvList;
  260. String sTitle = "DSRC OBU 수집통계";
  261. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  262. }
  263. //---------------------------------------------------------------------------
  264. void __fastcall TDSRH0701::FormClose(TObject *Sender, TCloseAction &Action)
  265. {
  266. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  267. CommClose();
  268. //DSRH0701 = NULL;
  269. }
  270. //---------------------------------------------------------------------------
  271. void __fastcall TDSRH0701::FormDestroy(TObject *Sender)
  272. {
  273. CommClose();
  274. }
  275. //---------------------------------------------------------------------------