1
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using ZR.Model;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.mes.qc;
|
||||
using ZR.Service.mes.wms.IService;
|
||||
|
||||
namespace ZR.Service.mes.wms
|
||||
@@ -51,7 +53,7 @@ namespace ZR.Service.mes.wms
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderByDescending(it => it.UpdatedTime)
|
||||
.OrderBy(it => it.Partnumber)
|
||||
.ToPage<WmOneTimeInventory, WmOneTimeInventoryDto>(parm);
|
||||
if (response.Result.Count > 0)
|
||||
{
|
||||
@@ -406,5 +408,95 @@ namespace ZR.Service.mes.wms
|
||||
.Where(it => it.Status == 1)
|
||||
.Sum(it => it.Quantity) ?? 0;
|
||||
}
|
||||
|
||||
// Util 获取物料清单,不包含毛坯
|
||||
public List<WmMaterial> GetWmMaterialList(string partnumber)
|
||||
{
|
||||
// 获取物料信息
|
||||
return Context
|
||||
.Queryable<WmMaterial>()
|
||||
.WhereIF(
|
||||
!string.IsNullOrEmpty(partnumber),
|
||||
it => it.Partnumber.Contains(partnumber)
|
||||
)
|
||||
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
|
||||
.Where(it => it.Type == 1)
|
||||
.Where(it => it.Status == 1)
|
||||
.Distinct()
|
||||
.OrderBy(it => it.Description)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<WmOneTimeInventoryExportDto> GetExportList(WmOneTimeInventoryQueryDto parm)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<WmMaterial> materials = GetWmMaterialList(parm.Partnumber);
|
||||
|
||||
// 获取所有partnumber列表
|
||||
List<string> partnumbers = materials
|
||||
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
|
||||
.Select(it => it.Partnumber)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
// 批量获取盘点数和现有库存
|
||||
Dictionary<string, object> stockNumbers = GetBatchOneTimeStockPartNum(partnumbers);
|
||||
Dictionary<string, int> realNumbers = GetBatchOneTimeRealPartNum(partnumbers);
|
||||
|
||||
// 构建导出数据
|
||||
List<WmOneTimeInventoryExportDto> exportDto = materials
|
||||
.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 WmOneTimeInventoryExportDto
|
||||
{
|
||||
零件号 = it.Partnumber,
|
||||
颜色 = it.Color,
|
||||
规格 = it.Specification,
|
||||
描述 = it.Description,
|
||||
盘点数 = stockNumber,
|
||||
现有库存 = found2 ? realNumber : 0,
|
||||
};
|
||||
})
|
||||
.ToList();
|
||||
return exportDto;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Util 获取指定抛光库零件盘点库存
|
||||
public Dictionary<string, object> GetBatchOneTimeStockPartNum(List<string> partnumbers)
|
||||
{
|
||||
return Context
|
||||
.Queryable<WmOneTimeInventory>()
|
||||
.Where(it => partnumbers.Contains(it.Partnumber))
|
||||
.GroupBy(it => it.Partnumber)
|
||||
.ToDictionary(g => g.Partnumber, g => SqlFunc.AggregateSum(g.Quantity) ?? 0);
|
||||
}
|
||||
|
||||
// Util 获取指定抛光库零件加报表后库存
|
||||
public Dictionary<string, int> GetBatchOneTimeRealPartNum(List<string> partnumbers)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 盘点时间
|
||||
DateTime checkTime = new(2024, 10, 20, 0, 0, 0);
|
||||
CommonFQCService commonFQCService = new();
|
||||
// 获取报表数据
|
||||
// 一次合格计算后库存 = 盘点库存 + 产线合格 + 抛光合格 - gp12投入 - 后道直接出库
|
||||
return commonFQCService.GetBatchOneTimePartRealStock(partnumbers, checkTime);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user