diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsBatchSearchController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsBatchSearchController.cs
index f1dc383c..f32dc1a0 100644
--- a/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsBatchSearchController.cs
+++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsBatchSearchController.cs
@@ -32,24 +32,62 @@ namespace ZR.Admin.WebApi.Controllers
/// 根据查询条件聚合批量查询出库数据,并生成树列表数据
///
///
- [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 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)
{
diff --git a/ZR.Model/MES/wms/Dto/WmGoodsBatchSearchDto.cs b/ZR.Model/MES/wms/Dto/WmGoodsBatchSearchDto.cs
index 35107dda..537360f7 100644
--- a/ZR.Model/MES/wms/Dto/WmGoodsBatchSearchDto.cs
+++ b/ZR.Model/MES/wms/Dto/WmGoodsBatchSearchDto.cs
@@ -7,6 +7,10 @@ namespace ZR.Model.MES.wms.Dto
///
public class WmGoodsBatchSearchDto : PagerInfo
{
+ ///
+ /// 查询类别:1-入库 2-出库
+ ///
+ public int Category { get; set; } = 1;
///
/// 查询类别:1-树父节点 2-树子节点
///
diff --git a/ZR.Service/mes/wms/IService/IWmGoodsBatchSearchService.cs b/ZR.Service/mes/wms/IService/IWmGoodsBatchSearchService.cs
index 3569358e..c246bbab 100644
--- a/ZR.Service/mes/wms/IService/IWmGoodsBatchSearchService.cs
+++ b/ZR.Service/mes/wms/IService/IWmGoodsBatchSearchService.cs
@@ -13,17 +13,53 @@ namespace ZR.Service.mes.wms.IService
public interface IWmGoodsBatchSearchService : IBaseService
{
///
- /// 树表最外层查询
+ /// 1.树表最外层查询(入库记录根据批次号聚合)
+ ///
+ ///
+ ///
+ PagedInfo GetBatchNowProductionByPackageCodeShort(WmGoodsBatchSearchDto parm);
+ ///
+ /// 2.树表子节点懒加载查询(入库记录根据批次号聚合)
+ ///
+ ///
+ ///
+ PagedInfo GetBatchNowProductionTreeLazyByPackageCodeShort(WmGoodsBatchSearchDto parm);
+ ///
+ /// 3.树表最外层查询(入库记录根据零件号聚合)
+ ///
+ ///
+ ///
+ PagedInfo GetBatchNowProductionByPartnumber(WmGoodsBatchSearchDto parm);
+ ///
+ /// 4.树表子节点懒加载查询(入库记录根据零件号聚合)
+ ///
+ ///
+ ///
+ PagedInfo GetBatchNowProductionTreeLazyByPartnumber(WmGoodsBatchSearchDto parm);
+ ///
+ /// 5.树表最外层查询(出库记录根据批次号聚合)
///
///
///
PagedInfo GetBatchOutRecordByPackageCodeShort(WmGoodsBatchSearchDto parm);
///
- /// 树表子节点懒加载查询
+ /// 6.树表子节点懒加载查询(出库记录根据批次号聚合)
///
///
///
PagedInfo GetBatchOutRecordTreeLazyByPackageCodeShort(WmGoodsBatchSearchDto parm);
+ ///
+ /// 7.树表最外层查询(出库记录根据零件号聚合)
+ ///
+ ///
+ ///
+ PagedInfo GetBatchOutRecordByPartnumber(WmGoodsBatchSearchDto parm);
+ ///
+ /// 8.树表子节点懒加载查询(出库记录根据零件号聚合)
+ ///
+ ///
+ ///
+ PagedInfo GetBatchOutRecordTreeLazyByPartnumber(WmGoodsBatchSearchDto parm);
}
}
diff --git a/ZR.Service/mes/wms/WmGoodsBatchSearchService.cs b/ZR.Service/mes/wms/WmGoodsBatchSearchService.cs
index 61ac581b..02ce2fac 100644
--- a/ZR.Service/mes/wms/WmGoodsBatchSearchService.cs
+++ b/ZR.Service/mes/wms/WmGoodsBatchSearchService.cs
@@ -25,6 +25,211 @@ namespace ZR.Service.Business
[AppService(ServiceType = typeof(IWmGoodsBatchSearchService), ServiceLifetime = LifeTime.Transient)]
public class WmGoodsBatchSearchService : BaseService, IWmGoodsBatchSearchService
{
+
+ public PagedInfo GetBatchNowProductionByPackageCodeShort(WmGoodsBatchSearchDto parm)
+ {
+ try
+ {
+ // 查询条件
+ var exp = Expressionable.Create()
+ .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 result = Context.SqlQueryable(sql)
+ .Where(exp)
+ .Select()
+ .ToPage(parm);
+ foreach (WmGoodsBatchTableDto item in result.Result)
+ {
+ WmMaterial material = Context.Queryable()
+ .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 GetBatchNowProductionTreeLazyByPackageCodeShort(WmGoodsBatchSearchDto parm)
+ {
+ try
+ {
+ PagedInfo result = new PagedInfo();
+ // 出库记录
+ List list = Context.Queryable()
+ .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()
+ .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 GetBatchNowProductionByPartnumber(WmGoodsBatchSearchDto parm)
+ {
+ try
+ {
+ // 查询条件
+ var exp = Expressionable.Create()
+ .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 result = Context.SqlQueryable(sql)
+ .Where(exp)
+ .Select()
+ .ToPage(parm);
+ foreach (WmGoodsBatchTableDto item in result.Result)
+ {
+ WmMaterial material = Context.Queryable()
+ .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 GetBatchNowProductionTreeLazyByPartnumber(WmGoodsBatchSearchDto parm)
+ {
+ try
+ {
+ PagedInfo result = new PagedInfo();
+ // 出库记录
+ List list = Context.Queryable()
+ .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()
+ .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 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()
.ToPage(parm);
- foreach(WmGoodsBatchTableDto item in result.Result)
+ foreach (WmGoodsBatchTableDto item in result.Result)
{
WmMaterial material = Context.Queryable()
.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 GetBatchOutRecordTreeLazyByPackageCodeShort(WmGoodsBatchSearchDto parm)
{
try
@@ -121,9 +328,111 @@ namespace ZR.Service.Business
result.Result = list;
return result;
}
- catch {
+ catch
+ {
return null;
}
}
+
+ public PagedInfo GetBatchOutRecordByPartnumber(WmGoodsBatchSearchDto parm)
+ {
+ try
+ {
+ // 查询条件
+ var exp = Expressionable.Create()
+ .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 result = Context.SqlQueryable(sql)
+ .Where(exp)
+ .Select()
+ .ToPage(parm);
+ foreach (WmGoodsBatchTableDto item in result.Result)
+ {
+ WmMaterial material = Context.Queryable()
+ .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 GetBatchOutRecordTreeLazyByPartnumber(WmGoodsBatchSearchDto parm)
+ {
+ try
+ {
+ PagedInfo result = new PagedInfo();
+ // 出库记录
+ List list = Context.Queryable()
+ .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()
+ .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;
+ }
+ }
+
}
}
\ No newline at end of file