using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Shentun.Peis.Enums; using Shentun.Peis.Models; using Shentun.Peis.PlugIns.Sms; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; namespace Shentun.Peis.ThirdBookings { /// /// 第三方预约记录 /// [Authorize] [ApiExplorerSettings(GroupName = "Work")] public class ThirdBookingAppService : ApplicationService { private readonly IRepository _thirdBookingRepository; private readonly IRepository _thirdInterfaceRepository; public ThirdBookingAppService( IRepository thirdBookingRepository, IRepository thirdInterfaceRepository) { _thirdBookingRepository = thirdBookingRepository; _thirdInterfaceRepository = thirdInterfaceRepository; } /// /// 获取人寿预约记录 /// /// /// [HttpPost("api/app/ThirdBooking/GetThirdBookingList")] public async Task> GetThirdBookingListAsync(GetThirdBookingListInputDto input) { Guid? customerOrgRegisterId = null; Guid? customerOrgId = null; var thirdBookingInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(o => o.ThirdInterfaceType == ThirdInterfaceTypeFlag.ThirdBooking); if (thirdBookingInterface != null && thirdBookingInterface.IsActive == 'Y') { var parmValue = thirdBookingInterface.ParmValue; var configurationBuilder = new ConfigurationBuilder() .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); var interfaceConfig = configurationBuilder.Build(); var isActive = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value; var customerOrgRegisterIdPara = interfaceConfig.GetSection("Interface").GetSection("CustomerOrgRegisterId").Value; var customerOrgIdPara = interfaceConfig.GetSection("Interface").GetSection("CustomerOrgId").Value; if (!string.IsNullOrWhiteSpace(isActive) && isActive == "Y") { customerOrgRegisterId = Guid.Parse(customerOrgRegisterIdPara); customerOrgId = Guid.Parse(customerOrgIdPara); } } var query = await _thirdBookingRepository.GetQueryableAsync(); if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.StartDate)) { query = query.Where(m => m.BookingDate >= Convert.ToDateTime(input.StartDate) && m.BookingDate < Convert.ToDateTime(input.EndDate).AddDays(1)); } if (!string.IsNullOrWhiteSpace(input.KeyWord)) { query = query.Where(m => m.PatientName == input.KeyWord || m.IdNo == input.KeyWord || m.Phone == input.KeyWord); } if (input.MedicalStatus != null) { query = query.Where(m => m.MedicalStatus == input.MedicalStatus); } var entListDto = query.Select(s => new GetThirdBookingListDto { ThirdBookingId = s.Id, Age = s.Age, BookingDate = s.BookingDate, CustomerOrgGroupId = s.CustomerOrgGroupId, IdNo = s.IdNo, MedicalStatus = s.MedicalStatus, PatientName = s.PatientName, Phone = s.Phone, SexId = GetSexId(s.SexName), CustomerOrgId = customerOrgId, CustomerOrgRegisterId = customerOrgRegisterId, }).ToList(); return entListDto; } /// /// 转换性别 /// /// private static char GetSexId(string SexName) { char SexId = 'U'; if (SexName == "0" || SexName == "男") { SexId = 'M'; } if (SexName == "1" || SexName == "女") { SexId = 'F'; } return SexId; } } }