一次合格与抛光品仓库查询逻辑调整,导出调整,盘点调整!!!
This commit is contained in:
@@ -313,7 +313,34 @@ namespace ZR.Service.mes.wms
|
||||
// TODO 匹配记录(partnumber零件号,时间范围)
|
||||
foreach (WmPolishInventoryDto item in list)
|
||||
{
|
||||
// TODO 获取实际库存 item.quantity(盘点开始数量) + recourd 记录的入库数量 - 出库数量(筛选条件是 时间区间【item.CreatedTime】 + partnumber[item.partnumber])
|
||||
//TODO 20250408 盘点时间修正(三个时间比对)
|
||||
WmPolishRecord minCheckRecord =
|
||||
wmPolishRecords
|
||||
.Where(o => o.Partnumber == item.Partnumber && o.ChangeType == 3)
|
||||
.OrderByDescending(o => o.ActionTime)
|
||||
.FirstOrDefault();
|
||||
DateTime minCheckRecordTime = DateTime.MinValue;
|
||||
int minCheckRecordQuantity = 0;
|
||||
if (minCheckRecord != null)
|
||||
{
|
||||
minCheckRecordTime = minCheckRecord.ActionTime ?? DateTime.MinValue;
|
||||
}
|
||||
|
||||
DateTime minCheckInventoryTime = item.CreatedTime ?? minDateTime;
|
||||
//TODO 20250408修改 最小盘点时间判断/如有盘点记录,则优先取盘点记录数据
|
||||
DateTime checkTime =
|
||||
minCheckRecordTime > minCheckInventoryTime
|
||||
? minCheckRecordTime
|
||||
: minCheckInventoryTime;
|
||||
if (checkTime == minCheckRecordTime)
|
||||
{
|
||||
// TODO 20250408 如果最早记录是盘点记录,则取盘点变动数量
|
||||
minCheckRecordQuantity = minCheckRecord.ChangeQuantity ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
minCheckRecordQuantity = item.Quantity.Value;
|
||||
}
|
||||
int? runum = wmPolishRecords
|
||||
.Where(o =>
|
||||
o.ActionTime >= item.CreatedTime
|
||||
@@ -330,7 +357,8 @@ namespace ZR.Service.mes.wms
|
||||
)
|
||||
.Select(o => o.ChangeQuantity)
|
||||
.Sum();
|
||||
item.RealQuantity = item.Quantity.Value + (runum.Value - chunum.Value);
|
||||
item.RealQuantity = minCheckRecordQuantity + (runum.Value - chunum.Value);
|
||||
item.CreatedTime = checkTime;
|
||||
}
|
||||
|
||||
list = list.Where(it => it.RealQuantity != 0 || it.Quantity != 0)
|
||||
@@ -696,7 +724,7 @@ namespace ZR.Service.mes.wms
|
||||
throw new Exception(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// 盘点
|
||||
public int DoWmPolishStocktaking(WmPolishInventory parm)
|
||||
{
|
||||
if (parm.Quantity < 0)
|
||||
@@ -707,7 +735,7 @@ namespace ZR.Service.mes.wms
|
||||
{
|
||||
Context.Ado.BeginTran();
|
||||
// 检查是否存在库中
|
||||
WmPolishInventory polishInventory = Context
|
||||
/* WmPolishInventory polishInventory = Context
|
||||
.Queryable<WmPolishInventory>()
|
||||
.Where(it => it.Id == parm.Id)
|
||||
.Where(it => it.Status == 1)
|
||||
@@ -717,7 +745,7 @@ namespace ZR.Service.mes.wms
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception("盘点记录不存在" + parm.Id);
|
||||
}
|
||||
Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();*/
|
||||
// 已有则新增记录
|
||||
string code = !string.IsNullOrEmpty(parm.WorkOrder)
|
||||
? parm.WorkOrder
|
||||
@@ -728,7 +756,7 @@ namespace ZR.Service.mes.wms
|
||||
parm.Partnumber,
|
||||
3,
|
||||
parm.Quantity,
|
||||
parm.ActionTime,
|
||||
parm.ActionTime ?? DateTime.Now,
|
||||
parm.Remark,
|
||||
parm.CreatedBy
|
||||
);
|
||||
@@ -779,39 +807,43 @@ namespace ZR.Service.mes.wms
|
||||
{
|
||||
try
|
||||
{
|
||||
List<WmMaterial> materials = GetWmMaterialList(parm.Partnumber);
|
||||
/* List<WmMaterial> materials = GetWmMaterialList(parm.Partnumber);
|
||||
|
||||
// 获取所有partnumber列表
|
||||
List<string> partnumbers = materials
|
||||
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
|
||||
.Select(it => it.Partnumber)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
// 获取所有partnumber列表
|
||||
List<string> partnumbers = materials
|
||||
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
|
||||
.Select(it => it.Partnumber)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
// 批量获取盘点数和现有库存
|
||||
Dictionary<string, object> stockNumbers = GetBatchPolishStockPartNum(partnumbers);
|
||||
Dictionary<string, int> realNumbers = GetBatchPolishRealPartNum(partnumbers);
|
||||
// 批量获取盘点数和现有库存
|
||||
Dictionary<string, object> stockNumbers = GetBatchPolishStockPartNum(partnumbers);
|
||||
Dictionary<string, int> realNumbers = GetBatchPolishRealPartNum(partnumbers);
|
||||
|
||||
// 更新盘点时间
|
||||
DateTime dateTime = DateTime.Now.ToLocalTime();
|
||||
// 更新盘点时间
|
||||
DateTime dateTime = DateTime.Now.ToLocalTime();*/
|
||||
|
||||
//TODO 20250408 新导出逻辑
|
||||
|
||||
// 构建导出数据
|
||||
List<WmPolishInventoryExportDto> exportDto = materials
|
||||
WmPolishInventoryQueryDto queryParams = new()
|
||||
{
|
||||
PageSize = 10000,
|
||||
PageNum = 1
|
||||
};
|
||||
// 构建导出数据
|
||||
List<WmPolishInventoryExportDto> exportDto = GetListNew(queryParams).Result
|
||||
.Select(it =>
|
||||
{
|
||||
bool found1 = stockNumbers.TryGetValue(it.Partnumber, out object value1);
|
||||
int stockNumber = found1 && value1 != null ? Convert.ToInt32(value1) : 0;
|
||||
bool found2 = realNumbers.TryGetValue(it.Partnumber, out int realNumber);
|
||||
|
||||
return new WmPolishInventoryExportDto
|
||||
{
|
||||
零件号 = it.Partnumber,
|
||||
颜色 = it.Color,
|
||||
规格 = it.Specification,
|
||||
描述 = it.Description,
|
||||
盘点时间 = dateTime,
|
||||
盘点数 = stockNumber,
|
||||
现有库存 = found2 ? realNumber : 0,
|
||||
盘点数 = it.Quantity ?? 0,
|
||||
现有库存 = it.RealQuantity,
|
||||
盘点时间 = it.CreatedTime,
|
||||
};
|
||||
})
|
||||
.ToList();
|
||||
@@ -867,6 +899,7 @@ namespace ZR.Service.mes.wms
|
||||
/// <returns></returns>
|
||||
public (string, object, object) ImportExcel(List<WmPolishInventoryExportDto> importList)
|
||||
{
|
||||
|
||||
List<WmPolishInventory> wmPolishInventorylist = importList
|
||||
.Select(it => new WmPolishInventory
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user