public IEnumerable <AttendanceModel> Page(string pattern, int page, int size, out int count) { var officerHandler = new OfficerHandle(Repository); var atdHandler = new OfficerAttendanceHandle(Repository); var orgHandler = new OrganizationHandle(Repository); var noDel = (short)DeleteStatus.No; var query = from atd in atdHandler.All(null) join ocr in officerHandler.All(t => t.IsDel == noDel) on atd.OfficerId equals ocr.Id join org in orgHandler.All(t => t.IsDel == noDel) on ocr.OrgId equals org.Id select new { officer = ocr, attendance = atd, org = org }; if (!string.IsNullOrWhiteSpace(pattern)) { query = query.Where(t => t.officer.Name.Contains(pattern) || t.officer.IdentyCode.Contains(pattern)); } if (!User.IsSupperAdministrator) { var orgId = User.Organization.Id; query = query.Where(t => t.officer.OrgId == orgId); } count = query.Count(); var skipCount = (page - 1) * size; var items = query.OrderByDescending(t => t.attendance.STime).Skip(skipCount).Take(size).ToArray() .Select(t => new AttendanceModel { attendance = t.attendance, officer = t.officer, org = t.org }); return(items); }
public IEnumerable <OfficerModel> Page(string orgId, string ptId, string name, string code, int page, int size, out int count) { using (var officerHandler = new OfficerHandle(Repository)) using (var userHandler = new UserHandle(Repository)) using (var orgHandler = new OrganizationHandle(Repository)) using (var ptpHandler = new PoliceTypeHandle(Repository)) { var noDel = (short)DeleteStatus.No; var query = from officer in officerHandler.All(t => t.IsDel == noDel) join useritem in userHandler.All(t => t.IsDel == noDel) on officer.UserId equals useritem.Id into usrs from usr in usrs.DefaultIfEmpty(new User { }) join org in orgHandler.All(t => t.IsDel == noDel) on officer.OrgId equals org.Id join ptp in ptpHandler.All(t => t.IsDel == noDel) on officer.PtId equals ptp.Id select new { officer = officer, usr = usr, org = org, ptp = ptp }; if (!string.IsNullOrWhiteSpace(name)) { query = query.Where(t => t.officer.Name.Contains(name)); } if (!string.IsNullOrWhiteSpace(code)) { query = query.Where(t => t.officer.IdentyCode.Contains(code)); } if (!string.IsNullOrWhiteSpace(ptId)) { query = query.Where(t => t.officer.PtId == ptId); } if (!string.IsNullOrWhiteSpace(orgId)) { query = query.Where(t => t.officer.OrgId == orgId); } if (string.IsNullOrWhiteSpace(orgId) && !User.IsSupperAdministrator) { orgId = User.Organization.Id; query = query.Where(t => t.officer.OrgId == orgId); } count = query.Count(); var skipCount = (page - 1) * size; var items = query.OrderByDescending(t => t.officer.SignupDate).Skip(skipCount).Take(size).ToArray() .Select(t => new OfficerModel { officer = t.officer, org = t.org, ptp = t.ptp, user = t.usr }); return(items); } }
public IEnumerable <CabinetModel> Page(string orgId, string name, int page, int size, out int count) { using (var cabinetHandler = new CabinetHandle(Repository)) using (var orgHandler = new OrganizationHandle(Repository)) using (var officerHandler = new OfficerHandle(Repository)) using (var siteHandler = new SiteHandle(Repository)) { var noDel = (short)DeleteStatus.No; var query = from cab in cabinetHandler.All(t => t.IsDel == noDel) join org in orgHandler.All(t => t.IsDel == noDel) on cab.OrgId equals org.Id join officer in officerHandler.All(t => t.IsDel == noDel) on cab.OfficerId equals officer.Id into officers from off in officers.DefaultIfEmpty(new Officer { }) join site in siteHandler.All(t => t.IsDel == noDel) on cab.StationId equals site.Id into sites from sta in sites.DefaultIfEmpty(new Station { }) select new { cab = cab, org = org, officer = off, sta = sta }; if (!string.IsNullOrWhiteSpace(name)) { query = query.Where(t => t.cab.Name.Contains(name)); } if (!string.IsNullOrWhiteSpace(orgId)) { query = query.Where(t => t.cab.OrgId == orgId); } if (string.IsNullOrWhiteSpace(orgId) && !User.IsSupperAdministrator) { var code = User.Organization.Code; query = query.Where(t => t.org.Code.StartsWith(code)); } count = query.Count(); var skipCount = (page - 1) * size; var items = query.OrderBy(t => t.sta.OrgId).Skip(skipCount).Take(size).ToArray() .Select(t => new CabinetModel { officer = t.officer, org = t.org, cabinet = t.cab }); return(items); } }
// 警械相关处理 // 1,获取标签绑定的警械信息 // 2,警械当前位置信息处理 // 3,保存警械移动轨迹 // 4,其它 private TagBindModel ExecuteEquipment(UpLoadDataPackage data) { var eqHandler = new EquipmentHandle(Repository); var offHandler = new OfficerHandle(Repository); var noDel = (short)DeleteStatus.No; var query = from eqt in eqHandler.All(t => t.IsDel == noDel) join officer in offHandler.All(t => t.IsDel == noDel) on eqt.OfficerId equals officer.Id select new { eqt = eqt, officer = officer }; var tagId = data.TagId; var m = query.Where(t => t.eqt.TagId == tagId).FirstOrDefault(); if (null != m) { var bdm = new TagBindModel { Equipment = m.eqt, Officer = m.officer }; ExecuteEquipmentLocation(data, bdm); return(bdm); } return(null); }
public IEnumerable <OfficerAttendanceQueryModel> AttendanceSelect(string pattern, DateTime stime, DateTime etime) { var ocrHandler = new OfficerHandle(Repository); var orgHandler = new OrganizationHandle(Repository); var ptHandler = new PoliceTypeHandle(Repository); var atdHandler = new OfficerAttendanceHandle(Repository); var noDel = (short)DeleteStatus.No; var query = from atd in atdHandler.All(null) join ocr in ocrHandler.All(t => t.IsDel == noDel) on atd.OfficerId equals ocr.Id join org in orgHandler.All(t => t.IsDel == noDel) on ocr.OrgId equals org.Id join ptp in ptHandler.All(t => t.IsDel == noDel) on ocr.PtId equals ptp.Id select new { atd = atd, ocr = ocr, org = org, ptp = ptp }; if (!string.IsNullOrWhiteSpace(pattern)) { query = query.Where(t => t.ocr.Name.Contains(pattern) || t.ocr.IdentyCode.Contains(pattern)); } if (!User.IsSupperAdministrator) { var orgId = User.Organization.Id; query = query.Where(t => t.org.Id == orgId); } var items = query.OrderBy(t => t.ocr.Id).OrderByDescending(t => t.atd.STime).ToArray(); if (0 == items.Count()) { return(new OfficerAttendanceQueryModel[0]); } var sttime = items.Select(t => t.atd.STime).Min(); var ettime = DateTime.Now.ToUnixTime(); if (!items.Any(t => t.atd.ETime == 0L)) { ettime = items.Select(t => t.atd.ETime).Max(); } var ids = items.Select(t => t.atd.OfficerId).Distinct().ToArray(); var tracks = OfficerTracks(sttime, ettime, ids); var data = items.Select(t => { var m = new OfficerAttendanceQueryModel { atd = t.atd, officer = t.ocr, org = t.org, ptp = t.ptp }; var sdtime = t.atd.STime; var edtime = ettime; if (t.atd.ETime != 0L) { edtime = t.atd.ETime; } m.tracks = tracks.Where(x => x.track.OfficerId == t.atd.OfficerId && x.track.UpTime >= sdtime && x.track.UpTime <= edtime); return(m); }); return(data); }
// 矩形选择 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); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); Handler.Dispose(); Handler = null; }
public OfficerModule(UserInfo user) : base(user) { Handler = new OfficerHandle(Repository); }
/// <summary> /// 使用用户名和密码获取用户内容 /// </summary> /// <param name="userId">用户名</param> /// <param name="passwd">密码</param> /// <param name="user">返回的用户信息</param> /// <returns></returns> public AccountLoginStatus Signin(string userId, string passwd, out UserInfo user) { var userHandler = new UserHandle(Repository); var roleHandler = new RoleHandle(Repository); var officerHandler = new OfficerHandle(Repository); var orgHandler = new OrganizationHandle(Repository); var featureHandler = new FeatureHandle(Repository); var menuHandler = new MenuHandle(Repository); var isDel = (short)DeleteStatus.No; var query = from usr in userHandler.All(t => t.Account == userId && t.IsDel == isDel) join orgitem in orgHandler.All(t => t.IsDel == isDel) on usr.OrgId equals orgitem.Id into orgarr from org in orgarr.DefaultIfEmpty(new data.entity.Organization()) join officeritem in officerHandler.All(t => t.IsDel == isDel) on usr.Id equals officeritem.UserId into officers from officer in officers.DefaultIfEmpty(new data.entity.Officer()) join roleitem in roleHandler.All(t => t.IsDel == isDel) on usr.RoleId equals roleitem.Id into roles from role in roles.DefaultIfEmpty(new data.entity.Role()) join fitem in featureHandler.All(t => t.IsDel == isDel) on role.Id equals fitem.RoleId into farr from feature in farr.DefaultIfEmpty(new data.entity.Feature()) join mitem in menuHandler.All(t => t.IsDel == isDel) on feature.MenuId equals mitem.Id into marr from menu in marr.DefaultIfEmpty(new data.entity.Menu()) select new { usr = usr, org = org, officer = officer, role = role, feature = feature, menu = menu }; user = query .GroupBy(t => new { usr = t.usr, org = t.org, officer = t.officer, role = t.role }) .ToArray() .Select(t => new UserInfo { User = t.Key.usr, Officer = t.Key.officer, Organization = t.Key.org, Role = t.Key.role, Features = t.Select(x => x.feature).Where(x => !string.IsNullOrWhiteSpace(x.MenuId)), Menus = t.Select(x => x.menu).Where(x => !string.IsNullOrWhiteSpace(x.Title)) }) .FirstOrDefault(); if (user == null) { return(AccountLoginStatus.UserNoExist); } if (user.User.Passwd != EscapePassword(userId, passwd)) { return(AccountLoginStatus.PasswordError); } if (user.User.Status == (int)AccountStatus.Exception) { return(AccountLoginStatus.ExceptionAccount); } if (user.User.Status == (int)AccountStatus.Locked) { return(AccountLoginStatus.LockedAccount); } user.User.SigninStatus = (short)AccountSigninStatus.Online; if (null == userHandler.Modify(user.User, true)) { return(AccountLoginStatus.Error); } return(AccountLoginStatus.Success); }
public IEnumerable <EquipmentModel> Page(string orgId, string storageId, string cabinetId, string tagCode, string factorCode, short dataType, int page, int size, out int count) { using (var eqtHandler = new EquipmentHandle(Repository)) using (var cateHandler = new EqtTypeHandle(Repository)) using (var stgHandler = new StorageHandle(Repository)) using (var cabHandler = new CabinetHandle(Repository)) using (var orgHandler = new OrganizationHandle(Repository)) using (var offHandler = new OfficerHandle(Repository)) { var noDel = (short)DeleteStatus.No; var query = from eqt in eqtHandler.All(t => t.IsDel == noDel) join org in orgHandler.All(t => t.IsDel == noDel) on eqt.OrgId equals org.Id join cate in cateHandler.All(t => t.IsDel == noDel) on eqt.CateId equals cate.Id join stg in stgHandler.All(t => t.IsDel == noDel) on eqt.LibId equals stg.Id join cabitem in cabHandler.All(t => t.IsDel == noDel) on eqt.CabId equals cabitem.Id into cabs from cab in cabs.DefaultIfEmpty(new Cabinet { }) join offitem in offHandler.All(t => t.IsDel == noDel) on eqt.OfficerId equals offitem.Id into offs from off in offs.DefaultIfEmpty(new Officer { }) select new { eqt = eqt, org = org, cate = cate, stg = stg, cab = cab, officer = off }; if (!string.IsNullOrWhiteSpace(storageId)) { query = query.Where(t => t.eqt.LibId == storageId); } if (!string.IsNullOrWhiteSpace(cabinetId)) { query = query.Where(t => t.eqt.CabId == cabinetId); } if (!string.IsNullOrWhiteSpace(tagCode)) { query = query.Where(t => t.eqt.TagId.Contains(tagCode)); } if (!string.IsNullOrWhiteSpace(factorCode)) { query = query.Where(t => t.eqt.FactorCode.Contains(factorCode)); } if (!string.IsNullOrWhiteSpace(orgId)) { query = query.Where(t => t.eqt.OrgId == orgId); } if (string.IsNullOrWhiteSpace(orgId) && !User.IsSupperAdministrator) { orgId = User.Organization.Id; query = query.Where(t => t.eqt.OrgId == orgId); } var dispatchStatus = 0; // 布控中 if (dataType == (short)QueryEqtDataType.Dispatching) { dispatchStatus = (short)DispatchedStatus.Doing; query = query.Where(t => t.eqt.Dispatched == dispatchStatus); } // 撤控 if (dataType == (short)QueryEqtDataType.Dispatched) { dispatchStatus = (short)DispatchedStatus.Done; query = query.Where(t => t.eqt.Dispatched == dispatchStatus); } var now = DateTime.Now.ToUnixTime(); // 已过期 if (dataType == (short)QueryEqtDataType.Expired) { query = query.Where(t => t.eqt.ExpiredTime <= now); } // 即将过期 if (dataType == (short)QueryEqtDataType.PreExpired) { var preDate = DateTime.Now.AddDays(PreExpiredInterval).ToUnixTime(); query = query.Where(t => t.eqt.ExpiredTime >= preDate && t.eqt.ExpiredTime < now); } // 尚未过期 if (dataType == (short)QueryEqtDataType.NoExpired) { query = query.Where(t => t.eqt.ExpiredTime >= now); } // 绑定警员 if (dataType == (short)QueryEqtDataType.Bound) { query = query.Where(t => t.eqt.OfficerId != null); } // 已损坏 if (dataType == (short)QueryEqtDataType.Destoried) { var sta = (short)EquipmentStatus.Destory; query = query.Where(t => t.eqt.Status == sta); } // 低电量 if (dataType == (short)QueryEqtDataType.LowPower) { query = query.Where(t => t.eqt.Power <= LowPowerFlag); } count = query.Count(); var skipCount = (page - 1) * size; var items = query.OrderByDescending(t => t.eqt.InputTime).Skip(skipCount).Take(size).ToArray() .Select(t => new EquipmentModel { cabinet = t.cab, category = t.cate, equipment = t.eqt, officer = t.officer, org = t.org, storage = t.stg }); return(items); } }