DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
efd1067ecf
  1. 279
      src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs
  2. 4
      src/Shentun.Peis.DbMigrator/appsettings.json
  3. 5
      src/Shentun.Peis.Domain/CustomerOrgGroups/CustomerOrgGroup.cs
  4. 2
      src/Shentun.Peis.Domain/Patients/Patient.cs
  5. 13768
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240420050902_init20240420002.Designer.cs
  6. 136
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240420050902_init20240420002.cs
  7. 158
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240420092428_init20240420003.cs
  8. 8
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240421094110_init20240421001.Designer.cs
  9. 39
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240421094110_init20240421001.cs
  10. 37
      src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs
  11. 18
      test/Shentun.Peis.Application.Tests/ApiWorkTest.cs
  12. 58
      test/Shentun.Peis.Application.Tests/BaseDataHandleTest.cs
  13. 6
      test/Shentun.Peis.Application.Tests/GuideTypeAppServiceTest.cs
  14. 2
      test/Shentun.Peis.Application.Tests/SysParmAppServiceTest.cs
  15. 4
      test/Shentun.Peis.Domain.Tests/CacheServiceTest.cs
  16. 6
      test/Shentun.Peis.Domain.Tests/GuideTypeManagerTest.cs
  17. 4
      test/Shentun.Peis.EntityFrameworkCore.Tests/EntityFrameworkCore/PeisEntityFrameworkCoreTestModule.cs

279
src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.Extensions.DependencyModel;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NPOI.DDF;
using Shentun.Peis.CustomerOrgs;
@ -21,12 +22,14 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading;
using System.Threading.Tasks;
using TencentCloud.Sqlserver.V20180328.Models;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Volo.Abp.Uow;
using Volo.Abp.Users;
using Xceed.Document.NET;
@ -55,14 +58,18 @@ namespace Shentun.Peis.DataMigrations
});
////默认指引类别ID
//private readonly Guid defaultGuidTypeId = Guid.Parse("3a120284-df18-7b36-4b12-0423a7d5c1c6");
////默认体检报告类别ID
//private readonly Guid defaultMedicalReportTypeId = Guid.Parse("3a120285-65dd-e7da-c923-6b503ab9e1d9");
//默认指引类别ID
private readonly Guid defaultGuidTypeId = Guid.Parse("3a120284-df18-7b36-4b12-0423a7d5c1c6");
private readonly char defaultGuidTypeId = '0';
//默认体检报告类别ID
private readonly Guid defaultMedicalReportTypeId = Guid.Parse("3a120285-65dd-e7da-c923-6b503ab9e1d9");
private readonly char defaultMedicalReportTypeId = '0';
//默认体检中心
private readonly Guid defaultMedicalCenterId = Guid.Parse("0de5b78a-731d-4f80-b262-655ebbf04581");
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IRepository<DeviceType, Guid> _deviceTypeRepository;
private readonly IRepository<ItemType, Guid> _itemTypeRepository;
private readonly ItemTypeManager _itemTypeManager;
@ -87,6 +94,14 @@ namespace Shentun.Peis.DataMigrations
private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository;
private readonly CustomerOrgManager _customerOrgManager;
private readonly IRepository<CustomerOrgRegister, Guid> _customerOrgRegisterRepository;
private readonly IRepository<CustomerOrgGroup, Guid> _customerOrgGroupRepository;
private readonly IRepository<CustomerOrgGroupDetail> _customerOrgGroupDetailRepository;
private readonly IRepository<Patient, Guid> _patientRepository;
private readonly IRepository<Nation> _nationRepository;
private readonly ILogger<BaseDataHandleAppService> _logger;
private Dictionary<string, string> veryPatientNo = new Dictionary<string, string>();
public BaseDataHandleAppService(
IRepository<DeviceType, Guid> deviceTypeRepository,
@ -112,7 +127,13 @@ namespace Shentun.Peis.DataMigrations
IRepository<MenuInfo, Guid> menuInfoRepository,
IRepository<CustomerOrg, Guid> customerOrgRepository,
CustomerOrgManager customerOrgManager,
IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository)
IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository,
IRepository<CustomerOrgGroup, Guid> customerOrgGroupRepository,
IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository,
IRepository<Nation> nationRepository,
IRepository<Patient, Guid> patientRepository,
IUnitOfWorkManager unitOfWorkManager,
ILogger<BaseDataHandleAppService> logger)
{
_deviceTypeRepository = deviceTypeRepository;
_itemTypeRepository = itemTypeRepository;
@ -138,6 +159,12 @@ namespace Shentun.Peis.DataMigrations
_customerOrgRepository = customerOrgRepository;
_customerOrgManager = customerOrgManager;
_customerOrgRegisterRepository = customerOrgRegisterRepository;
_customerOrgGroupRepository = customerOrgGroupRepository;
_customerOrgGroupDetailRepository = customerOrgGroupDetailRepository;
_nationRepository = nationRepository;
_patientRepository = patientRepository;
_unitOfWorkManager = unitOfWorkManager;
_logger = logger;
}
@ -1580,6 +1607,228 @@ namespace Shentun.Peis.DataMigrations
}
}
/// <summary>
/// 迁移单位分组
/// </summary>
/// <returns></returns>
public async Task TransferCustomerOrgGroupData()
{
var count = await _customerOrgGroupRepository.GetCountAsync();
if (count == 0)
{
List<CustomerOrgGroup> dataList = new List<CustomerOrgGroup>();
var oldCustomerOrgGroupList = await Db.Ado.GetDataTableAsync("select * from org_group order by display_order asc");
if (oldCustomerOrgGroupList.Rows.Count > 0)
{
List<FieldComparison> fieldComparisons = new List<FieldComparison>();
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
List<CustomerOrgRegister> customerOrgRegisterList = await _customerOrgRegisterRepository.GetListAsync();
foreach (DataRow row in oldCustomerOrgGroupList.Rows)
{
//新系统单位ID
Guid customerOrgId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == row["org_id"].ToString()).FirstOrDefault().NewKeyValue);
Guid customerOrgRegisterId = customerOrgRegisterList.Where(m => m.CustomerOrgId == customerOrgId
&& m.MedicalTimes == (short)Convert.ToInt32(row["org_medical_times"].ToString())).FirstOrDefault().Id;
Guid customerOrgGroupId = GuidGenerator.Create();
var data = new CustomerOrgGroup(customerOrgGroupId)
{
AgeLowerLimit = (short)Convert.ToInt32(row["age_lower_limit"].ToString()),
AgeUpperLimit = (short)Convert.ToInt32(row["age_upper_limit"].ToString()),
CustomerOrgRegisterId = customerOrgRegisterId,
DisplayName = row["org_group_name"].ToString(),
DisplayOrder = oldCustomerOrgGroupList.Rows.IndexOf(row) + 1,
ForSexId = ConvertForSex(row["for_sex_id"].ToString()),
JobPost = row["job_post"].ToString(),
JobTitle = row["job_title"].ToString(),
MaritalStatusId = Convert.ToChar(row["marital_status_id"].ToString()),
Price = Convert.ToDecimal(row["price"].ToString()),
Remark = row["remark"].ToString()
};
dataList.Add(data);
fieldComparisons.Add(new FieldComparison
{
FieldName = "id",
NewKeyValue = customerOrgGroupId.ToString(),
OldKeyValue = row["org_group_id"].ToString(),
TableName = "customer_org_group"
});
}
if (dataList.Any())
await _customerOrgGroupRepository.InsertManyAsync(dataList);
if (fieldComparisons.Any())
await _fieldComparisonRepository.InsertManyAsync(fieldComparisons);
}
}
}
/// <summary>
/// 迁移民族数据 民族对应
/// </summary>
/// <returns></returns>
public async Task TransferNationData()
{
var newNationList = await _nationRepository.GetListAsync();
var oldNationList = await Db.Ado.GetDataTableAsync("select * from nation");
if (oldNationList.Rows.Count > 0)
{
List<FieldComparison> fieldComparisons = new List<FieldComparison>();
foreach (DataRow row in oldNationList.Rows)
{
string oldName = row["nation_name"].ToString(); //老系统名称
var newNationEnt = newNationList.Where(m => m.DisplayName.Contains(oldName)).FirstOrDefault();
if (newNationEnt != null)
{
fieldComparisons.Add(new FieldComparison
{
FieldName = "id",
NewKeyValue = newNationEnt.Id.ToString(),
OldKeyValue = row["nation_id"].ToString(),
TableName = "nation"
});
}
}
if (fieldComparisons.Any())
await _fieldComparisonRepository.InsertManyAsync(fieldComparisons);
}
}
#region 人员登记
/// <summary>
/// 迁移档案数据
/// </summary>
/// <returns></returns>
public async Task<bool> TransferPatientData()
{
List<Patient> dataList = new List<Patient>();
List<string> oldPatientNos = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "patient")
.Select(s => s.OldKeyValue).ToList();
//var oldCustomerOrgGroupList = await Db.Ado.GetDataTableAsync("select top 200 * from patient_register where patient_id not in (@ids) order by patient_register_id asc",
// new { ids = oldPatientNos });
var oldCustomerOrgGroupList = await Db.Ado.GetDataTableAsync("select top 500 patient_id,nation_id,address," +
"birth_date,name,email,id_card_no,marital_status_id,mobile_telephone,patient_password,postalcode,telephone,sex_id " +
"from patient_register where is_hand is null order by patient_register_id asc");
List<string> tempPatientNos=new List<string>();
if (oldCustomerOrgGroupList.Rows.Count > 0)
{
List<FieldComparison> fieldComparisons = new List<FieldComparison>();
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "nation");
foreach (DataRow row in oldCustomerOrgGroupList.Rows)
{
tempPatientNos.Add(row["patient_id"].ToString());
if (!veryPatientNo.ContainsKey(row["patient_id"].ToString()) && !oldPatientNos.Contains(row["patient_id"].ToString()))
{
string nationId = null;
if (!string.IsNullOrWhiteSpace(row["nation_id"].ToString()))
{
nationId = fieldComparisonList.Where(m => m.OldKeyValue == row["nation_id"].ToString()).FirstOrDefault().NewKeyValue;
}
Guid PatientId = GuidGenerator.Create(); //档案ID
var data = new Patient(PatientId)
{
Address = row["address"].ToString(),
BirthDate = string.IsNullOrEmpty(row["birth_date"].ToString()) ? null : Convert.ToDateTime(row["birth_date"].ToString()),
BirthPlaceId = null,
DisplayName = row["name"].ToString(),
Email = row["email"].ToString(),
IdNo = row["id_card_no"].ToString(),
MaritalStatusId = Convert.ToChar(row["marital_status_id"].ToString()),
MedicalCenterId = defaultMedicalCenterId,
MobileTelephone = row["mobile_telephone"].ToString(),
NationId = nationId,
PatientNo = row["patient_id"].ToString(),
PatientPassword = row["patient_password"].ToString(),
PostalCode = row["postalcode"].ToString(),
SexId = ConvertSex(row["sex_id"].ToString()),
SimpleCode = LanguageConverter.GetPYSimpleCode(row["name"].ToString()),
Telephone = row["telephone"].ToString()
};
dataList.Add(data);
fieldComparisons.Add(new FieldComparison
{
FieldName = "id",
NewKeyValue = PatientId.ToString(),
OldKeyValue = row["patient_id"].ToString(),
TableName = "patient"
});
#region 增加标识
veryPatientNo.Add(row["patient_id"].ToString(), row["patient_id"].ToString());
#endregion
}
}
if (dataList.Any())
await _patientRepository.InsertManyAsync(dataList);
if (fieldComparisons.Any())
await _fieldComparisonRepository.InsertManyAsync(fieldComparisons);
#region 修改状态
Thread.Sleep(100);
await Db.Ado.ExecuteCommandAsync("update patient_register set is_hand='Y' where patient_id in (@ids) ", new { ids = tempPatientNos });
#endregion
_logger.LogInformation($"当前时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},迁移数据{dataList.Count}");
return true;
}
else
{
return false;
}
}
//public async Task TransferPatientRegisterData()
//{
//}
#endregion
private void LoadDLL()
{
// 定义dll文件夹路径
@ -1629,6 +1878,28 @@ namespace Shentun.Peis.DataMigrations
return 'A';
}
}
/// <summary>
/// 转换老系统性别
/// </summary>
/// <param name="SexId"></param>
/// <returns></returns>
private char ConvertSex(string SexId)
{
if (SexId == "0")
{
return 'M';
}
else if (SexId == "1")
{
return 'F';
}
else
{
return 'U';
}
}
}

4
src/Shentun.Peis.DbMigrator/appsettings.json

@ -1,9 +1,9 @@
{
"ConnectionStrings": {
"Default": "Host=140.143.162.39;Port=5432;Database=ShentunPeis070703;User ID=postgres;Password=shentun123;"
//"Default": "Host=140.143.162.39;Port=5432;Database=ShentunPeis070703;User ID=postgres;Password=shentun123;"
//"Default": "Host=140.143.162.39;Port=5432;Database=ShentunPeisTemp;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;"
"Default": "Host=10.1.12.140;Port=5432;Database=ShentunPeis;User ID=postgres;Password=st123;"
},
"OpenIddict": {
"Applications": {

5
src/Shentun.Peis.Domain/CustomerOrgGroups/CustomerOrgGroup.cs

@ -15,6 +15,9 @@ namespace Shentun.Peis.Models
[Index(nameof(CustomerOrgRegisterId), Name = "fki_fk_customer_org_group_register")]
public class CustomerOrgGroup : AuditedEntity<Guid>, IDisplayName, IDisplayOrder, IHasConcurrencyStamp
{
public CustomerOrgGroup(Guid id) : base(id) { }
public CustomerOrgGroup()
{
CustomerOrgGroupDetails = new HashSet<CustomerOrgGroupDetail>();
@ -25,7 +28,7 @@ namespace Shentun.Peis.Models
/// 分组名称
/// </summary>
[Column("display_name")]
[StringLength(20)]
[StringLength(50)]
public string DisplayName { get; set; } = null!;
/// <summary>
/// 价格

2
src/Shentun.Peis.Domain/Patients/Patient.cs

@ -106,7 +106,7 @@ namespace Shentun.Peis.Models
/// 手机号
/// </summary>
[Column("mobile_telephone")]
[StringLength(20)]
[StringLength(50)]
public string? MobileTelephone { get; set; }
/// <summary>
/// 地址

13768
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240420050902_init20240420002.Designer.cs
File diff suppressed because it is too large
View File

136
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240420050902_init20240420002.cs

@ -1,136 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.Peis.Migrations
{
public partial class init20240420002 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "column_reference_plug_ins",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", fixedLength: true, nullable: false, comment: "编号"),
display_name = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false, comment: "名称"),
dll_name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, comment: "Dll名称"),
parm_value = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true, comment: "配置参数"),
concurrency_stamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true),
creation_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
creator_id = table.Column<Guid>(type: "uuid", nullable: false),
last_modification_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
last_modifier_id = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_column_reference_plug_ins", x => x.id);
},
comment: "字段对照插件表");
migrationBuilder.CreateTable(
name: "column_reference",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", fixedLength: true, nullable: false, comment: "编号"),
display_name = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false, comment: "名称"),
column_reference_plug_ins_id = table.Column<Guid>(type: "uuid", nullable: false, comment: "插件ID"),
concurrency_stamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true),
creation_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
creator_id = table.Column<Guid>(type: "uuid", nullable: false),
last_modification_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
last_modifier_id = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_column_reference", x => x.id);
table.ForeignKey(
name: "fk_columnreference_columnreferenceplugins",
column: x => x.column_reference_plug_ins_id,
principalTable: "column_reference_plug_ins",
principalColumn: "id");
},
comment: "字段对照主表");
migrationBuilder.CreateTable(
name: "column_reference_code",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", fixedLength: true, nullable: false, comment: "编号"),
column_reference_id = table.Column<Guid>(type: "uuid", nullable: false, comment: "字段对照主表ID"),
code_value = table.Column<string>(type: "text", nullable: false, comment: "本系统编码值"),
filter_code_value = table.Column<string>(type: "text", nullable: true, comment: "过滤编码值"),
concurrency_stamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true),
creation_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
creator_id = table.Column<Guid>(type: "uuid", nullable: false),
last_modification_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
last_modifier_id = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_column_reference_code", x => x.id);
table.ForeignKey(
name: "fk_columnreferencecode_columnreference",
column: x => x.column_reference_id,
principalTable: "column_reference",
principalColumn: "id");
},
comment: "字段对照本系统编码表");
migrationBuilder.CreateTable(
name: "column_reference_interface",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", fixedLength: true, nullable: false, comment: "编号"),
column_reference_code_id = table.Column<Guid>(type: "uuid", nullable: false, comment: "字段对照本系统编码表ID"),
interface_code_value = table.Column<string>(type: "text", nullable: false, comment: "第三方系统编码值"),
concurrency_stamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true),
creation_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
creator_id = table.Column<Guid>(type: "uuid", nullable: false),
last_modification_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
last_modifier_id = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_column_reference_interface", x => x.id);
table.ForeignKey(
name: "fk_columnreferenceinterface_columnreferencecode",
column: x => x.column_reference_code_id,
principalTable: "column_reference_code",
principalColumn: "id");
},
comment: "字段对照第三方系统编码表");
migrationBuilder.CreateIndex(
name: "IX_column_reference_column_reference_plug_ins_id",
table: "column_reference",
column: "column_reference_plug_ins_id");
migrationBuilder.CreateIndex(
name: "IX_column_reference_code_column_reference_id",
table: "column_reference_code",
column: "column_reference_id");
migrationBuilder.CreateIndex(
name: "IX_column_reference_interface_column_reference_code_id",
table: "column_reference_interface",
column: "column_reference_code_id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "column_reference_interface");
migrationBuilder.DropTable(
name: "column_reference_code");
migrationBuilder.DropTable(
name: "column_reference");
migrationBuilder.DropTable(
name: "column_reference_plug_ins");
}
}
}

158
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240420092428_init20240420003.cs

@ -1,158 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.Peis.Migrations
{
public partial class init20240420003 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_lis_request_sample_group",
table: "lis_request");
migrationBuilder.DropForeignKey(
name: "fk_sample_",
table: "sample_group");
migrationBuilder.DropIndex(
name: "IX_lis_request_sample_group_id",
table: "lis_request");
migrationBuilder.DropColumn(
name: "sample_group_id",
table: "lis_request");
migrationBuilder.DropColumn(
name: "sampler",
table: "lis_request");
migrationBuilder.AddColumn<Guid>(
name: "sample_container_id",
table: "lis_request",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
comment: "标本容器编号");
migrationBuilder.AddColumn<Guid>(
name: "sample_type_id",
table: "lis_request",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
comment: "标本类型");
migrationBuilder.AddColumn<Guid>(
name: "sampler_id",
table: "lis_request",
type: "uuid",
nullable: true,
comment: "采样人ID");
migrationBuilder.CreateIndex(
name: "IX_lis_request_sample_container_id",
table: "lis_request",
column: "sample_container_id");
migrationBuilder.CreateIndex(
name: "IX_lis_request_sample_type_id",
table: "lis_request",
column: "sample_type_id");
migrationBuilder.AddForeignKey(
name: "fk_lis_request_sample_container",
table: "lis_request",
column: "sample_container_id",
principalTable: "sample_container",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_lis_request_sample_type",
table: "lis_request",
column: "sample_type_id",
principalTable: "sample_type",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_sample_group_sample_container",
table: "sample_group",
column: "sample_container_id",
principalTable: "sample_container",
principalColumn: "id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_lis_request_sample_container",
table: "lis_request");
migrationBuilder.DropForeignKey(
name: "fk_lis_request_sample_type",
table: "lis_request");
migrationBuilder.DropForeignKey(
name: "fk_sample_group_sample_container",
table: "sample_group");
migrationBuilder.DropIndex(
name: "IX_lis_request_sample_container_id",
table: "lis_request");
migrationBuilder.DropIndex(
name: "IX_lis_request_sample_type_id",
table: "lis_request");
migrationBuilder.DropColumn(
name: "sample_container_id",
table: "lis_request");
migrationBuilder.DropColumn(
name: "sample_type_id",
table: "lis_request");
migrationBuilder.DropColumn(
name: "sampler_id",
table: "lis_request");
migrationBuilder.AddColumn<Guid>(
name: "sample_group_id",
table: "lis_request",
type: "uuid",
fixedLength: true,
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
comment: "条码分组ID");
migrationBuilder.AddColumn<string>(
name: "sampler",
table: "lis_request",
type: "character varying(16)",
maxLength: 16,
nullable: true,
comment: "采样人姓名");
migrationBuilder.CreateIndex(
name: "IX_lis_request_sample_group_id",
table: "lis_request",
column: "sample_group_id");
migrationBuilder.AddForeignKey(
name: "fk_lis_request_sample_group",
table: "lis_request",
column: "sample_group_id",
principalTable: "sample_group",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_sample_",
table: "sample_group",
column: "sample_container_id",
principalTable: "sample_container",
principalColumn: "id");
}
}
}

8
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240420092428_init20240420003.Designer.cs → src/Shentun.Peis.EntityFrameworkCore/Migrations/20240421094110_init20240421001.Designer.cs

@ -13,8 +13,8 @@ using Volo.Abp.EntityFrameworkCore;
namespace Shentun.Peis.Migrations
{
[DbContext(typeof(PeisDbContext))]
[Migration("20240420092428_init20240420003")]
partial class init20240420003
[Migration("20240421094110_init20240421001")]
partial class init20240421001
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -2732,8 +2732,8 @@ namespace Shentun.Peis.Migrations
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasColumnName("display_name")
.HasComment("分组名称");

39
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240421094110_init20240421001.cs

@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.Peis.Migrations
{
public partial class init20240421001 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "display_name",
table: "customer_org_group",
type: "character varying(50)",
maxLength: 50,
nullable: false,
comment: "分组名称",
oldClrType: typeof(string),
oldType: "character varying(20)",
oldMaxLength: 20,
oldComment: "分组名称");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "display_name",
table: "customer_org_group",
type: "character varying(20)",
maxLength: 20,
nullable: false,
comment: "分组名称",
oldClrType: typeof(string),
oldType: "character varying(50)",
oldMaxLength: 50,
oldComment: "分组名称");
}
}
}

37
src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

@ -2730,8 +2730,8 @@ namespace Shentun.Peis.Migrations
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasColumnName("display_name")
.HasComment("分组名称");
@ -3864,11 +3864,14 @@ namespace Shentun.Peis.Migrations
modelBuilder.Entity("Shentun.Peis.Models.GuideType", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid")
b.Property<char>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("character(1)")
.HasColumnName("id")
.IsFixedLength();
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<char>("Id"));
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
@ -4950,8 +4953,8 @@ namespace Shentun.Peis.Migrations
.HasColumnName("display_order")
.HasDefaultValueSql("999999");
b.Property<Guid>("GuidTypeId")
.HasColumnType("uuid")
b.Property<char>("GuidTypeId")
.HasColumnType("character(1)")
.HasColumnName("guid_type_id")
.IsFixedLength()
.HasComment("指引类别");
@ -4981,8 +4984,8 @@ namespace Shentun.Peis.Migrations
.HasColumnType("uuid")
.HasColumnName("last_modifier_id");
b.Property<Guid>("MedicalReportTypeId")
.HasColumnType("uuid")
b.Property<char>("MedicalReportTypeId")
.HasColumnType("character(1)")
.HasColumnName("medical_report_type_id")
.IsFixedLength()
.HasComment("体检报告类别");
@ -5445,11 +5448,14 @@ namespace Shentun.Peis.Migrations
modelBuilder.Entity("Shentun.Peis.Models.MedicalReportType", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid")
b.Property<char>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("character(1)")
.HasColumnName("id")
.IsFixedLength();
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<char>("Id"));
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
@ -5988,8 +5994,8 @@ namespace Shentun.Peis.Migrations
.HasComment("组织单位ID");
b.Property<string>("MobileTelephone")
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasColumnName("mobile_telephone")
.HasComment("手机号");
@ -9463,8 +9469,7 @@ namespace Shentun.Peis.Migrations
.HasColumnType("uuid")
.HasColumnName("creator_id");
b.Property<int?>("DisplayOrder")
.IsRequired()
b.Property<int>("DisplayOrder")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("display_order")
@ -9597,7 +9602,7 @@ namespace Shentun.Peis.Migrations
.HasColumnType("uuid")
.HasColumnName("creator_id");
b.Property<int?>("DisplayOrder")
b.Property<int>("DisplayOrder")
.HasColumnType("integer")
.HasColumnName("display_order");
@ -12578,7 +12583,7 @@ namespace Shentun.Peis.Migrations
.WithMany("ItemTypes")
.HasForeignKey("MedicalReportTypeId")
.IsRequired()
.HasConstraintName("fk_item_ty");
.HasConstraintName("fk_item_type_medical_report_type");
b.Navigation("GuidType");

18
test/Shentun.Peis.Application.Tests/ApiWorkTest.cs

@ -29,14 +29,14 @@ namespace Shentun.Peis
}
[Fact]
//[UnitOfWork]
public async Task TestApi()
{
using (var aaa = _unitOfWorkManager.Begin(true, true))
{
await _appService.TestApi();
}
}
//[Fact]
////[UnitOfWork]
//public async Task TestApi()
//{
// using (var aaa = _unitOfWorkManager.Begin(true, true))
// {
// await _appService.TestApi();
// }
//}
}
}

58
test/Shentun.Peis.Application.Tests/BaseDataHandleTest.cs

@ -0,0 +1,58 @@
using Shentun.Peis.CustomerOrgs;
using Shentun.Peis.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
using Xunit.Abstractions;
using Xunit;
using Shentun.Peis.DataMigrations;
namespace Shentun.Peis
{
public class BaseDataHandleTest : PeisApplicationTestBase
{
private readonly ITestOutputHelper _output;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly BaseDataHandleAppService _appService;
public BaseDataHandleTest(ITestOutputHelper testOutputHelper)
{
_output = testOutputHelper;
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
_appService = GetRequiredService<BaseDataHandleAppService>();
}
[Fact]
public async Task TransferPatientData()
{
for (int i = 0; i < 1000; i++)
{
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
var IsHand = await _appService.TransferPatientData();
await unitOfWork.CompleteAsync();
_output.WriteLine($"处理{(i + 1) * 1000}");
if (!IsHand)
{
break;
}
}
}
}
}
}

6
test/Shentun.Peis.Application.Tests/GuideTypeAppServiceTest.cs

@ -17,7 +17,7 @@ namespace Shentun.Peis
{
public class GuideTypeAppServiceTest: PeisApplicationTestBase
{
private readonly IRepository<GuideType, Guid> _repository;
private readonly IRepository<GuideType, char> _repository;
private readonly GuideTypeAppService _guideTypeAppService;
private readonly ITestOutputHelper _output;
private readonly IUnitOfWorkManager _unitOfWorkManager;
@ -25,7 +25,7 @@ namespace Shentun.Peis
{
_output = testOutputHelper;
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
_repository = GetRequiredService<IRepository<GuideType, Guid>>();
_repository = GetRequiredService<IRepository<GuideType, char>>();
_guideTypeAppService = GetRequiredService<GuideTypeAppService>();
}
@ -104,7 +104,7 @@ namespace Shentun.Peis
{
using (var uow = _unitOfWorkManager.Begin())
{
await _guideTypeAppService.DeleteAsync(new Guid("3a0d6c49-cecf-19d9-0f4b-0923a28a3889"));
await _guideTypeAppService.DeleteAsync('0');
_output.WriteLine("删除成功");
}
}

2
test/Shentun.Peis.Application.Tests/SysParmAppServiceTest.cs

@ -47,7 +47,7 @@ namespace Shentun.Peis
using (var uow = _unitOfWorkManager.Begin())
{
var item = await _appService.GetSysParmValueListInSysParmAsync(
new Guid("4ec3a153-36bf-4555-9f3f-7248aeb323fe"), "doctor_check_check_charge");
new Guid("3a11fe49-5719-0e9e-dd44-0c4aff0900b0"), "doctor_check_check_charge");
_output.WriteLine(item.DisplayName+item.SysParmValueName + item.CreatorName + item.LastModifierName );
}

4
test/Shentun.Peis.Domain.Tests/CacheServiceTest.cs

@ -14,7 +14,7 @@ namespace Shentun.Peis
{
public class CacheServiceTest : PeisDomainTestBase
{
private readonly IRepository<GuideType, Guid> _repository;
private readonly IRepository<GuideType, char> _repository;
private readonly CacheService _cacheService;
//private readonly IDbContextProvider<PeisDbContext> _dbContextProvider;
private readonly ITestOutputHelper _output;
@ -23,7 +23,7 @@ namespace Shentun.Peis
{
_output = output;
_repository = GetRequiredService<IRepository<GuideType, Guid>>();
_repository = GetRequiredService<IRepository<GuideType, char>>();
_cacheService = GetRequiredService<CacheService>();

6
test/Shentun.Peis.Domain.Tests/GuideTypeManagerTest.cs

@ -21,7 +21,7 @@ namespace Shentun.Peis
{
public class GuideTypeManagerTest : PeisDomainTestBase
{
private readonly IRepository<GuideType, Guid> _repository;
private readonly IRepository<GuideType, char> _repository;
private readonly GuideTypeManager _manager;
//private readonly IDbContextProvider<PeisDbContext> _dbContextProvider;
private readonly ITestOutputHelper _output;
@ -33,7 +33,7 @@ namespace Shentun.Peis
//_dbContextProvider = GetRequiredService<IDbContextProvider<PeisDbContext>>();
//_dbContextProvider = dbContextProvider;
//_repository = Substitute.For<IRepository<GuideType,Guid>>();
_repository = GetRequiredService<IRepository<GuideType, Guid>>();
_repository = GetRequiredService<IRepository<GuideType, char>>();
_itemTypeRepository = GetRequiredService<IRepository<ItemType, Guid>>();
_manager = GetRequiredService<GuideTypeManager>();
@ -80,7 +80,7 @@ namespace Shentun.Peis
{
using (var uow = _unitOfWorkManager.Begin())
{
var entity = await _repository.GetAsync(new Guid("3a0d9464-e69e-67d5-c292-b2e11fb334b1"));
var entity = await _repository.GetAsync('0');
await _manager.CheckAndDeleteAsync(entity);
}

4
test/Shentun.Peis.EntityFrameworkCore.Tests/EntityFrameworkCore/PeisEntityFrameworkCoreTestModule.cs

@ -40,8 +40,8 @@ public class PeisEntityFrameworkCoreTestModule : AbpModule
}
private void ConfigurePostGress(IServiceCollection services)
{
string connectStr = "Host=140.143.162.39;Port=5432;Database=ShentunPeis070703;User ID=postgres;Password=shentun123";
//string connectStr = "Host=140.143.162.39;Port=5432;Database=ShentunPeis070703;User ID=postgres;Password=shentun123";
string connectStr = "Host=10.1.12.140;Port=5432;Database=ShentunPeis;User ID=postgres;Password=st123;";
services.Configure<AbpDbContextOptions>(options =>
{

Loading…
Cancel
Save