This commit is contained in:
2024-11-25 16:34:07 +08:00
parent 65ee306fe1
commit 59960809b8
4 changed files with 148 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ using Infrastructure.Attribute;
using Infrastructure.Extensions;
using SqlSugar;
using ZR.Model;
using ZR.Model.MES.qc;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Repository;
@@ -44,7 +45,7 @@ namespace ZR.Service.mes.wms
)
.Where((m, p) => m.Status == 1)
.Where((m, p) => m.Type == 1)
.WhereIF(string.IsNullOrEmpty(parm.Partnumber), (m, p) => p.Status == 1)
// .WhereIF(string.IsNullOrEmpty(parm.Partnumber), (m, p) => p.Status == 1)
.OrderBy((m, p) => m.Description)
.Select(
(m, p) =>
@@ -71,6 +72,74 @@ namespace ZR.Service.mes.wms
}
)
.ToList();
if (string.IsNullOrEmpty(parm.Partnumber))
{
// 盘点时间
DateTime? checkTime =
Context
.Queryable<WmOneTimeInventory>()
.Where(it => it.Status == 1)
.Select(it => it.CreatedTime)
.First() ?? new DateTime(2024, 11, 16, 12, 0, 0);
list = list.Where(ls =>
{
if (ls.Status != null)
{
return true;
}
if (
!string.IsNullOrEmpty(ls.Description) && ls.Description.Contains("倒车雷达")
)
{
return false;
}
bool bol1 = Context
.Queryable<QcQualityStatisticsFirst>()
.Where(it => it.FinishedPartNumber == ls.Partnumber)
.Where(it => it.StartTime >= checkTime)
.Any();
bool bol2 = Context
.Queryable<WmPolishWorkQualityStatistics>()
.Where(it => it.Partnumber == ls.Partnumber)
.Where(it => it.StartTime >= checkTime)
.Any();
bool bol3 = Context
.Queryable<WmPolishQualityStatistics>()
.Where(it => it.Partnumber == ls.Partnumber)
.Where(it => it.StartTime >= checkTime)
.Any();
bool bol4 = Context
.Queryable<WmGp12QualityStatistics>()
.Where(it => it.Partnumber == ls.Partnumber)
.Where(it => it.StartTime >= checkTime)
.Any();
if (bol1)
{
return true;
}
else if (bol2)
{
return true;
}
else if (bol3)
{
return true;
}
else if (bol4)
{
return true;
}
else
{
return false;
}
})
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
.DistinctBy(it => it.Partnumber)
.ToList();
}
foreach (WmOneTimeInventoryDto item in list)
{
// 获取实际库存

View File

@@ -13,6 +13,7 @@ using Newtonsoft.Json.Linq;
using SqlSugar;
using ZR.Common;
using ZR.Model;
using ZR.Model.MES.qc;
using ZR.Model.MES.qc.DTO;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
@@ -57,7 +58,7 @@ namespace ZR.Service.mes.wms
)
.Where((m, p) => m.Status == 1)
.Where((m, p) => m.Type == 1)
.WhereIF(string.IsNullOrEmpty(parm.Partnumber), (m, p) => p.Status == 1)
//.WhereIF(string.IsNullOrEmpty(parm.Partnumber), (m, p) => p.Status == 1)
.OrderBy((m, p) => m.Description)
.Select(
(m, p) =>
@@ -84,6 +85,76 @@ namespace ZR.Service.mes.wms
}
)
.ToList();
//TODO 优化1
if (string.IsNullOrEmpty(parm.Partnumber))
{
// 盘点时间
DateTime? checkTime =
Context
.Queryable<WmPolishInventory>()
.Where(it => it.Status == 1)
.Select(it => it.CreatedTime)
.First() ?? new DateTime(2024, 11, 16, 12, 0, 0);
list = list.Where(ls =>
{
if (ls.Status != null)
{
return true;
}
if (
!string.IsNullOrEmpty(ls.Description) && ls.Description.Contains("倒车雷达")
)
{
return false;
}
bool bol1 = Context
.Queryable<QcQualityStatisticsFirst>()
.Where(it => it.FinishedPartNumber == ls.Partnumber)
.Where(it => it.StartTime >= checkTime)
.Any();
bool bol2 = Context
.Queryable<WmPolishWorkQualityStatistics>()
.Where(it => it.Partnumber == ls.Partnumber)
.Where(it => it.StartTime >= checkTime)
.Any();
bool bol3 = Context
.Queryable<WmPolishQualityStatistics>()
.Where(it => it.Partnumber == ls.Partnumber)
.Where(it => it.StartTime >= checkTime)
.Any();
bool bol4 = Context
.Queryable<WmGp12QualityStatistics>()
.Where(it => it.Partnumber == ls.Partnumber)
.Where(it => it.StartTime >= checkTime)
.Any();
if (bol1)
{
return true;
}
else if (bol2)
{
return true;
}
else if (bol3)
{
return true;
}
else if (bol4)
{
return true;
}
else
{
return false;
}
})
.Where(it => !string.IsNullOrEmpty(it.Partnumber))
.DistinctBy(it => it.Partnumber)
.ToList();
}
foreach (WmPolishInventoryDto item in list)
{
// 获取实际库存