change - taskCode GetMaxCodeAsyncf方法恢复

dev
wenjy 1 year ago
parent c5fa3690e6
commit 33e5e169f1

@ -73,7 +73,8 @@ namespace Aucma.Core.SheetMetal.ViewModels
task.ProductPlanCode = PlanInfo.PlanCode; task.ProductPlanCode = PlanInfo.PlanCode;
task.OrderCode = PlanInfo.OrderCode; task.OrderCode = PlanInfo.OrderCode;
task.ProductLineCode = stationCode;//计划工位 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.MaterialCode = PlanInfo.MaterialCode;
task.MaterialName = PlanInfo.MaterialName; task.MaterialName = PlanInfo.MaterialName;
if (list.Count == 0) if (list.Count == 0)
@ -150,45 +151,30 @@ namespace Aucma.Core.SheetMetal.ViewModels
} }
#endregion #endregion
public string GetMaxCodeAsync(List<ExecutePlanInfo> 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))
{ {
ExecutePlanInfo planInfo = planInfos.Where(x => x.TaskCode.Contains(DateTime.Now.ToString("yyyy-MM-dd"))).OrderByDescending(x => x.TaskCode).First(); return date + (int.Parse(max) + 1);
if (planInfo != null) }
else
{ {
int taskCode = Convert.ToInt32(planInfo.TaskCode); return today + "00001";
taskCodeStr = (taskCode + 1).ToString();
return taskCodeStr;
} }
} }
else
{
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";
//}
} }
} }
} }

Loading…
Cancel
Save