CRSM000MF.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. " C.UPDT_DT AS CLCT_DATE, \r\n"
  118. " (CASE WHEN NVL(TO_DATE(C.UPDT_DT, 'YYYYMMDDHH24MISS'), \r\n"
  119. " SYSDATE-60/140) < SYSDATE - 10/1440 \r\n"
  120. " THEN 'Y' ELSE 'N' END) AS MISSING, \r\n"
  121. " DECODE(C.CMNC_STTS_CD, 'CMS0', '1', '0') AS STATUS \r\n"
  122. " FROM TB_CRS A, TB_CRS_CMRA B, TB_CRS_CMRA_STTS C \r\n"
  123. " WHERE A.CROSS_ID = B.CROSS_ID \r\n"
  124. " AND B.CAM_ID = C.CAM_ID(+) \r\n"
  125. " AND A.DEL_YN = 'N' \r\n"
  126. " AND B.DEL_YN = 'N' \r\n"
  127. " ORDER BY A.CROSS_ID, B.CAM_ID \r\n";
  128. try
  129. {
  130. int nRow = 0;
  131. int nDataCnt = 0;
  132. TcxDataController *pGDC = TvList->DataController;
  133. try
  134. {
  135. pADO = new TADOQuery(NULL);
  136. pADO->Close();
  137. pADO->Connection = ITSDb_GetConnection();
  138. pADO->SQL->Clear();
  139. pADO->SQL->Text = sQry;
  140. pADO->Prepared = true;
  141. pADO->Open();
  142. CMM_ClearGridTableView(TvList);
  143. TvList->BeginUpdate();
  144. nDataCnt = pADO->RecordCount;
  145. pGDC->RecordCount = nDataCnt;
  146. for( ; !pADO->Eof; pADO->Next(), nRow++)
  147. {
  148. String CROSS_ID = pADO->FieldByName("CROSS_ID")->AsString;
  149. String CROSS_NAME = pADO->FieldByName("CROSS_NAME")->AsString;
  150. pGDC->Values[nRow][Col00->Index] = CROSS_ID + ": " + CROSS_NAME;
  151. pGDC->Values[nRow][Col10->Index] = CROSS_ID;
  152. pGDC->Values[nRow][Col01->Index] = CROSS_NAME;
  153. pGDC->Values[nRow][Col15->Index] = pADO->FieldByName("CROSS_TYPE")->AsString;
  154. pGDC->Values[nRow][Col11->Index] = pADO->FieldByName("CAM_ID")->AsString;
  155. pGDC->Values[nRow][Col05->Index] = pADO->FieldByName("CAM_NAME")->AsString;
  156. String CLCT_DATE = pADO->FieldByName("CLCT_DATE")->AsString;
  157. pGDC->Values[nRow][Col06->Index] = APP_FormatStr(CLCT_DATE, STR_DATETIME);
  158. //pGDC->Values[nRow][Col07->Index] = pADO->FieldByName("STATUS")->AsString;
  159. String MISSING = pADO->FieldByName("MISSING")->AsString;
  160. String STATUS = pADO->FieldByName("STATUS")->AsString;
  161. if (MISSING == "Y" || STATUS != "1")
  162. {
  163. pGDC->Values[nRow][Col07->Index] = "이상";
  164. }
  165. else
  166. {
  167. pGDC->Values[nRow][Col07->Index] = "정상";
  168. }
  169. }
  170. }
  171. catch(EDatabaseError &E)
  172. {
  173. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  174. DBERRORMSG("TCRSM000M::UpdateFacility", String(E.ClassName()), E.Message, sQry);
  175. throw Exception(String(E.ClassName()) + E.Message);
  176. }
  177. catch(Exception &e)
  178. {
  179. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  180. DBERRORMSG("TCRSM000M::UpdateFacility", String(e.ClassName()), e.Message, sQry);
  181. throw Exception(String(e.ClassName()) + e.Message);
  182. }
  183. }
  184. __finally
  185. {
  186. if (pADO)
  187. {
  188. pADO->Close();
  189. delete pADO;
  190. }
  191. TvList->EndUpdate();
  192. }
  193. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  194. }
  195. //---------------------------------------------------------------------------
  196. void __fastcall TCRSM000M::BtnExlSaveClick(TObject *Sender)
  197. {
  198. TcxGrid *pGrid = CxList;
  199. TcxGridTableView *pView = TvList;
  200. String sTitle= FTitle;
  201. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  202. }
  203. //---------------------------------------------------------------------------
  204. void __fastcall TCRSM000M::ChkExpandClick(TObject *Sender)
  205. {
  206. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  207. }
  208. //---------------------------------------------------------------------------
  209. void __fastcall TCRSM000M::TvListDataControllerFilterChanged(TObject *Sender)
  210. {
  211. CMM_SetFilterLike(TvList);
  212. }
  213. //---------------------------------------------------------------------------
  214. void __fastcall TCRSM000M::Col07CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas,
  215. TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone)
  216. {
  217. if( AViewInfo )
  218. {
  219. if(AViewInfo->Text == "정상")
  220. {
  221. ACanvas->Canvas->Font->Color = clTeal;
  222. }
  223. //else if(AViewInfo->Text == "통신장애")
  224. //{
  225. // ACanvas->Canvas->Font->Color = clRed;
  226. //}
  227. else if(AViewInfo->Text == "알수없음")
  228. {
  229. ACanvas->Canvas->Font->Color = clGray;
  230. }
  231. else
  232. {
  233. ACanvas->Canvas->Font->Color = clRed;
  234. //ACanvas->Canvas->Font->Color = clFuchsia;
  235. }
  236. }
  237. }
  238. //---------------------------------------------------------------------------
  239. void __fastcall TCRSM000M::Col09CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas,
  240. TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone)
  241. {
  242. if( AViewInfo )
  243. {
  244. if(AViewInfo->Text == "정상")
  245. {
  246. ACanvas->Canvas->Font->Color = clTeal;
  247. }
  248. else
  249. {
  250. ACanvas->Canvas->Font->Color = clRed;
  251. }
  252. }
  253. }
  254. //---------------------------------------------------------------------------
  255. void __fastcall TCRSM000M::Col26CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  256. bool &ADone)
  257. {
  258. if( AViewInfo )
  259. {
  260. if(AViewInfo->Text == "정상")
  261. {
  262. ACanvas->Canvas->Font->Color = clTeal;
  263. }
  264. else
  265. {
  266. ACanvas->Canvas->Font->Color = clRed;
  267. }
  268. }
  269. }
  270. //---------------------------------------------------------------------------
  271. void __fastcall TCRSM000M::Col16CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  272. bool &ADone)
  273. {
  274. //앞문/뒷문
  275. if( AViewInfo )
  276. {
  277. if(AViewInfo->Text == "닫힘")
  278. {
  279. ACanvas->Canvas->Font->Color = clTeal;
  280. }
  281. else
  282. {
  283. ACanvas->Canvas->Font->Color = clRed;
  284. }
  285. }
  286. }
  287. //---------------------------------------------------------------------------
  288. void __fastcall TCRSM000M::Col18CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  289. bool &ADone)
  290. {
  291. //팬/히터
  292. if( AViewInfo )
  293. {
  294. if(AViewInfo->Text == "중지")
  295. {
  296. ACanvas->Canvas->Font->Color = clTeal;
  297. }
  298. else
  299. {
  300. ACanvas->Canvas->Font->Color = clRed;
  301. }
  302. }
  303. }
  304. //---------------------------------------------------------------------------
  305. void __fastcall TCRSM000M::Col20CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  306. bool &ADone)
  307. {
  308. //비디오입력
  309. if( AViewInfo )
  310. {
  311. if(AViewInfo->Text.Pos("정상"))
  312. {
  313. ACanvas->Canvas->Font->Color = clTeal;
  314. }
  315. else
  316. {
  317. ACanvas->Canvas->Font->Color = clRed;
  318. }
  319. }
  320. }
  321. //---------------------------------------------------------------------------
  322. void __fastcall TCRSM000M::Col21CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  323. bool &ADone)
  324. {
  325. try
  326. {
  327. TColor tBrush = ACanvas->Brush->Color;
  328. TColor tFont = ACanvas->Font->Color;
  329. String sValue = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  330. if (sValue != "-" && sValue.ToIntDef(0) > g_AppCfg.Temp.AlarmValue)
  331. {
  332. tBrush = clFuchsia;
  333. tFont = clWhite;
  334. }
  335. ACanvas->SetBrushColor(tBrush);
  336. ACanvas->Font->Color = tFont;
  337. }
  338. catch(Exception &e)
  339. {
  340. }
  341. }
  342. //---------------------------------------------------------------------------