Quellcode durchsuchen

新增物资领用批量处理功能

在 `PersonnelModuleController.cs` 中新增 `GoodsReceiveBatchList` 异步方法,处理物资进销存的批量领用列表请求。

在 `GoodsDTO.cs` 中新增 `GoodsReceiveBatchListDto` 和 `GoodsReceiveBatchListView` 类,分别用于传递请求参数和返回物资详细信息。

在 `GoodsRepository.cs` 中新增 `GoodsReceiveBatchListAsync` 方法,实现从数据库查询物资领用批量列表的逻辑,并返回相应的 JSON 视图。
LEIYI vor 6 Tagen
Ursprung
Commit
ad264f65fb

+ 13 - 0
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -2351,6 +2351,19 @@ WHERE
             return Ok(await _goodsRep.GoodsReceiveBatchOpAsync(dto));
         }
 
+        /// <summary>
+        /// 物资进销存
+        /// 领用 批量领用 List
+        /// </summary>
+        /// <param name="id">id</param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GoodsReceiveBatchList(GoodsReceiveBatchListDto Dto)
+        {
+            return Ok(await _goodsRep.GoodsReceiveBatchListAsync(Dto));
+        }
+
         /// <summary>
         /// 物资进销存
         /// 领用 批量领用 详情

+ 73 - 0
OASystem/OASystem.Domain/Dtos/PersonnelModule/GoodsDTO.cs

@@ -441,6 +441,79 @@ namespace OASystem.Domain.Dtos.PersonnelModule
 
     }
 
+    public class GoodsReceiveBatchListDto: DtoBase
+    {
+        /// <summary>
+        /// 当前登陆人
+        /// </summary>
+        public int CurrUserId { get; set; }
+
+        /// <summary>
+        /// 物品名称
+        /// </summary>
+        public string GoodsName { get; set; }
+
+    }
+
+    public class GoodsReceiveBatchListView
+    {
+        public int Id { get; set; }
+        public string GoodsName { get; set; }
+        /// <summary>
+        /// 累计数量
+        /// </summary>
+        public decimal AccumQty { get; set; }
+
+
+        public string GoodsDetails { get; set; }
+
+        /// <summary>
+        /// 原因
+        /// </summary>
+        public string Reason { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+
+        /// <summary>
+        /// 审核状态
+        /// </summary>
+        public GoodsAuditEnum Status { get; set; }
+
+        /// <summary>
+        /// 审核状态文本描述
+        /// </summary>
+        public string StatusText
+        {
+            get
+            {
+                return Status switch
+                {
+                    GoodsAuditEnum.Pending => GoodsAuditEnum.Pending.GetEnumDescription(),
+                    GoodsAuditEnum.Approved => GoodsAuditEnum.Approved.GetEnumDescription(),
+                    GoodsAuditEnum.UnApproved => GoodsAuditEnum.UnApproved.GetEnumDescription(),
+                    GoodsAuditEnum.OutPending => GoodsAuditEnum.OutPending.GetEnumDescription(),
+                    GoodsAuditEnum.OutConfirming => GoodsAuditEnum.OutConfirming.GetEnumDescription(),
+                    GoodsAuditEnum.OutConfirmed => GoodsAuditEnum.OutConfirmed.GetEnumDescription(),
+                    GoodsAuditEnum.OutRejected => GoodsAuditEnum.OutRejected.GetEnumDescription(),
+                    _ => "未知状态"
+                };
+            }
+        }
+
+        /// <summary>
+        /// 申请人
+        /// </summary>
+        public string Applicant { get; set; }
+
+        /// <summary>
+        /// 申请时间
+        /// </summary>
+        public DateTime ApplyTime { get; set; }
+    }
+
     /// <summary>
     /// 物品领用 Audit DTO
     /// </summary>

+ 78 - 0
OASystem/OASystem.Infrastructure/Repositories/PersonnelModule/GoodsRepository.cs

@@ -3341,6 +3341,84 @@ FROM
             return _jv;
         }
 
+        /// <summary>
+        /// 物品领用 批量 List
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <param name="currUserId"></param>
+        /// <returns></returns>
+        public async Task<JsonView> GoodsReceiveBatchListAsync(GoodsReceiveBatchListDto dto)
+        {
+            int currUserId = dto.CurrUserId;
+            string goodsName = dto.GoodsName;
+
+            
+            var showAllPeopleIds = new List<int>() {
+                374, // 罗颖
+                233, // 刘华举
+                208, // 雷怡
+                343, //  陈湘
+            };
+            var isShowAllPeople = showAllPeopleIds.Any(x => x == currUserId);
+
+            RefAsync<int> total = 0;
+            var receiveList = await _sqlSugar.Queryable<Pm_GoodsReceive>()
+                .LeftJoin<Sys_Users>((x,y) => x.CreateUserId == y.Id)
+                .Where((x, y) => x.IsDel == 0 && x.GoodsId == 0 )
+                .WhereIF(!string.IsNullOrEmpty(goodsName), (x,y) => x.GoodsName.Contains(goodsName))
+                .WhereIF(!isShowAllPeople,(x,y) => x.CreateUserId == currUserId)
+                .Select((x,y) => new GoodsReceiveBatchListView() { 
+                    Id   = x.Id,
+                    GoodsName = x.GoodsName,
+                    AccumQty = SqlFunc.Subqueryable<Pm_GoodsReceiveDetails>().Where(z => z.IsDel == 0 && z.GoodsReceiveId == x.Id).Sum(z => z.Quantity),
+                    Reason = x.Reason,
+                    Remark = x.Remark,
+                    Status = x.AuditStatus,
+                    Applicant = y.CnName,
+                    ApplyTime = x.CreateTime,
+                })
+                .ToPageListAsync(dto.PageIndex,dto.PageSize,total);
+
+            foreach (var item in receiveList)
+            {
+                var detailsText = new StringBuilder();
+                if (item.AccumQty > 0)
+                {
+                    var goodsInfos = await _sqlSugar.Queryable<Pm_GoodsReceiveDetails>()
+                        .InnerJoin<Pm_GoodsInfo>((x, y) => x.GoodsId == y.Id)
+                        .LeftJoin<Sys_SetData>((x, y, z) => y.Type == z.Id)
+                        .Where((x, y, z) => x.IsDel == 0 && x.GoodsReceiveId == item.Id)
+                        .Select((x, y, z) => new
+                        {
+                            goodsId = x.GoodsId,
+                            goodsName = y.Name,
+                            goodsType = z.Name,
+                            quantity = x.Quantity,
+                            remark = x.Remark,
+                        })
+                        .ToListAsync();
+
+                    if (goodsInfos.Any())
+                    {
+                        int index = 1;
+                        goodsInfos.ForEach(x =>
+                        {
+                            detailsText.Append($"{index}.{x.goodsName}({x.goodsType})  数量:{x.quantity:#0.00}  备注:{x.remark ?? "-"} <br/>");
+                            index++;
+                        });
+                    }
+                }
+                else detailsText.Append($"暂无数据!");
+                item.GoodsDetails = detailsText.ToString();
+            }
+
+            _jv.Code = StatusCodes.Status200OK;
+            _jv.Msg = $"操作成功!";
+            _jv.Data = receiveList;
+            _jv.Count = total;
+            return _jv;
+        }
+
 
         /// <summary>
         /// 物品领用 批量 详情