yuanrf vor 2 Tagen
Ursprung
Commit
17ed7e5a70

+ 226 - 15
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -61,6 +61,8 @@ using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
 using Bookmark = Aspose.Words.Bookmark;
 using Cell = Aspose.Words.Tables.Cell;
 using Table = Aspose.Words.Tables.Table;
+using OASystem.Domain.Dtos.PersonnelModule;
+using OASystem.API.OAMethodLib.DoubaoAPI;
 
 namespace OASystem.API.Controllers
 {
@@ -98,7 +100,7 @@ namespace OASystem.API.Controllers
         private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
         private readonly GroupCostParameterRepository _GroupCostParameterRepository;
         #endregion
-
+        private readonly IDoubaoService _doubaoService;
         private readonly SetDataRepository _setDataRep;
         private string url;
         private string path;
@@ -264,7 +266,8 @@ namespace OASystem.API.Controllers
             VisaProcessRepository visaProcessRep,
             ProcessOverviewRepository processOverviewRep,
             DynamicSearchService<Grp_DelegationInfo> groupSearchService,
-            IDeepSeekService deepSeekService
+            IDeepSeekService deepSeekService,
+            IDoubaoService doubaoService
             )
         {
             _logger = logger;
@@ -329,6 +332,7 @@ namespace OASystem.API.Controllers
             _processOverviewRep = processOverviewRep;
             _groupSearchService = groupSearchService;
             _deepSeekService = deepSeekService;
+            _doubaoService = doubaoService;
         }
 
         #region 页面加载弹窗信息
@@ -4751,7 +4755,7 @@ FROM
         /// <returns></returns>
         [HttpGet]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> VisaFileDownload1(int groupId, int fileTypeId,int language=1)
+        public async Task<IActionResult> VisaFileDownload1(int groupId, int fileTypeId, int language = 1)
         {
             if (!_visaTypeInit.TryGetValue(fileTypeId, out _))
             {
@@ -8423,7 +8427,7 @@ FROM
                 }
             };
 
-            (bool resStatus,string msg,string downloadUrl) = await GeneratorFileAsync(generatorFileReq);
+            (bool resStatus, string msg, string downloadUrl) = await GeneratorFileAsync(generatorFileReq);
 
             if (resStatus)
             {
@@ -8973,7 +8977,7 @@ FROM
                     }
                     catch (Exception ex)
                     {
-                        return (false, $"生成PDF文件时出错:{ex.Message}",string.Empty);
+                        return (false, $"生成PDF文件时出错:{ex.Message}", string.Empty);
                     }
                     finally
                     {
@@ -9625,7 +9629,7 @@ FROM
                 .Replace(@"\", "/")
                 .Replace("D:/FTP/File/OA2023", "http://132.232.92.186:24", StringComparison.OrdinalIgnoreCase);
 
-            return (true,fullPath, downloadUrl);
+            return (true, fullPath, downloadUrl);
         }
 
         /// <summary>
@@ -9987,9 +9991,9 @@ FROM
         /// </summary>
         /// <param name="jsonstring"></param>
         /// <returns></returns>
-        private async Task<Dictionary<string,string>> DeepSeekCNToENAsync(string jsonstring)
+        private async Task<Dictionary<string, string>> DeepSeekCNToENAsync(string jsonstring)
         {
-            var dic = new Dictionary<string,string>();
+            var dic = new Dictionary<string, string>();
 
             string question = $@"JSON中文字段转英文大写
 任务
@@ -13639,25 +13643,232 @@ FROM
                 return Ok(jw);
             }
 
-            if (dto.isFileClient)
+            var clients = await _sqlSugar.Queryable<Grp_TourClientList>()
+                           .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
+                           .ToListAsync();
+
+            if (!clients.Any())
+            {
+                jw.Msg = "团组客户信息不存在!";
+                return Ok(jw);
+            }
+
+            var TravelList = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
+            .Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToListAsync();
+
+            if (!TravelList.Any())
+            {
+                jw.Msg = "团组行程信息不存在!";
+                return Ok(jw);
+            }
+
+            string chat = string.Empty;
+
+            var templateSetting = await _sqlSugar.Queryable<Sys_SetData>().FirstAsync(x => x.Id == 1550 && x.IsDel == 0);
+            if (templateSetting != null && !string.IsNullOrEmpty(templateSetting.Remark))
             {
+                var stringFormatResp = await GeneralMethod.StringFormatAsync(new StringFormatDto
+                {
+                    FormatTemplate = templateSetting.Remark,
+                    Parameters = new List<string> {
+                            JsonConvert.SerializeObject(clients),
+                             JsonConvert.SerializeObject(TravelList)
+                        }
+                });
 
+                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 clients = await _sqlSugar.Queryable<Grp_TourClientList>()
-                           .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
-                           .ToListAsync();
 
-                if (!clients.Any())
+            var chatResult = await _doubaoService.CompleteChatAsync(new List<DouBaoChatMessage> { new DouBaoChatMessage { Role = DouBaoRole.user, Content = chat } });
+
+            if (string.IsNullOrEmpty(chatResult))
+            {
+                jw.Msg = "请示文件生成失败!";
+                return Ok(jw);
+            }
+
+            return Ok(JsonView(true, "请示文件生成成功!", chatResult));
+        }
+
+        /// <summary>
+        /// 企业拜访内容续写
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> BusinessEnterpriseContinueWrite(BusinessEnterpriseContinueWriteDto dto)
+        {
+            var jw = JsonView(false);
+
+            if (string.IsNullOrEmpty(dto.DepartEnterpriseName))
+            {
+                jw.Msg = "出访企业名称不能为空!";
+                return Ok(jw);
+            }
+
+            if (dto.EnterpriseNames == null || dto.EnterpriseNames.Count == 0)
+            {
+                jw.Msg = "企业名称列表不能为空!";
+                return Ok(jw);
+            }
+
+            ArrayList result = new ArrayList();
+
+            foreach (var enterpriseName in dto.EnterpriseNames)
+            {
+                var kimiResult = await this.ApprovalJourneyAiWrite(new ApprovalJourneyAiWriteDto { ClientName = dto.DepartEnterpriseName, ClientPurpose = enterpriseName });
+                result.Add(new
+                {
+                    EnterpriseName = enterpriseName,
+                    Content = kimiResult
+                });
+            }
+
+            return Ok(JsonView(true, "企业拜访内容续写成功!", result));
+        }
+
+        /// <summary>
+        /// 行程单位安排
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> BusinessSynchronizationWrite(BusinessSynchronizationWriteDto dto)
+        {
+            var jw = JsonView(false);
+
+            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())
+            {
+                jw.Msg = "团组行程信息不存在!";
+                return Ok(jw);
+            }
+
+            if (dto.EnterpriseNames == null || dto.EnterpriseNames.Count == 0)
+            {
+                jw.Msg = "企业名称列表不能为空!";
+                return Ok(jw);
+            }
+
+            string chat = string.Empty;
+            var templateSetting = await _sqlSugar.Queryable<Sys_SetData>().FirstAsync(x => x.Id == 1552 && x.IsDel == 0);
+            if (templateSetting != null && !string.IsNullOrEmpty(templateSetting.Remark))
+            {
+                var stringFormatResp = await GeneralMethod.StringFormatAsync(new StringFormatDto
+                {
+                    FormatTemplate = templateSetting.Remark,
+                    Parameters = new List<string> {
+                            JsonConvert.SerializeObject(dto.EnterpriseNames),
+                             JsonConvert.SerializeObject(travelList)
+                        }
+                });
+
+                if (stringFormatResp.Success)
+                {
+                    chat = stringFormatResp.FormattedResult;
+                }
+                else
                 {
-                    jw.Msg = "团组客户信息不存在!";
+                    jw.Msg = "对话内容模板格式化失败! templateSetting.Id: " + templateSetting.Id + ",错误:" + stringFormatResp.Message;
                     return Ok(jw);
                 }
             }
+            else
+            {
+                jw.Msg = "获取对话内容模板失败! templateSetting.Id: " + templateSetting.Id;
+                return Ok(jw);
+            }
+
+            var chatResult = await _doubaoService.CompleteChatAsync(new List<DouBaoChatMessage> { new DouBaoChatMessage { Role = DouBaoRole.user, Content = chat } });
+            if (string.IsNullOrEmpty(chatResult))
+            {
+                jw.Msg = "报批日程安排失败!";
+                return Ok(jw);
+            }
+
+            var jsonResult = JsonConvert.DeserializeObject<List<Grp_ApprovalTravelDetails>>(chatResult);
+            if (!jsonResult.Any())
+            {
+                jw.Msg = "AI报批日程安排失败!";
+                return Ok(jw);
+            }
+
+            _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(jsonResult)
+            .UpdateColumns(x => new { x.Details })
+            .ExecuteCommand();
+
+            return Ok(JsonView(true, "报批日程安排成功!", chatResult));
+
+        }
+
+
+        /// <summary>
+        /// 商邀Ai行程框架导出
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> BusinessJourneyFileDown(BusinessJourneyFileDownDto dto)
+        {
+            var jw = JsonView(false);
+
+            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())
+            {
+                jw.Msg = "团组行程信息不存在!";
+                return Ok(jw);
+            }
+
+            var groupTraveList = travelList
+            .Where(x => !string.IsNullOrWhiteSpace(x.行程安排))
+            .GroupBy(x => x.日期).ToList();
+
+            var grouopTraveListByStr = groupTraveList.ToDictionary(
+                x => x.Key,
+                x => string.Join("\r\n", x.Select(y => $"{y.具体时间} {y.行程安排}".Trim()))
+            );
+
+            return Ok(JsonView(true, "团组行程信息导出成功!", grouopTraveListByStr));
 
-            return Ok(JsonView(true, "请示文件生成成功!"));
         }
 
         #endregion

+ 1 - 0
OASystem/OASystem.Api/OAMethodLib/DoubaoAPI/DoubaoService.cs

@@ -40,6 +40,7 @@ namespace OASystem.API.OAMethodLib.DoubaoAPI
             options ??= new CompleteChatOptions();
             var httpClient = _httpClientFactory.CreateClient("Doubao");
             httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _doubaoSetting.ApiKey);
+            httpClient.Timeout.Add(TimeSpan.FromMinutes(10));
 
             var body = new Dictionary<string, object>
             {

+ 5 - 4
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -549,12 +549,12 @@ namespace OASystem.API.OAMethodLib
                 return (false, "当前费用不存在,不可操作!");
 
             // 自动审核 费用类型为签证时不校验
-            if (feeType !=  80)
+            if (feeType != 80)
             {
                 if (ccpInfo.IsAuditGM == 3)
                     return (false, "当前费用已自动审核,不可操作!");
             }
-           
+
             // 已审核
             if (ccpInfo.IsAuditGM == 1)
                 return (false, "当前费用已审核,不可操作!");
@@ -979,7 +979,7 @@ namespace OASystem.API.OAMethodLib
 
                 //美元(USD):7.5|
                 string rateStr = rate.FSellPri ?? "0.00";
-                
+
                 rateInfoStr += $"{rate.Name}({oaCurrncy.Name}):{rateStr}|";
             }
 
@@ -6833,8 +6833,9 @@ namespace OASystem.API.OAMethodLib
                     });
                 }
 
+                var parameters = dto.Parameters.Cast<object>().ToArray();
                 // 格式化字符串
-                string formattedResult = string.Format(dto.FormatTemplate, dto.Parameters.Cast<object>().ToArray());
+                string formattedResult = string.Format(dto.FormatTemplate, parameters);
 
                 var result = new StringFormatView
                 {

+ 18 - 1
OASystem/OASystem.Domain/Dtos/Groups/InvitationOfficialActivitiesListDto.cs

@@ -230,7 +230,24 @@ namespace OASystem.Domain.Dtos.Groups
     public class BusinessInvitationInstructionsFileDto
     {
         public int Diid { get; set; }
+    }
+
+    public class BusinessEnterpriseContinueWriteDto
+    {
+        public string DepartEnterpriseName { get; set; }
+
+        public List<string> EnterpriseNames { get; set; }
+    }
+
+    public class BusinessSynchronizationWriteDto
+    {
+        public int Diid { get; set; }
+
+        public List<string> EnterpriseNames { get; set; }
+    }
 
-        public bool isFileClient { get; set; } = false;
+    public class BusinessJourneyFileDownDto
+    {
+        public int Diid { get; set; }
     }
 }

+ 16 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/ApprovalTravelRepository.cs

@@ -0,0 +1,16 @@
+using OASystem.Domain.Entities.Groups;
+using OASystem.Domain;
+
+namespace OASystem.Infrastructure.Repositories.Groups
+{
+    /// <summary>
+    /// 报批行程仓储
+    /// </summary>
+    public class ApprovalTravelRepository : BaseRepository<Grp_ApprovalTravel, Grp_ApprovalTravel>
+    {
+        public ApprovalTravelRepository(SqlSugarClient sqlSugar)
+            : base(sqlSugar)
+        {
+        }
+    }
+}