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.
129 lines
4.7 KiB
129 lines
4.7 KiB
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;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
|
|
namespace Shentun.Peis.ThirdBookings
|
|
{
|
|
/// <summary>
|
|
/// 第三方预约记录
|
|
/// </summary>
|
|
[Authorize]
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
public class ThirdBookingAppService : ApplicationService
|
|
{
|
|
private readonly IRepository<ThirdBooking, Guid> _thirdBookingRepository;
|
|
private readonly IRepository<ThirdInterface, Guid> _thirdInterfaceRepository;
|
|
|
|
public ThirdBookingAppService(
|
|
IRepository<ThirdBooking, Guid> thirdBookingRepository,
|
|
IRepository<ThirdInterface, Guid> thirdInterfaceRepository)
|
|
{
|
|
_thirdBookingRepository = thirdBookingRepository;
|
|
_thirdInterfaceRepository = thirdInterfaceRepository;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取人寿预约记录
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/ThirdBooking/GetThirdBookingList")]
|
|
public async Task<List<GetThirdBookingListDto>> 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);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new UserFriendlyException("请开启第三方预约");
|
|
}
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 转换性别
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private static char GetSexId(string SexName)
|
|
{
|
|
char SexId = 'U';
|
|
if (SexName == "0" || SexName == "男")
|
|
{
|
|
SexId = 'M';
|
|
}
|
|
if (SexName == "1" || SexName == "女")
|
|
{
|
|
SexId = 'F';
|
|
}
|
|
return SexId;
|
|
}
|
|
|
|
|
|
}
|
|
}
|