IOServer.Process.Partial.cs 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace MSHO.Collection.Service.IO
  7. {
  8. partial class IOServer
  9. {
  10. private Dictionary<string, MSHO.Collection.DataAccess.Models.CollectConfig> m_CollectConfigs = new Dictionary<string, DataAccess.Models.CollectConfig>();
  11. private void Process_Exception(System.Net.Sockets.Socket client, Msg data) {
  12. var msg = new ErrorMsgRespMsg();
  13. msg.ClientCode = data.ClientCode;
  14. var error_msg = data as ErrorMsg;
  15. if (error_msg != null)
  16. {
  17. var clientConfig = MSHO.Collection.DataAccess.MSHOService.Instance.GetCollectConfigByCode(msg.ClientCode);
  18. if (clientConfig != null) {
  19. if (MSHO.Collection.DataAccess.MSHOService.Instance.SaveSystemLog(MSHO.Collection.DataAccess.Enums.SystemLogTypeEnum.ERROR, "MSHO.Collection.Client", error_msg.Model, error_msg.LogMessage, error_msg.LogDetails, clientConfig.CollectorName, clientConfig.Code))
  20. {
  21. msg.Result = true;
  22. }
  23. }
  24. }
  25. SendMsg(client, new Message(msg));
  26. }
  27. private void Process_Bus_Weighting(DataReportRespMsg msg, DataReportMsg data_report) {
  28. var weighting = JsonSerializable.FromJson<MSHO.Collection.DataAccess.ClientModels.Bus_Weighting>(data_report.Result);
  29. if (weighting != null)
  30. {
  31. #region clientConfig
  32. MSHO.Collection.DataAccess.Models.CollectConfig clientConfig = null;
  33. if (m_CollectConfigs.ContainsKey(msg.ClientCode))
  34. {
  35. clientConfig = m_CollectConfigs[msg.ClientCode];
  36. }
  37. if (clientConfig == null)
  38. {
  39. clientConfig = MSHO.Collection.DataAccess.MSHOService.Instance.GetCollectConfigByCode(msg.ClientCode);
  40. }
  41. #endregion
  42. if (clientConfig != null)
  43. {
  44. #region check exist
  45. if (!m_CollectConfigs.ContainsKey(msg.ClientCode))
  46. {
  47. m_CollectConfigs.Add(msg.ClientCode, clientConfig);
  48. }
  49. clientConfig.LastSourceTime = weighting.ReceiveTime;
  50. bool exist = false;
  51. if (weighting.Id.HasValue)
  52. {
  53. clientConfig.LastSourceID = weighting.Id.ToString();
  54. exist = MSHO.Collection.DataAccess.MSHOService.Instance.ExistWeighting(clientConfig.StationID, clientConfig.DeviceID, clientConfig.LastSourceID);
  55. }
  56. #endregion
  57. string weightId = weighting.Id.HasValue ? weighting.Id.ToString() : string.Empty;
  58. if (exist)
  59. {
  60. msg.Result = true;
  61. msg.DataId = weightId;
  62. }
  63. else
  64. {
  65. var serverWeighting = new MSHO.Collection.DataAccess.Models.Weighting()
  66. {
  67. StationID = clientConfig.StationID,
  68. DeviceID = clientConfig.DeviceID,
  69. WeightID = weightId,
  70. WeightTime = weighting.WeightTime,
  71. TruckNumber = weighting.TruckNumber,
  72. TruckColor = weighting.TruckCorlor,
  73. CaptureTime = weighting.TruckCapTime,
  74. ThroughDuring = weighting.Difference,
  75. LimitMode = weighting.LimitModeName,
  76. VehicleType = weighting.VehicleType,
  77. AxleType = weighting.AxleType,
  78. AxleCount = weighting.AxleCount,
  79. LaneNumber = weighting.LaneNum,
  80. Way = weighting.Way,
  81. IsReverse = weighting.IsReverse,
  82. IsBoast = weighting.IsBoast,
  83. Speed = weighting.Speed,
  84. PressColumn = weighting.PressColumns,
  85. Gross = weighting.Gross,
  86. LimitWeight = weighting.LimitWeight,
  87. OverloadWeight = weighting.OverWeight,
  88. OverloadRate = weighting.LimiteRate,
  89. AxleWeight1 = weighting.AxleWeight1,
  90. AxleWeight2 = weighting.AxleWeight2,
  91. AxleWeight3 = weighting.AxleWeight3,
  92. AxleWeight4 = weighting.AxleWeight4,
  93. AxleWeight5 = weighting.AxleWeight5,
  94. AxleWeight6 = weighting.AxleWeight6,
  95. AxleWeight7 = weighting.AxleWeight7,
  96. AxleWeight8 = weighting.AxleWeight8,
  97. UploadTime = DateTime.Now
  98. };
  99. if (serverWeighting.WeightTime.HasValue)
  100. {
  101. serverWeighting.WeightTime_Year = serverWeighting.WeightTime.Value.Year;
  102. serverWeighting.WeightTime_Month = serverWeighting.WeightTime.Value.Month;
  103. serverWeighting.WeightTime_Day = serverWeighting.WeightTime.Value.Day;
  104. serverWeighting.WeightTime_Hour = serverWeighting.WeightTime.Value.Hour;
  105. serverWeighting.WeightTime_Minute = serverWeighting.WeightTime.Value.Minute;
  106. }
  107. #region 附件
  108. foreach (var file in weighting.WeightingFiles)
  109. {
  110. file.DeviceID = serverWeighting.DeviceID;
  111. serverWeighting.WeightingFiles.Add(file);
  112. }
  113. #endregion
  114. try
  115. {
  116. if (MSHO.Collection.DataAccess.MSHOService.Instance.SaveWeighting(clientConfig, serverWeighting))
  117. {
  118. msg.Result = true;
  119. msg.DataId = weightId;
  120. msg.WeightingFiles = serverWeighting.WeightingFiles.ToList();
  121. }
  122. }
  123. catch (Exception ex)
  124. {
  125. MSHO.Collection.DataAccess.MSHOService.Instance.SaveSystemLog("MSHO.Collection.Service", "Process_Bus_Weighting", ex);
  126. msg.Result = false;
  127. msg.DataId = weightId;
  128. }
  129. }
  130. }
  131. }
  132. }
  133. private void Process_Kdtc_Weighting(DataReportRespMsg msg, DataReportMsg data_report)
  134. {
  135. var weighting = JsonSerializable.FromJson<MSHO.Collection.DataAccess.ClientModels.Kdtc_Weighting>(data_report.Result);
  136. if (weighting != null)
  137. {
  138. #region clientConfig
  139. MSHO.Collection.DataAccess.Models.CollectConfig clientConfig = null;
  140. if (m_CollectConfigs.ContainsKey(msg.ClientCode))
  141. {
  142. clientConfig = m_CollectConfigs[msg.ClientCode];
  143. }
  144. if (clientConfig == null)
  145. {
  146. clientConfig = MSHO.Collection.DataAccess.MSHOService.Instance.GetCollectConfigByCode(msg.ClientCode);
  147. }
  148. #endregion
  149. if (clientConfig != null)
  150. {
  151. #region check exist
  152. if (!m_CollectConfigs.ContainsKey(msg.ClientCode))
  153. {
  154. m_CollectConfigs.Add(msg.ClientCode, clientConfig);
  155. }
  156. clientConfig.LastSourceTime = weighting.CollectTime;
  157. bool exist = false;
  158. if (weighting.Id.HasValue)
  159. {
  160. clientConfig.LastSourceID = weighting.Id.ToString();
  161. exist = MSHO.Collection.DataAccess.MSHOService.Instance.ExistWeighting(clientConfig.StationID, clientConfig.DeviceID, clientConfig.LastSourceID);
  162. }
  163. #endregion
  164. string weightId = weighting.Id.HasValue ? weighting.Id.ToString() : string.Empty;
  165. if (exist)
  166. {
  167. msg.Result = true;
  168. msg.DataId = weightId;
  169. } else {
  170. var serverWeighting = new MSHO.Collection.DataAccess.Models.Weighting()
  171. {
  172. StationID = clientConfig.StationID,
  173. DeviceID = clientConfig.DeviceID,
  174. WeightID = weightId,
  175. WeightTime = weighting.WeightTime,
  176. TruckNumber = weighting.TruckNumber,
  177. TruckColor = weighting.TruckCorlor,
  178. CaptureTime = weighting.TruckCapTime,
  179. ThroughDuring = weighting.Difference,
  180. LimitMode = weighting.LimitModeName,
  181. VehicleType = weighting.VehicleType,
  182. AxleType = weighting.AxleType,
  183. AxleCount = weighting.AxleCount,
  184. LaneNumber = weighting.EnterLane,
  185. LeaveLane = weighting.LeaveLane,
  186. Way = weighting.Way,
  187. IsReverse = weighting.IsReverse,
  188. IsBoast = weighting.IsBoast,
  189. Speed = weighting.Speed,
  190. LimitSpeed = weighting.LimitSpeed,
  191. OverSpeed = weighting.OverSpeed,
  192. PressColumn = weighting.PressColumns,
  193. Gross = weighting.Gross,
  194. LimitWeight = weighting.LimitWeight,
  195. OverloadWeight = weighting.OverWeight,
  196. OverloadRate = weighting.LimiteRate,
  197. AxleWeight1 = weighting.AxleWeight1,
  198. AxleWeight2 = weighting.AxleWeight2,
  199. AxleWeight3 = weighting.AxleWeight3,
  200. AxleWeight4 = weighting.AxleWeight4,
  201. AxleWeight5 = weighting.AxleWeight5,
  202. AxleWeight6 = weighting.AxleWeight6,
  203. AxleWeight7 = weighting.AxleWeight7,
  204. AxleWeight8 = weighting.AxleWeight8,
  205. Length = weighting.Length,
  206. Width = weighting.Width,
  207. Height = weighting.Height,
  208. UploadTime = DateTime.Now
  209. };
  210. if (serverWeighting.OverloadRate.HasValue)
  211. {//计算限载率
  212. if (serverWeighting.OverloadRate.Value > 0)
  213. {
  214. serverWeighting.OverloadRate = serverWeighting.OverloadRate.Value / (decimal)100.00;
  215. }
  216. }
  217. if (serverWeighting.WeightTime.HasValue)
  218. {
  219. serverWeighting.WeightTime_Year = serverWeighting.WeightTime.Value.Year;
  220. serverWeighting.WeightTime_Month = serverWeighting.WeightTime.Value.Month;
  221. serverWeighting.WeightTime_Day = serverWeighting.WeightTime.Value.Day;
  222. serverWeighting.WeightTime_Hour = serverWeighting.WeightTime.Value.Hour;
  223. serverWeighting.WeightTime_Minute = serverWeighting.WeightTime.Value.Minute;
  224. }
  225. #region 附件
  226. foreach (var file in weighting.WeightingFiles)
  227. {
  228. file.DeviceID = serverWeighting.DeviceID;
  229. serverWeighting.WeightingFiles.Add(file);
  230. }
  231. #endregion
  232. try
  233. {
  234. if (MSHO.Collection.DataAccess.MSHOService.Instance.SaveWeighting(clientConfig, serverWeighting))
  235. {
  236. msg.Result = true;
  237. msg.DataId = weightId;
  238. msg.WeightingFiles = serverWeighting.WeightingFiles.ToList();
  239. }
  240. }
  241. catch (Exception ex)
  242. {
  243. MSHO.Collection.DataAccess.MSHOService.Instance.SaveSystemLog("MSHO.Collection.Service", "Process_Kdtc_Weighting", ex);
  244. msg.Result = false;
  245. msg.DataId = weightId;
  246. }
  247. }
  248. }
  249. }
  250. }
  251. private void Process_Access_Weighting(DataReportRespMsg msg, DataReportMsg data_report)
  252. {
  253. var weighting = JsonSerializable.FromJson<MSHO.Collection.DataAccess.ClientModels.Access_Weighting>(data_report.Result);
  254. if (weighting != null)
  255. {
  256. #region clientConfig
  257. MSHO.Collection.DataAccess.Models.CollectConfig clientConfig = null;
  258. if (m_CollectConfigs.ContainsKey(msg.ClientCode))
  259. {
  260. clientConfig = m_CollectConfigs[msg.ClientCode];
  261. }
  262. if (clientConfig == null)
  263. {
  264. clientConfig = MSHO.Collection.DataAccess.MSHOService.Instance.GetCollectConfigByCode(msg.ClientCode);
  265. }
  266. #endregion
  267. if (clientConfig != null)
  268. {
  269. #region check exist
  270. if (!m_CollectConfigs.ContainsKey(msg.ClientCode))
  271. {
  272. m_CollectConfigs.Add(msg.ClientCode, clientConfig);
  273. }
  274. clientConfig.LastSourceTime = weighting.WeightTime;
  275. bool exist = false;
  276. if (weighting.ID.HasValue)
  277. {
  278. clientConfig.LastSourceID = weighting.ID.ToString();
  279. exist = MSHO.Collection.DataAccess.MSHOService.Instance.ExistWeighting(clientConfig.StationID, clientConfig.DeviceID, clientConfig.LastSourceID);
  280. }
  281. #endregion
  282. string weightId = weighting.ID.HasValue ? weighting.ID.ToString() : string.Empty;
  283. if (exist)
  284. {
  285. msg.Result = true;
  286. msg.DataId = weightId;
  287. }
  288. else
  289. {
  290. string axleType = null;
  291. if (!string.IsNullOrEmpty(weighting.LicenseNo)) {
  292. var n = weighting.LicenseNo.LastIndexOf("-");
  293. if (n > 0)
  294. {
  295. axleType = weighting.LicenseNo.Substring(n + 1);
  296. }
  297. }
  298. var serverWeighting = new MSHO.Collection.DataAccess.Models.Weighting()
  299. {
  300. StationID = clientConfig.StationID,
  301. DeviceID = clientConfig.DeviceID,
  302. WeightID = weightId,
  303. WeightTime = weighting.WeightTime,
  304. TruckNumber = weighting.TruckNumber,
  305. CaptureTime = weighting.WeightTime,
  306. AxleCount = weighting.AxleCount,
  307. AxleType = axleType,
  308. Speed = weighting.Speed,
  309. Gross = weighting.Gross,
  310. LimitWeight = weighting.LimitWeight,
  311. OverloadRate = weighting.OverloadRate,
  312. Checker = weighting.Checker,
  313. LicenseNo = weighting.LicenseNo,
  314. Sequence = weighting.Sequence,
  315. GPRS = weighting.GPRS,
  316. Width = weighting.w,
  317. Height = weighting.h,
  318. UploadTime = DateTime.Now
  319. };
  320. if (serverWeighting.Gross.HasValue && weighting.LimitWeight.HasValue)
  321. {
  322. serverWeighting.OverloadWeight = weighting.Gross.Value - weighting.LimitWeight.Value;
  323. if (serverWeighting.OverloadWeight < 0)
  324. {
  325. serverWeighting.OverloadWeight = 0;
  326. }
  327. }
  328. if (serverWeighting.OverloadRate.HasValue)
  329. {
  330. if (serverWeighting.OverloadRate.Value > 0)
  331. {
  332. serverWeighting.OverloadRate = serverWeighting.OverloadRate.Value / (decimal)100.00;
  333. }
  334. }
  335. if (serverWeighting.WeightTime.HasValue)
  336. {
  337. serverWeighting.WeightTime_Year = serverWeighting.WeightTime.Value.Year;
  338. serverWeighting.WeightTime_Month = serverWeighting.WeightTime.Value.Month;
  339. serverWeighting.WeightTime_Day = serverWeighting.WeightTime.Value.Day;
  340. serverWeighting.WeightTime_Hour = serverWeighting.WeightTime.Value.Hour;
  341. serverWeighting.WeightTime_Minute = serverWeighting.WeightTime.Value.Minute;
  342. }
  343. #region 附件
  344. foreach (var file in weighting.WeightingFiles) {
  345. file.DeviceID = serverWeighting.DeviceID;
  346. serverWeighting.WeightingFiles.Add(file);
  347. }
  348. #endregion
  349. try
  350. {
  351. if (MSHO.Collection.DataAccess.MSHOService.Instance.SaveWeighting(clientConfig, serverWeighting))
  352. {
  353. msg.Result = true;
  354. msg.DataId = weightId;
  355. msg.WeightingFiles = serverWeighting.WeightingFiles.ToList();
  356. }
  357. }
  358. catch (Exception ex)
  359. {
  360. MSHO.Collection.DataAccess.MSHOService.Instance.SaveSystemLog("MSHO.Collection.Service", "Process_Access_Weighting", ex);
  361. msg.Result = false;
  362. msg.DataId = weightId;
  363. }
  364. }
  365. }
  366. }
  367. }
  368. private void Process_SQL2000_DiBangData_Weighting(DataReportRespMsg msg, DataReportMsg data_report)
  369. {
  370. var weighting = JsonSerializable.FromJson<MSHO.Collection.DataAccess.ClientModels.SQL2000_DiBangData_Weighting>(data_report.Result);
  371. if (weighting != null)
  372. {
  373. #region clientConfig
  374. MSHO.Collection.DataAccess.Models.CollectConfig clientConfig = null;
  375. if (m_CollectConfigs.ContainsKey(msg.ClientCode))
  376. {
  377. clientConfig = m_CollectConfigs[msg.ClientCode];
  378. }
  379. if (clientConfig == null)
  380. {
  381. clientConfig = MSHO.Collection.DataAccess.MSHOService.Instance.GetCollectConfigByCode(msg.ClientCode);
  382. }
  383. #endregion
  384. if (clientConfig != null)
  385. {
  386. #region check exist
  387. string prexWeightId = string.Empty;
  388. if (!m_CollectConfigs.ContainsKey(msg.ClientCode))
  389. {
  390. m_CollectConfigs.Add(msg.ClientCode, clientConfig);
  391. }
  392. clientConfig.LastSourceTime = weighting.WeightTime;
  393. bool exist = false;
  394. if (weighting.ID.HasValue)
  395. {
  396. prexWeightId = string.Format("SQL2000_{0}", weighting.ID.Value);
  397. clientConfig.LastSourceID = weighting.ID.ToString();
  398. exist = MSHO.Collection.DataAccess.MSHOService.Instance.ExistWeighting(clientConfig.StationID, clientConfig.DeviceID, prexWeightId);
  399. }
  400. #endregion
  401. string weightId = weighting.ID.HasValue ? weighting.ID.Value.ToString() : string.Empty;
  402. if (exist)
  403. {
  404. msg.Result = true;
  405. msg.DataId = weightId;
  406. }
  407. else
  408. {
  409. string axleType = null;
  410. if (!string.IsNullOrEmpty(weighting.LicenseNo))
  411. {
  412. var n = weighting.LicenseNo.LastIndexOf("-");
  413. if (n > 0)
  414. {
  415. axleType = weighting.LicenseNo.Substring(n + 1);
  416. }
  417. }
  418. var serverWeighting = new MSHO.Collection.DataAccess.Models.Weighting()
  419. {
  420. StationID = clientConfig.StationID,
  421. DeviceID = clientConfig.DeviceID,
  422. WeightID = prexWeightId,
  423. WeightTime = weighting.WeightTime,
  424. TruckNumber = weighting.TruckNumber,
  425. CaptureTime = weighting.WeightTime,
  426. AxleType = axleType,
  427. AxleCount = weighting.AxleCount,
  428. Speed = weighting.Speed,
  429. Gross = weighting.Gross,
  430. LimitWeight = weighting.LimitWeight,
  431. OverloadRate = weighting.OverloadRate,
  432. Checker = weighting.Checker,
  433. LicenseNo = weighting.LicenseNo,
  434. Sequence = weighting.Sequence,
  435. GPRS = weighting.GPRS,
  436. UploadTime = DateTime.Now
  437. };
  438. if (serverWeighting.Gross.HasValue && weighting.LimitWeight.HasValue)
  439. {
  440. serverWeighting.OverloadWeight = weighting.Gross.Value - weighting.LimitWeight.Value;
  441. if (serverWeighting.OverloadWeight < 0)
  442. {
  443. serverWeighting.OverloadWeight = 0;
  444. }
  445. }
  446. if (serverWeighting.OverloadRate.HasValue)
  447. {
  448. if (serverWeighting.OverloadRate.Value > 0)
  449. {
  450. serverWeighting.OverloadRate = serverWeighting.OverloadRate.Value / (decimal)100.00;
  451. }
  452. }
  453. if (serverWeighting.WeightTime.HasValue)
  454. {
  455. serverWeighting.WeightTime_Year = serverWeighting.WeightTime.Value.Year;
  456. serverWeighting.WeightTime_Month = serverWeighting.WeightTime.Value.Month;
  457. serverWeighting.WeightTime_Day = serverWeighting.WeightTime.Value.Day;
  458. serverWeighting.WeightTime_Hour = serverWeighting.WeightTime.Value.Hour;
  459. serverWeighting.WeightTime_Minute = serverWeighting.WeightTime.Value.Minute;
  460. }
  461. #region 附件
  462. foreach (var file in weighting.WeightingFiles)
  463. {
  464. file.DeviceID = serverWeighting.DeviceID;
  465. serverWeighting.WeightingFiles.Add(file);
  466. }
  467. #endregion
  468. try
  469. {
  470. if (MSHO.Collection.DataAccess.MSHOService.Instance.SaveWeighting(clientConfig, serverWeighting))
  471. {
  472. msg.Result = true;
  473. msg.DataId = weightId;
  474. msg.WeightingFiles = serverWeighting.WeightingFiles.ToList();
  475. }
  476. }
  477. catch (Exception ex)
  478. {
  479. MSHO.Collection.DataAccess.MSHOService.Instance.SaveSystemLog("MSHO.Collection.Service", "Process_SQL2000_DiBangData_Weighting", ex);
  480. msg.Result = false;
  481. msg.DataId = weightId;
  482. }
  483. }
  484. }
  485. }
  486. }
  487. private void Process_SQL2000_oreManageDBCli_Weighting(DataReportRespMsg msg, DataReportMsg data_report)
  488. {
  489. var weighting = JsonSerializable.FromJson<MSHO.Collection.DataAccess.ClientModels.SQL2000_oreManageDBCli_Weighting>(data_report.Result);
  490. if (weighting != null)
  491. {
  492. #region clientConfig
  493. MSHO.Collection.DataAccess.Models.CollectConfig clientConfig = null;
  494. if (m_CollectConfigs.ContainsKey(msg.ClientCode))
  495. {
  496. clientConfig = m_CollectConfigs[msg.ClientCode];
  497. }
  498. if (clientConfig == null)
  499. {
  500. clientConfig = MSHO.Collection.DataAccess.MSHOService.Instance.GetCollectConfigByCode(msg.ClientCode);
  501. }
  502. #endregion
  503. if (clientConfig != null)
  504. {
  505. #region check exist
  506. if (!m_CollectConfigs.ContainsKey(msg.ClientCode))
  507. {
  508. m_CollectConfigs.Add(msg.ClientCode, clientConfig);
  509. }
  510. clientConfig.LastSourceTime = weighting.WeightTime;
  511. bool exist = false;
  512. if (weighting.ID.HasValue)
  513. {
  514. clientConfig.LastSourceID = weighting.ID.ToString();
  515. exist = MSHO.Collection.DataAccess.MSHOService.Instance.ExistWeighting(clientConfig.StationID, clientConfig.DeviceID, clientConfig.LastSourceID);
  516. }
  517. #endregion
  518. string weightId = weighting.ID.HasValue ? weighting.ID.Value.ToString() : string.Empty;
  519. if (exist)
  520. {
  521. msg.Result = true;
  522. msg.DataId = weightId;
  523. }
  524. else
  525. {
  526. var serverWeighting = new MSHO.Collection.DataAccess.Models.Weighting()
  527. {
  528. StationID = clientConfig.StationID,
  529. DeviceID = clientConfig.DeviceID,
  530. WeightID = weightId,
  531. WeightTime = weighting.checkdate,
  532. TruckNumber = weighting.licenseplate,
  533. CaptureTime = weighting.checkdate,
  534. AxleCount = weighting.axleCount,
  535. Gross = weighting.totalWeigh,
  536. LimitWeight = weighting.amountWeigh,
  537. OverloadWeight = 0,
  538. OverloadRate = weighting.overRatio,
  539. Checker = weighting.@operator,
  540. Remark = weighting.descript,
  541. UploadTime = DateTime.Now
  542. };
  543. if (serverWeighting.Gross.HasValue)
  544. {
  545. if (serverWeighting.Gross.Value > 0)
  546. {
  547. serverWeighting.Gross /= 1000;
  548. }
  549. }
  550. if (serverWeighting.LimitWeight.HasValue)
  551. {
  552. if (serverWeighting.LimitWeight.Value > 0)
  553. {
  554. serverWeighting.LimitWeight /= 1000;
  555. }
  556. }
  557. if (serverWeighting.Gross.HasValue && serverWeighting.LimitWeight.HasValue)
  558. {
  559. if (serverWeighting.Gross.Value > serverWeighting.LimitWeight.Value)
  560. {
  561. serverWeighting.OverloadWeight = serverWeighting.Gross.Value - serverWeighting.LimitWeight.Value;
  562. }
  563. }
  564. if (serverWeighting.OverloadRate.HasValue)
  565. {
  566. if (serverWeighting.OverloadRate.Value > 0)
  567. {
  568. serverWeighting.OverloadRate = serverWeighting.OverloadRate.Value / (decimal)100.00;
  569. }
  570. }
  571. if (serverWeighting.WeightTime.HasValue)
  572. {
  573. serverWeighting.WeightTime_Year = serverWeighting.WeightTime.Value.Year;
  574. serverWeighting.WeightTime_Month = serverWeighting.WeightTime.Value.Month;
  575. serverWeighting.WeightTime_Day = serverWeighting.WeightTime.Value.Day;
  576. serverWeighting.WeightTime_Hour = serverWeighting.WeightTime.Value.Hour;
  577. serverWeighting.WeightTime_Minute = serverWeighting.WeightTime.Value.Minute;
  578. }
  579. #region 附件
  580. foreach (var file in weighting.WeightingFiles)
  581. {
  582. file.DeviceID = serverWeighting.DeviceID;
  583. serverWeighting.WeightingFiles.Add(file);
  584. }
  585. #endregion
  586. try
  587. {
  588. if (MSHO.Collection.DataAccess.MSHOService.Instance.SaveWeighting(clientConfig, serverWeighting))
  589. {
  590. msg.Result = true;
  591. msg.DataId = weightId;
  592. msg.WeightingFiles = serverWeighting.WeightingFiles.ToList();
  593. }
  594. }
  595. catch (Exception ex)
  596. {
  597. MSHO.Collection.DataAccess.MSHOService.Instance.SaveSystemLog("MSHO.Collection.Service", "Process_SQL2000_oreManageDBCli_Weighting", ex);
  598. msg.Result = false;
  599. msg.DataId = weightId;
  600. }
  601. }
  602. }
  603. }
  604. }
  605. private void Process_SQL2000_oreManageDBCli_2_Weighting(DataReportRespMsg msg, DataReportMsg data_report)
  606. {
  607. var weighting = JsonSerializable.FromJson<MSHO.Collection.DataAccess.ClientModels.SQL2000_oreManageDBCli_2_Weighting>(data_report.Result);
  608. if (weighting != null)
  609. {
  610. #region clientConfig
  611. MSHO.Collection.DataAccess.Models.CollectConfig clientConfig = null;
  612. if (m_CollectConfigs.ContainsKey(msg.ClientCode))
  613. {
  614. clientConfig = m_CollectConfigs[msg.ClientCode];
  615. }
  616. if (clientConfig == null)
  617. {
  618. clientConfig = MSHO.Collection.DataAccess.MSHOService.Instance.GetCollectConfigByCode(msg.ClientCode);
  619. }
  620. #endregion
  621. if (clientConfig != null)
  622. {
  623. #region check exist
  624. if (!m_CollectConfigs.ContainsKey(msg.ClientCode))
  625. {
  626. m_CollectConfigs.Add(msg.ClientCode, clientConfig);
  627. }
  628. clientConfig.LastSourceTime = weighting.WeightTime;
  629. bool exist = false;
  630. if (weighting.ID.HasValue)
  631. {
  632. clientConfig.LastSourceID = weighting.ID.ToString();
  633. exist = MSHO.Collection.DataAccess.MSHOService.Instance.ExistWeighting(clientConfig.StationID, clientConfig.DeviceID, clientConfig.LastSourceID);
  634. }
  635. #endregion
  636. string weightId = weighting.ID.HasValue ? weighting.ID.Value.ToString() : string.Empty;
  637. if (exist)
  638. {
  639. msg.Result = true;
  640. msg.DataId = weightId;
  641. }
  642. else
  643. {
  644. var serverWeighting = new MSHO.Collection.DataAccess.Models.Weighting()
  645. {
  646. StationID = clientConfig.StationID,
  647. DeviceID = clientConfig.DeviceID,
  648. WeightID = weightId,
  649. WeightTime = weighting.checkdate,
  650. TruckNumber = weighting.licenseplate,
  651. CaptureTime = weighting.checkdate,
  652. AxleCount = weighting.axleCount,
  653. AxleType = weighting.vehicleType,
  654. Way = weighting.direction,
  655. LaneNumber = weighting.roadNum,
  656. Gross = weighting.totalWeigh,
  657. LimitWeight = weighting.amountWeigh,
  658. OverloadWeight = weighting.overWeigh,
  659. OverloadRate = weighting.overRatio,
  660. Checker = weighting.@operator,
  661. UploadTime = DateTime.Now
  662. };
  663. #region axleWeight
  664. if (!string.IsNullOrEmpty(weighting.axleWeight)) {
  665. int num = 0;
  666. var sp = weighting.axleWeight.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
  667. switch (sp.Length) {
  668. case 1:
  669. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  670. break;
  671. case 2:
  672. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  673. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  674. break;
  675. case 3:
  676. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  677. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  678. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  679. break;
  680. case 4:
  681. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  682. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  683. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  684. if (int.TryParse(sp[3], out num)) { serverWeighting.AxleWeight4 = num; }
  685. break;
  686. case 5:
  687. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  688. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  689. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  690. if (int.TryParse(sp[3], out num)) { serverWeighting.AxleWeight4 = num; }
  691. if (int.TryParse(sp[4], out num)) { serverWeighting.AxleWeight5 = num; }
  692. break;
  693. case 6:
  694. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  695. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  696. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  697. if (int.TryParse(sp[3], out num)) { serverWeighting.AxleWeight4 = num; }
  698. if (int.TryParse(sp[4], out num)) { serverWeighting.AxleWeight5 = num; }
  699. if (int.TryParse(sp[5], out num)) { serverWeighting.AxleWeight6 = num; }
  700. break;
  701. case 7:
  702. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  703. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  704. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  705. if (int.TryParse(sp[3], out num)) { serverWeighting.AxleWeight4 = num; }
  706. if (int.TryParse(sp[4], out num)) { serverWeighting.AxleWeight5 = num; }
  707. if (int.TryParse(sp[5], out num)) { serverWeighting.AxleWeight6 = num; }
  708. if (int.TryParse(sp[6], out num)) { serverWeighting.AxleWeight7 = num; }
  709. break;
  710. case 8:
  711. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  712. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  713. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  714. if (int.TryParse(sp[3], out num)) { serverWeighting.AxleWeight4 = num; }
  715. if (int.TryParse(sp[4], out num)) { serverWeighting.AxleWeight5 = num; }
  716. if (int.TryParse(sp[5], out num)) { serverWeighting.AxleWeight6 = num; }
  717. if (int.TryParse(sp[6], out num)) { serverWeighting.AxleWeight7 = num; }
  718. if (int.TryParse(sp[7], out num)) { serverWeighting.AxleWeight8 = num; }
  719. break;
  720. }
  721. }
  722. #endregion
  723. if (serverWeighting.Gross.HasValue)
  724. {
  725. if (serverWeighting.Gross.Value > 0)
  726. {
  727. serverWeighting.Gross /= 1000;
  728. }
  729. }
  730. if (serverWeighting.LimitWeight.HasValue)
  731. {
  732. if (serverWeighting.LimitWeight.Value > 0)
  733. {
  734. serverWeighting.LimitWeight /= 1000;
  735. }
  736. }
  737. if (serverWeighting.OverloadWeight.HasValue)
  738. {
  739. if (serverWeighting.OverloadWeight.Value > 0)
  740. {
  741. serverWeighting.OverloadWeight /= 1000;
  742. }
  743. }
  744. if (serverWeighting.OverloadRate.HasValue)
  745. {
  746. if (serverWeighting.OverloadRate.Value > 0)
  747. {
  748. serverWeighting.OverloadRate = serverWeighting.OverloadRate.Value / (decimal)100.00;
  749. }
  750. }
  751. if (serverWeighting.WeightTime.HasValue)
  752. {
  753. serverWeighting.WeightTime_Year = serverWeighting.WeightTime.Value.Year;
  754. serverWeighting.WeightTime_Month = serverWeighting.WeightTime.Value.Month;
  755. serverWeighting.WeightTime_Day = serverWeighting.WeightTime.Value.Day;
  756. serverWeighting.WeightTime_Hour = serverWeighting.WeightTime.Value.Hour;
  757. serverWeighting.WeightTime_Minute = serverWeighting.WeightTime.Value.Minute;
  758. }
  759. #region 附件
  760. foreach (var file in weighting.WeightingFiles)
  761. {
  762. file.DeviceID = serverWeighting.DeviceID;
  763. serverWeighting.WeightingFiles.Add(file);
  764. }
  765. #endregion
  766. try
  767. {
  768. if (MSHO.Collection.DataAccess.MSHOService.Instance.SaveWeighting(clientConfig, serverWeighting))
  769. {
  770. msg.Result = true;
  771. msg.DataId = weightId;
  772. msg.WeightingFiles = serverWeighting.WeightingFiles.ToList();
  773. }
  774. }
  775. catch (Exception ex)
  776. {
  777. MSHO.Collection.DataAccess.MSHOService.Instance.SaveSystemLog("MSHO.Collection.Service", "Process_SQL2000_oreManageDBCli_Weighting", ex);
  778. msg.Result = false;
  779. msg.DataId = weightId;
  780. }
  781. }
  782. }
  783. }
  784. }
  785. private void Process_SQL2000_oreManageDBCli_3_Weighting(DataReportRespMsg msg, DataReportMsg data_report)
  786. {
  787. var weighting = JsonSerializable.FromJson<MSHO.Collection.DataAccess.ClientModels.SQL2000_oreManageDBCli_3_Weighting>(data_report.Result);
  788. if (weighting != null)
  789. {
  790. #region clientConfig
  791. MSHO.Collection.DataAccess.Models.CollectConfig clientConfig = null;
  792. if (m_CollectConfigs.ContainsKey(msg.ClientCode))
  793. {
  794. clientConfig = m_CollectConfigs[msg.ClientCode];
  795. }
  796. if (clientConfig == null)
  797. {
  798. clientConfig = MSHO.Collection.DataAccess.MSHOService.Instance.GetCollectConfigByCode(msg.ClientCode);
  799. }
  800. #endregion
  801. if (clientConfig != null)
  802. {
  803. #region check exist
  804. if (!m_CollectConfigs.ContainsKey(msg.ClientCode))
  805. {
  806. m_CollectConfigs.Add(msg.ClientCode, clientConfig);
  807. }
  808. clientConfig.LastSourceTime = weighting.WeightTime;
  809. bool exist = false;
  810. if (weighting.ID.HasValue)
  811. {
  812. clientConfig.LastSourceID = weighting.ID.ToString();
  813. exist = MSHO.Collection.DataAccess.MSHOService.Instance.ExistWeighting(clientConfig.StationID, clientConfig.DeviceID, clientConfig.LastSourceID);
  814. }
  815. #endregion
  816. string weightId = weighting.ID.HasValue ? weighting.ID.Value.ToString() : string.Empty;
  817. if (exist)
  818. {
  819. msg.Result = true;
  820. msg.DataId = weightId;
  821. }
  822. else
  823. {
  824. var serverWeighting = new MSHO.Collection.DataAccess.Models.Weighting()
  825. {
  826. StationID = clientConfig.StationID,
  827. DeviceID = clientConfig.DeviceID,
  828. WeightID = weightId,
  829. WeightTime = weighting.checkdate,
  830. TruckNumber = weighting.licenseplate,
  831. CaptureTime = weighting.checkdate,
  832. AxleCount = weighting.axleCount,
  833. AxleType = weighting.vehicleType,
  834. LaneNumber = weighting.roadNum,
  835. Gross = weighting.totalWeigh,
  836. LimitWeight = weighting.amountWeigh,
  837. OverloadWeight = weighting.overWeigh,
  838. OverloadRate = weighting.overRatio,
  839. Checker = weighting.@operator,
  840. UploadTime = DateTime.Now
  841. };
  842. #region axleWeight
  843. if (!string.IsNullOrEmpty(weighting.axleWeight))
  844. {
  845. int num = 0;
  846. var sp = weighting.axleWeight.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
  847. switch (sp.Length)
  848. {
  849. case 1:
  850. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  851. break;
  852. case 2:
  853. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  854. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  855. break;
  856. case 3:
  857. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  858. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  859. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  860. break;
  861. case 4:
  862. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  863. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  864. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  865. if (int.TryParse(sp[3], out num)) { serverWeighting.AxleWeight4 = num; }
  866. break;
  867. case 5:
  868. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  869. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  870. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  871. if (int.TryParse(sp[3], out num)) { serverWeighting.AxleWeight4 = num; }
  872. if (int.TryParse(sp[4], out num)) { serverWeighting.AxleWeight5 = num; }
  873. break;
  874. case 6:
  875. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  876. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  877. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  878. if (int.TryParse(sp[3], out num)) { serverWeighting.AxleWeight4 = num; }
  879. if (int.TryParse(sp[4], out num)) { serverWeighting.AxleWeight5 = num; }
  880. if (int.TryParse(sp[5], out num)) { serverWeighting.AxleWeight6 = num; }
  881. break;
  882. case 7:
  883. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  884. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  885. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  886. if (int.TryParse(sp[3], out num)) { serverWeighting.AxleWeight4 = num; }
  887. if (int.TryParse(sp[4], out num)) { serverWeighting.AxleWeight5 = num; }
  888. if (int.TryParse(sp[5], out num)) { serverWeighting.AxleWeight6 = num; }
  889. if (int.TryParse(sp[6], out num)) { serverWeighting.AxleWeight7 = num; }
  890. break;
  891. case 8:
  892. if (int.TryParse(sp[0], out num)) { serverWeighting.AxleWeight1 = num; }
  893. if (int.TryParse(sp[1], out num)) { serverWeighting.AxleWeight2 = num; }
  894. if (int.TryParse(sp[2], out num)) { serverWeighting.AxleWeight3 = num; }
  895. if (int.TryParse(sp[3], out num)) { serverWeighting.AxleWeight4 = num; }
  896. if (int.TryParse(sp[4], out num)) { serverWeighting.AxleWeight5 = num; }
  897. if (int.TryParse(sp[5], out num)) { serverWeighting.AxleWeight6 = num; }
  898. if (int.TryParse(sp[6], out num)) { serverWeighting.AxleWeight7 = num; }
  899. if (int.TryParse(sp[7], out num)) { serverWeighting.AxleWeight8 = num; }
  900. break;
  901. }
  902. }
  903. #endregion
  904. if (serverWeighting.Gross.HasValue)
  905. {
  906. if (serverWeighting.Gross.Value > 0)
  907. {
  908. serverWeighting.Gross /= 1000;
  909. }
  910. }
  911. if (serverWeighting.LimitWeight.HasValue)
  912. {
  913. if (serverWeighting.LimitWeight.Value > 0)
  914. {
  915. serverWeighting.LimitWeight /= 1000;
  916. }
  917. }
  918. if (serverWeighting.OverloadWeight.HasValue)
  919. {
  920. if (serverWeighting.OverloadWeight.Value > 0)
  921. {
  922. serverWeighting.OverloadWeight /= 1000;
  923. }
  924. }
  925. if (serverWeighting.OverloadRate.HasValue)
  926. {
  927. if (serverWeighting.OverloadRate.Value > 0)
  928. {
  929. serverWeighting.OverloadRate = serverWeighting.OverloadRate.Value / (decimal)100.00;
  930. }
  931. }
  932. if (serverWeighting.WeightTime.HasValue)
  933. {
  934. serverWeighting.WeightTime_Year = serverWeighting.WeightTime.Value.Year;
  935. serverWeighting.WeightTime_Month = serverWeighting.WeightTime.Value.Month;
  936. serverWeighting.WeightTime_Day = serverWeighting.WeightTime.Value.Day;
  937. serverWeighting.WeightTime_Hour = serverWeighting.WeightTime.Value.Hour;
  938. serverWeighting.WeightTime_Minute = serverWeighting.WeightTime.Value.Minute;
  939. }
  940. #region 附件
  941. foreach (var file in weighting.WeightingFiles)
  942. {
  943. file.DeviceID = serverWeighting.DeviceID;
  944. serverWeighting.WeightingFiles.Add(file);
  945. }
  946. #endregion
  947. try
  948. {
  949. if (MSHO.Collection.DataAccess.MSHOService.Instance.SaveWeighting(clientConfig, serverWeighting))
  950. {
  951. msg.Result = true;
  952. msg.DataId = weightId;
  953. msg.WeightingFiles = serverWeighting.WeightingFiles.ToList();
  954. }
  955. }
  956. catch (Exception ex)
  957. {
  958. MSHO.Collection.DataAccess.MSHOService.Instance.SaveSystemLog("MSHO.Collection.Service", "Process_SQL2000_oreManageDBCli_Weighting", ex);
  959. msg.Result = false;
  960. msg.DataId = weightId;
  961. }
  962. }
  963. }
  964. }
  965. }
  966. private void Process_LowSpeedNew_Weighting(DataReportRespMsg msg, DataReportMsg data_report)
  967. {
  968. var weighting = JsonSerializable.FromJson<MSHO.Collection.DataAccess.ClientModels.LowSpeedNew_Weighting>(data_report.Result);
  969. if (weighting != null)
  970. {
  971. #region clientConfig
  972. MSHO.Collection.DataAccess.Models.CollectConfig clientConfig = null;
  973. if (m_CollectConfigs.ContainsKey(msg.ClientCode))
  974. {
  975. clientConfig = m_CollectConfigs[msg.ClientCode];
  976. }
  977. if (clientConfig == null)
  978. {
  979. clientConfig = MSHO.Collection.DataAccess.MSHOService.Instance.GetCollectConfigByCode(msg.ClientCode);
  980. }
  981. #endregion
  982. if (clientConfig != null)
  983. {
  984. #region check exist
  985. if (!m_CollectConfigs.ContainsKey(msg.ClientCode))
  986. {
  987. m_CollectConfigs.Add(msg.ClientCode, clientConfig);
  988. }
  989. clientConfig.LastSourceTime = weighting.WeightTime;
  990. bool exist = false;
  991. if (!string.IsNullOrEmpty(weighting.CheckCode))
  992. {
  993. clientConfig.LastSourceID = weighting.CheckCode;
  994. exist = MSHO.Collection.DataAccess.MSHOService.Instance.ExistWeighting(clientConfig.StationID, clientConfig.DeviceID, clientConfig.LastSourceID);
  995. }
  996. #endregion
  997. string weightId = (string.IsNullOrEmpty(weighting.CheckCode) ? (weighting.LSData_ID.HasValue ? weighting.LSData_ID.Value.ToString() : string.Empty) : weighting.CheckCode);
  998. if (exist)
  999. {
  1000. msg.Result = true;
  1001. msg.DataId = weightId;
  1002. }
  1003. else
  1004. {
  1005. var serverWeighting = new MSHO.Collection.DataAccess.Models.Weighting()
  1006. {
  1007. StationID = clientConfig.StationID,
  1008. DeviceID = clientConfig.DeviceID,
  1009. WeightID = weightId,
  1010. WeightTime = weighting.Check_DT,
  1011. TruckNumber = weighting.License_Plate,
  1012. TruckColor = weighting.Plate_Color,
  1013. CaptureTime = weighting.Check_DT,
  1014. LaneNumber = (int)weighting.Lane_ID,
  1015. Speed = weighting.Veh_Speed,
  1016. AxleCount = (int)weighting.Axle_Num,
  1017. AxleType = (weighting.Axle_Type.HasValue ? weighting.Axle_Type.Value.ToString() : null),
  1018. Gross = weighting.Whole_Weight,
  1019. LimitWeight = weighting.Whole_Limit,
  1020. OverloadWeight = weighting.Whole_Over,
  1021. OverloadRate = weighting.Whole_Overrate,
  1022. Checker = weighting.Staff_ID,
  1023. Remark = (weighting.Over_Num > 0 ? string.Format("超限次数{0}", weighting.Over_Num) : null),
  1024. AxleWeight1 = weighting.Axle1_Weight,
  1025. AxleWeight2 = weighting.Axle2_Weight,
  1026. AxleWeight3 = weighting.Axle3_Weight,
  1027. AxleWeight4 = weighting.Axle4_Weight,
  1028. AxleWeight5 = weighting.Axle5_Weight,
  1029. AxleWeight6 = weighting.Axle6_Weight,
  1030. AxleWeight7 = weighting.Axle7_Weight,
  1031. AxleWeight8 = weighting.Axle8_Weight,
  1032. Width = weighting.Veh_Width,
  1033. Height = weighting.Veh_Height,
  1034. Length = weighting.Veh_Length,
  1035. UploadTime = DateTime.Now
  1036. };
  1037. #region process value
  1038. if (serverWeighting.Gross.HasValue)
  1039. {
  1040. if (serverWeighting.Gross.Value > 0)
  1041. {
  1042. serverWeighting.Gross /= 1000;
  1043. }
  1044. }
  1045. if (serverWeighting.LimitWeight.HasValue)
  1046. {
  1047. if (serverWeighting.LimitWeight.Value > 0)
  1048. {
  1049. serverWeighting.LimitWeight /= 1000;
  1050. }
  1051. }
  1052. if (serverWeighting.OverloadWeight.HasValue)
  1053. {
  1054. if (serverWeighting.OverloadWeight.Value > 0)
  1055. {
  1056. serverWeighting.OverloadWeight /= 1000;
  1057. }
  1058. }
  1059. if (serverWeighting.OverloadWeight.HasValue && serverWeighting.LimitWeight.HasValue && serverWeighting.OverloadWeight.Value > 0 && serverWeighting.LimitWeight > 0)
  1060. {
  1061. serverWeighting.OverloadRate = serverWeighting.OverloadWeight.Value / serverWeighting.LimitWeight.Value;
  1062. }
  1063. else if (serverWeighting.OverloadRate.HasValue)
  1064. {
  1065. if (serverWeighting.OverloadRate.Value > 0)
  1066. {
  1067. serverWeighting.OverloadRate = serverWeighting.OverloadRate.Value / (decimal)100.00;
  1068. }
  1069. }
  1070. if (serverWeighting.WeightTime.HasValue)
  1071. {
  1072. serverWeighting.WeightTime_Year = serverWeighting.WeightTime.Value.Year;
  1073. serverWeighting.WeightTime_Month = serverWeighting.WeightTime.Value.Month;
  1074. serverWeighting.WeightTime_Day = serverWeighting.WeightTime.Value.Day;
  1075. serverWeighting.WeightTime_Hour = serverWeighting.WeightTime.Value.Hour;
  1076. serverWeighting.WeightTime_Minute = serverWeighting.WeightTime.Value.Minute;
  1077. }
  1078. #endregion
  1079. #region 附件
  1080. foreach (var file in weighting.WeightingFiles)
  1081. {
  1082. file.DeviceID = serverWeighting.DeviceID;
  1083. serverWeighting.WeightingFiles.Add(file);
  1084. }
  1085. #endregion
  1086. try
  1087. {
  1088. if (MSHO.Collection.DataAccess.MSHOService.Instance.SaveWeighting(clientConfig, serverWeighting))
  1089. {
  1090. msg.Result = true;
  1091. msg.DataId = weightId;
  1092. msg.WeightingFiles = serverWeighting.WeightingFiles.ToList();
  1093. }
  1094. }
  1095. catch (Exception ex)
  1096. {
  1097. MSHO.Collection.DataAccess.MSHOService.Instance.SaveSystemLog("MSHO.Collection.Service", "Process_LowSpeedNew_Weighting", ex);
  1098. msg.Result = false;
  1099. msg.DataId = weightId;
  1100. }
  1101. }
  1102. }
  1103. }
  1104. }
  1105. }
  1106. }