public void updateUserSalary(string localYear, string localMonth) { List <UserSalary> ListUserSalary = this.GetData(localYear, localMonth); //先删除表中的记录 //List<UserWorkDayOrNight> User foreach (UserSalary s in ListUserSalary) { this.Delete(s); } //再统计客服的排班情况,最后更新值班奖金 //先插入客服的数据,再更新值班数量 UserRepository UserRepo = new UserRepository(); List <User> ListUser = UserRepo.GetAll() .Where(p => p.Type.ID.ToString().Trim() == "1") .ToList(); PersonShopGroupPBsRepository PersonShopGroupPBRepo = new PersonShopGroupPBsRepository(); foreach (User u in ListUser) { UserSalary LocalUserSalary = new UserSalary(); LocalUserSalary.User = u; LocalUserSalary.Year = Convert.ToInt32(localYear); LocalUserSalary.Month = Convert.ToInt32(localMonth); ////统计值班数量 //取出排班表的信息,然后统计白班晚班的信息 List <PersonShopGroupPBs> listPersonShopGroupPBs = PersonShopGroupPBRepo.GetListPersonShopGroupPBByUser(u, localYear, localMonth); int DayNum = 0; int NightNum = 0; foreach (var d in listPersonShopGroupPBs) { if (d._ShopGroups.WorkDayOrNight == DayOrNight.白班) { DayNum = DayNum + 1; } if (d._ShopGroups.WorkDayOrNight == DayOrNight.晚班) { NightNum = NightNum + 1; } } LocalUserSalary.DayNum = DayNum; LocalUserSalary.NightNum = NightNum; LocalUserSalary.TotalNum = LocalUserSalary.DayNum + LocalUserSalary.NightNum; LocalUserSalary.zhiBanSalary = LocalUserSalary.TotalNum * u.UserEnmLevel.UserLevelSalary; LocalUserSalary.TotalSalary = LocalUserSalary.zhiBanSalary; this.Save(LocalUserSalary); } }
//根据班组排班表中的内容,更新PersonPB里的数据 public void PaiBan(DateTime localStartDate, DateTime localEndDate, Kf_DepartMent kf_DepartMent) { List <PersonPB> listPersonPB = this.GetAll() .Where(it => it.UserWorkDate.WorkDate.Date <= localEndDate.Date) .Where(it => it.UserWorkDate.WorkDate.Date >= localStartDate.Date) .WhereIf(it => it._Shop._Kf_DepartMent == kf_DepartMent, kf_DepartMent.ID != 1) .ToList(); foreach (var PB in listPersonPB) { this.Delete(PB); } ShopGroupDetailRepository shopGroupDetailRepo = new ShopGroupDetailRepository();// PersonShopGroupPBsRepository personShopGroupPBsRepo = new PersonShopGroupPBsRepository(); List <PersonShopGroupPBs> listPersonShopGroupPBs = personShopGroupPBsRepo.GetAll() .Where(it => it.UserWorkDate.WorkDate.Date <= localEndDate.Date) .Where(it => it.UserWorkDate.WorkDate.Date >= localStartDate.Date) .WhereIf(it => it._ShopGroups._Kf_DepartMent == kf_DepartMent, kf_DepartMent.ID != 1) .ToList(); List <ShopGroupDetails> listShopGroupDetails = shopGroupDetailRepo.GetAll() .WhereIf(it => it._Shop._Kf_DepartMent == kf_DepartMent, kf_DepartMent.ID != 1) .ToList(); foreach (var personShopGroupPBs in listPersonShopGroupPBs) { List <Shop> listShop = listShopGroupDetails .Where(it => it._ShopGroup == personShopGroupPBs._ShopGroups) .Select(it => it._Shop) .ToList(); foreach (var shop in listShop) { PersonPB pb = new PersonPB(); pb._Shop = shop; pb._user = personShopGroupPBs._User; pb.UserWorkDate = personShopGroupPBs.UserWorkDate; pb.WorkDayOrNight = personShopGroupPBs._ShopGroups.WorkDayOrNight; this.Save(pb); } } }
public void updatePersonPBData(string Year, string Month, Kf_DepartMent kf_DepartMent) { PersonShopGroupPBsRepository PersonShopGroupPBRepo = new PersonShopGroupPBsRepository(); List <PersonShopGroupPBs> listPersonShopGroupPBs = PersonShopGroupPBRepo.GetListPersonShopGroupPB(Year, Month, kf_DepartMent); UserRepository UserRepo = new UserRepository(); List <User> ListUser = UserRepo.GetAll() .Where(p => p.Type.ID.ToString().Trim() == "1") .ToList(); List <PersonPBData> listPersonPBData = this.GetData(Year, Month, kf_DepartMent); foreach (var PersonPBData in listPersonPBData) { this.Delete(PersonPBData); } var distinctWorkDate = from y in listPersonShopGroupPBs group y by new { y.UserWorkDate }; foreach (var workDate in distinctWorkDate) { foreach (var user in ListUser) { PersonPBData PersonPBData = new PersonPBData(); PersonPBData.UserWorkDate = workDate.Key.UserWorkDate; PersonPBData._user = user; PersonPBData.Year = Year.ToInt(); PersonPBData.Month = Month.ToInt(); PersonPBData.UpdateTime = System.DateTime.Now; //如果能查到是白班,那么就是白班,如果能查到是晚班,那么就是晚班,如果白班和白班都查到了,那么是全班,如果都没查到,那么是休班. List <PersonShopGroupPBs> listLocalPersonShopGroupPBs = listPersonShopGroupPBs .Where(it => it._User == user) .Where(it => it.UserWorkDate == workDate.Key.UserWorkDate) .ToList(); if (listLocalPersonShopGroupPBs.Count == 0) { PersonPBData.WorkDayOrNight = DayOrNight.休班; } else if (listLocalPersonShopGroupPBs.Count == 1) { if (listLocalPersonShopGroupPBs.FirstOrDefault()._ShopGroups.WorkDayOrNight == DayOrNight.白班) { PersonPBData.WorkDayOrNight = DayOrNight.白班; } if (listLocalPersonShopGroupPBs.FirstOrDefault()._ShopGroups.WorkDayOrNight == DayOrNight.晚班) { PersonPBData.WorkDayOrNight = DayOrNight.晚班; } } else { PersonPBData.WorkDayOrNight = DayOrNight.全天; } PersonPBData.DayNumMonth = 0; PersonPBData.NightNumMonth = 0; PersonPBData.RestNumMonth = 0; this.Save(PersonPBData); } } List <PersonPBData> listPersonPBDataNew = this.GetData(Year, Month, kf_DepartMent); foreach (var User in ListUser) { List <PersonPBData> listLocalPersonPBDataNew = listPersonPBDataNew.Where(it => it._user == User).ToList(); int intUserDayNumMonth = 0; int intUserNightNumMonth = 0; int intUserRestNumMonth = 0; foreach (var personPBData in listLocalPersonPBDataNew) { if (personPBData.WorkDayOrNight == DayOrNight.休班) { intUserRestNumMonth = intUserRestNumMonth + 1; } if (personPBData.WorkDayOrNight == DayOrNight.全天) { intUserDayNumMonth = intUserDayNumMonth + 1; intUserNightNumMonth = intUserNightNumMonth + 1; } if (personPBData.WorkDayOrNight == DayOrNight.白班) { intUserDayNumMonth = intUserDayNumMonth + 1; } if (personPBData.WorkDayOrNight == DayOrNight.晚班) { intUserNightNumMonth = intUserNightNumMonth + 1; } } foreach (var personPBData in listLocalPersonPBDataNew) { //PersonPBData pbData = this.GetByDatabaseID(personPBData.ID); personPBData.DayNumMonth = intUserDayNumMonth; personPBData.NightNumMonth = intUserNightNumMonth; personPBData.RestNumMonth = intUserRestNumMonth; this.Save(personPBData); } } }