LEIYI 7 months ago
parent
commit
c3abf611d9

+ 13 - 3
OASystem/OASystem.Domain/Dtos/PersonnelModule/GoodsDTO.cs

@@ -199,16 +199,26 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     /// </summary>
     public class GoodsReceiveListDTO : DtoBase
     {
-
         /// <summary>
         /// 物品Id
         /// </summary>
         public int GoodsId { get; set; }
 
         /// <summary>
-        /// 当前登录UserId
+        /// 物品Name
+        /// </summary>
+        public string GoodsName { get; set; }
+
+        /// <summary>
+        /// 类型Ids
         /// </summary>
-        public int CurrUserId { get; set; }
+        public string? TypeLabel { get; set; }
+
+        /// <summary>
+        /// UserIds
+        /// </summary>
+        public string? UserLabel { get; set; }
+
     }
 
     /// <summary>

+ 3 - 1
OASystem/OASystem.Domain/ViewModels/PersonnelModule/GoodsInfoView.cs

@@ -80,6 +80,7 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
     /// </summary>
     public class GoodsReceiveListView: GoodsReceiveView
     {
+        public string GoodsType { get; set; }
     }
     /// <summary>
     /// 
@@ -88,8 +89,9 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
     {
         public string GoodsStorageInfo { get; set; }
         public object? QuantityInfos { get; set; }
+        public object? QuantityInfosStr { get; set; }
 
-        public string GoodsStorageInfoStr { get; set; }
+        public string GoodsType { get; set; }
     }
 
     /// <summary>

+ 43 - 8
OASystem/OASystem.Infrastructure/Repositories/PersonnelModule/GoodsRepository.cs

@@ -292,8 +292,6 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                                           gs.BatchNo,
                                           GoodsName = gi.Name,
                                           gs.Quantity,
-                                          gs.ReceiveQuantity,
-                                          QuantityStatusText = gs.Quantity - gs.ReceiveQuantity == 0 ? "已领用完" : "-",
                                           gs.UnitPrice,
                                           gs.TotalPrice,
                                           gs.SupplierName,
@@ -518,20 +516,54 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
         /// <returns></returns>
         public async Task<JsonView> GoodsReceiveList(GoodsReceiveListDTO dto)
         {
+            //参数处理
+            int[] typeLabel = new int[] { },
+                  userLabel = new int[] { };
+            if (!string.IsNullOrEmpty(dto.TypeLabel))
+            {
+                typeLabel = dto.TypeLabel
+                    .Split(',')
+                    .Select(x =>
+                    {
+                        if (int.TryParse(x, out var id)) return id;
+                        return id;
+                    })
+                    .ToArray();
+            }
+            if (!string.IsNullOrEmpty(dto.UserLabel))
+            {
+                userLabel = dto.UserLabel
+                    .Split(',')
+                    .Select(x =>
+                    {
+                        if (int.TryParse(x, out var id)) return id;
+                        return id;
+                    })
+                    .ToArray();
+            }
+
+            //物品ID和物品名称只能传一个
+            if (dto.GoodsId > 0) dto.GoodsName = string.Empty;
+            if (!string.IsNullOrEmpty(dto.GoodsName)) dto.GoodsId = 0;
+
             RefAsync<int> total = 0;
             var data = await _sqlSugar.Queryable<Pm_GoodsReceive>()
                                       .LeftJoin<Pm_GoodsInfo>((gr, gi) => gr.GoodsId == gi.Id)
-                                      .LeftJoin<Sys_Users>((gr, gi, u1) => gr.AuditUserId == u1.Id)
-                                      .LeftJoin<Sys_Users>((gr, gi, u1, u2) => gr.CreateUserId == u2.Id)
-                                      .Where((gr, gi, u1, u2) => gr.IsDel == 0)
-                                      .WhereIF(dto.GoodsId > 0, (gr, gi, u1, u2) => gr.GoodsId == dto.GoodsId)
-                                      .WhereIF(dto.CurrUserId > 0, (gr, gi, u1, u2) => gr.CreateUserId == dto.CurrUserId)
-                                      .Select((gr, gi, u1, u2) => new GoodsReceiveListView
+                                      .LeftJoin<Sys_SetData>((gr, gi,sd) => gi.Type == sd.Id)
+                                      .LeftJoin<Sys_Users>((gr, gi,sd,u1) => gr.AuditUserId == u1.Id)
+                                      .LeftJoin<Sys_Users>((gr, gi,sd, u1, u2) => gr.CreateUserId == u2.Id)
+                                      .Where((gr, gi, sd, u1, u2) => gr.IsDel == 0)
+                                      .WhereIF(dto.GoodsId > 0, (gr, gi, sd, u1, u2) => gr.GoodsId == dto.GoodsId)
+                                      .WhereIF(!string.IsNullOrEmpty(dto.GoodsName), (gr, gi, sd, u1, u2) => gi.Name.Contains(dto.GoodsName))
+                                      .WhereIF(typeLabel.Length > 0, (gr, gi, sd, u1, u2) => typeLabel.Contains(gi.Type))
+                                      .WhereIF(userLabel.Length > 0, (gr, gi, sd, u1, u2) => userLabel.Contains(gr.CreateUserId))
+                                      .Select((gr, gi, sd, u1, u2) => new GoodsReceiveListView
                                       {
                                           Id = gr.Id,
                                           GroupId = gr.GroupId,
                                           GoodsId = gr.GoodsId,
                                           GoodsName = gi.Name,
+                                          GoodsType = sd.Name,
                                           Quantity = gr.Quantity,
                                           Reason = gr.Reason,
                                           Remark = gr.Remark,
@@ -594,6 +626,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                     var subData1 = JsonConvert.DeserializeObject<List<GoodsReceiveLinkStorageView>>(data.GoodsStorageInfo);
                     if (subData1.Count > 0)
                     {
+                        string quantityInfosStr = string.Empty;
                         var storageIds = subData1.Select(x => x.StorageId).ToList();
                         var storages = await _sqlSugar.Queryable<Pm_GoodsStorage>().Where(x => x.IsDel == 0 && storageIds.Contains(x.Id)).ToListAsync();
                         foreach (var item in subData1)
@@ -607,9 +640,11 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                                     BatchNo = storageInfo.BatchNo,
                                     RecsiveQuantity = item.Quantity
                                 });
+                                quantityInfosStr += $"物品名称:{data.GoodsName} 批次号:{storageInfo.BatchNo} 领用数量:{item.Quantity} \r\n";
                             }
                         }
                         data.QuantityInfos = subData;
+                        data.QuantityInfosStr = quantityInfosStr;
                     }
                 }
                 catch (Exception e)