public BsTableDataSource <CountryPersonServiceModel> GetCountryPersonList1(GetCountryPersonList1 request) { using (var db = DbFactory.Open()) { if (string.IsNullOrEmpty(request.adcd)) { throw new Exception("adcd异常!"); } var bulider = db.From <CountryPerson>(); if (!string.IsNullOrEmpty(request.adcd)) { bulider.Where(x => x.adcd == request.adcd); } #region if (!string.IsNullOrEmpty(request.post)) { bulider.Where(w => w.Position.Contains(request.post)); } if (!string.IsNullOrEmpty(request.position)) { bulider.Where(w => w.Post.Contains(request.position)); } if (!string.IsNullOrEmpty(request.name)) { bulider.Where(w => w.UserName.Contains(request.name)); } #endregion var _year = request.year == null ? DateTime.Now.Year : request.year; bulider.And(x => x.Year == _year); bulider.Limit(0, 9999); //var PageSize = request.PageSize == 0 ? 15 : request.PageSize; //var PageIndex = request.PageIndex == 0 ? 0 : (request.PageIndex) * PageSize; //bulider.Limit(PageIndex, PageSize); var list = db.Select <CountryPersonServiceModel>(bulider); var newlist = list.Select(w => w.UserName).Distinct().ToList(); List <CountryPersonServiceModel> rlist = new List <CountryPersonServiceModel>(); var city = db.Single <ADCDInfo>(w => w.adcd == request.adcd.Substring(0, 4) + "00000000000"); newlist.ForEach(w => { var f = list.Where(x => x.UserName == w).ToList(); var newpost = ""; var phones = ""; var gwid = 0; f.ForEach(y => { newpost += y.Position + "_" + y.Post + ";"; phones += y.Phone + ";"; if (y.Position == "指挥") { gwid = 1; } if (y.Position == "副指挥") { gwid = 2; } if (y.Position == "成员") { gwid = 3; } if (y.Position == "综合组") { gwid = 4; } if (y.Position == "监测预警组") { gwid = 5; } if (y.Position == "人员转移组") { gwid = 6; } if (y.Position == "抢险救援组") { gwid = 7; } if (y.Position == "宣传报道组") { gwid = 8; } if (y.Position == "后勤服务组") { gwid = 9; } }); var rphones = phones.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Distinct(); CountryPersonServiceModel cpsm = new CountryPersonServiceModel() { UserName = w, Id = f.FirstOrDefault().Id, Phone = string.Join(";", rphones), Post = newpost.TrimEnd(';'), adcd = f.FirstOrDefault().adcd, adnmparent = city.adnm, Gwid = gwid, Position = f.FirstOrDefault().Position }; var builder1 = db.From <SpotCheck>(); builder1.Where(y => y.adcd == request.adcd && y.year == _year && y.bycheckman == cpsm.UserName && y.bycheckphone == cpsm.Phone).OrderByDescending(o => o.checktime); //分页 var fbycheckman = db.Single(builder1); if (fbycheckman != null) { cpsm.checkresult = fbycheckman.checkstatus + "(" + Convert.ToDateTime(fbycheckman.checktime).ToString("yyyy-MM-dd HH:mm:ss") + ")"; } else { cpsm.checkresult = "-"; } rlist.Add(cpsm); }); return(new BsTableDataSource <CountryPersonServiceModel> { rows = rlist, total = rlist.Count() }); } }
public BsTableDataSource <CountryPersonServiceModel> Get(GetCountryPersonList1 request) { return(CountryPerson.GetCountryPersonList1(request)); }