仓库-批量查看功能完成

This commit is contained in:
2024-04-26 17:59:59 +08:00
parent e838aa3eae
commit 1f9b493c24
4 changed files with 401 additions and 14 deletions

View File

@@ -32,24 +32,62 @@ namespace ZR.Admin.WebApi.Controllers
/// 根据查询条件聚合批量查询出库数据,并生成树列表数据
/// </summary>
/// <returns></returns>
[HttpPost("getBatchOutRecordTreeTableData")]
[HttpPost("getBatchTreeTableData")]
[Log(Title = "根据查询条件聚合批量查询出库数据,并生成树列表数据", BusinessType = BusinessType.QUERY)]
public IActionResult GetBatchOutRecordTreeTableData([FromBody] WmGoodsBatchSearchDto parm)
public IActionResult GetBatchTreeTableData([FromBody] WmGoodsBatchSearchDto parm)
{
if (parm is null)
{
throw new ArgumentNullException(nameof(parm));
}
PagedInfo<WmGoodsBatchTableDto> result = null;
// 树父列表
if (parm.Model == 1 && parm.Type == 1)
// 入库
if (parm.Category == 1)
{
result = _wmGoodsBatchSearchService.GetBatchOutRecordByPackageCodeShort(parm);
// 按批次号
// 树父列表
if (parm.Model == 1 && parm.Type == 1)
{
result = _wmGoodsBatchSearchService.GetBatchNowProductionByPackageCodeShort(parm);
}
// 树子列表
else if (parm.Model == 1 && parm.Type == 2)
{
result = _wmGoodsBatchSearchService.GetBatchNowProductionTreeLazyByPackageCodeShort(parm);
}
// 按零件号
else if (parm.Model == 2 && parm.Type == 1)
{
result = _wmGoodsBatchSearchService.GetBatchNowProductionByPartnumber(parm);
}
else if (parm.Model == 2 && parm.Type == 2)
{
result = _wmGoodsBatchSearchService.GetBatchNowProductionTreeLazyByPartnumber(parm);
}
}
// 树子列表
else if (parm.Model == 1 && parm.Type == 2)
// 出库
else if (parm.Category == 2)
{
result = _wmGoodsBatchSearchService.GetBatchOutRecordTreeLazyByPackageCodeShort(parm);
// 按批次号
// 树父列表
if (parm.Model == 1 && parm.Type == 1)
{
result = _wmGoodsBatchSearchService.GetBatchOutRecordByPackageCodeShort(parm);
}
// 树子列表
else if (parm.Model == 1 && parm.Type == 2)
{
result = _wmGoodsBatchSearchService.GetBatchOutRecordTreeLazyByPackageCodeShort(parm);
}
// 按零件号
else if (parm.Model == 2 && parm.Type == 1)
{
result = _wmGoodsBatchSearchService.GetBatchOutRecordByPartnumber(parm);
}
else if (parm.Model == 2 && parm.Type == 2)
{
result = _wmGoodsBatchSearchService.GetBatchOutRecordTreeLazyByPartnumber(parm);
}
}
if (result is null)
{

View File

@@ -7,6 +7,10 @@ namespace ZR.Model.MES.wms.Dto
/// </summary>
public class WmGoodsBatchSearchDto : PagerInfo
{
/// <summary>
/// 查询类别:1-入库 2-出库
/// </summary>
public int Category { get; set; } = 1;
/// <summary>
/// 查询类别:1-树父节点 2-树子节点
/// </summary>

View File

@@ -13,17 +13,53 @@ namespace ZR.Service.mes.wms.IService
public interface IWmGoodsBatchSearchService : IBaseService<WmGoodsBatchSearchDto>
{
/// <summary>
/// 树表最外层查询
/// 1.树表最外层查询(入库记录根据批次号聚合)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
PagedInfo<WmGoodsBatchTableDto> GetBatchNowProductionByPackageCodeShort(WmGoodsBatchSearchDto parm);
/// <summary>
/// 2.树表子节点懒加载查询(入库记录根据批次号聚合)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
PagedInfo<WmGoodsBatchTableDto> GetBatchNowProductionTreeLazyByPackageCodeShort(WmGoodsBatchSearchDto parm);
/// <summary>
/// 3.树表最外层查询(入库记录根据零件号聚合)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
PagedInfo<WmGoodsBatchTableDto> GetBatchNowProductionByPartnumber(WmGoodsBatchSearchDto parm);
/// <summary>
/// 4.树表子节点懒加载查询(入库记录根据零件号聚合)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
PagedInfo<WmGoodsBatchTableDto> GetBatchNowProductionTreeLazyByPartnumber(WmGoodsBatchSearchDto parm);
/// <summary>
/// 5.树表最外层查询(出库记录根据批次号聚合)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
PagedInfo<WmGoodsBatchTableDto> GetBatchOutRecordByPackageCodeShort(WmGoodsBatchSearchDto parm);
/// <summary>
/// 树表子节点懒加载查询
/// 6.树表子节点懒加载查询(出库记录根据批次号聚合)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
PagedInfo<WmGoodsBatchTableDto> GetBatchOutRecordTreeLazyByPackageCodeShort(WmGoodsBatchSearchDto parm);
/// <summary>
/// 7.树表最外层查询(出库记录根据零件号聚合)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
PagedInfo<WmGoodsBatchTableDto> GetBatchOutRecordByPartnumber(WmGoodsBatchSearchDto parm);
/// <summary>
/// 8.树表子节点懒加载查询(出库记录根据零件号聚合)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
PagedInfo<WmGoodsBatchTableDto> GetBatchOutRecordTreeLazyByPartnumber(WmGoodsBatchSearchDto parm);
}
}

View File

@@ -25,6 +25,211 @@ namespace ZR.Service.Business
[AppService(ServiceType = typeof(IWmGoodsBatchSearchService), ServiceLifetime = LifeTime.Transient)]
public class WmGoodsBatchSearchService : BaseService<WmGoodsBatchSearchDto>, IWmGoodsBatchSearchService
{
public PagedInfo<WmGoodsBatchTableDto> GetBatchNowProductionByPackageCodeShort(WmGoodsBatchSearchDto parm)
{
try
{
// 查询条件
var exp = Expressionable.Create<WmGoodsNowProduction>()
.AndIF(!string.IsNullOrEmpty(parm.Partnumber), it => it.Partnumber.Contains(parm.Partnumber))
// 根据sql语句进行切换
.AndIF(!string.IsNullOrEmpty(parm.PackageCode), it => it.PackageCode.Contains(parm.PackageCode))
.ToExpression();
string sql = "SELECT\n" +
" MAX( id ) AS ID,\n" +
" SUBSTRING_INDEX( package_code_client, '_', 1 ) AS PackageCodeClient_son,\n" +
" NULL AS PackageCodeClient_short_parent,\n" +
" MAX( partnumber ) AS Partnumber,\n" +
" '' AS Description,\n" +
" SUBSTRING_INDEX( package_code_client, '_', 1 ) AS PackageCode,\n" +
" SUBSTRING_INDEX( package_code_client, '_', 1 ) AS package_code,\n" +
" MAX( location_code ) AS LocationCode,\n" +
" COUNT( * ) AS PackageNum,\n" +
" SUM( goods_num_logic ) AS GoodsNumLogic,\n" +
" SUM( goods_num_action ) AS GoodsNumAction,\n" +
" MAX( remark ) AS Remark,\n" +
" MAX( entry_warehouse_time ) AS EntryWarehouseTime,\n" +
" TRUE AS HasChild \n" +
"FROM\n" +
" wm_goods_now_production \n" +
"GROUP BY\n" +
" PackageCode \n" +
"ORDER BY\n" +
" EntryWarehouseTime DESC";
PagedInfo<WmGoodsBatchTableDto> result = Context.SqlQueryable<WmGoodsNowProduction>(sql)
.Where(exp)
.Select<WmGoodsBatchTableDto>()
.ToPage(parm);
foreach (WmGoodsBatchTableDto item in result.Result)
{
WmMaterial material = Context.Queryable<WmMaterial>()
.Where(it => it.Partnumber.Contains(item.Partnumber))
.First();
if (material == null)
{
item.Description = "此零件号不在物料清单内!";
continue;
}
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
}
return result;
}
catch
{
return null;
}
}
public PagedInfo<WmGoodsBatchTableDto> GetBatchNowProductionTreeLazyByPackageCodeShort(WmGoodsBatchSearchDto parm)
{
try
{
PagedInfo<WmGoodsBatchTableDto> result = new PagedInfo<WmGoodsBatchTableDto>();
// 出库记录
List<WmGoodsBatchTableDto> list = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.PackageCodeClient.Contains(parm.PackageCode))
.Select(it => new WmGoodsBatchTableDto
{
Id = it.Id,
PackageCode = it.PackageCodeClient,
PackageCodeClient_son = null,
PackageCodeClient_short_parent = parm.PackageCode,
Partnumber = it.Partnumber,
Description = "",
LocationCode = it.LocationCode,
PackageNum = 1,
GoodsNumLogic = (int)it.GoodsNumLogic,
GoodsNumAction = (int)it.GoodsNumAction,
EntryWarehouseTime = it.EntryWarehouseTime,
Remark = it.Remark,
HasChild = false
})
.OrderBy(it => it.Id)
.ToList();
foreach (WmGoodsBatchTableDto item in list)
{
WmMaterial material = Context.Queryable<WmMaterial>()
.Where(it => it.Partnumber.Contains(item.Partnumber))
.First();
if (material == null)
{
item.Description = "此零件号不在物料清单内!";
continue;
}
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
}
result.Result = list;
return result;
}
catch
{
return null;
}
}
public PagedInfo<WmGoodsBatchTableDto> GetBatchNowProductionByPartnumber(WmGoodsBatchSearchDto parm)
{
try
{
// 查询条件
var exp = Expressionable.Create<WmGoodsNowProduction>()
.AndIF(!string.IsNullOrEmpty(parm.Partnumber), it => it.Partnumber.Contains(parm.Partnumber))
// 根据sql语句进行切换
//.AndIF(!string.IsNullOrEmpty(parm.PackageCode), it => it.PackageCode.Contains(parm.PackageCode))
.ToExpression();
string sql = "SELECT\n" +
" MAX( id ) AS ID,\n" +
" MAX( partnumber ) AS PackageCodeClient_son,\n" +
" NULL AS PackageCodeClient_short_parent,\n" +
" MAX( partnumber ) AS Partnumber,\n" +
" '' AS Description,\n" +
" '' AS PackageCode,\n" +
" '' AS LocationCode,\n" +
" COUNT( * ) AS PackageNum,\n" +
" SUM( goods_num_logic ) AS GoodsNumLogic,\n" +
" SUM( goods_num_action ) AS GoodsNumAction,\n" +
" '' AS Remark,\n" +
" NULL AS EntryWarehouseTime,\n" +
" TRUE AS HasChild \n" +
"FROM\n" +
" wm_goods_now_production \n" +
"GROUP BY\n" +
" Partnumber \n" +
"ORDER BY\n" +
" ID DESC";
PagedInfo<WmGoodsBatchTableDto> result = Context.SqlQueryable<WmGoodsNowProduction>(sql)
.Where(exp)
.Select<WmGoodsBatchTableDto>()
.ToPage(parm);
foreach (WmGoodsBatchTableDto item in result.Result)
{
WmMaterial material = Context.Queryable<WmMaterial>()
.Where(it => it.Partnumber.Contains(item.Partnumber))
.First();
if (material == null)
{
item.Description = "此零件号不在物料清单内!";
continue;
}
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
}
return result;
}
catch
{
return null;
}
}
public PagedInfo<WmGoodsBatchTableDto> GetBatchNowProductionTreeLazyByPartnumber(WmGoodsBatchSearchDto parm)
{
try
{
PagedInfo<WmGoodsBatchTableDto> result = new PagedInfo<WmGoodsBatchTableDto>();
// 出库记录
List<WmGoodsBatchTableDto> list = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.Partnumber == parm.Partnumber)
.Select(it => new WmGoodsBatchTableDto
{
Id = it.Id,
PackageCode = it.PackageCodeClient,
PackageCodeClient_son = null,
PackageCodeClient_short_parent = it.Partnumber,
Partnumber = it.Partnumber,
Description = "",
LocationCode = it.LocationCode,
PackageNum = 1,
GoodsNumLogic = (int)it.GoodsNumLogic,
GoodsNumAction = (int)it.GoodsNumAction,
EntryWarehouseTime = it.EntryWarehouseTime,
Remark = it.Remark,
HasChild = false
})
.OrderBy(it => it.Id)
.ToList();
foreach (WmGoodsBatchTableDto item in list)
{
WmMaterial material = Context.Queryable<WmMaterial>()
.Where(it => it.Partnumber.Contains(item.Partnumber))
.First();
if (material == null)
{
item.Description = "此零件号不在物料清单内!";
continue;
}
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
}
result.Result = list;
return result;
}
catch
{
return null;
}
}
public PagedInfo<WmGoodsBatchTableDto> GetBatchOutRecordByPackageCodeShort(WmGoodsBatchSearchDto parm)
{
try
@@ -42,11 +247,12 @@ namespace ZR.Service.Business
" MAX( partnumber ) AS Partnumber,\n" +
" '' AS Description,\n" +
" SUBSTRING_INDEX( package_code_client, '_', 1 ) AS PackageCode,\n" +
" SUBSTRING_INDEX( package_code_client, '_', 1 ) AS package_code,\n" +
" MAX( location_code ) AS LocationCode,\n" +
" COUNT( * ) AS PackageNum,\n" +
" SUM( goods_num_logic ) AS GoodsNumLogic,\n" +
" SUM( goods_num_action ) AS GoodsNumAction,\n" +
" MAX( Remark ) AS Remark,\n" +
" MAX( remark ) AS Remark,\n" +
" MAX( out_time ) AS OutTime,\n" +
" TRUE AS HasChild \n" +
"FROM\n" +
@@ -59,12 +265,12 @@ namespace ZR.Service.Business
.Where(exp)
.Select<WmGoodsBatchTableDto>()
.ToPage(parm);
foreach(WmGoodsBatchTableDto item in result.Result)
foreach (WmGoodsBatchTableDto item in result.Result)
{
WmMaterial material = Context.Queryable<WmMaterial>()
.Where(it => it.Partnumber.Contains(item.Partnumber))
.First();
if(material == null)
if (material == null)
{
item.Description = "此零件号不在物料清单内!";
continue;
@@ -80,6 +286,7 @@ namespace ZR.Service.Business
}
public PagedInfo<WmGoodsBatchTableDto> GetBatchOutRecordTreeLazyByPackageCodeShort(WmGoodsBatchSearchDto parm)
{
try
@@ -121,9 +328,111 @@ namespace ZR.Service.Business
result.Result = list;
return result;
}
catch {
catch
{
return null;
}
}
public PagedInfo<WmGoodsBatchTableDto> GetBatchOutRecordByPartnumber(WmGoodsBatchSearchDto parm)
{
try
{
// 查询条件
var exp = Expressionable.Create<WmGoodsOutRecord>()
.AndIF(!string.IsNullOrEmpty(parm.Partnumber), it => it.Partnumber.Contains(parm.Partnumber))
// 根据sql语句进行切换
//.AndIF(!string.IsNullOrEmpty(parm.PackageCode), it => it.PackageCode.Contains(parm.PackageCode))
.ToExpression();
string sql = "SELECT\n" +
" MAX( id ) AS ID,\n" +
" MAX( partnumber ) AS PackageCodeClient_son,\n" +
" NULL AS PackageCodeClient_short_parent,\n" +
" MAX( partnumber ) AS Partnumber,\n" +
" '' AS Description,\n" +
" '' AS PackageCode,\n" +
" '' AS LocationCode,\n" +
" COUNT( * ) AS PackageNum,\n" +
" SUM( goods_num_logic ) AS GoodsNumLogic,\n" +
" SUM( goods_num_action ) AS GoodsNumAction,\n" +
" '' AS Remark,\n" +
" NULL AS OutTime,\n" +
" TRUE AS HasChild \n" +
"FROM\n" +
" wm_goods_out_record \n" +
"GROUP BY\n" +
" Partnumber \n" +
"ORDER BY\n" +
" ID DESC";
PagedInfo<WmGoodsBatchTableDto> result = Context.SqlQueryable<WmGoodsOutRecord>(sql)
.Where(exp)
.Select<WmGoodsBatchTableDto>()
.ToPage(parm);
foreach (WmGoodsBatchTableDto item in result.Result)
{
WmMaterial material = Context.Queryable<WmMaterial>()
.Where(it => it.Partnumber.Contains(item.Partnumber))
.First();
if (material == null)
{
item.Description = "此零件号不在物料清单内!";
continue;
}
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
}
return result;
}
catch
{
return null;
}
}
public PagedInfo<WmGoodsBatchTableDto> GetBatchOutRecordTreeLazyByPartnumber(WmGoodsBatchSearchDto parm)
{
try
{
PagedInfo<WmGoodsBatchTableDto> result = new PagedInfo<WmGoodsBatchTableDto>();
// 出库记录
List<WmGoodsBatchTableDto> list = Context.Queryable<WmGoodsOutRecord>()
.Where(it => it.Partnumber == parm.Partnumber)
.Select(it => new WmGoodsBatchTableDto
{
Id = it.Id,
PackageCode = it.PackageCodeClient,
PackageCodeClient_son = null,
PackageCodeClient_short_parent = it.Partnumber,
Partnumber = it.Partnumber,
Description = "",
LocationCode = it.LocationCode,
PackageNum = 1,
GoodsNumLogic = (int)it.GoodsNumLogic,
GoodsNumAction = (int)it.GoodsNumAction,
OutTime = it.OutTime,
Remark = it.Remark,
HasChild = false
})
.OrderBy(it => it.Id)
.ToList();
foreach (WmGoodsBatchTableDto item in list)
{
WmMaterial material = Context.Queryable<WmMaterial>()
.Where(it => it.Partnumber.Contains(item.Partnumber))
.First();
if (material == null)
{
item.Description = "此零件号不在物料清单内!";
continue;
}
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
}
result.Result = list;
return result;
}
catch
{
return null;
}
}
}
}