Browse Source

单位登记人数金额报表

master
wxd 1 year ago
parent
commit
a1ae71bcda
  1. 77
      src/Shentun.Peis.Application.Contracts/CustomerReports/GetCustomerOrgPhysicalExaminationStatisticsDto.cs
  2. 31
      src/Shentun.Peis.Application.Contracts/CustomerReports/GetCustomerOrgPhysicalExaminationStatisticsInputDto.cs
  3. 87
      src/Shentun.Peis.Application/CustomerReports/CustomerReportAppService.cs

77
src/Shentun.Peis.Application.Contracts/CustomerReports/GetCustomerOrgPhysicalExaminationStatisticsDto.cs

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.CustomerReports
{
public class GetCustomerOrgPhysicalExaminationStatisticsDto
{
/// <summary>
/// 单位名称
/// </summary>
public string CustomerOrgName { get; set; }
/// <summary>
/// 单位Id
/// </summary>
public Guid CustomerOrgId { get; set; }
/// <summary>
/// 人次 登记人数
/// </summary>
public int RegisterCount { get; set; }
/// <summary>
/// 已检人次 总检
/// </summary>
public int CheckCount { get; set; }
/// <summary>
/// 标准均价
/// </summary>
public decimal AvgStandardPrice { get; set; }
/// <summary>
/// 实收均价
/// </summary>
public decimal AvgChargePrice { get; set; }
/// <summary>
/// 标准价格总金额
/// </summary>
public decimal SumStandardPrice { get; set; }
/// <summary>
/// 实收价格总金额
/// </summary>
public decimal SumChargePrice { get; set; }
}
public class GetCustomerOrgPhysicalExaminationStatisticsPatientRegisterGroupDto
{
public Guid PatientRegisterId { get; set; }
public char CompleteFlag { get; set; }
/// <summary>
/// 单位名称
/// </summary>
public string CustomerOrgName { get; set; }
/// <summary>
/// 单位Id
/// </summary>
public Guid CustomerOrgId { get; set; }
/// <summary>
/// 标准
/// </summary>
public decimal StandardPrice { get; set; }
/// <summary>
/// 实收
/// </summary>
public decimal ChargePrice { get; set; }
}
}

31
src/Shentun.Peis.Application.Contracts/CustomerReports/GetCustomerOrgPhysicalExaminationStatisticsInputDto.cs

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Shentun.Peis.CustomerReports
{
public class GetCustomerOrgPhysicalExaminationStatisticsInputDto
{
public List<Guid> CustomerOrgIds { get; set; }
/// <summary>
/// 日期类型(1、登记日期 2、体检日期 3、总检日期)
/// </summary>
[Required(ErrorMessage = "日期类型不能为空")]
public char DateType { get; set; }
/// <summary>
/// 开始日期
/// </summary>
[Required(ErrorMessage = "开始日期不能为空")]
public string StartDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
[Required(ErrorMessage = "结束日期不能为空")]
public string EndDate { get; set; }
}
}

87
src/Shentun.Peis.Application/CustomerReports/CustomerReportAppService.cs

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using NPOI.HPSF;
using NPOI.POIFS.Properties;
using NPOI.POIFS.Storage;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
@ -11,6 +12,7 @@ using NPOI.XSSF.UserModel.Extensions;
using Org.BouncyCastle.Crypto.Tls;
using Shentun.Peis.CustomerOrgs;
using Shentun.Peis.Enums;
using Shentun.Peis.InternalReports;
using Shentun.Peis.Models;
using Shentun.Peis.PeisReports;
using Shentun.Peis.ReportTemplates;
@ -2292,6 +2294,91 @@ namespace Shentun.Peis.CustomerReports
}
/// <summary>
/// 单位体检数据统计
/// </summary>
/// <returns></returns>
[HttpPost("api/app/CustomerReport/GetCustomerOrgPhysicalExaminationStatistics")]
public async Task<List<GetCustomerOrgPhysicalExaminationStatisticsDto>> GetCustomerOrgPhysicalExaminationStatisticsAsync(GetCustomerOrgPhysicalExaminationStatisticsInputDto input)
{
var qeruy = from patientRegister in await _patientRegisterRepository.GetQueryableAsync()
join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId
join registerCheckAsbitem in await _registerAsbitemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId
join customerOrg in await _customerOrgRepository.GetQueryableAsync() on patientRegister.CustomerOrgId equals customerOrg.Id
join customerOrgParent in await _customerOrgRepository.GetQueryableAsync()
on customerOrg.PathCode.Substring(0, 5) equals customerOrgParent.PathCode
select new
{
patientRegister,
registerCheckAsbitem,
customerOrgParent
};
if (input.CustomerOrgIds.Any())
{
List<Guid?> CustomerOrgIds = new List<Guid?>();
foreach (var item in input.CustomerOrgIds)
{
CustomerOrgIds.AddRange(await _customerOrgManager.GetCustomerOrgChildrenId(item));
}
qeruy = qeruy.Where(m => CustomerOrgIds.Contains(m.patientRegister.CustomerOrgId));
}
if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate))
{
if (input.DateType == '1')
{
qeruy = qeruy.Where(m => m.patientRegister.CreationTime >= Convert.ToDateTime(input.StartDate) &&
m.patientRegister.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1));
}
else if (input.DateType == '2')
{
qeruy = qeruy.Where(m => m.patientRegister.MedicalStartDate != null && m.patientRegister.MedicalStartDate >= Convert.ToDateTime(input.StartDate) &&
m.patientRegister.MedicalStartDate < Convert.ToDateTime(input.EndDate).AddDays(1));
}
else if (input.DateType == '3')
{
qeruy = qeruy.Where(m => m.patientRegister.SummaryDate != null && m.patientRegister.SummaryDate >= Convert.ToDateTime(input.StartDate) &&
m.patientRegister.SummaryDate < Convert.ToDateTime(input.EndDate).AddDays(1));
}
}
var patientRegisterGroup = qeruy.ToList().GroupBy(g => g.patientRegister.Id);
var patientRegisterGroupList = patientRegisterGroup.Select(s => new GetCustomerOrgPhysicalExaminationStatisticsPatientRegisterGroupDto
{
PatientRegisterId = s.First().patientRegister.Id,
CompleteFlag = s.First().patientRegister.CompleteFlag,
StandardPrice = s.Sum(ss => ss.registerCheckAsbitem.StandardPrice * ss.registerCheckAsbitem.Amount),
ChargePrice = s.Sum(ss => ss.registerCheckAsbitem.ChargePrice * ss.registerCheckAsbitem.Amount),
CustomerOrgId = s.First().customerOrgParent.Id,
CustomerOrgName = s.First().customerOrgParent.DisplayName,
}).ToList();
var customerOrgGroup = patientRegisterGroupList.GroupBy(g => g.CustomerOrgId);
var customerOrgGrouplist = customerOrgGroup.Select(s => new GetCustomerOrgPhysicalExaminationStatisticsDto
{
CustomerOrgName = s.First().CustomerOrgName,
CustomerOrgId = s.First().CustomerOrgId,
CheckCount = s.Where(m => m.CompleteFlag == PatientRegisterCompleteFlag.SumCheck).Count(),
RegisterCount = s.Count(),
AvgChargePrice = Math.Round(s.Average(v => v.ChargePrice), 2),
AvgStandardPrice = Math.Round(s.Average(v => v.StandardPrice), 2),
SumChargePrice = Math.Round(s.Sum(v => v.ChargePrice), 2),
SumStandardPrice = Math.Round(s.Sum(v => v.StandardPrice), 2)
}).OrderByDescending(o => o.RegisterCount).ToList();
return customerOrgGrouplist;
}

Loading…
Cancel
Save