/// <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="param"></param> /// <returns></returns> public List<ReportSummaryVM> CountReport(ReportSummaryParam param) { try { ReportMileageWCFPara mileageParam = new ReportMileageWCFPara() { BeginTime = param.BeginTime, EndTime = param.EndTime, tenantCode = param.TenantCode, VehicleCode = param.Vehicles.Select(s => s.VehicleCode).ToArray(), LicenceNumber = param.Vehicles.Select(s => s.LicenceNumber).ToArray() }; //List<ReportMileageViewModel> listMileage = this.GetMileage(mileageParam);执行使用8.22s //查询车辆里程的代码优化 List<ReportMileageViewModel> listMileage = this.GetNewMileage(mileageParam);//执行使用5.74s IAlertReportBase reportBase = new AlertReportBase(); var ltVehicleCode = param.Vehicles.Select(s => s.VehicleCode).ToList(); Dictionary<Guid, VCountStopCar> dicStop = new StopCarReportService().Count(ltVehicleCode, param.BeginTime, param.EndTime, StopCar_Time, param.TenantCode); Dictionary<Guid, int> dicRob = reportBase.Count<ERobAlertReport>(ltVehicleCode, param.BeginTime, param.EndTime); Dictionary<Guid, int> dicPowerdown = reportBase.Count<EPowerDownAlertReport>(ltVehicleCode, param.BeginTime, param.EndTime); Dictionary<Guid, int> dicOverSpeed = CountOverSpeed(param); var dicParam = new Dictionary<string, object>(); dicParam.Add("IsInArea", true); //入区域条件 dicParam.Add("IsDelayStay", false); //非延迟出区域 Dictionary<Guid, int> dicArea = reportBase.Count<EAreaAlertReport>(ltVehicleCode, param.BeginTime, param.EndTime, dicParam); return CrateReportSummaryVM(param.Vehicles, listMileage, dicStop, dicPowerdown, dicRob, dicOverSpeed, dicArea); } catch (Exception ex) { Logger.Error(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; } }
/// <summary> /// 添加报警点信息 /// </summary> /// <param name="vehicleCode"></param> /// <param name="beginTime"></param> /// <param name="ltHistoryRunInfo"></param> private void AddAlertPoint(Guid vehicleCode, DateTime beginTime, List<VGPSHistoryRunInfo> ltHistoryRunInfo) { AlertReportBase alertReportBase = new AlertReportBase(); //查询断电报警 IList<EPowerDownAlertReport> EPowerDownAlertReportList = alertReportBase.ReportSearch<EPowerDownAlertReport>(new List<Guid>() { vehicleCode }, beginTime, Convert.ToDateTime(ltHistoryRunInfo[ltHistoryRunInfo.Count - 1].ReportTime)); //查询劫车报警 IList<ERobAlertReport> ERobAlertReportList = alertReportBase.ReportSearch<ERobAlertReport>(new List<Guid>() { vehicleCode }, beginTime, Convert.ToDateTime(ltHistoryRunInfo[ltHistoryRunInfo.Count - 1].ReportTime)); for (int i = 0, i_Count = ltHistoryRunInfo.Count; i < i_Count; i++) { //判断是否断电报警 var power = EPowerDownAlertReportList.Where(o => o.GPSReportTime == Convert.ToDateTime(ltHistoryRunInfo[i].ReportTime) || (o.GPSReportTime >= Convert.ToDateTime(ltHistoryRunInfo[i].ReportTime) && o.GPSReportTime <= Convert.ToDateTime(ltHistoryRunInfo[i + 1].ReportTime))).ToList(); if (power != null && power.Count>0) { ltHistoryRunInfo[i].IsPoweOff = true; ltHistoryRunInfo[i].Description = power[0].VehiclePosition; } //判断是否劫车报警 var rob = ERobAlertReportList.Where(o => o.GPSReportTime == Convert.ToDateTime(ltHistoryRunInfo[i].ReportTime) || (o.GPSReportTime >= Convert.ToDateTime(ltHistoryRunInfo[i].ReportTime) && o.GPSReportTime <= Convert.ToDateTime(ltHistoryRunInfo[i + 1].ReportTime))).ToList(); if (rob != null && rob.Count>0) { ltHistoryRunInfo[i].IsRob = true; ltHistoryRunInfo[i].Description = rob[0].VehiclePosition; } } }