From ec2ec62fde86543570796c7ef617211e44515890 Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Fri, 9 Aug 2024 17:17:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DOAN.Service/MES/group/GroupScheduleService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DOAN.Service/MES/group/GroupScheduleService.cs b/DOAN.Service/MES/group/GroupScheduleService.cs index cd198be..2d5dbef 100644 --- a/DOAN.Service/MES/group/GroupScheduleService.cs +++ b/DOAN.Service/MES/group/GroupScheduleService.cs @@ -149,7 +149,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(parm); From ee715a49a670824fcd5ecad0f5c0bbb25d9556f4 Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Mon, 12 Aug 2024 08:57:18 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=88=E4=BB=BD?= =?UTF-8?q?=E7=9A=84=E6=8E=92=E7=8F=AD=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MES/group/GroupScheduleController.cs | 37 ++++++++++++++++++ .../MES/group/GroupScheduleService.cs | 38 +++++++++++++++++++ .../group/IService/IGroupScheduleService.cs | 2 + 3 files changed, 77 insertions(+) diff --git a/DOAN.Admin.WebApi/Controllers/MES/group/GroupScheduleController.cs b/DOAN.Admin.WebApi/Controllers/MES/group/GroupScheduleController.cs index 7c5aecb..2add882 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/group/GroupScheduleController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/group/GroupScheduleController.cs @@ -208,7 +208,44 @@ namespace DOAN.Admin.WebApi.Controllers return SUCCESS(response); } + //TODO 获取月份的排班情况 + /// + /// 获取月份的排班情况 + /// + /// + /// <日期,排组的数量> + [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); + + } diff --git a/DOAN.Service/MES/group/GroupScheduleService.cs b/DOAN.Service/MES/group/GroupScheduleService.cs index 2d5dbef..0d215e2 100644 --- a/DOAN.Service/MES/group/GroupScheduleService.cs +++ b/DOAN.Service/MES/group/GroupScheduleService.cs @@ -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 { @@ -173,6 +174,43 @@ namespace DOAN.Service.Business .Where(it => it.FkPersonId == person_id) .ExecuteCommand(); } + /// + /// 获取本月排班情况 + /// + /// + /// + public Dictionary GetMonthScheduleResult(int HandleMonth) + { + Dictionary results = new Dictionary(); + //获取月份所有日期 + List GetDatesOfMonth(int month) + { + int year = DateTime.Now.Year; // 获取当前年份 + List dates = new List(); + 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 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; + + } } } \ No newline at end of file diff --git a/DOAN.Service/MES/group/IService/IGroupScheduleService.cs b/DOAN.Service/MES/group/IService/IGroupScheduleService.cs index 451c224..dae0107 100644 --- a/DOAN.Service/MES/group/IService/IGroupScheduleService.cs +++ b/DOAN.Service/MES/group/IService/IGroupScheduleService.cs @@ -25,5 +25,7 @@ namespace DOAN.Service.group.IService PagedInfo 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 GetMonthScheduleResult(int HandleMonth) } }