修改
This commit is contained in:
@@ -105,8 +105,8 @@ namespace DOAN.Service.MES.order
|
||||
|
||||
|
||||
// 将单元格的数字值转换为DateTime
|
||||
importDate = cell.DateCellValue.Value;
|
||||
|
||||
importDate = cell?.DateCellValue?? DateTime.MinValue;
|
||||
importDate = importDate.Date;
|
||||
|
||||
// 遍历每一行
|
||||
for (int row = 4; row <= sheet.LastRowNum; row++)
|
||||
@@ -120,12 +120,13 @@ namespace DOAN.Service.MES.order
|
||||
model.PurchaseOrderErp = currentRow.GetCell(1)?.ToString();
|
||||
model.Poitem = currentRow.GetCell(2)?.ToString();
|
||||
model.Variety = currentRow.GetCell(3)?.ToString();
|
||||
string specordindicator= currentRow.GetCell(4)?.ToString();
|
||||
if(!string.IsNullOrEmpty(specordindicator)&&specordindicator=="是")
|
||||
|
||||
string specordindicator = currentRow.GetCell(4)?.ToString();
|
||||
if (!string.IsNullOrEmpty(specordindicator) && specordindicator == "是")
|
||||
{
|
||||
model.Specordindicator = 1;
|
||||
}
|
||||
else if(!string.IsNullOrEmpty(specordindicator) && specordindicator == "否")
|
||||
else if (!string.IsNullOrEmpty(specordindicator) && specordindicator == "否")
|
||||
{
|
||||
model.Specordindicator = 0;
|
||||
}
|
||||
@@ -133,17 +134,25 @@ namespace DOAN.Service.MES.order
|
||||
{
|
||||
model.Specordindicator = -1;
|
||||
}
|
||||
|
||||
model.KdType = currentRow.GetCell(5)?.ToString();
|
||||
model.DocumentDate = currentRow.GetCell(6).DateCellValue.Value;
|
||||
model.DocumentDate = currentRow.GetCell(6)?.DateCellValue; // 直接赋值,如果为 null 则保持 null
|
||||
model.Seller = currentRow.GetCell(7)?.ToString();
|
||||
model.SalesArea = currentRow.GetCell(8)?.ToString();
|
||||
model.MaterialName = currentRow.GetCell(9)?.ToString();
|
||||
model.MaterialCode = currentRow.GetCell(10)?.ToString();
|
||||
model.DemandQuantity = (int)currentRow.GetCell(11).NumericCellValue;
|
||||
model.DeliveryDate= currentRow.GetCell(12).DateCellValue.Value;
|
||||
model.DeliveryQuantity = (int)currentRow.GetCell(13).NumericCellValue;
|
||||
model.StartDate = currentRow.GetCell(14).DateCellValue.Value;
|
||||
model.EndDate = currentRow.GetCell(15).DateCellValue.Value;
|
||||
|
||||
var demandQuantityCell = currentRow.GetCell(11);
|
||||
model.DemandQuantity = demandQuantityCell != null && demandQuantityCell.CellType == CellType.Numeric ? (int)demandQuantityCell.NumericCellValue : 0;
|
||||
|
||||
model.DeliveryDate = currentRow.GetCell(12)?.DateCellValue; // 直接赋值,如果为 null 则保持 null
|
||||
|
||||
var deliveryQuantityCell = currentRow.GetCell(13);
|
||||
model.DeliveryQuantity = deliveryQuantityCell != null && deliveryQuantityCell.CellType == CellType.Numeric ? (int)deliveryQuantityCell.NumericCellValue : 0;
|
||||
|
||||
model.StartDate = currentRow.GetCell(14)?.DateCellValue; // 直接赋值,如果为 null 则保持 null
|
||||
model.EndDate = currentRow.GetCell(15)?.DateCellValue; // 直接赋值,如果为 null 则保持 null
|
||||
|
||||
string Orderindicator = currentRow.GetCell(16)?.ToString();
|
||||
if (!string.IsNullOrEmpty(Orderindicator) && Orderindicator == "是")
|
||||
{
|
||||
@@ -157,11 +166,13 @@ namespace DOAN.Service.MES.order
|
||||
{
|
||||
model.Orderindicator = -1;
|
||||
}
|
||||
|
||||
model.RouteCode = currentRow.GetCell(17)?.ToString();
|
||||
model.Remark = currentRow.GetCell(18)?.ToString();
|
||||
model.ImportDate = importDate;
|
||||
model.CreatedTime = importDate;
|
||||
model.CreatedBy = username;
|
||||
|
||||
orderPurchases.Add(model);
|
||||
|
||||
}
|
||||
@@ -175,7 +186,14 @@ namespace DOAN.Service.MES.order
|
||||
|
||||
if(orderPurchases.Count>0)
|
||||
{
|
||||
return Context.Insertable(orderPurchases).ExecuteCommand();
|
||||
int result = 0;
|
||||
UseTran2(() =>
|
||||
{
|
||||
Context.Deleteable<OrderPurchase>().Where(x => x.ImportDate == importDate).ExecuteCommand();
|
||||
result= Context.Insertable(orderPurchases).ExecuteCommand();
|
||||
});
|
||||
return result;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user