|
|
@@ -3199,6 +3199,118 @@ OPTION (MAXRECURSION 0); -- 允许无限递归 ";
|
|
|
return Ok(jw);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 省外员工统一分析
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="userId"></param>
|
|
|
+ /// <param name="start"></param>
|
|
|
+ /// <param name="end"></param>
|
|
|
+ /// <param name="createUserId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet]
|
|
|
+ public async Task<IActionResult> AiPerformanceAnalysis_otherProvincesEmployeeAsync(DateTime start, DateTime end)
|
|
|
+ {
|
|
|
+ var jw = JsonView(false);
|
|
|
+
|
|
|
+ var options = _sqlSugar.Queryable<Sys_SetData>()
|
|
|
+ .First(x => x.Id == 1417);
|
|
|
+
|
|
|
+ List<int> userIds = new List<int>();
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(options.Remark);
|
|
|
+ userIds = result[396].ToList();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ jw.Msg = "解析配置失败!" + ex.Message;
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+ var dbQuery = _sqlSugar.Queryable<Pm_PerformanceAnalysis>()
|
|
|
+ .LeftJoin<Sys_Users>((x, y) => x.UserId == y.Id && y.IsDel == 0)
|
|
|
+ .Where((x, y) => x.IsDel == 0 && userIds.Contains(x.UserId)
|
|
|
+ && x.StartDate == start && x.EndDate == end)
|
|
|
+ .Select((x, y) => new { x.Id, x.JsonResult, x.UserId, x.StartDate, x.EndDate, y.CnName });
|
|
|
+
|
|
|
+ var data = await dbQuery.ToListAsync();
|
|
|
+
|
|
|
+ if (data.Count != userIds.Count)
|
|
|
+ {
|
|
|
+ jw.Data = new { };
|
|
|
+ jw.Code = 203;
|
|
|
+ jw.Msg = "还有" + (userIds.Count - data.Count) + "个用户未生成绩效数据!";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var insertString = string.Empty;
|
|
|
+
|
|
|
+ foreach (var item in data)
|
|
|
+ {
|
|
|
+ var apiResponse = item.JsonResult;
|
|
|
+ if (apiResponse != null)
|
|
|
+ {
|
|
|
+ var apiResponseData = JsonConvert.DeserializeObject<AiResponse>(apiResponse);
|
|
|
+ insertString += $"用户:{item.CnName},绩效分析数据 :{apiResponseData.Answer},考勤分析数据:{apiResponseData.KaoqinAnswer}\r\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var chat = string.Empty;
|
|
|
+ var templateSetting = await _sqlSugar.Queryable<Sys_SetData>().FirstAsync(x => x.Id == 1549 && x.IsDel == 0);
|
|
|
+ if (templateSetting != null && !string.IsNullOrEmpty(templateSetting.Remark))
|
|
|
+ {
|
|
|
+ var stringFormatResp = await GeneralMethod.StringFormatAsync(new StringFormatDto
|
|
|
+ {
|
|
|
+ FormatTemplate = templateSetting.Remark,
|
|
|
+ Parameters = new List<string> {
|
|
|
+ insertString
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (stringFormatResp.Success)
|
|
|
+ {
|
|
|
+ chat = stringFormatResp.FormattedResult;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ jw.Msg = "对话内容模板格式化失败! templateSetting.Id: " + templateSetting.Id + ",错误:" + stringFormatResp.Message;
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ jw.Msg = "获取对话内容模板失败! templateSetting.Id: " + templateSetting.Id;
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+ var resp = await _deepSeekService.ChatAsync(chat);
|
|
|
+ if (!resp.Success)
|
|
|
+ {
|
|
|
+ jw.Msg = "Ai分析用户绩效失败!" + resp.Message;
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+ //转为pdf文件
|
|
|
+ var url = this.MarkdownToWord(new
|
|
|
+ List<WordContentItem>{
|
|
|
+ new
|
|
|
+ WordContentItem{
|
|
|
+ Type = WordContentType.Markdown,
|
|
|
+ MarkdownContent = resp.Answer
|
|
|
+ }
|
|
|
+ }
|
|
|
+ , $"外省市场员工绩效总览_{start.ToString("yyyy-MM-dd")}-{end.ToString("yyyy-MM-dd")}绩效分析");
|
|
|
+
|
|
|
+ jw.Data = new { url };
|
|
|
+ jw.Code = 200;
|
|
|
+ jw.Msg = "操作成功!";
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 市场部员工分析
|
|
|
/// </summary>
|