jeremy 11 months ago
parent
commit
5d10ed06fd

BIN
Depends/ReportGenerator.dll


BIN
Depends/Vinno.vCloud.Report.dll


+ 16 - 1
ReportGenerator/ParagraphGenerater.cs

@@ -113,7 +113,22 @@ namespace ReportService
                 }
                 else if (reportInfo.ElementValues[textElement.Tag].GetValue() != null)
                 {
-                    textElementValue = reportInfo.ElementValues[textElement.Tag]?.GetValue().ToString();
+                    if (textElement.Tag.Name == "ResultPrompt" && !string.IsNullOrEmpty(textElement.Tag.ParentName))
+                    {
+                        var tempValue = reportInfo.ElementValues[textElement.Tag]?.GetValue().ToString();
+                        if (!string.IsNullOrEmpty(tempValue))
+                        {
+                            JObject json = JObject.Parse(tempValue);
+                            if (json != null && json.ContainsKey(textElement.Tag.ParentName))
+                            {
+                                textElementValue = json[textElement.Tag.ParentName].ToString();
+                            }
+                        }
+                    }
+                    else
+                    {
+                        textElementValue = reportInfo.ElementValues[textElement.Tag]?.GetValue().ToString();
+                    }
                 }
             }
             else if (textElement.MeasureTag != null && reportInfo.MeasureElementValues?.Count > 0)

+ 55 - 0
ReportGenerator/ReportPreviewImagesGenerater.cs

@@ -7,6 +7,7 @@ using Syncfusion.DocIORenderer;
 using Vinno.IUS.Common.IO;
 using SkiaSharp;
 using System;
+using Syncfusion.Pdf.Graphics;
 
 namespace ReportService
 {
@@ -114,5 +115,59 @@ namespace ReportService
                 return null;
             }
         }
+
+        /// <summary>
+        /// 转换为image
+        /// </summary>
+        /// <param name="reportInfo"></param>
+        /// <param name="pdfSavePath"></param>
+        public IEnumerable<ImageInfo> ConvertPDFReportToImage(string pdfPath)
+        {
+            List<ImageInfo> imageInfos = new List< ImageInfo >();
+            using (var fiumPdf = new PdfDocument(pdfPath))
+            {
+                var firstPages = fiumPdf.Pages;
+                foreach (var firstPage in firstPages)
+                {
+                    var width = (int)(firstPage.Size.Width * 4);
+                    var height = (int)(firstPage.Size.Height * 4);
+                    using (var pageBitmap = new PDFiumBitmap(width, height, true))
+                    {
+                        firstPage.Render(pageBitmap, (0, 0, width, height));
+                        using (var bytes = pageBitmap.AsBmpStream())
+                        {
+                            if (bytes != null && bytes.Length > 0)
+                            {
+                                using (SKBitmap sourceBitmap = SKBitmap.Decode(bytes))
+                                {
+                                    // 创建目标 SKBitmap 对象
+                                    using (SKBitmap targetBitmap = new SKBitmap(width, height, SKColorType.Rgba8888, SKAlphaType.Premul))
+                                    {
+                                        // 创建 SKCanvas 对象
+                                        using (SKCanvas canvas = new SKCanvas(targetBitmap))
+                                        {
+                                            // 绘制白色矩形
+                                            canvas.Clear(SKColors.White);
+                                            // 将源 SKBitmap 对象绘制到目标 SKBitmap 对象上
+                                            canvas.DrawBitmap(sourceBitmap, SKRect.Create(width, height));
+                                        }
+                                        using (MemoryStream stream = new MemoryStream())
+                                        {
+                                            targetBitmap.Encode(stream, SKEncodedImageFormat.Jpeg, 100);
+                                            var imageInfo = new ImageInfo();
+                                            imageInfo.ImageBuffer = new ByteBuffer(stream.GetBuffer());
+                                            imageInfos.Add(imageInfo);
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            return imageInfos;
+        }
     }
+    
+
 }

+ 56 - 12
ReportGenerator/TableGenerater.cs

@@ -204,6 +204,7 @@ namespace ReportService
                         var groupFieldList = new List<string>();
                         var minRowSpanDic = new Dictionary<int, int>();
                         var otherMergeRowIndexs = new List<int>();
+                        bool isHiddenBorder = true;
                         //查询是否存在绑定值
                         var tupleResult = QueryIsExistBindValue(table, mergeRowIndexs, reportInfo);
                         var fixedGroupFields = new List<string>();
@@ -213,6 +214,7 @@ namespace ReportService
                             minRowSpanDic = tupleResult.Item2;
                             otherMergeRowIndexs = tupleResult.Item3;
                             fixedGroupFields = tupleResult.Item4;
+                            isHiddenBorder = tupleResult.Item5;
                         }
                         var otherMergeCellDictionary = new Dictionary<CellPostion, ICell>();
                         var existCellDictionary = new Dictionary<CellPostion, ICell>();
@@ -235,7 +237,7 @@ namespace ReportService
                             int newCellCount = 0;
                             if (isExistGroupFold)
                             {
-                                var cellDictionary = ResetTableGroupRowDefinition(fixedGroupFields, groupFieldList, table, existCellDictionary, columnCount, cellRowInfos, waitCloneICell, isAllFill, isTopTable);
+                                var cellDictionary = ResetTableGroupRowDefinition(fixedGroupFields, groupFieldList, table, existCellDictionary, columnCount, cellRowInfos, waitCloneICell, isAllFill, isTopTable, isHiddenBorder);
                                 
                                 table.Cells = cellDictionary;
                             }
@@ -251,7 +253,7 @@ namespace ReportService
                                 }
                                 else
                                 {
-                                    var cellDictionary = ResetTabelCell(isTopTable, existCellDictionary, waitCloneICell, minRowSpanDic, table.RowDefinitions.Count, columnCount, diffCellCount, newCellCount, otherMergeCellDictionary, isAllFill);
+                                    var cellDictionary = ResetTabelCell(isTopTable, existCellDictionary, waitCloneICell, minRowSpanDic, table.RowDefinitions.Count, columnCount, diffCellCount, newCellCount, otherMergeCellDictionary, isAllFill, isHiddenBorder);
                                     table.Cells = cellDictionary;
                                 }
                             }
@@ -297,14 +299,48 @@ namespace ReportService
         /// <param name="mergeRowIndexs"></param>
         /// <param name="reportInfo"></param>
         /// <returns></returns>
-        private static Tuple<List<string>, Dictionary<int, int>, List<int>, List<string>> QueryIsExistBindValue(RTTable table, List<int> mergeRowIndexs, ReportInfo reportInfo)
+        private static Tuple<List<string>, Dictionary<int, int>, List<int>, List<string>, bool> QueryIsExistBindValue(RTTable table, List<int> mergeRowIndexs, ReportInfo reportInfo)
         {
             var groupFieldList = new List<string>();
             var minRowSpanDic = new Dictionary<int, int>();
             var staticTextGroupFieldList = new List<string>();
             var inputGroupFieldList = new List<string>();
+            var isHiddenBorder = true;
             foreach (var cell in table.Cells)
             {
+                var borders = cell.Value.Borders;
+                if (borders.Bottom.BorderStyle == RTBorderStyle.None)
+                {
+                    isHiddenBorder = isHiddenBorder & true;
+                }
+                else
+                {
+                    isHiddenBorder = isHiddenBorder & false;
+                }
+                if (borders.Top.BorderStyle == RTBorderStyle.None)
+                {
+                    isHiddenBorder = isHiddenBorder & true;
+                }
+                else
+                {
+                    isHiddenBorder = isHiddenBorder & false;
+                }
+                if (borders.Left.BorderStyle == RTBorderStyle.None)
+                {
+                    isHiddenBorder = isHiddenBorder & true;
+                }
+                else
+                {
+                    isHiddenBorder = isHiddenBorder & false;
+                }
+                if (borders.Right.BorderStyle == RTBorderStyle.None)
+                {
+                    isHiddenBorder = isHiddenBorder & true;
+                }
+                else
+                {
+                    isHiddenBorder = isHiddenBorder & false;
+                }
                 if (!mergeRowIndexs.Contains(cell.Key.Row))
                 {
                     var tempGroupField = ((RTCell)cell.Value).GroupField;
@@ -360,7 +396,7 @@ namespace ReportService
                 }
             }
             groupFieldList = groupFieldList.Distinct().ToList();
-            return Tuple.Create(groupFieldList, minRowSpanDic, mergeRowIndexs, staticTextGroupFieldList);
+            return Tuple.Create(groupFieldList, minRowSpanDic, mergeRowIndexs, staticTextGroupFieldList, isHiddenBorder);
         }
 
         /// <summary>
@@ -492,7 +528,7 @@ namespace ReportService
         /// <returns>重新绘制的单元格</returns>
         private static Dictionary<CellPostion, ICell> ResetTabelCell(bool isTopTable, Dictionary<CellPostion, ICell> existCellDictionary,
         ICell waitCloneICell, Dictionary<int, int> minRowSpanDic, int tableRowCount, int columnCount, int diffCellCount, int newCellCount, Dictionary<CellPostion, ICell> otherMergeCellDictionary,
-        bool isAllFill)
+        bool isAllFill, bool isHiddenBorder)
         {
             int rowIndex = 0;
             int colIndex = 0;
@@ -501,7 +537,7 @@ namespace ReportService
             foreach (var key in existCellDictionary.Keys)
             {
                 var cellInfo = existCellDictionary[key];
-                ResetCellBorderStyle(cellInfo, colIndex, rowIndex, tableRowCount, columnCount, key.RowSpan, key.ColumnSpan, isAllFill, isTopTable, false);
+                ResetCellBorderStyle(cellInfo, colIndex, rowIndex, tableRowCount, columnCount, key.RowSpan, key.ColumnSpan, isAllFill, isTopTable, false, isHiddenBorder:isHiddenBorder);
                 if (key.ColumnSpan > 1)
                 {
                     if ((colIndex + key.ColumnSpan) > columnCount)
@@ -563,7 +599,7 @@ namespace ReportService
                         var cellInfo = (waitCloneICell.Clone() as RTCell);
                         cellInfo.Borders.Bottom.BorderStyle = RTBorderStyle.Solid;
                         cellInfo.Background = RTColor.White;
-                        ResetCellBorderStyle(cellInfo, colIndex, rowIndex, tableRowCount, columnCount, 1, 1, isAllFill, isTopTable);
+                        ResetCellBorderStyle(cellInfo, colIndex, rowIndex, tableRowCount, columnCount, 1, 1, isAllFill, isTopTable, isHiddenBorder:isHiddenBorder);
                         cellDictionary.Add(new CellPostion(rowIndex, colIndex, 1, 1), cellInfo);
                     }
                     rowIndex++;
@@ -579,7 +615,7 @@ namespace ReportService
                         rowIndex += minRowSpanDic[item.Row];
                     }
                     var cellInfo = otherMergeCellDictionary[item];
-                    ResetCellBorderStyle(cellInfo, item.Column, rowIndex, tableRowCount, columnCount, item.RowSpan, item.ColumnSpan, isAllFill, isTopTable);
+                    ResetCellBorderStyle(cellInfo, item.Column, rowIndex, tableRowCount, columnCount, item.RowSpan, item.ColumnSpan, isAllFill, isTopTable, isHiddenBorder:isHiddenBorder);
                     lastRowIndex = item.Row;
                     var newCellPostion = new CellPostion(rowIndex, item.Column, item.RowSpan, item.ColumnSpan);
                     cellDictionary.Add(newCellPostion, cellInfo);
@@ -598,7 +634,7 @@ namespace ReportService
         /// <param name="mergeRowIndexCount"></param>
         /// <returns>重绘后表格内单元格的差异值</returns>
         private static Dictionary<CellPostion, ICell> ResetTableGroupRowDefinition(List<string> fixedGroupFields, List<string> groupFieldList, RTTable table, Dictionary<CellPostion, ICell> existCellDictionary, int columnCount,
-            Dictionary<string, RTRowDefinition> cellRowInfos,ICell waitCloneICell, bool isAllFill, bool isTopTable)
+            Dictionary<string, RTRowDefinition> cellRowInfos,ICell waitCloneICell, bool isAllFill, bool isTopTable, bool isHiddenBorder)
         {
             var spanColumnCell = existCellDictionary.Where(c => c.Key.ColumnSpan >= 1 && c.Key.RowSpan == 1)?.ToList() ?? new List<KeyValuePair<CellPostion, ICell>>();
 
@@ -696,7 +732,7 @@ namespace ReportService
                         foreach (var item in fCells)
                         {
                             var cellInfo = item.Value;
-                            ResetCellBorderStyle(cellInfo, curColIndex, curRowIndex, tableRowCount, columnCount, item.Key.RowSpan, item.Key.ColumnSpan, isAllFill, isTopTable);
+                            ResetCellBorderStyle(cellInfo, curColIndex, curRowIndex, tableRowCount, columnCount, item.Key.RowSpan, item.Key.ColumnSpan, isAllFill, isTopTable, isHiddenBorder:isHiddenBorder);
                             item.Key.Row = curRowIndex;
                             item.Key.Column = curColIndex;
                             cellDictionary.Add(item.Key, cellInfo);
@@ -743,7 +779,7 @@ namespace ReportService
                         var cellInfo = (waitCloneICell.Clone() as RTCell);
                         cellInfo.Borders.Bottom.BorderStyle = RTBorderStyle.Solid;
                         cellInfo.Background = RTColor.White;
-                        ResetCellBorderStyle(cellInfo, colIndex, rowIndex, tableRowCount, columnCount, 1, 1, isAllFill, isTopTable);
+                        ResetCellBorderStyle(cellInfo, colIndex, rowIndex, tableRowCount, columnCount, 1, 1, isAllFill, isTopTable, isHiddenBorder:isHiddenBorder);
                         cellDictionary.Add(new CellPostion(rowIndex, colIndex, 1, 1), cellInfo);
                         if ((colIndex + 1) >= columnCount)
                         {
@@ -933,8 +969,16 @@ namespace ReportService
         /// <param name="rowIndex"></param>
         /// <param name="tableCount"></param>
         private static void ResetCellBorderStyle(ICell cellInfo, int colIndex, int rowIndex, int tableRowCount, int tableColumnCount, int rowSpan, int columnSpan,
-            bool isAllFill, bool isTopTable, bool isShowTopBorder = true)
+            bool isAllFill, bool isTopTable, bool isShowTopBorder = true, bool isHiddenBorder = true)
         {
+            if (isHiddenBorder)
+            {
+                cellInfo.Borders.Left.BorderStyle = RTBorderStyle.None;
+                cellInfo.Borders.Right.BorderStyle = RTBorderStyle.None;
+                cellInfo.Borders.Top.BorderStyle = RTBorderStyle.None;
+                cellInfo.Borders.Bottom.BorderStyle = RTBorderStyle.None;
+                return;
+            }
             if (cellInfo.Borders.Left.BorderStyle != RTBorderStyle.None || cellInfo.Borders.Right.BorderStyle != RTBorderStyle.None ||
                                     cellInfo.Borders.Bottom.BorderStyle != RTBorderStyle.None || cellInfo.Borders.Top.BorderStyle != RTBorderStyle.None)
             {

+ 65 - 0
ReportService/ReportConverter/ReportPreviewHelper.cs

@@ -17,6 +17,67 @@ namespace ReportService
         private static readonly ReportPreviewImagesGenerater _reportPreviewImagesGenerater = new ReportPreviewImagesGenerater();
         private static readonly string _reportPreviewFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ReportPreviewTemp");
 
+        /// <summary>
+        /// pdf转img
+        /// </summary>
+        /// <param name="pdfFileUrl"></param>
+        /// <param name="isPhysicalPath"></param>
+        /// <returns></returns>
+        public static List<string> GetImageReportPreviewByPDFFile(string pdfFileUrl, bool isPhysicalPath = true)
+        {
+            if (!Directory.Exists(_reportPreviewFolder))
+            {
+                Directory.CreateDirectory(_reportPreviewFolder);
+            }
+            else
+            {
+                //删除过时文件
+                FileHelper.DeleteFile(_reportPreviewFolder, DateTime.Now.AddHours(-6));
+            }
+            DirectoryInfo reportFolder = new DirectoryInfo(_reportPreviewFolder);
+            string fileName = $"{Guid.NewGuid().ToString("N")}";
+            string filePath = Path.Combine(_reportPreviewFolder, fileName);
+
+            var files = reportFolder.GetFiles().Where(f => f.FullName.Contains(fileName) && f.Extension == $".jpg");
+            if (files != null && files.Any())
+            {
+                foreach (var file in files)
+                {
+                    file.Delete();
+                }
+            }
+            var curPhysicalFilePath = pdfFileUrl;
+            if (!isPhysicalPath)
+            {
+                //那就是网络路径
+                curPhysicalFilePath = DownloadAsync(_reportPreviewFolder, pdfFileUrl).Result;
+            }
+            var imageFiles = new List<string>();
+            var imgList = _reportPreviewImagesGenerater.ConvertPDFReportToImage(curPhysicalFilePath);
+            if (imgList != null && imgList.Count() > 0)
+            {
+                int i = 0;
+                foreach (var image in imgList)
+                {
+                    using (var bitmap = SkiaSharp.SKBitmap.Decode(image.ImageBuffer.GetBytes()))
+                    {
+                        var imagePath = $"{filePath}_{i}.jpg";
+                        using (var fileStream = new FileStream(imagePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
+                        {
+                            bitmap.Encode(fileStream, SkiaSharp.SKEncodedImageFormat.Jpeg, 100);
+                            imageFiles.Add(imagePath);
+                            i++;
+                        }
+                    }
+                }
+            }
+            if (File.Exists(curPhysicalFilePath))
+            {
+                File.Delete(curPhysicalFilePath);
+            }
+            return imageFiles;
+        }
+
         /// <summary>
         /// 生成报告预览图
         /// </summary>
@@ -277,6 +338,10 @@ namespace ReportService
             }
             var fileName = Path.GetFileName(url);
             var targetPath = Path.Combine(downloadFolder, fileName);
+            if (File.Exists(targetPath))
+            {
+                File.Delete(targetPath);
+            }
             long fileSize = 0;
             using (var request = new HttpRequestMessage())
             {

+ 159 - 12
ReportService/Service/ReportService.Exam.cs

@@ -60,10 +60,6 @@ namespace ReportService.Service
             {
                 ReloadVitalReportConfig();
 
-                // var list = new List<int>() {
-                //     1,2,3,4,5,6, 7,98,99
-                // };
-
                 // var re = new VitalReportConvertDetailRequest()
                 // {
 
@@ -85,7 +81,7 @@ namespace ReportService.Service
                 //    ExamType  = 97,
                 //    ExamCode  = "",
                 //    ReportCode  = "",
-                //    Type  = 1,
+                //    Type = 1,
                 //    IsCover  = true
                 // };
                 // var d = DoPersonAndHealthExamReport(re);
@@ -644,6 +640,39 @@ namespace ReportService.Service
         /// </summary>
         public async Task<bool> ReloadVitalReportConfigAsync(ReloadReportConfigRequest request)
         {
+            // var re = new VitalReportConvertDetailRequest()
+            // {
+
+            //    PhysicalExamNumber = "01820240328006",
+            //    IDCardNo = "321282198904132442",
+            //    ExamType = 4,
+            //    ExamCode = "F64D6DE65ACD478FA09B41AA230F1DF2",
+            //    ReportCode = "",
+            //    Type = 1,
+            //    IsCover = true
+            // };
+            // var d = JoinVitalReportQueueAsync(re).Result;
+
+            // var _reportPreviewImagesGenerater = new ReportPreviewImagesGenerater();
+            // var path = @"D:\vCloudStorage\FlyinsonoStorage\20240419\3FFBDF5A5341469285A4F3FD4FE15F35.pdf";
+            // var imgList = _reportPreviewImagesGenerater.ConvertPDFReportToImage(path);
+            // if (imgList != null && imgList.Count() > 0)
+            //     {
+            //         int i = 0;
+            //         var filePath = @"D:\vCloudCache";
+            //         foreach (var image in imgList)
+            //         {
+            //             using (var bitmap = SkiaSharp.SKBitmap.Decode(image.ImageBuffer.GetBytes()))
+            //             {
+            //                 var imagePath = $"{filePath}_{i}.jpg";
+            //                 using (var fileStream = new FileStream(imagePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
+            //                 {
+            //                     bitmap.Encode(fileStream, SkiaSharp.SKEncodedImageFormat.Jpeg, 100);
+            //                     i++;
+            //                 }
+            //             }
+            //         }
+            //     }
             var res = true;
             if (request.Type == 0)
             {
@@ -4962,10 +4991,11 @@ namespace ReportService.Service
                             var reportInfoList = reportInfos.ToList();
                             //验证 个人基本信息是否存在,或者是否需要更新
                             CheckIsNeedUpdatePersonReport(registerInfo, reportInfoList);
+                            var ability_Code = "";
                             //验证 个人健康体检是否存在,或者是否需要更新
-                            CheckIsNeedUpdateHealthExamReport(registerInfo, reportInfoList);
+                            CheckIsNeedUpdateHealthExamReport(registerInfo, reportInfoList, ref ability_Code);
                             //验证老年人生活自理能力评估表
-                            CheckIsNeedUpdateOldPersonSelfCareReport(registerInfo, reportInfoList);
+                            CheckIsNeedUpdateOldPersonSelfCareReport(registerInfo, reportInfoList, ability_Code);
                             //验证老年人中医药健康管理服务记录表
                             CheckIsNeedUpdateOldPersonTCMCDetailRecordReport(registerInfo, reportInfoList);
 
@@ -5078,7 +5108,7 @@ namespace ReportService.Service
         /// <summary>
         /// 云端处理验证老年人生活自理能力评估表
         /// </summary>
-        private bool CheckIsNeedUpdateOldPersonSelfCareReport(RegisterInfoDTO registerInfo, List<WingInterfaceLibrary.DTO.Vital.ReportDTO> reportInfoList)
+        private bool CheckIsNeedUpdateOldPersonSelfCareReport(RegisterInfoDTO registerInfo, List<WingInterfaceLibrary.DTO.Vital.ReportDTO> reportInfoList, string ability_Code)
         {
             //看看有没有创建健康体检检查
             var examReq = new GetExamRecordListDBRequest()
@@ -5086,7 +5116,7 @@ namespace ReportService.Service
                 PatientCode = registerInfo.IDCardNo,
                 Keys = new List<string>() { "LNRZLNLPG" },
                 IsValidOperationDoctor = false,
-                PhysicalExamNumber = registerInfo.PhysicalExamNumber
+                Codes = new List<string>() { ability_Code }
             };
             var examRecords = _vitalExamDBService.GetExamRecordListAsync(examReq).Result;
             if (examRecords == null || examRecords.Count <= 0)
@@ -5137,7 +5167,7 @@ namespace ReportService.Service
         /// <summary>
         /// 云端轮询处理健康体检数据
         /// </summary>
-        private bool CheckIsNeedUpdateHealthExamReport(RegisterInfoDTO registerInfo, List<WingInterfaceLibrary.DTO.Vital.ReportDTO> reportInfoList)
+        private bool CheckIsNeedUpdateHealthExamReport(RegisterInfoDTO registerInfo, List<WingInterfaceLibrary.DTO.Vital.ReportDTO> reportInfoList, ref string ability_Code)
         {
             //看看有没有创建健康体检检查
             var examReq = new GetExamRecordListDBRequest()
@@ -5153,6 +5183,23 @@ namespace ReportService.Service
                 Logger.WriteLineWarn($"GetInspectedRegisterInfoList examRecords is null, request:{JsonConvert.SerializeObject(examReq)}");
                 return true;
             }
+            // 
+            var curExamRecord = examRecords?.Where(c => c.ExamState == ExamStateEnum.Inspected)?.OrderByDescending(c => c.ExamTime)?.FirstOrDefault() ?? new ExamRecordDTO();
+            if (curExamRecord?.ExamRecordDatas?.Count > 0)
+            {
+                var curExamRecordData = curExamRecord.ExamRecordDatas?.FirstOrDefault(c => c.Key == "ZZYBZK") ?? new ExamRecordDataDTO();
+                if (!string.IsNullOrEmpty(curExamRecordData?.ExamData))
+                {
+                    var ZZYBZKObject = JObject.Parse(curExamRecordData.ExamData);
+                    if (ZZYBZKObject != null)
+                    {
+                        if (ZZYBZKObject.ContainsKey("Ability_Code"))
+                        {
+                            ability_Code = ZZYBZKObject["Ability_Code"]?.ToString() ?? string.Empty;
+                        }
+                    }
+                }
+            }
             var isExistHealthExam = reportInfoList.Exists(c => c.Key == "HEIHealthExamination");
             bool isNeedUpdateHealthExam = false;
             if (!isExistHealthExam)
@@ -7866,7 +7913,7 @@ namespace ReportService.Service
                 {
                     physicalExamNumber = vinnoRecordInfo.DevicePatientID;
                 }
-                Logger.WriteLineWarn($"CreateHEIUltrasonicExamAndReport Start, request:{JsonConvert.SerializeObject(request)}");
+                // Logger.WriteLineWarn($"CreateHEIUltrasonicExamAndReport Start, request:{JsonConvert.SerializeObject(request)}");
                 if (string.IsNullOrEmpty(physicalExamNumber))
                 {
                     Logger.WriteLineWarn($"CreateHEIUltrasonicExamAndReport FindRecordInfoByCodeAsync Error, VinnoRecordCode:{ultrasonicCode}");
@@ -7887,7 +7934,7 @@ namespace ReportService.Service
                 {
                     patientCode = registerInfo.IDCardNo;
                 }
-                Logger.WriteLineWarn($"CreateHEIUltrasonicExamAndReport Log, vinnoRecordInfo:{JsonConvert.SerializeObject(vinnoRecordInfo)}, registerInfo:{JsonConvert.SerializeObject(registerInfo)}");
+                // Logger.WriteLineWarn($"CreateHEIUltrasonicExamAndReport Log, vinnoRecordInfo:{JsonConvert.SerializeObject(vinnoRecordInfo)}, registerInfo:{JsonConvert.SerializeObject(registerInfo)}");
                 if (type == 0)
                 {
                     var dbRequest = new CreateExamDBRequest
@@ -7952,6 +7999,23 @@ namespace ReportService.Service
                         }
                         operationDoctor = vinnoReportInfo.ReportUserCode;
                     }
+                    var imgList = new List<string>();
+                    if (!string.IsNullOrEmpty(ultrasonicPdfUrl) && _isNeedImageReport)
+                    {
+                        var tempImgList = ReportPreviewHelper.GetImageReportPreviewByPDFFile(ultrasonicPdfUrl, false);
+                        if (tempImgList?.Count > 0)
+                        {
+                            for (var j = 0; j < tempImgList.Count; j++)
+                            {
+                                var localPathImg = tempImgList[j];
+                                var imgUrl = UploadFileAsync(localPathImg, Path.GetFileName(localPathImg)).Result;
+                                if (!string.IsNullOrWhiteSpace(imgUrl))
+                                {
+                                    imgList.Add(imgUrl);
+                                }
+                            }
+                        }
+                    }
                     //看看检查是否已经创建
                     var reportInfo = new WingInterfaceLibrary.DTO.Vital.ReportDTO()
                     {
@@ -7988,6 +8052,18 @@ namespace ReportService.Service
                             }
                             //OperationDoctor = !string.IsNullOrEmpty(first.ExamDoctor) ? first.ExamDoctor : "8404B000976740D4CC9FAF99FF7698F1"
                         };
+                        if (imgList?.Count > 0)
+                        {
+                            dbRequest.PreviewList = new List<PreviewDTO>() {
+                                new PreviewDTO()
+                                {
+                                    FileToken = string.Join(";", imgList),
+                                    ThumbnailToken = "",
+                                    Language = "zh-CN",
+                                    FileType = (int)UploadFileTypeEnum.JPG
+                                }
+                            };
+                        }
                         reportCode = await _vitalReportDBService.CreateReportAsync(dbRequest);
                     }
                     else
@@ -8011,7 +8087,32 @@ namespace ReportService.Service
                             TemplateCode = reportInfo.TemplateCode,
                             PhysicalExamNumber = reportInfo.PhysicalExamNumber,
                             ExamCode = examCode,
+                            PreviewList = reportInfo.PreviewList
                         };
+                        if (imgList?.Count > 0)
+                        {
+                            if (updateReq.PreviewList?.Count > 0)
+                            {
+                                foreach(var previewInfo in updateReq.PreviewList)
+                                {
+                                    if (previewInfo.FileType == (int)UploadFileTypeEnum.JPG && previewInfo.Language == "zh-CN")
+                                    {
+                                        previewInfo.FileToken = string.Join(";", imgList);
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                updateReq.PreviewList = new List<PreviewDTO>();
+                                updateReq.PreviewList.Add(new PreviewDTO()
+                                {
+                                    FileToken = string.Join(";", imgList),
+                                    ThumbnailToken = "",
+                                    Language = "zh-CN",
+                                    FileType = (int)UploadFileTypeEnum.JPG
+                                });
+                            }
+                        }
                         var updateRes = await _vitalReportDBService.UpdateReportAsync(updateReq);
                         reportCode = reportInfo.Code;
                     }
@@ -8769,6 +8870,7 @@ namespace ReportService.Service
                 {
                     var thumbnailToken = string.Empty;
                     var imageUrlList = new List<string>();
+                    var imgList = new List<string>();
                     for (var i = 0; i < pathList.Count; i++)
                     {
                         var localPath = pathList[i];
@@ -8781,6 +8883,50 @@ namespace ReportService.Service
                         {
                             thumbnailToken = CreateThumbnailFile(localPath, 100, 30).Result;
                         }
+                        if (fileType == UploadFileTypeEnum.PDF && _isNeedImageReport)
+                        {
+                            var tempImgList = ReportPreviewHelper.GetImageReportPreviewByPDFFile(localPath);
+                            if (tempImgList?.Count > 0)
+                            {
+                                for (var j = 0; j < tempImgList.Count; j++)
+                                {
+                                    var localPathImg = tempImgList[j];
+                                    var imgUrl = UploadFileAsync(localPathImg, Path.GetFileName(localPathImg)).Result;
+                                    if (!string.IsNullOrWhiteSpace(imgUrl))
+                                    {
+                                        imgList.Add(imgUrl);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    var tempPreviewList = new List<PreviewDTO>();
+                    if (reportInfo.PreviewList?.Count > 0)
+                    {
+                        foreach(var previewInfo in reportInfo.PreviewList)
+                        {
+                            if (previewInfo.FileType == (int)UploadFileTypeEnum.JPG && previewInfo.Language == "zh-CN")
+                            {
+                                previewInfo.FileToken = string.Join(";", imgList);
+                            }
+                            tempPreviewList.Add(new PreviewDTO()
+                            {
+                                FileToken = previewInfo.FileToken,
+                                ThumbnailToken = previewInfo.ThumbnailToken,
+                                Language = previewInfo.Language,
+                                FileType = previewInfo.FileType,
+                            });
+                        }
+                    }
+                    else
+                    {
+                        tempPreviewList.Add(new PreviewDTO()
+                        {
+                            FileToken = string.Join(";", imgList),
+                            ThumbnailToken = thumbnailToken,
+                            Language = "zh-CN",
+                            FileType = (int)UploadFileTypeEnum.JPG
+                        });
                     }
                     var updateReq = new UpdateReportDBRequest()
                     {
@@ -8801,6 +8947,7 @@ namespace ReportService.Service
                         TemplateCode = reportInfo.TemplateCode,
                         PhysicalExamNumber = reportInfo.PhysicalExamNumber,
                         ExamCode = reportInfo.ExamCode,
+                        PreviewList = tempPreviewList
                     };
                     var updateRes = _vitalReportDBService.UpdateReportAsync(updateReq).Result;
                     var examRequst = new UpdateExamDBRequest()

+ 1 - 0
ReportService/Service/ReportService.cs

@@ -79,6 +79,7 @@ namespace ReportService.Service
         private readonly ReportPostersObserver _reportPosterObserver;
         private readonly HttpClient _httpClient = new HttpClient();
         private string _cloudServerUrl => EnvironmentConfigManager.GetParammeter<StringParameter>("Vital", "CloudServerUrl").Value;
+        private bool _isNeedImageReport => EnvironmentConfigManager.GetParammeter<BoolParameter>("Vital", "IsNeedImageReport").Value;
         public ReportService()
         {
             CacheMaintenance.Instance.Get<IReportPostersManager>().RegisterDBFunction(FindReportPosterByCode, FindReportPostersWithCodes);

+ 7 - 0
Vinno.vCloud.Report/Interfaces/IReportPreviewImagesGenerater.cs

@@ -7,5 +7,12 @@ namespace Vinno.vCloud.Report.Interfaces
     {
         IEnumerable<ImageInfo> GenerateReportPreviewImages(ReportInfo reportInfo);
         byte[] ConvertReportToPdf(ReportInfo reportInfo);
+
+        /// <summary>
+        /// 转换为image
+        /// </summary>
+        /// <param name="reportInfo"></param>
+        /// <param name="pdfSavePath"></param>
+        IEnumerable<ImageInfo> ConvertPDFReportToImage(string pdfPath);
     }
 }