public IEnumerable <OfficerAttendanceTrackModel> OfficerTracks(long stime, long etime, params string[] officerIds) { var trackHandler = new OfficerTrackHandle(Repository); var stHandler = new StationHandle(Repository); var ids = officerIds.Where(t => !string.IsNullOrWhiteSpace(t)).ToArray(); var noDel = (short)DeleteStatus.No; var query = from track in trackHandler.All(null) join sta in stHandler.All(t => t.IsDel == noDel) on track.SiteId equals sta.SiteId into stas from site in stas.DefaultIfEmpty(new Station { }) select new { track = track, site = site }; query = query.Where(t => t.track.UpTime >= stime && t.track.UpTime <= etime); if (ids.Length > 0) { query = query.Where(t => ids.Any(x => t.track.OfficerId == x)); } var items = query.OrderBy(t => t.track.OfficerId).OrderByDescending(t => t.track.UpTime).ToArray() .Select(t => new OfficerAttendanceTrackModel { station = t.site, track = t.track }); return(items); }
public IEnumerable <StationModel> Page(string orgId, string siteId, int page, int size, out int count) { var staHandler = new StationHandle(Repository); var orgHandler = new OrganizationHandle(Repository); var noDel = (short)DeleteStatus.No; var query = from sta in staHandler.All(t => t.IsDel == noDel) join orgitem in orgHandler.All(t => t.IsDel == noDel) on sta.OrgId equals orgitem.Id into orgs from org in orgs.DefaultIfEmpty(new Organization { }) select new { sta = sta, org = org }; if (!string.IsNullOrWhiteSpace(siteId)) { query = query.Where(t => t.sta.SiteId.Contains(siteId)); } if (string.IsNullOrWhiteSpace(orgId) && !User.IsSupperAdministrator) { orgId = User.Organization.Id; } if (!string.IsNullOrEmpty(orgId)) { query = query.Where(t => t.sta.OrgId == orgId); } count = query.Count(); var skipCount = (page - 1) * size; var items = query.Skip(skipCount).Take(size).ToArray() .Select(t => new StationModel { org = t.org, station = t.sta }); return(items); }
// 矩形选择 public IEnumerable <OfficerDispatchQueryModel> RectangleSelect(double x1, double y1, double x2, double y2) { var lcHandler = new OfficerLocationHandle(Repository); var ocHandler = new OfficerHandle(Repository); var orgHandler = new OrganizationHandle(Repository); var ptHandler = new PoliceTypeHandle(Repository); var stHandler = new StationHandle(Repository); var noDel = (short)DeleteStatus.No; var query = from lc in lcHandler.All(null) join oc in ocHandler.All(t => t.IsDel == noDel) on lc.OfficerId equals oc.Id join org in orgHandler.All(t => t.IsDel == noDel) on oc.OrgId equals org.Id join ptp in ptHandler.All(t => t.IsDel == noDel) on oc.PtId equals ptp.Id join sts in stHandler.All(t => t.IsDel == noDel) on lc.SiteId equals sts.SiteId into stas from st in stas.DefaultIfEmpty(new Station { }) select new { location = lc, officer = oc, org = org, ptp = ptp, station = st }; // 此处进一步查询 if (!User.IsSupperAdministrator) { var orgId = User.Organization.Id; query = query.Where(t => t.org.Id == orgId); } var xmin = x1; var xmax = x2; if (x1 > x2) { xmax = x1; xmin = x2; } var ymin = y1; var ymax = y2; if (y1 > y2) { ymin = y2; ymax = y1; } var items = query.OrderByDescending(t => t.location.UpTime).ToArray() .Select(t => { OfficerDispatchQueryModel m = null; if (string.IsNullOrWhiteSpace(t.station.SiteId) || (t.station.Lon >= xmin && t.station.Lon <= xmax && t.station.Lat >= ymin && t.station.Lat <= ymax) ) { m = new OfficerDispatchQueryModel { location = t.location, officer = t.officer, org = t.org, ptp = t.ptp, station = t.station }; } return(m); }).Where(t => t != null).ToArray(); return(items); }