diff --git a/src/Shentun.Pacs.Application/PacsBusiness/PacsBusinessAppService.cs b/src/Shentun.Pacs.Application/PacsBusiness/PacsBusinessAppService.cs index 7f7dc50..61e8c50 100644 --- a/src/Shentun.Pacs.Application/PacsBusiness/PacsBusinessAppService.cs +++ b/src/Shentun.Pacs.Application/PacsBusiness/PacsBusinessAppService.cs @@ -4,12 +4,14 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using NPOI.POIFS.Storage; +using NPOI.SS.Formula.Functions; using NPOI.Util; using NUglify.Helpers; using Shentun.Pacs.ColumnReferenceCodes; using Shentun.Pacs.CustomerOrgs; using Shentun.Pacs.Devices; using Shentun.Pacs.Enums; +using Shentun.Pacs.Migrations; using Shentun.Pacs.Models; using Shentun.Pacs.PatientRegisters; using Shentun.Pacs.Patients; @@ -1706,21 +1708,35 @@ namespace Shentun.Pacs.PacsBusiness string pictureFilename = $"{shareAddress}{item.PictureFilename.Replace(pacsRequestPath, "/").Replace("//", "/").Replace("/", @"\")}"; - int maxId = await oldDb.Ado.GetIntAsync("select isnull(max(check_picture_id),0) from check_picture"); - await oldDb.Ado.ExecuteCommandAsync("insert into check_picture(check_picture_id,patient_register_id,asbitem_id,device_id,picture_filename,print_flag," + - "local_store_flag,display_order,is_new_pacs) VALUES (@check_picture_id,@patient_register_id,@asbitem_id,@device_id,@picture_filename,@print_flag,@local_store_flag,@display_order,@is_new_pacs);", - new List() { - new SugarParameter("patient_register_id",registerCheckFirst.registerCheckAsbitem.OldPatientRegisterId), - new SugarParameter("asbitem_id",registerCheckFirst.registerCheckAsbitem.OldAsbitemId), - new SugarParameter("device_id",null), - new SugarParameter("picture_filename",pictureFilename), - new SugarParameter("print_flag",'Y'), - new SugarParameter("local_store_flag",'Y'), - new SugarParameter("display_order",registerCheckPictureList.IndexOf(item)+1), - new SugarParameter("is_new_pacs",'Y'), - new SugarParameter("check_picture_id",maxId+1), - }); + string maxIdString = oldDb.Ado.UseStoredProcedure().GetString("proc_getprimarykey", new List() { + new SugarParameter("@primarykey_builder_id","check_picture_id"), + new SugarParameter("@serial_no_len",10), + new SugarParameter("@null_date_string",'1') + + }); + + int maxId; + + bool isMaxId = int.TryParse(maxIdString, out maxId); + + if (isMaxId) + { + await oldDb.Ado.ExecuteCommandAsync("insert into check_picture(check_picture_id,patient_register_id,asbitem_id,device_id,picture_filename,print_flag," + + "local_store_flag,display_order,is_new_pacs) VALUES (@check_picture_id,@patient_register_id,@asbitem_id,@device_id,@picture_filename,@print_flag,@local_store_flag,@display_order,@is_new_pacs);", + new List() { + new SugarParameter("patient_register_id",registerCheckFirst.registerCheckAsbitem.OldPatientRegisterId), + new SugarParameter("asbitem_id",registerCheckFirst.registerCheckAsbitem.OldAsbitemId), + new SugarParameter("device_id",null), + new SugarParameter("picture_filename",pictureFilename), + new SugarParameter("print_flag",'Y'), + new SugarParameter("local_store_flag",'Y'), + new SugarParameter("display_order",registerCheckPictureList.IndexOf(item)+1), + new SugarParameter("is_new_pacs",'Y'), + new SugarParameter("check_picture_id",maxId) + }); + } + } #endregion @@ -1873,6 +1889,7 @@ namespace Shentun.Pacs.PacsBusiness } #endregion + /// /// 转换老系统性别