Jeremy 1 жил өмнө
parent
commit
7b0be5c3e2

+ 3 - 0
Tools/Flyinsono.DBCopy.Tool/AutoMapperProfile.cs

@@ -33,6 +33,9 @@ namespace Flyinsono.DBCopy.Tool
             CreateMap<SubjectItem, SubjectItemView>().ReverseMap();
             CreateMap<ExamScores, ExamScoreView>().ReverseMap();
             CreateMap<MyExamAnswer, MyExamAnswerView>().ReverseMap();
+            CreateMap<ImageInfo, ReportImageInfo>().ReverseMap();
+            CreateMap<CustomLabel, CustomLabelView>().ReverseMap();
+            CreateMap<QualityControlData, QualityControlDataView>().ReverseMap();
 
         }
     }

+ 66 - 0
Tools/Flyinsono.DBCopy.Tool/Entities/CustomLabel.cs

@@ -0,0 +1,66 @@
+using SharpCompress.Common;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Flyinsono.DBCopy.Tool.Entities
+{
+    /// <summary>
+    /// 自定义标签
+    /// </summary>
+    internal class CustomLabel
+    {
+        public string Id { get; private set; }
+
+        public DateTime CreateTime { get; set; } = DateTime.MinValue;
+
+        public DateTime UpdateTime { get; set; } = DateTime.MinValue;
+
+        public bool IsDeleted { get; set; }
+        /// <summary>
+        /// Name
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Code
+        /// </summary>
+        public string Code { get; set; }
+
+        /// <summary>
+        /// Description
+        /// </summary>
+        public string Description { get; set; }
+
+        /// <summary>
+        /// Father Code
+        /// </summary>
+        public string FatherCode { get; set; }
+
+        /// <summary>
+        /// Label Type
+        /// </summary>
+        public CustomLabelType LabelType { get; set; }
+
+        /// <summary>
+        /// Is show
+        /// </summary>
+        public bool IsShow { get; set; }
+
+        /// <summary>
+        /// user id array
+        /// </summary>
+        public List<string> UserIds { get; set; } = new List<string>();
+    }
+
+    /// <summary>
+    /// Label type enum
+    /// </summary>
+    public enum CustomLabelType
+    {
+        Group,
+        Label
+    }
+}

+ 44 - 8
Tools/Flyinsono.DBCopy.Tool/Service/MigrateService.cs

@@ -54,6 +54,7 @@ namespace Flyinsono.DBCopy.Tool.Service
         private ExamScoreDBRepository _examScoreDBRepository;
         private ReportTemplateDBRepository _reportTemplateDBRepository;
         private ReportInfoResultDBRepository _reportInfoResultDBRepository;
+        private CustomLabelDBRepository _customLabelDBRepository;
 
         public MigrateService(string dcServiceUrl)
         {
@@ -81,6 +82,7 @@ namespace Flyinsono.DBCopy.Tool.Service
             _reportTemplateDBRepository = new ReportTemplateDBRepository();
             _adminDBRepository = new AdminDBRepository();
             _reportInfoResultDBRepository = new ReportInfoResultDBRepository();
+            _customLabelDBRepository = new CustomLabelDBRepository();
         }
 
         public async Task WriteMigrateStaticAsync()
@@ -942,16 +944,50 @@ namespace Flyinsono.DBCopy.Tool.Service
         {
             try
             {
+                var customLabelIds = reports.SelectMany(x => x.CustomLabels ?? new List<string>()).Distinct().ToList();
+                var customerLabels = _customLabelDBRepository.GetCustomLabelByCodes(customLabelIds);
+
                 var reportInfos = new List<ReportInfoResultDTO>();
-                foreach (var video in reports)
+                foreach (var report in reports)
                 {
-                    var videoInfo = new ReportInfoResultDTO
+                    var reportInfo = new ReportInfoResultDTO
                     {
-                        Code = video.Id,
-                        CreateTime = video.CreateTime,
-                        UpdateTime = video.UpdateTime,
+                        Code = report.Id,
+                        CreateTime = report.CreateTime,
+                        UpdateTime = report.UpdateTime,
+                        ReportTemplateJson = report.Template,
+                        ElementCollectionJson = Newtonsoft.Json.JsonConvert.SerializeObject(report.ElementCollection),
+                        MeasureElementCollectionJson = Newtonsoft.Json.JsonConvert.SerializeObject(report.MeasureElementCollection),
+                        ReportUserCode = report.User?._id,
+                        ReportUserName = report.User?.Name,
+                        RecordCode = report.RecordId,
+                        PatientPerfPhysician = report.PatientPerfPhysician,
+                        PatientRefPhysician = report.PatientRefPhysician,
+                        PatientName = report.PatientName,
+                        PreviewImages = report.PreviewImages.MappingTo<List<WingInterfaceLibrary.DTO.DataCenter.ReportImageInfo>>(),
+                        CustomLabels = new List<CustomLabelView>(),
+                        ReportOrgan = (DiagnosisOrganEnum)report.Organ,
+                        QualifiedState = (WingInterfaceLibrary.Enum.QualifiedState)report.QualifiedState,
+                        QualityType = (WingInterfaceLibrary.Enum.QualityType)report.QualityType,
+                        ReportPreviewPdf = GetFileUrl(report.ReportPreviewPdf),
+                        QualityControlDatas = new List<QualityControlDataView>(),
                     };
-                    reportInfos.Add(videoInfo);
+                    if (report.CustomLabels != null && report.CustomLabels.Any())
+                    {
+                        foreach (var item in report.CustomLabels)
+                        {
+                            var customLabel = customerLabels.FirstOrDefault(x => x.Code == item);
+                            if (customLabel != null)
+                            {
+                                reportInfo.CustomLabels.Add(customLabel.MappingTo<CustomLabelView>());
+                            }
+                        }
+                    }
+                    if (report.QualityControlDatas != null && report.QualityControlDatas.Any())
+                    {
+                        reportInfo.QualityControlDatas = report.QualityControlDatas.MappingTo<List<QualityControlDataView>>();
+                    }
+                    reportInfos.Add(reportInfo);
                 }
                 var request = new ReceiveReportInfosRequest
                 {
@@ -1197,11 +1233,11 @@ namespace Flyinsono.DBCopy.Tool.Service
                         CarotidScanType = (CarotidScanTypeEnum)carotid3dModelData.CarotidScanType,
                         MeasureImageFiles = new List<MeasureImageFileDTO>()
                     };
-                    if (!string.IsNullOrWhiteSpace(carotid3dModelData.CarotidAIMeasureImageToken)) 
+                    if (!string.IsNullOrWhiteSpace(carotid3dModelData.CarotidAIMeasureImageToken))
                     {
                         string[] keyValuePairs = carotid3dModelData.CarotidAIMeasureImageToken.Split(';');
                         foreach (string keyValuePair in keyValuePairs)
-                        { 
+                        {
                             string[] parts = keyValuePair.Split('=');
                             if (parts.Length != 2) continue;
                             if (Enum.TryParse(parts[0], out CarotidAIImageTypeEnum imageType))

+ 24 - 0
Tools/Flyinsono.DBCopy.Tool/Service/Repositories/CustomLabelDBRepository.cs

@@ -0,0 +1,24 @@
+using Flyinsono.DBCopy.Tool.Entities;
+using Flyinsono.DBCopy.Tool.Utilities;
+using MongoDB.Driver;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using WingServerCommon.Mapper;
+
+namespace Flyinsono.DBCopy.Tool.Service.Repositories
+{
+    internal class CustomLabelDBRepository
+    {
+        public IList<CustomLabel> GetCustomLabelByCodes(IList<string> labelCodes)
+        {
+            var builder = Builders<CustomLabel>.Filter;
+            var filter = builder.Where(x => labelCodes.Contains(x.Code));
+            var entities = MongoDbClientSingle.Instance.CustomLabels.Find(filter)?.ToList() ?? new List<CustomLabel>();
+            return entities;
+        }
+    }
+}

+ 2 - 0
Tools/Flyinsono.DBCopy.Tool/Utilities/MongoDbClient.cs

@@ -205,6 +205,7 @@ namespace Flyinsono.DBCopy.Tool.Utilities
         public IMongoCollection<UserGroup> UserGroups { get; private set; }
         public IMongoCollection<UltrasonicClass> UltrasonicClasses { get; private set; }
         public IMongoCollection<ReportTemplates> ReportTemplates { get; private set; }
+        public IMongoCollection<CustomLabel> CustomLabels { get; private set; }
         private void RegisterEntities()
         {
             Admins = GetCollection<Admins>("Admins");
@@ -256,6 +257,7 @@ namespace Flyinsono.DBCopy.Tool.Utilities
             UserGroups = GetCollection<UserGroup>("UserGroups");
             UltrasonicClasses = GetCollection<UltrasonicClass>("UltrasonicClasses");
             ReportTemplates = GetCollection<ReportTemplates>("ReportTemplates");
+            CustomLabels = GetCollection<CustomLabel>("CustomLabels");
         }