refactor(MES): 更新工作订单导入服务的字段命名和验证逻辑

- 将字段注释从"铸件"改为"成品"和"原材料"以更准确描述业务含义
- 移除对单位、材质和版本字段的非空验证,使其更符合业务需求
- 使用雪花算法替代GUID生成工作订单ID,提高ID生成效率
This commit is contained in:
2026-01-30 11:36:40 +08:00
parent e12417dec2
commit 4bfe08d0c1

View File

@@ -62,7 +62,7 @@ namespace DOAN.Service.MES.product
{ {
ProWorkorder workorder = new ProWorkorder(); ProWorkorder workorder = new ProWorkorder();
//00 铸件品名 //00 品名
ICell currentCell_01 = currentRow.GetCell(0); ICell currentCell_01 = currentRow.GetCell(0);
workorder.productionName = currentCell_01?.ToString(); workorder.productionName = currentCell_01?.ToString();
if (currentCell_01 == null || string.IsNullOrEmpty(workorder.productionName)) if (currentCell_01 == null || string.IsNullOrEmpty(workorder.productionName))
@@ -70,7 +70,7 @@ namespace DOAN.Service.MES.product
continue; continue;
} }
//01 铸件型号 //01 成品型号
ICell currentCell_02 = currentRow.GetCell(1); ICell currentCell_02 = currentRow.GetCell(1);
workorder.productionCode = currentCell_02?.ToString(); workorder.productionCode = currentCell_02?.ToString();
if (currentCell_02 == null || string.IsNullOrEmpty(workorder.productionCode)) if (currentCell_02 == null || string.IsNullOrEmpty(workorder.productionCode))
@@ -81,16 +81,12 @@ namespace DOAN.Service.MES.product
//02 单位 //02 单位
ICell currentCell_04 = currentRow.GetCell(2); ICell currentCell_04 = currentRow.GetCell(2);
workorder.Unit = currentCell_04?.ToString(); workorder.Unit = currentCell_04?.ToString();
if (currentCell_04 == null || string.IsNullOrEmpty(workorder.Unit))
{
continue;
}
//3 plan_num //3 计划数量
ICell currentCell_07 = currentRow.GetCell(3); ICell currentCell_07 = currentRow.GetCell(3);
workorder.PlanNum = (int)currentCell_07?.NumericCellValue; workorder.PlanNum = (int)currentCell_07?.NumericCellValue;
//4 材质品名 //4 原材料名称
ICell currentCell_11 = currentRow.GetCell(4); ICell currentCell_11 = currentRow.GetCell(4);
workorder.MaterialName = currentCell_11?.ToString(); workorder.MaterialName = currentCell_11?.ToString();
if (currentCell_11 == null || string.IsNullOrEmpty(workorder.MaterialName)) if (currentCell_11 == null || string.IsNullOrEmpty(workorder.MaterialName))
@@ -98,7 +94,7 @@ namespace DOAN.Service.MES.product
continue; continue;
} }
//5 材质牌 //5 原材料编
ICell currentCell_12 = currentRow.GetCell(5); ICell currentCell_12 = currentRow.GetCell(5);
workorder.MaterialCode = currentCell_12?.ToString(); workorder.MaterialCode = currentCell_12?.ToString();
if (currentCell_12 == null || string.IsNullOrEmpty(workorder.MaterialCode)) if (currentCell_12 == null || string.IsNullOrEmpty(workorder.MaterialCode))
@@ -106,13 +102,9 @@ namespace DOAN.Service.MES.product
continue; continue;
} }
//6 材质 //6 原材料材质
ICell currentCell_13 = currentRow.GetCell(6); ICell currentCell_13 = currentRow.GetCell(6);
workorder.MaterialtextureCode = currentCell_13?.ToString(); workorder.MaterialtextureCode = currentCell_13?.ToString();
if (currentCell_13 == null || string.IsNullOrEmpty(workorder.MaterialtextureCode))
{
continue;
}
//7 炉号 //7 炉号
ICell currentCell_14 = currentRow.GetCell(7); ICell currentCell_14 = currentRow.GetCell(7);
@@ -133,10 +125,6 @@ namespace DOAN.Service.MES.product
//9 版本 //9 版本
ICell currentCell_16 = currentRow.GetCell(9); ICell currentCell_16 = currentRow.GetCell(9);
workorder.Version = currentCell_16?.ToString(); workorder.Version = currentCell_16?.ToString();
if (currentCell_16 == null || string.IsNullOrEmpty(workorder.Version))
{
continue;
}
//10 指导日期 //10 指导日期
ICell cell17 = currentRow.GetCell(10); ICell cell17 = currentRow.GetCell(10);
@@ -231,7 +219,7 @@ namespace DOAN.Service.MES.product
ICell currentCell_012 = currentRow.GetCell(18); ICell currentCell_012 = currentRow.GetCell(18);
workorder.Remark01 = currentCell_012?.StringCellValue; workorder.Remark01 = currentCell_012?.StringCellValue;
workorder.Id = Guid.NewGuid().ToString(); workorder.Id = SnowFlakeSingle.Instance.NextId().ToString();
workorder.CreatedBy = username; workorder.CreatedBy = username;
workorder.CreatedTime = DateTime.Now; workorder.CreatedTime = DateTime.Now;
workorder.WorkorderDate = dateValue; workorder.WorkorderDate = dateValue;
@@ -308,7 +296,7 @@ namespace DOAN.Service.MES.product
ProWorkorder workorder = new ProWorkorder(); ProWorkorder workorder = new ProWorkorder();
#region excel #region excel
//00 铸件品名 //00 品名
ICell currentCell_01 = currentRow.GetCell(0); ICell currentCell_01 = currentRow.GetCell(0);
workorder.productionName = currentCell_01?.ToString(); workorder.productionName = currentCell_01?.ToString();
if (currentCell_01 == null || string.IsNullOrEmpty(workorder.productionName)) if (currentCell_01 == null || string.IsNullOrEmpty(workorder.productionName))
@@ -316,7 +304,7 @@ namespace DOAN.Service.MES.product
continue; continue;
} }
//01 铸件型号 //01 成品型号
ICell currentCell_02 = currentRow.GetCell(1); ICell currentCell_02 = currentRow.GetCell(1);
workorder.productionCode = currentCell_02?.ToString(); workorder.productionCode = currentCell_02?.ToString();
if (currentCell_02 == null || string.IsNullOrEmpty(workorder.productionCode)) if (currentCell_02 == null || string.IsNullOrEmpty(workorder.productionCode))
@@ -327,16 +315,12 @@ namespace DOAN.Service.MES.product
//02 单位 //02 单位
ICell currentCell_04 = currentRow.GetCell(2); ICell currentCell_04 = currentRow.GetCell(2);
workorder.Unit = currentCell_04?.ToString(); workorder.Unit = currentCell_04?.ToString();
if (currentCell_04 == null || string.IsNullOrEmpty(workorder.Unit))
{
continue;
}
//3 plan_num //3 计划数量
ICell currentCell_07 = currentRow.GetCell(3); ICell currentCell_07 = currentRow.GetCell(3);
workorder.PlanNum = (int)currentCell_07?.NumericCellValue; workorder.PlanNum = (int)currentCell_07?.NumericCellValue;
//4 材质品名 //4 原材料名称
ICell currentCell_11 = currentRow.GetCell(4); ICell currentCell_11 = currentRow.GetCell(4);
workorder.MaterialName = currentCell_11?.ToString(); workorder.MaterialName = currentCell_11?.ToString();
if (currentCell_11 == null || string.IsNullOrEmpty(workorder.MaterialName)) if (currentCell_11 == null || string.IsNullOrEmpty(workorder.MaterialName))
@@ -344,7 +328,7 @@ namespace DOAN.Service.MES.product
continue; continue;
} }
//5 材质牌 //5 原材料编
ICell currentCell_12 = currentRow.GetCell(5); ICell currentCell_12 = currentRow.GetCell(5);
workorder.MaterialCode = currentCell_12?.ToString(); workorder.MaterialCode = currentCell_12?.ToString();
if (currentCell_12 == null || string.IsNullOrEmpty(workorder.MaterialCode)) if (currentCell_12 == null || string.IsNullOrEmpty(workorder.MaterialCode))
@@ -379,10 +363,6 @@ namespace DOAN.Service.MES.product
//9 版本 //9 版本
ICell currentCell_16 = currentRow.GetCell(9); ICell currentCell_16 = currentRow.GetCell(9);
workorder.Version = currentCell_16?.ToString(); workorder.Version = currentCell_16?.ToString();
if (currentCell_16 == null || string.IsNullOrEmpty(workorder.Version))
{
continue;
}
//10 指导日期 //10 指导日期
ICell cell17 = currentRow.GetCell(10); ICell cell17 = currentRow.GetCell(10);
@@ -478,7 +458,7 @@ namespace DOAN.Service.MES.product
workorder.Remark01 = currentCell_012?.StringCellValue; workorder.Remark01 = currentCell_012?.StringCellValue;
#endregion #endregion
workorder.Id = Guid.NewGuid().ToString(); workorder.Id = SnowFlakeSingle.Instance.NextId().ToString();
workorder.CreatedBy = username; workorder.CreatedBy = username;
workorder.CreatedTime = DateTime.Now; workorder.CreatedTime = DateTime.Now;
workorder.WorkorderDate = dateValue; workorder.WorkorderDate = dateValue;