|
|
@@ -4171,7 +4171,7 @@ FROM
|
|
|
return Ok(JsonView(false, "公司信息添加失败!"));
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
// 存在信息为空则更新公司地址信息
|
|
|
if (string.IsNullOrEmpty(compnayInfo.Address))
|
|
|
@@ -13777,20 +13777,44 @@ FROM
|
|
|
return Ok(jw);
|
|
|
}
|
|
|
|
|
|
- var clients = await _sqlSugar.Queryable<Grp_TourClientList>()
|
|
|
- .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
|
|
|
- .ToListAsync();
|
|
|
+ var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
|
|
|
+ .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
|
|
|
+ .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
|
|
|
+ .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.Diid)
|
|
|
+ .Select((tcl, dc, cc) => new ClientInfo
|
|
|
+ {
|
|
|
+ LastName = dc.LastName,
|
|
|
+ FirstName = dc.FirstName,
|
|
|
+ Sex = dc.Sex,
|
|
|
+ Birthday = dc.BirthDay,
|
|
|
+ Company = cc.CompanyFullName,
|
|
|
+ Job = dc.Job
|
|
|
+ })
|
|
|
+ .ToList();
|
|
|
+ foreach (var item in DeleClientList)
|
|
|
+ {
|
|
|
+ EncryptionProcessor.DecryptProperties(item);
|
|
|
+ }
|
|
|
|
|
|
- if (!clients.Any())
|
|
|
+ if (!DeleClientList.Any())
|
|
|
{
|
|
|
jw.Msg = "团组客户信息不存在!";
|
|
|
return Ok(jw);
|
|
|
}
|
|
|
|
|
|
- var TravelList = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
|
|
|
- .Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToListAsync();
|
|
|
+ var travelList = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
|
|
|
+ .LeftJoin<Grp_ApprovalTravelDetails>((x, a) => x.Id == a.ParentId && a.IsDel == 0)
|
|
|
+ .Where((x, a) => x.IsDel == 0 && x.Diid == dto.Diid)
|
|
|
+ .Select((x, a) => new
|
|
|
+ {
|
|
|
+ 日期 = x.Date,
|
|
|
+ 具体时间 = a.Time,
|
|
|
+ 行程安排 = a.Details,
|
|
|
+ 数据id = a.Id,
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
|
|
|
- if (!TravelList.Any())
|
|
|
+ if (!travelList.Any())
|
|
|
{
|
|
|
jw.Msg = "团组行程信息不存在!";
|
|
|
return Ok(jw);
|
|
|
@@ -13805,8 +13829,8 @@ FROM
|
|
|
{
|
|
|
FormatTemplate = templateSetting.Remark,
|
|
|
Parameters = new List<string> {
|
|
|
- JsonConvert.SerializeObject(clients),
|
|
|
- JsonConvert.SerializeObject(TravelList)
|
|
|
+ JsonConvert.SerializeObject(DeleClientList),
|
|
|
+ JsonConvert.SerializeObject(travelList)
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -13826,9 +13850,10 @@ FROM
|
|
|
return Ok(jw);
|
|
|
}
|
|
|
|
|
|
+ Console.WriteLine(chat);
|
|
|
|
|
|
// var chatResult = await _doubaoService.CompleteChatAsync(new List<DouBaoChatMessage> { new DouBaoChatMessage { Role = DouBaoRole.user, Content = chat } });
|
|
|
- var apiResp = await _deepSeekService.ChatAsync(chat);
|
|
|
+ var apiResp = await _deepSeekService.ChatAsync(chat, false, "deepseek-reasoner", 0.7f, 60000);
|
|
|
var chatResult = apiResp.Answer;
|
|
|
|
|
|
if (string.IsNullOrEmpty(chatResult))
|
|
|
@@ -13837,9 +13862,30 @@ FROM
|
|
|
return Ok(jw);
|
|
|
}
|
|
|
|
|
|
- return Ok(JsonView(true, "请示文件生成成功!", chatResult));
|
|
|
+ string outputPath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{groupInfo.TeamName}请示文件.docx";
|
|
|
+
|
|
|
+ string json = chatResult;
|
|
|
+ byte[] wordBytes = JsonToWordHelper.ConvertJsonToWord(json);
|
|
|
+ System.IO.File.WriteAllBytes(outputPath, wordBytes);
|
|
|
+
|
|
|
+ //WordExporter.MarkdownToWord(chatResult, outputPath);
|
|
|
+ string url = outputPath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath"));
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "请示文件生成成功!", url));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // [HttpPost("export-word")]
|
|
|
+ // public IActionResult ExportWord([FromBody] string json)
|
|
|
+ // {
|
|
|
+ // var bytes = JsonToWordHelper.ConvertJsonToWord(json);
|
|
|
+
|
|
|
+ // return File(
|
|
|
+ // bytes,
|
|
|
+ // "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
|
+ // "出访请示.docx");
|
|
|
+ // }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 企业拜访内容续写
|
|
|
/// </summary>
|
|
|
@@ -13851,33 +13897,101 @@ FROM
|
|
|
{
|
|
|
var jw = JsonView(false);
|
|
|
|
|
|
- if (string.IsNullOrEmpty(dto.DepartEnterpriseName))
|
|
|
+ var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
|
|
|
+ .Where(x => x.IsDel == 0 && x.Id == dto.Diid)
|
|
|
+ .FirstAsync();
|
|
|
+
|
|
|
+ var resultArr = new ArrayList();
|
|
|
+ var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).ToList();
|
|
|
+ const int chiNumber = 5;
|
|
|
+
|
|
|
+ if (!content.Any())
|
|
|
{
|
|
|
- jw.Msg = "出访企业名称不能为空!";
|
|
|
+ jw.Msg = "团组行程信息不存在!";
|
|
|
return Ok(jw);
|
|
|
}
|
|
|
|
|
|
- if (dto.EnterpriseNames == null || dto.EnterpriseNames.Count == 0)
|
|
|
+ foreach (var x in content)
|
|
|
{
|
|
|
- jw.Msg = "企业名称列表不能为空!";
|
|
|
- return Ok(jw);
|
|
|
- }
|
|
|
+ var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
|
|
|
+ if (chiList.Count < chiNumber)
|
|
|
+ {
|
|
|
+ for (int i = chiList.Count; i < chiNumber; i++)
|
|
|
+ {
|
|
|
+ chiList.Add(new Grp_ApprovalTravelDetails());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- ArrayList result = new ArrayList();
|
|
|
+ resultArr.Add(new
|
|
|
+ {
|
|
|
+ x.Id,
|
|
|
+ x.Date,
|
|
|
+ x.Diid,
|
|
|
+ chiList = chiList.Select(x1 => new
|
|
|
+ {
|
|
|
+ timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
|
|
|
+ x1.Details,
|
|
|
+ x1.ParentId,
|
|
|
+ x1.Id
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- foreach (var enterpriseName in dto.EnterpriseNames)
|
|
|
+ string chat = string.Empty;
|
|
|
+ var templateSetting = await _sqlSugar.Queryable<Sys_SetData>().FirstAsync(x => x.Id == 1554 && x.IsDel == 0);
|
|
|
+ if (templateSetting != null && !string.IsNullOrEmpty(templateSetting.Remark))
|
|
|
{
|
|
|
- var kimiResult = await this.ApprovalJourneyAiWrite(new ApprovalJourneyAiWriteDto { ClientName = dto.DepartEnterpriseName, ClientPurpose = enterpriseName });
|
|
|
- result.Add(new
|
|
|
+ var stringFormatResp = await GeneralMethod.StringFormatAsync(new StringFormatDto
|
|
|
{
|
|
|
- EnterpriseName = enterpriseName,
|
|
|
- Content = kimiResult
|
|
|
+ FormatTemplate = templateSetting.Remark,
|
|
|
+ Parameters = new List<string> {
|
|
|
+ JsonConvert.SerializeObject(resultArr),
|
|
|
+ di.ClientName
|
|
|
+ }
|
|
|
});
|
|
|
+
|
|
|
+ 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 apiResult = await _deepSeekService.ChatAsync(chat, false, "deepseek-reasoner", 0.7f, 60000);
|
|
|
+ var chatResult = apiResult.Answer;
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(chatResult))
|
|
|
+ {
|
|
|
+ jw.Msg = "企业拜访内容续写失败!";
|
|
|
+ return Ok(jw);
|
|
|
}
|
|
|
|
|
|
- return Ok(JsonView(true, "企业拜访内容续写成功!", result));
|
|
|
+ chatResult = GeneralMethod.ExtractJson(chatResult);
|
|
|
+ var JsonResult = JsonDocument.Parse(chatResult);
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "企业拜访内容续写成功!", new
|
|
|
+ {
|
|
|
+ chatResult,
|
|
|
+ JsonResult
|
|
|
+ }));
|
|
|
}
|
|
|
|
|
|
+ // [HttpPost]
|
|
|
+ // public object ToOjbect(ToOjbectDto dto)
|
|
|
+ // {
|
|
|
+ // return JsonDocument.Parse(dto.Value);
|
|
|
+ // }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 行程单位安排
|
|
|
/// </summary>
|
|
|
@@ -13943,7 +14057,7 @@ FROM
|
|
|
}
|
|
|
|
|
|
//var chatResult = await _doubaoService.CompleteChatAsync(new List<DouBaoChatMessage> { new DouBaoChatMessage { Role = DouBaoRole.user, Content = chat } });
|
|
|
- var apiResp = await _deepSeekService.ChatAsync(chat);
|
|
|
+ var apiResp = await _deepSeekService.ChatAsync(chat, false, "deepseek-reasoner", 0.7f, 20000);
|
|
|
var chatResult = apiResp.Answer;
|
|
|
|
|
|
if (string.IsNullOrEmpty(chatResult))
|
|
|
@@ -13981,6 +14095,13 @@ FROM
|
|
|
{
|
|
|
var jw = JsonView(false);
|
|
|
|
|
|
+ var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
|
|
|
+ if (Find == null)
|
|
|
+ {
|
|
|
+ jw.Msg = "请选择正确的团组!";
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
var travelList = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
|
|
|
.LeftJoin<Grp_ApprovalTravelDetails>((x, a) => x.Id == a.ParentId && a.IsDel == 0)
|
|
|
.Where((x, a) => x.IsDel == 0 && x.Diid == dto.Diid)
|
|
|
@@ -14059,7 +14180,7 @@ FROM
|
|
|
}
|
|
|
|
|
|
// var chatResult = await _doubaoService.CompleteChatAsync(new List<DouBaoChatMessage> { new DouBaoChatMessage { Role = DouBaoRole.user, Content = chat } });
|
|
|
- var apiResp = await _deepSeekService.ChatAsync(chat);
|
|
|
+ var apiResp = await _deepSeekService.ChatAsync(chat, false, "deepseek-reasoner", 0.7f, 40000);
|
|
|
var chatResult = apiResp.Answer;
|
|
|
|
|
|
if (string.IsNullOrEmpty(chatResult))
|
|
|
@@ -14068,7 +14189,164 @@ FROM
|
|
|
return Ok(jw);
|
|
|
}
|
|
|
|
|
|
- return Ok(JsonView(true, "行程框架导出成功!", chatResult));
|
|
|
+ chatResult = GeneralMethod.ExtractJson(chatResult);
|
|
|
+ var _travelList = new List<TravelPlan>();
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var jsonResult = JsonConvert.DeserializeObject<List<TravelPlan>>(chatResult);
|
|
|
+ _travelList = jsonResult;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ jw.Msg = "AI行程框架导出失败!(JSON转换失败!)";
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建数据源Table
|
|
|
+ var dtSource = new DataTable();
|
|
|
+ dtSource.Columns.Add("Days", typeof(string));
|
|
|
+ dtSource.Columns.Add("Date", typeof(string));
|
|
|
+ dtSource.Columns.Add("Week", typeof(string));
|
|
|
+ dtSource.Columns.Add("Traffic", typeof(string));
|
|
|
+ dtSource.Columns.Add("Trip", typeof(string));
|
|
|
+
|
|
|
+ var days = 1;
|
|
|
+ //获取数据,放到datatable
|
|
|
+ foreach (var item in _travelList)
|
|
|
+ {
|
|
|
+
|
|
|
+ DataRow dr = dtSource.NewRow();
|
|
|
+ dr["Days"] = days;
|
|
|
+ dr["Date"] = item.Date;
|
|
|
+ dr["Week"] = item.WeekDay;
|
|
|
+ dr["Traffic"] = string.Join("\r\n", item.Traffic);
|
|
|
+ dr["Trip"] = item.Trip;
|
|
|
+ dtSource.Rows.Add(dr);
|
|
|
+ }
|
|
|
+
|
|
|
+ var dic = new Dictionary<string, string>
|
|
|
+ {
|
|
|
+ { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
|
|
|
+ { "City", GeneralMethod.GetGroupCityLine(dto.Diid, "/") },
|
|
|
+ { "Days", Find.VisitDays.ToString() },
|
|
|
+ { "DeleCode", Find.TourCode },
|
|
|
+ { "Pnum", Find.VisitPNumber.ToString() }
|
|
|
+ };
|
|
|
+
|
|
|
+ //模板路径
|
|
|
+ string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
|
|
|
+
|
|
|
+ //载入模板
|
|
|
+ Document doc = null;
|
|
|
+ DocumentBuilder builder = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //载入模板
|
|
|
+ doc = new Document(tempPath);
|
|
|
+ builder = new DocumentBuilder(doc);
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ jw.Msg = "模板位置不存在!";
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var key in dic.Keys)
|
|
|
+ {
|
|
|
+ Bookmark bookmark = doc.Range.Bookmarks[key];
|
|
|
+ if (bookmark != null)
|
|
|
+ {
|
|
|
+ builder.MoveToBookmark(key);
|
|
|
+ builder.Write(dic[key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取word里所有表格
|
|
|
+ NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
|
|
|
+ //获取所填表格的序数
|
|
|
+ Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //循环赋值
|
|
|
+ for (int i = 0; i < dtSource.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ builder.MoveToCell(0, i + 1, 0, 0);
|
|
|
+ builder.Write(dtSource.Rows[i]["Days"].ToString());
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i + 1, 1, 0);
|
|
|
+ builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i + 1, 2, 0);
|
|
|
+ builder.Write(dtSource.Rows[i]["Traffic"].ToString());
|
|
|
+
|
|
|
+ var trip = dtSource.Rows[i]["Trip"].ToString();
|
|
|
+ builder.MoveToCell(0, i + 1, 3, 0);
|
|
|
+ builder.Write(trip);
|
|
|
+
|
|
|
+ var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
|
|
|
+ var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
|
|
|
+
|
|
|
+ // 获取特定索引的段落
|
|
|
+ Paragraph paragraph = (Paragraph)paragraphs[0];
|
|
|
+ Run run = paragraph.Runs[0];
|
|
|
+ Aspose.Words.Font font = run.Font;
|
|
|
+ font.Name = "黑体";
|
|
|
+
|
|
|
+ //设置双休红色
|
|
|
+ cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
|
|
|
+ paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
|
|
|
+ paragraph = (Paragraph)paragraphs[1];
|
|
|
+ if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
|
|
|
+ {
|
|
|
+ run = paragraph.Runs[0];
|
|
|
+ font = run.Font;
|
|
|
+ font.Color = Color.Red;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除多余行
|
|
|
+ while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
|
|
|
+ {
|
|
|
+ tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
|
|
|
+ }
|
|
|
+
|
|
|
+ string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
|
|
|
+ if (!Directory.Exists(savePath))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(savePath);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ string path = savePath + Find.TeamName + "出访日程";
|
|
|
+ string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
|
|
|
+ string postfix = ".docx";
|
|
|
+
|
|
|
+ doc.Save(path + postfix, saveFormat);
|
|
|
+ jw = JsonView(true, "导出成功", ftpPath + postfix);
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ jw = JsonView(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(jw);
|
|
|
}
|
|
|
|
|
|
#endregion
|