yuanrf 14 hours ago
parent
commit
06fccd6ec1
1 changed files with 35 additions and 6 deletions
  1. 35 6
      OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

+ 35 - 6
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -18,6 +18,7 @@ using System.Data;
 using System.Diagnostics;
 using System.Globalization;
 using static OASystem.API.OAMethodLib.JWTHelper;
+using OASystem.API.OAMethodLib.DeepSeekAPI;
 
 namespace OASystem.API.Controllers
 {
@@ -40,6 +41,7 @@ namespace OASystem.API.Controllers
         private readonly GoodsRepository _goodsRep;
         private readonly DecreasePaymentsRepository _otherPaymentRep;
         private readonly FeeAuditRepository _feeAuditRep;
+        private readonly IDeepSeekService _deepSeekService;
 
         private readonly string url;
         private readonly string path;
@@ -57,6 +59,7 @@ namespace OASystem.API.Controllers
         /// <param name="sqlSugar"></param>
         /// <param name="otherPaymentRep"></param>
         /// <param name="feeAuditRep"></param>
+        /// <param name="deepSeekService"></param>
         public PersonnelModuleController(
             IHubContext<ChatHub, IChatClient> hubContext,
             IMapper mapper,
@@ -67,7 +70,8 @@ namespace OASystem.API.Controllers
             GoodsRepository goodsRep,
             SqlSugarClient sqlSugar,
             DecreasePaymentsRepository otherPaymentRep,
-            FeeAuditRepository feeAuditRep
+            FeeAuditRepository feeAuditRep,
+            IDeepSeekService deepSeekService
             )
         {
             _mapper = mapper;
@@ -90,6 +94,7 @@ namespace OASystem.API.Controllers
             _goodsRep = goodsRep;
             _otherPaymentRep = otherPaymentRep;
             _feeAuditRep = feeAuditRep;
+            _deepSeekService = deepSeekService;
         }
 
         #region 工资表单
@@ -3165,12 +3170,36 @@ OPTION (MAXRECURSION 0); -- 允许无限递归      ";
                 detailViews.Add(approval_detail);
             }
 
-            jw.Data = new
+            string question = $"请根据以下数据分析用户绩效:";
+            question += $"外出打卡信息:{JsonConvert.SerializeObject(checkin_data.checkindata)}";
+            if (approval_data.sp_no_list.Count > 0)
             {
-                checkin_data = checkin_data.checkindata,
-                approval_data = approval_data.sp_no_list,
-                detailViews = detailViews
-            };
+                question += $"外出申请信息:{JsonConvert.SerializeObject(detailViews)}";
+            }
+            question += $"请根据以上数据分析用户绩效,按照一个月拜访20个客户的标准给出是否合格,并给出分析报告。";
+
+            try
+            {
+                var resp = await _deepSeekService.ChatAsync(question);
+                if (!resp.Success)
+                {
+                    jw.Msg = "Ai分析用户绩效失败!" + resp.Message;
+                    return Ok(jw);
+                }
+
+                jw.Data = new
+                {
+                    checkin_data = checkin_data.checkindata,
+                    approval_data = approval_data.sp_no_list,
+                    detailViews = detailViews,
+                    Answer = resp.Answer
+                };
+            }
+            catch (Exception ex)
+            {
+                jw.Msg = "Ai分析用户绩效失败!" + ex.Message;
+                return Ok(jw);
+            }
 
             jw.Code = 200;
             jw.Msg = "查询成功!";