仓库-拼箱,添加可设置次箱往主箱添加的数量

This commit is contained in:
2024-04-20 10:46:36 +08:00
parent c0a9092584
commit eba391bab9
2 changed files with 57 additions and 13 deletions

View File

@@ -31,26 +31,50 @@ namespace ZR.Service.Business
// 拼箱计数器
int num = 0;
int? quantityCount = 0;
List<string> ids = new();
// 第二箱录入数量(限制只能输入两箱)
int secondNum = parm.secondNum;
int? secondHas = 0;
bool isDelete = false;
string secondId = "";
// 箱验证
foreach (ResultionPackageCodeDto package in list)
{
num++;
// 有第二箱录入数量的情况下只能两箱拼
if (num == 3)
{
return null;
}
WmGoodsNowProduction check1 = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient == package.PatchCode).First();
if (check1 == null)
{
return null;
}
if (num == 1)
{
description = "\n主箱:" + package.PatchCode + ",\n次箱:";
quantityCount += package.Quantity;
continue;
}
if(num==2)
{
secondId = check1.Id;
description += package.PatchCode + ",";
}
// 第二箱数量为正数且比箱子总数量小
if (num == 2 && secondNum < package.Quantity && secondNum > 0)
{
isDelete = false;
secondHas = package.Quantity - secondNum;
quantityCount += secondNum;
}
else
{
ids.Add(check1.Id);
description += package.PatchCode + ",";
isDelete = true;
secondHas = 0;
quantityCount += package.Quantity;
}
quantityCount += package.Quantity;
}
ResultionPackageCodeDto mainPackage = list[0];
// 短批次
@@ -114,14 +138,34 @@ namespace ZR.Service.Business
+ "^Qty=" + quantityCount;
nowProduction.GoodsNumLogic = quantityCount;
nowProduction.GoodsNumAction = quantityCount;
nowProduction.Remark = "拼箱";
nowProduction.Remark = "拼箱整箱";
// 修改主箱
Context.Updateable(nowProduction).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
// TODO修改打印记录
// 删除分箱
Context.Deleteable<WmGoodsNowProduction>().In(ids).ExecuteCommand();
// 次箱操作
if (isDelete)
{
// 删除次箱
Context.Deleteable<WmGoodsNowProduction>().Where(it=>it.Id == secondId).ExecuteCommand();
}
else
{
// 修改次箱子
WmGoodsNowProduction nowProduction2 = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.Id == secondId).First();
if (nowProduction2 == null)
{
return null;
}
nowProduction2.UpdatedBy = parm.CreateBy;
nowProduction2.UpdatedTime = nowTime;
nowProduction2.PackageCodeOriginal = "Code=" + nowProduction2.PackageCodeClient
+ "^ItemNumber=" + nowProduction2.Partnumber
+ "^Order=" + nowProduction2.PackageCodeClient.Split('_')[0].Substring(2)
+ "^Qty=" + secondHas;
nowProduction2.GoodsNumLogic = secondHas;
nowProduction2.GoodsNumAction = secondHas;
nowProduction2.Remark = "拼箱零头箱";
}
return log;
}
@@ -137,7 +181,7 @@ namespace ZR.Service.Business
{
return null;
}
description += "\n由主箱:" + mainPackage.PatchCode + "拆分:";
// 短批次
string shortPatchCode = mainPackage.PatchCode.Split('_')[0];
@@ -168,7 +212,7 @@ namespace ZR.Service.Business
}
}
int firstNum = parm.firstNum;
int? secondNum = mainNowProduction.GoodsNumAction - firstNum;
if (secondNum <= 0)
{