DESKTOP-G961P6V\Zhh 1 year ago
parent
commit
6cb43bd667
  1. 41
      src/Shentun.WebPeis.Application.Contracts/AppointReports/CustomerOrgInputDto.cs
  2. 34
      src/Shentun.WebPeis.Application.Contracts/AppointReports/GetAppointStatisticsReportDto.cs
  3. 120
      src/Shentun.WebPeis.Application/AppointReports/AppointReportAppService.cs

41
src/Shentun.WebPeis.Application.Contracts/AppointReports/CustomerOrgInputDto.cs

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Shentun.WebPeis.AppointReports
{
public class CustomerOrgInputDto
{
/// <summary>
/// 单位ID 需要包含查出子级ID
/// </summary>
public Guid CustomerOrgId { get; set; }
/// <summary>
/// 单位体检次数ID
/// </summary>
public Guid CustomerOrgRegisterId { get; set; }
/// <summary>
///
/// </summary>
public List<Guid> CustomerOrgGroupId { get; set; } = new List<Guid>();
/// <summary>
/// 日期类型(1、登记日期 2、体检日期 3、总检日期)
/// </summary>
public char DateType { get; set; }
/// <summary>
/// 开始日期
/// </summary>
public string StartDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public string EndDate { get; set; }
}
}

34
src/Shentun.WebPeis.Application.Contracts/AppointReports/GetAppointStatisticsReportDto.cs

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointReports
{
public class GetAppointStatisticsReportDto
{
/// <summary>
/// 单位名称
/// </summary>
public string CustomerOrgName { get; set; }
/// <summary>
/// 登记人数 备单人数
/// </summary>
public int RegisterCount { get; set; }
/// <summary>
/// 预约人数
/// </summary>
public int AppointCount { get; set;}
/// <summary>
/// 未预约人数
/// </summary>
public int UnAppointCount { get; set; }
/// <summary>
/// 已开始检查人数
/// </summary>
public int CheckCount { get; set; }
}
}

120
src/Shentun.WebPeis.Application/AppointReports/AppointReportAppService.cs

@ -0,0 +1,120 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Shentun.WebPeis.Models;
using System;
using System.Collections.Generic;
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.WebPeis.AppointReports
{
/// <summary>
/// 统计
/// </summary>
[ApiExplorerSettings(GroupName = "Work")]
//[Authorize]
public class AppointReportAppService : ApplicationService
{
private readonly IRepository<AppointPatientRegister> _appointPatientRegisterRepository;
private readonly IRepository<PatientRegister> _patientRegisterRepository;
private readonly IRepository<CustomerOrg> _customerOrgRepository;
private readonly IRepository<CustomerOrgRegister> _customerOrgRegisterRepository;
public AppointReportAppService(
IRepository<AppointPatientRegister> appointPatientRegisterRepository,
IRepository<PatientRegister> patientRegisterRepository,
IRepository<CustomerOrg> customerOrgRepository,
IRepository<CustomerOrgRegister> customerOrgRegisterRepository)
{
_appointPatientRegisterRepository = appointPatientRegisterRepository;
_patientRegisterRepository = patientRegisterRepository;
_customerOrgRepository = customerOrgRepository;
_customerOrgRegisterRepository = customerOrgRegisterRepository;
}
/// <summary>
/// 获取预约统计报表
/// </summary>
/// <returns></returns>
[HttpPost("api/app/AppointReport/GetAppointStatisticsReport")]
public async Task<List<GetAppointStatisticsReportDto>> GetAppointStatisticsReportAsync(List<CustomerOrgInputDto> input)
{
List<GetAppointStatisticsReportDto> result = new List<GetAppointStatisticsReportDto>();
if (!input.Any())
throw new UserFriendlyException("请选择单位");
foreach (var item in input)
{
var query = from patientRegister in await _patientRegisterRepository.GetQueryableAsync()
join appointPatientRegister in await _appointPatientRegisterRepository.GetQueryableAsync()
on patientRegister.PatientRegisterId equals appointPatientRegister.PatientRegisterId into appointPatientRegisterTemp
from appointPatientRegisterEmpty in appointPatientRegisterTemp.DefaultIfEmpty()
join customerOrgRegister in await _customerOrgRegisterRepository.GetQueryableAsync()
on patientRegister.CustomerOrgRegisterId equals customerOrgRegister.CustomerOrgRegisterId
join customerOrg in await _customerOrgRepository.GetQueryableAsync()
on customerOrgRegister.CustomerOrgId equals customerOrg.CustomerOrgId
select new
{
patientRegister,
appointPatientRegisterEmpty,
customerOrg
};
if (item.CustomerOrgId == Guid.Empty)
throw new UserFriendlyException("单位不能为空");
if (item.CustomerOrgRegisterId == Guid.Empty)
throw new UserFriendlyException("单位体检次数不能为空");
query = query.Where(m => m.patientRegister.CustomerOrgRegisterId == item.CustomerOrgRegisterId);
if (item.CustomerOrgGroupId.Any())
query = query.Where(m => m.patientRegister.CustomerOrgGroupId != null
&& item.CustomerOrgGroupId.Contains(m.patientRegister.CustomerOrgGroupId.Value));
if (!string.IsNullOrEmpty(item.StartDate) && !string.IsNullOrEmpty(item.EndDate))
{
if (item.DateType == '1')
{
query = query.Where(m => m.patientRegister.CreationTime >= Convert.ToDateTime(item.StartDate) &&
m.patientRegister.CreationTime < Convert.ToDateTime(item.EndDate).AddDays(1));
}
else if (item.DateType == '2')
{
query = query.Where(m => m.patientRegister.MedicalStartDate >= Convert.ToDateTime(item.StartDate) &&
m.patientRegister.MedicalStartDate < Convert.ToDateTime(item.EndDate).AddDays(1));
}
else if (item.DateType == '3')
{
query = query.Where(m => m.patientRegister.SummaryDate != null && m.patientRegister.SummaryDate >= Convert.ToDateTime(item.StartDate) &&
m.patientRegister.SummaryDate < Convert.ToDateTime(item.EndDate).AddDays(1));
}
}
var customerOrgGroup = query.ToList().GroupBy(g => g.customerOrg);
var appointStatisticsReports = customerOrgGroup.Select(s => new GetAppointStatisticsReportDto
{
CustomerOrgName = s.Key.CustomerOrgName,
AppointCount = s.Where(m => m.appointPatientRegisterEmpty != null).Count(),
CheckCount = s.Where(m => m.patientRegister.IsMedicalStart == 'Y').Count(),
RegisterCount = s.Count(),
UnAppointCount = s.Count() - s.Where(m => m.appointPatientRegisterEmpty != null).Count()
}).ToList();
result.AddRange(appointStatisticsReports);
}
return result;
}
}
}
Loading…
Cancel
Save