diff --git a/src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterQZTLUserIdInputDto.cs b/src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterQZTLUserIdInputDto.cs new file mode 100644 index 0000000..2e90492 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/TransToWebPeiss/SyncPatientRegisterQZTLUserIdInputDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.TransToWebPeiss +{ + public class SyncPatientRegisterQZTLUserIdInputDto + { + public List PatientRegisterNos { get; set; } = new List(); + } +} diff --git a/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs b/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs index 9fab772..ff05b69 100644 --- a/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs +++ b/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs @@ -37,6 +37,8 @@ using NPOI.HSSF.Record.Chart; using System.IdentityModel.Tokens.Jwt; using Shentun.Peis.PlugIns.Sms; using Shentun.Peis.ThirdBookingPushs; +using Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl; +using System.Data; namespace Shentun.Peis.TransToWebPeis { @@ -1637,5 +1639,133 @@ namespace Shentun.Peis.TransToWebPeis } } } + + + #region 临时处理青藏公司用户id关系 + + + /// + /// + /// + /// + [HttpPost("api/app/TransToWebPeis/SyncPatientRegisterQZTLUserId")] + public async Task SyncPatientRegisterQZTLUserIdAsync(SyncPatientRegisterQZTLUserIdInputDto input) + { + if (input.PatientRegisterNos.Any()) + { + + + SqlSugarClient peisTemp = new SqlSugarClient(new ConnectionConfig() + { + ConnectionString = "Host=10.1.12.140;Port=5432;Database=ShentunPeis0508;User ID=postgres;Password=st123;", + DbType = SqlSugar.DbType.PostgreSQL, + IsAutoCloseConnection = true + }); + + //SqlSugarClient peisTempOld = new SqlSugarClient(new ConnectionConfig() + //{ + // ConnectionString = "server=10.1.12.139;uid=sa;pwd=VMware6.0u2;database=mypeis;Encrypt=false;", + // DbType = SqlSugar.DbType.SqlServer, + // IsAutoCloseConnection = true + //}); + + + List oldList = new List(); + + var qztlDataList = await peisTemp.Ado.GetDataTableAsync($"select data from public.qztl_import_data "); + + //组合参数 + foreach (DataRow item in qztlDataList.Rows) + { + if (!string.IsNullOrWhiteSpace(item["data"].ToString())) + { + var oldData = JsonConvert.DeserializeObject(item["data"].ToString()); + + if (oldData != null && oldData.errorMsg == "OK") + { + + oldList.AddRange(oldData.plans); + } + } + } + + + + + //#region sqlserver 数据 + //var qztlDataOldList = await peisTempOld.Ado.GetDataTableAsync($"select data from qztl_import_data where create_date>'2023-01-01' "); + + ////组合参数 + //foreach (DataRow item in qztlDataOldList.Rows) + //{ + + + // if (!string.IsNullOrWhiteSpace(item["data"].ToString())) + // { + // string oldstr = item["data"].ToString().Replace("\"[", "[").Replace("]\"", "]").Replace("\\",""); + // var oldData = JsonConvert.DeserializeObject(oldstr); + + // if (oldData != null && oldData.errorMsg == "OK") + // { + + // oldList.AddRange(oldData.plans.Where(m => m.year == 2024).ToList()); + // } + // } + //} + //#endregion + + + foreach (var patientRegisterNo in input.PatientRegisterNos) + { + var patientRegisterList = await peisTemp.Ado.GetDataTableAsync($"select a.id,a.patient_name,b.id_no from public.patient_register as a " + + $"left join patient as b on a.patient_id=b.id where patient_register_no='{patientRegisterNo}' "); + + if (patientRegisterList.Rows.Count > 0) + { + string patientName = patientRegisterList.Rows[0]["patient_name"].ToString(); + string idNo = patientRegisterList.Rows[0]["id_no"].ToString(); + Guid patientRegisterId = Guid.Parse(patientRegisterList.Rows[0]["id"].ToString()); + + var isDT = oldList.Where(f => f.personName.Trim() == patientName.Trim() + && f.cardId.Trim().ToUpper() == idNo.Trim().ToUpper() + && f.year == 2024).Select(s => s.id).Distinct().ToList(); + + //if (isDT.Count == 0) + //{ + // var idNos = oldList.Where(f => f.personName.Trim() == patientName.Trim() && f.year == 2024).Select(s => s.cardId).Distinct().ToList(); + // _logger.LogInformation($"未找到数据:条码号=>{patientRegisterNo},姓名=>{patientName},体检系统身份证=>{idNo},青藏公司导入身份证=>{string.Join(",", idNos)}"); + // continue; + //} + + //if (isDT.Count > 1) + //{ + // _logger.LogInformation($"存在多条数据:条码号=>{patientRegisterNo},姓名=>{patientName},身份证=>{idNo}"); + // continue; + //} + + if (isDT.Count == 1) + { + + await peisTemp.Ado.ExecuteCommandAsync("update patient_register_exter set planuserid=@planuserid where patient_register_id=@patient_register_id ;", + new List() { + new SugarParameter("planuserid",isDT.First().ToString()), + new SugarParameter("patient_register_id",patientRegisterId) + + }); + _logger.LogInformation($"青藏公司数据处理:条码号=>{patientRegisterNo},姓名=>{patientName},身份证=>{idNo},更新青藏铁路用户id=>{isDT.First()}"); + } + + + // _logger.LogInformation($"青藏公司数据处理:条码号=>{patientRegisterNo},姓名=>{patientName},身份证=>{idNo},更新青藏铁路用户id=>{isDT.First()}"); + + + } + + } + } + } + + + #endregion } }