|
@@ -26,6 +26,7 @@ using OASystem.Domain.Dtos.Groups;
|
|
using OASystem.Domain.Entities.Customer;
|
|
using OASystem.Domain.Entities.Customer;
|
|
using OASystem.Domain.Entities.Financial;
|
|
using OASystem.Domain.Entities.Financial;
|
|
using OASystem.Domain.Entities.Groups;
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
|
+using OASystem.Domain.ViewModels.CRM;
|
|
using OASystem.Domain.ViewModels.Financial;
|
|
using OASystem.Domain.ViewModels.Financial;
|
|
using OASystem.Domain.ViewModels.Groups;
|
|
using OASystem.Domain.ViewModels.Groups;
|
|
using OASystem.Domain.ViewModels.OCR;
|
|
using OASystem.Domain.ViewModels.OCR;
|
|
@@ -39,6 +40,7 @@ using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
using System.Globalization;
|
|
using System.Globalization;
|
|
using System.IO.Compression;
|
|
using System.IO.Compression;
|
|
|
|
+using System.Text.Json;
|
|
using System.Web;
|
|
using System.Web;
|
|
using static OASystem.API.OAMethodLib.JWTHelper;
|
|
using static OASystem.API.OAMethodLib.JWTHelper;
|
|
using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
|
|
using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
|
|
@@ -2251,7 +2253,7 @@ FROM
|
|
.LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
|
|
.LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
|
|
.LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
|
|
.LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
|
|
.Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
|
|
.Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
|
|
- .Select((x, s, dc, cc) => new groupClints
|
|
|
|
|
|
+ .Select((x, s, dc, cc) => new GroupClints
|
|
{
|
|
{
|
|
Id = x.Id,
|
|
Id = x.Id,
|
|
Name = s.Name,
|
|
Name = s.Name,
|
|
@@ -2745,18 +2747,103 @@ FROM
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[HttpPost]
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
- public async Task<IActionResult> VisaFileUploadAndUpdate(FormFile file)
|
|
|
|
|
|
+ public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile file,int fileTypeId)
|
|
{
|
|
{
|
|
//文件验证
|
|
//文件验证
|
|
- if (file.Length < 1)
|
|
|
|
|
|
+ if (file.Length < 1) return Ok(JsonView(false,"请选择文件!"));
|
|
|
|
+
|
|
|
|
+ var visaFiles = new VisaUploadFileTypeView();
|
|
|
|
+ var filetypes = visaFiles.GetVisaUploadFileTypeViewItemInit();
|
|
|
|
+ if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
|
|
|
|
+
|
|
|
|
+ //服务器存储文件
|
|
|
|
+ var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
|
|
|
|
+ if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
|
|
|
|
+ var filePath = Path.Combine(fileServerPath, file.FileName);
|
|
|
|
+ using (var stream = new FileStream(filePath, FileMode.Create))
|
|
{
|
|
{
|
|
|
|
+ await file.CopyToAsync(stream);
|
|
|
|
+ }
|
|
|
|
+ //日志记录-上传文件
|
|
|
|
+ _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, file.FileName);
|
|
|
|
+
|
|
|
|
+ //kimi AI 识别文档返回json结果
|
|
|
|
+ int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
|
|
|
|
+ var KiMiApi = new KiMiApiClient();
|
|
|
|
+ var files = new List<IFormFile>() { file };
|
|
|
|
+ var seedConter = await KiMiApi.UploadFilesAsync(files);
|
|
|
|
+
|
|
|
|
+ if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
|
|
|
|
+
|
|
|
|
+ var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
|
|
|
|
+ var messages = new List<SeedMessages>
|
|
|
|
+ {
|
|
|
|
+ new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
|
|
|
|
+ new() { Role = KimiRole.user, Content = seedMessage }
|
|
|
|
+ };
|
|
|
|
+ messages.InsertRange(1, seedConter);
|
|
|
|
|
|
|
|
+ string jsonString = string.Empty;
|
|
|
|
+ bool isJson = false; // 是否是json格式 不是json格式继续访问AI
|
|
|
|
+ while (!isJson)
|
|
|
|
+ {
|
|
|
|
+ kimiAI_API_Index++;
|
|
|
|
+ var kimiApiResult = await KiMiApi.SeedMessage(messages);
|
|
|
|
+ var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
|
|
|
|
+ jsonString += kimiApiResult_JObject["content"].ToString();
|
|
|
|
+
|
|
|
|
+ string startStr = "```json", endStr = "```";
|
|
|
|
+
|
|
|
|
+ // 判断并清除开头部分
|
|
|
|
+ if (jsonString.StartsWith(startStr))
|
|
|
|
+ {
|
|
|
|
+ jsonString = jsonString.Remove(0, startStr.Length);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 判断并清除结尾部分
|
|
|
|
+ if (jsonString.EndsWith(endStr))
|
|
|
|
+ {
|
|
|
|
+ jsonString = jsonString.Replace(endStr, "");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //验证json格式是否正确
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ JsonDocument.Parse(jsonString);
|
|
|
|
+ isJson = true; // 如果解析成功,则是json格式
|
|
|
|
+ }
|
|
|
|
+ catch (Exception)
|
|
|
|
+ {
|
|
|
|
+ //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
|
|
|
|
+ messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ var clientInfo = new Crm_DeleClient(); //客户资料表
|
|
|
|
+ var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
|
|
|
|
+ var clientCompany = new Crm_CustomerCompany(); //客户公司表
|
|
|
|
+ var clientCert = new Crm_CustomerCert(); //客户证件表
|
|
|
|
+ var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
|
|
|
|
+
|
|
|
|
+ //按照表格类型分别进行参数处理
|
|
|
|
+ switch (fileTypeId) {
|
|
|
|
+ //澳新签证个人申请表
|
|
|
|
+ case 1:
|
|
|
|
|
|
|
|
+ _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
|
|
|
|
+ VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
|
|
|
|
|
|
- return Ok(JsonView(true));
|
|
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return Ok(JsonView(true, jsonString));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|