diff --git a/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderScheduleController.cs b/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderScheduleController.cs index f841158..570a4bc 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderScheduleController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderScheduleController.cs @@ -74,7 +74,6 @@ namespace DOAN.Admin.WebApi.Controllers [HttpPost("update_seleced_station")] public IActionResult UpdateSelectedWorkstation([FromBody] ProRelWorkorderLineBodyDto lineBodyDto) { - var response = _ProWorkorderSchedule.UpdateSelectedWorkstation(lineBodyDto); return SUCCESS(response); } diff --git a/DOAN.Admin.WebApi/Controllers/MES/product/ProweekplanManageController.cs b/DOAN.Admin.WebApi/Controllers/MES/product/ProweekplanManageController.cs index 1f23ba5..668b704 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/product/ProweekplanManageController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/product/ProweekplanManageController.cs @@ -69,7 +69,14 @@ namespace DOAN.WebApi.Controllers.MES.product } + //TODO 更新本周实际装配数量进度 输入年,周,更新计划进度 + [HttpGet("updateactualassemblyprogress")] + public IActionResult UpdateActualAssemblyProgress(int year, int week) + { + int result = _proweekplanManageService.UpdateActualAssemblyProgress(year, week); + return SUCCESS(result); + } diff --git a/DOAN.Admin.WebApi/wwwroot/ImportTemplate/weekplan.xlsx b/DOAN.Admin.WebApi/wwwroot/ImportTemplate/weekplan.xlsx new file mode 100644 index 0000000..44379c0 Binary files /dev/null and b/DOAN.Admin.WebApi/wwwroot/ImportTemplate/weekplan.xlsx differ diff --git a/DOAN.Service/MES/product/IService/IProweekplanManageService.cs b/DOAN.Service/MES/product/IService/IProweekplanManageService.cs index 9da47f6..b47101e 100644 --- a/DOAN.Service/MES/product/IService/IProweekplanManageService.cs +++ b/DOAN.Service/MES/product/IService/IProweekplanManageService.cs @@ -18,5 +18,9 @@ namespace DOAN.Service.MES.product.IService PagedInfo SearchWeekplan(WeekplanQueryDto weekplanQuery); + + int UpdateActualAssemblyProgress(int year, int week); + + } } diff --git a/DOAN.Service/MES/product/ProweekplanManageService.cs b/DOAN.Service/MES/product/ProweekplanManageService.cs index 039b6fe..a107835 100644 --- a/DOAN.Service/MES/product/ProweekplanManageService.cs +++ b/DOAN.Service/MES/product/ProweekplanManageService.cs @@ -44,8 +44,6 @@ namespace DOAN.Service.MES.product IRow secondRow = sheet.GetRow(1); NPOI.SS.UserModel.ICell cell = secondRow.GetCell(0); - - string title = cell.ToString(); //提取括号内的数字 int week = extractWeek(title); @@ -93,6 +91,8 @@ namespace DOAN.Service.MES.product double actual_qty = currentRow.GetCell(8).NumericCellValue; proWeeklyPlan.CompletedQty = (int)actual_qty; proWeeklyPlan.CreatedBy = username; + + // 2025/8/25 星期一 产品类型 // 2025/8/25 ProWeeklyDate proWeeklyDatePlan = new ProWeeklyDate(); @@ -103,7 +103,7 @@ namespace DOAN.Service.MES.product DateTime? MondayDate = sheet.GetRow(2).GetCell(9)?.DateCellValue; proWeeklyDatePlan.WeekDate = (DateTime)MondayDate; proWeeklyPlan.PlanStartDate = (DateTime)MondayDate; - + proWeeklyPlan.PlanYear = MondayDate.Value.Year; // 星期一名称 string MondayName = sheet.GetRow(3).GetCell(9)?.ToString(); @@ -271,8 +271,9 @@ namespace DOAN.Service.MES.product UseTran2(() => { - // 先删除本周计划 + // 先删除本周计划和本周的日期计划 Context.Deleteable().Where(p => p.PlanYear == proWeeklyPlan.PlanYear && p.PlanWeek == proWeeklyPlan.PlanWeek).ExecuteCommand(); + Context.Deleteable().Where(p=>p.FkWeeklyId == proWeeklyPlan.Id).ExecuteCommand(); Context.Insertable(proWeeklyPlan).ExecuteCommand(); Context.Insertable(proWeeklyDatePlan).ExecuteCommand(); Context.Insertable(proWeeklyDatePlan2).ExecuteCommand(); @@ -355,6 +356,45 @@ namespace DOAN.Service.MES.product } + + public int UpdateActualAssemblyProgress(int year, int week) + { + //获取周的日期开始到结束 + DateTime? WeekStartDate = Context.Queryable() + .Where(it => it.FkWeeklyId == SqlFunc.Subqueryable().Where(s => s.PlanWeek == week && s.PlanYear == year).Select(s => s.Id)) + .Where(it => it.DayOfWeek == "星期一") + .Select(it => it.WeekDate) + .First(); + + DateTime? WeekEndDate = Context.Queryable() + .Where(it => it.FkWeeklyId == SqlFunc.Subqueryable().Where(s => s.PlanWeek == week && s.PlanYear == year).Select(s => s.Id)) + .Where(it => it.DayOfWeek == "星期日") + .Select(it => it.WeekDate) + .First(); + + // + if (WeekStartDate == null && WeekEndDate == null) + { + Context + .Queryable() + .LeftJoin((w, r) => w.Id == r.Id) + .Where((w, r) => w.WorkorderDate >= WeekStartDate && w.WorkorderDate <= WeekEndDate) + .GroupBy(it => new { it.ProductionCode, it.Specification }) + .Select(it => new + { + it.ProductionCode, + it.Specification, + TotalDeliveryNum = SqlFunc.AggregateSum(it.DeliveryNum) + }).ToList(); + + } + + return 0; + + } + + + private int extractWeek(string title) { global::System.Text.RegularExpressions.Match match = Regex.Match(title, @"[((](\d+)[))]");