You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
760 lines
33 KiB
760 lines
33 KiB
using Dapper;
|
|
using Newtonsoft.Json.Converters;
|
|
using Newtonsoft.Json;
|
|
using Npgsql;
|
|
using NPOI.SS.Formula.Functions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
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;
|
|
using Shentun.Peis.Patients;
|
|
|
|
namespace Shentun.Peis.PlugIns.Gem
|
|
{
|
|
public class ImportPatientRegisterPlugInsGem : ImportPatientRegisterPlugInsBase
|
|
{
|
|
private Guid _importCustomerOrgId;
|
|
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)
|
|
{
|
|
|
|
}
|
|
|
|
public override async Task ImportAsync()
|
|
{
|
|
await LoginAsync();
|
|
await InitAsync();
|
|
for (var i = 0; i < 30; i++)
|
|
{
|
|
var qztlPatientRegisterFromInterface = await CallInterfaceServiceAsync();
|
|
if (qztlPatientRegisterFromInterface == null || !qztlPatientRegisterFromInterface.plans.Any())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//设置导入人员信息
|
|
foreach (var patient in qztlPatientRegisterFromInterface.plans)
|
|
{
|
|
try
|
|
{
|
|
//婚姻状况
|
|
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;
|
|
if (!string.IsNullOrWhiteSpace(jobPost) && jobPost.Length >= 10)
|
|
{
|
|
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 = _customerOrgDto.MedicalCenterId,
|
|
ParentId = _importCustomerOrgId,
|
|
DisplayName = orgName,
|
|
ShortName = orgName,
|
|
IsActive = 'Y',
|
|
IsLock = 'Y'
|
|
});
|
|
}
|
|
CustomerOrgGroupDto customerOrgGroupDto;
|
|
if (patient.ifFj == 1)
|
|
{
|
|
//复检
|
|
//加载单位分组信息
|
|
_customerOrgGroupDtos = await CallAppServiceAsync<Guid, List<CustomerOrgGroupDto>>(
|
|
"api/app/customer-org-group/in-customer-org-id/" + _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);
|
|
}
|
|
//获取病人ID
|
|
|
|
var patientRegister = new CreatePatientRegisterDto()
|
|
{
|
|
MedicalCenterId = _customerOrgDto.MedicalCenterId,
|
|
//PatientRegisterId = null,
|
|
//PatientId = null,
|
|
IsMaxMedicalTimes = 'Y',
|
|
CompleteFlag = '0',
|
|
CustomerOrgId = customerOrgDto.Id,
|
|
CustomerOrgRegisterId = _customerOrgRegisterDto.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 (!string.IsNullOrWhiteSpace(patient.cardId))
|
|
{
|
|
var patientInfo = await CallAppServiceAsync<IdNoInputDto, PatientDto>(
|
|
"api/app/patient/GetByIdNo",
|
|
new IdNoInputDto()
|
|
{
|
|
IdNo = patient.cardId
|
|
});
|
|
if (patientInfo != null)
|
|
{
|
|
patientRegister.PatientId = patientInfo.Id;
|
|
}
|
|
|
|
}
|
|
|
|
if (medicalTypeDto != null)
|
|
{
|
|
patientRegister.MedicalTypeId = medicalTypeDto.Id;
|
|
}
|
|
if (personnelType != null)
|
|
{
|
|
patientRegister.PersonnelTypeId = personnelType.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, object>(
|
|
"api/PatientRegister/CreatePatientRegister",
|
|
patientRegister);
|
|
|
|
var succesIds = new List<string>();
|
|
var deleteIds = new List<string>();
|
|
succesIds.Add(patientRegister.Planuserid);
|
|
await NoteOk(succesIds, deleteIds);
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
|
|
if (ex.Message.Contains("人员信息姓名和性别和原来的信息都不一致") ||
|
|
ex.Message.Contains("身份证号解析出的性别与填入的性别不一致"))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
else
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public async Task InitAsync()
|
|
{
|
|
var customerOrgIdStr = InterfaceConfig.GetSection("Interface").GetSection("单位编号").Value;
|
|
_hospitalId = InterfaceConfig.GetSection("Interface").GetSection("HospitalId").Value;
|
|
_aesKEY = InterfaceConfig.GetSection("Interface").GetSection("aesKEY").Value;
|
|
if (string.IsNullOrWhiteSpace(customerOrgIdStr))
|
|
{
|
|
return;
|
|
}
|
|
if (!Guid.TryParse(customerOrgIdStr, out _importCustomerOrgId))
|
|
{
|
|
throw new Exception("单位编号不正确");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(_hospitalId))
|
|
{
|
|
throw new Exception("HospitalId参数不能为空");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(_aesKEY))
|
|
{
|
|
throw new Exception("_aesKEY参数不能为空");
|
|
}
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
|
|
{
|
|
string sql;
|
|
sql = @"
|
|
SELECT id as customer_org_id,
|
|
display_name as customer_org_name,
|
|
parent_id ,
|
|
path_code
|
|
from
|
|
customer_org
|
|
where id = @CustomerOrgId
|
|
";
|
|
var customerOrgForPlugInss = (await conn.QueryAsync<CustomerOrgForPlugIns>(sql,
|
|
new { CustomerOrgId = _importCustomerOrgId })).FirstOrDefault();
|
|
|
|
if (customerOrgForPlugInss == null)
|
|
{
|
|
throw new Exception("单位编号不正确,找不到单位");
|
|
}
|
|
|
|
var year = customerOrgForPlugInss.CustomerOrgName.Substring(
|
|
customerOrgForPlugInss.CustomerOrgName.Length - 5
|
|
, 4);
|
|
if (!int.TryParse(year, out var yearNumber))
|
|
{
|
|
throw new Exception("单位名称必须是以2000年这样的格式结尾");
|
|
}
|
|
if (yearNumber < 2024 || yearNumber > 2050)
|
|
{
|
|
throw new Exception("单位名称年限范围必须在2024-2050之间");
|
|
}
|
|
|
|
_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,
|
|
});
|
|
//加载人员类别列表
|
|
_personnelTypes = await CallAppServiceAsync<string, List<PersonnelTypeDto>>("api/app/PersonnelType/GetAll", "");
|
|
}
|
|
|
|
|
|
public async Task<QztlPatientRegisterFromInterface?> CallInterfaceServiceAsync()
|
|
{
|
|
string baseAddress = InterfaceWebApiUrl;
|
|
string ary = "HospitalId=" + _hospitalId + (Char)38 + "year=" + _year + (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("\\", "");
|
|
if(result.IndexOf("status") < 0)
|
|
{
|
|
throw new Exception($"调用WebApi中无status,返回值:" + result);
|
|
}
|
|
QztlPatientRegisterFromInterface? resultDto = JsonConvert.DeserializeObject<QztlPatientRegisterFromInterface>(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 (QztlPatientRegisterFromInterface)resultDto;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public char ConvertMaritalStatus(int maritalStatus)
|
|
{
|
|
|
|
switch (maritalStatus)
|
|
{
|
|
case 1:
|
|
return '0';
|
|
case 2:
|
|
return '1';
|
|
case 3:
|
|
return '4';
|
|
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 == '0')
|
|
{
|
|
maritalStatusName = "未婚";
|
|
}
|
|
else
|
|
{
|
|
maritalStatusName = "已婚";
|
|
}
|
|
if (sexName == "女")
|
|
{
|
|
groupName += maritalStatusName + sexName;
|
|
}
|
|
else
|
|
{
|
|
groupName += sexName;
|
|
}
|
|
|
|
_customerOrgGroupDtos = await CallAppServiceAsync<Guid, List<CustomerOrgGroupDto>>(
|
|
"api/app/customer-org-group/in-customer-org-id/" + _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("\\", "");
|
|
if (result.IndexOf("更新ok") >= 0 || result.IndexOf("更新OK") >= 0 || result.IndexOf("更新Ok") >= 0)
|
|
{
|
|
return;
|
|
}
|
|
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;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|