FRAME_TrafficLinkListF.cpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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_TrafficLinkListF.h"
  9. #include "CDSNodeF.h"
  10. #include "CDSLinkF.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 "cxStyles"
  33. #pragma link "cxTextEdit"
  34. #pragma link "dxSkinBlack"
  35. #pragma link "dxSkinBlue"
  36. #pragma link "dxSkinsCore"
  37. #pragma link "dxSkinscxPCPainter"
  38. #pragma link "cxLabel"
  39. #pragma resource "*.dfm"
  40. //TFRAMETrafficLinkList *FRAMETrafficLinkList;
  41. //---------------------------------------------------------------------------
  42. __fastcall TFRAMETrafficLinkList::TFRAMETrafficLinkList(TComponent* Owner)
  43. : TFrame(Owner)
  44. {
  45. LangTrans->Translate(this, ITSDb_GetConnection());
  46. m_pGDC = TvList->DataController;
  47. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<링크 소통정보가 없습니다>";
  48. FCodeLTC = ItsCodeManager->FLists.Find("LTC"); //소통등급
  49. FCodeCST = ItsCodeManager->FLists.Find("CST"); //수집시스템 유형
  50. FCodeMCS = ItsCodeManager->FLists.Find("MCS"); //결측보정 수단
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TFRAMETrafficLinkList::UpdateList()
  54. {
  55. TCDSTraffic *pTraf;
  56. TItsNode *pNode;
  57. TItsSubCode *pSubCode;
  58. CMM_ClearGridTableView(TvList);
  59. FLastAnsTime = "";
  60. int nRow = 0;
  61. try
  62. {
  63. TvList->BeginUpdate();
  64. TDateTime dtBefore15MM = Now() - (double)15 / (double)1440;
  65. try
  66. {
  67. ItsLinkManager->FLists.Lock();
  68. FOR_STL(TItsLink*, pLink, ItsLinkManager->FLists)
  69. {
  70. pTraf = pLink->TRAF;
  71. if (pLink->REGN_YN == "Y" || ChkDispExt->Checked == true)
  72. {
  73. String sFNodeName = "[" + pLink->F_NODE_ID + "] ";
  74. pNode = ItsNodeManager->FLists.Find(pLink->F_NODE_ID);
  75. if (pNode) sFNodeName = sFNodeName + pNode->NODE_NAME;
  76. String sTNodeName = "[" + pLink->T_NODE_ID + "] ";
  77. pNode = ItsNodeManager->FLists.Find(pLink->T_NODE_ID);
  78. if (pNode) sTNodeName = sTNodeName + pNode->NODE_NAME;
  79. String sCST = "[" + pTraf->PRCN_SORC + "] ";
  80. if (FCodeCST)
  81. {
  82. pSubCode = FCodeCST->FSubLists.Find(pTraf->PRCN_SORC);
  83. if (pSubCode) sCST = sCST + pSubCode->CMMN_CD_KOR_NM;
  84. else
  85. {
  86. if (FCodeMCS)
  87. {
  88. pSubCode = FCodeMCS->FSubLists.Find(pTraf->PRCN_SORC);
  89. if (pSubCode) sCST = pSubCode->CMMN_CD_KOR_NM + sCST;
  90. }
  91. }
  92. }
  93. String sMCS = "[" + pTraf->ADJS_SORC + "] ";
  94. if (FCodeMCS)
  95. {
  96. pSubCode = FCodeMCS->FSubLists.Find(pTraf->ADJS_SORC);
  97. if (pSubCode) sMCS = sMCS + pSubCode->CMMN_CD_KOR_NM;
  98. }
  99. String sLTC = "[" + pTraf->CMTR_GRAD_CD + "] ";
  100. if (FCodeLTC)
  101. {
  102. pSubCode = FCodeLTC->FSubLists.Find(pTraf->CMTR_GRAD_CD);
  103. if (pSubCode) sLTC = sLTC + pSubCode->CMMN_CD_KOR_NM;
  104. }
  105. String sMissing = (pTraf->MISS_YN == "Y") ? FrmLang->lblMissing->Caption : String("");//"결측" : "";
  106. if (pTraf->LASTANS == "N")
  107. sMissing = FrmLang->lblMissing->Caption;//"결측";
  108. if (FLastAnsTime == "")
  109. FLastAnsTime = ITSUtil_StrToTime(pTraf->MPRCN_DT);
  110. nRow = m_pGDC->AppendRecord();
  111. m_pGDC->Values[nRow][Column01->Index] = pLink->LINK_ID; //'링크ID';
  112. m_pGDC->Values[nRow][Column02->Index] = sFNodeName; //'시작노드ID';
  113. m_pGDC->Values[nRow][Column03->Index] = sTNodeName; //'종료노드ID';
  114. m_pGDC->Values[nRow][Column04->Index] = ITSUtil_StrToTime(pTraf->PRCN_DT); //'가공 일시';
  115. //if (pTraf->LASTANS == "N") // 최신 15분 이전 기준
  116. {
  117. m_pGDC->Values[nRow][Column05->Index] = pTraf->TFVL; //'교통량';
  118. m_pGDC->Values[nRow][Column06->Index] = pTraf->SPED; //'속도';
  119. m_pGDC->Values[nRow][Column07->Index] = pTraf->OCPY_RATE; //'점유율';
  120. m_pGDC->Values[nRow][Column08->Index] = pTraf->TRVL_HH; //'통행시간';
  121. m_pGDC->Values[nRow][Column09->Index] = sLTC; //'소통등급';
  122. m_pGDC->Values[nRow][Column10->Index] = pTraf->CMTR_GRAD_CD; //'소통등급코드';
  123. m_pGDC->Values[nRow][Column11->Index] = sMissing; //'결측여부';
  124. m_pGDC->Values[nRow][Column12->Index] = pTraf->PRCN_SPED; //'가공속도';
  125. m_pGDC->Values[nRow][Column13->Index] = pTraf->SMTH_SPED; //'평활화속도';
  126. m_pGDC->Values[nRow][Column14->Index] = pTraf->ADJS_SPED; //'보정속도';
  127. m_pGDC->Values[nRow][Column15->Index] = pTraf->PTRN_SPED; //'패턴속도';
  128. m_pGDC->Values[nRow][Column16->Index] = sCST; //'가공소스';
  129. m_pGDC->Values[nRow][Column17->Index] = sMCS; //'보정소스';
  130. m_pGDC->Values[nRow][Column18->Index] = pTraf->DATA_NUM; //'데이터개수'
  131. }
  132. }
  133. }
  134. }
  135. __finally
  136. {
  137. ItsLinkManager->FLists.UnLock();
  138. }
  139. }
  140. __finally
  141. {
  142. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  143. TvList->EndUpdate();
  144. TvList->DataController->GotoFirst();
  145. TvList->DataController->FocusedRecordIndex = 0;
  146. }
  147. }
  148. //---------------------------------------------------------------------------
  149. void __fastcall TFRAMETrafficLinkList::ChkDispExtPropertiesChange(TObject *Sender)
  150. {
  151. UpdateList();
  152. }
  153. //---------------------------------------------------------------------------
  154. int __fastcall TFRAMETrafficLinkList::GetSelLinkIds(String &ALinkIds)
  155. {
  156. ALinkIds = "";
  157. if (TvList->ViewData->RecordCount <= 0) return 0;
  158. int nIndex = m_pGDC->FocusedRecordIndex;
  159. if( nIndex < 0 )
  160. return 0;
  161. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Column01->Index]);
  162. ALinkIds = sLinkId;
  163. return 1;
  164. }
  165. //---------------------------------------------------------------------------
  166. void __fastcall TFRAMETrafficLinkList::TvListDataControllerFilterChanged(TObject *Sender)
  167. {
  168. CMM_SetFilterLike(TvList);
  169. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  170. }
  171. //---------------------------------------------------------------------------
  172. void __fastcall TFRAMETrafficLinkList::BtnExlSaveClick(TObject *Sender)
  173. {
  174. TcxGrid *pGrid = CxList;
  175. TcxGridTableView *pView = TvList;
  176. String sTitle= lblFileName->Caption;//"링크소통정보";
  177. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  178. }
  179. //---------------------------------------------------------------------------
  180. void __fastcall TFRAMETrafficLinkList::Column09CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  181. bool &ADone)
  182. {
  183. if (AViewInfo)
  184. {
  185. String sGrade = AViewInfo->GridRecord->DisplayTexts[Column10->Index];
  186. if (sGrade == "LTC1")
  187. {
  188. ACanvas->Canvas->Brush->Color = clLime;
  189. }
  190. else if (sGrade == "LTC2")
  191. {
  192. ACanvas->Canvas->Brush->Color = clYellow;
  193. }
  194. else if (sGrade == "LTC3")
  195. {
  196. ACanvas->Canvas->Brush->Color = clRed;
  197. }
  198. else
  199. {
  200. ACanvas->Canvas->Brush->Color = clGray;
  201. }
  202. }
  203. }
  204. //---------------------------------------------------------------------------
  205. void __fastcall TFRAMETrafficLinkList::Column11CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  206. bool &ADone)
  207. {
  208. if (AViewInfo)
  209. {
  210. String sMiss = AViewInfo->GridRecord->DisplayTexts[Column11->Index];
  211. if (sMiss == FrmLang->lblMissing->Caption)//"결측")
  212. {
  213. ACanvas->Canvas->Font->Color = clRed;
  214. }
  215. }
  216. }
  217. //---------------------------------------------------------------------------