feat(入库单): 实现入库单号自动生成及箱数统计功能

为HD和GP12类型的入库单实现自动生成单号功能,格式为类型前缀+日期+4位流水号。同时添加箱数统计逻辑,从相关扫描记录中获取实际箱数。移除硬编码的默认值,使入库单信息更准确。
This commit is contained in:
2025-11-18 10:48:45 +08:00
parent 12a32e1942
commit 92e3a7f9d5
2 changed files with 71 additions and 5 deletions

View File

@@ -1239,9 +1239,41 @@ namespace ZR.Service.Business
_ = Task.Run(() =>
{
ProFinishedProductReceiptService proFinishedProductReceiptService = new ProFinishedProductReceiptService();
// 生成ReceiptNoGP+日期YYYYMMDD+0001顺序递增
string today = nowTime.ToString("yyyyMMdd");
string receiptNoPrefix = $"HD{today}";
// 查询今天已存在的最大单号
var lastReceipt = Context
.Queryable<ProFinishedProductReceipt>()
.Where(it => it.ReceiptNo.StartsWith(receiptNoPrefix))
.OrderBy(it => it.ReceiptNo, OrderByType.Desc)
.First();
string newReceiptNo;
if (lastReceipt != null && !string.IsNullOrEmpty(lastReceipt.ReceiptNo))
{
// 提取流水号并递增
string sequenceStr = lastReceipt.ReceiptNo.Substring(receiptNoPrefix.Length);
if (int.TryParse(sequenceStr, out int sequence))
{
newReceiptNo = $"{receiptNoPrefix}{(sequence + 1):D4}";
}
else
{
newReceiptNo = $"{receiptNoPrefix}0001";
}
}
else
{
newReceiptNo = $"{receiptNoPrefix}0001";
}
// 箱数
int _packageCount = Context.Queryable<QcBackEndRecordLabelScan>().Where(it => it.WorkOrder == qcBackEndWorkorder.WorkOrder).Where(it => it.LabelType == 1).Count();
ProFinishedProductReceipt newModel = new()
{
ReceiptNo = "1",
ReceiptNo = newReceiptNo,
SiteNo = qcBackEndWorkorder.SiteNo,
WorkOrder = qcBackEndWorkorder.WorkOrder,
WarehouseCode = "LS",
@@ -1259,7 +1291,7 @@ namespace ZR.Service.Business
BatchCode = nowTime.ToString("yyyyMMdd"),
Unit = "个",
PackageCode = qcBackEndWorkorder.WorkOrder,
PackageCount = 1,
PackageCount = _packageCount,
PackageNum = qcBackEndWorkorder.QualifiedNumber,
LabelCode = "",
LabelPrintStatus = "未打印",

View File

@@ -738,8 +738,42 @@ namespace ZR.Service.Business
_ = Task.Run(() =>
{
ProFinishedProductReceiptService proFinishedProductReceiptService = new ProFinishedProductReceiptService();
// 生成ReceiptNoGP+日期YYYYMMDD+0001顺序递增
string today = nowTime.ToString("yyyyMMdd");
string receiptNoPrefix = $"GP{today}";
// 查询今天已存在的最大单号
var lastReceipt = Context
.Queryable<ProFinishedProductReceipt>()
.Where(it => it.ReceiptNo.StartsWith(receiptNoPrefix))
.OrderBy(it => it.ReceiptNo, OrderByType.Desc)
.First();
string newReceiptNo;
if (lastReceipt != null && !string.IsNullOrEmpty(lastReceipt.ReceiptNo))
{
// 提取流水号并递增
string sequenceStr = lastReceipt.ReceiptNo.Substring(receiptNoPrefix.Length);
if (int.TryParse(sequenceStr, out int sequence))
{
newReceiptNo = $"{receiptNoPrefix}{(sequence + 1):D4}";
}
else
{
newReceiptNo = $"{receiptNoPrefix}0001";
}
}
else
{
newReceiptNo = $"{receiptNoPrefix}0001";
}
// 箱数
int _packageCount = Context.Queryable<QcGp12RecordLabelScan>().Where(it=>it.WorkOrder == qcGp12Workorder.WorkOrder).Where(it => it.LabelType == 1).Count();
ProFinishedProductReceipt newModel = new() {
ReceiptNo = "1",
ReceiptNo = newReceiptNo,
SiteNo = qcGp12Workorder.SiteNo,
WorkOrder = qcGp12Workorder.WorkOrder,
WarehouseCode = "LS",
@@ -757,9 +791,9 @@ namespace ZR.Service.Business
BatchCode = nowTime.ToString("yyyyMMdd"),
Unit = "个",
PackageCode = qcGp12Workorder.WorkOrder,
PackageCount = 1,
PackageCount = _packageCount,
PackageNum = qcGp12Workorder.QualifiedNumber,
LabelCode = "",
LabelCode = $"LabelType=FPR^ReceiptNo={qcGp12Workorder.WorkOrder}^WorkOrder={qcGp12Workorder.WorkOrder}^PartNumber={qcGp12Workorder.PartNumber}^LabelFrom=GP12",
LabelPrintStatus = "未打印",
StorageLocation = "LS",
QcStatus = "待检验",