Browse Source

冲突

bjmzak
DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
4d588b128b
  1. 28
      src/Shentun.Peis.Application.Contracts/DataMigrations/CreateFieldComparisonDto.cs
  2. 351
      src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs
  3. 6
      src/Shentun.Peis.Application/PeisReports/PeisReportAppService.cs
  4. 4
      src/Shentun.Peis.Domain/CustomerOrgRegisters/CustomerOrgRegister.cs
  5. 2
      src/Shentun.Peis.Domain/CustomerOrgs/CustomerOrgManager.cs
  6. 10
      src/Shentun.Peis.Domain/Data/DefaultDataSeederContributor.cs

28
src/Shentun.Peis.Application.Contracts/DataMigrations/CreateFieldComparisonDto.cs

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Shentun.Peis.DataMigrations
{
public class CreateFieldComparisonDto
{
/// <summary>
/// 表名 新系统表名
/// </summary>
public string TableName { get; set; }
/// <summary>
/// 老系统主键值
/// </summary>
public string OldKeyValue { get; set; }
/// <summary>
/// 新系统主键值
/// </summary>
public string NewKeyValue { get; set; }
}
}

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

@ -1,9 +1,12 @@
using log4net.Plugin;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.Extensions.DependencyModel;
using Microsoft.Extensions.Options;
using NPOI.DDF;
using Shentun.Peis.CustomerOrgs;
using Shentun.Peis.Enums;
using Shentun.Peis.ItemTypes;
using Shentun.Peis.Models;
@ -32,8 +35,8 @@ namespace Shentun.Peis.DataMigrations
/// <summary>
/// 基础数据处理
/// </summary>
[Authorize]
[RemoteService(false)]
//[Authorize]
//[RemoteService(false)]
public class BaseDataHandleAppService : ApplicationService
{
@ -53,9 +56,11 @@ namespace Shentun.Peis.DataMigrations
//默认指引类别ID
private readonly char defaultGuidTypeId = '0';
private readonly Guid defaultGuidTypeId = Guid.Parse("3a120284-df18-7b36-4b12-0423a7d5c1c6");
//默认体检报告类别ID
private readonly char defaultMedicalReportTypeId = '0';
private readonly Guid defaultMedicalReportTypeId = Guid.Parse("3a120285-65dd-e7da-c923-6b503ab9e1d9");
//默认体检中心
private readonly Guid defaultMedicalCenterId = Guid.Parse("0de5b78a-731d-4f80-b262-655ebbf04581");
private readonly IRepository<DeviceType, Guid> _deviceTypeRepository;
@ -79,6 +84,9 @@ namespace Shentun.Peis.DataMigrations
private readonly IRepository<ItemResultMatch, Guid> _ItemResultMatchRepository;
private readonly MyUserAppService _myUserAppService;
private readonly IRepository<MenuInfo, Guid> _menuInfoRepository;
private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository;
private readonly CustomerOrgManager _customerOrgManager;
private readonly IRepository<CustomerOrgRegister, Guid> _customerOrgRegisterRepository;
public BaseDataHandleAppService(
IRepository<DeviceType, Guid> deviceTypeRepository,
@ -101,7 +109,10 @@ namespace Shentun.Peis.DataMigrations
IRepository<Diagnosis, Guid> diagnosisRepository,
IRepository<Suggestion, Guid> suggestionRepository,
MyUserAppService myUserAppService,
IRepository<MenuInfo, Guid> menuInfoRepository)
IRepository<MenuInfo, Guid> menuInfoRepository,
IRepository<CustomerOrg, Guid> customerOrgRepository,
CustomerOrgManager customerOrgManager,
IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository)
{
_deviceTypeRepository = deviceTypeRepository;
_itemTypeRepository = itemTypeRepository;
@ -124,12 +135,38 @@ namespace Shentun.Peis.DataMigrations
_suggestionRepository = suggestionRepository;
_myUserAppService = myUserAppService;
_menuInfoRepository = menuInfoRepository;
_customerOrgRepository = customerOrgRepository;
_customerOrgManager = customerOrgManager;
_customerOrgRegisterRepository = customerOrgRegisterRepository;
}
/// <summary>
/// 手动添加字段对照
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public async Task CreateFieldComparisonAsync(CreateFieldComparisonDto input)
{
FieldComparison fieldComparison = new FieldComparison
{
FieldName = "id",
NewKeyValue = input.NewKeyValue,
OldKeyValue = input.OldKeyValue,
TableName = input.TableName
};
await _fieldComparisonRepository.InsertAsync(fieldComparison);
}
/// <summary>
/// 迁移仪器类别数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferDeviceTypeData()
{
var count = await _deviceTypeRepository.GetCountAsync();
@ -172,6 +209,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移数值单位数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferUnitData()
{
var count = await _unitRepository.GetCountAsync();
@ -213,6 +251,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移体检类别数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferMedicalTypeData()
{
var count = await _medicalTypeRepository.GetCountAsync();
@ -254,6 +293,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移人员类别数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferPersonnelTypeData()
{
var count = await _personnelTypeRepository.GetCountAsync();
@ -296,6 +336,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移发票项目类别数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferInvoiceItemTypeData()
{
var count = await _invoiceItemTypeRepository.GetCountAsync();
@ -336,6 +377,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移项目类别-科室数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferItemTypeData()
{
var count = await _itemTypeRepository.GetCountAsync();
@ -386,6 +428,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移标本类型数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferSampleTypeData()
{
var count = await _sampleTypeRepository.GetCountAsync();
@ -426,6 +469,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移项目数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferItemData()
{
var count = await _itemRepository.GetCountAsync();
@ -563,6 +607,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移组合项目数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferAsbitemData()
{
var count = await _asbitemRepository.GetCountAsync();
@ -672,6 +717,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移组合项目明细数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferAsbitemDetailData()
{
var count = await _asbitemDetailRepository.GetCountAsync();
@ -748,6 +794,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移体检套餐数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferMedicalPackageData()
{
var count = await _medicalPackageRepository.GetCountAsync();
@ -799,6 +846,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移体检套餐明细数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferMedicalPackageDetailData()
{
var count = await _medicalPackageDetailRepository.GetCountAsync();
@ -843,6 +891,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移诊断设置数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferDiagnosisData()
{
var count = await _diagnosisRepository.GetCountAsync();
@ -942,6 +991,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移诊断建议数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferSuggestionData()
{
var count = await _suggestionRepository.GetCountAsync();
@ -990,6 +1040,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移项目结果模板数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferItemResultTemplateData()
{
var count = await _itemResultTemplateRepository.GetCountAsync();
@ -1052,6 +1103,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移项目结果匹配数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferItemResultMatchData()
{
var count = await _ItemResultMatchRepository.GetCountAsync();
@ -1108,6 +1160,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移项目参考范围数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferReferenceRangeData()
{
var count = (await _referenceRangeRepository.GetQueryableAsync()).Where(m => m.ReferenceRangeTypeFlag != ItemReferenceRangeTypeFlag.Character).Count();
@ -1168,6 +1221,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移后台用户数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferUserData()
{
@ -1202,6 +1256,7 @@ namespace Shentun.Peis.DataMigrations
/// 迁移菜单
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferMenuInfoData()
{
var oldMenuInfoList = await PgDb.Ado.GetDataTableAsync("select * from menu_info");
@ -1239,6 +1294,292 @@ namespace Shentun.Peis.DataMigrations
}
/// <summary>
/// 迁移体检单位数据 一级
/// </summary>
/// <returns></returns>
public async Task TransferTopCustomerOrgData()
{
var count = await _customerOrgRepository.GetCountAsync();
if (count == 0)
{
List<CustomerOrg> dataList = new List<CustomerOrg>();
List<FieldComparison> fieldComparisons = new List<FieldComparison>();
var oldCustomerOrgList = await Db.Ado.GetDataTableAsync("select * from org where len(org_id)=5 order by display_order asc");
if (oldCustomerOrgList.Rows.Count > 0)
{
foreach (DataRow row in oldCustomerOrgList.Rows)
{
Guid customerOrgId = GuidGenerator.Create();
var data = new CustomerOrg(customerOrgId)
{
Accounts = row["accounts"].ToString(),
Address = row["address"].ToString(),
Bank = row["bank"].ToString(),
DisplayName = row["org_name"].ToString(),
DisplayOrder = oldCustomerOrgList.Rows.IndexOf(row) + 1,
Fax = row["fax"].ToString(),
InvoiceName = row["org_name"].ToString(),
IsActive = 'Y',
IsLock = Convert.ToChar(row["lock_flag"].ToString()),
MedicalCenterId = defaultMedicalCenterId,
OrgTypeId = Guid.Parse("3a11fe4e-7dd3-b379-43b9-5be586097abe"), //默认为私营
ParentId = null,
PathCode = (oldCustomerOrgList.Rows.IndexOf(row) + 1).ToString().PadLeft(5, '0'),
PostalCode = row["postalcode"].ToString(),
Remark = row["linkman"].ToString() + "|" + "telephone",
ShortName = row["short_name"].ToString(),
SimpleCode = LanguageConverter.GetPYSimpleCode(row["org_name"].ToString()),
Telephone = row["telephone"].ToString(),
};
dataList.Add(data);
fieldComparisons.Add(new FieldComparison
{
FieldName = "id",
NewKeyValue = customerOrgId.ToString(),
OldKeyValue = row["org_id"].ToString(),
TableName = "customer_org"
});
}
if (dataList.Any())
await _customerOrgRepository.InsertManyAsync(dataList);
if (fieldComparisons.Any())
await _fieldComparisonRepository.InsertManyAsync(fieldComparisons);
}
}
}
/// <summary>
/// 迁移体检单位数据 二级
/// </summary>
/// <returns></returns>
public async Task TransferTwoCustomerOrgData()
{
var count = (await _customerOrgRepository.GetQueryableAsync()).Where(m => m.PathCode.Length > 5).Count();
if (count == 0)
{
List<CustomerOrg> dataList = new List<CustomerOrg>();
List<FieldComparison> fieldComparisons = new List<FieldComparison>();
var oldCustomerOrgList = await Db.Ado.GetDataTableAsync("select * from [dbo].[org] where len(org_id)=8 order by org_id asc");
if (oldCustomerOrgList.Rows.Count > 0)
{
List<CustomerOrg> customerOrgList = await _customerOrgRepository.GetListAsync(m => m.ParentId == null);
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
foreach (DataRow row in oldCustomerOrgList.Rows)
{
#region 查找上级ID
string oldId = row["org_id"].ToString();
string oldParentId = oldId.Substring(0, 5);
Guid parentId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == oldParentId).FirstOrDefault().NewKeyValue);
#endregion
Guid customerOrgId = GuidGenerator.Create();
#region 备注 导入联系人姓名、电话
string remark = "";
if (!string.IsNullOrWhiteSpace(row["linkman"].ToString()))
{
remark = row["linkman"].ToString();
}
if (!string.IsNullOrWhiteSpace(row["telephone"].ToString()))
{
if (!string.IsNullOrWhiteSpace(remark))
{
remark += "|" + row["telephone"].ToString();
}
else
{
remark = row["telephone"].ToString();
}
}
#endregion
var data = new CustomerOrg(customerOrgId)
{
Accounts = row["accounts"].ToString(),
Address = row["address"].ToString(),
Bank = row["bank"].ToString(),
DisplayName = row["org_name"].ToString(),
DisplayOrder = oldCustomerOrgList.Rows.IndexOf(row) + 1,
Fax = row["fax"].ToString(),
InvoiceName = row["org_name"].ToString(),
IsActive = 'Y',
IsLock = Convert.ToChar(row["lock_flag"].ToString()),
MedicalCenterId = defaultMedicalCenterId,
OrgTypeId = Guid.Parse("3a11fe4e-7dd3-b379-43b9-5be586097abe"), //默认为私营
ParentId = parentId,
PathCode = _customerOrgManager.CreatePathCode(parentId).Result,
PostalCode = row["postalcode"].ToString(),
Remark = remark,
ShortName = row["short_name"].ToString(),
SimpleCode = LanguageConverter.GetPYSimpleCode(row["org_name"].ToString()),
Telephone = row["telephone"].ToString(),
};
await _customerOrgRepository.InsertAsync(data, true);
fieldComparisons.Add(new FieldComparison
{
FieldName = "id",
NewKeyValue = customerOrgId.ToString(),
OldKeyValue = row["org_id"].ToString(),
TableName = "customer_org"
});
}
if (fieldComparisons.Any())
await _fieldComparisonRepository.InsertManyAsync(fieldComparisons);
}
}
}
/// <summary>
/// 迁移体检单位数据 三级
/// </summary>
/// <returns></returns>
public async Task TransferThreeCustomerOrgData()
{
var count = (await _customerOrgRepository.GetQueryableAsync()).Where(m => m.PathCode.Length > 11).Count();
if (count == 0)
{
List<CustomerOrg> dataList = new List<CustomerOrg>();
List<FieldComparison> fieldComparisons = new List<FieldComparison>();
var oldCustomerOrgList = await Db.Ado.GetDataTableAsync("select * from [dbo].[org] where len(org_id)=11 order by org_id asc");
if (oldCustomerOrgList.Rows.Count > 0)
{
List<CustomerOrg> customerOrgList = await _customerOrgRepository.GetListAsync(m => m.ParentId == null);
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
foreach (DataRow row in oldCustomerOrgList.Rows)
{
#region 查找上级ID
string oldId = row["org_id"].ToString();
string oldParentId = oldId.Substring(0, 8);
Guid parentId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == oldParentId).FirstOrDefault().NewKeyValue);
#endregion
Guid customerOrgId = GuidGenerator.Create();
#region 备注 导入联系人姓名、电话
string remark = "";
if (!string.IsNullOrWhiteSpace(row["linkman"].ToString()))
{
remark = row["linkman"].ToString();
}
if (!string.IsNullOrWhiteSpace(row["telephone"].ToString()))
{
if (!string.IsNullOrWhiteSpace(remark))
{
remark += "|" + row["telephone"].ToString();
}
else
{
remark = row["telephone"].ToString();
}
}
#endregion
var data = new CustomerOrg(customerOrgId)
{
Accounts = row["accounts"].ToString(),
Address = row["address"].ToString(),
Bank = row["bank"].ToString(),
DisplayName = row["org_name"].ToString(),
DisplayOrder = oldCustomerOrgList.Rows.IndexOf(row) + 1,
Fax = row["fax"].ToString(),
InvoiceName = row["org_name"].ToString(),
IsActive = 'Y',
IsLock = Convert.ToChar(row["lock_flag"].ToString()),
MedicalCenterId = defaultMedicalCenterId,
OrgTypeId = Guid.Parse("3a11fe4e-7dd3-b379-43b9-5be586097abe"), //默认为私营
ParentId = parentId,
PathCode = _customerOrgManager.CreatePathCode(parentId).Result,
PostalCode = row["postalcode"].ToString(),
Remark = remark,
ShortName = row["short_name"].ToString(),
SimpleCode = LanguageConverter.GetPYSimpleCode(row["org_name"].ToString()),
Telephone = row["telephone"].ToString(),
};
await _customerOrgRepository.InsertAsync(data, true);
fieldComparisons.Add(new FieldComparison
{
FieldName = "id",
NewKeyValue = customerOrgId.ToString(),
OldKeyValue = row["org_id"].ToString(),
TableName = "customer_org"
});
}
if (fieldComparisons.Any())
await _fieldComparisonRepository.InsertManyAsync(fieldComparisons);
}
}
}
/// <summary>
/// 迁移单位体检次数数据
/// </summary>
/// <returns></returns>
public async Task TransferCustomerOrgRegisterData()
{
var count = await _customerOrgRegisterRepository.GetCountAsync();
if (count == 0)
{
List<CustomerOrgRegister> dataList = new List<CustomerOrgRegister>();
var oldCustomerOrgRegisterList = await Db.Ado.GetDataTableAsync("select * from org_medical_register");
if (oldCustomerOrgRegisterList.Rows.Count > 0)
{
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
foreach (DataRow row in oldCustomerOrgRegisterList.Rows)
{
Guid customerOrgId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == row["org_id"].ToString()).FirstOrDefault().NewKeyValue);
Guid customerOrgRegisterId = GuidGenerator.Create();
if (customerOrgId == GuidFlag.PersonCustomerOrgId)
customerOrgRegisterId = GuidFlag.PersonCustomerOrgRegisterId;
var data = new CustomerOrgRegister(customerOrgRegisterId)
{
BeginTime = Convert.ToDateTime(row["start_time"].ToString()),
CustomerOrgId = customerOrgId,
EndTime = !string.IsNullOrWhiteSpace(row["end_time"].ToString()) ? Convert.ToDateTime(row["end_time"].ToString()) : null,
IsComplete = Convert.ToChar(row["complete_flag"].ToString()),
MedicalTimes = (short)Convert.ToInt32(row["org_medical_times"].ToString()),
RegisterName = "",
RegisterNo = ""
};
dataList.Add(data);
}
if (dataList.Any())
await _customerOrgRegisterRepository.InsertManyAsync(dataList);
}
}
}
private void LoadDLL()
{
// 定义dll文件夹路径

6
src/Shentun.Peis.Application/PeisReports/PeisReportAppService.cs

@ -208,6 +208,10 @@ namespace Shentun.Peis.PeisReports
{
sumquery = sumquery.Where(m => m.a.CompleteFlag == input.CompleteFlag);
}
else
{
sumquery = sumquery.Where(m => m.a.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration);
}
if (input.IsAudit != null)
{
@ -450,7 +454,7 @@ namespace Shentun.Peis.PeisReports
[HttpPost("api/app/peisreport/getregisterasbitemchargestatus")]
public async Task<List<GetRegisterAsbitemChargeStatusDto>> GetRegisterAsbitemChargeStatusAsync(GetRegisterAsbitemChargeStatusRequestDto input)
{
var query = from j in await _registerAsbitemRepository.GetQueryableAsync()
join k in await _registerCheckRepository.GetQueryableAsync() on j.RegisterCheckId equals k.Id into kk
from jk in kk.DefaultIfEmpty()

4
src/Shentun.Peis.Domain/CustomerOrgRegisters/CustomerOrgRegister.cs

@ -14,6 +14,10 @@ namespace Shentun.Peis.Models
[Table("customer_org_register")]
public class CustomerOrgRegister : AuditedEntity<Guid>, IHasConcurrencyStamp
{
public CustomerOrgRegister(Guid id):base(id) {
}
public CustomerOrgRegister()
{
CustomerOrgCharges = new HashSet<CustomerOrgCharge>();

2
src/Shentun.Peis.Domain/CustomerOrgs/CustomerOrgManager.cs

@ -221,7 +221,7 @@ namespace Shentun.Peis.CustomerOrgs
/// </summary>
/// <param name="parentId"></param>
/// <returns></returns>
private async Task<string> CreatePathCode(Guid? parentId)
public async Task<string> CreatePathCode(Guid? parentId)
{
string PathCode = "00001";
//一级

10
src/Shentun.Peis.Domain/Data/DefaultDataSeederContributor.cs

@ -94,22 +94,22 @@ namespace Shentun.Peis.Data
await CreateMaritalStatusAsync();
//结果状态
await CreateResultStatusAsync();
//await CreateResultStatusAsync();
//支付方式
await CreatePayModeAsync();
//体检结论类别
await CreateMedicalConclusionTypeAsync();
//await CreateMedicalConclusionTypeAsync();
//生成客户单位类别数据
await CreateCustomerOrgTypeAsync();
//await CreateCustomerOrgTypeAsync();
//生成民族数据
await CreateNationAsync();
//生成性激素期限数据
await CreateSexHormoneTermAsync();
////生成性激素期限数据
//await CreateSexHormoneTermAsync();
await CreateDiagnosisLevelAsync();
}

Loading…
Cancel
Save