提报质量bug

This commit is contained in:
2024-08-23 16:16:20 +08:00
parent fd150f1804
commit 649867d2d0
8 changed files with 189 additions and 39 deletions

View File

@@ -1,5 +1,6 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
@@ -421,43 +422,67 @@ namespace Tnb.QcMgr
JoinType.Left,a.id == e.planid,
});
GetQuery(Query, entity);
// if (!string.IsNullOrEmpty(entity.materialid))
// {
// Query = Query.Where((a, b, c, d, e) => c.materialid==entity.materialid);
// }
// if (!string.IsNullOrEmpty(entity.processid))
// {
// Query = Query.Where((a, b, c, d, e) => d.processid==entity.processid);
// }
// if (!string.IsNullOrEmpty(entity.workid))
// {
// Query = Query.Where((a, b, c, d, e) => e.workid==entity.workid);
// }
Query = Query.Where((a, b, c, d, e)=>c.materialid==entity.materialid || d.processid==entity.processid || e.workid==entity.workid);
List<QcCheckPlanH> list = await Query.ToListAsync();
List<string> removes = new();
foreach (QcCheckPlanH data in list)
if (list.IsEmpty())
{
if (!string.IsNullOrEmpty(entity.materialid))
{
if (_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id).Any())
{
if (!_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id && p.materialid == entity.materialid).Any())
{
removes.Add(data.id);
}
}
}
if (!string.IsNullOrEmpty(entity.processid))
{
if (_repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == data.id).Any())
{
if (!_repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == data.id && p.processid == entity.processid).Any())
{
removes.Add(data.id);
}
}
}
if (!string.IsNullOrEmpty(entity.workid))
{
if (_repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == data.id).Any())
{
if (!_repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == data.id && p.workid == entity.workid).Any())
{
removes.Add(data.id);
}
}
}
throw Oops.Bah("未找到质检方案");
}
if (list.Count > 1)
{
throw Oops.Bah("找到多个质检方案");
}
// List<string> removes = new();
// foreach (QcCheckPlanH data in list)
// {
// if (!string.IsNullOrEmpty(entity.materialid))
// {
// // if (_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id).Any())
// // {
// // if (!_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id && p.materialid == entity.materialid).Any())
// // {
// // removes.Add(data.id);
// // }
// // }
// }
// if (!string.IsNullOrEmpty(entity.processid))
// {
// if (_repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == data.id).Any())
// {
// if (!_repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == data.id && p.processid == entity.processid).Any())
// {
// removes.Add(data.id);
// }
//
// }
// }
// if (!string.IsNullOrEmpty(entity.workid))
// {
// if (_repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == data.id).Any())
// {
// if (!_repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == data.id && p.workid == entity.workid).Any())
// {
// removes.Add(data.id);
// }
// }
// }
// }
//
// list = list.Where(p => !removes.Contains(p.id)).ToList();
// .WhereIF(!string.IsNullOrEmpty(entity.materialid), (a, b, c, d, e) => c.materialid == entity.materialid)
// .WhereIF(!string.IsNullOrEmpty(entity.processid), (a, b, c, d, e) => d.processid == entity.processid)