|
@@ -99,7 +99,7 @@ namespace OASystem.API.Controllers
|
|
|
{
|
|
|
Directory.CreateDirectory(outputDir);
|
|
|
}
|
|
|
-
|
|
|
+ AsposeHelper.removewatermark_v2180();
|
|
|
doc.Save(outputPath);
|
|
|
string url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
|
|
@@ -213,7 +213,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
/// <summary>
|
|
|
/// 户口簿识别
|
|
|
- /// 文档下载 ?
|
|
|
+ /// 文档下载
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -241,7 +241,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
#region Feil Down
|
|
|
|
|
|
- BizLicenseOCRResponse res = residenceBookData.Data as BizLicenseOCRResponse;
|
|
|
+ ResidenceBookletOCRResponse res = residenceBookData.Data as ResidenceBookletOCRResponse;
|
|
|
|
|
|
Document doc = new Document();
|
|
|
DocumentBuilder builder = new DocumentBuilder(doc);
|
|
@@ -251,16 +251,34 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
if (res != null)
|
|
|
{
|
|
|
- content += $"公司名称:{res.Name}\r\n\r\n";
|
|
|
- content += $"统一社会信用代码(三合一之前为注册号):{res.RegNum}\r\n\r\n";
|
|
|
- content += $"注册资本:{res.Capital}\r\n\r\n";
|
|
|
- content += $"法人代表:{res.Person}\r\n\r\n";
|
|
|
- content += $"地址:{res.Address}\r\n\r\n";
|
|
|
- content += $"经营范围:{res.Business}\r\n\r\n";
|
|
|
- content += $"主题类型:{res.Type}\r\n\r\n";
|
|
|
- content += $"营业期限:{res.Period}\r\n\r\n";
|
|
|
- content += $"组成形式:{res.ComposingForm}\r\n\r\n";
|
|
|
- content += $"成立日期:{res.SetDate}\r\n\r\n";
|
|
|
+ content += $"户号:{res.HouseholdNumber ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"姓名:{res.Name ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"曾用名:{res.FormerName ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"性别:{res.Sex ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"出生地:{res.BirthPlace ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"民族:{res.Nation ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"籍贯:{res.NativePlace ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"出生日期:{res.BirthDate ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"公民身份证件编号:{res.IdCardNumber ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"文化程度:{res.EducationDegree ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"服务处所:{res.ServicePlace ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"户别:{res.Household ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"住址:{res.Address ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"承办人签章文字:{res.Signature ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"签发日期:{res.IssueDate ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"户主页编号:{res.HomePageNumber ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"户主姓名:{res.HouseholderName ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"户主或与户主关系:{res.Relationship ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"本市(县)其他住址:{res.OtherAddresses ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"宗教信仰:{res.ReligiousBelief ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"身高:{res.Height ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"血型:{res.BloodType ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"婚姻状况:{res.MaritalStatus ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"兵役状况:{res.VeteranStatus ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"职业:{res.Profession ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"何时由何地迁来本市(县):{res.MoveToCityInformation ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"何时由何地迁来本址:{res.MoveToSiteInformation ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"登记日期:{res.RegistrationDate ?? "Unknown"}\r\n\r\n";
|
|
|
}
|
|
|
|
|
|
builder.Write(content);
|
|
@@ -274,8 +292,8 @@ namespace OASystem.API.Controllers
|
|
|
Directory.CreateDirectory(outputDir);
|
|
|
}
|
|
|
|
|
|
+ AsposeHelper.removewatermark_v2180();
|
|
|
doc.Save(outputPath);
|
|
|
-
|
|
|
string url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
|
|
|
|
|
@@ -576,7 +594,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
/// <summary>
|
|
|
/// 护照识别(中国大陆地区护照)
|
|
|
- /// 获取护照识别(中国大陆地区护照)返回数据
|
|
|
+ /// 文档下载
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -649,13 +667,13 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
/// <summary>
|
|
|
/// 护照识别(港澳台地区及境外护照)
|
|
|
- /// 获取护照识别(港澳台地区及境外护照)返回数据
|
|
|
+ /// 文档下载
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
- public async Task<IActionResult> GetMLIDPassport(PassportOCRDto dto)
|
|
|
+ public async Task<IActionResult> GetMLIDPassport(MLIDPassportOCRDto dto)
|
|
|
{
|
|
|
double strSize = 1024 * 1024 * 7;
|
|
|
if (dto.picBase64.Length > strSize)
|
|
@@ -678,27 +696,20 @@ namespace OASystem.API.Controllers
|
|
|
string url = "";
|
|
|
#region 文档下载
|
|
|
|
|
|
- string fileName = "护照识别(中国大陆地区护照)";
|
|
|
+ string fileName = "护照识别(港澳台地区及境外护照)";
|
|
|
string content = $"{fileName}\r\n\r\n";
|
|
|
- PassportOCRResponse pInfo = mlidpData.Data as PassportOCRResponse;
|
|
|
+ MLIDPassportOCRResponse mlidInfo = mlidpData.Data as MLIDPassportOCRResponse;
|
|
|
Document doc = new Document();
|
|
|
DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
- if (pInfo != null)
|
|
|
+ if (mlidInfo != null)
|
|
|
{
|
|
|
- content += $"国家码:{pInfo.Country ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"护照号:{pInfo.PassportNo ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"性别:{pInfo.Sex ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"国籍:{pInfo.Nationality ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"出生日期:{pInfo.BirthDate ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"签发日期:{pInfo.IssueDate ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"签发地点:{pInfo.IssuePlace ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"有效期:{pInfo.ExpiryDate ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"持证人签名:{pInfo.Signature ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"最下方第一行 MRZ Code 序列:{pInfo.CodeSet ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"最下方第二行 MRZ Code 序列:{pInfo.CodeCrc ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"姓名:{pInfo.Name ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"姓:{pInfo.FamilyName ?? "Unknown"}\r\n\r\n";
|
|
|
- content += $"名:{pInfo.FirstName ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"护照ID:{mlidInfo.ID ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"姓名:{mlidInfo.Name ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"出生日期:{mlidInfo.DateOfBirth ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"性别(F女,M男):{mlidInfo.Sex ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"有效期:{mlidInfo.DateOfExpiration ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"发行国:{mlidInfo.IssuingCountry ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"国家地区代码:{mlidInfo.Nationality ?? "Unknown"}\r\n\r\n";
|
|
|
}
|
|
|
builder.Write(content);
|
|
|
|
|
@@ -717,7 +728,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- return Ok(JsonView(true, "操作成功", new { dataSource = pInfo, url = url }));
|
|
|
+ return Ok(JsonView(true, "操作成功", new { dataSource = mlidInfo, url = url }));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -736,30 +747,57 @@ namespace OASystem.API.Controllers
|
|
|
return Ok(JsonView("图片不能大于7M!"));
|
|
|
}
|
|
|
|
|
|
- try
|
|
|
+ var mlidpData = await TencentOCRTools.GetOCR((int)TencentOCREnum.BusinessCard, dto);
|
|
|
+ if (mlidpData.Code != 0)
|
|
|
{
|
|
|
- var mlidpData = await TencentOCRTools.GetOCR((int)TencentOCREnum.BusinessCard, dto);
|
|
|
- if (mlidpData.Code != 0)
|
|
|
- {
|
|
|
- return Ok(JsonView(mlidpData.Msg));
|
|
|
- }
|
|
|
+ return Ok(JsonView(mlidpData.Msg));
|
|
|
+ }
|
|
|
|
|
|
- if (mlidpData.Data == null)
|
|
|
- {
|
|
|
- return Ok(JsonView(mlidpData.Msg));
|
|
|
- }
|
|
|
+ if (mlidpData.Data == null)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(mlidpData.Msg));
|
|
|
+ }
|
|
|
|
|
|
- return Ok(JsonView(mlidpData.Data));
|
|
|
+ string url = "";
|
|
|
+ #region 文档下载
|
|
|
+
|
|
|
+ string fileName = "名片识别";
|
|
|
+ string content = $"{fileName}\r\n\r\n";
|
|
|
+ BusinessCardOCRResponse bcData = mlidpData.Data as BusinessCardOCRResponse;
|
|
|
+ List<BusinessCardInfo> bcInfos = new List<BusinessCardInfo>();
|
|
|
+ bcInfos = bcData.BusinessCardInfos.ToList();
|
|
|
+ Document doc = new Document();
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+
|
|
|
+ foreach (var view in bcInfos)
|
|
|
+ {
|
|
|
+ content += $"TypeName:{view?.Name ?? "Unknown"}\t\r\nContent:{view?.Value ?? "Unknown"}\r\n\r\n";
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+
|
|
|
+ builder.Write(content);
|
|
|
+
|
|
|
+ string outputDir = $"{AppSettingsHelper.Get("WordBasePath")}/TencentOCR";
|
|
|
+ string outputFile = $"{fileName}{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
|
|
|
+ string outputPath = Path.Combine(outputDir, outputFile);
|
|
|
+
|
|
|
+ if (!Directory.Exists(outputDir))
|
|
|
{
|
|
|
- return Ok(JsonView(false, ex.Message));
|
|
|
+ Directory.CreateDirectory(outputDir);
|
|
|
}
|
|
|
+ //去水印
|
|
|
+ AsposeHelper.removewatermark_v2180();
|
|
|
+ doc.Save(outputPath);
|
|
|
+ url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "操作成功", new { dataSource = bcData, url = url }));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 智能结构化识别V2
|
|
|
- /// 获取名片 返回数据
|
|
|
+ /// 文档下载
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -791,32 +829,14 @@ namespace OASystem.API.Controllers
|
|
|
{
|
|
|
return Ok(JsonView(false, ssData.Msg));
|
|
|
}
|
|
|
+ string fileName = "智能结构化识别V2";
|
|
|
|
|
|
- //var wordRes = GenerateWord(ssData.Data as List<ocrGeneralView>, "智能结构化识别V2");
|
|
|
List<ocrGeneralView>? datas = ssData.Data as List<ocrGeneralView>;
|
|
|
-
|
|
|
- var data = new {
|
|
|
- dataSource = ssData.Data,
|
|
|
- url = GenerateWord(datas, "智能结构化识别V2")
|
|
|
- };
|
|
|
- return Ok(JsonView(true, ssData.Msg, data));
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 生成 ocr word
|
|
|
- /// </summary>
|
|
|
- /// <param name="views"></param>
|
|
|
- /// <param name="fileName"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private string GenerateWord(List<ocrGeneralView> views, string fileName)
|
|
|
- {
|
|
|
Document doc = new Document();
|
|
|
DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
|
|
|
string content = $"{fileName}\r\n\r\n";
|
|
|
- foreach (var view in views)
|
|
|
+ foreach (var view in datas)
|
|
|
{
|
|
|
content += $"TypeName:{view.name}\t\r\nContent:{view.value}\r\n\r\n";
|
|
|
}
|
|
@@ -831,11 +851,21 @@ namespace OASystem.API.Controllers
|
|
|
{
|
|
|
Directory.CreateDirectory(outputDir);
|
|
|
}
|
|
|
-
|
|
|
+ //去水印
|
|
|
+ AsposeHelper.removewatermark_v2180();
|
|
|
doc.Save(outputPath);
|
|
|
|
|
|
- return $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
+ string url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
+
|
|
|
+
|
|
|
+ var data = new {
|
|
|
+ dataSource = ssData.Data,
|
|
|
+ url = url
|
|
|
+ };
|
|
|
+ return Ok(JsonView(true, ssData.Msg, data));
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region android ios
|