Преглед на файлове

签证 上传AI识别 新增表格

Lyyyi преди 13 часа
родител
ревизия
e9fe7b581b

+ 138 - 45
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -9,6 +9,7 @@ using iTextSharp.text.pdf;
 using iTextSharp.xmp.impl.xpath;
 using Microsoft.AspNetCore.Routing.Template;
 using Microsoft.AspNetCore.SignalR;
+using NetUV.Core.Requests;
 using NPOI.OpenXmlFormats.Wordprocessing;
 using NPOI.SS.Formula.Functions;
 using NPOI.SS.UserModel;
@@ -53,6 +54,7 @@ using System.Diagnostics;
 using System.Globalization;
 using System.IO.Compression;
 using System.Linq.Expressions;
+using System.Runtime.ConstrainedExecution;
 using System.Text.Json;
 using System.Web;
 using static OASystem.API.OAMethodLib.JWTHelper;
@@ -3521,13 +3523,13 @@ FROM
 个人信息:
 - 姓名:请提取文档中的“姓名”。
 - 拼音名:请提取文档中的“拼音名”或“英文名”。
-- 曾用名:请提取文档中的“曾用名”或“别名”。
-- 性别:请提取文档中的“性别”。
-- 出生日期:请提取文档中的“出生日期”。
-- 出生地省:请提取文档中的“出生地省”或“出生地省份”。
-- 出生地市:请提取文档中的“出生地市”或“出生地城市”。
-- 国籍:请提取文档中的“国籍”或“现国籍”。
-- 身份证号码:请提取文档中的“身份证号码”。
+- 曾用名:请提取文档中的“曾用名”或“别名”,去除“曾用名”“别名”等字段名称字样,仅保留实际姓名内容
+- 性别:请提取文档中的“性别”。当前信息未提取到且身份证效验通过可提取第17位奇偶性判断性别(奇男偶女)。
+- 出生日期:请提取文档中的“出生日期”。当前信息未提取到且身份证效验通过可提取第7-14位作为出生日期(格式YYYY-MM-DD)。
+- 出生地省:请提取文档中的“出生地省”或“出生地省份”。当前信息未提取到且身份证效验通过可提取第1-2位对应省级行政区划代码用于出生地省回填。
+- 出生地市:请提取文档中的“出生地市”或“出生地城市”。当前信息未提取到且身份证效验通过可提取第3-4位对应地级行政区划代码用于出生地市回填。
+- 国籍:请提取文档中的“国籍”或“现国籍”。当前信息未提取到且身份证效验通过可提取信息回填。
+- 身份证号码:请提取文档中的“身份证号码”。效验规则:身份证号码必须为18位,前17位为数字、第18位为数字或X,且需通过ISO 7064:1983 MOD 11-2校验算法验证;
 - 婚姻状况:请提取文档中的“婚姻状况”。
 - 离婚原因:请提取文档中的“离婚原因”。
 
@@ -3558,7 +3560,7 @@ FROM
 - 工作单位地址:请提取文档中的“工作单位地址”或“单位地址”。
 - 工作单位电话:请提取文档中的“工作单位电话”或“单位电话”。
 - 职位:请提取文档中的“职位”或“目前职位”。
-- 月薪:请提取文档中的“月薪”或“月收入”。
+- 月薪:请提取文档中的“月薪”或“月收入”或“年薪”(如果是年薪自动除以12得到月薪)
 
 教育经历:
 - 教育经历:请提取文档中所有教育经历,以列表形式返回,每个条目包含以下信息:
@@ -3641,7 +3643,7 @@ FROM
 
 把表格里的每个可填字段转换成“标题:值”的键值对,值用原文,不翻译。
 注:日期格式:YYYY-MM-DD、值为空时空字符串
-只返回json结,不需要其他内容,json内容去掉换行。");
+只返回json结构体,不需要其他内容,json内容去掉换行。");
             var messages = new List<SeedMessages>
             {
                 new()  { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
@@ -3747,7 +3749,7 @@ FROM
                             { }
 
                             if (TryGetNonEmptyStringProperty(userInfo, "身份证号码", out string idNo))
-                                certs.Add(new() { PassportType = 74, CertNo = idNo, Country = nationality });
+                                certs.Add(new() { SdId = 773, CertNo = idNo, Country = nationality });
 
                             if (TryGetNonEmptyStringProperty(userInfo, "婚姻状况", out string marital_status))
                                 info.Marriage = marital_status switch
@@ -3809,7 +3811,6 @@ FROM
                                     familys.Add(familyInfo1);
                                 }
                             }
-
                         }
 
                         if (root.TryGetProperty("工作信息", out JsonElement workInfo))
@@ -3863,28 +3864,31 @@ FROM
                         {
                             if (eduInfo.TryGetProperty("教育经历", out JsonElement educations))
                             {
-                                foreach (JsonElement edu in educations.EnumerateArray())
+                                if (educations.ValueKind == JsonValueKind.Array)
                                 {
-                                    var schoolInfo = new Crm_VisaCustomerSchool();
-                                    if (TryGetNonEmptyStringProperty(edu, "学校名称", out string school_name))
-                                        schoolInfo.School = school_name;
+                                    foreach (JsonElement edu in educations.EnumerateArray())
+                                    {
+                                        var schoolInfo = new Crm_VisaCustomerSchool();
+                                        if (TryGetNonEmptyStringProperty(edu, "学校名称", out string school_name))
+                                            schoolInfo.School = school_name;
 
-                                    if (TryGetNonEmptyStringProperty(edu, "学校地址", out string school_address))
-                                        schoolInfo.Address = school_address;
+                                        if (TryGetNonEmptyStringProperty(edu, "学校地址", out string school_address))
+                                            schoolInfo.Address = school_address;
 
-                                    if (TryGetNonEmptyStringProperty(edu, "专业", out string degree))
-                                        schoolInfo.Subject = degree;
+                                        if (TryGetNonEmptyStringProperty(edu, "专业", out string degree))
+                                            schoolInfo.Subject = degree;
 
-                                    if (TryGetNonEmptyStringProperty(edu, "学位", out string major))
-                                        schoolInfo.Education = major;
+                                        if (TryGetNonEmptyStringProperty(edu, "学位", out string major))
+                                            schoolInfo.Education = major;
 
-                                    if (TryGetNonEmptyDateTimeProperty(edu, "入学时间", out DateTime? enrollment_date))
-                                        schoolInfo.StudyStart = enrollment_date;
+                                        if (TryGetNonEmptyDateTimeProperty(edu, "入学时间", out DateTime? enrollment_date))
+                                            schoolInfo.StudyStart = enrollment_date;
 
-                                    if (TryGetNonEmptyDateTimeProperty(edu, "毕业时间", out DateTime? graduation_date))
-                                        schoolInfo.StudyEnd = graduation_date;
+                                        if (TryGetNonEmptyDateTimeProperty(edu, "毕业时间", out DateTime? graduation_date))
+                                            schoolInfo.StudyEnd = graduation_date;
 
-                                    schools.Add(schoolInfo);
+                                        schools.Add(schoolInfo);
+                                    }
                                 }
                             }
                         }
@@ -4028,14 +4032,19 @@ FROM
                                     _ => 0
                                 };
 
-                            if (TryGetNonEmptyDateTimeProperty(otherInfo, "因公护照有效期", out DateTime? GetUSAVisaDate))
-                                info.GetUSAVisaDate = GetUSAVisaDate;
+                            if (info.IsUSAVia == 1)
+                            {
+                                if (TryGetNonEmptyDateTimeProperty(otherInfo, "因公护照有效期", out DateTime? GetUSAVisaDate))
+                                    info.GetUSAVisaDate = GetUSAVisaDate;
+
+                                if (TryGetNonEmptyStringProperty(otherInfo, "因公护照类型", out string USAVisaCate))
+                                    info.USAVisaCate = USAVisaCate;
 
-                            if (TryGetNonEmptyStringProperty(otherInfo, "因公护照类型", out string USAVisaCate))
-                                info.USAVisaCate = USAVisaCate;
+                                if (TryGetNonEmptyStringProperty(otherInfo, "因公护照号码", out string USAVisaCode))
+                                    info.USAVisaCode = USAVisaCode;
 
-                            if (TryGetNonEmptyStringProperty(otherInfo, "因公护照号码", out string USAVisaCode))
-                                info.USAVisaCode = USAVisaCode;
+                                certs.Add(new() { SdId = 774, PassportType = 1012, CertNo = info.USAVisaCode });
+                            }
 
                             if (otherInfo.TryGetProperty("亲属、朋友及联系人信息", out JsonElement personInfos1))
                             {
@@ -4134,9 +4143,10 @@ FROM
                     info.Phone.Equals(x.Phone))
                     .FirstOrDefault();
 
-                var compnayInfos = await _sqlSugar.Queryable<Crm_CustomerCompany>()
-                        .Where(x => x.IsDel == 0)
-                        .ToListAsync();
+                var compnayInfos = await _sqlSugar
+                    .Queryable<Crm_CustomerCompany>()
+                    .Where(x => x.IsDel == 0)
+                    .ToListAsync();
 
                 foreach (var company1 in compnayInfos)
                 {
@@ -4155,6 +4165,23 @@ FROM
                         return Ok(JsonView(false, "公司信息添加失败!"));
                     }
                 }
+                else 
+                {
+                    // 存在信息为空则更新公司地址信息
+                    if (string.IsNullOrEmpty(compnayInfo.Address))
+                    {
+                        compnayInfo.Address = company.Address;
+
+                        var companyUpd = await _sqlSugar.Updateable(compnayInfo)
+                            .UpdateColumns(x => x.Address)
+                            .ExecuteCommandAsync();
+                        if (companyUpd < 1)
+                        {
+                            _sqlSugar.RollbackTran();
+                            return Ok(JsonView(false, "公司地址信息更新失败!"));
+                        }
+                    }
+                }
 
                 if (infoVaild == null) //添加
                 {
@@ -4169,11 +4196,28 @@ FROM
                         return Ok(JsonView(false, "信息添加失败!"));
                     }
 
+                    if (certs.Any())
+                    {
+                        foreach (var cert in certs)
+                        {
+                            cert.CertNo = AesEncryptionHelper.Encrypt(cert.CertNo);
+                            cert.DcId = insertId;
+                            cert.CreateUserId = 4;
+                        }
+                        var cretInsert = await _sqlSugar.Insertable(certs).ExecuteCommandAsync();
+                        if (cretInsert < 1)
+                        {
+                            _sqlSugar.RollbackTran();
+                            return Ok(JsonView(false, "证件信息添加失败!"));
+                        }
+                    }
+
                     if (familys.Any())
                     {
                         foreach (var family in familys)
                         {
                             family.DcId = insertId;
+                            family.CreateUserId = 4;
                         }
                         var familyInsert = await _sqlSugar.Insertable(familys).ExecuteCommandAsync();
                         if (familyInsert < 1)
@@ -4188,6 +4232,7 @@ FROM
                         foreach (var school in schools)
                         {
                             school.DcId = insertId;
+                            school.CreateUserId = 4;
                         }
                         var schoolInsert = await _sqlSugar.Insertable(schools).ExecuteCommandAsync();
                         if (schoolInsert < 1)
@@ -4202,6 +4247,7 @@ FROM
                         foreach (var work in works)
                         {
                             work.DcId = insertId;
+                            work.CreateUserId = 4;
                         }
                         var workInsert = await _sqlSugar.Insertable(works).ExecuteCommandAsync();
                         if (workInsert < 1)
@@ -4235,6 +4281,9 @@ FROM
                         }
                     }
 
+                    // 单独处理 婚姻字段  0 未设置 重新设置值
+                    if (updInfo.Marriage == 0) updInfo.Marriage = info.Marriage;
+
                     EncryptionProcessor.EncryptProperties(updInfo);
 
                     var upd = await _sqlSugar.Updateable(updInfo).ExecuteCommandAsync();
@@ -4246,10 +4295,33 @@ FROM
 
                     int parentId = updInfo.Id;
 
+                    if (certs.Any())
+                    {
+                        await _sqlSugar.Updateable<Crm_CustomerCert>()
+                            .SetColumns(x => x.IsDel == 1)
+                            .SetColumns(x => x.DeleteUserId == 4)
+                            .SetColumns(x => x.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
+                            .Where(x => x.DcId == parentId)
+                            .ExecuteCommandAsync();
+
+                        foreach (var cert in certs)
+                        {
+                            cert.CertNo = AesEncryptionHelper.Encrypt(cert.CertNo);
+                            cert.DcId = parentId;
+                            cert.CreateUserId = 4;
+                        }
+                        var cretInsert = await _sqlSugar.Insertable(certs).ExecuteCommandAsync();
+                        if (cretInsert < 1)
+                        {
+                            _sqlSugar.RollbackTran();
+                            return Ok(JsonView(false, "证件信息添加失败!"));
+                        }
+                    }
+
                     if (familys.Any())
                     {
                         await _sqlSugar.Updateable<Crm_VisaCustomerFamily>()
-                            .SetColumns(x => x.IsDel == 0)
+                            .SetColumns(x => x.IsDel == 1)
                             .SetColumns(x => x.DeleteUserId == 4)
                             .SetColumns(x => x.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
                             .Where(x => x.DcId == parentId)
@@ -4258,6 +4330,7 @@ FROM
                         foreach (var family in familys)
                         {
                             family.DcId = parentId;
+                            family.CreateUserId = 4;
                         }
                         var familyInsert = await _sqlSugar.Insertable(familys).ExecuteCommandAsync();
                         if (familyInsert < 1)
@@ -4270,7 +4343,7 @@ FROM
                     if (schools.Any())
                     {
                         await _sqlSugar.Updateable<Crm_VisaCustomerSchool>()
-                            .SetColumns(x => x.IsDel == 0)
+                            .SetColumns(x => x.IsDel == 1)
                             .SetColumns(x => x.DeleteUserId == 4)
                             .SetColumns(x => x.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
                             .Where(x => x.DcId == parentId)
@@ -4279,6 +4352,7 @@ FROM
                         foreach (var school in schools)
                         {
                             school.DcId = parentId;
+                            school.CreateUserId = 4;
                         }
                         var schoolInsert = await _sqlSugar.Insertable(schools).ExecuteCommandAsync();
                         if (schoolInsert < 1)
@@ -4291,7 +4365,7 @@ FROM
                     if (works.Any())
                     {
                         await _sqlSugar.Updateable<Crm_VisaCustomerCompany>()
-                            .SetColumns(x => x.IsDel == 0)
+                            .SetColumns(x => x.IsDel == 1)
                             .SetColumns(x => x.DeleteUserId == 4)
                             .SetColumns(x => x.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
                             .Where(x => x.DcId == parentId)
@@ -4300,6 +4374,7 @@ FROM
                         foreach (var work in works)
                         {
                             work.DcId = parentId;
+                            work.CreateUserId = 4;
                         }
                         var workInsert = await _sqlSugar.Insertable(works).ExecuteCommandAsync();
                         if (workInsert < 1)
@@ -8082,7 +8157,7 @@ FROM
                             SetFieldValue(formFields, "member_first_entry", pdfData.GetSafeString("member_first_entry"));    // 首入申根国标签
 
                             // 申请入境次数
-                            string request_entry = pdfData.GetSafeString("member_first_entry");
+                            string request_entry = pdfData.GetSafeString("request_entry");
                             switch (request_entry)
                             {
                                 case "1":
@@ -8178,6 +8253,9 @@ FROM
                         }
                         finally
                         {
+                            // 展平表单
+                            stamper.FormFlattening = true;
+
                             // 按正确顺序关闭资源
                             stamper?.Close();
                             reader?.Close();
@@ -9063,7 +9141,7 @@ FROM
                         SetFieldValue(formFields, "marital_widower", "Off");     // 婚姻状况 - 丧偶
                         SetFieldValue(formFields, "marital_other", "Off");       // 婚姻状况 - 其他
                         SetFieldValue(formFields, "marital_other_specify", "");  // 婚姻状况 - 其他(请具体说明)
-                        var maritalStatus = pdfData.GetSafeString("marital_status");
+                        var maritalStatus = pdfData.GetSafeString("marriage");
                         //设置婚姻状况
                         switch (maritalStatus)
                         {
@@ -9237,7 +9315,7 @@ FROM
                         SetFieldValue(formFields, "member_first_entry", pdfData.GetSafeString("member_first_entry"));    // 首入申根国标签
 
                         // 申请入境次数
-                        string request_entry = pdfData.GetSafeString("member_first_entry");
+                        string request_entry = pdfData.GetSafeString("request_entry");
                         switch (request_entry)
                         {
                             case "1":
@@ -9317,8 +9395,8 @@ FROM
                         SetFieldValue(formFields, "cost_covered_sponsor_accomodation", "Off"); // 提供住宿
                         SetFieldValue(formFields, "cost_covered_sponsor_during_stay", "Off");  // 旅行期间的所有费用均由主办方承担
                         SetFieldValue(formFields, "cost_covered_sponsor_transport", "Off");    // 预先支付的交通费用
-                        SetFieldValue(formFields, "cost_covered_sponsor_other", "Off");        // 其他
-                        SetFieldValue(formFields, "cost_covered_sponsor_other_specify", "");   // 其他(请具体说明
+                        SetFieldValue(formFields, "cost_covered_sponsor_other", "Yes");        // 其他
+                        SetFieldValue(formFields, "cost_covered_sponsor_other_specify", pdfData.GetSafeString("cost_covered_sponsor_other_specify"));   // 其他(请具体说明
                         #endregion
 
                         #endregion
@@ -9700,7 +9778,7 @@ FROM
 
             #region 出生日期(日-月-年)
             string birthday = string.Empty;
-            string idCard = idInfo?.CertNo?.Trim() ?? "";
+            string idCard = AesEncryptionHelper.Decrypt(idInfo?.CertNo?.Trim() ?? "");
 
             // 1. 优先从身份证中提取 (需为18位身份证)
             if (!string.IsNullOrEmpty(idCard) && idCard.Length >= 14)
@@ -10099,7 +10177,22 @@ FROM
         {
             if (formFields.Fields.ContainsKey(fieldName) && !string.IsNullOrEmpty(value))
             {
-                formFields.SetField(fieldName, value);
+                // 设置宋体(支持中文)
+                //BaseFont bf = BaseFont.CreateFont("C:\\Windows\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
+                //formFields.SetFieldProperty(fieldName, "textfont", bf, null);
+
+                //// 设置字号:8
+                //formFields.SetFieldProperty(fieldName, "textsize", 8f, null);
+
+                // 设置字体颜色:黑色
+                formFields.SetFieldProperty(fieldName, "textcolor", iTextSharp.text.BaseColor.BLACK, null);
+
+                // 填充值(显示值、实际值、保存外观)
+                formFields.SetField(fieldName, value, value, true);
+
+                // 设置打印标志
+                formFields.SetFieldProperty(fieldName, "setflags", PdfFormField.FLAGS_PRINT, null);
+
             }
         }
 

+ 1 - 1
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -2674,7 +2674,7 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
         }
 
         /// <summary>
-        /// 商邀资料AI 混元AI查询资料
+        /// 商邀资料AI 混元AI续写
         /// </summary>
         /// <returns></returns>
         [HttpPost]

+ 1 - 1
OASystem/OASystem.Api/OASystem.API.csproj

@@ -52,7 +52,7 @@
     <PackageReference Include="CurlThin.Native" Version="0.0.8" />
     <PackageReference Include="EPPlus" Version="7.4.1" />
     <PackageReference Include="Flurl.Http" Version="3.2.4" />
-    <PackageReference Include="iTextSharp" Version="5.5.13.4" />
+    <PackageReference Include="iTextSharp" Version="5.5.13.5" />
     <PackageReference Include="JsonDiffPatch.Net" Version="2.3.0" />
     <PackageReference Include="Markdig" Version="0.33.0" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.11" />

+ 3 - 1
OASystem/OASystem.Domain/Entities/Customer/Crm_CustomerCert.cs

@@ -21,13 +21,15 @@ namespace OASystem.Domain.Entities.Customer
 
         /// <summary>
         /// 证件类型表Id
+        /// 773	身份证 774	护照 775	学生证 776	军人证 777	回乡证 778	台胞证 779	港澳通行证 780	国际海员证 781	外国人永久居留证 782	旅行证 783	台湾通行证 784	港澳台居住证 785	其他
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int SdId { get; set; }
 
         /// <summary>
         /// 护照类型 Id(数据类型表Id)
-        /// SdId == 74 该字段有值
+        /// SdId == 774 该字段有值 使用stid=74的值
+        /// 1010 外交护照 1011 公务护照 1012 因公普通护照 1013 因私普通护照 1014 特区护照
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int PassportType { get; set; } = 0;