Browse Source

AI报告模板

Jeremy 2 years ago
parent
commit
3cd5ea601c
1 changed files with 20 additions and 0 deletions
  1. 20 0
      ReportService/Service/ReportService.cs

+ 20 - 0
ReportService/Service/ReportService.cs

@@ -17,6 +17,7 @@ using WingServerCommon.Config.Parameters;
 using ReportService.Posters;
 using Newtonsoft.Json.Linq;
 using Newtonsoft.Json;
+using System.Collections.Concurrent;
 
 namespace ReportService.Service
 {
@@ -42,6 +43,8 @@ namespace ReportService.Service
         private string _reportUrl = ConfigurationManager.GetParammeter<StringParameter>("Report", "ReportUrl").Value;
         private string _reportMessageTemplateId = ConfigurationManager.GetParammeter<StringParameter>("Report", "ReportMessageTemplateId").Value;
 
+        private readonly ConcurrentDictionary<string, string> _aiReportTemplateDictionary = new ConcurrentDictionary<string, string>();
+
         /// <summary>
         /// Init service
         /// </summary>
@@ -91,6 +94,7 @@ namespace ReportService.Service
                     Language = request.Language,
                 });
                 reportInfo.ReportDatasJson = newReportDatasJson;
+                reportInfo.ReportTemplateJson = GetAIReportTemplate(request.Language);
             }
             return reportInfo;
         }
@@ -999,6 +1003,22 @@ namespace ReportService.Service
             }
             return await _reportDBService.CopyThesaurusAsync(request.ThesaurusCode, string.Empty, userInfo.RootOrganizationCode);
         }
+
+        public string GetAIReportTemplate(string language)
+        {
+            if (_aiReportTemplateDictionary.TryGetValue(language, out var reportTemplate))
+            {
+                return reportTemplate ?? string.Empty;
+            }
+            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resource\Diagnosis\ReportTemplate", $"{language}.json");
+            if (File.Exists(filePath))
+            {
+                var content = File.ReadAllText(filePath) ?? string.Empty;
+                _aiReportTemplateDictionary.AddOrUpdate(language, content, (d, h) => content);
+                return content;
+            }
+            return string.Empty;
+        }
     }
 }