排班修改

This commit is contained in:
qianhao.xu 2024-08-12 15:05:58 +08:00
parent a2893c4550
commit b3d3ede4b6
3 changed files with 32 additions and 17 deletions

View File

@ -252,7 +252,6 @@ namespace DOAN.Admin.WebApi.Controllers
/// </summary>
/// <param name="date">要排的日期</param>
/// <returns>-2 已有数据不可复制 -1 前一天无数据无法复制 >=1 复制的数量</returns>
///
[HttpGet("CopyGroup")]
public IActionResult CopyGroup(DateTime date)
{

View File

@ -186,7 +186,7 @@ namespace DOAN.Service.Business
//获取月份所有日期
List<DateTime> GetDatesOfMonth(int year, int month)
{
List<DateTime> dates = new List<DateTime>();
DateTime firstDayOfMonth = new DateTime(year, month, 1);
@ -199,7 +199,7 @@ namespace DOAN.Service.Business
return dates;
}
List<DateTime> All_Dates = GetDatesOfMonth(year,HandleMonth);
List<DateTime> All_Dates = GetDatesOfMonth(year, HandleMonth);
foreach (DateTime date in All_Dates)
{
@ -225,19 +225,19 @@ namespace DOAN.Service.Business
List<GroupSchedule> date_schedules = Queryable().Where(it => it.ScheduleDate == PreDate).ToList();
if(date_schedules==null|| date_schedules.Count==0) { return -1; }
bool isExist= Queryable().Where(it => it.ScheduleDate == date).Any();
if (date_schedules == null || date_schedules.Count == 0) { return -1; }
bool isExist = Queryable().Where(it => it.ScheduleDate == date).Any();
if (isExist) { return -2; }
//TODO copy 班组人员
string[] collects = date_schedules.Select(it => it.Id).ToArray();
List<GroupRelPersonGroup> Copy_groups = Context.Queryable<GroupRelPersonGroup>().Where(it => collects.Contains(it.FkGroupId)).ToList();
List<GroupRelPersonGroup> inserts_GroupRelPersonGroup = new List<GroupRelPersonGroup>();
foreach (var group in date_schedules)
{
group.ScheduleDate = date;
group.CreatedBy = CreatedBy;
group.CreatedTime = DateTime.Now;
@ -245,23 +245,39 @@ namespace DOAN.Service.Business
group.UpdatedTime = DateTime.Now;
//组绑定 的人员
List<GroupRelPersonGroup> Copy_group_presons = Copy_groups.Where(it => it.FkGroupId == group.Id).ToList();
group.Id = XueHua;
foreach (var person in Copy_group_presons)
if (Copy_group_presons.Count > 0)
{
person.FkGroupId = group.Id;
person.CreatedBy = group.CreatedBy;
person.CreatedTime = group.CreatedTime;
group.Id = XueHua;
foreach (var person in Copy_group_presons)
{
person.FkGroupId = group.Id;
person.CreatedBy = group.CreatedBy;
person.CreatedTime = group.CreatedTime;
}
string[] person_id_array = Copy_group_presons.Select(it => it.FkPersonId).ToArray();
string[] Resigneds = Context.Queryable<GroupPerson>().Where(it => person_id_array.Contains(it.Id))
.Where(it => it.Status == 0)
.Select(it => it.Id)
.ToArray();
if (Resigneds.Length > 0)
{
Copy_group_presons = Copy_group_presons.Where(it => !Resigneds.Contains(it.FkPersonId)).ToList();
}
inserts_GroupRelPersonGroup.AddRange(Copy_group_presons);
}
inserts_GroupRelPersonGroup.AddRange(Copy_group_presons);
}
UseTran2(() =>
{
// 删除原有数据
// Context.Deleteable(date_schedules).ExecuteCommand();
// Context.Deleteable<GroupRelPersonGroup>().Where(it => collects.Contains(it.FkGroupId)).ExecuteCommand();
// Context.Deleteable(date_schedules).ExecuteCommand();
// Context.Deleteable<GroupRelPersonGroup>().Where(it => collects.Contains(it.FkGroupId)).ExecuteCommand();
result = Context.Insertable(date_schedules).ExecuteCommand();
Context.Insertable(inserts_GroupRelPersonGroup).ExecuteCommand();

View File

@ -26,7 +26,7 @@ namespace DOAN.Service.group.IService
int GroupAddPerson(string group_schedule_id, string person_id, string CreatedBy);
int GroupRemovePerson(string group_schedule_id, string person_id);
List<SchedulingSituation> GetMonthScheduleResult(int year,int HandleMonth);
List<SchedulingSituation> GetMonthScheduleResult(int year,int HandleMonth);
int CopyPreDaySchedule(DateTime date, string CreatedBy);
}