This commit is contained in:
赵正易 2024-08-12 09:03:29 +08:00
commit 06a701a113
3 changed files with 78 additions and 1 deletions

View File

@ -208,7 +208,44 @@ namespace DOAN.Admin.WebApi.Controllers
return SUCCESS(response);
}
//TODO 获取月份的排班情况
/// <summary>
/// 获取月份的排班情况
/// </summary>
/// <param name="month_str"></param>
/// <returns> <日期,排组的数量></returns>
[HttpGet("month_schedule_result")]
public IActionResult GetMonthScheduleResult(string month_str)
{
int HandleMonth = 0;
switch (month_str)
{
case "today":
HandleMonth = DateTime.Now.Month;
break;
case "prev-month":
HandleMonth = DateTime.Now.Month - 1;
if (HandleMonth == 0)
{
HandleMonth = 12; // 如果月份为0则应该是12月
}
break;
case "next-month":
HandleMonth = DateTime.Now.Month + 1;
if (HandleMonth == 13)
{
HandleMonth = 1; // 如果月份为13则应该是1月
}
break;
default:
HandleMonth = -1; // 表示无效的输入
break;
}
var response= _GroupScheduleService.GetMonthScheduleResult(HandleMonth);
return SUCCESS(response);
}

View File

@ -12,6 +12,7 @@ using System.Linq;
using DOAN.Model.MES.group.Dto;
using Aliyun.OSS;
using Microsoft.AspNetCore.Http.HttpResults;
using MimeKit.Tnef;
namespace DOAN.Service.Business
{
@ -149,7 +150,7 @@ namespace DOAN.Service.Business
.Where((q,p)=>q.Status == 1)
.WhereIF(!string.IsNullOrEmpty(parm.WorkNum),(q,p)=>q.WorkNum.Contains(parm.WorkNum))
.WhereIF(!string.IsNullOrEmpty(parm.Name),(q,p)=>q.Name.Contains(parm.Name))
.WhereIF(!string.IsNullOrEmpty(parm.FkPost),(q,p)=>q.FkPost.Contains(parm.FkPost))
.WhereIF(!string.IsNullOrEmpty(parm.FkPost),(q,p)=>q.FkPost==parm.FkPost)
.Select((q, p) => new GroupPersonDto { PostName = p.PostName }, true)
.ToPage<GroupPersonDto, GroupPersonDto>(parm);
@ -173,6 +174,43 @@ namespace DOAN.Service.Business
.Where(it => it.FkPersonId == person_id)
.ExecuteCommand();
}
/// <summary>
/// 获取本月排班情况
/// </summary>
/// <param name="HandleMonth"></param>
/// <returns></returns>
public Dictionary<DateTime, int> GetMonthScheduleResult(int HandleMonth)
{
Dictionary<DateTime, int> results = new Dictionary<DateTime, int>();
//获取月份所有日期
List<DateTime> GetDatesOfMonth(int month)
{
int year = DateTime.Now.Year; // 获取当前年份
List<DateTime> dates = new List<DateTime>();
DateTime firstDayOfMonth = new DateTime(year, month, 1);
DateTime lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); // 获取下个月的第一天,然后减去一天得到本月的最后一天
for (DateTime date = firstDayOfMonth; date <= lastDayOfMonth; date = date.AddDays(1))
{
dates.Add(date);
}
return dates;
}
List<DateTime> All_Dates= GetDatesOfMonth(HandleMonth);
foreach (DateTime date in All_Dates)
{
int counts= Queryable().Where(it=>it.ScheduleDate==date).Count();
results.Add(date, counts);
}
return results;
}
}
}

View File

@ -25,5 +25,7 @@ namespace DOAN.Service.group.IService
PagedInfo<GroupPersonDto> SearchPerson_group_bind_No(GroupScheduleQueryDto3 parm);
int GroupAddPerson(string group_schedule_id, string person_id, string CreatedBy);
int GroupRemovePerson(string group_schedule_id, string person_id);
public Dictionary<DateTime, int> GetMonthScheduleResult(int HandleMonth)
}
}