From 21802e3bfdb8c378aa5475c7c42acfa742ba782c Mon Sep 17 00:00:00 2001 From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com> Date: Mon, 13 May 2024 05:22:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=9D=92=E8=97=8F=E9=93=81?= =?UTF-8?q?=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImportPatientRegisterPlugInsGem.cs | 533 +++++++++++++++++- .../QztlPatientRegisterFromInterface.cs | 2 +- .../PlugInsBase.cs | 13 +- .../CreateCustomerOrgGroupWithDetailDto.cs | 28 + .../CustomerOrgs/CustomerOrgIdInputDto.cs | 11 + .../DisplayNameInputDto.cs | 11 + .../CustomerOrgGroupAppService.cs | 49 +- .../CustomerOrgRegisterAppService.cs | 30 + .../CustomerOrgs/CustomerOrgAppService.cs | 32 ++ .../MedicalTypes/MedicalTypeAppService.cs | 17 + .../PersonnelTypes/PersonnelTypeAppService.cs | 40 ++ .../CustomerOrgGroupManager.cs | 3 +- .../CustomerOrgs/CustomerOrgManager.cs | 9 +- 13 files changed, 768 insertions(+), 10 deletions(-) create mode 100644 src/Shentun.Peis.Application.Contracts/CustomerOrgGroups/CreateCustomerOrgGroupWithDetailDto.cs create mode 100644 src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgIdInputDto.cs create mode 100644 src/Shentun.Peis.Application.Contracts/DisplayNameInputDto.cs diff --git a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportPatientRegisterPlugInsGem.cs b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportPatientRegisterPlugInsGem.cs index 2077982..2e5f80c 100644 --- a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportPatientRegisterPlugInsGem.cs +++ b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportPatientRegisterPlugInsGem.cs @@ -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 _personnelTypes; + private List _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( + "api/app/MedicalType/GetByDisplayName", new DisplayNameInputDto() { DisplayName = medicalTypeName }); + if (medicalTypeDto == null) + { + var createMedicalTypeDto = new CreateMedicalTypeDto() + { + DisplayName = medicalTypeName, + }; + medicalTypeDto = await CallAppServiceAsync( + "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>( + "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( + "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>( + "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 groupNames = new List(); + 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(); + //获取分组信息 + var customerOrgGroupDetailOrAsbitemDtos = await CallAppServiceAsync>( + "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>( + "api/PatientRegister/CreatePatientRegister", + patientRegister); } @@ -98,6 +296,20 @@ namespace Shentun.Peis.PlugIns.Gem _year = year; } + //加载单位信息 + _customerOrgDto = await CallAppServiceAsync( + "api/app/CustomerOrg/GetById", new CustomerOrgIdInputDto() + { + CustomerOrgId = _importCustomerOrgId, + }); + //加载单位登记信息 + _customerOrgRegisterDto = await CallAppServiceAsync( + "api/app/CustomerOrgRegister/GetLastCustomerOrgRegisterByCustomerOrgId", new CustomerOrgIdInputDto() + { + CustomerOrgId = _importCustomerOrgId, + }); + //加载人员类别列表 + var _personnelTypes = await CallAppServiceAsync>("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(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 GetCustomerOrgGroup(List 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>( + "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>( + "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>( + "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( + "api/app/CustomerOrgGroup/CreateCustomerOrgGroupWithDetail", createCustomerOrgGroupWithDetailDto); + return customerOrgGroup; + } + + + public async Task NoteOk(List successIds, List 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 ; + } + + } + } + } } } diff --git a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/QztlPatientRegisterFromInterface.cs b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/QztlPatientRegisterFromInterface.cs index 8c09251..36817c4 100644 --- a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/QztlPatientRegisterFromInterface.cs +++ b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/QztlPatientRegisterFromInterface.cs @@ -39,7 +39,7 @@ namespace Shentun.Peis.PlugIns.Gem /// /// 年龄 int /// - public int age { get; set; } + public short age { get; set; } /// /// 身份证号 /// diff --git a/src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs b/src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs index cc98349..fa04724 100644 --- a/src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs +++ b/src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs @@ -124,7 +124,7 @@ namespace Shentun.Peis.PlugIns return conn; } - public async Task CallAppServiceAsync(string url, TInput data) + public async Task CallAppServiceAsync(string url, TInput data,string method = "post") { string baseAddress = _appBaseAddress; using (var httpClientHandler = new HttpClientHandler()) @@ -142,7 +142,16 @@ namespace Shentun.Peis.PlugIns using (HttpContent httpContent = new StringContent(sendData)) { httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); - HttpResponseMessage response = await httpClient.PostAsync(url, httpContent); + HttpResponseMessage response = null; + if (method == "post") + { + response = await httpClient.PostAsync(url, httpContent); + } + else + { + response = await httpClient.GetAsync(url); + } + string result; if (!response.IsSuccessStatusCode) { diff --git a/src/Shentun.Peis.Application.Contracts/CustomerOrgGroups/CreateCustomerOrgGroupWithDetailDto.cs b/src/Shentun.Peis.Application.Contracts/CustomerOrgGroups/CreateCustomerOrgGroupWithDetailDto.cs new file mode 100644 index 0000000..f4f8c75 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/CustomerOrgGroups/CreateCustomerOrgGroupWithDetailDto.cs @@ -0,0 +1,28 @@ +using Shentun.Peis.CustomerOrgGroupDetails; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.CustomerOrgGroups +{ + public class CreateCustomerOrgGroupWithDetailDto : CreateCustomerOrgGroupDto + { + /// + /// 是否使用最后一次的体检次数 单位ID 跟体检次数ID 二选一 + /// + public char IsMaxMedicalTimes { get; set; } = 'Y'; + + /// + /// 单位ID + /// + public Guid? CustomerOrgId { get; set; } + + /// + /// 体检次数ID + /// + public Guid? CustomerOrgRegisterId { get; set; } + + public List Details { get; set; } = new List(); + + } +} diff --git a/src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgIdInputDto.cs b/src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgIdInputDto.cs new file mode 100644 index 0000000..1fe44a9 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgIdInputDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.CustomerOrgs +{ + public class CustomerOrgIdInputDto + { + public Guid CustomerOrgId { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/DisplayNameInputDto.cs b/src/Shentun.Peis.Application.Contracts/DisplayNameInputDto.cs new file mode 100644 index 0000000..d42d09e --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/DisplayNameInputDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis +{ + public class DisplayNameInputDto + { + public string DisplayName { get; set; } + } +} diff --git a/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs b/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs index cc17fbd..8c1307b 100644 --- a/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Shentun.Peis.CustomerOrgGroupDetails; using Shentun.Peis.CustomerOrgGroups; +using Shentun.Peis.CustomerOrgs; using Shentun.Peis.HelperDto; using Shentun.Peis.Models; using Shentun.Peis.PatientRegisters; @@ -40,13 +41,15 @@ namespace Shentun.Peis.CustomerOrgGroups private readonly IRepository _userRepository; private readonly CustomerOrgGroupManager _manager; private readonly CacheService _cacheService; + private readonly CustomerOrgGroupDetailManager _customerOrgGroupDetailManager; public CustomerOrgGroupAppService( IRepository repository, IRepository customerOrgRegisterRepository, ICustomerOrgGroupDetailRepository customerOrgGroupDetailRepository, IRepository userRepository, CustomerOrgGroupManager manager, - CacheService cacheService) + CacheService cacheService, + CustomerOrgGroupDetailManager customerOrgGroupDetailManager) : base(repository) { this._customerOrgRegisterRepository = customerOrgRegisterRepository; @@ -54,6 +57,7 @@ namespace Shentun.Peis.CustomerOrgGroups _userRepository = userRepository; _manager = manager; _cacheService = cacheService; + _customerOrgGroupDetailManager = customerOrgGroupDetailManager; } /// /// 获取通过主键 @@ -70,6 +74,8 @@ namespace Shentun.Peis.CustomerOrgGroups } + + /// /// 获取列表 团检分组 /// @@ -212,6 +218,45 @@ namespace Shentun.Peis.CustomerOrgGroups var dto = ObjectMapper.Map(entity); return dto; } + [HttpPost("api/app/CustomerOrgGroup/CreateCustomerOrgGroupWithDetail")] + public async Task CreateCustomerOrgGroupWithDetailAsync(CreateCustomerOrgGroupWithDetailDto input) + { + + + var createEntity = ObjectMapper.Map(input); + var entity = await _manager.CreateAsync(input.IsMaxMedicalTimes, input.CustomerOrgRegisterId, input.CustomerOrgId, createEntity); + + //检查体检次数是否完成 + await _manager.CheckCustomerOrgRegisterStatus(entity.CustomerOrgRegisterId); + + entity = await Repository.InsertAsync(entity); + + //插入明细 + + + if (input.Details.Any()) + { + var createEntityList = ObjectMapper.Map, List>(input.Details); + var list = new List(); + foreach (var item in createEntityList) + { + item.CustomerOrgGroupId = entity.Id; + var customerOrgGroupDetail = _customerOrgGroupDetailManager.CreateAsync(item); + list.Add(customerOrgGroupDetail); + } + var sumMonkey = list.Sum(o => o.Price * o.Amount); + entity.Price = sumMonkey; + entity = await Repository.InsertAsync(entity); + + await _customerOrgGroupDetailRepository.InsertManyAsync(list); + } + + + var dto = ObjectMapper.Map(entity); + return dto; + } + + /// /// 更新 /// @@ -334,7 +379,7 @@ namespace Shentun.Peis.CustomerOrgGroups if (CustomerOrgRegisterId != Guid.Empty) { var entlist = await Repository.GetListAsync(m => m.CustomerOrgRegisterId == CustomerOrgRegisterId); - var userList = await _userRepository.GetListAsync(); + //var userList = await _userRepository.GetListAsync(); var entdto = entlist.Select(s => new CustomerOrgGroupDto { CreationTime = s.CreationTime, diff --git a/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs b/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs index ec508c4..f5d6b4a 100644 --- a/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs @@ -210,7 +210,37 @@ namespace Shentun.Peis.CustomerOrgRegisters } + /// + /// + /// + /// + /// + [HttpPost("api/app/CustomerOrgRegister/GetLastCustomerOrgRegisterByCustomerOrgId")] + public async Task GetLastCustomerOrgRegisterByCustomerOrgId(CustomerOrgIdInputDto input) + { + var entity = (await Repository.GetQueryableAsync()).Where(m => m.CustomerOrgId == input.CustomerOrgId) + .OrderByDescending(o=>o.MedicalTimes).FirstOrDefault(); + var entdto = new CustomerOrgRegisterDto() + { + CreationTime = entity.CreationTime, + CreatorId = entity.CreatorId, + Id = entity.Id, + LastModificationTime = entity.LastModificationTime, + LastModifierId = entity.LastModifierId, + BeginTime = DataHelper.ConversionDateToString(entity.BeginTime), + EndTime = DataHelper.ConversionDateToString(entity.EndTime), + RegisterName = entity.RegisterName, + RegisterNo = entity.RegisterNo, + MedicalTimes = entity.MedicalTimes, + IsComplete = entity.IsComplete, + CustomerOrgId = entity.CustomerOrgId, + CreatorName = _cacheService.GetSurnameAsync(entity.CreatorId).Result, + LastModifierName = _cacheService.GetSurnameAsync(entity.LastModifierId).Result + }; + + return entdto; + } } } diff --git a/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs b/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs index 1ea8538..67d609b 100644 --- a/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs @@ -5,6 +5,7 @@ using Shentun.Peis.Enums; using Shentun.Peis.HelperDto; using Shentun.Peis.Models; using Shentun.Peis.OrganizationUnits; +using Shentun.Peis.PersonnelTypes; using System; using System.Collections.Generic; using System.Linq; @@ -12,8 +13,10 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; using Volo.Abp.Identity; +using Volo.Abp.ObjectMapping; namespace Shentun.Peis.CustomerOrgs { @@ -63,6 +66,35 @@ namespace Shentun.Peis.CustomerOrgs entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId); return entityDto; } + [HttpPost("api/app/CustomerOrg/GetById")] + public async Task GetByIdAsync(CustomerOrgIdInputDto input) + { + var entity = await Repository.GetAsync(input.CustomerOrgId); + var entityDto = ObjectMapper.Map(entity); + entityDto.CreatorName = await _cacheService.GetSurnameAsync(entityDto.CreatorId); + entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId); + return entityDto; + } + /// + /// 获取所有一级子单位 + /// + /// + /// + [HttpPost("api/app/CustomerOrg/GetChildCustomerOrgsById")] + public async Task> GetChildCustomerOrgsByIdAsync(CustomerOrgIdInputDto input) + { + var list = await Repository.GetListAsync(o=>o.ParentId == input.CustomerOrgId); + var dtos = new List(); + foreach(var customerOrg in list) + { + var entityDto = ObjectMapper.Map(customerOrg); + entityDto.CreatorName = await _cacheService.GetSurnameAsync(entityDto.CreatorId); + entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId); + dtos.Add(entityDto); + } + return dtos; + } + /// /// 获取列表 团检单位设置 /// diff --git a/src/Shentun.Peis.Application/MedicalTypes/MedicalTypeAppService.cs b/src/Shentun.Peis.Application/MedicalTypes/MedicalTypeAppService.cs index e6a8d6d..53c933a 100644 --- a/src/Shentun.Peis.Application/MedicalTypes/MedicalTypeAppService.cs +++ b/src/Shentun.Peis.Application/MedicalTypes/MedicalTypeAppService.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Shentun.Peis.HelperDto; using Shentun.Peis.MedicalReportTypes; using Shentun.Peis.Models; +using Shentun.Peis.PersonnelTypes; using Shentun.Peis.Units; using SqlSugar; using System; @@ -67,6 +68,22 @@ namespace Shentun.Peis.MedicalTypes return entityDto; } /// + /// + /// + /// + /// + [HttpPost("api/app/MedicalType/GetByDisplayName")] + public async Task GetByDisplayNameAsync(DisplayNameInputDto input) + { + var entity = await _medicalTypeRepository.GetAsync(o => o.DisplayName == input.DisplayName); + + var entityDto = ObjectMapper.Map(entity); + entityDto.CreatorName = await _cacheService.GetSurnameAsync(entityDto.CreatorId); + entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId); + + return entityDto; + } + /// /// 获取列表 体检类别 遗弃 /// /// diff --git a/src/Shentun.Peis.Application/PersonnelTypes/PersonnelTypeAppService.cs b/src/Shentun.Peis.Application/PersonnelTypes/PersonnelTypeAppService.cs index 88386c4..adcffb9 100644 --- a/src/Shentun.Peis.Application/PersonnelTypes/PersonnelTypeAppService.cs +++ b/src/Shentun.Peis.Application/PersonnelTypes/PersonnelTypeAppService.cs @@ -66,6 +66,23 @@ namespace Shentun.Peis.PersonnelTypes return entityDto; } + /// + /// + /// + /// + /// + [HttpPost("api/app/PersonnelType/GetByDisplayName")] + public async Task GetByDisplayNameAsync(DisplayNameInputDto input) + { + var entity = await _personnelTypeRepository.GetAsync(o=>o.DisplayName == input.DisplayName); + + var entityDto = ObjectMapper.Map(entity); + entityDto.CreatorName = await _cacheService.GetSurnameAsync(entityDto.CreatorId); + entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId); + + return entityDto; + } + /// /// 获取列表 人员类别 遗弃 /// @@ -107,6 +124,29 @@ namespace Shentun.Peis.PersonnelTypes return entdto; + } + [HttpPost("api/app/PersonnelType/GetAll")] + public async Task> GetAll() + { + var entlist = await Repository.GetQueryableAsync(); + + var entdto = entlist.Select(s => new PersonnelTypeDto + { + CreationTime = s.CreationTime, + CreatorId = s.CreatorId, + DisplayName = s.DisplayName, + DisplayOrder = s.DisplayOrder, + Id = s.Id, + LastModificationTime = s.LastModificationTime, + LastModifierId = s.LastModifierId, + SimpleCode = s.SimpleCode, + CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result, + LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result + }).OrderBy(o => o.DisplayOrder).ToList(); + + return entdto; + + } /// diff --git a/src/Shentun.Peis.Domain/CustomerOrgGroups/CustomerOrgGroupManager.cs b/src/Shentun.Peis.Domain/CustomerOrgGroups/CustomerOrgGroupManager.cs index 0ed7ed8..5aa1e05 100644 --- a/src/Shentun.Peis.Domain/CustomerOrgGroups/CustomerOrgGroupManager.cs +++ b/src/Shentun.Peis.Domain/CustomerOrgGroups/CustomerOrgGroupManager.cs @@ -6,6 +6,7 @@ using Shentun.Peis.Models; using Shentun.Utilities; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -85,7 +86,7 @@ namespace Shentun.Peis.CustomerOrgGroups throw new UserFriendlyException($"不允许有同名的分组名称"); } - return new CustomerOrgGroup + return new CustomerOrgGroup(GuidGenerator.Create()) { DisplayName = entity.DisplayName, AgeLowerLimit = entity.AgeLowerLimit, diff --git a/src/Shentun.Peis.Domain/CustomerOrgs/CustomerOrgManager.cs b/src/Shentun.Peis.Domain/CustomerOrgs/CustomerOrgManager.cs index 02a65f5..d30d251 100644 --- a/src/Shentun.Peis.Domain/CustomerOrgs/CustomerOrgManager.cs +++ b/src/Shentun.Peis.Domain/CustomerOrgs/CustomerOrgManager.cs @@ -29,6 +29,7 @@ namespace Shentun.Peis.CustomerOrgs public class CustomerOrgManager : DomainService { private readonly IRepository _repository; + private readonly IRepository _customerOrgTypeRepository; private readonly IRepository _patientRegisterRepository; private readonly IRepository _customerOrgRegisterRepository; private readonly IRepository _customerOrgGroupRepository; @@ -47,7 +48,8 @@ namespace Shentun.Peis.CustomerOrgs CustomerOrgRegisterManager customerOrgRegisterManager, CustomerOrgGroupManager customerOrgGroupManager, ContactPersonManager contactPersonManager, - PeisOrganizationUnitManager peisOrganizationUnitManager + PeisOrganizationUnitManager peisOrganizationUnitManager, + IRepository customerOrgTypeRepository ) { _repository = repository; @@ -59,6 +61,7 @@ namespace Shentun.Peis.CustomerOrgs this._customerOrgGroupManager = customerOrgGroupManager; this._contactPersonManager = contactPersonManager; _peisOrganizationUnitManager = peisOrganizationUnitManager; + _customerOrgTypeRepository = customerOrgTypeRepository; } /// /// 创建 @@ -69,6 +72,10 @@ namespace Shentun.Peis.CustomerOrgs CustomerOrg entity ) { + if(entity.OrgTypeId == Guid.Empty) + { + entity.OrgTypeId = (await _customerOrgTypeRepository.GetListAsync()).FirstOrDefault().Id; + } await Verify(entity); #region 验证同名 if (await _repository.FirstOrDefaultAsync(m => m.DisplayName == entity.DisplayName && m.ParentId == entity.ParentId) != null)