FRAME_TrafficLinkListF.cpp 9.5 KB

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