1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using SqlSugar;
|
||||
using ZR.Model;
|
||||
using ZR.Model.MES.wms;
|
||||
@@ -53,7 +54,7 @@ namespace ZR.Service.mes.wms
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(it => it.Partnumber)
|
||||
.OrderByDescending(it => it.Quantity)
|
||||
.ToPage<WmOneTimeInventory, WmOneTimeInventoryDto>(parm);
|
||||
if (response.Result.Count > 0)
|
||||
{
|
||||
@@ -450,6 +451,9 @@ namespace ZR.Service.mes.wms
|
||||
Dictionary<string, object> stockNumbers = GetBatchOneTimeStockPartNum(partnumbers);
|
||||
Dictionary<string, int> realNumbers = GetBatchOneTimeRealPartNum(partnumbers);
|
||||
|
||||
// 更新盘点时间
|
||||
DateTime dateTime = DateTime.Now.ToLocalTime();
|
||||
|
||||
// 构建导出数据
|
||||
List<WmOneTimeInventoryExportDto> exportDto = materials
|
||||
.Select(it =>
|
||||
@@ -466,6 +470,7 @@ namespace ZR.Service.mes.wms
|
||||
描述 = it.Description,
|
||||
盘点数 = stockNumber,
|
||||
现有库存 = found2 ? realNumber : 0,
|
||||
盘点时间 = dateTime,
|
||||
};
|
||||
})
|
||||
.ToList();
|
||||
@@ -502,12 +507,65 @@ namespace ZR.Service.mes.wms
|
||||
CommonFQCService commonFQCService = new();
|
||||
// 获取报表数据
|
||||
// 一次合格计算后库存 = 盘点库存 + 产线合格 + 抛光合格 - gp12投入 - 后道直接出库
|
||||
return commonFQCService.GetBatchOneTimePartRealStock(partnumbers, checkTime.Value.ToLocalTime());
|
||||
return commonFQCService.GetBatchOneTimePartRealStock(partnumbers, checkTime.Value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入数据
|
||||
/// </summary>
|
||||
/// <param name="importData"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) ImportExcel(List<WmOneTimeInventoryExportDto> importList)
|
||||
{
|
||||
List<WmOneTimeInventory> wmOneTimeInventorylist = importList.Select(it => new WmOneTimeInventory
|
||||
{
|
||||
Id = SnowFlakeSingle.Instance.NextId().ToString(),
|
||||
Type = 1,
|
||||
Status = 1,
|
||||
MaxNum = 0,
|
||||
MinNum = 0,
|
||||
WarnNum = 0,
|
||||
CreatedBy = "页面导入",
|
||||
Remark = "EXCEL 盘点导入",
|
||||
CreatedTime = it.盘点时间 ?? DateTime.Now.ToLocalTime(),
|
||||
Partnumber = it.零件号,
|
||||
Quantity = it.盘点数
|
||||
}).ToList();
|
||||
var x = Context.Storageable(wmOneTimeInventorylist)
|
||||
.SplitError(x => x.Item.Partnumber.IsEmpty(), "零件号不能为空")
|
||||
.SplitError(x => x.Item.Quantity.IsEmpty(), "盘点数不能为空")
|
||||
.SplitUpdate(it => it.Any()) // 数据库存在更新
|
||||
.SplitDelete(it => it.Item.Quantity == 0) //盘点数为0的不导入
|
||||
.SplitInsert(it => true) // 其余插入
|
||||
.WhereColumns(it => it.Partnumber)//如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2})
|
||||
.ToStorage();
|
||||
|
||||
// 清空全部
|
||||
var result = x.AsInsertable.ExecuteCommand();//不存在则插入;
|
||||
var result2 = x.AsUpdateable.IgnoreColumns(it => new { it.Id }).ExecuteCommand();//存在则修改;
|
||||
var result3 = x.AsDeleteable.ExecuteCommand(); //盘点数为0的删除;
|
||||
string msg = string.Format(" 插入{0} 更新{1} 错误数据{2} 不计算数据{3} 删除数据{4} 总共{5}",
|
||||
x.InsertList.Count,
|
||||
x.UpdateList.Count,
|
||||
x.ErrorList.Count,
|
||||
x.IgnoreList.Count,
|
||||
x.DeleteList.Count,
|
||||
x.TotalList.Count);
|
||||
//输出统计
|
||||
Console.WriteLine(msg);
|
||||
|
||||
//输出错误信息
|
||||
foreach (var item in x.ErrorList)
|
||||
{
|
||||
Console.WriteLine("零件异常:" + item.Item.Partnumber + " : " + item.StorageMessage);
|
||||
}
|
||||
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user