feat(工单物料): 重构工单物料查询接口并支持分页
- 新增WorkorderMaterialQueryDto作为统一查询参数模型 - 修改物料库存、可领料工单、成品库存和可出货订单查询接口,支持分页返回 - 优化RouteCode为10的工单编号生成逻辑,从101开始编号 - 调整采购订单出货数量计算方式,直接减扣出库数量
This commit is contained in:
@@ -314,7 +314,7 @@ namespace DOAN.Service.MES.product
|
||||
}
|
||||
}
|
||||
|
||||
//13 班号code
|
||||
//13 线别
|
||||
ICell currentCell_20 = currentRow.GetCell(13);
|
||||
if (currentCell_20 == null)
|
||||
{
|
||||
@@ -464,6 +464,8 @@ namespace DOAN.Service.MES.product
|
||||
int currentSort = (maxSort / 10) * 10 + 10;
|
||||
|
||||
// 直接按照Excel导入顺序生成工单号
|
||||
// 用于跟踪RouteCode为10的工单序号
|
||||
int? route10CurrentIndex = null;
|
||||
foreach (var workorder in workorderList)
|
||||
{
|
||||
string nickCode = mmMaterials
|
||||
@@ -471,8 +473,50 @@ namespace DOAN.Service.MES.product
|
||||
.Select(it => it.Type)
|
||||
.FirstOrDefault();
|
||||
|
||||
// 特殊处理:当RouteCode为10时,计数从101开始
|
||||
int indexToUse = currentIndex;
|
||||
if (workorder.RouteCode == "10")
|
||||
{
|
||||
// 第一次处理RouteCode为10的工单时,查询数据库获取最大序号
|
||||
if (!route10CurrentIndex.HasValue)
|
||||
{
|
||||
// 检查是否已经有RouteCode为10的工单
|
||||
var route10Workorders = Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.WorkorderDate == dateValue.Date)
|
||||
.Where(it => it.RouteCode == "10")
|
||||
.Select(it => it.Workorder)
|
||||
.ToList()
|
||||
.Where(w => w.StartsWith(dateValue.ToString("yyyyMMdd")))
|
||||
.Select(w =>
|
||||
{
|
||||
var parts = w.Split('_');
|
||||
if (parts.Length >= 4 && int.TryParse(parts[3], out int index))
|
||||
return index;
|
||||
return 0;
|
||||
})
|
||||
.ToList();
|
||||
|
||||
int route10MaxIndex = route10Workorders.Count > 0 ? route10Workorders.Max() : 0;
|
||||
if (route10MaxIndex < 101)
|
||||
{
|
||||
route10CurrentIndex = 101;
|
||||
}
|
||||
else
|
||||
{
|
||||
route10CurrentIndex = route10MaxIndex + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 后续的RouteCode为10的工单,直接在内存中递增序号
|
||||
route10CurrentIndex++;
|
||||
}
|
||||
indexToUse = route10CurrentIndex.Value;
|
||||
}
|
||||
|
||||
// 生成唯一的工单编号
|
||||
var generateResult = GenerateUniqueWorkorderNo(workorder, dateValue, currentIndex, nickCode);
|
||||
var generateResult = GenerateUniqueWorkorderNo(workorder, dateValue, indexToUse, nickCode);
|
||||
workorder.Workorder = generateResult.Item1;
|
||||
// 使用连续的sort值,不受编号冲突影响
|
||||
workorder.Sort = currentSort;
|
||||
@@ -546,6 +590,8 @@ namespace DOAN.Service.MES.product
|
||||
int currentSort = (maxSort / 10) * 10 + 10;
|
||||
|
||||
// 直接按照Excel导入顺序生成工单号
|
||||
// 用于跟踪RouteCode为10的工单序号
|
||||
int? route10CurrentIndex = null;
|
||||
foreach (var workorder in workorderList)
|
||||
{
|
||||
string nickCode = mmMaterials
|
||||
@@ -553,8 +599,50 @@ namespace DOAN.Service.MES.product
|
||||
.Select(it => it.Type)
|
||||
.FirstOrDefault();
|
||||
|
||||
// 特殊处理:当RouteCode为10时,计数从101开始
|
||||
int indexToUse = currentIndex;
|
||||
if (workorder.RouteCode == "10")
|
||||
{
|
||||
// 第一次处理RouteCode为10的工单时,查询数据库获取最大序号
|
||||
if (!route10CurrentIndex.HasValue)
|
||||
{
|
||||
// 检查是否已经有RouteCode为10的工单
|
||||
var route10Workorders = Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.WorkorderDate == dateValue.Date)
|
||||
.Where(it => it.RouteCode == "10")
|
||||
.Select(it => it.Workorder)
|
||||
.ToList()
|
||||
.Where(w => w.StartsWith(dateValue.ToString("yyyyMMdd")))
|
||||
.Select(w =>
|
||||
{
|
||||
var parts = w.Split('_');
|
||||
if (parts.Length >= 4 && int.TryParse(parts[3], out int index))
|
||||
return index;
|
||||
return 0;
|
||||
})
|
||||
.ToList();
|
||||
|
||||
int route10MaxIndex = route10Workorders.Count > 0 ? route10Workorders.Max() : 0;
|
||||
if (route10MaxIndex < 101)
|
||||
{
|
||||
route10CurrentIndex = 101;
|
||||
}
|
||||
else
|
||||
{
|
||||
route10CurrentIndex = route10MaxIndex + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 后续的RouteCode为10的工单,直接在内存中递增序号
|
||||
route10CurrentIndex++;
|
||||
}
|
||||
indexToUse = route10CurrentIndex.Value;
|
||||
}
|
||||
|
||||
// 生成唯一的工单编号
|
||||
var generateResult = GenerateUniqueWorkorderNo(workorder, dateValue, currentIndex, nickCode);
|
||||
var generateResult = GenerateUniqueWorkorderNo(workorder, dateValue, indexToUse, nickCode);
|
||||
workorder.Workorder = generateResult.Item1;
|
||||
// 使用连续的sort值,不受编号冲突影响
|
||||
workorder.Sort = currentSort;
|
||||
|
||||
Reference in New Issue
Block a user