浏览代码

添加机票费用自动审核功能及相关修改

在 `GroupsController.cs` 中添加了对 `OASystem.Domain.ViewModels.Statistics` 的引用,并实现了新的私有方法 `AirTicketResAutoAudit`,用于机票费用的自动审核,包含多个数据库查询和逻辑处理。同时,更新了 `AirTicketResAutoAuditTest` 方法以返回审核状态和消息。

在 `PersonnelModuleController.cs` 中,修改了 `CreateUserId` 的赋值方式,并添加了对 `receiveInfo.Remark` 的检查,以确保备注信息的正确性。

在 `DailyFeePaymentRepository.cs` 中,新增了费用类型 `物资采购`。在 `FeeAuditRepository.cs` 中,保留了当前舱位类型的逻辑,但注释掉了与当前舱位费用相关的代码。
Lyyyi 2 月之前
父节点
当前提交
a77b58779b

+ 107 - 4
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -29,6 +29,7 @@ using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.OCR;
+using OASystem.Domain.ViewModels.Statistics;
 using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Financial;
 using OASystem.Infrastructure.Repositories.Groups;
@@ -39,6 +40,7 @@ using System.Data;
 using System.Diagnostics;
 using System.Globalization;
 using System.IO.Compression;
+using System.Text.Json.Nodes;
 using System.Web;
 using static OASystem.API.OAMethodLib.JWTHelper;
 using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
@@ -4254,7 +4256,16 @@ FROM
                 int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
 
                 //自动审核
-                var autoAdit = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId);
+                var autoAdit = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
+
+                #region 舱位单价方式
+               
+
+
+
+                #endregion
+
+
 
 
                 await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
@@ -4282,9 +4293,101 @@ FROM
             return Ok(JsonView(true, groupData.Msg, groupData.Data));
         }
 
+        /// <summary>
+        /// 机票费用自动审核 AI识别方式
+        /// </summary>
+        /// <returns></returns>
+        private async Task<(bool, string)> AirTicketResAutoAudit(int diId,int dataId)
+        {
+            var auditFeeTypeIds = new List<int>() {
+                    457,   //头等舱
+                    458,   //公务舱
+                    459,   //超经舱
+                    460,   //经济舱
+                    1430,  //公务舱(实际经济舱)
+                    1431,  //头等舱(实际公务舱)
+                    1432,  //头等舱(实际经济舱)
+                };
+
+            int currModule = 85;
+            var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
+                .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
+                .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
+                .Select((x, y) => new {
+                    x.Id,
+                    CcpId = y.Id,
+                    x.FlightsDate,
+                    x.Price,
+                    x.CType,
+                    x.ClientNum,
+                    x.DIId
+                })
+                .FirstAsync();
+            if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
+
+            var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
+            if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
+
+            var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
+            if (groupCostInfo == null) return (false, "团组成本信息未填写!");
+
+            var groupCostContents = await _sqlSugar
+                .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
+                .Where(x => x.IsDel == 0 && x.Diid == diId)
+                .ToListAsync();
+            if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
+
+            //处理 成本详细信息日期为空 填装费用信息 
+            var airFeeLabel = new StringBuilder();
+            for (int i = 0; i < groupCostContents.Count; i++)
+            {
+                if (string.IsNullOrEmpty(groupCostContents[i].Date))
+                {
+                    int index = i - 1;
+                    if (index >= 0)
+                    {
+                        groupCostContents[i].Date = groupCostContents[index].Date;
+                        var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
+                        if (dtBool) groupCostContents[i].CurrTime = _dateTime;
+                    }
+                }
+                else
+                {
+                    var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
+                    if (dtBool) groupCostContents[i].CurrTime = _dateTime;
+                }
+
+                var item = groupCostContents[i];
+                airFeeLabel.AppendLine($"{item.Date}");
+                airFeeLabel.AppendLine($"{item.ITIN.Replace("\n"," ")}");
+            }
+            airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
+            airFeeLabel.AppendLine($"取出{airInfo.FlightsDate}费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
+
+            //访问Kimi AI 返回价格结果
+            var msgs = new List<SeedMessages>()
+                {
+                   new ()
+                   {
+                        Role = KimiRole.user,
+                        Content = airFeeLabel.ToString()
+                   }
+                };
+
+            KiMiApiClient client = new KiMiApiClient();
+            var kimiApiResult = await client.SeedMessage(msgs);
+            var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
+            string clients = kimiApiResult_JObject["content"].ToString();
+
+
+
+
+            return (false,"不可自动审核!");
+        }
+
         /// <summary>
         /// 机票费用录入
-        /// 自动审核测试
+        /// 自动审核测试 - AI 识别
         /// </summary>
         /// <param name="groupId"></param>
         /// <param name="Id"></param>
@@ -4293,9 +4396,9 @@ FROM
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
         {
-            var autoAdit = await _feeAuditRep.FeeAutomaticAudit(5, groupId, Id);
+            (bool status,string msg) = await AirTicketResAutoAudit(groupId, Id);
 
-            return Ok(JsonView(true, autoAdit.Msg, autoAdit.Data));
+            return Ok(JsonView(status, msg));
         }
 
         /// <summary>

+ 19 - 5
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -2239,8 +2239,8 @@ WHERE
                 SupplierName = "-",
                 SupplierSocialAccount = "-",
                 SupplierTypeId = 0,
-                CreateUserId = currUserInfo.UserId,
-                Remark = $"物资领用模块添加"
+                CreateUserId = receiveInfo.CreateUserId,
+                Remark = $"物资领用模块添加!!"
             };
 
             //其他费用
@@ -2433,7 +2433,6 @@ WHERE
 
             //if (!auditEnums.Contains(receiveInfo.AuditStatus)) 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);
 
@@ -2478,6 +2477,8 @@ WHERE
 
             string remark = $"物资领用模块添加!需核对领用物品价格!!!";
 
+            if (!string.IsNullOrEmpty(receiveInfo.Remark)) remark = $"{receiveInfo.Remark}\n物资领用模块添加!需核对领用物品价格!!!";
+
             var requestData = new DecreasePaymentsOpDto()
             {
                 Status = 1,
@@ -2502,12 +2503,25 @@ WHERE
                 SupplierName = "-",
                 SupplierSocialAccount = "-",
                 SupplierTypeId = 0,
-                CreateUserId = currUserInfo.UserId,
+                CreateUserId = receiveInfo.CreateUserId,
                 Remark = remark
             };
 
-            //其他费用
 
+            //1   2590 √
+            //2   2737 √ √
+            //3   2760 √ √
+            //4   2761 √ √
+            //5   2788 √ √
+            //6   2796 √ √
+            //7   2809 √ √
+            //8   2833 √ √
+            //9   2834 √ √
+            //10  2839 √ √
+            //11  2846 √ √
+
+
+            //其他费用
             #region 调用方法
             JsonView groupData = await _otherPaymentRep.OpDecreasePayments(requestData);
             if (groupData.Code != 200)

+ 1 - 0
OASystem/OASystem.Infrastructure/Repositories/Financial/DailyFeePaymentRepository.cs

@@ -71,6 +71,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
                 55, //大运会
                 90, //各部门基础固定费用明细
                 104, //团组费用
+                116, //物资采购
             };
             var priceTypeData = setTypeData.Where(s => typeIds.Contains(s.Id)).ToList();
             var priceSubTypeData = setData.Where(s => typeIds.Contains(s.STid)).ToList();

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

@@ -662,7 +662,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 //decimal currAirFee = 0.00M;      //当前舱位录入费用
                 decimal currAirCost = 0.00M;     //当前舱位成本费用
 
-
                 switch (airInfo.CType)
                 {
                     //头等舱