yuanrf 1 settimana fa
parent
commit
212eae3dce

+ 19 - 0
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -4975,6 +4975,25 @@ FROM
             return Ok(JsonView(true, groupData.Msg, groupData.Data));
 
         }
+
+        /// <summary>
+        /// 团组增减款项操作 自动审核test
+        /// </summary>
+        /// <param name="groupId"></param>
+        /// <param name="dataId"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> DecreaseFeeAutomaticAudit(int groupId,int dataId)
+        {
+            //自动审核
+            var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, groupId, dataId);
+
+
+            return Ok(autoAdit);
+
+        }
+
         /// <summary>
         /// 团组增减款项操作 删除
         /// </summary>

+ 122 - 0
OASystem/OASystem.Api/Controllers/MarketCustomerResourcesController.cs

@@ -1270,6 +1270,128 @@ namespace OASystem.API.Controllers
             });
         }
 
+        [HttpPost]
+        public IActionResult InsertDataExcel1(IFormFile file )
+        {
+
+            // 检查文件是否为空
+            if (file == null || file.Length == 0)
+            {
+                return BadRequest("No file uploaded.");
+            }
+
+            // 保存文件到服务器
+            var uploadsFolder = Path.Combine(Directory.GetCurrentDirectory(), "File");
+            if (!Directory.Exists(uploadsFolder))
+            {
+                Directory.CreateDirectory(uploadsFolder);
+            }
+
+            var filePath = Path.Combine(uploadsFolder, file.FileName);
+            using (var stream = new FileStream(filePath, FileMode.Create))
+            {
+                 file.CopyToAsync(stream);
+            }
+
+            Workbook workbook = new Workbook(filePath);
+
+            // 获取第一个工作表
+            Worksheet worksheet = workbook.Worksheets[0];
+
+            // 获取表头(第一行作为列名)
+            int headerRowIndex = 0; // 假设第一行是表头
+            Row headerRow = worksheet.Cells.Rows[headerRowIndex];
+            int colCount = worksheet.Cells.MaxDataColumn + 1;
+
+            // 动态存储列名
+            var clients = new List<Crm_ClientDataAndUser>();
+
+            // 遍历数据行(从第二行开始)
+            int rowCount = worksheet.Cells.MaxDataRow + 1;
+            for (int row = headerRowIndex + 1; row < rowCount; row++)
+            {
+                var cellVal1 = worksheet.Cells[row, 0].Value;  //序号
+                var cellVal2 = worksheet.Cells[row, 1].Value;  //数据Id
+                var cellVal3 = worksheet.Cells[row, 2].Value;  //userId
+
+                int parentId = !string.IsNullOrEmpty(cellVal2?.ToString()) ? int.Parse(cellVal2?.ToString()) : 0;
+                int userId = !string.IsNullOrEmpty(cellVal3?.ToString()) ? int.Parse(cellVal3?.ToString()) : 0;
+                var rowData = new Crm_ClientDataAndUser()
+                {
+                    usersId = userId,
+                    NewClientDataId = parentId
+                };
+
+                clients.Add(rowData); // 将当前行数据添加到集合中
+            }
+
+            var count = 0;
+
+            //var notClentUser = new List<int>() { 21, 95  , 327 };
+            var notClentUser = new List<int>() { 21, 95, 327,213 };
+
+            var insertList = new List<Crm_ClientDataAndUser>();
+
+            if (clients.Count > 0)
+            {
+                _sqlSugar.BeginTran();
+
+
+                //检索相关客户数据
+                var newClientArr = _sqlSugar.Queryable<Crm_NewClientData>()
+                    .Where(x => x.IsDel == 0)
+                    .Select(x => new Crm_NewClientData
+                    {
+                        Client = x.Client,
+                        Id = x.Id
+                    })
+                    .ToList();
+
+                foreach (var item in clients)
+                {
+                    var searchClient = newClientArr.Where(x => x.Id == item.NewClientDataId).ToList();
+
+                    foreach (var clientData in searchClient)
+                    {
+                        var clientDataAndUser = _sqlSugar.Queryable<Crm_ClientDataAndUser>()
+                                                .Where(x => x.NewClientDataId == clientData.Id && x.IsDel == 0)
+                                                .ToList();
+
+                        if (clientDataAndUser.Count > 0)
+                        {
+                            //清除关联表数据
+                            _sqlSugar.Updateable<Crm_ClientDataAndUser>()
+                                .Where(x => !notClentUser.Contains(x.usersId)
+                                && x.NewClientDataId == clientData.Id && x.IsDel == 0)
+                                .SetColumns(x => new Crm_ClientDataAndUser
+                                {
+                                    IsDel = 1,
+                                    DeleteTime = DateTime.Now.ToString(),
+                                    DeleteUserId = 235
+                                })
+                                .ExecuteCommand();
+                        }
+
+                        insertList.Add(new Crm_ClientDataAndUser
+                        {
+                            usersId = item.usersId,
+                            NewClientDataId = clientData.Id,
+                            CreateTime = DateTime.Now,
+                            CreateUserId = 235,
+                        });
+                    }
+                }
+
+                count = _sqlSugar.Insertable(insertList).ExecuteCommand();
+
+                _sqlSugar.CommitTran();
+            }
+
+            return Ok(new
+            {
+                count,
+            });
+        }
 
         #region 回滚数据记录
 

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

@@ -42,6 +42,7 @@ namespace OASystem.API.Controllers
 
         private readonly IHubContext<ChatHub, IChatClient> _hubContext;
         private readonly GoodsRepository _goodsRep;
+        //private readonly GroupsController _groupsController;
 
         private string url;
         private string path;
@@ -57,6 +58,7 @@ namespace OASystem.API.Controllers
         /// <param name="hubContext"></param>
         /// <param name="goodsRep"></param>
         /// <param name="sqlSugar"></param>
+        /// <param name="groupsController"></param>
         public PersonnelModuleController(
             IHubContext<ChatHub, IChatClient> hubContext,
             IMapper mapper,
@@ -66,6 +68,7 @@ namespace OASystem.API.Controllers
             TaskAllocationRepository taskAllocationRep,
             GoodsRepository goodsRep,
             SqlSugarClient sqlSugar
+           // GroupsController groupsController
             )
         {
             _mapper = mapper;
@@ -86,7 +89,7 @@ namespace OASystem.API.Controllers
             this._taskAllocationRep = taskAllocationRep;
             _hubContext = hubContext;
             _goodsRep = goodsRep;
-
+            //_groupsController = groupsController;
         }
 
         #region 工资表单
@@ -2154,7 +2157,45 @@ WHERE
                     return id;
                 })
                 .ToArray();
-            return Ok(await _goodsRep.GoodsReceiveAudit(idArray, currUserInfo.UserId, dto.AuditEnum));
+
+
+            var view = await _goodsRep.GoodsReceiveAudit(idArray, currUserInfo.UserId, dto.AuditEnum);
+
+            //TODO:出库成功 并且是团组相关物资 向团组其他款项添加信息
+            #region 出库成功并且是团组相关物资 向团组其他款项添加信息
+
+            if (idArray.Length < 1) return Ok(view);
+
+            int receiveId = idArray[0];
+
+            var receiveInfo = await _sqlSugar.Queryable<Pm_GoodsReceive>().FirstAsync(x => x.IsDel == 0 && x.Id == receiveId);
+            if (receiveInfo == null) return Ok(view);
+
+            if (receiveInfo.AuditStatus != GoodsAuditEnum.OutConfirmed) return Ok(view);
+
+            var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == receiveInfo.GroupId);
+            if (groupInfo == null) return Ok(view);
+
+            var basicData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 91).ToListAsync();
+            var goodsInfo = await _sqlSugar.Queryable<Pm_GoodsInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == receiveInfo.GoodsId);
+            if (goodsInfo == null) return Ok(view);
+
+            var basicInfo = basicData.FirstOrDefault(x => x.Name.Equals(goodsInfo.Name));
+            if (basicInfo == null) return Ok(view);
+
+            var requestData = new DecreasePaymentsOpDto() {
+                Status = 1,
+                DiId = groupInfo.Id,
+
+
+            };
+            //var otherFeeView = await _groupsController.OpDecreasePayments(requestData);
+
+            
+
+            #endregion
+
+            return Ok(view);
         }
 
         /// <summary>

+ 64 - 50
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -3106,26 +3106,13 @@ And u.UId = {0} And u.FId = 1 ", dto.UserId);
             for (int row = headerRowIndex + 1; row < rowCount; row++)
             {
                 var cellVal1 = worksheet.Cells[row, 0].Value;  //序号
-                var cellVal2 = worksheet.Cells[row, 1].Value;  //区域分类
-                var cellVal3 = worksheet.Cells[row, 2].Value;  //省级分类
-                var cellVal4 = worksheet.Cells[row, 3].Value;  //单位名称
-                var cellVal5 = worksheet.Cells[row, 4].Value;  //单位详细地址
-                var cellVal6 = worksheet.Cells[row, 5].Value;  //座机号
-                var cellVal7 = worksheet.Cells[row, 6].Value;  //所在城市
-                var cellVal8 = worksheet.Cells[row, 7].Value;  //分配人Id
-
-                int userId = !string.IsNullOrEmpty(cellVal8?.ToString()) ? int.Parse(cellVal8?.ToString()) : 0;
+                var cellVal2 = worksheet.Cells[row, 1].Value;  //单位名称
+                var cellVal3 = worksheet.Cells[row, 2].Value;  //出访次数
+
+                int count = !string.IsNullOrEmpty(cellVal3?.ToString()) ? int.Parse(cellVal3?.ToString()) : 0;
                 var rowData = new Crm_NewClientData() {
-                    Number = userId,
-                    Lvlid = lvData.FirstOrDefault(x => x.Name.Equals(cellVal2?.ToString()))?.Id ?? 0,//区域分类
-                    Client = cellVal4?.ToString().Trim(),//单位名称
-                    Weight = "C",//客户权重
-                    Phone = cellVal6?.ToString(), //座机号
-                    Location = cellVal7?.ToString(),//所在城市
-                    Address = cellVal5?.ToString(),//单位详细地址
-                    LastUpdateUserId = 4, //最后更新人
-                    LastUpdateTime = DateTime.Now, //最后更新时间
-                    CreateUserId = 4, //创建人
+                    Number = count,
+                    Client = cellVal2?.ToString().Trim(),//单位名称
                 };
 
                 clients.Add(rowData); // 将当前行数据添加到集合中
@@ -3134,47 +3121,52 @@ And u.UId = {0} And u.FId = 1 ", dto.UserId);
 
             if (clients.Any())
             {
-                _sqlSugar.BeginTran();
-                try
-                {
-                    int total = 0;
-                    foreach (var item in clients)
-                    {
+                var clientArr = clients.Select(x => x.Client).ToList();
+                var clientDatas = _sqlSugar.Queryable<Crm_NewClientData>().Where(x => x.IsDel == 0)
+                    .ToList()
+                    .Select(x => new { id = x.Id, client = AesEncryptionHelper.Decrypt(x.Client), remark = AesEncryptionHelper.Decrypt(x.Remark) });
 
-                        var userId = item.Number;
-                        item.Number = 0;
+                var clientDatas1 = clientDatas.Where(x => clientArr.Contains(x.client)).ToList();
 
-                        var insertId = _sqlSugar.Insertable(item).ExecuteReturnIdentity();
-                        if (insertId < 1)
-                        {
-                            _sqlSugar.RollbackTran();
-                            return Ok(JsonView(false));
-                        }
+                var updates = new List<Crm_NewClientData>();
 
-                        var linkUser = new Crm_ClientDataAndUser() {
-                            usersId = userId,
-                            NewClientDataId = insertId,
-                            CreateUserId = 4
-                        };
+                foreach (var item in clientDatas1)
+                {
 
-                        var insertSub = _sqlSugar.Insertable(linkUser).ExecuteReturnIdentity();
-                        if (insertSub < 1)
-                        {
-                            _sqlSugar.RollbackTran();
-                            return Ok(JsonView(false));
-                        }
-                        total++;
+                    string newRemark = item.remark;
+                    var str = clients.FirstOrDefault(x => x.Client.Equals(item.client))?.Number ?? 0;
+                    if (str > 0)
+                    {
+                        newRemark += $"\r\n2025年拟出访次数{str}次";
                     }
 
-                    _sqlSugar.CommitTran();
-                    return Ok(JsonView(true,$"操作成功!成功条数:{total}"));
+                    updates.Add(new Crm_NewClientData() { 
+                        Id = item.id,
+
+                        Remark = AesEncryptionHelper.Encrypt(newRemark)
+                    });
 
                 }
-                catch (Exception)
+
+                if (updates.Any())
                 {
-                    _sqlSugar.RollbackTran();
-                    return Ok(JsonView(false));
+                    //加密后更改
+                    var update = _sqlSugar.Updateable(updates).UpdateColumns(it => new {
+                        //it.Client, 
+                        it.Remark,
+                        //it.Phone,
+                        //it.Address,
+                        // it.Location,
+                    }).ExecuteCommand();
+
+
+                    if (update > 0)
+                    {
+                        return Ok(JsonView(true, $"数据加密成功!加密条数:{update}"));
+                    }
                 }
+
+
             }
             return Ok(JsonView(false));
         }
@@ -3222,6 +3214,28 @@ And u.UId = {0} And u.FId = 1 ", dto.UserId);
             return Ok(JsonView(false));
         }
 
+
+        /// <summary>
+        /// 数库事务异常测试
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> TransactionExTest()
+        {
+            _sqlSugar.BeginTran();
+
+
+            var a1 = new List<dynamic>();
+
+            var a2 = a1[0].ToString();
+
+
+            _sqlSugar.RollbackTran();
+
+            return Ok(JsonView(false));
+        }
+
         #endregion
 
     }

BIN
OASystem/OASystem.Api/File/xxxxxx.xls


+ 7 - 3
OASystem/OASystem.Api/Middlewares/ExceptionHandlingMiddleware.cs

@@ -25,7 +25,7 @@ namespace OASystem.API.Middlewares
         /// </summary>
         /// <param name="httpContext"></param>
         /// <returns></returns>
-        public async Task InvokeAsync(HttpContext httpContext)
+        public async Task InvokeAsync(HttpContext httpContext, SqlSugarClient db)
         {
             try
             {
@@ -33,7 +33,7 @@ namespace OASystem.API.Middlewares
             }
             catch (Exception ex)
             {
-                await HandleExceptionAsync(httpContext, ex); // 捕获异常了 在HandleExceptionAsync中处理
+                await HandleExceptionAsync(httpContext, ex, db); // 捕获异常了 在HandleExceptionAsync中处理
             }
         }
 
@@ -43,8 +43,12 @@ namespace OASystem.API.Middlewares
         /// <param name="context"></param>
         /// <param name="exception"></param>
         /// <returns></returns>
-        private async Task HandleExceptionAsync(HttpContext context, Exception exception)
+        private async Task HandleExceptionAsync(HttpContext context, Exception exception, SqlSugarClient db)
         {
+            if (db.Ado != null && db.Ado.Transaction != null)
+            {
+                db.Ado.RollbackTran();
+            }
 
             context.Response.ContentType = "application/json";  // 返回json 类型
             var response = context.Response;

+ 8 - 0
OASystem/OASystem.Api/appsettings.json

@@ -415,6 +415,14 @@
         {
           "Id": 325,
           "Name": "陈策"
+        },
+        {
+          "Id": 187,
+          "Name": "曾艳"
+        },
+        {
+          "Id": 22,
+          "Name": "朱成梅"
         }
       ]
     },

+ 1 - 4
OASystem/OASystem.Domain/Dtos/Groups/DecreasePaymentsDto.cs

@@ -56,10 +56,7 @@ namespace OASystem.Domain.Dtos.Groups
         /// <summary>
         /// 对方姓名
         /// </summary>
-        public string OtherSideName
-        {
-            get; set;
-        }
+        public string OtherSideName { get; set; }
 
         /// <summary>
         /// 编号

+ 2 - 1
OASystem/OASystem.Domain/Entities/PersonnelModule/Pm_GoodsStorage.cs

@@ -96,7 +96,8 @@ namespace OASystem.Domain.Entities.PersonnelModule
         /// 入库确认描述
         /// </summary>
         [SugarColumn(ColumnDescription = "入库确认描述", IsNullable = true, ColumnDataType = "varchar(100)")]
-        public string StatusDesc { get; set; } = string.Format("人事部:状态:待确认  审核人:-  审核时间:-;<br/>财务部:状态:待确认  审核人:-  审核时间:-;");
+        public string StatusDesc { get; set; } = string.Format("人事部:状态:待确认  审核人:-  审核时间:-;");
+            //string.Format("人事部:状态:待确认  审核人:-  审核时间:-;<br/>财务部:状态:待确认  审核人:-  审核时间:-;");
 
     }
 }

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

@@ -264,6 +264,7 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
     {
         public int Id { get; set; }
         public int GoodsId { get; set; }
+        public int GoodsType { get; set; }
         public string GoodsName { get; set; }
         public string BatchNo { get; set; }
         public decimal Quantity { get; set; }

+ 45 - 23
OASystem/OASystem.Infrastructure/Repositories/Financial/DailyFeePaymentRepository.cs

@@ -383,17 +383,19 @@ namespace OASystem.Infrastructure.Repositories.Financial
             /*
              * 2024-10-29
              * 各部门基础固定费用明细”里的费用数据新增后,财务和总经理审核都默认直接通过isAudit=1),并且可编辑,如果ispay=1的话将不可编辑
-             *  2025-02-24
+             * 2025-02-24
              * 团组费用 默认总经理审核通过
+             * 2025-03-25
+             * 各部门基础固定费用明细”里的费用数据新增后,默认老张通过 财务手动审核 
              */
             var priceTypeInfo = await _sqlSugar.Queryable<Sys_SetData>().FirstAsync(x => x.IsDel == 0 && x.Id == dto.PriceTypeId);
             if (priceTypeInfo != null && (priceTypeInfo.STid == 90 || priceTypeInfo.STid == 104))
             {
-                if (priceTypeInfo.STid == 90)
-                {
-                    _fee.FAudit = 1;
-                    _fee.FAuditDate = DateTime.Now;
-                }
+                //if (priceTypeInfo.STid == 90)
+                //{
+                //    _fee.FAudit = 1;
+                //    _fee.FAuditDate = DateTime.Now;
+                //}
 
                 _fee.MAudit = 1;
                 _fee.MAuditDate = DateTime.Now;
@@ -468,29 +470,49 @@ namespace OASystem.Infrastructure.Repositories.Financial
             try
             {
                 Fin_DailyFeePayment _fee = _mapper.Map<Fin_DailyFeePayment>(dto);
+
+                /*
+                 * 
+                 * 2025-02-24
+                 * 更改后的费用类型为 团组费用 默认总经理审核通过
+                 * 2025-03-25
+                 * 更改后的费用类型为 各部门基础固定费用明细”里的费用数据新增后,默认老张通过 财务手动审核
+                 * 
+                 */
+                var priceTypeInfo = await _sqlSugar.Queryable<Sys_SetData>().FirstAsync(x => x.IsDel == 0 && x.Id == dto.PriceTypeId);
+                var auditStatus = false;
+                if (priceTypeInfo != null && (priceTypeInfo.STid == 90 || priceTypeInfo.STid == 104))
+                {
+                    auditStatus = true;
+                }
+
                 _fee.CreateUserId = dto.UserId;
                 int? editFeeStatus = await _sqlSugar.Updateable<Fin_DailyFeePayment>()
-                                      .Where(a => a.Id == dto.Id)
-                                      .SetColumns(a => new Fin_DailyFeePayment
-                                      {
-                                          Instructions = dto.Instructions,
-                                          SumPrice = dto.SumPrice,
-                                          TransferTypeId = dto.TransferTypeId,
-                                          PriceTypeId = dto.PriceTypeId,
-                                          CompanyId = dto.CompanyId,
-                                          GroupId = dto.GroupId,
-                                      }).ExecuteCommandAsync();
+                    .SetColumns(a => new Fin_DailyFeePayment
+                    {
+                        Instructions = dto.Instructions,
+                        SumPrice = dto.SumPrice,
+                        TransferTypeId = dto.TransferTypeId,
+                        PriceTypeId = dto.PriceTypeId,
+                        CompanyId = dto.CompanyId,
+                        GroupId = dto.GroupId,
+                    })
+                    .SetColumnsIF(auditStatus, a => a.MAudit == 1)
+                    .SetColumnsIF(auditStatus, a => a.MAuditDate == DateTime.Now)
+                    .Where(a => a.Id == dto.Id)
+                    .ExecuteCommandAsync();
 
                 var _feeContents = _mapper.Map<List<Fin_DailyFeePaymentContent>>(dto.FeeContents);
 
                 await _sqlSugar.Updateable<Fin_DailyFeePaymentContent>()
-                                  .Where(a => a.DFPId == _fee.Id)
-                                  .SetColumns(a => new Fin_DailyFeePaymentContent
-                                  {
-                                      IsDel = 1,
-                                      DeleteUserId = _fee.CreateUserId,
-                                      DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
-                                  }).ExecuteCommandAsync();
+                    .Where(a => a.DFPId == _fee.Id)
+                    .SetColumns(a => new Fin_DailyFeePaymentContent
+                    {
+                        IsDel = 1,
+                        DeleteUserId = _fee.CreateUserId,
+                        DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                    })
+                    .ExecuteCommandAsync();
 
                 if (_feeContents.Any())
                 {

+ 1 - 1
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -1150,7 +1150,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         var info = _groupNameList[i];
                         _groupNameList[i].GroupName = FormartTeamName(info.GroupName);
                     }
-
+                    _groupNameList.Insert(0, new GroupNameView() { Id = 0, GroupName = "未选择" });
                     view.Code = StatusCodes.Status200OK;
                     view.Msg = "成功!";
                     view.Data = _groupNameList;

+ 10 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/FeeAuditRepository.cs

@@ -383,6 +383,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == diId).FirstAsync();
                 if (groupDetails != null) groupSize = groupDetails.VisitPNumber;
 
+                decimal otherSubTotal = costContents.Sum(x => x.TeFee);
                 decimal groupCostCNYTotal = costContents.Sum(x => x.TeFee) * _teamRate * groupSize; //团组成本出行物资总金额
                 if (groupCostCNYTotal <= 0.00M)
                 {
@@ -418,6 +419,15 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     }
                 }
                 ids = ids.Distinct().ToList();
+
+                //验证该费用是不是出行物资费用 是:审核 不是:不审核
+                if (!ids.Contains(dataId))
+                {
+                    _view.Msg = $"该费用不属于出行物资,不执行自动审核!";
+                    QuashAudit(currModule, diId, dataId);
+                    return _view;
+                }
+
                 decimal otherFeeCNYTotal = otherFeeDatas.Where(x => ids.Contains(x.Id)).Sum(x => x.FeeTotal);  //其他费用出行物资总金额
                 if (otherFeeCNYTotal <= 0.00M)
                 {

+ 75 - 31
OASystem/OASystem.Infrastructure/Repositories/PersonnelModule/GoodsRepository.cs

@@ -33,7 +33,6 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
         private JsonView _jv;
         private string _url;
         private string _excelPath;
-        
         public GoodsRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
         {
             _mapper = mapper;
@@ -336,6 +335,28 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             return _jv;
         }
 
+        /// <summary>
+        /// 入库/出库 审核类型
+        /// 根据物品类型 处理审核是否需要多部门审核
+        /// </summary>
+        /// <param name="goodsTypeId">物品类型Id </param>
+        /// <returns></returns>
+        public bool GoodsAuditType(int goodsTypeId)
+        {
+            //多部门审核类型Id            
+            var goodsTypeIds = new List<int>() {
+                1420, //1420	贵重物品
+            };
+
+            if (goodsTypeIds.Contains(goodsTypeId))
+            {
+                return true;
+            }
+            
+            return false;
+        }
+
+
         /// <summary>
         /// 物品入库列表(带审核)
         /// </summary>
@@ -376,6 +397,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                 {
                     Id = gs.Id,
                     GoodsId = gs.GoodsId,
+                    GoodsType = gi.Type,
                     BatchNo = gs.BatchNo,
                     GoodsName = gi.Name,
                     Quantity = gs.Quantity,
@@ -403,24 +425,24 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             var finAuditInfo = auditList.FirstOrDefault(x => x.AuditDep == GoodsAuditDepEnum.Financial);
             if (hrAuditInfo != null)
             {
-                if (hrAuditInfo.AuditorIds.Any(x => x == userId))
-                {
-                    hrAuditPer = true;
-                }
+                if (hrAuditInfo.AuditorIds.Any(x => x == userId)) hrAuditPer = true;
             }
             if (finAuditInfo != null)
             {
-                if (finAuditInfo.AuditorIds.Any(x => x == userId))
-                {
-                    finAuditPer = true;
-                }
+                if (finAuditInfo.AuditorIds.Any(x => x == userId)) finAuditPer = true;
             }
+
             foreach (var item in data)
             {
-                item.AuditPers = new GoodsStorageAuditPerView[] {
-                    new (){ AuditPer  = hrAuditPer, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = GoodsAuditDepEnum.Hr.GetEnumDescription()},
-                    new (){ AuditPer  = finAuditPer, AuditDep = GoodsAuditDepEnum.Financial, ButtonText = GoodsAuditDepEnum.Financial.GetEnumDescription()}
-                };
+                var auditDeps = new List<GoodsStorageAuditPerView>();
+                auditDeps.Add(new() { AuditPer = hrAuditPer, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = GoodsAuditDepEnum.Hr.GetEnumDescription() });
+                var auditPer = GoodsAuditType(item.GoodsType);
+                if (auditPer)
+                {
+                    auditDeps.Add(new() { AuditPer = finAuditPer, AuditDep = GoodsAuditDepEnum.Financial, ButtonText = GoodsAuditDepEnum.Financial.GetEnumDescription() });
+                }
+
+                item.AuditPers = auditDeps.ToArray();
             }
 
             _jv.Code = StatusCodes.Status200OK;
@@ -488,9 +510,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             _sqlSugar.BeginTran();
             if (info.Id > 0) //修改
             {
-                var selectInfo = await _sqlSugar.Queryable<Pm_GoodsStorage>()
-                                                .Where(x => x.Id == dto.Id)
-                                                .FirstAsync();
+                var selectInfo = await _sqlSugar.Queryable<Pm_GoodsStorage>().FirstAsync(x => x.Id == dto.Id);
                 var auditStatus = selectInfo.ConfirmStatus;
                 if (auditStatus == GoodsConfirmEnum.Confirmed || auditStatus == GoodsConfirmEnum.PartConfirmed)
                 {
@@ -606,6 +626,14 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                 return _jv;
             }
 
+            var goodsInfo = await _sqlSugar.Queryable<Pm_GoodsInfo>().Where(x => x.IsDel == 0 && x.Id == info.GoodsId).FirstAsync();
+            if (goodsInfo == null)
+            {
+                _jv.Msg = string.Format("物品信息不存在!");
+                return _jv;
+            }
+            int goodsTypeId = goodsInfo.Type;
+
             var preChangeStatus = info.ConfirmStatus;
 
             if (preChangeStatus == dto.ConfirmStatus)
@@ -616,6 +644,12 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
 
             var preInfos = await _sqlSugar.Queryable<Pm_GoodsAudit>().Where(x => x.IsDel == 0 && x.DataId == gsId).ToListAsync();
 
+            //验证是否需要多级确认
+            var isAuditPer = GoodsAuditType(goodsTypeId);
+
+            //单部门审核时默认人事部审核
+            if (!isAuditPer) goodsAuditDep = GoodsAuditDepEnum.Hr;
+
             var auditInfo = preInfos.FirstOrDefault(x => x.Dep == goodsAuditDep);
             if (auditInfo != null)
             {
@@ -655,21 +689,32 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             //入库确认 更改入库状态及扣或增加除库存数、金额
             var confirmStatus = GoodsConfirmEnum.WaitConfirm;
 
-            if (preInfos.Where(x => x.AuditStatus == GoodsConfirmEnum.Confirmed).Count() >= 2)
+            if (isAuditPer) //多级审核确认
             {
-                confirmStatus = GoodsConfirmEnum.Confirmed;
-            }else if (preInfos.Where(x => x.AuditStatus == GoodsConfirmEnum.Confirmed).Count() >= 1)
-            {
-                confirmStatus = GoodsConfirmEnum.PartConfirmed;
-            }
-            else if (preInfos.Where(x => x.AuditStatus == GoodsConfirmEnum.UnApproved).Count() > 0)
-            {
-                confirmStatus = GoodsConfirmEnum.UnApproved;
+                if (preInfos.Where(x => x.AuditStatus == GoodsConfirmEnum.Confirmed).Count() >= 2)
+                {
+                    confirmStatus = GoodsConfirmEnum.Confirmed;
+                }
+                else if (preInfos.Where(x => x.AuditStatus == GoodsConfirmEnum.Confirmed).Count() >= 1)
+                {
+                    confirmStatus = GoodsConfirmEnum.PartConfirmed;
+                }
+                else if (preInfos.Where(x => x.AuditStatus == GoodsConfirmEnum.UnApproved).Count() > 0)
+                {
+                    confirmStatus = GoodsConfirmEnum.UnApproved;
+                }
+                else if (preInfos.Where(x => x.AuditStatus == GoodsConfirmEnum.PartConfirmed).Count() > 0)
+                {
+                    confirmStatus = GoodsConfirmEnum.PartConfirmed;
+                }
             }
-            else if (preInfos.Where(x => x.AuditStatus == GoodsConfirmEnum.PartConfirmed).Count() > 0)
+            else //人事部审核确认
             {
-                confirmStatus = GoodsConfirmEnum.PartConfirmed;
+                confirmStatus = GoodsConfirmEnum.Confirmed;
+                confirmStatus = dto.ConfirmStatus;
+                preInfos = preInfos.Where(x => x.Dep == GoodsAuditDepEnum.Hr).ToList();
             }
+
             //入库状态描述
             var statusDesc = new StringBuilder();
             foreach (var preInfo in preInfos)
@@ -704,7 +749,6 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             decimal auditQuantity = info.Quantity,
                     auditTotalPrice = info.TotalPrice;
 
-            var goodsInfo = await _sqlSugar.Queryable<Pm_GoodsInfo>().FirstAsync(x => x.Id == info.GoodsId);
             goodsInfo.LastUpdateUserId = currUserId;
             goodsInfo.LastUpdateTime = DateTime.Now;
             if (confirmStatus == GoodsConfirmEnum.Confirmed) // 确认状态
@@ -789,7 +833,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
         /// 2:出库审核
         /// </param>
         /// <returns></returns>
-        public List<GoodsAuditDepView> GoodsStorageConfirmAuditDep(int auditType=1)
+        public List<GoodsAuditDepView> GoodsStorageConfirmAuditDep(int auditType = 1)
         {
             var auditList = new List<GoodsAuditDepView>();
 
@@ -806,7 +850,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             {
                 AuditDep = GoodsAuditDepEnum.Financial,
                 AuditorIds = new int[] {
-                    187,    // 曾艳 
+                    187,    // 曾艳 
                     281,    // 伏虹瑾
                     208,    // 雷怡
                 }
@@ -1511,7 +1555,6 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                     break;
                 case GoodsAuditEnum.OutConfirmed: //出库确认
                     _jv = await GoodsReceiveOutConfirming(receiveInfo, userId, auditDep, auditEnum);
-                    //TODO:出库成功 并且是团组相关物资 向团组其他款项添加信息
 
                     break;
                 case GoodsAuditEnum.OutRejected:  //出库拒绝
@@ -1523,6 +1566,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             {
                 _sqlSugar.CommitTran();
                 _jv.Msg = $"操作成功!";
+                _jv.Data = auditEnum;
                 return _jv;
             }