|
|
|
@ -11,6 +11,15 @@ using System.Net.Http.Headers; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Text.RegularExpressions; |
|
|
|
using Shentun.Peis.PatientRegisters; |
|
|
|
using Shentun.Peis.PersonnelTypes; |
|
|
|
using Shentun.Peis.MedicalTypes; |
|
|
|
using Shentun.Peis.CustomerOrgs; |
|
|
|
using Shentun.Peis.CustomerOrgGroups; |
|
|
|
using Shentun.Peis.CustomerReports; |
|
|
|
using Shentun.Peis.CustomerOrgGroupDetails; |
|
|
|
using Shentun.Peis.CustomerOrgRegisters; |
|
|
|
using Shentun.Peis.Enums; |
|
|
|
|
|
|
|
namespace Shentun.Peis.PlugIns.Gem |
|
|
|
{ |
|
|
|
@ -20,6 +29,10 @@ namespace Shentun.Peis.PlugIns.Gem |
|
|
|
private string _hospitalId; |
|
|
|
private string _aesKEY; |
|
|
|
private string _year; |
|
|
|
private CustomerOrgDto _customerOrgDto; |
|
|
|
private CustomerOrgRegisterDto _customerOrgRegisterDto; |
|
|
|
private List<PersonnelTypeDto> _personnelTypes; |
|
|
|
private List<CustomerOrgGroupDto> _customerOrgGroupDtos; |
|
|
|
public ImportPatientRegisterPlugInsGem(string parmValue) : base(parmValue) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -27,6 +40,7 @@ namespace Shentun.Peis.PlugIns.Gem |
|
|
|
|
|
|
|
public override async Task ImportAsync() |
|
|
|
{ |
|
|
|
await LoginAsync(); |
|
|
|
await InitAsync(); |
|
|
|
|
|
|
|
var qztlPatientRegisterFromInterface = await CallInterfaceServiceAsync(); |
|
|
|
@ -34,9 +48,193 @@ namespace Shentun.Peis.PlugIns.Gem |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
foreach(var patient in qztlPatientRegisterFromInterface.plans) |
|
|
|
//设置导入人员信息
|
|
|
|
foreach (var patient in qztlPatientRegisterFromInterface.plans) |
|
|
|
{ |
|
|
|
//婚姻状况
|
|
|
|
var maritalStatusId = ConvertMaritalStatus(patient.wedding); |
|
|
|
//人员类别
|
|
|
|
var personnelType = ConvertPersonnelType(patient.tjJieduan); |
|
|
|
//性别
|
|
|
|
var sexId = ConvertSex(patient.sex); |
|
|
|
//体检类别
|
|
|
|
var medicalTypeName = patient.tjpcV; |
|
|
|
MedicalTypeDto medicalTypeDto = null; |
|
|
|
if (!string.IsNullOrWhiteSpace(medicalTypeName)) |
|
|
|
{ |
|
|
|
medicalTypeDto = await CallAppServiceAsync<DisplayNameInputDto, MedicalTypeDto>( |
|
|
|
"api/app/MedicalType/GetByDisplayName", new DisplayNameInputDto() { DisplayName = medicalTypeName }); |
|
|
|
if (medicalTypeDto == null) |
|
|
|
{ |
|
|
|
var createMedicalTypeDto = new CreateMedicalTypeDto() |
|
|
|
{ |
|
|
|
DisplayName = medicalTypeName, |
|
|
|
}; |
|
|
|
medicalTypeDto = await CallAppServiceAsync<CreateMedicalTypeDto, MedicalTypeDto>( |
|
|
|
"api/app/medical-type", new CreateMedicalTypeDto() { DisplayName = medicalTypeName }); |
|
|
|
} |
|
|
|
} |
|
|
|
//职称
|
|
|
|
var jobTitle = ConvertJobTitle(patient.gradeZwV); |
|
|
|
//职务
|
|
|
|
var jobPost = ConvertJobPost(patient.tjTab1); |
|
|
|
string workTypeV = patient.workTypeV; |
|
|
|
if (string.IsNullOrWhiteSpace(workTypeV)) |
|
|
|
{ |
|
|
|
workTypeV = ""; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
workTypeV = "," + workTypeV; |
|
|
|
} |
|
|
|
jobPost = jobPost + workTypeV; |
|
|
|
jobPost = jobPost.Substring(0, 10);//只能存储10个汉字
|
|
|
|
//查找子单位是否存在,如存在获取子单位id,如果不存在这创建子单位
|
|
|
|
var orgName = patient.orgName; |
|
|
|
var pos = orgName.IndexOf("_"); |
|
|
|
orgName = orgName.Substring(0, pos); |
|
|
|
if (string.IsNullOrWhiteSpace(patient.mobile)) |
|
|
|
{ |
|
|
|
//青海省第五人民医院要强行设置为 11111111111
|
|
|
|
} |
|
|
|
var customerOrgDtos = await CallAppServiceAsync<CustomerOrgIdInputDto, List<CustomerOrgDto>>( |
|
|
|
"api/app/CustomerOrg/GetChildCustomerOrgsById", |
|
|
|
new CustomerOrgIdInputDto() { CustomerOrgId = _importCustomerOrgId }); |
|
|
|
CustomerOrgDto customerOrgDto = null; |
|
|
|
if (customerOrgDtos != null && customerOrgDtos.Any()) |
|
|
|
{ |
|
|
|
customerOrgDto = customerOrgDtos.Where(o => o.DisplayName == orgName).FirstOrDefault(); |
|
|
|
} |
|
|
|
if (customerOrgDto == null) |
|
|
|
{ |
|
|
|
customerOrgDto = await CallAppServiceAsync<CreateCustomerOrgDto, CustomerOrgDto>( |
|
|
|
"api/app/customerorg/create", new CreateCustomerOrgDto() |
|
|
|
{ |
|
|
|
MedicalCenterId = _importCustomerOrgId, |
|
|
|
ParentId = _customerOrgDto.MedicalCenterId, |
|
|
|
DisplayName = orgName, |
|
|
|
ShortName = orgName, |
|
|
|
IsActive = 'Y', |
|
|
|
IsLock = 'Y' |
|
|
|
}); |
|
|
|
} |
|
|
|
CustomerOrgGroupDto customerOrgGroupDto; |
|
|
|
if (patient.ifFj == 1) |
|
|
|
{ |
|
|
|
//复检
|
|
|
|
//加载单位分组信息
|
|
|
|
_customerOrgGroupDtos = await CallAppServiceAsync<Guid, List<CustomerOrgGroupDto>>( |
|
|
|
"api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=" + _importCustomerOrgId.ToString() |
|
|
|
, Guid.Empty, "get"); |
|
|
|
customerOrgGroupDto = _customerOrgGroupDtos.Where(o => o.DisplayName == "复检").FirstOrDefault(); |
|
|
|
if (customerOrgGroupDto == null) |
|
|
|
{ |
|
|
|
throw new Exception("没有复检这个分组"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
List<string> groupNames = new List<string>(); |
|
|
|
if (patient.ifGy == 1) |
|
|
|
{ |
|
|
|
groupNames.Add("高原"); |
|
|
|
} |
|
|
|
else if (patient.ifJk == 1) |
|
|
|
{ |
|
|
|
groupNames.Add("健康"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new Exception("分组名称必须是高原或健康体检二选一"); |
|
|
|
} |
|
|
|
if (patient.ifGt == 1) |
|
|
|
{ |
|
|
|
groupNames.Add("高铁"); |
|
|
|
} |
|
|
|
if (patient.ifWh == 1) |
|
|
|
{ |
|
|
|
groupNames.Add("职害"); |
|
|
|
} |
|
|
|
if (patient.ifCw == 1) |
|
|
|
{ |
|
|
|
groupNames.Add("普速"); |
|
|
|
} |
|
|
|
if (patient.ifMain == 1) |
|
|
|
{ |
|
|
|
groupNames.Add("行车"); |
|
|
|
} |
|
|
|
if (patient.ifCy == 1) |
|
|
|
{ |
|
|
|
groupNames.Add("从业"); |
|
|
|
} |
|
|
|
customerOrgGroupDto = await GetCustomerOrgGroup(groupNames, sexId, maritalStatusId); |
|
|
|
} |
|
|
|
var patientRegister = new CreatePatientRegisterDto() |
|
|
|
{ |
|
|
|
MedicalCenterId = _customerOrgDto.MedicalCenterId, |
|
|
|
//PatientRegisterId = null,
|
|
|
|
//PatientId = null,
|
|
|
|
IsMaxMedicalTimes = 'Y', |
|
|
|
CompleteFlag = '0', |
|
|
|
CustomerOrgId = customerOrgDto.Id, |
|
|
|
CustomerOrgGroupId = customerOrgGroupDto.Id, |
|
|
|
PatientName = patient.personName, |
|
|
|
SexId = sexId, |
|
|
|
Age = patient.age, |
|
|
|
MaritalStatusId = maritalStatusId, |
|
|
|
MobileTelephone = patient.mobile, |
|
|
|
Planuserid = patient.id.ToString(), |
|
|
|
IdNo = patient.cardId, |
|
|
|
PersonnelTypeId = personnelType.Id, |
|
|
|
JobTitle = jobTitle, |
|
|
|
Remark = patient.remark, |
|
|
|
JobPost = jobPost, |
|
|
|
Remark2 = patient.tjOpinion, |
|
|
|
Remark3 = patient.fjOpinion, |
|
|
|
QztlIsFj = patient.ifFj ==1?'Y':'N', |
|
|
|
QztlIsGt = patient.ifGt == 1 ? 'Y' : 'N', |
|
|
|
QztlIsWh = patient.ifWh == 1 ? 'Y' : 'N', |
|
|
|
QztlIsCw = patient.ifCw == 1 ? 'Y' : 'N', |
|
|
|
QztlIsMain = patient.ifMain == 1 ? 'Y' : 'N', |
|
|
|
QztlIsCy = patient.ifCy == 1 ? 'Y' : 'N', |
|
|
|
IsQztlImport = 'Y' |
|
|
|
}; |
|
|
|
if(medicalTypeDto!=null) |
|
|
|
{ |
|
|
|
patientRegister.MedicalTypeId = medicalTypeDto.Id; |
|
|
|
} |
|
|
|
if(patient.ifGy == 1) |
|
|
|
{ |
|
|
|
patientRegister.QztlType = '0'; |
|
|
|
} |
|
|
|
else if(patient.ifJk == 1) { } |
|
|
|
{ |
|
|
|
patientRegister.QztlType = '1'; |
|
|
|
} |
|
|
|
patientRegister.RegisterCheckAsbitems = new List<CreatePatientRegisterRegisterCheckAsbitem>(); |
|
|
|
//获取分组信息
|
|
|
|
var customerOrgGroupDetailOrAsbitemDtos = await CallAppServiceAsync<Guid, List<CustomerOrgGroupDetailOrAsbitemDto>>( |
|
|
|
"api/app/customerorggroupdetail/getcustomerorggroupdetailinasbitem?CustomerOrgGroupId=" + customerOrgGroupDto.Id.ToString() |
|
|
|
, Guid.Empty, "get"); |
|
|
|
if(!customerOrgGroupDetailOrAsbitemDtos.Any() ) |
|
|
|
{ |
|
|
|
throw new Exception("分组未包含项目"); |
|
|
|
} |
|
|
|
foreach(var asbitem in customerOrgGroupDetailOrAsbitemDtos) |
|
|
|
{ |
|
|
|
patientRegister.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem() |
|
|
|
{ |
|
|
|
AsbitemId = asbitem.AsbitemId, |
|
|
|
StandardPrice = asbitem.Price, |
|
|
|
ChargePrice = asbitem.CustomerOrgGroupDetailPrice, |
|
|
|
PayTypeFlag = '1', |
|
|
|
IsCharge = 'N', |
|
|
|
Amount = asbitem.CustomerOrgGroupDetailAmount |
|
|
|
}); |
|
|
|
} |
|
|
|
await CallAppServiceAsync<CreatePatientRegisterDto, List<PatientRegisterOrNoDto>>( |
|
|
|
"api/PatientRegister/CreatePatientRegister", |
|
|
|
patientRegister); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -98,6 +296,20 @@ namespace Shentun.Peis.PlugIns.Gem |
|
|
|
|
|
|
|
_year = year; |
|
|
|
} |
|
|
|
//加载单位信息
|
|
|
|
_customerOrgDto = await CallAppServiceAsync<CustomerOrgIdInputDto, CustomerOrgDto>( |
|
|
|
"api/app/CustomerOrg/GetById", new CustomerOrgIdInputDto() |
|
|
|
{ |
|
|
|
CustomerOrgId = _importCustomerOrgId, |
|
|
|
}); |
|
|
|
//加载单位登记信息
|
|
|
|
_customerOrgRegisterDto = await CallAppServiceAsync<CustomerOrgIdInputDto, CustomerOrgRegisterDto>( |
|
|
|
"api/app/CustomerOrgRegister/GetLastCustomerOrgRegisterByCustomerOrgId", new CustomerOrgIdInputDto() |
|
|
|
{ |
|
|
|
CustomerOrgId = _importCustomerOrgId, |
|
|
|
}); |
|
|
|
//加载人员类别列表
|
|
|
|
var _personnelTypes = await CallAppServiceAsync<string, List<PersonnelTypeDto>>("api/app/PersonnelType/GetAll", ""); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -131,7 +343,7 @@ namespace Shentun.Peis.PlugIns.Gem |
|
|
|
result = await response.Content.ReadAsStringAsync(); |
|
|
|
|
|
|
|
result = result.Replace(":\"[{", ":[{").Replace("}]\"", "}]").Replace("\\", ""); |
|
|
|
|
|
|
|
|
|
|
|
QztlPatientRegisterFromInterface? resultDto = JsonConvert.DeserializeObject<QztlPatientRegisterFromInterface>(result); |
|
|
|
if (resultDto != null) |
|
|
|
{ |
|
|
|
@ -165,5 +377,320 @@ namespace Shentun.Peis.PlugIns.Gem |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public char ConvertMaritalStatus(int maritalStatus) |
|
|
|
{ |
|
|
|
|
|
|
|
switch (maritalStatus) |
|
|
|
{ |
|
|
|
case 1: |
|
|
|
return '0'; |
|
|
|
case 2: |
|
|
|
return '1'; |
|
|
|
case 3: |
|
|
|
return '3'; |
|
|
|
default: |
|
|
|
return '9'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public char ConvertSex(int sex) |
|
|
|
{ |
|
|
|
|
|
|
|
switch (sex) |
|
|
|
{ |
|
|
|
case 1: |
|
|
|
return 'M'; |
|
|
|
case 2: |
|
|
|
return 'F'; |
|
|
|
default: |
|
|
|
return 'U'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public string ConvertJobPost(string jobPost) |
|
|
|
{ |
|
|
|
if (string.IsNullOrWhiteSpace(jobPost)) |
|
|
|
{ |
|
|
|
return ""; |
|
|
|
} |
|
|
|
switch (jobPost) |
|
|
|
{ |
|
|
|
case "0": |
|
|
|
return "普通成员"; |
|
|
|
case "1": |
|
|
|
return "班子成员"; |
|
|
|
default: |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
public string ConvertJobTitle(string jobTitle) |
|
|
|
{ |
|
|
|
if (string.IsNullOrWhiteSpace(jobTitle)) |
|
|
|
{ |
|
|
|
return "无"; |
|
|
|
} |
|
|
|
switch (jobTitle) |
|
|
|
{ |
|
|
|
case "0": |
|
|
|
return "无"; |
|
|
|
case "1": |
|
|
|
return "科员"; |
|
|
|
case "2": |
|
|
|
return "副科"; |
|
|
|
case "3": |
|
|
|
return "正科"; |
|
|
|
case "4": |
|
|
|
return "副处"; |
|
|
|
case "5": |
|
|
|
return "正处"; |
|
|
|
case "6": |
|
|
|
return "副局"; |
|
|
|
case "7": |
|
|
|
return "正局"; |
|
|
|
default: |
|
|
|
return "无"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public PersonnelTypeDto ConvertPersonnelType(int personnelType) |
|
|
|
{ |
|
|
|
string personnelTypeName; |
|
|
|
switch (personnelType) |
|
|
|
{ |
|
|
|
case 1: |
|
|
|
personnelTypeName = "岗前"; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
personnelTypeName = "岗中"; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
personnelTypeName = "岗后"; |
|
|
|
break; |
|
|
|
default: |
|
|
|
personnelTypeName = ""; |
|
|
|
break; |
|
|
|
} |
|
|
|
if (string.IsNullOrWhiteSpace(personnelTypeName)) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
var personnelTypeDto = _personnelTypes.Where(o => o.DisplayName == personnelTypeName).FirstOrDefault(); |
|
|
|
return personnelTypeDto; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<CustomerOrgGroupDto> GetCustomerOrgGroup(List<string> goupNames, char sexId, char maritalStatusId) |
|
|
|
{ |
|
|
|
string sexName = ""; |
|
|
|
if (sexId == 'M') |
|
|
|
{ |
|
|
|
sexName = "男"; |
|
|
|
} |
|
|
|
else if (sexId == 'F') |
|
|
|
{ |
|
|
|
sexName = "女"; |
|
|
|
} |
|
|
|
string groupName = ""; |
|
|
|
for (var i = 0; i < goupNames.Count; i++) |
|
|
|
{ |
|
|
|
if (i == 0) |
|
|
|
{ |
|
|
|
groupName = goupNames[i]; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
groupName += goupNames[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
string maritalStatusName; |
|
|
|
if (maritalStatusId == '9' || maritalStatusId == '1') |
|
|
|
{ |
|
|
|
maritalStatusName = "已婚"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
maritalStatusName = "未婚"; |
|
|
|
} |
|
|
|
if (sexName == "女") |
|
|
|
{ |
|
|
|
groupName += maritalStatusName + sexName; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
groupName += sexName; |
|
|
|
} |
|
|
|
|
|
|
|
_customerOrgGroupDtos = await CallAppServiceAsync<Guid, List<CustomerOrgGroupDto>>( |
|
|
|
"api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=" + _importCustomerOrgId.ToString() |
|
|
|
, Guid.Empty, "get"); |
|
|
|
var customerOrgGroup = _customerOrgGroupDtos.Where(o => o.DisplayName == groupName).FirstOrDefault(); |
|
|
|
if (customerOrgGroup != null) |
|
|
|
{ |
|
|
|
return customerOrgGroup; |
|
|
|
} |
|
|
|
//-------------自动创建分组
|
|
|
|
//检测有没有单个分组
|
|
|
|
|
|
|
|
string existGroupName = ""; |
|
|
|
var createCustomerOrgGroupWithDetailDto = new CreateCustomerOrgGroupWithDetailDto() |
|
|
|
{ |
|
|
|
IsMaxMedicalTimes = 'Y', |
|
|
|
CustomerOrgId = _importCustomerOrgId, |
|
|
|
DisplayName = groupName, |
|
|
|
ForSexId = sexId, |
|
|
|
AgeLowerLimit = 0, |
|
|
|
AgeUpperLimit = 200, |
|
|
|
MaritalStatusId = 'A' |
|
|
|
}; |
|
|
|
for (var i = 0; i < goupNames.Count; i++) |
|
|
|
{ |
|
|
|
if (i == 0) |
|
|
|
{ |
|
|
|
if (sexName == "女") |
|
|
|
{ |
|
|
|
existGroupName = goupNames[i] + maritalStatusName + sexName; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
existGroupName = goupNames[i] + maritalStatusName + sexName; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
existGroupName = goupNames[i]; |
|
|
|
} |
|
|
|
|
|
|
|
_customerOrgGroupDtos = await CallAppServiceAsync<Guid, List<CustomerOrgGroupDto>>( |
|
|
|
"api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=" + _importCustomerOrgId.ToString() |
|
|
|
, Guid.Empty, "get"); |
|
|
|
customerOrgGroup = _customerOrgGroupDtos.Where(o => o.DisplayName == existGroupName).FirstOrDefault(); |
|
|
|
if (customerOrgGroup == null) |
|
|
|
{ |
|
|
|
throw new Exception($"分组名{existGroupName}不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
var customerOrgGroupDetailOrAsbitemDtos = await CallAppServiceAsync<Guid, List<CustomerOrgGroupDetailOrAsbitemDto>>( |
|
|
|
"api/app/customerorggroupdetail/getcustomerorggroupdetailinasbitem?CustomerOrgGroupId=" + customerOrgGroup.Id.ToString() |
|
|
|
, Guid.Empty, "get"); |
|
|
|
|
|
|
|
foreach (var customerOrgGroupDetailOrAsbitemDto in customerOrgGroupDetailOrAsbitemDtos) |
|
|
|
{ |
|
|
|
if (!createCustomerOrgGroupWithDetailDto.Details. |
|
|
|
Where(o => o.AsbitemId == customerOrgGroupDetailOrAsbitemDto.AsbitemId).ToList().Any()) |
|
|
|
{ |
|
|
|
createCustomerOrgGroupWithDetailDto.Details.Add(new CreateCustomerOrgGroupDetail_Detail() |
|
|
|
{ |
|
|
|
AsbitemId = customerOrgGroupDetailOrAsbitemDto.AsbitemId, |
|
|
|
Amount = customerOrgGroupDetailOrAsbitemDto.CustomerOrgGroupDetailAmount, |
|
|
|
Price = customerOrgGroupDetailOrAsbitemDto.Price, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
customerOrgGroup = await CallAppServiceAsync<CreateCustomerOrgGroupWithDetailDto, CustomerOrgGroupDto>( |
|
|
|
"api/app/CustomerOrgGroup/CreateCustomerOrgGroupWithDetail", createCustomerOrgGroupWithDetailDto); |
|
|
|
return customerOrgGroup; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task NoteOk(List<string> successIds, List<string> deleteIds) |
|
|
|
{ |
|
|
|
if(successIds == null || deleteIds == null) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (successIds.Count == 0 || deleteIds.Count == 0) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
string successIdStr = ""; |
|
|
|
for (var i = 0 ; i < successIds.Count; i++) |
|
|
|
{ |
|
|
|
if(i == 0) |
|
|
|
{ |
|
|
|
successIdStr = successIds[i]; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
successIdStr += "," + successIds[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
string deleteIdStr = ""; |
|
|
|
for (var i = 0; i < deleteIds.Count; i++) |
|
|
|
{ |
|
|
|
if (i == 0) |
|
|
|
{ |
|
|
|
deleteIdStr = deleteIds[i]; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
deleteIdStr += "," + deleteIds[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
string baseAddress = "http://62.156.10.237:8005/health/values/SetPlanOK?"; |
|
|
|
string ary = "HospitalId=" + _hospitalId + (Char)38 + |
|
|
|
"ids=" + successIdStr + (Char)38 + "delids=" + deleteIdStr + (Char)38 + "AesKey=" + _aesKEY; |
|
|
|
baseAddress = baseAddress + ary; |
|
|
|
using (var httpClientHandler = new HttpClientHandler()) |
|
|
|
{ |
|
|
|
using (var httpClient = new HttpClient(httpClientHandler)) |
|
|
|
{ |
|
|
|
httpClient.BaseAddress = new Uri(baseAddress); |
|
|
|
|
|
|
|
httpClient.DefaultRequestHeaders.Accept.Add( |
|
|
|
new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));//设置accept标头,告诉JSON是可接受的响应类型
|
|
|
|
//httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accesToken);
|
|
|
|
IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); |
|
|
|
timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; |
|
|
|
//var sendData = JsonConvert.SerializeObject(data, Newtonsoft.Json.Formatting.Indented, timeFormat);
|
|
|
|
using (HttpContent httpContent = new StringContent("")) |
|
|
|
{ |
|
|
|
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); |
|
|
|
HttpResponseMessage response = await httpClient.GetAsync(""); |
|
|
|
string result; |
|
|
|
if (!response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
|
result = response.Content.ReadAsStringAsync().Result; |
|
|
|
throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); |
|
|
|
} |
|
|
|
result = await response.Content.ReadAsStringAsync(); |
|
|
|
|
|
|
|
result = result.Replace(":\"[{", ":[{").Replace("}]\"", "}]").Replace("\\", ""); |
|
|
|
|
|
|
|
dynamic? resultDto = JsonConvert.DeserializeObject(result); |
|
|
|
if (resultDto != null) |
|
|
|
{ |
|
|
|
if (resultDto.status != 0) |
|
|
|
{ |
|
|
|
throw new Exception($"调用WebApi失败,返回错误,消息:" + resultDto.status + resultDto.errorMsg); |
|
|
|
} |
|
|
|
//插入数据库中备份
|
|
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) |
|
|
|
{ |
|
|
|
string sql; |
|
|
|
var qztlImportDataEntity = new QztlImportDataEntity() |
|
|
|
{ |
|
|
|
Id = Guid.NewGuid(), |
|
|
|
Data = result, |
|
|
|
DataType = '0', |
|
|
|
IsComplete = 'Y', |
|
|
|
CreationTime = DateTime.Now, |
|
|
|
}; |
|
|
|
|
|
|
|
sql = @"insert into qztl_import_data(id, data, data_type, is_complete,creation_time)
|
|
|
|
values(@Id, @Data, @DataType, @IsComplete,@CreationTime)";
|
|
|
|
conn.Execute(sql, qztlImportDataEntity); |
|
|
|
|
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
return ; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |