|
|
@@ -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 工资表单
|
|
|
@@ -3108,5 +3113,103 @@ OPTION (MAXRECURSION 0); -- 允许无限递归 ";
|
|
|
//}
|
|
|
|
|
|
#endregion
|
|
|
+
|
|
|
+ #region Ai绩效分析
|
|
|
+
|
|
|
+ [HttpGet]
|
|
|
+ public async Task<IActionResult> AiPerformanceAnalysis_JobMarketingAsync(int userId, DateTime start, DateTime end)
|
|
|
+ {
|
|
|
+ var jw = JsonView(false);
|
|
|
+
|
|
|
+ var user_entity = _sqlSugar.Queryable<Sys_Users>()
|
|
|
+ .First(e => e.Id == userId && e.IsDel == 0);
|
|
|
+
|
|
|
+ if (user_entity == null)
|
|
|
+ {
|
|
|
+ jw.Msg = "用户不存在!";
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<string> useridlist = new List<string> { user_entity.QiyeChatUserId };
|
|
|
+
|
|
|
+ //获取企微外出打卡信息
|
|
|
+ var checkin_data = await _qiYeWeChatApiService.GetCheckinDataAsync(useridlist, 2, start, end);
|
|
|
+ if (checkin_data.errcode != 0)
|
|
|
+ {
|
|
|
+ jw.Msg = "获取企微外出打卡信息失败!" + checkin_data.errmsg;
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取企微外出申请信息
|
|
|
+ var approval_data = await _qiYeWeChatApiService.GetApprovalInfoUpdateAsync(start, end, newCursor: "", size: 100, filters: new List<IQiYeWeChatApiService.FilterCondition>(){
|
|
|
+ new
|
|
|
+ IQiYeWeChatApiService.FilterCondition{
|
|
|
+ key = "creator",
|
|
|
+ value = user_entity.QiyeChatUserId
|
|
|
+ },
|
|
|
+ new IQiYeWeChatApiService.FilterCondition{
|
|
|
+ key="record_type",
|
|
|
+ value="4"
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (approval_data.errcode != 0)
|
|
|
+ {
|
|
|
+ jw.Msg = "获取企微外出申请信息失败!" + approval_data.errmsg;
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ApprovalDetailView> detailViews = new List<ApprovalDetailView>();
|
|
|
+ foreach (var item in approval_data.sp_no_list)
|
|
|
+ {
|
|
|
+ var approval_detail = await _qiYeWeChatApiService.GetApprovalDetailAsync(item);
|
|
|
+ if (approval_detail.errcode != 0)
|
|
|
+ {
|
|
|
+ jw.Msg = "获取企微外出申请详情失败!" + approval_detail.errmsg;
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+ detailViews.Add(approval_detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ string question = $"请根据以下数据分析用户绩效:";
|
|
|
+ question += $"外出打卡信息:{JsonConvert.SerializeObject(checkin_data.checkindata)}";
|
|
|
+ if (approval_data.sp_no_list.Count > 0)
|
|
|
+ {
|
|
|
+ question += $"外出申请信息:{JsonConvert.SerializeObject(detailViews)}";
|
|
|
+ }
|
|
|
+ question += $"请根据我提供的{user_entity.CnName}数据信息(提供的数据已经是一个月的数据),按照一个月拜访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 = "查询成功!";
|
|
|
+
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
}
|
|
|
}
|