TAS0010MF.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "CDSIfscF.h"
  7. #include "AppGlobalF.h"
  8. #include "ITSLangTransF.h"
  9. #include "ITSMapF.h"
  10. #pragma hdrstop
  11. #include "TAS0010MF.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "cxButtons"
  15. #pragma link "cxCalc"
  16. #pragma link "cxCalendar"
  17. #pragma link "cxClasses"
  18. #pragma link "cxContainer"
  19. #pragma link "cxControls"
  20. #pragma link "cxCustomData"
  21. #pragma link "cxData"
  22. #pragma link "cxDataStorage"
  23. #pragma link "cxDropDownEdit"
  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 "cxGroupBox"
  33. #pragma link "cxLabel"
  34. #pragma link "cxLookAndFeelPainters"
  35. #pragma link "cxLookAndFeels"
  36. #pragma link "cxMaskEdit"
  37. #pragma link "cxSpinEdit"
  38. #pragma link "cxSplitter"
  39. #pragma link "cxStyles"
  40. #pragma link "cxTextEdit"
  41. #pragma link "cxTimeEdit"
  42. #pragma link "cxTrackBar"
  43. #pragma link "dxSkinBlack"
  44. #pragma link "dxSkinBlue"
  45. #pragma link "dxSkinsCore"
  46. #pragma link "dxSkinscxPCPainter"
  47. #pragma link "FRAME_OpenMapF"
  48. #pragma resource "*.dfm"
  49. TTAS0010M *TAS0010M = NULL;
  50. //---------------------------------------------------------------------------
  51. void TTAS0010M_MapCallback(TObject *ASender, const String AFunc, const String AArgs, const bool AFirst)
  52. {
  53. try
  54. {
  55. if (!TAS0010M) return;
  56. TAS0010M->OpenMapCallback(ASender, AFunc, AArgs, AFirst);
  57. }
  58. catch(Exception &exception)
  59. {
  60. }
  61. }
  62. //---------------------------------------------------------------------------
  63. __fastcall TTAS0010M::TTAS0010M(TComponent* Owner)
  64. : TForm(Owner)
  65. {
  66. LangTrans->Translate(this, ITSDb_GetConnection());
  67. ITSSkin_Load(this);
  68. CMM_LoadForm(g_sFormsDir, this);
  69. FTitle = Caption;//"혼잡지도분석";
  70. FTargetIdx = 0;
  71. CbTarget->ItemIndex = FTargetIdx;
  72. FIfscMngr = new TTrafficValManager();
  73. CbLinkLevel->ItemIndex = 1; //IFSC
  74. FLinkLevel = CbLinkLevel->ItemIndex+1;
  75. FLayerIdx = LyrTp_Node;
  76. FRAMEOpenMap1->LayerIdx = FLayerIdx;
  77. FRAMEOpenMap1->ChkShowNmbr->Visible = false;
  78. FRAMEOpenMap1->BtnMoveMapToFit->Visible = false;
  79. FRAMEOpenMap1->MapCallbackFunc = TTAS0010M_MapCallback;
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TTAS0010M::CommClose()
  83. {
  84. try
  85. {
  86. if (BtnStop->Enabled)
  87. BtnStopClick((TObject*)BtnStop);
  88. delete FIfscMngr;
  89. CMM_SaveForm(g_sFormsDir, this);
  90. }
  91. catch(...)
  92. {
  93. }
  94. }
  95. //---------------------------------------------------------------------------
  96. void __fastcall TTAS0010M::FormShow(TObject *Sender)
  97. {
  98. Refresh();
  99. FRAMEOpenMap1->OpenMap();
  100. FormInit();
  101. TmrShow->Enabled = true;
  102. }
  103. //---------------------------------------------------------------------------
  104. void __fastcall TTAS0010M::FormInit()
  105. {
  106. ADOQry->Connection = ITSDb_GetConnection();
  107. ADOSta->Connection = ITSDb_GetConnection();
  108. m_pGDC = TvList->DataController;
  109. TDateTime dtNow = Now() - ((double)3 / (double)24);
  110. DtStDate->Date = dtNow;
  111. DtEdDate->Date = Now();
  112. //DtStTime->EditValue = dtNow.FormatString("hh") + ":00";
  113. dtNow = Now() - ((double)2 / (double)24);
  114. //DtEdTime->EditValue = dtNow.FormatString("hh") + ":59";
  115. DtStTime->Time = StrToDateTime(dtNow.FormatString("hh") + ":00");
  116. DtEdTime->Time = StrToDateTime(dtNow.FormatString("hh") + ":59");
  117. }
  118. //---------------------------------------------------------------------------
  119. void __fastcall TTAS0010M::TmrShowTimer(TObject *Sender)
  120. {
  121. TmrShow->Enabled = false;
  122. if (TmrShow->Tag == 1)
  123. {
  124. int nIndex = m_pGDC->FocusedRecordIndex;
  125. if (nIndex < 0)
  126. {
  127. cxTrackBar1->Position = 0;
  128. FStatTime = "";
  129. BtnPlay->Enabled = true;
  130. BtnStop->Enabled = false;
  131. BtnSearch->Enabled = true;
  132. return;
  133. }
  134. if (m_pGDC->FocusedRecordIndex + 1 == m_pGDC->RecordCount)
  135. {
  136. cxTrackBar1->Position = 0;
  137. FStatTime = "";
  138. BtnPlay->Enabled = true;
  139. BtnStop->Enabled = false;
  140. BtnSearch->Enabled = true;
  141. return;
  142. }
  143. m_pGDC->FocusedRecordIndex++;
  144. nIndex = m_pGDC->FocusedRecordIndex;
  145. FSimIndex = nIndex;
  146. cxTrackBar1->Position = nIndex;
  147. FStatTime = VarToStr(m_pGDC->Values[nIndex][Column04->Index]);
  148. //cxGroupBox1->Caption = "▶ 소통정보 표출 - " + VarToStr(m_pGDC->Values[nIndex][Column02->Index]);
  149. cxGroupBox1->Caption = lblText1->Caption + " - " + VarToStr(m_pGDC->Values[nIndex][Column02->Index]);
  150. SelStatisticsHistory(FStatTime);
  151. BtnPlay->Enabled = false;
  152. BtnStop->Enabled = true;
  153. TmrShow->Interval = SeRefreshSec->Value * 1000;
  154. TmrShow->Enabled = true;
  155. }
  156. }
  157. //---------------------------------------------------------------------------
  158. void __fastcall TTAS0010M::InitGisLink()
  159. {
  160. if (!FRAMEOpenMap1->MapStart) return;
  161. try
  162. {
  163. if (FLinkLevel == 2)
  164. {
  165. ItsIfscManager->FLists.Lock();
  166. try
  167. {
  168. FOR_STL(TItsIfsc*, pIfsc, ItsIfscManager->FLists)
  169. {
  170. if (pIfsc->DEL_YN == "Y") continue;
  171. if (pIfsc->IsVertex)
  172. {
  173. TTrafficVal* pTraf = new TTrafficVal();
  174. pTraf->ID = pIfsc->IFSC_ID;
  175. pTraf->IsUpdate = true;
  176. pTraf->GRADE_VAL = 0;
  177. FIfscMngr->FLists.Push(pTraf->ID, pTraf);
  178. sJs.printf(L"addEditLink('%s', '%s', '%s', '%s', '%s', '%s')",
  179. pIfsc->IFSC_ID.c_str(),
  180. pIfsc->IFSC_NM.c_str(),
  181. pIfsc->STRT_NM.c_str(),
  182. pIfsc->END_NM.c_str(),
  183. pIfsc->X_CRDN_ARR.c_str(),
  184. pIfsc->Y_CRDN_ARR.c_str());
  185. FRAMEOpenMap1->ExecScript(sJs);
  186. }
  187. }
  188. }
  189. __finally
  190. {
  191. ItsIfscManager->FLists.UnLock();
  192. }
  193. FRAMEOpenMap1->ExecScript("makeEditLinkLayer()");
  194. }
  195. }
  196. catch(...)
  197. {
  198. }
  199. }
  200. //---------------------------------------------------------------------------
  201. void __fastcall TTAS0010M::BtnSearchClick(TObject *Sender)
  202. {
  203. Application->ProcessMessages();
  204. TSqlCursor sqlCrs((TControl*)BtnSearch);
  205. FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hhnn");
  206. FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hhnn");
  207. if (FStDateTime > FEdDateTime)
  208. {
  209. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작시각이 검색 종료시각 보다 큽니다.",
  210. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  211. ActiveControl = DtStDate;
  212. return;
  213. }
  214. if (StrToInt(DtEdTime->Time.FormatString("hh")) - StrToInt(DtStTime->Time.FormatString("hh")) >= 3)
  215. {
  216. Application->MessageBox(lblText2->Caption.c_str(),//L"3시간 이상의 정보를 조회할 수 없습니다.",
  217. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  218. ActiveControl = DtStDate;
  219. return;
  220. }
  221. if (FLinkLevel != CbLinkLevel->ItemIndex+1)
  222. {
  223. //링크레벨을 고정하지 않고 변경할 경우 여기에서 링크 버텍스를 다시 로딩해 줘야 한다.
  224. }
  225. FLinkLevel = CbLinkLevel->ItemIndex+1;
  226. FTargetIdx = CbTarget->ItemIndex;
  227. switch(FTargetIdx)
  228. {
  229. case 0: //이력 정보(통계 5분 정보)
  230. case 1: //통계 15분 정보
  231. FStDateTime = FStDateTime + "00";
  232. FEdDateTime = FEdDateTime + "59";
  233. break;
  234. case 2: //패턴 5분 정보
  235. case 3: //패턴 15분 정보
  236. FStDateTime = FStDateTime;
  237. FEdDateTime = FEdDateTime;
  238. break;
  239. default: return;
  240. }
  241. SelHistory();
  242. ClearGis();
  243. }
  244. //---------------------------------------------------------------------------
  245. void __fastcall TTAS0010M::BtnCloseClick(TObject *Sender)
  246. {
  247. Close();
  248. }
  249. //---------------------------------------------------------------------------
  250. void __fastcall TTAS0010M::FormClose(TObject *Sender, TCloseAction &Action)
  251. {
  252. CommClose();
  253. TAS0010M = NULL;
  254. Action = caFree;
  255. }
  256. //---------------------------------------------------------------------------
  257. void __fastcall TTAS0010M::DtStDatePropertiesValidate(TObject *Sender, Variant &DisplayValue, TCaption &ErrorText, bool &Error)
  258. {
  259. DtEdDate->Date = DtStDate->Date;
  260. }
  261. //---------------------------------------------------------------------------
  262. void __fastcall TTAS0010M::SelHistory()
  263. {
  264. TSqlCursor sqlCrs;
  265. String sQry;
  266. TADOQuery *pADO = ADOQry;
  267. //select substr('20180108xxyy', 1, 6), substr('20180108xxyy', 9, 4) from dual
  268. switch(FTargetIdx)
  269. {
  270. case 0: //이력 정보(통계 5분 정보)
  271. sQry = "SELECT PRCN_DT AS PRCN_DT, COUNT(IFSC_ID) CNT \r\n"
  272. " FROM TB_IFSC_TRAF_HS A \r\n"
  273. " WHERE PRCN_DT BETWEEN :p01 AND :p03 \r\n"
  274. " GROUP BY PRCN_DT \r\n"
  275. " ORDER BY PRCN_DT \r\n";
  276. ITSDb_SQLText(pADO, sQry);
  277. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  278. ITSDb_SQLBind(pADO, "p03", FEdDateTime);
  279. break;
  280. case 1: //통계 15분 정보
  281. sQry = "SELECT STAT_DT AS PRCN_DT, COUNT(IFSC_ID) CNT \r\n"
  282. " FROM TB_IFSC_15M_STAT A \r\n"
  283. " WHERE STAT_DT BETWEEN :p01 AND :p03 \r\n"
  284. " GROUP BY STAT_DT \r\n"
  285. " ORDER BY STAT_DT \r\n";
  286. ITSDb_SQLText(pADO, sQry);
  287. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  288. ITSDb_SQLBind(pADO, "p03", FEdDateTime);
  289. break;
  290. case 2: //패턴 5분 정보
  291. sQry = "SELECT STAT_YM || ' ' || STAT_HM AS PRCN_DT, COUNT(IFSC_ID) CNT \r\n"
  292. " FROM TB_IFSC_5M_PTRN A \r\n"
  293. " WHERE STAT_YM = SUBSTR(:p01, 1, 6) \r\n"
  294. " AND STAT_HM BETWEEN SUBSTR(:p02, 9, 4) AND SUBSTR(:p03, 9, 4) \r\n"
  295. " GROUP BY STAT_YM || ' ' || STAT_HM \r\n"
  296. " ORDER BY STAT_YM || ' ' || STAT_HM \r\n";
  297. ITSDb_SQLText(pADO, sQry);
  298. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  299. ITSDb_SQLBind(pADO, "p02", FStDateTime);
  300. ITSDb_SQLBind(pADO, "p03", FEdDateTime);
  301. break;
  302. case 3: //패턴 15분 정보
  303. sQry = "SELECT STAT_YM || ' ' || STAT_HM AS PRCN_DT, COUNT(IFSC_ID) CNT \r\n"
  304. " FROM TB_IFSC_15M_PTRN A \r\n"
  305. " WHERE STAT_YM = SUBSTR(:p01, 1, 6) \r\n"
  306. " AND STAT_HM BETWEEN SUBSTR(:p02, 9, 4) AND SUBSTR(:p03, 9, 4) \r\n"
  307. " GROUP BY STAT_YM || ' ' || STAT_HM \r\n"
  308. " ORDER BY STAT_YM || ' ' || STAT_HM \r\n";
  309. ITSDb_SQLText(pADO, sQry);
  310. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  311. ITSDb_SQLBind(pADO, "p02", FStDateTime);
  312. ITSDb_SQLBind(pADO, "p03", FEdDateTime);
  313. break;
  314. }
  315. try
  316. {
  317. ITSDb_SQLOpen(pADO);
  318. DspHistory();
  319. }
  320. catch(EDatabaseError &E)
  321. {
  322. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  323. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  324. throw Exception(String(E.ClassName()) + E.Message);
  325. }
  326. catch(Exception &e)
  327. {
  328. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  329. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
  330. throw Exception(String(e.ClassName()) + e.Message);
  331. }
  332. }
  333. //---------------------------------------------------------------------------
  334. void __fastcall TTAS0010M::DspHistory()
  335. {
  336. TADOQuery *pADO = ADOQry;
  337. try
  338. {
  339. CMM_ClearGridTableView(TvList);
  340. int nRow = 0;
  341. try
  342. {
  343. TvList->BeginUpdate(lsimImmediate);
  344. m_pGDC->RecordCount = pADO->RecordCount;
  345. for( ; !pADO->Eof; pADO->Next(), nRow++)
  346. {
  347. m_pGDC->Values[nRow][Column01->Index] = nRow+1;
  348. //m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("PRCN_DT2")->AsDateTime.DateTimeString(); //가공시각
  349. //m_pGDC->Values[nRow][Column02->Index] = ITSUtil_StrToTime(pADO->FieldByName("PRCN_DT")->AsString); //가공시각
  350. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("PRCN_DT")->AsString; //가공시각
  351. m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("CNT")->AsInteger;
  352. m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("PRCN_DT")->AsString;
  353. }
  354. }
  355. __finally
  356. {
  357. if (pADO)
  358. {
  359. pADO->Close();
  360. }
  361. TvList->EndUpdate();
  362. CxList->SetFocus();
  363. cxTrackBar1->Position = 0;
  364. cxTrackBar1->Properties->Max = nRow;
  365. cxTrackBar1->Properties->Frequency = cxTrackBar1->Properties->Max * 0.1;
  366. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  367. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  368. Application->MessageBox(sEnd.c_str(),
  369. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  370. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  371. }
  372. }
  373. catch(EDatabaseError &E)
  374. {
  375. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  376. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  377. throw Exception(String(E.ClassName()) + E.Message);
  378. }
  379. catch(Exception &e)
  380. {
  381. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  382. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  383. throw Exception(String(e.ClassName()) + e.Message);
  384. }
  385. }
  386. //---------------------------------------------------------------------------
  387. void __fastcall TTAS0010M::BtnPlayClick(TObject *Sender)
  388. {
  389. if (m_pGDC->RecordCount <= 0)
  390. {
  391. Application->MessageBox(lblText3->Caption.c_str(),//L"표출할 정보가 없습니다. 이력정보를 다시 조회하신 후 작업을 진행 하십시요.",
  392. FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  393. return;
  394. }
  395. m_pGDC->FocusedRecordIndex = 0;
  396. int nIndex = m_pGDC->FocusedRecordIndex;
  397. if (nIndex < 0) return;
  398. FSimIndex = nIndex;
  399. cxTrackBar1->Position = nIndex;
  400. FStatTime = VarToStr(m_pGDC->Values[nIndex][Column04->Index]);
  401. CxList->SetFocus();
  402. BtnPlay->Enabled = false;
  403. BtnStop->Enabled = true;
  404. BtnSearch->Enabled = false;
  405. //cxGroupBox1->Caption = "▶ 소통정보 표출 - " + VarToStr(m_pGDC->Values[nIndex][Column02->Index]);
  406. cxGroupBox1->Caption = lblText1->Caption + " - " + VarToStr(m_pGDC->Values[nIndex][Column02->Index]);
  407. SelStatisticsHistory(FStatTime);
  408. TmrShow->Tag = 1;
  409. TmrShow->Interval = SeRefreshSec->Value * 1000;
  410. TmrShow->Enabled = true;
  411. }
  412. //---------------------------------------------------------------------------
  413. void __fastcall TTAS0010M::BtnStopClick(TObject *Sender)
  414. {
  415. TmrShow->Enabled = false;
  416. BtnPlay->Enabled = true;
  417. BtnStop->Enabled = false;
  418. BtnSearch->Enabled = true;
  419. }
  420. //---------------------------------------------------------------------------
  421. void __fastcall TTAS0010M::SelStatisticsHistory(String AStatTime)
  422. {
  423. int ii;
  424. TSqlCursor sqlCrs;
  425. String sQry;
  426. TADOQuery *pADO = ADOSta;
  427. switch(FTargetIdx)
  428. {
  429. case 0: //이력 정보
  430. sQry = "SELECT A.IFSC_ID, NVL(B.CMTR_GRAD_CD, 'LTC0') TRFGRD, C.SPED, \r\n"
  431. " C.PRCN_DT REGDATE \r\n"
  432. " FROM TB_IFSC A, \r\n"
  433. " TB_SECT_GRAD_STUP B, \r\n"
  434. " TB_IFSC_TRAF_HS C \r\n"
  435. " WHERE A.IFSC_ID = C.IFSC_ID \r\n"
  436. " AND A.SECT_GRAD_CD = B.SECT_GRAD_CD \r\n"
  437. " AND (C.SPED >= B.LWST_TRVL_SPED AND C.SPED <= B.HGHS_TRVL_SPED) \r\n"
  438. " AND C.PRCN_DT = :p01 \r\n";
  439. ITSDb_SQLText(pADO, sQry);
  440. ITSDb_SQLBind(pADO, "p01", AStatTime);
  441. break;
  442. case 1: //통계 15분 정보
  443. sQry = "SELECT A.IFSC_ID, NVL(B.CMTR_GRAD_CD, 'LTC0') TRFGRD, C.SPED, \r\n"
  444. " C.STAT_DT REGDATE \r\n"
  445. " FROM TB_IFSC A, \r\n"
  446. " TB_SECT_GRAD_STUP B, \r\n"
  447. " TB_IFSC_15M_STAT C \r\n"
  448. " WHERE A.IFSC_ID = C.IFSC_ID \r\n"
  449. " AND A.SECT_GRAD_CD = B.SECT_GRAD_CD \r\n"
  450. " AND (C.SPED >= B.LWST_TRVL_SPED AND C.SPED <= B.HGHS_TRVL_SPED) \r\n"
  451. " AND C.STAT_DT = :p01 \r\n";
  452. ITSDb_SQLText(pADO, sQry);
  453. ITSDb_SQLBind(pADO, "p01", AStatTime);
  454. break;
  455. case 2: //패턴 5분 정보
  456. sQry = "SELECT A.IFSC_ID, NVL(B.CMTR_GRAD_CD, 'LTC0') TRFGRD, \r\n"
  457. " C.SPED, C.STAT_YM || C.STAT_HM REGDATE \r\n"
  458. " FROM TB_IFSC A, \r\n"
  459. " TB_SECT_GRAD_STUP B, \r\n"
  460. " TB_IFSC_5M_PTRN C \r\n"
  461. " WHERE A.IFSC_ID = C.IFSC_ID \r\n"
  462. " AND A.SECT_GRAD_CD = B.SECT_GRAD_CD \r\n"
  463. " AND (C.SPED >= B.LWST_TRVL_SPED AND C.SPED <= B.HGHS_TRVL_SPED) \r\n"
  464. " AND C.STAT_YM = SUBSTR(:p01, 1, 6) \r\n"
  465. " AND C.STAT_HM = SUBSTR(:p02, 8, 4) \r\n";
  466. ITSDb_SQLText(pADO, sQry);
  467. ITSDb_SQLBind(pADO, "p01", AStatTime);
  468. ITSDb_SQLBind(pADO, "p02", AStatTime);
  469. break;
  470. case 3: //패턴 15분 정보
  471. sQry = "SELECT A.IFSC_ID, NVL(B.CMTR_GRAD_CD, 'LTC0') TRFGRD, \r\n"
  472. " C.SPED, C.STAT_YM || C.STAT_HM REGDATE \r\n"
  473. " FROM TB_IFSC A, \r\n"
  474. " TB_SECT_GRAD_STUP B, \r\n"
  475. " TB_IFSC_15M_PTRN C \r\n"
  476. " WHERE A.IFSC_ID = C.IFSC_ID \r\n"
  477. " AND A.SECT_GRAD_CD = B.SECT_GRAD_CD \r\n"
  478. " AND (C.SPED >= B.LWST_TRVL_SPED AND C.SPED <= B.HGHS_TRVL_SPED) \r\n"
  479. " AND C.STAT_YM = SUBSTR(:p01, 1, 6) \r\n"
  480. " AND C.STAT_HM = SUBSTR(:p02, 8, 4) \r\n";
  481. ITSDb_SQLText(pADO, sQry);
  482. ITSDb_SQLBind(pADO, "p01", AStatTime);
  483. ITSDb_SQLBind(pADO, "p02", AStatTime);
  484. break;
  485. }
  486. int nGradeCd;
  487. try
  488. {
  489. String sLinkInfo = "";
  490. ITSDb_SQLOpen(pADO);
  491. for( ; !pADO->Eof; pADO->Next())
  492. {
  493. String sID = pADO->FieldByName("IFSC_ID")->AsString;
  494. TTrafficVal *pTraf = FIfscMngr->FLists.Find(sID);
  495. if (pTraf)
  496. {
  497. String TRFGRD = pADO->FieldByName("TRFGRD")->AsString;
  498. if (TRFGRD == "LTC1") nGradeCd = 1;
  499. else if (TRFGRD == "LTC2") nGradeCd = 2;
  500. else if (TRFGRD == "LTC3") nGradeCd = 3;
  501. else nGradeCd = 0;
  502. if (pTraf->GRADE_VAL != nGradeCd)
  503. {
  504. pTraf->GRADE_VAL = nGradeCd;
  505. sJs.printf(L"updateHistLink('%s', %d)", sID.c_str(), nGradeCd);
  506. FRAMEOpenMap1->ExecScript(sJs);
  507. }
  508. }
  509. }
  510. }
  511. catch(EDatabaseError &E)
  512. {
  513. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  514. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  515. throw Exception(String(E.ClassName()) + E.Message);
  516. }
  517. catch(Exception &e)
  518. {
  519. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  520. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
  521. throw Exception(String(e.ClassName()) + e.Message);
  522. }
  523. }
  524. //---------------------------------------------------------------------------
  525. void __fastcall TTAS0010M::ClearGis()
  526. {
  527. cxGroupBox1->Caption = lblText1->Caption;//"▶ 소통정보 표출";
  528. }
  529. //---------------------------------------------------------------------------
  530. void __fastcall TTAS0010M::TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  531. TMouseButton AButton, TShiftState AShift, bool &AHandled)
  532. {
  533. if (BtnPlay->Enabled == false) return;
  534. int nRow = m_pGDC->FocusedRecordIndex;
  535. if( nRow <= -1 )
  536. return;
  537. FStatTime = VarToStr(m_pGDC->Values[nRow][Column04->Index]);
  538. //cxGroupBox1->Caption = "▶ 소통정보 표출 - " + VarToStr(m_pGDC->Values[nRow][Column02->Index]);
  539. cxGroupBox1->Caption = lblText1->Caption + " - " + VarToStr(m_pGDC->Values[nRow][Column02->Index]);
  540. SelStatisticsHistory(FStatTime);
  541. }
  542. //---------------------------------------------------------------------------
  543. void __fastcall TTAS0010M::BtnSearch2Click(TObject *Sender)
  544. {
  545. Application->ProcessMessages();
  546. if (!FRAMEOpenMap1->MapStart) return;
  547. String sLinkId = EdLinkId->Text.Trim();
  548. sJs.printf(L"extentLayerObject(%d, '%s')", LyrTp_Traffic, sLinkId.c_str());
  549. FRAMEOpenMap1->ExecScript(sJs);
  550. }
  551. //---------------------------------------------------------------------------
  552. void __fastcall TTAS0010M::OpenMapCallback(TObject *ASender, const String AFunc, const String AArgs, const bool AFirst)
  553. {
  554. try
  555. {
  556. if (AFirst)
  557. {
  558. //지도를 편집모드로 변경
  559. sJs.printf(L"setEditMode(%d, 1)", FLayerIdx);
  560. FRAMEOpenMap1->ExecScript(sJs);
  561. //편집레이어 생성
  562. FRAMEOpenMap1->ExecScript("initEditLayer()");
  563. FRAMEOpenMap1->ExecScript("setEditArrow(0)");
  564. FRAMEOpenMap1->ExecScript("setEditColor()");
  565. //배경링크레이어 생성
  566. InitGisLink();
  567. return;
  568. }
  569. }
  570. catch(Exception &exception)
  571. {
  572. }
  573. }
  574. //---------------------------------------------------------------------------
  575. void __fastcall TTAS0010M::FormCloseQuery(TObject *Sender, bool &CanClose)
  576. {
  577. FRAMEOpenMap1->OnCloseQuery(CanClose);
  578. }
  579. //---------------------------------------------------------------------------