CRSM000MF.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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 "CDSFacilityF.h"
  9. #include "ITSLangTransF.h"
  10. #pragma hdrstop
  11. #include "CRSM000MF.h"
  12. #include "FrmMainF.h"
  13. #include "ITS_OPLibF.h"
  14. //---------------------------------------------------------------------------
  15. #pragma package(smart_init)
  16. #pragma link "cxButtons"
  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 "cxGridBandedTableView"
  29. #pragma link "cxGridCustomTableView"
  30. #pragma link "cxGridCustomView"
  31. #pragma link "cxGridLevel"
  32. #pragma link "cxGridTableView"
  33. #pragma link "cxGroupBox"
  34. #pragma link "cxLabel"
  35. #pragma link "cxLookAndFeelPainters"
  36. #pragma link "cxLookAndFeels"
  37. #pragma link "cxStyles"
  38. #pragma link "cxTextEdit"
  39. #pragma link "dxSkinBlue"
  40. #pragma link "dxSkinsCore"
  41. #pragma link "dxSkinscxPCPainter"
  42. #pragma link "dxSkinBlack"
  43. #pragma link "dxSkinMcSkin"
  44. #pragma resource "*.dfm"
  45. TCRSM000M *CRSM000M = NULL;
  46. //---------------------------------------------------------------------------
  47. __fastcall TCRSM000M::TCRSM000M(TComponent* Owner)
  48. : TForm(Owner)
  49. {
  50. LangTrans->Translate(this, ITSDb_GetConnection());
  51. ITSSkin_Load(this);
  52. CMM_LoadForm(g_sFormsDir, this);
  53. FTitle = Caption;
  54. FFacilityType = "";
  55. }
  56. //---------------------------------------------------------------------------
  57. void __fastcall TCRSM000M::CommClose()
  58. {
  59. try
  60. {
  61. CMM_SaveForm(g_sFormsDir, this);
  62. }
  63. catch(...)
  64. {
  65. }
  66. }
  67. //---------------------------------------------------------------------------
  68. void __fastcall TCRSM000M::FormShow(TObject *Sender)
  69. {
  70. Refresh();
  71. FormInit();
  72. TmrShow->Enabled = true;
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TCRSM000M::FormInit()
  76. {
  77. //TvList->OptionsView->NoDataToDisplayInfoText = "<교차로교통량 CCTV 상태현황>";
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TCRSM000M::TmrShowTimer(TObject *Sender)
  81. {
  82. TmrShow->Enabled = false;
  83. RefreshData();
  84. }
  85. //---------------------------------------------------------------------------
  86. void __fastcall TCRSM000M::BtnSearchClick(TObject *Sender)
  87. {
  88. BtnSearch->Enabled = false;
  89. TmrShow->Enabled = true;
  90. }
  91. //---------------------------------------------------------------------------
  92. void __fastcall TCRSM000M::RefreshData()
  93. {
  94. BtnSearch->Enabled = false;
  95. UpdateFacility();
  96. BtnSearch->Enabled = true;
  97. }
  98. //---------------------------------------------------------------------------
  99. void __fastcall TCRSM000M::BtnCloseClick(TObject *Sender)
  100. {
  101. Close();
  102. }
  103. //---------------------------------------------------------------------------
  104. void __fastcall TCRSM000M::FormClose(TObject *Sender, TCloseAction &Action)
  105. {
  106. CommClose();
  107. CRSM000M = NULL;
  108. Action = caFree;
  109. }
  110. //---------------------------------------------------------------------------
  111. void __fastcall TCRSM000M::UpdateFacility()
  112. {
  113. String sQry;
  114. TADOQuery *pADO = NULL;
  115. sQry = "SELECT A.CROSS_ID, A.NAME AS CROSS_NAME, A.CROSS_TYPE, \r\n"
  116. " B.CAM_ID, B.NAME AS CAM_NAME, \r\n"
  117. " TO_CHAR(C.CAP_DATE, 'YYYYMMDDHH24MISS') AS CLCT_DATE, \r\n"
  118. " (CASE WHEN NVL(C.CAP_DATE, SYSDATE-60/140) < SYSDATE - 10/1440 \r\n"
  119. " THEN 'Y' ELSE 'N' END) AS MISSING, \r\n"
  120. " C.STATUS \r\n"
  121. " FROM MST_CROSS A, MST_CCAM B, COL_CCAM_STATUS C \r\n"
  122. " WHERE A.CROSS_ID = B.CROSS_ID \r\n"
  123. " AND B.CAM_ID = C.CAM_ID(+) \r\n"
  124. " AND A.DEL_YN = 'N' \r\n"
  125. " AND B.DEL_YN = 'N' \r\n"
  126. " ORDER BY A.CROSS_ID, B.CAM_ID \r\n";
  127. try
  128. {
  129. int nRow = 0;
  130. int nDataCnt = 0;
  131. TcxDataController *pGDC = TvList->DataController;
  132. try
  133. {
  134. pADO = new TADOQuery(NULL);
  135. pADO->Close();
  136. pADO->Connection = ITSDb_GetConnection();
  137. pADO->SQL->Clear();
  138. pADO->SQL->Text = sQry;
  139. pADO->Prepared = true;
  140. pADO->Open();
  141. CMM_ClearGridTableView(TvList);
  142. TvList->BeginUpdate();
  143. nDataCnt = pADO->RecordCount;
  144. pGDC->RecordCount = nDataCnt;
  145. for( ; !pADO->Eof; pADO->Next(), nRow++)
  146. {
  147. String CROSS_ID = pADO->FieldByName("CROSS_ID")->AsString;
  148. String CROSS_NAME = pADO->FieldByName("CROSS_NAME")->AsString;
  149. pGDC->Values[nRow][Col00->Index] = CROSS_ID + ": " + CROSS_NAME;
  150. pGDC->Values[nRow][Col10->Index] = CROSS_ID;
  151. pGDC->Values[nRow][Col01->Index] = CROSS_NAME;
  152. pGDC->Values[nRow][Col15->Index] = pADO->FieldByName("CROSS_TYPE")->AsString;
  153. pGDC->Values[nRow][Col11->Index] = pADO->FieldByName("CAM_ID")->AsString;
  154. pGDC->Values[nRow][Col05->Index] = pADO->FieldByName("CAM_NAME")->AsString;
  155. String CLCT_DATE = pADO->FieldByName("CLCT_DATE")->AsString;
  156. pGDC->Values[nRow][Col06->Index] = APP_FormatStr(CLCT_DATE, STR_DATETIME);
  157. //pGDC->Values[nRow][Col07->Index] = pADO->FieldByName("STATUS")->AsString;
  158. String MISSING = pADO->FieldByName("MISSING")->AsString;
  159. String STATUS = pADO->FieldByName("STATUS")->AsString;
  160. if (MISSING == "Y" || STATUS != "1")
  161. {
  162. pGDC->Values[nRow][Col07->Index] = "이상";
  163. }
  164. else
  165. {
  166. pGDC->Values[nRow][Col07->Index] = "정상";
  167. }
  168. }
  169. }
  170. catch(EDatabaseError &E)
  171. {
  172. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  173. DBERRORMSG("TCRSM000M::UpdateFacility", String(E.ClassName()), E.Message, sQry);
  174. throw Exception(String(E.ClassName()) + E.Message);
  175. }
  176. catch(Exception &e)
  177. {
  178. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  179. DBERRORMSG("TCRSM000M::UpdateFacility", String(e.ClassName()), e.Message, sQry);
  180. throw Exception(String(e.ClassName()) + e.Message);
  181. }
  182. }
  183. __finally
  184. {
  185. if (pADO)
  186. {
  187. pADO->Close();
  188. delete pADO;
  189. }
  190. TvList->EndUpdate();
  191. }
  192. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  193. }
  194. //---------------------------------------------------------------------------
  195. void __fastcall TCRSM000M::BtnExlSaveClick(TObject *Sender)
  196. {
  197. TcxGrid *pGrid = CxList;
  198. TcxGridTableView *pView = TvList;
  199. String sTitle= FTitle;
  200. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  201. }
  202. //---------------------------------------------------------------------------
  203. void __fastcall TCRSM000M::ChkExpandClick(TObject *Sender)
  204. {
  205. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  206. }
  207. //---------------------------------------------------------------------------
  208. void __fastcall TCRSM000M::TvListDataControllerFilterChanged(TObject *Sender)
  209. {
  210. CMM_SetFilterLike(TvList);
  211. }
  212. //---------------------------------------------------------------------------
  213. void __fastcall TCRSM000M::Col07CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas,
  214. TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone)
  215. {
  216. if( AViewInfo )
  217. {
  218. if(AViewInfo->Text == "정상")
  219. {
  220. ACanvas->Canvas->Font->Color = clTeal;
  221. }
  222. //else if(AViewInfo->Text == "통신장애")
  223. //{
  224. // ACanvas->Canvas->Font->Color = clRed;
  225. //}
  226. else if(AViewInfo->Text == "알수없음")
  227. {
  228. ACanvas->Canvas->Font->Color = clGray;
  229. }
  230. else
  231. {
  232. ACanvas->Canvas->Font->Color = clRed;
  233. //ACanvas->Canvas->Font->Color = clFuchsia;
  234. }
  235. }
  236. }
  237. //---------------------------------------------------------------------------
  238. void __fastcall TCRSM000M::Col09CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas,
  239. TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone)
  240. {
  241. if( AViewInfo )
  242. {
  243. if(AViewInfo->Text == "정상")
  244. {
  245. ACanvas->Canvas->Font->Color = clTeal;
  246. }
  247. else
  248. {
  249. ACanvas->Canvas->Font->Color = clRed;
  250. }
  251. }
  252. }
  253. //---------------------------------------------------------------------------
  254. void __fastcall TCRSM000M::Col26CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  255. bool &ADone)
  256. {
  257. if( AViewInfo )
  258. {
  259. if(AViewInfo->Text == "정상")
  260. {
  261. ACanvas->Canvas->Font->Color = clTeal;
  262. }
  263. else
  264. {
  265. ACanvas->Canvas->Font->Color = clRed;
  266. }
  267. }
  268. }
  269. //---------------------------------------------------------------------------
  270. void __fastcall TCRSM000M::Col16CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  271. bool &ADone)
  272. {
  273. //앞문/뒷문
  274. if( AViewInfo )
  275. {
  276. if(AViewInfo->Text == "닫힘")
  277. {
  278. ACanvas->Canvas->Font->Color = clTeal;
  279. }
  280. else
  281. {
  282. ACanvas->Canvas->Font->Color = clRed;
  283. }
  284. }
  285. }
  286. //---------------------------------------------------------------------------
  287. void __fastcall TCRSM000M::Col18CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  288. bool &ADone)
  289. {
  290. //팬/히터
  291. if( AViewInfo )
  292. {
  293. if(AViewInfo->Text == "중지")
  294. {
  295. ACanvas->Canvas->Font->Color = clTeal;
  296. }
  297. else
  298. {
  299. ACanvas->Canvas->Font->Color = clRed;
  300. }
  301. }
  302. }
  303. //---------------------------------------------------------------------------
  304. void __fastcall TCRSM000M::Col20CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  305. bool &ADone)
  306. {
  307. //비디오입력
  308. if( AViewInfo )
  309. {
  310. if(AViewInfo->Text.Pos("정상"))
  311. {
  312. ACanvas->Canvas->Font->Color = clTeal;
  313. }
  314. else
  315. {
  316. ACanvas->Canvas->Font->Color = clRed;
  317. }
  318. }
  319. }
  320. //---------------------------------------------------------------------------
  321. void __fastcall TCRSM000M::Col21CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  322. bool &ADone)
  323. {
  324. try
  325. {
  326. TColor tBrush = ACanvas->Brush->Color;
  327. TColor tFont = ACanvas->Font->Color;
  328. String sValue = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  329. if (sValue != "-" && sValue.ToIntDef(0) > g_AppCfg.Temp.AlarmValue)
  330. {
  331. tBrush = clFuchsia;
  332. tFont = clWhite;
  333. }
  334. ACanvas->SetBrushColor(tBrush);
  335. ACanvas->Font->Color = tFont;
  336. }
  337. catch(Exception &e)
  338. {
  339. }
  340. }
  341. //---------------------------------------------------------------------------