BDSH0201F.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. #pragma hdrstop
  9. #include "BDSH0201F.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxCheckBox"
  14. #pragma link "cxClasses"
  15. #pragma link "cxContainer"
  16. #pragma link "cxControls"
  17. #pragma link "cxCustomData"
  18. #pragma link "cxData"
  19. #pragma link "cxDataStorage"
  20. #pragma link "cxEdit"
  21. #pragma link "cxFilter"
  22. #pragma link "cxGraphics"
  23. #pragma link "cxGrid"
  24. #pragma link "cxGridCustomTableView"
  25. #pragma link "cxGridCustomView"
  26. #pragma link "cxGridLevel"
  27. #pragma link "cxGridTableView"
  28. #pragma link "cxLabel"
  29. #pragma link "cxLookAndFeelPainters"
  30. #pragma link "cxLookAndFeels"
  31. #pragma link "cxSpinEdit"
  32. #pragma link "cxStyles"
  33. #pragma link "cxTextEdit"
  34. #pragma link "dxSkinBlack"
  35. #pragma link "dxSkinBlue"
  36. #pragma link "dxSkinsCore"
  37. #pragma link "dxSkinscxPCPainter"
  38. #pragma resource "*.dfm"
  39. TBDSH0201 *BDSH0201 = NULL;
  40. //---------------------------------------------------------------------------
  41. __fastcall TBDSH0201::TBDSH0201(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  42. : TForm(Owner)
  43. {
  44. ITSSkin_Load(this);
  45. CMM_LoadForm(g_sFormsDir, this);
  46. FParent = hHandle;
  47. FStDateTime = sFrom;
  48. FEdDateTime = sTo;
  49. FIdList = sIdList;
  50. Caption = "블랙박스 돌발 수집 이력";
  51. Col16->Visible = false;
  52. Col16->VisibleForCustomization = false;
  53. }
  54. //---------------------------------------------------------------------------
  55. __fastcall TBDSH0201::~TBDSH0201(void)
  56. {
  57. }
  58. //--------------------------------------------------------------------------
  59. /*
  60. * form 초기화
  61. *
  62. * arguments
  63. *
  64. * return
  65. * void
  66. */
  67. void __fastcall TBDSH0201::FormInit()
  68. {
  69. ADOQry->Connection = ITSDb_GetConnection();
  70. m_pGDC = TvList->DataController;
  71. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<블랙박스 돌발 수집 이력>";
  72. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  73. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  74. }
  75. //---------------------------------------------------------------------------
  76. /*
  77. * form을 보여줄때 호출되는 event 메서드이다.
  78. * arguments
  79. * Sender : event handler 객체
  80. * return
  81. * void
  82. */
  83. void __fastcall TBDSH0201::FormShow(TObject *Sender)
  84. {
  85. FormInit();
  86. Refresh();
  87. TmrShow->Enabled = true;
  88. }
  89. //---------------------------------------------------------------------------
  90. /*
  91. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  92. * Form과 DataModule class를 delete시킨다.
  93. * arguments
  94. *
  95. * return
  96. * void
  97. */
  98. void __fastcall TBDSH0201::CommClose()
  99. {
  100. CMM_SaveForm(g_sFormsDir, this);
  101. //BDSH0201 = NULL;
  102. }
  103. //---------------------------------------------------------------------------
  104. /*
  105. * 최초 1회 수행되는 타이머 이벤트
  106. * arguments
  107. * Sender : event handler 객체
  108. * return
  109. * void
  110. */
  111. void __fastcall TBDSH0201::TmrShowTimer(TObject *Sender)
  112. {
  113. TmrShow->Enabled = false;
  114. Application->ProcessMessages();
  115. SelHistory();
  116. }
  117. //---------------------------------------------------------------------------
  118. void __fastcall TBDSH0201::ChkExpandClick(TObject *Sender)
  119. {
  120. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  121. }
  122. //---------------------------------------------------------------------------
  123. /*
  124. * Refresh Data Event Function
  125. * arguments
  126. *
  127. * return
  128. * void
  129. */
  130. void __fastcall TBDSH0201::SelHistory()
  131. {
  132. TSqlCursor sqlCrs;
  133. String sQry;
  134. TADOQuery *pADO = ADOQry;
  135. sQry = "SELECT A.*, \r\n"
  136. " B.OCRR_DT, \r\n"
  137. " B.TRMN_ID, \r\n"
  138. " B.EVT_TYPE, \r\n"
  139. " DECODE(B.EVT_TYPE, '1', '1.주기보고', \r\n"
  140. " '2', '2.사용자전송', \r\n"
  141. " '3', '3.긴급전송', \r\n"
  142. " '---') AS EVT_DESC, \r\n"
  143. " B.X_CRDN, \r\n"
  144. " B.Y_CRDN, \r\n"
  145. " B.GPS_DRCT, \r\n"
  146. " B.SPED, \r\n"
  147. " B.VHRN_MODE, \r\n"
  148. " DECODE(B.VHRN_MODE, '1', '1.주행모드', \r\n"
  149. " '2', '2.주차모드', \r\n"
  150. " '---') AS VHRN_DESC, \r\n"
  151. " B.TRMN_VER, \r\n"
  152. " B.IMGN_PATH, \r\n"
  153. " B.LINK_ID, C.ROAD_NAME \r\n"
  154. " FROM TB_BDS_TRMN A, \r\n"
  155. " TB_BDS_INCD_CLCT B, \r\n"
  156. " TB_LINK C \r\n"
  157. " WHERE A.BDS_MNGM_NMBR IN(" + FIdList + ") \r\n"
  158. " AND A.BDS_MNGM_NMBR = B.BDS_MNGM_NMBR \r\n"
  159. " AND B.LINK_ID = C.LINK_ID(+) \r\n"
  160. " AND B.OCRR_DT BETWEEN :p01 \r\n"
  161. " AND :p02 \r\n";
  162. //" ORDER BY A.BDS_MNGM_NMBR, B.OCRR_DT \r\n";
  163. try
  164. {
  165. ITSDb_SQLText(pADO, sQry);
  166. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  167. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  168. ITSDb_SQLOpen(pADO);
  169. DspHistory();
  170. }
  171. catch(EDatabaseError &E)
  172. {
  173. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  174. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  175. throw Exception(String(E.ClassName()) + E.Message);
  176. }
  177. catch(Exception &exception)
  178. {
  179. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  180. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  181. throw Exception(String(exception.ClassName()) + exception.Message);
  182. }
  183. }
  184. //---------------------------------------------------------------------------
  185. void __fastcall TBDSH0201::DspHistory()
  186. {
  187. TADOQuery *pADO = ADOQry;
  188. try
  189. {
  190. TcxGridChartSeries *pChart = NULL;
  191. CMM_ClearGridTableView(TvList);
  192. int nRow = 0;
  193. int nDataCnt = 0;
  194. try {
  195. TvList->BeginUpdate();
  196. nDataCnt = pADO->RecordCount;
  197. m_pGDC->RecordCount = nDataCnt;
  198. for( ; !pADO->Eof; pADO->Next(), nRow++)
  199. {
  200. TvList->DataController->Values[nRow][Col00->Index] = pADO->FieldByName("BDS_MNGM_NMBR")->AsInteger;
  201. TvList->DataController->Values[nRow][Col01->Index] = pADO->FieldByName("OPNC_NMBR")->AsString;
  202. TvList->DataController->Values[nRow][Col02->Index] = pADO->FieldByName("MDM_NMBR")->AsString;
  203. TvList->DataController->Values[nRow][Col03->Index] = pADO->FieldByName("USIM_NMBR")->AsString;
  204. TvList->DataController->Values[nRow][Col04->Index] = pADO->FieldByName("VHCL_NMBR")->AsString;
  205. TvList->DataController->Values[nRow][Col05->Index] = pADO->FieldByName("OWNR_NM")->AsString;
  206. TvList->DataController->Values[nRow][Col06->Index] = pADO->FieldByName("PRCT_NM")->AsString;
  207. TvList->DataController->Values[nRow][Col07->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("OCRR_DT")->AsString).FormatString(STR_DATETIME);
  208. TvList->DataController->Values[nRow][Col16->Index] = pADO->FieldByName("TRMN_ID")->AsString;
  209. TvList->DataController->Values[nRow][Col08->Index] = pADO->FieldByName("EVT_DESC")->AsString;
  210. TvList->DataController->Values[nRow][Col09->Index] = pADO->FieldByName("X_CRDN")->AsString;
  211. TvList->DataController->Values[nRow][Col10->Index] = pADO->FieldByName("Y_CRDN")->AsString;
  212. TvList->DataController->Values[nRow][Col11->Index] = pADO->FieldByName("GPS_DRCT")->AsString;
  213. TvList->DataController->Values[nRow][Col12->Index] = pADO->FieldByName("SPED")->AsString;
  214. TvList->DataController->Values[nRow][Col13->Index] = pADO->FieldByName("VHRN_DESC")->AsString;
  215. TvList->DataController->Values[nRow][Col14->Index] = pADO->FieldByName("TRMN_VER")->AsString;
  216. TvList->DataController->Values[nRow][Col15->Index] = pADO->FieldByName("IMGN_PATH")->AsString;
  217. TvList->DataController->Values[nRow][Col17->Index] = pADO->FieldByName("OCRR_DT")->AsString;
  218. TvList->DataController->Values[nRow][Col18->Index] = pADO->FieldByName("EVT_TYPE")->AsString;
  219. String LINK_ID = pADO->FieldByName("LINK_ID")->AsString;
  220. if (LINK_ID.Trim() == "0") LINK_ID = "";
  221. TvList->DataController->Values[nRow][Col20->Index] = LINK_ID;
  222. TvList->DataController->Values[nRow][Col21->Index] = pADO->FieldByName("ROAD_NAME")->AsString;
  223. }
  224. }
  225. __finally
  226. {
  227. if (pADO)
  228. {
  229. pADO->Close();
  230. }
  231. TvList->EndUpdate();
  232. //CxList->SetFocus();
  233. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  234. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  235. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  236. }
  237. }
  238. catch(EDatabaseError &E)
  239. {
  240. throw Exception(String(E.ClassName()) + E.Message);
  241. }
  242. catch(...)
  243. {
  244. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  245. }
  246. }
  247. //---------------------------------------------------------------------------
  248. void __fastcall TBDSH0201::OnMessage(TMessage &Msg)
  249. {
  250. switch (Msg.Msg)
  251. {
  252. case WM_PARAM_DATABASE:
  253. if (WP_DB_SELECT_OK == Msg.WParam)
  254. {
  255. //ShowMessage("Select Ok");
  256. }
  257. break;
  258. }
  259. }
  260. //---------------------------------------------------------------------------
  261. void __fastcall TBDSH0201::BtnExlSaveClick(TObject *Sender)
  262. {
  263. TcxGrid *pGrid = CxList;
  264. TcxGridTableView *pView = TvList;
  265. String sTitle = "블랙박스 돌발 수집 이력";
  266. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  267. }
  268. //---------------------------------------------------------------------------
  269. void __fastcall TBDSH0201::FormClose(TObject *Sender, TCloseAction &Action)
  270. {
  271. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  272. CommClose();
  273. //BDSH0201 = NULL;
  274. }
  275. //---------------------------------------------------------------------------
  276. void __fastcall TBDSH0201::TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  277. TMouseButton AButton, TShiftState AShift,
  278. bool &AHandled)
  279. {
  280. if (!ACellViewInfo) return;
  281. try {
  282. TcxDataController *pGDC = TvList->DataController;
  283. int nRow = pGDC->FocusedRecordIndex;
  284. if (nRow < 0) return;
  285. String EventID = VarToStr(pGDC->Values[nRow][Col00->Index]);
  286. String BDS_MNGM_NMBR = EventID; // N VARCHAR2(20) N 블랙박스 관리 번호
  287. String OPNC_NMBR = VarToStr(pGDC->Values[nRow][Col01->Index]); // N VARCHAR2(128) Y 개통 번호
  288. String MDM_NMBR = VarToStr(pGDC->Values[nRow][Col02->Index]); // N VARCHAR2(10) Y 모뎀 번호
  289. String USIM_NMBR = VarToStr(pGDC->Values[nRow][Col03->Index]); // N VARCHAR2(10) Y 유심 번호
  290. String VHCL_NMBR = VarToStr(pGDC->Values[nRow][Col04->Index]); // N VARCHAR2(15) Y 차량 번호
  291. String OWNR_NM = VarToStr(pGDC->Values[nRow][Col05->Index]); // N VARCHAR2(30) Y 소유자 명
  292. String OCRR_DT = VarToStr(pGDC->Values[nRow][Col17->Index]); // N VARCHAR2(14) N 발생 일시
  293. String EVT_TYPE = VarToStr(pGDC->Values[nRow][Col08->Index]);
  294. String TRMN_ID = VarToStr(pGDC->Values[nRow][Col16->Index]); // N VARCHAR2(128) Y 단말기 ID
  295. String X_CRDN = VarToStr(pGDC->Values[nRow][Col09->Index]); // N NUMBER(11,8) Y x 좌표
  296. String Y_CRDN = VarToStr(pGDC->Values[nRow][Col10->Index]); // N NUMBER(10,8) Y Y 좌표
  297. String IMGN_PATH = VarToStr(pGDC->Values[nRow][Col15->Index]); // N VARCHAR2(200) Y 영상 경로
  298. OWNR_NM = StringReplace(OWNR_NM, "|", " ", TReplaceFlags() << rfReplaceAll);
  299. String AClassName = "TFrmFtpCamViewer";
  300. HWND hExeForm = FindWindow(AClassName.c_str(), NULL);
  301. if (hExeForm)
  302. {
  303. SetWindowPos(hExeForm, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
  304. }
  305. else
  306. {
  307. String sExeName = g_sAppDir + "FtpCamViewer.exe";
  308. String sExeParam =
  309. EventID + "|" +
  310. BDS_MNGM_NMBR + "|" +
  311. OPNC_NMBR + "|" +
  312. MDM_NMBR + "|" +
  313. USIM_NMBR + "|" +
  314. VHCL_NMBR + "|" +
  315. OWNR_NM + "|" +
  316. OCRR_DT + "|" +
  317. EVT_TYPE + "|" +
  318. TRMN_ID + "|" +
  319. X_CRDN + "|" +
  320. Y_CRDN + "|" +
  321. IMGN_PATH ;
  322. //ShellExecute(FrmMain->Handle, NULL, sExeName.c_str(), sExeParam.c_str(), NULL, SW_SHOWNORMAL);
  323. ShellExecute(NULL, NULL, sExeName.c_str(), sExeParam.c_str(), NULL, SW_SHOWNORMAL);
  324. }
  325. } catch(...) {}
  326. }
  327. //---------------------------------------------------------------------------