|  | @@ -1,27 +1,21 @@
 | 
	
		
			
				|  |  |  using Aspose.Cells;
 | 
	
		
			
				|  |  |  using Aspose.Words;
 | 
	
		
			
				|  |  | -using Aspose.Words.Fonts;
 | 
	
		
			
				|  |  | -using Microsoft.AspNetCore.Mvc.ViewEngines;
 | 
	
		
			
				|  |  | -using NPOI.HPSF;
 | 
	
		
			
				|  |  | +using Microsoft.EntityFrameworkCore.Internal;
 | 
	
		
			
				|  |  | +using Microsoft.IdentityModel.Tokens;
 | 
	
		
			
				|  |  | +using NPOI.OpenXmlFormats.Wordprocessing;
 | 
	
		
			
				|  |  | +using NPOI.XWPF.UserModel;
 | 
	
		
			
				|  |  |  using OASystem.API.OAMethodLib.File;
 | 
	
		
			
				|  |  | -//using OASystem.API.OAMethodLib.NPOI;
 | 
	
		
			
				|  |  |  using OASystem.API.OAMethodLib.TencentCloudAPI;
 | 
	
		
			
				|  |  |  using OASystem.API.OAMethodLib.YouDaoAPI;
 | 
	
		
			
				|  |  |  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;
 | 
	
		
			
				|  |  | -using Org.BouncyCastle.Utilities.Encoders;
 | 
	
		
			
				|  |  | -using StackExchange.Redis;
 | 
	
		
			
				|  |  | -using System.Collections.Generic;
 | 
	
		
			
				|  |  | -using System.Data;
 | 
	
		
			
				|  |  | -using System.Net.NetworkInformation;
 | 
	
		
			
				|  |  | +using System.Text;
 | 
	
		
			
				|  |  |  using TencentCloud.Ocr.V20181119.Models;
 | 
	
		
			
				|  |  | -using Ubiety.Dns.Core;
 | 
	
		
			
				|  |  | +using Document = NPOI.XWPF.UserModel.Document;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |  {
 | 
	
	
		
			
				|  | @@ -80,27 +74,48 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              GeneralBasicOCRResponse res = gbData.Data as GeneralBasicOCRResponse;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            Document doc = new Document();
 | 
	
		
			
				|  |  | -            DocumentBuilder builder = new DocumentBuilder(doc);
 | 
	
		
			
				|  |  | +            // 创建文档对象
 | 
	
		
			
				|  |  | +            XWPFDocument doc = new XWPFDocument();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            XWPFParagraph p1 = doc.CreateParagraph();
 | 
	
		
			
				|  |  | +            XWPFRun runText = p1.CreateRun();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              string fileName = "通用印刷体";
 | 
	
		
			
				|  |  | -            string content = $"{fileName}\r\n\r\n";
 | 
	
		
			
				|  |  | +            string content = $"{fileName}\n";
 | 
	
		
			
				|  |  | +            runText.SetText(content);
 | 
	
		
			
				|  |  | +            runText.AddCarriageReturn();
 | 
	
		
			
				|  |  |              foreach (var view in res.TextDetections)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                content += $"Content:{view.DetectedText}\r\n\r\n";
 | 
	
		
			
				|  |  | +                XWPFRun runText1 = p1.CreateRun();
 | 
	
		
			
				|  |  | +                string content1 = $"Content:{view.DetectedText}\n";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                runText1.SetText(content1);
 | 
	
		
			
				|  |  | +                runText1.AddCarriageReturn();
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            builder.Write(content);
 | 
	
		
			
				|  |  | +            runText.FontSize = 12;
 | 
	
		
			
				|  |  | +            runText.SetFontFamily("宋体", FontCharRange.None); //设置宋体字体
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            string outputDir = $"{AppSettingsHelper.Get("WordBasePath")}/TencentOCR";
 | 
	
		
			
				|  |  | -            string outputFile = $"{fileName}{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
 | 
	
		
			
				|  |  | -            string outputPath = Path.Combine(outputDir, outputFile);
 | 
	
		
			
				|  |  | +            //工作流写入,通过流的方式进行创建生成文件
 | 
	
		
			
				|  |  | +            MemoryStream stream = new MemoryStream();
 | 
	
		
			
				|  |  | +            doc.Write(stream);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            string FilePath = $"{AppSettingsHelper.Get("WordBasePath")}/TencentOCR";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            if (!Directory.Exists(outputDir))
 | 
	
		
			
				|  |  | +            if (!Directory.Exists(FilePath))
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                Directory.CreateDirectory(outputDir);
 | 
	
		
			
				|  |  | +                Directory.CreateDirectory(FilePath);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            AsposeHelper.removewatermark_v2180();
 | 
	
		
			
				|  |  | -            doc.Save(outputPath);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            string outputFile = $"{fileName}{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            string sDate = DateTime.Now.ToString("yyyy年MM月dd日-HH时mm分ss秒-ffff");
 | 
	
		
			
				|  |  | +            FilePath = FilePath + "/" + outputFile;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            FileStream Fs = new FileStream(FilePath, FileMode.OpenOrCreate);
 | 
	
		
			
				|  |  | +            doc.Write(Fs);
 | 
	
		
			
				|  |  | +            Fs.Close();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              string url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              #endregion
 | 
	
	
		
			
				|  | @@ -108,7 +123,6 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |              return Ok(JsonView(true, "操作成功", new { dataSource = res, url = url }));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          /// 身份证识别(国徽面/反面)
 | 
	
		
			
				|  |  |          /// 文档下载
 | 
	
	
		
			
				|  | @@ -132,7 +146,7 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |                  return Ok(JsonView("图片不能大于7M!"));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            var idCardData =await TencentOCRTools.GetOCR((int)TencentOCREnum.IDCard, dto);
 | 
	
		
			
				|  |  | +            var idCardData = await TencentOCRTools.GetOCR((int)TencentOCREnum.IDCard, dto);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (idCardData.Code != 0)
 | 
	
		
			
				|  |  |              {
 | 
	
	
		
			
				|  | @@ -243,73 +257,176 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              ResidenceBookletOCRResponse res = residenceBookData.Data as ResidenceBookletOCRResponse;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            Document doc = new Document();
 | 
	
		
			
				|  |  | -            DocumentBuilder builder = new DocumentBuilder(doc);
 | 
	
		
			
				|  |  | +            // 创建文档对象
 | 
	
		
			
				|  |  | +            XWPFDocument doc = new XWPFDocument();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            XWPFParagraph p = doc.CreateParagraph();
 | 
	
		
			
				|  |  | +            XWPFRun runText = p.CreateRun();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              string fileName = "户口簿识别";
 | 
	
		
			
				|  |  | -            string content = $"{fileName}\r\n\r\n";
 | 
	
		
			
				|  |  | +            string content = $"{fileName}\n";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (res != null)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                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);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            string outputDir = $"{AppSettingsHelper.Get("WordBasePath")}/TencentOCR";
 | 
	
		
			
				|  |  | +                content += $"户号:{res.HouseholdNumber ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"姓名:{res.Name ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"曾用名:{res.FormerName ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"性别:{res.Sex ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"出生地:{res.BirthPlace ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"民族:{res.Nation ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"籍贯:{res.NativePlace ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"出生日期:{res.BirthDate ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"公民身份证件编号:{res.IdCardNumber ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"文化程度:{res.EducationDegree ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"服务处所:{res.ServicePlace ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"户别:{res.Household ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"住址:{res.Address ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"承办人签章文字:{res.Signature ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"签发日期:{res.IssueDate ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"户主页编号:{res.HomePageNumber ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"户主姓名:{res.HouseholderName ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"户主或与户主关系:{res.Relationship ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"本市(县)其他住址:{res.OtherAddresses ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"宗教信仰:{res.ReligiousBelief ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"身高:{res.Height ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"血型:{res.BloodType ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"婚姻状况:{res.MaritalStatus ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"兵役状况:{res.VeteranStatus ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"职业:{res.Profession ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"何时由何地迁来本市(县):{res.MoveToCityInformation ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"何时由何地迁来本址:{res.MoveToSiteInformation ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"登记日期:{res.RegistrationDate ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            setWrap(content,p, runText);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            runText.FontSize = 12;
 | 
	
		
			
				|  |  | +            runText.SetFontFamily("宋体", FontCharRange.None); //设置宋体字体
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //工作流写入,通过流的方式进行创建生成文件
 | 
	
		
			
				|  |  | +            MemoryStream stream = new MemoryStream();
 | 
	
		
			
				|  |  | +            doc.Write(stream);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            string FilePath = $"{AppSettingsHelper.Get("WordBasePath")}/TencentOCR";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (!Directory.Exists(FilePath))
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                Directory.CreateDirectory(FilePath);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              string outputFile = $"{fileName}{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
 | 
	
		
			
				|  |  | -            string outputPath = Path.Combine(outputDir, outputFile);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            if (!Directory.Exists(outputDir))
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                Directory.CreateDirectory(outputDir);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            string sDate = DateTime.Now.ToString("yyyy年MM月dd日-HH时mm分ss秒-ffff");
 | 
	
		
			
				|  |  | +            FilePath = FilePath + "/" + outputFile;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            AsposeHelper.removewatermark_v2180();
 | 
	
		
			
				|  |  | -            doc.Save(outputPath);
 | 
	
		
			
				|  |  | -            string url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
 | 
	
		
			
				|  |  | +            FileStream Fs = new FileStream(FilePath, FileMode.OpenOrCreate);
 | 
	
		
			
				|  |  | +            doc.Write(Fs);
 | 
	
		
			
				|  |  | +            Fs.Close();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            string url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            var data = new { 
 | 
	
		
			
				|  |  | +            var data = new
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  |                  dataSource = residenceBookData.Data,
 | 
	
		
			
				|  |  |                  url = url
 | 
	
		
			
				|  |  |              };
 | 
	
		
			
				|  |  |              #endregion
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              return Ok(JsonView(data));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// npoi 创建 Word
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        /// <param name="typeName"></param>
 | 
	
		
			
				|  |  | +        /// <param name="content"></param>
 | 
	
		
			
				|  |  | +        /// <returns></returns>
 | 
	
		
			
				|  |  | +        private string NPOICreateWord(string typeName, string content)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            try
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                // 创建文档对象
 | 
	
		
			
				|  |  | +                XWPFDocument doc = new XWPFDocument();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                XWPFParagraph p = doc.CreateParagraph();
 | 
	
		
			
				|  |  | +                XWPFRun runText = p.CreateRun();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                string fileName = typeName;
 | 
	
		
			
				|  |  | +                string content1 = $"{fileName}\n{content}";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                setWrap(content1, p, runText);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                runText.FontSize = 12;
 | 
	
		
			
				|  |  | +                runText.SetFontFamily("宋体", FontCharRange.None); //设置宋体字体
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //工作流写入,通过流的方式进行创建生成文件
 | 
	
		
			
				|  |  | +                MemoryStream stream = new MemoryStream();
 | 
	
		
			
				|  |  | +                doc.Write(stream);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                string FilePath = $"{AppSettingsHelper.Get("WordBasePath")}/TencentOCR";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (!Directory.Exists(FilePath))
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    Directory.CreateDirectory(FilePath);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                string outputFile = $"{fileName}{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                string sDate = DateTime.Now.ToString("yyyy年MM月dd日-HH时mm分ss秒-ffff");
 | 
	
		
			
				|  |  | +                FilePath = FilePath + "/" + outputFile;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                FileStream Fs = new FileStream(FilePath, FileMode.OpenOrCreate);
 | 
	
		
			
				|  |  | +                doc.Write(Fs);
 | 
	
		
			
				|  |  | +                Fs.Close();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                return $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            catch (Exception ex)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                return ex.Message;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// npoi 换行
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        /// <param name="value"></param>
 | 
	
		
			
				|  |  | +        /// <param name="paragraph"></param>
 | 
	
		
			
				|  |  | +        /// <param name="run"></param>
 | 
	
		
			
				|  |  | +        private void setWrap(Object value, XWPFParagraph paragraph, XWPFRun run)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            if (((String)value).IndexOf("\n") > 0)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                //设置换行
 | 
	
		
			
				|  |  | +                String[] text = value.ToString().Split("\n");
 | 
	
		
			
				|  |  | +               
 | 
	
		
			
				|  |  | +                for (int f = 0; f < text.Length; f++)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    XWPFRun run1 = paragraph.CreateRun();
 | 
	
		
			
				|  |  | +                    if (f == 0)
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        //此处不缩进因为word模板已经缩进了。
 | 
	
		
			
				|  |  | +                        run1.SetText(text[f].Trim());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    else
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        run1.AddCarriageReturn();//硬回车
 | 
	
		
			
				|  |  | +                                                //注意:wps换行首行缩进是三个空格符,office要的话可以用 run.addTab();缩进或者四个空格符
 | 
	
		
			
				|  |  | +                        run1.SetText(text[f].Trim());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                run.SetText((String)value);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          /// 营业执照识别
 | 
	
		
			
				|  |  | -        /// 获取营业执照返回数据 
 | 
	
		
			
				|  |  | +        /// 文档下载 
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  |          /// <param name="dto"></param>
 | 
	
		
			
				|  |  |          /// <returns></returns>
 | 
	
	
		
			
				|  | @@ -335,13 +452,36 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |                  return Ok(JsonView(residenceBookData.Msg));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            BizLicenseOCRResponse dataInfo = residenceBookData.Data as BizLicenseOCRResponse;
 | 
	
		
			
				|  |  | +            string fileName = "营业执照识别";
 | 
	
		
			
				|  |  | +            string content = "";
 | 
	
		
			
				|  |  | +            if (dataInfo != null)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                content += $"统一社会信用代码(三合一之前为注册号):{dataInfo.RegNum}\n";
 | 
	
		
			
				|  |  | +                content += $"公司名称:{dataInfo.Name}\n";
 | 
	
		
			
				|  |  | +                content += $"注册资本:{dataInfo.Capital}\n";
 | 
	
		
			
				|  |  | +                content += $"法定代表人:{dataInfo.Person}\n";
 | 
	
		
			
				|  |  | +                content += $"地址:{dataInfo.Address} \n";
 | 
	
		
			
				|  |  | +                content += $"经营范围:{dataInfo.Business}\n";
 | 
	
		
			
				|  |  | +                content += $"主体类型:{dataInfo.Type} \n";
 | 
	
		
			
				|  |  | +                content += $"营业期限:{dataInfo.Period}\n";
 | 
	
		
			
				|  |  | +                content += $"组成形式:{dataInfo.ComposingForm}\n";
 | 
	
		
			
				|  |  | +                content += $"成立日期:{dataInfo.SetDate}\n";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return Ok(JsonView(residenceBookData.Data));
 | 
	
		
			
				|  |  | +            string url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  | +            var data = new
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                dataSource = residenceBookData.Data,
 | 
	
		
			
				|  |  | +                url = url
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +            return Ok(JsonView(data));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          /// 组织结构识别
 | 
	
		
			
				|  |  | -        /// 获取组织结构返回数据 
 | 
	
		
			
				|  |  | +        /// 文档下载 
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  |          /// <param name="dto"></param>
 | 
	
		
			
				|  |  |          /// <returns></returns>
 | 
	
	
		
			
				|  | @@ -367,7 +507,25 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |                  return Ok(JsonView(occData.Msg));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return Ok(JsonView(occData.Data));
 | 
	
		
			
				|  |  | +            string fileName = "组织结构识别";
 | 
	
		
			
				|  |  | +            string content = "";
 | 
	
		
			
				|  |  | +            OrgCodeCertOCRResponse occInfo = occData.Data as OrgCodeCertOCRResponse;
 | 
	
		
			
				|  |  | +            if (occInfo != null)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                content += $"代码:{occInfo.OrgCode}\n";
 | 
	
		
			
				|  |  | +                content += $"机构名称:{occInfo.Name}\n";
 | 
	
		
			
				|  |  | +                content += $"地址:{occInfo.Address}\n";
 | 
	
		
			
				|  |  | +                content += $"有效期:{occInfo.ValidDate}\n";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            string url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            var data = new
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                dataSource = occInfo,
 | 
	
		
			
				|  |  | +                url = url
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +            return Ok(JsonView(data));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
	
		
			
				|  | @@ -399,109 +557,71 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |                  return Ok(JsonView(vehicleLicenseData.Result.Msg));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              #region word下载
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              VehicleLicenseOCRResponse vlData = vehicleLicenseData.Result.Data as VehicleLicenseOCRResponse;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            string url = ""; 
 | 
	
		
			
				|  |  | +            string url = "";
 | 
	
		
			
				|  |  |              string fileName = "";
 | 
	
		
			
				|  |  |              string content = "";
 | 
	
		
			
				|  |  |              dynamic data = null;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            try
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                //Aspose.Words.License lic = new Aspose.Words.License();
 | 
	
		
			
				|  |  | -                //lic.SetLicense("Aspose.Wrods.lic");//破解版不用设置license
 | 
	
		
			
				|  |  | +            //Aspose.Words.License lic = new Aspose.Words.License();
 | 
	
		
			
				|  |  | +            //lic.SetLicense("Aspose.Wrods.lic");//破解版不用设置license
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                if (dto.CardSide == 0) // 正面
 | 
	
		
			
				|  |  | +            if (dto.CardSide == 0) // 正面
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                fileName = "行驶证识别-主页";
 | 
	
		
			
				|  |  | +                TextVehicleFront frontInfo = vlData.FrontInfo;
 | 
	
		
			
				|  |  | +                if (frontInfo != null)
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    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}";
 | 
	
		
			
				|  |  | +                    data = frontInfo;
 | 
	
		
			
				|  |  | +                    content += $"号牌号码:{frontInfo.PlateNo ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"车辆类型:{frontInfo.VehicleType ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"所有人:{frontInfo.Owner ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"住址:{frontInfo.Address ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"使用性质:{frontInfo.UseCharacter ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"品牌型号:{frontInfo.Model ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"车辆识别代号:{frontInfo.Vin ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"发动机号码:{frontInfo.EngineNo ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"注册日期:{frontInfo.RegisterDate ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"发证日期:{frontInfo.IssueDate ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"印章:{frontInfo.Seal ?? "Unknown"}\n";
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                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);
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | +                url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else if (dto.CardSide == 1) //反面
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                TextVehicleBack backInfo = vlData.BackInfo;
 | 
	
		
			
				|  |  | +                fileName = "行驶证识别-副页";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                    doc.Save(outputPath);
 | 
	
		
			
				|  |  | -                    url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
 | 
	
		
			
				|  |  | +                if (backInfo != null)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    data = backInfo;
 | 
	
		
			
				|  |  | +                    content += $"号牌号码:{backInfo.PlateNo ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"档案编号:{backInfo.FileNo ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"核定人数:{backInfo.AllowNum ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"总质量:{backInfo.TotalMass ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"整备质量:{backInfo.CurbWeight ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"核定载质量:{backInfo.LoadQuality ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"外廓尺寸:{backInfo.ExternalSize ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"备注:{backInfo.Marks ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"检验记录:{backInfo.Record ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                    content += $"准牵引总质量:{backInfo.TotalQuasiMass ?? "Unknown"}\n";
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                #endregion
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                return Ok(JsonView(true, "操作成功", new { dataSource = data, url = url }));
 | 
	
		
			
				|  |  | +                url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            catch (Exception ex)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                return Ok(JsonView(false, $"InnerException:{ex.InnerException?.Message ?? "Unknown"} ErrMsg:{ex.Message}"));
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | +            #endregion
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return Ok(JsonView(true, "操作成功", new { dataSource = data, url = url }));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  | -        /// 房产证识别(腾讯OCR 未找到)
 | 
	
		
			
				|  |  | -        /// 返回数据 
 | 
	
		
			
				|  |  | +        /// 房产证识别
 | 
	
		
			
				|  |  | +        /// 文档下载
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  |          /// <param name="dto"></param>
 | 
	
		
			
				|  |  |          /// <returns></returns>
 | 
	
	
		
			
				|  | @@ -527,18 +647,31 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |                  return Ok(JsonView(pcData.Msg));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return Ok(JsonView(pcData.Data));
 | 
	
		
			
				|  |  | +            PropOwnerCertOCRResponse pocInfo = pcData.Data as PropOwnerCertOCRResponse;
 | 
	
		
			
				|  |  | +            string fileName = "房产证识别";
 | 
	
		
			
				|  |  | +            string content = "";
 | 
	
		
			
				|  |  | +            if (pocInfo != null) {
 | 
	
		
			
				|  |  | +                content += $"房地产权利人:{pocInfo.Owner}\n";
 | 
	
		
			
				|  |  | +                content += $"共有情况:{pocInfo.Possession}\n";
 | 
	
		
			
				|  |  | +                content += $"登记时间:{pocInfo.RegisterTime}\n";
 | 
	
		
			
				|  |  | +                content += $"规划用途:{pocInfo.Purpose}\n";
 | 
	
		
			
				|  |  | +                content += $"房屋性质:{pocInfo.Nature}\n";
 | 
	
		
			
				|  |  | +                content += $"房地坐落:{pocInfo.Location}\n";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            string url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return Ok(JsonView(new { dataSource = pocInfo, url = url }));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  | -        /// 结婚证识别(腾讯OCR 未找到)
 | 
	
		
			
				|  |  | -        /// 返回数据 
 | 
	
		
			
				|  |  | +        /// 结婚证识别
 | 
	
		
			
				|  |  | +        /// 文档下载
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  |          /// <param name="dto"></param>
 | 
	
		
			
				|  |  |          /// <returns></returns>
 | 
	
		
			
				|  |  |          [HttpPost]
 | 
	
		
			
				|  |  |          [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
 | 
	
		
			
				|  |  | -        public async Task<IActionResult> GetMarriageLicense(MarriageLicenseOCRDto dto)
 | 
	
		
			
				|  |  | +        public async Task<IActionResult> GetMarriageLicense(GeneralBasicOCRDto dto)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              double strSize = 1024 * 1024 * 7;
 | 
	
		
			
				|  |  |              if (dto.picBase64.Length > strSize)
 | 
	
	
		
			
				|  | @@ -558,18 +691,29 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |                  return Ok(JsonView(mlData.Msg));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return Ok(JsonView(mlData.Data));
 | 
	
		
			
				|  |  | +            string fileName = "结婚证识别";
 | 
	
		
			
				|  |  | +            string content = "";
 | 
	
		
			
				|  |  | +            GeneralBasicOCRResponse data = mlData.Data as GeneralBasicOCRResponse;
 | 
	
		
			
				|  |  | +            List<TextDetection> infos = data.TextDetections.ToList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            foreach (var item in infos)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                content += $"Content:{item.DetectedText}\n";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            string url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return Ok(JsonView(new { dataSource = infos, url = url }));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  | -        /// 统一信用代码识别 (腾讯OCR 未找到)
 | 
	
		
			
				|  |  | -        /// 返回数据 
 | 
	
		
			
				|  |  | +        /// 统一信用代码识别
 | 
	
		
			
				|  |  | +        /// 文档下载 
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  |          /// <param name="dto"></param>
 | 
	
		
			
				|  |  |          /// <returns></returns>
 | 
	
		
			
				|  |  |          [HttpPost]
 | 
	
		
			
				|  |  |          [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
 | 
	
		
			
				|  |  | -        public async Task<IActionResult> GetUniformCreditCode(UniformCreditCodeOCRDto dto)
 | 
	
		
			
				|  |  | +        public async Task<IActionResult> GetUniformCreditCode(GeneralBasicOCRDto dto)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              double strSize = 1024 * 1024 * 7;
 | 
	
		
			
				|  |  |              if (dto.picBase64.Length > strSize)
 | 
	
	
		
			
				|  | @@ -589,7 +733,18 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |                  return Ok(JsonView(gbData.Msg));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return Ok(JsonView(gbData.Data));
 | 
	
		
			
				|  |  | +            string fileName = "统一信用代码识别";
 | 
	
		
			
				|  |  | +            string content = "";
 | 
	
		
			
				|  |  | +            GeneralBasicOCRResponse data = gbData.Data as GeneralBasicOCRResponse;
 | 
	
		
			
				|  |  | +            List<TextDetection> infos = data.TextDetections.ToList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            foreach (var item in infos)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                content += $"Content:{item.DetectedText}\n";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            string url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return Ok(JsonView(new { dataSource = infos, url = url }));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
	
		
			
				|  | @@ -624,45 +779,30 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |              #region 文档下载
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              string fileName = "护照识别(中国大陆地区护照)";
 | 
	
		
			
				|  |  | -            string content = $"{fileName}\r\n\r\n";
 | 
	
		
			
				|  |  | +            string content = $"";
 | 
	
		
			
				|  |  |              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}";
 | 
	
		
			
				|  |  | +                content += $"国籍:{pInfo.Nationality ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"国家码:{pInfo.Country ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"护照号:{pInfo.PassportNo ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"姓名:{pInfo.Name ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"姓:{pInfo.FamilyName ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"名:{pInfo.FirstName ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"性别:{pInfo.Sex ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"出生日期:{pInfo.BirthDate ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"签发日期:{pInfo.IssueDate ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"签发地点:{pInfo.IssuePlace ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"有效期:{pInfo.ExpiryDate ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"持证人签名:{pInfo.Signature ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"最下方第一行 MRZ Code 序列:{pInfo.CodeSet ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"最下方第二行 MRZ Code 序列:{pInfo.CodeCrc ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              #endregion
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return Ok(JsonView(true,"操作成功", new { dataSource = pInfo, url = url }));
 | 
	
		
			
				|  |  | +            return Ok(JsonView(true, "操作成功", new { dataSource = pInfo, url = url }));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
	
		
			
				|  | @@ -697,34 +837,21 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |              #region 文档下载
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              string fileName = "护照识别(港澳台地区及境外护照)";
 | 
	
		
			
				|  |  | -            string content = $"{fileName}\r\n\r\n";
 | 
	
		
			
				|  |  | +            string content = $"";
 | 
	
		
			
				|  |  |              MLIDPassportOCRResponse mlidInfo = mlidpData.Data as MLIDPassportOCRResponse;
 | 
	
		
			
				|  |  | -            Document doc = new Document();
 | 
	
		
			
				|  |  | -            DocumentBuilder builder = new DocumentBuilder(doc);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              if (mlidInfo != null)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                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";
 | 
	
		
			
				|  |  | +                content += $"护照ID:{mlidInfo.ID ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"姓名:{mlidInfo.Name ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"出生日期:{mlidInfo.DateOfBirth ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"性别(F女,M男):{mlidInfo.Sex ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"有效期:{mlidInfo.DateOfExpiration ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"发行国:{mlidInfo.IssuingCountry ?? "Unknown"}\n";
 | 
	
		
			
				|  |  | +                content += $"国家地区代码:{mlidInfo.Nationality ?? "Unknown"}\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}";
 | 
	
		
			
				|  |  | +            url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              #endregion
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -733,7 +860,7 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          /// 名片识别
 | 
	
		
			
				|  |  | -        /// 获取名片 返回数据 
 | 
	
		
			
				|  |  | +        /// 文档下载 
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  |          /// <param name="dto"></param>
 | 
	
		
			
				|  |  |          /// <returns></returns>
 | 
	
	
		
			
				|  | @@ -762,32 +889,17 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |              #region 文档下载
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              string fileName = "名片识别";
 | 
	
		
			
				|  |  | -            string content = $"{fileName}\r\n\r\n";
 | 
	
		
			
				|  |  | +            string content = $"";
 | 
	
		
			
				|  |  |              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";
 | 
	
		
			
				|  |  | +                content += $"TypeName:{view?.Name ?? "Unknown"}\nContent:{view?.Value ?? "Unknown"}\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);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            //去水印
 | 
	
		
			
				|  |  | -            AsposeHelper.removewatermark_v2180();
 | 
	
		
			
				|  |  | -            doc.Save(outputPath);
 | 
	
		
			
				|  |  | -            url = $"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/TencentOCR/{outputFile}";
 | 
	
		
			
				|  |  | +            url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              #endregion
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -818,7 +930,7 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |                  return Ok(JsonView("图片不能大于7M!"));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -           
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              var ssData = await TencentOCRTools.GetOCR((int)TencentOCREnum.SmartStructuralOCRV2, dto);
 | 
	
		
			
				|  |  |              if (ssData.Code != 0)
 | 
	
		
			
				|  |  |              {
 | 
	
	
		
			
				|  | @@ -832,38 +944,22 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |              string fileName = "智能结构化识别V2";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              List<ocrGeneralView>? datas = ssData.Data as List<ocrGeneralView>;
 | 
	
		
			
				|  |  | -            Document doc = new Document();
 | 
	
		
			
				|  |  | -            DocumentBuilder builder = new DocumentBuilder(doc);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            string content = $"{fileName}\r\n\r\n";
 | 
	
		
			
				|  |  | +            string content = $"";
 | 
	
		
			
				|  |  |              foreach (var view in datas)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                content += $"TypeName:{view.name}\t\r\nContent:{view.value}\r\n\r\n";
 | 
	
		
			
				|  |  | +                content += $"TypeName:{view.name}\nContent:{view.value}\n";
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            builder.Write(content);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            string outputDir = $"{AppSettingsHelper.Get("WordBasePath")}/TencentOCR";
 | 
	
		
			
				|  |  | -            string outputFile = $"{fileName}{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
 | 
	
		
			
				|  |  | -            string outputPath = Path.Combine(outputDir, outputFile);
 | 
	
		
			
				|  |  | +            string url = NPOICreateWord(fileName, content);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            if (!Directory.Exists(outputDir))
 | 
	
		
			
				|  |  | +            var data = new
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                Directory.CreateDirectory(outputDir);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            //去水印
 | 
	
		
			
				|  |  | -            AsposeHelper.removewatermark_v2180();
 | 
	
		
			
				|  |  | -            doc.Save(outputPath);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -           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
 | 
	
	
		
			
				|  | @@ -875,7 +971,7 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |          /// 获取名片 移动端 返回数据 
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  |          /// <param name="dto"></param>
 | 
	
		
			
				|  |  | -        /// <returns></returns>
 | 
	
		
			
				|  |  | +        /// <returns></returns> 
 | 
	
		
			
				|  |  |          [HttpPost]
 | 
	
		
			
				|  |  |          [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
 | 
	
		
			
				|  |  |          public async Task<IActionResult> PostBusinessCardApp(BusinessCardOCRDto dto)
 |