From 33e5e169f134ee64090a754bef00a92a4f2a8ffc Mon Sep 17 00:00:00 2001 From: wenjy Date: Sun, 31 Dec 2023 19:53:57 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20taskCode=20GetMaxCodeAsyncf?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/QuantityIssuedViewModel.cs | 56 +++++++------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs index 772ceb9e..e8cdcd8b 100644 --- a/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs @@ -73,7 +73,8 @@ namespace Aucma.Core.SheetMetal.ViewModels task.ProductPlanCode = PlanInfo.PlanCode; task.OrderCode = PlanInfo.OrderCode; task.ProductLineCode = stationCode;//计划工位 - task.TaskCode = GetMaxCodeAsync(list); + //task.TaskCode = GetMaxCodeAsync(); + task.TaskCode = System.Guid.NewGuid().ToString("N").Substring(0,16); task.MaterialCode = PlanInfo.MaterialCode; task.MaterialName = PlanInfo.MaterialName; if (list.Count == 0) @@ -150,45 +151,30 @@ namespace Aucma.Core.SheetMetal.ViewModels } #endregion - public string GetMaxCodeAsync(List planInfos) + public string GetMaxCodeAsync() { - string taskCodeStr = string.Empty; - if(planInfos != null) + + string stationCode = Appsettings.app("StoreInfo", "StationCode"); + string today = DateTime.Now.ToString("yyyyMMdd"); + var maxCode = _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(stationCode)).Result.Max(d => d.TaskCode); + if (maxCode.IsNotEmptyOrNull()) { - if (planInfos.Count > 0) + string date = maxCode.Substring(0, 8); + string max = maxCode.Substring(maxCode.Length - 4, maxCode.Length); + + if (today.Equals(date)) + { + return date + (int.Parse(max) + 1); + } + else { - ExecutePlanInfo planInfo = planInfos.Where(x => x.TaskCode.Contains(DateTime.Now.ToString("yyyy-MM-dd"))).OrderByDescending(x => x.TaskCode).First(); - if (planInfo != null) - { - int taskCode = Convert.ToInt32(planInfo.TaskCode); - taskCodeStr = (taskCode + 1).ToString(); - return taskCodeStr; - } + return today + "00001"; } } - taskCodeStr = DateTime.Now.ToString("yyyy-MM-dd") + "1".PadLeft(5, '0'); - - return taskCodeStr; - //string stationCode = Appsettings.app("StoreInfo", "StationCode"); - //string today = DateTime.Now.ToString("yyyyMMdd"); - //var maxCode = _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(stationCode)).Result.Max(d=>d.TaskCode); - //if (maxCode.IsNotEmptyOrNull()) - //{ - // string date= maxCode.Substring(0, 8); - // string max = maxCode.Substring(maxCode.Length-4, maxCode.Length); - - // if (today.Equals(date)) { - // return date + (int.Parse(max) + 1); - // } - // else - // { - // return today + "00001"; - // } - //} - //else - //{ - // return today + "00001"; - //} + else + { + return today + "00001"; + } } } }