|
@@ -1,5 +1,6 @@
|
|
|
using Aspose.Cells;
|
|
|
using Aspose.Words;
|
|
|
+using Aspose.Words.Fonts;
|
|
|
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
|
|
using NPOI.HPSF;
|
|
|
using OASystem.API.OAMethodLib.File;
|
|
@@ -10,6 +11,7 @@ using OASystem.Domain.Dtos.CRM;
|
|
|
using OASystem.Domain.Dtos.QiYeWeChat;
|
|
|
using OASystem.Domain.Dtos.Tencent;
|
|
|
using OASystem.Domain.ViewModels.OCR;
|
|
|
+using OASystem.Domain.ViewModels.QiYeWeChat;
|
|
|
using OASystem.Domain.ViewModels.TencentOCR;
|
|
|
using OASystem.Infrastructure.Repositories.CRM;
|
|
|
using Org.BouncyCastle.Crypto;
|
|
@@ -211,7 +213,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
/// <summary>
|
|
|
/// 户口簿识别
|
|
|
- /// 文档下载
|
|
|
+ /// 文档下载 ?
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -261,8 +263,6 @@ namespace OASystem.API.Controllers
|
|
|
content += $"成立日期:{res.SetDate}\r\n\r\n";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
builder.Write(content);
|
|
|
|
|
|
string outputDir = $"{AppSettingsHelper.Get("WordBasePath")}/TencentOCR";
|
|
@@ -276,14 +276,17 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
doc.Save(outputPath);
|
|
|
|
|
|
+ string url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
|
|
|
|
|
|
- return $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
-
|
|
|
+ var data = new {
|
|
|
+ dataSource = residenceBookData.Data,
|
|
|
+ url = url
|
|
|
+ };
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
- return Ok(JsonView(residenceBookData.Data));
|
|
|
+ return Ok(JsonView(data));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -351,7 +354,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
/// <summary>
|
|
|
/// 行驶证识别
|
|
|
- /// 获取行驶证返回数据
|
|
|
+ /// 文档下载
|
|
|
/// CardSide=0 主页正面(有红色印章的一面),CardSide=1 行驶证副页正面(有号码号牌的一面),CardSide=2 行驶证主页正面和副页正面。
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
@@ -366,24 +369,121 @@ namespace OASystem.API.Controllers
|
|
|
return Ok(JsonView("图片不能大于7M!"));
|
|
|
}
|
|
|
|
|
|
- var vehicleLicenseData = await TencentOCRTools.GetOCR((int)TencentOCREnum.VehicleLicense, dto);
|
|
|
+ var vehicleLicenseData = TencentOCRTools.GetOCR((int)TencentOCREnum.VehicleLicense, dto);
|
|
|
|
|
|
- if (vehicleLicenseData.Code != 0)
|
|
|
+ if (vehicleLicenseData.Result.Code != 0)
|
|
|
{
|
|
|
- return Ok(JsonView(vehicleLicenseData.Msg));
|
|
|
+ return Ok(JsonView(vehicleLicenseData.Result.Msg));
|
|
|
}
|
|
|
|
|
|
- if (vehicleLicenseData.Data == null)
|
|
|
+ if (vehicleLicenseData.Result.Data == null)
|
|
|
{
|
|
|
- return Ok(JsonView(vehicleLicenseData.Msg));
|
|
|
+ return Ok(JsonView(vehicleLicenseData.Result.Msg));
|
|
|
}
|
|
|
|
|
|
- return Ok(JsonView(vehicleLicenseData.Data));
|
|
|
+
|
|
|
+ #region word下载
|
|
|
+
|
|
|
+ VehicleLicenseOCRResponse vlData = vehicleLicenseData.Result.Data as VehicleLicenseOCRResponse;
|
|
|
+
|
|
|
+ string url = "";
|
|
|
+ string fileName = "";
|
|
|
+ string content = "";
|
|
|
+ dynamic data = null;
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //Aspose.Words.License lic = new Aspose.Words.License();
|
|
|
+ //lic.SetLicense("Aspose.Wrods.lic");//破解版不用设置license
|
|
|
+
|
|
|
+ if (dto.CardSide == 0) // 正面
|
|
|
+ {
|
|
|
+ fileName = "行驶证识别-主页";
|
|
|
+ content = $"{fileName}\r\n\r\n";
|
|
|
+ TextVehicleFront frontInfo = vlData.FrontInfo;
|
|
|
+ Document doc = new Document();
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+ if (frontInfo != null)
|
|
|
+ {
|
|
|
+ data = frontInfo;
|
|
|
+ content += $"号牌号码:{frontInfo.PlateNo ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"车辆类型:{frontInfo.VehicleType ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"所有人:{frontInfo.Owner ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"住址:{frontInfo.Address ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"使用性质:{frontInfo.UseCharacter ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"品牌型号:{frontInfo.Model ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"车辆识别代号:{frontInfo.Vin ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"发动机号码:{frontInfo.EngineNo ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"注册日期:{frontInfo.RegisterDate ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"发证日期:{frontInfo.IssueDate ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"印章:{frontInfo.Seal ?? "Unknown"}\r\n\r\n";
|
|
|
+ }
|
|
|
+ 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))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(outputDir);
|
|
|
+ }
|
|
|
+ //去水印
|
|
|
+ new Aspose.Words.License().SetLicense(new MemoryStream(Convert.FromBase64String(AsposeHelper.asposeKey)));
|
|
|
+ doc.Save(outputPath);
|
|
|
+ url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
+ }
|
|
|
+ else if (dto.CardSide == 1) //反面
|
|
|
+ {
|
|
|
+ TextVehicleBack backInfo = vlData.BackInfo;
|
|
|
+ fileName = "行驶证识别-副页";
|
|
|
+ content = $"{fileName}\r\n\r\n";
|
|
|
+ Document doc = new Document();
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+ if (backInfo != null)
|
|
|
+ {
|
|
|
+ data = backInfo;
|
|
|
+ content += $"号牌号码:{backInfo.PlateNo ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"档案编号:{backInfo.FileNo ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"核定人数:{backInfo.AllowNum ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"总质量:{backInfo.TotalMass ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"整备质量:{backInfo.CurbWeight ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"核定载质量:{backInfo.LoadQuality ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"外廓尺寸:{backInfo.ExternalSize ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"备注:{backInfo.Marks ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"检验记录:{backInfo.Record ?? "Unknown"}\r\n\r\n";
|
|
|
+ content += $"准牵引总质量:{backInfo.TotalQuasiMass ?? "Unknown"}\r\n\r\n";
|
|
|
+ }
|
|
|
+ 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))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(outputDir);
|
|
|
+ }
|
|
|
+
|
|
|
+ doc.Save(outputPath);
|
|
|
+ url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "操作成功", new { dataSource = data, url = url }));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ return Ok(JsonView(false, $"InnerException:{ex.InnerException?.Message ?? "Unknown"} ErrMsg:{ex.Message}"));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 房产证识别
|
|
|
- /// 获取房产证返回数据
|
|
|
+ /// 房产证识别(腾讯OCR 未找到)
|
|
|
+ /// 返回数据
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -413,8 +513,8 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 结婚证识别
|
|
|
- /// 获取结婚证返回数据
|
|
|
+ /// 结婚证识别(腾讯OCR 未找到)
|
|
|
+ /// 返回数据
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -444,8 +544,8 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 统一信用代码识别
|
|
|
- /// 获取统一信用代码返回数据
|
|
|
+ /// 统一信用代码识别 (腾讯OCR 未找到)
|
|
|
+ /// 返回数据
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -502,7 +602,49 @@ namespace OASystem.API.Controllers
|
|
|
return Ok(JsonView(pData.Msg));
|
|
|
}
|
|
|
|
|
|
- return Ok(JsonView(pData.Data));
|
|
|
+ string url = "";
|
|
|
+ #region 文档下载
|
|
|
+
|
|
|
+ string fileName = "护照识别(中国大陆地区护照)";
|
|
|
+ string content = $"{fileName}\r\n\r\n";
|
|
|
+ PassportOCRResponse pInfo = pData.Data as PassportOCRResponse;
|
|
|
+ Document doc = new Document();
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+ if (pInfo != 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";
|
|
|
+ }
|
|
|
+ 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))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(outputDir);
|
|
|
+ }
|
|
|
+ //去水印
|
|
|
+ new Aspose.Words.License().SetLicense(new MemoryStream(Convert.FromBase64String(AsposeHelper.asposeKey)));
|
|
|
+ doc.Save(outputPath);
|
|
|
+ url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ return Ok(JsonView(true,"操作成功", new { dataSource = pInfo, url = url }));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -533,7 +675,49 @@ namespace OASystem.API.Controllers
|
|
|
return Ok(JsonView(mlidpData.Msg));
|
|
|
}
|
|
|
|
|
|
- return Ok(JsonView(mlidpData.Data));
|
|
|
+ string url = "";
|
|
|
+ #region 文档下载
|
|
|
+
|
|
|
+ string fileName = "护照识别(中国大陆地区护照)";
|
|
|
+ string content = $"{fileName}\r\n\r\n";
|
|
|
+ PassportOCRResponse pInfo = mlidpData.Data as PassportOCRResponse;
|
|
|
+ Document doc = new Document();
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+ if (pInfo != 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";
|
|
|
+ }
|
|
|
+ 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))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(outputDir);
|
|
|
+ }
|
|
|
+ //去水印
|
|
|
+ new Aspose.Words.License().SetLicense(new MemoryStream(Convert.FromBase64String(AsposeHelper.asposeKey)));
|
|
|
+ doc.Save(outputPath);
|
|
|
+ url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "操作成功", new { dataSource = pInfo, url = url }));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|