diff --git a/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs b/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs index f0a7c8f..59b4238 100644 --- a/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs +++ b/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.Extensions.DependencyModel; using Microsoft.Extensions.Logging; @@ -41,8 +42,8 @@ namespace Shentun.Peis.DataMigrations /// /// 基础数据处理 /// - //[Authorize] - //[RemoteService(false)] + [Authorize] + [RemoteService(false)] public class BaseDataHandleAppService : ApplicationService { @@ -2120,33 +2121,33 @@ namespace Shentun.Peis.DataMigrations } - /// - /// 处理异常 人员登记 异常后更新状态 - /// - /// - [RemoteService(false)] - public async Task HandPatientRegisterStatus() - { - List updateIds = new List(); - List newIds = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "patient_register").Select(s => s.OldKeyValue).ToList(); + ///// + ///// 处理异常 人员登记 异常后更新状态 + ///// + ///// + //[RemoteService(false)] + //public async Task HandPatientRegisterStatus() + //{ + // List updateIds = new List(); + // List newIds = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "patient_register").Select(s => s.OldKeyValue).ToList(); - var oldPatientRegisterList = await Db.Ado.GetDataTableAsync("select patient_register_id,is_dj from patient_register where is_dj is not null order by patient_register_id asc"); - if (oldPatientRegisterList.Rows.Count > 0) - { - foreach (DataRow row in oldPatientRegisterList.Rows) - { - if (!newIds.Contains(row["patient_register_id"].ToString())) - { - updateIds.Add(row["patient_register_id"].ToString()); - } - } + // var oldPatientRegisterList = await Db.Ado.GetDataTableAsync("select patient_register_id,is_dj from patient_register where is_dj is not null order by patient_register_id asc"); + // if (oldPatientRegisterList.Rows.Count > 0) + // { + // foreach (DataRow row in oldPatientRegisterList.Rows) + // { + // if (!newIds.Contains(row["patient_register_id"].ToString())) + // { + // updateIds.Add(row["patient_register_id"].ToString()); + // } + // } - if (updateIds.Any()) - { - await Db.Ado.ExecuteCommandAsync("update patient_register set is_dj=null where patient_register_id in (@ids) ", new { ids = updateIds }); - } - } - } + // if (updateIds.Any()) + // { + // await Db.Ado.ExecuteCommandAsync("update patient_register set is_dj=null where patient_register_id in (@ids) ", new { ids = updateIds }); + // } + // } + //} @@ -2376,7 +2377,10 @@ namespace Shentun.Peis.DataMigrations string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='register_check_asbitem'"); - var registerCheckAsbitemList = await _registerCheckAsbitemRepository.GetListAsync(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0); + var registerCheckAsbitemList = (await _registerCheckAsbitemRepository.GetQueryableAsync()).OrderBy(o => o.Id) + .Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).ToList(); + + if (registerCheckAsbitemList.Any()) { @@ -2461,6 +2465,7 @@ namespace Shentun.Peis.DataMigrations var registerCheckAsbitemList = (from registerCheckQuery in await _registerCheckRepository.GetQueryableAsync() join registerCheckAsbitemQuery in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheckQuery.Id equals registerCheckAsbitemQuery.RegisterCheckId + orderby registerCheckQuery.Id ascending where string.Compare(registerCheckQuery.Id.ToString(), nextKeyValue) > 0 select new { @@ -2725,54 +2730,217 @@ namespace Shentun.Peis.DataMigrations - /// - /// 迁移人员图片数据 - /// - /// - public async Task TransferPersonPhohoData(int handcount) - { - string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='patient_register_photo'"); + ///// + ///// 迁移人员图片数据 + ///// + ///// + //public async Task TransferPersonPhohoData(int handcount) + //{ + // string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='patient_register_photo'"); - var patientRegisterList = (await _patientRegisterRepository.GetQueryableAsync()).OrderBy(o => o.Id) - .Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).Take(handcount).ToList(); + // var patientRegisterList = (await _patientRegisterRepository.GetQueryableAsync()).OrderBy(o => o.Id) + // .Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).Take(handcount).ToList(); - if (patientRegisterList.Any()) - { + // if (patientRegisterList.Any()) + // { - foreach (var item in patientRegisterList) - { + // foreach (var item in patientRegisterList) + // { - using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) - { - #region 转换成老系统PatientRegisterId - string oldPatientRegisterId = (await _fieldComparisonRepository.GetQueryableAsync()) - .Where(m => m.TableName == "patient_register" && m.NewKeyValue == item.Id.ToString()).FirstOrDefault().OldKeyValue; - #endregion + // using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) + // { + // #region 转换成老系统PatientRegisterId + // string oldPatientRegisterId = (await _fieldComparisonRepository.GetQueryableAsync()) + // .Where(m => m.TableName == "patient_register" && m.NewKeyValue == item.Id.ToString()).FirstOrDefault().OldKeyValue; + // #endregion - var photograph = await Db.Ado.GetScalarAsync($"select photograph from patient_register where patient_register_id='{oldPatientRegisterId}' "); + // var photograph = await Db.Ado.GetScalarAsync($"select photograph from patient_register where patient_register_id='{oldPatientRegisterId}' "); - #region 上传图片,获取地址 + // #region 上传图片,获取地址 - if (photograph != null && !string.IsNullOrEmpty(photograph.ToString())) - { - string photo = UpLoadImg(item.Id, item.CreationTime, (byte[])photograph); + // if (photograph != null && !string.IsNullOrEmpty(photograph.ToString())) + // { + // string photo = UpLoadImg(item.Id, item.CreationTime, (byte[])photograph); - item.Photo = photo; + // item.Photo = photo; - await _patientRegisterRepository.UpdateAsync(item); + // await _patientRegisterRepository.UpdateAsync(item); - } + // } - #endregion + // #endregion - await uow.CompleteAsync(); + // await uow.CompleteAsync(); - await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.Id}',addtime=getdate(),handlecount+=1 where tablename='patient_register_photo' "); - } - } - } - } + // await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.Id}',addtime=getdate(),handlecount+=1 where tablename='patient_register_photo' "); + // } + // } + // } + //} + + + + ///// + ///// 纠正登记项目明细数据 + ///// + ///// + //public async Task CorrectRegisterCheckItemData() + //{ + // string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='register_check_asbitem_2'"); + + // //var registerCheckAsbitemList = (await _registerCheckAsbitemRepository.GetQueryableAsync()).OrderBy(o => o.Id) + // // .Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).ToList(); + // var registerCheckAsbitemList = (from registerCheckQuery in (await _registerCheckRepository.GetQueryableAsync()).Include(x => x.RegisterCheckItems) + // join registerCheckAsbitemQuery in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheckQuery.Id equals registerCheckAsbitemQuery.RegisterCheckId + // orderby registerCheckQuery.Id ascending + // where (registerCheckQuery.RegisterCheckItems.Count == 0 && string.Compare(registerCheckQuery.Id.ToString(), nextKeyValue) > 0) + // select registerCheckAsbitemQuery).ToList(); + + + + // if (registerCheckAsbitemList.Any()) + // { + + // foreach (var item in registerCheckAsbitemList) + // { + + // using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) + // { + + // List registerCheckItemInsert = new List(); + + // #region 转换成老系统PatientRegisterId + // string oldPatientRegisterId = (await _fieldComparisonRepository.GetQueryableAsync()) + // .Where(m => m.TableName == "patient_register" && m.NewKeyValue == item.PatientRegisterId.ToString()).FirstOrDefault().OldKeyValue; + // #endregion + + // #region 转换成老系统AsbitemId + // string oldAsbitemId = (await _fieldComparisonRepository.GetQueryableAsync()) + // .Where(m => m.TableName == "asbitem" && m.NewKeyValue == item.AsbitemId.ToString()).FirstOrDefault().OldKeyValue; + // #endregion + + // var oldRegisterCheckItemList = await Db.Ado.GetDataTableAsync($"select * from register_item where patient_register_id='{oldPatientRegisterId}' and asbitem_id='{oldAsbitemId}'"); + + // if (oldRegisterCheckItemList.Rows.Count > 0) + // { + + // foreach (DataRow row in oldRegisterCheckItemList.Rows) + // { + // #region 转换项目ID 老转新 + // Guid newItemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()) + // .Where(m => m.TableName == "item" && m.OldKeyValue == row["item_id"].ToString()).FirstOrDefault().NewKeyValue); + + // #endregion + + + // var data = new RegisterCheckItem + // { + // CheckDate = string.IsNullOrEmpty(row["check_date"].ToString()) ? null : Convert.ToDateTime(row["check_date"].ToString()), + // CriticalValue = null, + // CheckDoctorName = row["check_doctor"].ToString().Trim(), + // CriticalRangeValue = null, + // ItemId = newItemId, + // ReferenceRangeValue = row["reference_range_value"].ToString(), + // RegisterCheckId = item.RegisterCheckId, + // Result = row["result"].ToString(), + // ResultStatusId = _registerCheckItemManager.GetResultStatusId(row["result"].ToString(), row["reference_range_value"].ToString()), + // Unit = row["Unit"].ToString() + // }; + + // registerCheckItemInsert.Add(data); + // } + + // } + + // if (registerCheckItemInsert.Any()) + // await _registerCheckItemRepository.InsertManyAsync(registerCheckItemInsert); + + + // await uow.CompleteAsync(); + + + // await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.Id}',addtime=getdate(),handlecount+=1 where tablename='register_check_asbitem_2' "); + + // } + // } + + + + // } + //} + + + ///// + ///// 纠正医生小结数据 + ///// + ///// + //public async Task CorrectRegisterCheckSummaryData() + //{ + // string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='register_check_summary_2'"); + + // //var registerCheckAsbitemList = (from registerCheckQuery in await _registerCheckRepository.GetQueryableAsync() + // // join registerCheckAsbitemQuery in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheckQuery.Id equals registerCheckAsbitemQuery.RegisterCheckId + // // orderby registerCheckQuery.Id ascending + // // where string.Compare(registerCheckQuery.Id.ToString(), nextKeyValue) > 0 + // // select new + // // { + // // PatientRegisterId = registerCheckQuery.PatientRegisterId, + // // RegisterCheckId = registerCheckQuery.Id, + // // AsbitemId = registerCheckAsbitemQuery.AsbitemId + // // }).ToList(); + + // var registerCheckAsbitemList = (from registerCheckQuery in (await _registerCheckRepository.GetQueryableAsync()).Include(x => x.RegisterCheckSummaries).AsQueryable() + // join registerCheckAsbitemQuery in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheckQuery.Id equals registerCheckAsbitemQuery.RegisterCheckId + // orderby registerCheckQuery.Id ascending + // where (registerCheckQuery.RegisterCheckSummaries.Count == 0 && string.Compare(registerCheckQuery.Id.ToString(), nextKeyValue) > 0) + // select new + // { + // PatientRegisterId = registerCheckQuery.PatientRegisterId, + // RegisterCheckId = registerCheckQuery.Id, + // AsbitemId = registerCheckAsbitemQuery.AsbitemId + // }).ToList(); + // if (registerCheckAsbitemList.Any()) + // { + + // foreach (var item in registerCheckAsbitemList) + // { + // using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) + // { + // #region 转换成老系统PatientRegisterId + // string oldPatientRegisterId = (await _fieldComparisonRepository.GetQueryableAsync()) + // .Where(m => m.TableName == "patient_register" && m.NewKeyValue == item.PatientRegisterId.ToString()).FirstOrDefault().OldKeyValue; + // #endregion + + // #region 转换成老系统AsbitemId + // string oldAsbitemId = (await _fieldComparisonRepository.GetQueryableAsync()) + // .Where(m => m.TableName == "asbitem" && m.NewKeyValue == item.AsbitemId.ToString()).FirstOrDefault().OldKeyValue; + // #endregion + + // var oldSummary = await Db.Ado.GetStringAsync($"select summary from register_asbitem where patient_register_id='{oldPatientRegisterId}' and asbitem_id='{oldAsbitemId}'"); + // if (!string.IsNullOrWhiteSpace(oldSummary)) + // { + // var data = new RegisterCheckSummary + // { + // RegisterCheckId = item.RegisterCheckId, + // DisplayOrder = 1, + // Summary = oldSummary, + // SummaryFlag = '0' + // }; + + + // await _registerCheckSummaryRepository.InsertAsync(data); + + // await uow.CompleteAsync(); + // } + // await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.RegisterCheckId}',addtime=getdate(),handlecount+=1 where tablename='register_check_summary_2' "); + // } + // } + + + + // } + //} #endregion diff --git a/src/Shentun.Peis.HttpApi.Host/appsettings.json b/src/Shentun.Peis.HttpApi.Host/appsettings.json index a1ce9e9..d697370 100644 --- a/src/Shentun.Peis.HttpApi.Host/appsettings.json +++ b/src/Shentun.Peis.HttpApi.Host/appsettings.json @@ -8,6 +8,7 @@ "ConnectionStrings": { "Default": "Host=140.143.162.39;Port=5432;Database=ShentunPeis070703;User ID=postgres;Password=shentun123;" //"Default": "Host=localhost;Port=5432;Database=ShentunPeis1218;User ID=postgres;Password=wxd123;" + //"Default": "Host=10.1.12.140;Port=5432;Database=ShentunPeis;User ID=postgres;Password=st123;" }, "AuthServer": { "Authority": "http://localhost:9530", @@ -32,6 +33,7 @@ "RequestPath": "/CheckPictureImg", "Alias": "CheckPictureImg" }, + //"AdminId": "3a11fe49-5719-0e9e-dd44-0c4aff0900b0", "AdminId": "3a0c4180-107c-0c89-b25b-0bd34666dcec", "PeisReportPdfPath": "E:\\mypeis\\PeisReportPdf\\" } \ No newline at end of file