/// <summary> /// 劫车报警 /// </summary> /// <param name="para"></param> /// <returns></returns> public List<RobAlertReportViewModel> GetRobAlert(ReportSearchViewModel para) { try { List<Guid> vehicleList = para.VehicleList.Select(p => p.Key).ToList(); IAlertReportBase alertReportBase = new AlertReportBase(); IList<ERobAlertReport> list = alertReportBase.ReportSearch<ERobAlertReport>(vehicleList, para.BeginTime, para.EndTime); List<RobAlertReportViewModel> listModel = new List<RobAlertReportViewModel>(); //if (list != null && list.Count > 0) //{ //int index = 0; IDictionary<Guid, int> dicCount = list.GroupBy(p => p.VehicleCode).ToDictionary(p => p.Key, p => p.Count()); foreach (KeyValuePair<Guid, string> kvp in para.VehicleList) { //index++; RobAlertReportViewModel model = new RobAlertReportViewModel(); //model.Index = index; model.VehicleNo = kvp.Value; if (dicCount.ContainsKey(kvp.Key)) model.Count = dicCount[kvp.Key]; else model.Count = 0; listModel.Add(model); } //} listModel = listModel.OrderBy(p => p.VehicleNo).ToList(); return listModel; } catch (Exception ex) { Logger.Error("Error GetRobAlert:" + ex.Message, ex); return null; } }
/// <summary> /// 断电报警 /// </summary> /// <param name="para"></param> /// <returns></returns> public List<PowerDownAlertReportViewModel> GetPowerDownAlert(ReportSearchViewModel para) { try { List<Guid> vehicleList = para.VehicleList.Select(p => p.Key).ToList(); IAlertReportBase alertReportBase = new AlertReportBase(); IList<EPowerDownAlertReport> list = alertReportBase.ReportSearch<EPowerDownAlertReport>(vehicleList, para.BeginTime, para.EndTime); List<PowerDownAlertReportViewModel> listModel = new List<PowerDownAlertReportViewModel>(); //if (list != null && list.Count > 0) //{ foreach (KeyValuePair<Guid, string> kvp in para.VehicleList) { int count = 0; TimeSpan sumTime = new TimeSpan(); for (int i = 0; i < list.Count; i++) { if (kvp.Key == list[i].VehicleCode) { count++; sumTime += list[i].AlertTimeSpan; } } PowerDownAlertReportViewModel model = new PowerDownAlertReportViewModel(); //model.Index = index; model.VehicleNo = kvp.Value; model.Count = count; model.CountTime = sumTime; if (sumTime.TotalMinutes == 0.0) model.CountTimeString = "0分"; else model.CountTimeString = DateTimeHelper.GetTimeCnName(sumTime, EnumTimeCnNameDepth.Minutes); listModel.Add(model); } //} listModel = listModel.OrderBy(p => p.VehicleNo).ToList(); return listModel; } catch (Exception ex) { Logger.Error("Error GetPowerDownAlert:" + ex.Message, ex); return null; } }