FrmCctvLogSttsSubF.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "ITSDbF.h"
  7. #include "ITSLogF.h"
  8. #include "ITSLangTransF.h"
  9. #pragma hdrstop
  10. #include "FrmCctvLogSttsSubF.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 "cxLookAndFeelPainters"
  31. #pragma link "cxLookAndFeels"
  32. #pragma link "cxSplitter"
  33. #pragma link "cxStyles"
  34. #pragma link "cxTextEdit"
  35. #pragma link "dxSkinBlack"
  36. #pragma link "dxSkinBlue"
  37. #pragma link "dxSkinCaramel"
  38. #pragma link "dxSkinCoffee"
  39. #pragma link "dxSkinDarkRoom"
  40. #pragma link "dxSkinDarkSide"
  41. #pragma link "dxSkinFoggy"
  42. #pragma link "dxSkinGlassOceans"
  43. #pragma link "dxSkiniMaginary"
  44. #pragma link "dxSkinLilian"
  45. #pragma link "dxSkinLiquidSky"
  46. #pragma link "dxSkinLondonLiquidSky"
  47. #pragma link "dxSkinMcSkin"
  48. #pragma link "dxSkinMoneyTwins"
  49. #pragma link "dxSkinOffice2007Black"
  50. #pragma link "dxSkinOffice2007Blue"
  51. #pragma link "dxSkinOffice2007Green"
  52. #pragma link "dxSkinOffice2007Pink"
  53. #pragma link "dxSkinOffice2007Silver"
  54. #pragma link "dxSkinOffice2010Black"
  55. #pragma link "dxSkinOffice2010Blue"
  56. #pragma link "dxSkinOffice2010Silver"
  57. #pragma link "dxSkinsCore"
  58. #pragma link "dxSkinscxPCPainter"
  59. #pragma link "dxSkinSeven"
  60. #pragma link "dxSkinSharp"
  61. #pragma link "dxSkinSilver"
  62. #pragma link "dxSkinStardust"
  63. #pragma link "cxLabel"
  64. #pragma link "cxGridBandedTableView"
  65. #pragma resource "*.dfm"
  66. //TFrmCctvLogSttsSub *FrmCctvLogSttsSub = NULL;
  67. //---------------------------------------------------------------------------
  68. __fastcall TFrmCctvLogSttsSub::TFrmCctvLogSttsSub(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  69. : TForm(Owner)
  70. {
  71. LangTrans->Translate(this, ITSDb_GetConnection());
  72. ITSSkin_Load(this);
  73. //CMM_LoadForm(g_sFormsDir, this);
  74. FParent = hHandle;
  75. FStDateTime = sFrom;
  76. FEdDateTime = sTo;
  77. FIdList = sIdList;
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TFrmCctvLogSttsSub::FormInit()
  81. {
  82. ADOQry->Connection = ITSDb_GetConnection();
  83. m_pGDC = TvList->DataController;
  84. TvList->OptionsView->NoDataToDisplayInfoText = Caption + ": " + lblText1->Caption;//조회결과가 없습니다.";
  85. LblSearch->Caption = lblText2->Caption + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TFrmCctvLogSttsSub::FormShow(TObject *Sender)
  89. {
  90. FormInit();
  91. Refresh();
  92. TmrShow->Enabled = true;
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TFrmCctvLogSttsSub::CommClose()
  96. {
  97. //CMM_SaveForm(g_sFormsDir, this);
  98. //FrmVmsLogSub = NULL;
  99. }
  100. //---------------------------------------------------------------------------
  101. void __fastcall TFrmCctvLogSttsSub::TmrShowTimer(TObject *Sender)
  102. {
  103. TmrShow->Enabled = false;
  104. SelHistory();
  105. }
  106. //---------------------------------------------------------------------------
  107. void __fastcall TFrmCctvLogSttsSub::ChkExpandClick(TObject *Sender)
  108. {
  109. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  110. }
  111. //---------------------------------------------------------------------------
  112. void __fastcall TFrmCctvLogSttsSub::SelHistory()
  113. {
  114. TSqlCursor sqlCrs;
  115. String sQry;
  116. TADOQuery *pADO = ADOQry;
  117. #if 0
  118. sQry = "SELECT A.*, B.CCTV_CTLR_ID, B.CCTV_NM, B.CCTV_TYPE \r\n"
  119. " FROM TB_CCTV_CTLR_STTS_HS A, \r\n"
  120. " TB_CCTV_CTLR B \r\n"
  121. " WHERE B.CCTV_CTLR_NMBR IN(" + FIdList + ") \r\n"
  122. " AND A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  123. " AND A.CCTV_CTLR_NMBR = B.CCTV_CTLR_NMBR \r\n";
  124. #else
  125. sQry = "SELECT A.*, B.CCTV_CTLR_ID, B.ISTL_LCTN_NM AS CCTV_NM, B.CCTV_TYPE \r\n"
  126. " FROM TB_CCTV_STTS_HS A, \r\n"
  127. " TB_CCTV_CTLR B \r\n"
  128. " WHERE B.CCTV_MNGM_NMBR IN(" + FIdList + ") \r\n"
  129. " AND A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  130. " AND A.CCTV_MNGM_NMBR = B.CCTV_MNGM_NMBR \r\n";
  131. #endif
  132. try
  133. {
  134. ITSDb_SQLText(pADO, sQry);
  135. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  136. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  137. ITSDb_SQLOpen(pADO);
  138. }
  139. catch(EDatabaseError &E)
  140. {
  141. DBERRORMSG("History Qeury", String(E.ClassName()), E.Message, sQry);
  142. throw Exception(String(E.ClassName()) + E.Message);
  143. }
  144. catch(Exception &e)
  145. {
  146. DBERRORMSG("History Qeury", String(e.ClassName()), e.Message, sQry);
  147. throw Exception(String(e.ClassName()) + e.Message);
  148. }
  149. DspHistory();
  150. }
  151. //---------------------------------------------------------------------------
  152. void __fastcall TFrmCctvLogSttsSub::DspHistory()
  153. {
  154. TADOQuery *pADO = ADOQry;
  155. try
  156. {
  157. TcxGridChartSeries *pChart = NULL;
  158. CMM_ClearGridTableView(TvList);
  159. int nRow = 0;
  160. int nDataCnt = 0;
  161. try {
  162. TvList->BeginUpdate(lsimImmediate);
  163. nDataCnt = pADO->RecordCount;
  164. m_pGDC->RecordCount = nDataCnt;
  165. for( ; !pADO->Eof; pADO->Next(), nRow++)
  166. {
  167. m_pGDC->Values[nRow][Col00->Index] = pADO->FieldByName("CCTV_MNGM_NMBR")->AsString;
  168. m_pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("CCTV_CTLR_ID")->AsString;
  169. m_pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("CCTV_NM")->AsString;
  170. m_pGDC->Values[nRow][Col03->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("CRTN_DT")->AsString).FormatString(STR_DATETIME);
  171. String sComm = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  172. if (sComm != "CMS0")
  173. {
  174. m_pGDC->Values[nRow][Col04->Index] = lblMOS1->Caption;//"장애";
  175. m_pGDC->Values[nRow][Col13->Index] = "-"; //문열림
  176. m_pGDC->Values[nRow][Col11->Index] = "-"; //팬
  177. m_pGDC->Values[nRow][Col09->Index] = "-"; //히터
  178. m_pGDC->Values[nRow][Col08->Index] = "-"; //함체온도
  179. continue;
  180. }
  181. #if 1
  182. String sType = pADO->FieldByName("CCTV_TYPE")->AsString;
  183. m_pGDC->Values[nRow][Col04->Index] = lblMOS0->Caption;//"장애";
  184. if (sType != "1")
  185. {
  186. m_pGDC->Values[nRow][Col13->Index] = "-"; //문열림
  187. m_pGDC->Values[nRow][Col11->Index] = "-"; //팬
  188. m_pGDC->Values[nRow][Col09->Index] = "-"; //히터
  189. m_pGDC->Values[nRow][Col08->Index] = "-"; //함체온도
  190. continue;
  191. }
  192. #endif
  193. //도어
  194. String sDoor = pADO->FieldByName("CBOX_DOOR_STTS_CD")->AsString;
  195. if (sDoor == "CDS0") m_pGDC->Values[nRow][Col13->Index] = lblCDS0->Caption;//"닫힘";
  196. else if (sDoor == "CDS1") m_pGDC->Values[nRow][Col13->Index] = lblCDS1->Caption;//"열림";
  197. else m_pGDC->Values[nRow][Col13->Index] = "?";
  198. //팬상태
  199. String sFans = pADO->FieldByName("FAN_STTS_CD")->AsString;
  200. if (sFans == "PAS0") m_pGDC->Values[nRow][Col11->Index] = lblPAS0->Caption;//"동작";
  201. else if (sFans == "PAS1") m_pGDC->Values[nRow][Col11->Index] = lblPAS1->Caption;//"정지";
  202. else m_pGDC->Values[nRow][Col11->Index] = "?";
  203. //히터상태
  204. String sHets = pADO->FieldByName("HETR_STTS_CD")->AsString;
  205. if (sHets == "HTS0") m_pGDC->Values[nRow][Col09->Index] = lblHTS0->Caption;//"가동";
  206. else if (sHets == "HTS1") m_pGDC->Values[nRow][Col09->Index] = lblHTS1->Caption;//"중지";
  207. else m_pGDC->Values[nRow][Col09->Index] = "?";
  208. //온도
  209. m_pGDC->Values[nRow][Col08->Index] = pADO->FieldByName("CBOX_TMPR")->AsString;
  210. }
  211. }
  212. __finally
  213. {
  214. if (pADO)
  215. {
  216. pADO->Close();
  217. }
  218. TvList->EndUpdate();
  219. //CxList->SetFocus();
  220. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + lblCnt->Caption;//" 건";
  221. }
  222. }
  223. catch(EDatabaseError &E)
  224. {
  225. DBERRORMSG("History Results", String(E.ClassName()), E.Message, pADO->SQL->Text);
  226. throw Exception(String(E.ClassName()) + E.Message);
  227. }
  228. catch(Exception &e)
  229. {
  230. DBERRORMSG("History Results", String(e.ClassName()), e.Message, pADO->SQL->Text);
  231. throw Exception(String(e.ClassName()) + e.Message);
  232. }
  233. }
  234. //---------------------------------------------------------------------------
  235. void __fastcall TFrmCctvLogSttsSub::BtnExlSaveClick(TObject *Sender)
  236. {
  237. TcxGrid *pGrid = CxList;
  238. TcxGridTableView *pView = TvList;
  239. String sTitle= Caption;
  240. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  241. }
  242. //---------------------------------------------------------------------------
  243. void __fastcall TFrmCctvLogSttsSub::FormClose(TObject *Sender, TCloseAction &Action)
  244. {
  245. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  246. CommClose();
  247. }
  248. //---------------------------------------------------------------------------
  249. void __fastcall TFrmCctvLogSttsSub::FormDestroy(TObject *Sender)
  250. {
  251. //
  252. }
  253. //---------------------------------------------------------------------------
  254. void __fastcall TFrmCctvLogSttsSub::Col05CustomDrawCell(TcxCustomGridTableView *Sender,
  255. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  256. bool &ADone)
  257. {
  258. try
  259. {
  260. TColor tColor;
  261. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  262. tColor = ACanvas->Brush->Color;
  263. #if 1
  264. if (sStatus.Pos("-")) tColor = clGray;
  265. else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
  266. else if (sStatus.Pos(lblPWS0->Caption)) tColor = clYellow;
  267. else if (sStatus.Pos(lblCDS1->Caption)) tColor = clYellow;
  268. else if (sStatus.Pos(lblPAS0->Caption)) tColor = clYellow;
  269. else if (sStatus.Pos(lblHTS0->Caption)) tColor = clYellow;
  270. else if (sStatus.Pos("0")) tColor = clRed;
  271. else tColor = clLime;
  272. #else
  273. if (sStatus.Pos("-")) tColor = clGray;
  274. else if (sStatus.Pos("장애")) tColor = clRed;
  275. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  276. else if (sStatus.Pos("열림")) tColor = clYellow;
  277. else if (sStatus.Pos("동작")) tColor = clYellow;
  278. else if (sStatus.Pos("가동")) tColor = clYellow;
  279. else if (sStatus.Pos("0")) tColor = clRed;
  280. else tColor = clLime;
  281. #endif
  282. ACanvas->SetBrushColor(tColor);
  283. ACanvas->Font->Color = clBlack;
  284. }
  285. catch(Exception &e)
  286. {
  287. }
  288. }
  289. //---------------------------------------------------------------------------
  290. void __fastcall TFrmCctvLogSttsSub::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
  291. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  292. bool &ADone)
  293. {
  294. try
  295. {
  296. TColor tColor;
  297. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  298. tColor = ACanvas->Brush->Color;
  299. #if 1
  300. if (sStatus.Pos("-")) tColor = clGray;
  301. else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
  302. else if (sStatus.Pos(lblPWS1->Caption)) tColor = clRed;
  303. else tColor = clLime;
  304. #else
  305. if (sStatus.Pos("-")) tColor = clGray;
  306. else if (sStatus.Pos("Error")) tColor = clRed;
  307. else if (sStatus.Pos("Off")) tColor = clRed;
  308. else tColor = clLime;
  309. #endif
  310. ACanvas->SetBrushColor(tColor);
  311. ACanvas->Font->Color = clBlack;
  312. }
  313. catch(Exception &e)
  314. {
  315. }
  316. }
  317. //---------------------------------------------------------------------------
  318. void __fastcall TFrmCctvLogSttsSub::Col08CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  319. bool &ADone)
  320. {
  321. try
  322. {
  323. TColor tBrush = ACanvas->Brush->Color;
  324. TColor tFont = ACanvas->Font->Color;
  325. String sValue = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  326. if (sValue != "-" && sValue.ToIntDef(0) > g_AppCfg.Temp.AlarmValue)
  327. {
  328. tBrush = clFuchsia;
  329. tFont = clWhite;
  330. }
  331. ACanvas->SetBrushColor(tBrush);
  332. ACanvas->Font->Color = tFont;
  333. }
  334. catch(Exception &e)
  335. {
  336. }
  337. }
  338. //---------------------------------------------------------------------------