IST00601F.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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 "ITSLangTransF.h"
  9. #include "ITS_OPLibF.h"
  10. #pragma hdrstop
  11. #include "IST00601F.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "FRAME_ChartF"
  15. #pragma link "cxButtons"
  16. #pragma link "cxCalc"
  17. #pragma link "cxCheckBox"
  18. #pragma link "cxClasses"
  19. #pragma link "cxContainer"
  20. #pragma link "cxControls"
  21. #pragma link "cxCustomData"
  22. #pragma link "cxData"
  23. #pragma link "cxDataStorage"
  24. #pragma link "cxEdit"
  25. #pragma link "cxFilter"
  26. #pragma link "cxGraphics"
  27. #pragma link "cxGrid"
  28. #pragma link "cxGridCustomTableView"
  29. #pragma link "cxGridCustomView"
  30. #pragma link "cxGridLevel"
  31. #pragma link "cxGridTableView"
  32. #pragma link "cxLookAndFeelPainters"
  33. #pragma link "cxLookAndFeels"
  34. #pragma link "cxProgressBar"
  35. #pragma link "cxSplitter"
  36. #pragma link "cxStyles"
  37. #pragma link "cxTextEdit"
  38. #pragma link "dxSkinBlack"
  39. #pragma link "dxSkinBlue"
  40. #pragma link "dxSkinsCore"
  41. #pragma link "dxSkinscxPCPainter"
  42. #pragma link "cxLabel"
  43. #pragma link "dxSkinMcSkin"
  44. #pragma resource "*.dfm"
  45. TIST00601 *IST00601 = NULL;
  46. //---------------------------------------------------------------------------
  47. __fastcall TIST00601::TIST00601(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  48. : TForm(Owner)
  49. {
  50. LangTrans->Translate(this, ITSDb_GetConnection());
  51. ITSSkin_Load(this);
  52. CMM_LoadForm(g_sFormsDir, this);
  53. FParent = hHandle;
  54. FStDateTime = sFrom;
  55. FEdDateTime = sTo;
  56. FIdList = sIdList;
  57. }
  58. //---------------------------------------------------------------------------
  59. __fastcall TIST00601::~TIST00601(void)
  60. {
  61. }
  62. //--------------------------------------------------------------------------
  63. void __fastcall TIST00601::FormInit()
  64. {
  65. ADOQry->Connection = ITSDb_GetConnection();
  66. m_pGDC = TvList->DataController;
  67. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<프로세스 상태통계 정보>";
  68. FRAMEChart1->FTitle = Caption;//"프로세스 상태통계";
  69. FRAMEChart1->SetChartLegend(lblText1->Caption, FrmLang->lblCnt->Caption);//"프로세스", "개수");
  70. FRAMEChart1->ChartValueDisplay(FRAMEChart1->ChkDisplayVal->Checked);
  71. FRAMEChart1->TvChart->ToolBox->CustomizeButton = true;
  72. FRAMEChart1->TvChart->Legend->Position = cppDefault;
  73. FRAMEChart1->TvChart->DiagramStackedBar->Enabled = true;
  74. FRAMEChart1->TvChart->DiagramStackedColumn->Enabled = true;
  75. //FRAMEChart1->TvChart->DiagramStackedColumn->Active = true;
  76. FRAMEChart1->TvChart->DiagramColumn->Active = true;
  77. LblSearch->Caption = FrmLang->lblQryCond->Caption + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TIST00601::FormShow(TObject *Sender)
  81. {
  82. FormInit();
  83. Refresh();
  84. TmrShow->Enabled = true;
  85. }
  86. //---------------------------------------------------------------------------
  87. void __fastcall TIST00601::CommClose()
  88. {
  89. CMM_SaveForm(g_sFormsDir, this);
  90. //IST00601 = NULL;
  91. }
  92. //---------------------------------------------------------------------------
  93. void __fastcall TIST00601::TmrShowTimer(TObject *Sender)
  94. {
  95. TmrShow->Enabled = false;
  96. Application->ProcessMessages();
  97. SelHistory();
  98. }
  99. //---------------------------------------------------------------------------
  100. void __fastcall TIST00601::ChkExpandClick(TObject *Sender)
  101. {
  102. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  103. }
  104. //---------------------------------------------------------------------------
  105. void __fastcall TIST00601::SelHistory()
  106. {
  107. TSqlCursor sqlCrs;
  108. String sQry;
  109. TADOQuery *pADO = ADOQry;
  110. sQry = "SELECT A.SYST_ID FCLT_ID, A.SYST_NM FCLT_NM, \r\n"
  111. " NVL(B.CNT, 0) CNT_SPS0, NVL(C.CNT, 0) CNT_SPS1, NVL(D.CNT, 0) CNT_SPS2, NVL(E.CNT, 0) CNT_SPS3, NVL(F.CNT, 0) CNT_SPS4 \r\n"
  112. " FROM TB_UNIT_SYST A, \r\n"
  113. " (SELECT SYST_ID, COUNT(SYST_ID) CNT FROM TB_UNIT_SYST_STTS_HS WHERE SYST_STTS_CD = 'SPS0' AND CRTN_DT BETWEEN :p01 AND :p02 GROUP BY SYST_ID \r\n"
  114. " ) B, \r\n"
  115. " (SELECT SYST_ID, COUNT(SYST_ID) CNT FROM TB_UNIT_SYST_STTS_HS WHERE SYST_STTS_CD = 'SPS1' AND CRTN_DT BETWEEN :p03 AND :p04 GROUP BY SYST_ID \r\n"
  116. " ) C, \r\n"
  117. " (SELECT SYST_ID, COUNT(SYST_ID) CNT FROM TB_UNIT_SYST_STTS_HS WHERE SYST_STTS_CD = 'SPS2' AND CRTN_DT BETWEEN :p05 AND :p06 GROUP BY SYST_ID \r\n"
  118. " ) D, \r\n"
  119. " (SELECT SYST_ID, COUNT(SYST_ID) CNT FROM TB_UNIT_SYST_STTS_HS WHERE SYST_STTS_CD = 'SPS3' AND CRTN_DT BETWEEN :p07 AND :p08 GROUP BY SYST_ID \r\n"
  120. " ) E, \r\n"
  121. " (SELECT SYST_ID, COUNT(SYST_ID) CNT FROM TB_UNIT_SYST_STTS_HS WHERE SYST_STTS_CD = 'SPS4' AND CRTN_DT BETWEEN :p09 AND :p10 GROUP BY SYST_ID \r\n"
  122. " ) F \r\n"
  123. " WHERE A.SYST_ID = B.SYST_ID(+) \r\n"
  124. " AND A.SYST_ID = C.SYST_ID(+) \r\n"
  125. " AND A.SYST_ID = D.SYST_ID(+) \r\n"
  126. " AND A.SYST_ID = E.SYST_ID(+) \r\n"
  127. " AND A.SYST_ID = F.SYST_ID(+) \r\n"
  128. " AND A.STTS_DSPL_YN = 'Y' \r\n"
  129. // " AND A.SYST_ID IN ('CTV01', 'DSRC01', 'EXT03', 'UOT01', 'UTP01', 'VMS01', 'WALL01', 'WEB01', 'WEB02') \r\n"
  130. " ORDER BY A.SYST_ID \r\n";
  131. try
  132. {
  133. ITSDb_SQLText(pADO, sQry);
  134. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  135. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  136. ITSDb_SQLBind(pADO, "p03", FStDateTime);
  137. ITSDb_SQLBind(pADO, "p04", FEdDateTime);
  138. ITSDb_SQLBind(pADO, "p05", FStDateTime);
  139. ITSDb_SQLBind(pADO, "p06", FEdDateTime);
  140. ITSDb_SQLBind(pADO, "p07", FStDateTime);
  141. ITSDb_SQLBind(pADO, "p08", FEdDateTime);
  142. ITSDb_SQLBind(pADO, "p09", FStDateTime);
  143. ITSDb_SQLBind(pADO, "p10", FEdDateTime);
  144. ITSDb_SQLOpen(pADO);
  145. DspHistory();
  146. }
  147. catch(EDatabaseError &E)
  148. {
  149. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  150. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  151. throw Exception(String(E.ClassName()) + E.Message);
  152. }
  153. catch(Exception &exception)
  154. {
  155. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  156. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  157. throw Exception(String(exception.ClassName()) + exception.Message);
  158. }
  159. }
  160. //---------------------------------------------------------------------------
  161. void __fastcall TIST00601::DspHistory()
  162. {
  163. TADOQuery *pADO = ADOQry;
  164. TcxGridChartView *TvChart = FRAMEChart1->TvChart;
  165. try
  166. {
  167. TcxGridChartSeries *pChart1 = NULL;
  168. TcxGridChartSeries *pChart2 = NULL;
  169. TvChart->ClearSeries();
  170. FRAMEChart1->ChartValueDisplay(FRAMEChart1->ChkDisplayVal->Checked);
  171. CMM_ClearGridTableView(TvList);
  172. int nRow = 0;
  173. int nDataCnt = 0;
  174. try {
  175. TvList->BeginUpdate();
  176. TvChart->BeginUpdate();
  177. nDataCnt = pADO->RecordCount;
  178. TvChart->DataController->RecordCount = nDataCnt;
  179. m_pGDC->RecordCount = nDataCnt;
  180. pChart1 = TvChart->CreateSeries();
  181. pChart1->DataBinding->ValueType = "Integer";
  182. pChart1->DisplayText = FrmLang->lblChartTotal->Caption;//"전체";
  183. pChart2 = TvChart->CreateSeries();
  184. pChart2->DataBinding->ValueType = "Integer";
  185. pChart2->DisplayText = lblText2->Caption;//"실행중";
  186. int nSPS0;
  187. int nSPS1;
  188. int nSPS2;
  189. int nSPS3;
  190. int nSPS4;
  191. //int nSPS_Total = nSPS0 + nSPS1 + nSPS2 + nSPS3 + nSPS4;
  192. int nSPS_Total = 288;
  193. for( ; !pADO->Eof; pADO->Next(), nRow++)
  194. {
  195. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("FCLT_ID")->AsString;
  196. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("FCLT_NM")->AsString;
  197. nSPS0 = pADO->FieldByName("CNT_SPS0")->AsInteger;
  198. nSPS1 = pADO->FieldByName("CNT_SPS1")->AsInteger;
  199. nSPS2 = pADO->FieldByName("CNT_SPS2")->AsInteger;
  200. nSPS3 = pADO->FieldByName("CNT_SPS3")->AsInteger;
  201. nSPS4 = pADO->FieldByName("CNT_SPS4")->AsInteger;
  202. m_pGDC->Values[nRow][Column03->Index] = nSPS_Total;
  203. m_pGDC->Values[nRow][Column04->Index] = nSPS1;
  204. m_pGDC->Values[nRow][Column05->Index] = nSPS_Total ? (double)nSPS1 / (double)nSPS_Total * (double)100 : 0;
  205. pChart1->Values[nRow] = nSPS_Total;
  206. pChart2->Values[nRow] = nSPS1;
  207. TvChart->Categories->Values[nRow] = m_pGDC->Values[nRow][Column02->Index];
  208. }
  209. }
  210. __finally
  211. {
  212. if (pADO)
  213. {
  214. pADO->Close();
  215. }
  216. TvChart->EndUpdate();
  217. TvList->EndUpdate();
  218. //CxList->SetFocus();
  219. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  220. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  221. Application->MessageBox(sEnd.c_str(),
  222. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  223. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  224. }
  225. }
  226. catch(EDatabaseError &E)
  227. {
  228. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  229. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  230. throw Exception(String(E.ClassName()) + E.Message);
  231. }
  232. catch(Exception &e)
  233. {
  234. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  235. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  236. throw Exception(String(e.ClassName()) + e.Message);
  237. }
  238. }
  239. //---------------------------------------------------------------------------
  240. void __fastcall TIST00601::OnMessage(TMessage &Msg)
  241. {
  242. switch (Msg.Msg)
  243. {
  244. case WM_PARAM_DATABASE:
  245. if (WP_DB_SELECT_OK == Msg.WParam)
  246. {
  247. //ShowMessage("Select Ok");
  248. }
  249. break;
  250. }
  251. }
  252. //---------------------------------------------------------------------------
  253. void __fastcall TIST00601::BtnExlSaveClick(TObject *Sender)
  254. {
  255. TcxGrid *pGrid = CxList;
  256. TcxGridTableView *pView = TvList;
  257. String sTitle= Caption;//"프로세스상태통계";
  258. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  259. }
  260. //---------------------------------------------------------------------------
  261. void __fastcall TIST00601::FormClose(TObject *Sender, TCloseAction &Action)
  262. {
  263. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  264. CommClose();
  265. //IST00601 = NULL;
  266. }
  267. //---------------------------------------------------------------------------
  268. void __fastcall TIST00601::FormDestroy(TObject *Sender)
  269. {
  270. CommClose();
  271. }
  272. //---------------------------------------------------------------------------