浏览代码

重命名异步方法并添加批量领用详情接口

在 `PersonnelModuleController.cs` 中,将 `GoodsReceiveBatchOp` 方法重命名为 `GoodsReceiveBatchOpAsync`,并新增 `GoodsReceiveBatchInfo` 异步方法以获取批量领用的详细信息。

在 `GoodsDTO.cs` 中,`GoodsReceiveBatchOpDto` 继承自 `GoodsReceiveBatchView`,并添加 `CurrUserId` 属性,同时注释掉 `GoodsReceiveDetailsView` 中的 `GoodsReceiveId` 属性。

在 `GoodsRepository.cs` 中,`GoodsReceiveBatchOp` 方法重命名为 `GoodsReceiveBatchOpAsync`,并新增 `GoodsReceiveBatchInfoAsync` 方法以根据 ID 查询批量领用的详细信息。
LEIYI 6 天之前
父节点
当前提交
2f61ab32db

+ 16 - 2
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -2338,7 +2338,7 @@ WHERE
             if (!dto.ReceiveDetails.Any()) Ok(JsonView(false,"请传入领用明细!"));
 
             int index = 1;
-            foreach (var item in dto.ReceiveDetails)
+            foreach (var item in dto.ReceiveDetails)    
             {
                 //物品验证
                 if (item.GoodsId < 1) return Ok(JsonView(false, $"第{index}项物品无效!"));
@@ -2348,9 +2348,23 @@ WHERE
                 index++;
             }
 
-            return Ok(await _goodsRep.GoodsReceiveBatchOp(dto));
+            return Ok(await _goodsRep.GoodsReceiveBatchOpAsync(dto));
         }
 
+        /// <summary>
+        /// 物资进销存
+        /// 领用 批量领用 详情
+        /// </summary>
+        /// <param name="id">id</param>
+        /// <returns></returns>
+        [HttpGet("{id}")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GoodsReceiveBatchInfo( int id)
+        {
+            return Ok(await _goodsRep.GoodsReceiveBatchInfoAsync(id));
+        }
+
+
         /// <summary>
         /// 物资进销存
         /// 领用 审核 含批量领用

+ 18 - 6
OASystem/OASystem.Domain/Dtos/PersonnelModule/GoodsDTO.cs

@@ -364,7 +364,16 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     }
 
 
-    public class GoodsReceiveBatchOpDto
+    public class GoodsReceiveBatchOpDto : GoodsReceiveBatchView
+    {
+        public int CurrUserId { get; set; }
+    }
+
+
+
+
+
+    public class GoodsReceiveBatchView
     {
         /// <summary>
         /// ID
@@ -394,7 +403,6 @@ namespace OASystem.Domain.Dtos.PersonnelModule
         /// </summary>
         public string? Remark { get; set; }
 
-        public int CurrUserId { get; set; }
     }
 
     public class GoodsReceiveAuditDto
@@ -406,15 +414,19 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     public class GoodsReceiveDetailsView
     {
         public int Id { get; set; }
-        /// <summary>
-        /// 物品领用Id
-        /// </summary>
-        public int GoodsReceiveId { get; set; }
+        ///// <summary>
+        ///// 物品领用Id
+        ///// </summary>
+        //public int GoodsReceiveId { get; set; }
         /// <summary>
         /// 物品Id
         /// Pm_GoodsInfo Id
         /// </summary>
         public int GoodsId { get; set; }
+        /// <summary>
+        /// 物品名称
+        /// </summary>
+        public string GoodsName { get; set; }
         ///// <summary>
         ///// 物资入库批次信息
         ///// {storageId:1,quantity:10}

+ 45 - 1
OASystem/OASystem.Infrastructure/Repositories/PersonnelModule/GoodsRepository.cs

@@ -3117,7 +3117,7 @@ FROM
         /// <param name="dto"></param>
         /// <param name="currUserId"></param>
         /// <returns></returns>
-        public async Task<JsonView> GoodsReceiveBatchOp(GoodsReceiveBatchOpDto dto)
+        public async Task<JsonView> GoodsReceiveBatchOpAsync(GoodsReceiveBatchOpDto dto)
         {
             var goodsReceiveId = dto.Id;
             var currUserId = dto.CurrUserId;
@@ -3341,6 +3341,50 @@ FROM
             return _jv;
         }
 
+
+        /// <summary>
+        /// 物品领用 批量 详情
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <param name="currUserId"></param>
+        /// <returns></returns>
+        public async Task<JsonView> GoodsReceiveBatchInfoAsync(int id)
+        {
+            var receiveInfo = await _sqlSugar.Queryable<Pm_GoodsReceive>()
+                .Where(x => x.IsDel == 0 && x.Id == id)
+                .FirstAsync();
+            if (receiveInfo == null)
+            {
+                _jv.Msg = "暂无数据!";
+                return _jv;
+            }
+
+            var info = new GoodsReceiveBatchView();
+            info.Id = receiveInfo.Id;
+            info.GroupId = receiveInfo.GroupId;
+            info.Reason = receiveInfo.Reason;
+            info.Remark = receiveInfo.Remark;
+            info.ReceiveDetails = await _sqlSugar
+                .Queryable<Pm_GoodsReceiveDetails>()
+                .LeftJoin<Pm_GoodsInfo>((x, y) => x.GoodsId == y.Id)
+                .Where((x, y) => x.IsDel == 0 && x.GoodsReceiveId == receiveInfo.Id)
+                .Select((x, y) => new GoodsReceiveDetailsView()
+                {
+                    Id = x.Id,
+                    GoodsId = x.GoodsId,
+                    GoodsName = y.Name,
+                    Quantity = x.Quantity,
+                    Remark = x.Remark,
+                })
+                .ToArrayAsync();
+
+            _jv.Code = StatusCodes.Status200OK;
+            _jv.Msg = $"操作成功!";
+            _jv.Data = info;
+            return _jv;
+        }
+
+
         /// <summary>
         /// 物品领用 审核 通过
         /// </summary>