BaseDbCls.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using com.hnshituo.core.webapp.vo;
  2. using Common;
  3. using MeterPlugInLibrary;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Reflection;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace RailMeterSystem
  12. {
  13. public class BaseDbCls
  14. {
  15. Log lg = Log.GetInstance();
  16. internal bool setBaseDb()
  17. {
  18. bool flag = true;
  19. #region 初始化一次缓存类
  20. PbStaticRailwayCache.Load();
  21. #endregion
  22. #region 读取音频文件名称
  23. /*
  24. List<string> ls = new List<string>();
  25. DirectoryInfo folder = new DirectoryInfo(PbStaticRailwayCache.path + "\\Sound");
  26. foreach (FileInfo file in folder.GetFiles("*.wav"))
  27. {
  28. ls.Add(file.Name.Replace(".wav", ""));
  29. }
  30. PbStaticRailwayCache.voiceInfo = ls;
  31. //*/
  32. #endregion
  33. #region 所有摄像头配置信息
  34. MeterBaseVideoinfoService mbvs = new MeterBaseVideoinfoService();
  35. RESTfulResult<List<MeterBaseVideoinfo>> rm = mbvs.doQueryWf(new MeterBaseVideoinfo { });
  36. if (rm.Succeed && rm.Data != null && rm.Data.Count > 0)
  37. {
  38. PbStaticRailwayCache.ltVideoInfo = rm.Data;
  39. }
  40. else
  41. {
  42. lg.WriteLog(1, "未找到摄像头配置信息MeterBaseVideoinfo");
  43. return false;
  44. }
  45. #endregion
  46. #region 所有计量点数据
  47. MeterBaseSpotInfoService service = new MeterBaseSpotInfoService();
  48. RESTfulResult<List<MeterBaseSpotInfo>> rms = service.doQueryWf(new MeterBaseSpotInfo { validFlag = "1", spotTypeNo = "001002002" });
  49. if (rms.Succeed && rms.Data != null && rms.Data.Count > 0)
  50. {
  51. PbStaticRailwayCache.sportInfos = rms.Data;
  52. }
  53. else
  54. {
  55. lg.WriteLog(1, "MeterBaseSpotInfo");
  56. return false;
  57. }
  58. #endregion
  59. #region 秤体量程配置
  60. MeterBaseScaleRangeService rangeService = new MeterBaseScaleRangeService();
  61. RESTfulResult<List<MeterBaseScaleRange>> rmR = rangeService.doQueryWf(new MeterBaseScaleRange { });
  62. if (rmR.Succeed && rmR.Data != null && rmR.Data.Count > 0)
  63. {
  64. PbStaticRailwayCache.ltRange = rmR.Data;
  65. }
  66. else
  67. {
  68. lg.WriteLog(1, "未找到秤体量程配置信息MeterBaseScaleRange");
  69. return false;
  70. }
  71. #endregion
  72. #region 轨道衡监控表
  73. MeterWorkStaticMonitorService staticMonitorService = new MeterWorkStaticMonitorService();
  74. RESTfulResult<List<MeterWorkStaticMonitor>> rr = staticMonitorService.doQueryWf(new MeterWorkStaticMonitor { validFlag = "1" });
  75. if (rr.Succeed && rr.Data != null && rr.Data.Count > 0)
  76. {
  77. PbStaticRailwayCache.ltMonitor = rr.Data;
  78. }
  79. else
  80. {
  81. lg.WriteLog(1, "未找到监控表信息MeterWorkStaticMonitor");
  82. return false;
  83. }
  84. #endregion
  85. #region 车型 ltCarType
  86. string sql = @"SELECT base_code baseCode,base_name baseName,memo FROM Com_Base_Info where p_base_code='001028' and valid_Flag='1'";
  87. PbModelDbService<List<ComBaseInfo>> pb = new PbModelDbService<List<ComBaseInfo>>();
  88. RESTfulResult<List<ComBaseInfo>> rmType = pb.executeSqlDataWf(sql);
  89. if (rmType.Succeed && rmType.Data != null && rmType.Data.Count > 0)
  90. {
  91. PbStaticRailwayCache.ltCarType = rmType.Data;
  92. }
  93. else
  94. {
  95. lg.WriteLog(1, "未找到车型基础信息");
  96. return false;
  97. }
  98. #endregion
  99. return flag;
  100. }
  101. public bool getSpot()
  102. {
  103. #region 获取摄像头数据用于截图 meter_base_videoinfo
  104. if (PbStaticRailwayCache.ltVideoInfo != null && PbStaticRailwayCache.ltVideoInfo.Count > 0)
  105. {
  106. PbStaticRailwayCache.videoInfo = PbStaticRailwayCache.ltVideoInfo.Where(s => s.pointid == PbStaticRailwayCache.sportInfo.baseSpotNo).FirstOrDefault();
  107. List<MeterBaseVideoChild> videoChild = new List<MeterBaseVideoChild>();
  108. Type postType = PbStaticRailwayCache.videoInfo.GetType();
  109. PropertyInfo[] postTypeInfos = postType.GetProperties(); //返回为当前 Type 的所有公共属性,PropertyInfo[] PropertyInfo 的所有公共属性的 Type 对象数组
  110. foreach (PropertyInfo p in postTypeInfos)
  111. {
  112. if (p.Name.Contains("videoip")) //2021年4月11日 杨秀东:原来从摄像头截图使用摄像头position;现在从硬盘录像机截图,使用videoip
  113. {
  114. string str = (string)p.GetValue(PbStaticRailwayCache.videoInfo, null);
  115. if (str != "" && str != null)
  116. {
  117. videoChild.Add(
  118. new MeterBaseVideoChild
  119. {
  120. pointid = PbStaticRailwayCache.videoInfo.pointid,
  121. p_ip = str,
  122. p_rate = "0",//************解码率直接给定了,这里没取配置值*************
  123. vdo_port = PbStaticRailwayCache.videoInfo.vdoPort,
  124. vdo_pwd = PbStaticRailwayCache.videoInfo.vdoPwd,
  125. vdo_user = PbStaticRailwayCache.videoInfo.vdoUser
  126. }
  127. );
  128. }
  129. }
  130. }
  131. PbStaticRailwayCache.videoChild = videoChild;
  132. if (videoChild.Count == 0)
  133. {
  134. return false;
  135. }
  136. else
  137. {
  138. //将摄像头操作类存储再缓存中
  139. List<DhCameraShot> list = new List<DhCameraShot>();
  140. foreach (MeterBaseVideoChild child in PbStaticRailwayCache.videoChild)
  141. {
  142. DhCameraShot cameraShot = new DhCameraShot();
  143. cameraShot.ip = child.p_ip;
  144. cameraShot.port = child.vdo_port;
  145. cameraShot.uid = child.vdo_user;
  146. cameraShot.pwd = child.vdo_pwd;
  147. list.Add(cameraShot);
  148. }
  149. CarCache.cameraShots = list;
  150. }
  151. }
  152. #endregion
  153. return true;
  154. }
  155. }
  156. }