Sfoglia il codice sorgente

优化物品管理和审核功能

在 `GroupsController.cs` 中更新价格数据列表顺序,添加新条目并移除旧条目,确保数据一致性。更新注释为英文以保持一致性。

在 `GoodsInfoView.cs` 中新增 `GoodsDetails` 属性,移除 `AuditPers` 属性,以优化物品接收列表视图模型。

在 `GoodsRepository.cs` 中添加对 PostgreSQL 复制功能的支持,新增 `userNameLabel` 数组以存储用户名称,并在查询中使用。重构查询逻辑,合并旧数据和新数据,简化代码结构。

添加审核相关处理逻辑,确保在物品审核时显示用户名称和时间。重构物品领用审核列表查询逻辑,使用 SQL 查询语句提高性能和可读性,并添加物品领用详情设置逻辑,以返回详细信息和审核状态描述。
LEIYI 6 giorni fa
parent
commit
d3e596b707

+ 12 - 12
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -18404,17 +18404,17 @@ ORDER by  gctggrc.id DESC
                 ("BXRS", "BXCB", "BXXS", "bx"),
                 ("HCPRS", "HCPCB", "HCPXS", "hcp"),
                 ("JJCRS", "JJCCB", "JJCXS", "jjc"),
-                ("GWCRS", "GWCCB", "GWCXS", "gwc")                     ,
-                ("TDCRS", "TDCCB", "TDCXS", "tdc")                      ,
-                ("CPRS", "CPCB", "CPXS", "cp")                           ,
-                ("HSRS", "HSCB", "HSXS", "hsjc")                       ,
-                ("TBRNumber", "TBRCB", "TBRXS", "tbr")                 ,
-                ("SGRNumber", "SGRCB", "SGRXS", "sgr")                 ,
-                ("JSESNumber", "JSESCB", "JSESXS", "jses")             ,
-                ("SUITENumber", "SUITECB", "SUITEXS", "suite")         ,
-                ("DJRS", "DJCB", "DJXS", "dj")                           ,
-                ("GWRS", "GWCB", "GWXS", "gw")                           ,
-                ("LYJRS", "LYJCB", "LYJXS", "lyj")                      ,
+                ("GWCRS", "GWCCB", "GWCXS", "gwc"),
+                ("TDCRS", "TDCCB", "TDCXS", "tdc"),
+                ("CPRS", "CPCB", "CPXS", "cp"),
+                ("HSRS", "HSCB", "HSXS", "hsjc"),
+                ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
+                ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
+                ("JSESNumber", "JSESCB", "JSESXS", "jses"),
+                ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
+                ("DJRS", "DJCB", "DJXS", "dj"),
+                ("GWRS", "GWCB", "GWXS", "gw"),
+                ("LYJRS", "LYJCB", "LYJXS", "lyj"),
             };
             var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
             var rightSum = 0.00M;
@@ -18980,7 +18980,7 @@ AirHotelPrice
 
         #endregion
 
-        #region 酒店预订 新 雷怡 2023-12-28 17:45
+        #region 酒店预订 New 2023-12-28 17:45
 
         /// <summary>
         /// 酒店预订 

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

@@ -199,7 +199,9 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
     public class GoodsReceiveListView: GoodsReceiveView
     {
         public string GoodsType { get; set; }
-        public GoodsStorageAuditPerView[] AuditPers { get; set; }
+
+        public string GoodsDetails { get; set; }
+
     }
 
     public class GoodsReceiveListMobileView : GoodsReceiveListView

+ 280 - 124
OASystem/OASystem.Infrastructure/Repositories/PersonnelModule/GoodsRepository.cs

@@ -3,6 +3,7 @@ using AutoMapper;
 using EyeSoft.Collections.Generic;
 using EyeSoft.Runtime.InteropServices;
 using Newtonsoft.Json;
+using Npgsql.Replication.PgOutput.Messages;
 using OASystem.Domain;
 using OASystem.Domain.Dtos.PersonnelModule;
 using OASystem.Domain.Dtos.System;
@@ -1117,6 +1118,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                   userLabel = Array.Empty<int>(),
                   auditLabel = Array.Empty<int>(),
                   groupLabel = Array.Empty<int>();
+            string[] userNameLabel = Array.Empty<string>();
             int currUserId = dto.CurrUserId;
             if (!string.IsNullOrEmpty(dto.TypeLabel))
             {
@@ -1139,6 +1141,12 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                         return id;
                     })
                     .ToArray();
+
+                if (userLabel.Any())
+                {
+                    userNameLabel = await _sqlSugar.Queryable<Sys_Users>().Where(x => userLabel.Contains(x.Id)).Select(x => x.CnName).ToArrayAsync();
+                }
+
             }
             if (!string.IsNullOrEmpty(dto.AuditLabel))
             {
@@ -1173,21 +1181,10 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             bool isAllGroups = false;
             if (groupLabel.Contains(-3)) isAllGroups = true;
 
-
             //物品ID和物品名称只能传一个
             if (dto.GoodsId > 0) dto.GoodsName = string.Empty;
             if (!string.IsNullOrEmpty(dto.GoodsName)) dto.GoodsId = 0;
 
-            //财务人事审核权限处理
-            var auditList = GoodsStorageConfirmAuditDep(2);
-            bool hrAuditPer = false;
-            var hrAuditInfo = auditList.FirstOrDefault(x => x.AuditDep == GoodsAuditDepEnum.Hr);
-
-            if (hrAuditInfo.AuditorIds.Any(x => x == currUserId))
-            {
-                hrAuditPer = true;
-            }
-
             if (currUserId == 343) //陈湘OAId登录 只显示贵重物品审核信息
             {
                 if (_goodsTypeIds.Any())
@@ -1198,27 +1195,17 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                 }
             }
 
-
             var beginBool = DateTime.TryParse(!string.IsNullOrEmpty(dto.BeginDt) ? $"{dto.BeginDt} 00:00:00" : string.Empty, out var begin);
             var endBool = DateTime.TryParse(!string.IsNullOrEmpty(dto.EndDt) ? $"{dto.EndDt} 00:00:00" : string.Empty, out var end);
 
-            RefAsync<int> total = 0;
-            var data = _sqlSugar.Queryable<Pm_GoodsReceive>()
-                .LeftJoin<Pm_GoodsInfo>((gr, gi) => gr.GoodsId == gi.Id)
+            //新旧领用数据整合
+            var oldDatas = _sqlSugar.Queryable<Pm_GoodsReceive>()
+                .InnerJoin<Pm_GoodsInfo>((gr, gi) => gr.GoodsId == gi.Id)
                 .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)
                 .LeftJoin<Grp_DelegationInfo>((gr, gi, sd, u1, u2, di) => gr.GroupId == di.Id)
-                .Where((gr, gi, sd, u1, u2, di) => gr.IsDel == 0)
-                .WhereIF(dto.GoodsId > 0, (gr, gi, sd, u1, u2, di) => gr.GoodsId == dto.GoodsId)
-                .WhereIF(!string.IsNullOrEmpty(dto.GoodsName), (gr, gi, sd, u1, u2, di) => gi.Name.Contains(dto.GoodsName))
-                .WhereIF(auditLabel.Length > 0, (gr, gi, sd, u1, u2, di) => auditLabel.Contains((int)gr.AuditStatus))
-                .WhereIF(typeLabel.Length > 0, (gr, gi, sd, u1, u2, di) => typeLabel.Contains(gi.Type))
-                .WhereIF(userLabel.Length > 0, (gr, gi, sd, u1, u2, di) => userLabel.Contains(gr.CreateUserId))
-                .WhereIF(isAllGroups, (gr, gi, sd, u1, u2, di) => gr.GroupId > 0)
-                .WhereIF(!isAllGroups && groupLabel.Length > 0, (gr, gi, sd, u1, u2, di) => groupLabel.Contains(gr.GroupId))
-                .WhereIF(beginBool && endBool, (gr, gi, sd, u1, u2, di) => gr.CreateTime >= begin && gr.CreateTime <= end)
-                //.WhereIF((string.IsNullOrEmpty(dto.GoodsName) || !isAllGroups) && hrAuditPer, (gr, gi, sd, u1, u2, di) => _goodsTypeIds.Contains(gi.Type))
+                .Where((gr, gi, sd, u1, u2, di) => gr.IsDel == 0 && gr.GoodsId > 0)
                 .Select((gr, gi, sd, u1, u2, di) => new GoodsReceiveListMobileView
                 {
                     Id = gr.Id,
@@ -1239,8 +1226,62 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                     AuditTime = gr.AuditTime,
                     CreateUserName = u2.CnName,
                     CreateTime = gr.CreateTime
-                })
-                .OrderByDescending(gr => gr.CreateTime);
+                });
+
+            var newDatas = _sqlSugar.Queryable<Pm_GoodsReceive>()
+                .LeftJoin<Pm_GoodsReceiveDetails>((gr, grd) => gr.Id == grd.GoodsReceiveId)
+                .LeftJoin<Pm_GoodsInfo>((gr, grd, gi) => grd.GoodsId == gi.Id)
+                .LeftJoin<Sys_SetData>((gr, grd, gi, sd) => gi.Type == sd.Id)
+                .LeftJoin<Sys_Users>((gr, grd, gi, sd, u1) => gr.AuditUserId == u1.Id)
+                .LeftJoin<Sys_Users>((gr, grd, gi, sd, u1, u2) => gr.CreateUserId == u2.Id)
+                .LeftJoin<Grp_DelegationInfo>((gr, grd, gi, sd, u1, u2, di) => gr.GroupId == di.Id)
+                .Where((gr, grd, gi, sd, u1, u2, di) => gr.IsDel == 0 && grd.IsDel == 0 && gr.GoodsId < 1)
+                .Select((gr, grd, gi, sd, u1, u2, di) => new GoodsReceiveListMobileView
+                {
+                    Id = gr.Id,
+                    GroupId = gr.GroupId,
+                    GroupName = di.TeamName,
+                    GoodsId = gr.GoodsId,
+                    GoodsName = gi.Name,
+                    GoodsTypeId = gi.Type,
+                    GoodsType = sd.Name,
+                    Quantity = grd.Quantity,
+                    Unit = gi.Unit,
+                    Reason = gr.Reason,
+                    Remark = gr.Remark,
+                    AuditStatus = gr.AuditStatus,
+                    StatusDesc = gr.StatusDesc,
+                    AuditUserId = gr.AuditUserId,
+                    AuditUserName = u1.CnName,
+                    AuditTime = gr.AuditTime,
+                    CreateUserName = u2.CnName,
+                    CreateTime = gr.CreateTime
+                });
+
+            var isIdSelect = false;
+            var isNameSelect = false;
+            if (dto.GoodsId > 0)
+            {
+                isIdSelect = true;
+                dto.GoodsName = string.Empty;
+            }
+            if (!string.IsNullOrEmpty(dto.GoodsName))
+            {
+                isIdSelect = false;
+                isNameSelect = true;
+            }
+
+            RefAsync<int> total = 0;
+            var data = _sqlSugar.UnionAll(oldDatas, newDatas)
+                .WhereIF(isIdSelect && !isNameSelect, x => x.GoodsId == dto.GoodsId)
+                .WhereIF(!isIdSelect && isNameSelect, x => x.GoodsName.Contains(dto.GoodsName))
+                .WhereIF(auditLabel.Length > 0, x => auditLabel.Contains((int)x.AuditStatus))
+                .WhereIF(typeLabel.Length > 0, x => typeLabel.Contains(x.GoodsTypeId))
+                .WhereIF(userNameLabel.Length > 0, x => userNameLabel.Contains(x.CreateUserName))
+                .WhereIF(!isAllGroups && groupLabel.Length > 0, x => groupLabel.Contains(x.GroupId))
+                .WhereIF(isAllGroups, x => x.GroupId > 0)
+                .WhereIF(beginBool && endBool, x => x.CreateTime >= begin && x.CreateTime <= end)
+                .OrderByDescending(x => x.CreateTime);
 
             //excel导出
             if (dto.IsExcelDownload)
@@ -1269,22 +1310,54 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                 var tableData = await data.ToListAsync();
                 foreach (var item in tableData)
                 {
-                    if (string.IsNullOrEmpty(item.GoodsName))
+                    var oldGroupName = item.GroupName;
+                    item.GroupName = item.GroupId switch
                     {
-                        var goodIds = await _sqlSugar.Queryable<Pm_GoodsReceiveDetails>()
-                            .Where(x => x.GoodsReceiveId == item.Id && x.IsDel == 0)
-                            .Select(x => x.GoodsId)
-                            .ToListAsync();
-
-                        if (goodIds.Any())
+                        0 => "其他物资(公司内部物资)",
+                        -1 => "拜访客户所使用的物资",
+                        -2 => "库存调整",
+                        _ => oldGroupName
+                    };
+
+                    //审核相关处理
+                    if (string.IsNullOrEmpty(item.AuditUserName))
+                    {
+                        var oldAuditDatas = await _sqlSugar.Queryable<Pm_GoodsAudit>()
+                           .LeftJoin<Sys_Users>((x, u) => x.AuditUserId == u.Id)
+                           .Where((x, u) => x.IsDel == 0 && x.Type == 2 && x.DataId == item.Id)
+                           .Select((x, u) => new { 
+                                x.AuditTime,
+                                u.CnName
+                           })
+                           .ToListAsync();
+                        if (oldAuditDatas.Any())
                         {
-                            var goodsNames = await _sqlSugar.Queryable<Pm_GoodsInfo>()
-                                .Where(x => goodIds.Contains(x.Id) && x.IsDel == 0)
-                                .Select(x => x.Name)
-                                .ToListAsync();
-                            if (goodsNames.Any())
+                            item.AuditUserName = string.Join("、", oldAuditDatas.Select(x => x.CnName).ToArray());
+                            if (!string.IsNullOrEmpty(item.AuditUserName))
                             {
-                                item.GoodsName = string.Join("、", goodsNames);
+                                item.AuditTime = oldAuditDatas.Last().AuditTime;
+                            }
+                            else item.AuditTime = DateTime.Now;
+                        }
+                        else
+                        { 
+                            var newAuditDatas = await _sqlSugar.Queryable<Sys_AuditRecord>()
+                                .InnerJoin<Sys_AuditFlow>((x,y) => x.FlowId == y.Id)
+                               .Where((x, y) => x.IsDel == 0 && y.BusinessType == 1 && y.BusinessId == item.Id)
+                               .Select((x, y) => new {
+                                   x.AuditTime,
+                                   x.AuditorName
+                               })
+                               .ToListAsync();
+                            if (newAuditDatas.Any())
+                            {
+                                item.AuditUserName = string.Join("、", newAuditDatas.Select(x => x.AuditorName).Distinct().ToArray());
+
+                                if (!string.IsNullOrEmpty(item.AuditUserName))
+                                {
+                                    item.AuditTime = newAuditDatas.Last().AuditTime;
+                                }
+                                else item.AuditTime = DateTime.Now;
                             }
                         }
                     }
@@ -1304,42 +1377,61 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             }
 
             //返回分页数据
-            //领用审核List只显示多条审核数据 陈湘
             var view = await data.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
 
             foreach (var item in view)
             {
-                //默认审核验证 多条 or 单挑
-                var isAudit = GoodsAuditType(item.GoodsTypeId);
-                var auditPers = new List<GoodsStorageAuditPerView>()
+                //团组名称处理
+                var oldGroupName = item.GroupName;
+                item.GroupName = item.GroupId switch
                 {
-                    new (){ AuditPer  = true, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = $"领用确认"},
+                    0 => "其他物资(公司内部物资)",
+                    -1 => "拜访客户所使用的物资",
+                    -2 => "库存调整",
+                    _ => oldGroupName
                 };
-                if (isAudit) auditPers.Add(new() { AuditPer = hrAuditPer, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = $"出库确认" });
-
-                item.AuditPers = auditPers.ToArray();
-
-                //批量审核物品处理
-                if (string.IsNullOrEmpty(item.GoodsName))
-                {
-                    var goodIds = await _sqlSugar.Queryable<Pm_GoodsReceiveDetails>()
-                        .Where(x => x.GoodsReceiveId == item.Id && x.IsDel == 0)
-                        .Select(x => x.GoodsId)
-                        .ToListAsync();
-
-                    if (goodIds.Any())
+                //审核相关处理
+                if (string.IsNullOrEmpty(item.AuditUserName))
+                {
+                    var oldAuditDatas = await _sqlSugar.Queryable<Pm_GoodsAudit>()
+                       .LeftJoin<Sys_Users>((x, u) => x.AuditUserId == u.Id)
+                       .Where((x, u) => x.IsDel == 0 && x.Type == 2 && x.DataId == item.Id)
+                       .Select((x, u) => new {
+                           x.AuditTime,
+                           u.CnName
+                       })
+                       .ToListAsync();
+                    if (oldAuditDatas.Any())
                     {
-                        var goodsNames = await _sqlSugar.Queryable<Pm_GoodsInfo>()
-                            .Where(x => goodIds.Contains(x.Id) && x.IsDel == 0)
-                            .Select(x => x.Name)
-                            .ToListAsync();
-                        if (goodsNames.Any())
+                        item.AuditUserName = string.Join("、", oldAuditDatas.Select(x => x.CnName).ToArray());
+                        if (!string.IsNullOrEmpty(item.AuditUserName))
                         {
-                            item.GoodsName = string.Join("、", goodsNames);
+                            item.AuditTime = oldAuditDatas.Last().AuditTime;
                         }
+                        else item.AuditTime = DateTime.Now;
                     }
-                }
+                    else
+                    {
+                        var newAuditDatas = await _sqlSugar.Queryable<Sys_AuditRecord>()
+                            .InnerJoin<Sys_AuditFlow>((x, y) => x.FlowId == y.Id)
+                           .Where((x, y) => x.IsDel == 0 && y.BusinessType == 1 && y.BusinessId == item.Id)
+                           .Select((x, y) => new {
+                               x.AuditTime,
+                               x.AuditorName
+                           })
+                           .ToListAsync();
+                        if (newAuditDatas.Any())
+                        {
+                            item.AuditUserName = string.Join("、", newAuditDatas.Select(x => x.AuditorName).Distinct().ToArray());
 
+                            if (!string.IsNullOrEmpty(item.AuditUserName))
+                            {
+                                item.AuditTime = newAuditDatas.Last().AuditTime;
+                            }
+                            else item.AuditTime = DateTime.Now;
+                        }
+                    }
+                }
             }
 
             if (dto.PortType == 2 || dto.PortType == 3)
@@ -2856,7 +2948,6 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
 
         #region New 物品领用、审核
 
-
         /// <summary>
         /// 物品领用审核列表
         /// </summary>
@@ -2866,77 +2957,142 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
         {
             var currUserId = dto.CurrUserId;
             var auditStatus = dto.AuditStatus;
+            var goodsName = dto.GoodsName;
+
+            var sql = string.Format(@"SELECT
+  ROW_NUMBER() OVER (ORDER BY CreateTime DESC) AS RowNumber,
+  *
+FROM
+  (
+    Select
+      gr.Id,
+      gr.GroupId,
+      CASE
+        WHEN gr.GroupId = 0 THEN '其他物资(公司内部物资)'
+        WHEN gr.GroupId = -1 THEN '拜访客户所使用的物资'
+        WHEN gr.GroupId = -2 THEN '库存调整'
+        ELSE di.TeamName
+      END [GroupName],
+      gr.GoodsId,
+      CASE
+        WHEN gr.GoodsId = 0 THEN gr.GoodsName
+        ELSE gi.Name
+      END [GoodsName],
+      gi.Type [GoodsTypeId],
+      sd.Name [GoodsType],
+      CASE
+        WHEN gi.Type = 0
+        OR gi.Type IS NULL THEN CASE
+          WHEN af.TemplateId = 3 THEN 1
+          ELSE 0
+        END
+        WHEN gi.Type = 1423 THEN 1
+        ELSE 0
+      END [IsValuable],
+      gr.Quantity,
+      gi.Unit,
+      gr.Reason,
+      gr.Remark,
+      gr.AuditStatus,
+      gr.StatusDesc,
+      gr.AuditUserId,
+      u1.CnName [AuditUserName],
+      gr.AuditTime,
+      u2.CnName [CreateUserName],
+      gr.CreateTime
+    FROM
+      OA2023DB.dbo.Pm_GoodsReceive gr
+      LEFT JOIN Pm_GoodsInfo gi ON gr.GoodsId = gi.Id
+      LEFT JOIN Grp_DelegationInfo di ON gr.GroupId = di.Id
+      LEFT JOIN Sys_Users u1 ON gr.AuditUserId = u1.Id
+      LEFT JOIN Sys_Users u2 ON gr.CreateUserId = u2.Id
+      LEFT JOIN Sys_AuditFlow af ON gr.Id = af.BusinessId
+      LEFT JOIN Sys_SetData sd ON gi.Type = sd.Id
+    WHERE
+      gr.IsDel = 0
+  ) Temp ");
 
-            //财务人事审核权限处理
-            var auditList = GoodsStorageConfirmAuditDep(2);
-            bool hrAuditPer = false;
-            var hrAuditInfo = auditList.FirstOrDefault(x => x.AuditDep == GoodsAuditDepEnum.Hr);
-
-            if (hrAuditInfo.AuditorIds.Any(x => x == currUserId))
-            {
-                hrAuditPer = true;
-            }
 
             var isValueable = false;
             if (currUserId == 343) //陈湘OAId登录 只显示贵重物品审核信息
             {
                 isValueable = true;
             }
-
-
             RefAsync<int> total = 0;
-            var data = _sqlSugar.Queryable<Pm_GoodsReceive>()
-                .LeftJoin<Pm_GoodsInfo>((gr, gi) => gr.GoodsId == gi.Id)
-                .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)
-                .LeftJoin<Grp_DelegationInfo>((gr, gi, sd, u1, u2, di) => gr.GroupId == di.Id)
-                .Where((gr, gi, sd, u1, u2, di) => gr.IsDel == 0)
-                .WhereIF(!string.IsNullOrEmpty(dto.GoodsName), (gr, gi, sd, u1, u2, di) => gi.Name.Contains(dto.GoodsName))
-                .WhereIF(auditStatus > 0, (gr, gi, sd, u1, u2, di) => auditStatus == (int)gr.AuditStatus)
-                .Select((gr, gi, sd, u1, u2, di) => new GoodsReceiveListMobileView
-                {
-                    Id = gr.Id,
-                    GroupId = gr.GroupId,
-                    GroupName = di.TeamName,
-                    GoodsId = gr.GoodsId,
-                    GoodsName = gr.GoodsId == 0 ? gr.GoodsName : gi.Name,
-                    GoodsTypeId = gi.Type,
-                    GoodsType = sd.Name,
-                    IsValuable = gi.Type == 0 
-                    ? SqlFunc.Subqueryable<Sys_AuditFlow>().Where(x => x.BusinessId == gr.Id && x.BusinessType == 1).Select(x => x.TemplateId) == 3 
-                    : _goodsTypeIds.Contains(gi.Type),
-                    Quantity = gr.Quantity,
-                    Unit = gi.Unit,
-                    Reason = gr.Reason,
-                    Remark = gr.Remark,
-                    AuditStatus = gr.AuditStatus,
-                    StatusDesc = gr.StatusDesc,
-                    AuditUserId = gr.AuditUserId,
-                    AuditUserName = u1.CnName,
-                    AuditTime = gr.AuditTime,
-                    CreateUserName = u2.CnName,
-                    CreateTime = gr.CreateTime
-                })
-                //.WhereIF(isValueable, )
-                .OrderByDescending(gr => gr.CreateTime);
-
-            //返回分页数据
-            //领用审核List只显示多条审核数据 陈湘
-            var view = await data.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
+            var view = await _sqlSugar.SqlQueryable<GoodsReceiveListMobileView>(sql)
+                .WhereIF(isValueable, x => x.IsValuable == true)
+                .WhereIF(!string.IsNullOrEmpty(goodsName), x => x.GoodsName.Contains(goodsName))
+                .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
 
             foreach (var item in view)
             {
-                //默认审核验证 多条 or 单挑
-                var isAudit = GoodsAuditType(item.GoodsTypeId);
-                var auditPers = new List<GoodsStorageAuditPerView>()
-                {
-                    new (){ AuditPer  = true, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = $"领用确认"},
-                };
-                if (isAudit) auditPers.Add(new() { AuditPer = hrAuditPer, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = $"出库确认" });
+                var details = $"暂无物品信息数据";
+                
+                //设置领用详情
+                if (item.GoodsTypeId < 1)
+                {
+                    var detailsData = await _sqlSugar.Queryable<Pm_GoodsReceiveDetails>()
+                    .LeftJoin<Pm_GoodsInfo>((grd, gi) => grd.GoodsId == gi.Id)
+                    .LeftJoin<Sys_SetData>((grd, gi, sd) => gi.Type == sd.Id)
+                    .Where((grd, gi, sd) => grd.IsDel == 0 && grd.GoodsReceiveId == item.Id)
+                    .Select((grd, gi, sd) => new
+                    {
+                        gi.Name,
+                        TypeName = sd.Name,
+                        grd.Quantity,
+                        grd.Remark
+                    })
+                    .ToListAsync();
+
+                    if (detailsData.Any())
+                    {
+                        //设置领用数量 多个物品 计算领用合计
+                        item.Quantity = detailsData.Sum(x => x.Quantity);
+
+                        var text = new StringBuilder();
+                        text.Append($"归属团组:{item.GroupName} <br/><br/>");
+                        detailsData.ForEach(x =>
+                        {
+                            var str = $"物品名称:{x.Name}   物品类型:{x.TypeName}   领用数量:{x.Quantity}   备注:{x.Remark}<br/>";
+                            text.Append(str);
+                        });
+                        details = text.ToString();
+                    }
+                }
+                else details = $"归属团组:{item.GroupName} <br/><br/>物品名称:{item.GoodsName}   物品类型:{item.GoodsType}   领用数量:{item.Quantity}   备注:{item.Remark}<br/>";
 
-                item.AuditPers = auditPers.ToArray();
+                item.GoodsDetails = details;
 
+                //设置领用状态描述
+                var auditRecords = await _sqlSugar.Queryable<Sys_AuditRecord>()
+                    .InnerJoin<Sys_AuditFlow>((ar,af) => ar.FlowId == af.Id)
+                    .Where((ar, af) => ar.IsDel == 0 && af.BusinessId == item.Id && af.BusinessType == 1)
+                    .Select((ar, af) => new {
+                        NodeId = ar.NodeId,
+                        ar.NodeName,
+                        ar.AuditResult,
+                        ar.AuditorName,
+                        ar.AuditTime
+                    })
+                    //.OrderBy((ar, af) => ar.AuditTime)
+                    .ToListAsync();
+                if (auditRecords.Any())
+                {
+                    var text = new StringBuilder();
+                    auditRecords.ForEach(x =>
+                    {
+                        var statusText = x.AuditResult switch { 
+                            0 => "待审核",
+                            1 => "已审核",
+                            2 => "已拒绝",
+                            3 => "无需处理",
+                            _ => "未知"
+                        };
+                        var str = $"{x.NodeName}:状态:{statusText}  审核人:{x.AuditorName}  审核时间:{x.AuditTime.ToString("yyyy-MM-dd HH:mm:ss")}<br/>";
+                        text.Append(str);
+                    });
+                    item.StatusDesc = text.ToString();
+                }
             }
 
             if (dto.PortType == 2 || dto.PortType == 3)