FRAME_TrafficRoadListF.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "FrmResourceF.h"
  6. #include "ITSLangTransF.h"
  7. #pragma hdrstop
  8. #include "FRAME_TrafficRoadListF.h"
  9. #include "CDSNodeF.h"
  10. #include "CDSLinkF.h"
  11. #include "CDSIfscF.h"
  12. #include "CDSRoadF.h"
  13. //---------------------------------------------------------------------------
  14. #pragma package(smart_init)
  15. #pragma link "cxButtons"
  16. #pragma link "cxCalc"
  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 "cxGridCustomTableView"
  29. #pragma link "cxGridCustomView"
  30. #pragma link "cxGridLevel"
  31. #pragma link "cxGridTableView"
  32. #pragma link "cxLookAndFeelPainters"
  33. #pragma link "cxLookAndFeels"
  34. #pragma link "cxStyles"
  35. #pragma link "cxTextEdit"
  36. #pragma link "dxSkinBlack"
  37. #pragma link "dxSkinBlue"
  38. #pragma link "dxSkinsCore"
  39. #pragma link "dxSkinscxPCPainter"
  40. #pragma link "cxLabel"
  41. #pragma resource "*.dfm"
  42. //TFRAMETrafficRoadList *FRAMERoadList;
  43. //---------------------------------------------------------------------------
  44. __fastcall TFRAMETrafficRoadList::TFRAMETrafficRoadList(TComponent* Owner)
  45. : TFrame(Owner)
  46. {
  47. LangTrans->Translate(this, ITSDb_GetConnection());
  48. m_pGDC = TvList->DataController;
  49. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<도로 소통정보가 없습니다>";
  50. FCodeLTC = ItsCodeManager->FLists.Find("LTC");
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TFRAMETrafficRoadList::UpdateList()
  54. {
  55. TItsSubCode *pSubCode;
  56. TCDSTraffic *pTraf;
  57. CMM_ClearGridTableView(TvList);
  58. FLastAnsTime = "";
  59. int nRow = 0;
  60. try
  61. {
  62. TvList->BeginUpdate();
  63. TDateTime dtBefore15MM = Now() - (double)15 / (double)1440;
  64. try
  65. {
  66. ItsRoadManager->FLists.Lock();
  67. FOR_STL(TItsRoad*, pRoad, ItsRoadManager->FLists)
  68. {
  69. pTraf = pRoad->TRAF;
  70. if (pRoad->REGN_YN == "Y" || ChkDispExt->Checked == true)
  71. {
  72. String sLTC = "[" + pTraf->CMTR_GRAD_CD + "] ";
  73. if (FCodeLTC)
  74. {
  75. pSubCode = FCodeLTC->FSubLists.Find(pTraf->CMTR_GRAD_CD);
  76. if (pSubCode) sLTC = sLTC + pSubCode->CMMN_CD_KOR_NM;
  77. else sLTC = FrmLang->lblMissing->Caption;//"결측";
  78. }
  79. String sMissing = "";
  80. if (pTraf->LASTANS == "N")
  81. sMissing = FrmLang->lblMissing->Caption;//"결측";
  82. if (FLastAnsTime == "")
  83. FLastAnsTime = ITSUtil_StrToTime(pTraf->MPRCN_DT);
  84. nRow = m_pGDC->AppendRecord();
  85. m_pGDC->Values[nRow][Column00->Index] = pRoad->ROAD_NM; //'정보제공구간 명'
  86. m_pGDC->Values[nRow][Column19->Index] = pRoad->DRCT_CD == "0" ? FrmLang->lblUp->Caption : FrmLang->lblDown->Caption;//"상행" : "하행"; //'방향 명'
  87. m_pGDC->Values[nRow][Column01->Index] = pRoad->ROAD_ID; //'정보제공구간 ID'
  88. m_pGDC->Values[nRow][Column02->Index] = pRoad->STRT_NM; //'시점명';
  89. m_pGDC->Values[nRow][Column03->Index] = pRoad->END_NM; //'종점명';
  90. m_pGDC->Values[nRow][Column04->Index] = ITSUtil_StrToTime(pTraf->PRCN_DT); //'가공 일시';
  91. //if (pLink->LASTANS == "N") // 최신 15분 이전 기준
  92. {
  93. m_pGDC->Values[nRow][Column05->Index] = pTraf->TFVL; //'교통량';
  94. m_pGDC->Values[nRow][Column06->Index] = pTraf->SPED; //'속도';
  95. m_pGDC->Values[nRow][Column07->Index] = pTraf->OCPY_RATE; //'점유율';
  96. m_pGDC->Values[nRow][Column08->Index] = pTraf->TRVL_HH; //'통행시간';
  97. m_pGDC->Values[nRow][Column09->Index] = sLTC; //'소통등급';
  98. m_pGDC->Values[nRow][Column10->Index] = pTraf->CMTR_GRAD_CD; //'소통등급코드';
  99. m_pGDC->Values[nRow][Column11->Index] = sMissing; //'결측여부';
  100. //m_pGDC->Values[nRow][Column12->Index] = pSvcLink->PRCN_SPED; //'가공속도';
  101. //m_pGDC->Values[nRow][Column13->Index] = pSvcLink->SMTH_SPED; //'평활화속도';
  102. //m_pGDC->Values[nRow][Column14->Index] = pSvcLink->ADJS_SPED; //'보정속도';
  103. m_pGDC->Values[nRow][Column15->Index] = pTraf->PTRN_SPED; //'패턴속도';
  104. //m_pGDC->Values[nRow][Column16->Index] = sCST; //'가공소스';
  105. //m_pGDC->Values[nRow][Column17->Index] = sMCS; //'보정소스';
  106. m_pGDC->Values[nRow][Column18->Index] = pTraf->DATA_NUM; //'데이터개수'
  107. }
  108. }
  109. }
  110. }
  111. __finally
  112. {
  113. ItsRoadManager->FLists.UnLock();
  114. }
  115. }
  116. __finally
  117. {
  118. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  119. TvList->EndUpdate();
  120. TvList->DataController->GotoFirst();
  121. TvList->DataController->FocusedRecordIndex = 0;
  122. }
  123. }
  124. //---------------------------------------------------------------------------
  125. void __fastcall TFRAMETrafficRoadList::ChkDispExtPropertiesChange(TObject *Sender)
  126. {
  127. UpdateList();
  128. }
  129. //---------------------------------------------------------------------------
  130. int __fastcall TFRAMETrafficRoadList::GetSelLinkIds(String &ALinkIds)
  131. {
  132. ALinkIds = "";
  133. if (TvList->ViewData->RecordCount <= 0) return 0;
  134. int nIndex = m_pGDC->FocusedRecordIndex;
  135. if( nIndex < 0 )
  136. return 0;
  137. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Column01->Index]);
  138. ALinkIds = sLinkId;
  139. return 1;
  140. }
  141. //---------------------------------------------------------------------------
  142. void __fastcall TFRAMETrafficRoadList::TvListDataControllerFilterChanged(TObject *Sender)
  143. {
  144. CMM_SetFilterLike(TvList);
  145. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  146. }
  147. //---------------------------------------------------------------------------
  148. void __fastcall TFRAMETrafficRoadList::BtnExlSaveClick(TObject *Sender)
  149. {
  150. TcxGrid *pGrid = CxList;
  151. TcxGridTableView *pView = TvList;
  152. String sTitle= lblFileName->Caption;//"도로소통정보";
  153. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  154. }
  155. //---------------------------------------------------------------------------
  156. void __fastcall TFRAMETrafficRoadList::Column09CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  157. bool &ADone)
  158. {
  159. if (AViewInfo)
  160. {
  161. String sGrade = AViewInfo->GridRecord->DisplayTexts[Column10->Index];
  162. if (sGrade == "LTC1")
  163. {
  164. ACanvas->Canvas->Brush->Color = clLime;
  165. }
  166. else if (sGrade == "LTC2")
  167. {
  168. ACanvas->Canvas->Brush->Color = clYellow;
  169. }
  170. else if (sGrade == "LTC3")
  171. {
  172. ACanvas->Canvas->Brush->Color = clRed;
  173. }
  174. else
  175. {
  176. ACanvas->Canvas->Brush->Color = clGray;
  177. }
  178. }
  179. }
  180. //---------------------------------------------------------------------------
  181. void __fastcall TFRAMETrafficRoadList::Column11CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  182. bool &ADone)
  183. {
  184. if (AViewInfo)
  185. {
  186. String sMiss = AViewInfo->GridRecord->DisplayTexts[Column11->Index];
  187. if (sMiss == FrmLang->lblMissing->Caption)//"결측")
  188. {
  189. ACanvas->Canvas->Font->Color = clRed;
  190. }
  191. }
  192. }
  193. //---------------------------------------------------------------------------