导入周计划

This commit is contained in:
gcw_MV9p2JJN 2025-09-08 15:21:43 +08:00
parent d30d86d5b4
commit 0f2ddcfad5
5 changed files with 55 additions and 5 deletions

View File

@ -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);
}

View File

@ -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);
}

Binary file not shown.

View File

@ -18,5 +18,9 @@ namespace DOAN.Service.MES.product.IService
PagedInfo<ProWeeklyPlanAndDateDto> SearchWeekplan(WeekplanQueryDto weekplanQuery);
int UpdateActualAssemblyProgress(int year, int week);
}
}

View File

@ -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<ProWeeklyPlan>().Where(p => p.PlanYear == proWeeklyPlan.PlanYear && p.PlanWeek == proWeeklyPlan.PlanWeek).ExecuteCommand();
Context.Deleteable<ProWeeklyDate>().Where(p=>p.FkWeeklyId == proWeeklyPlan.Id).ExecuteCommand();
Context.Insertable<ProWeeklyPlan>(proWeeklyPlan).ExecuteCommand();
Context.Insertable<ProWeeklyDate>(proWeeklyDatePlan).ExecuteCommand();
Context.Insertable<ProWeeklyDate>(proWeeklyDatePlan2).ExecuteCommand();
@ -355,6 +356,45 @@ namespace DOAN.Service.MES.product
}
public int UpdateActualAssemblyProgress(int year, int week)
{
//获取周的日期开始到结束
DateTime? WeekStartDate = Context.Queryable<ProWeeklyDate>()
.Where(it => it.FkWeeklyId == SqlFunc.Subqueryable<ProWeeklyPlan>().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<ProWeeklyDate>()
.Where(it => it.FkWeeklyId == SqlFunc.Subqueryable<ProWeeklyPlan>().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<ProWorkorder>()
.LeftJoin<ProReportwork>((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+)[)]");