Explorar el Código

优化查询逻辑,使用 AsQueryable 方法

将对 `_billBomsetgrpRepository` 的查询从 `GetList` 方法更改为使用 `AsQueryable` 方法,添加了条件以筛选符合特定条件的记录,包括 `BomCode` 和 `ProMaterCode` 的匹配,以及 `IsStop` 字段的检查。最终结果按 `EditTime` 排序并取第一条记录,提升了查询的灵活性和性能,确保了代码的一致性。
林豪 左 hace 4 semanas
padre
commit
680c0c92c2
Se han modificado 1 ficheros con 4 adiciones y 7 borrados
  1. 4 7
      wms.service/Service/FJService.cs

+ 4 - 7
wms.service/Service/FJService.cs

@@ -422,10 +422,9 @@ namespace wms.service.Service
             //后续一个配方会有多个垛型
             if (reqDto.MatCode.StartsWith("57")) //是芯股
             {
-                stack = _billBomsetgrpRepository.GetList(p =>
+                stack = _billBomsetgrpRepository.AsQueryable().Where(p =>
                         (p.BomCode == procode || procode.Contains(p.BomCode)) && p.ProMaterCode.StartsWith("57") &&
-                        p.IsStop == 0)
-                    .OrderBy(x => x.EditTime).First();
+                        p.IsStop == 0).OrderBy(x => x.EditTime).First();
                 if (stack == null)
                 {
                     res.ResCode = ResponseStatusCodeEnum.ErrParam.GetHashCode();
@@ -436,11 +435,9 @@ namespace wms.service.Service
             }
             else //不是芯股
             {
-                var stackList = _billBomsetgrpRepository.GetList(p =>
+                stack = _billBomsetgrpRepository.GetList(p =>
                     (p.BomCode == procode || procode.Contains(p.BomCode)) && !p.ProMaterCode.StartsWith("57") &&
-                    p.IsStop == 0).ToList();
-
-                stack = stackList.OrderBy(x => x.EditTime).First();
+                    p.IsStop == 0).OrderBy(x => x.EditTime).First(); ;
 
                 if (stack == null)
                 {