5 changed files with 327 additions and 0 deletions
-
61src/Shentun.Peis.Application.Contracts/DirectorManagement/GetPatientListDto.cs
-
30src/Shentun.Peis.Application.Contracts/DirectorManagement/GetPatientListInputDto.cs
-
33src/Shentun.Peis.Application.Contracts/DirectorManagement/GetRevenueReportDto.cs
-
25src/Shentun.Peis.Application.Contracts/DirectorManagement/GetRevenueReportInputDto.cs
-
178src/Shentun.Peis.Application/DirectorManagements/DirectorManagementAppService.cs
@ -0,0 +1,61 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.DirectorManagement |
||||
|
{ |
||||
|
public class GetPatientListDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 姓名
|
||||
|
/// </summary>
|
||||
|
public string PatientName { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检日期
|
||||
|
/// </summary>
|
||||
|
public string MedicalStartDate { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检状态
|
||||
|
/// </summary>
|
||||
|
public string CompleteFlag { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检次数
|
||||
|
/// </summary>
|
||||
|
public short MedicalTimes { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 性别
|
||||
|
/// </summary>
|
||||
|
public string SexName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 年龄
|
||||
|
/// </summary>
|
||||
|
public string Age { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 婚姻状况
|
||||
|
/// </summary>
|
||||
|
public string MaritalStatusName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 民族
|
||||
|
/// </summary>
|
||||
|
public string NationName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 身份证号码
|
||||
|
/// </summary>
|
||||
|
public string IdNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 手机号码
|
||||
|
/// </summary>
|
||||
|
public string MobileTelephone { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.DirectorManagement |
||||
|
{ |
||||
|
public class GetPatientListInputDto |
||||
|
{ |
||||
|
public string IdNo { get; set; } |
||||
|
|
||||
|
public string PatientName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 日期类型(1、登记日期 2、体检日期 3、总检日期)
|
||||
|
/// </summary>
|
||||
|
public char? DateType { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 开始日期
|
||||
|
/// </summary>
|
||||
|
public string StartDate { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 结束日期
|
||||
|
/// </summary>
|
||||
|
public string EndDate { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.DirectorManagement |
||||
|
{ |
||||
|
public class GetRevenueReportDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 标准价格统计金额
|
||||
|
/// </summary>
|
||||
|
public decimal StandardMoney { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 实收价格统计金额
|
||||
|
/// </summary>
|
||||
|
public decimal ChargeMoney { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 体检人数
|
||||
|
/// </summary>
|
||||
|
public int SumCount { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 个人体检数量
|
||||
|
/// </summary>
|
||||
|
public int PersonCount { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 单位体检数量
|
||||
|
/// </summary>
|
||||
|
public int CustomerOrgCount { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.DirectorManagement |
||||
|
{ |
||||
|
public class GetRevenueReportInputDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 收费标记 查询所有传 null
|
||||
|
/// </summary>
|
||||
|
public char? IsCharge { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 开始日期
|
||||
|
/// </summary>
|
||||
|
public string StartDate { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 结束日期
|
||||
|
/// </summary>
|
||||
|
public string EndDate { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,178 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal; |
||||
|
using NPOI.POIFS.Storage; |
||||
|
using Shentun.Peis.DirectorManagement; |
||||
|
using Shentun.Peis.Enums; |
||||
|
using Shentun.Peis.Models; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Net.Http.Headers; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
|
||||
|
namespace Shentun.Peis.DirectorManagements |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 主任管理报表数据
|
||||
|
/// </summary>
|
||||
|
[ApiExplorerSettings(GroupName = "Work")] |
||||
|
[Authorize] |
||||
|
public class DirectorManagementAppService : ApplicationService |
||||
|
{ |
||||
|
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository; |
||||
|
private readonly IRepository<Patient, Guid> _patientRepository; |
||||
|
private readonly CacheService _cacheService; |
||||
|
private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository; |
||||
|
private readonly IRepository<RegisterCheckAsbitem, Guid> _registerCheckAsbitemRepository; |
||||
|
public DirectorManagementAppService( |
||||
|
IRepository<PatientRegister, Guid> patientRegisterRepository, |
||||
|
IRepository<Patient, Guid> patientRepository, |
||||
|
CacheService cacheService, |
||||
|
IRepository<RegisterCheck, Guid> registerCheckRepository, |
||||
|
IRepository<RegisterCheckAsbitem, Guid> registerCheckAsbitemRepository) |
||||
|
{ |
||||
|
_patientRegisterRepository = patientRegisterRepository; |
||||
|
_patientRepository = patientRepository; |
||||
|
_cacheService = cacheService; |
||||
|
_registerCheckRepository = registerCheckRepository; |
||||
|
_registerCheckAsbitemRepository = registerCheckAsbitemRepository; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 查询客户信息
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/DirectorManagement/GetPatientList")] |
||||
|
public async Task<List<GetPatientListDto>> GetPatientListAsync(GetPatientListInputDto input) |
||||
|
{ |
||||
|
var query = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() |
||||
|
join patient in await _patientRepository.GetQueryableAsync() on patientRegister.PatientId equals patient.Id |
||||
|
select new |
||||
|
{ |
||||
|
idNo = patient.IdNo, |
||||
|
mobileTelephone = patient.MobileTelephone, |
||||
|
nationId = patient.NationId, |
||||
|
patientRegister |
||||
|
}; |
||||
|
if (!string.IsNullOrWhiteSpace(input.IdNo)) |
||||
|
{ |
||||
|
query = query.Where(m => m.idNo == input.IdNo); |
||||
|
} |
||||
|
if (!string.IsNullOrWhiteSpace(input.PatientName)) |
||||
|
{ |
||||
|
query = query.Where(m => m.patientRegister.PatientName == input.PatientName); |
||||
|
} |
||||
|
if (input.DateType != null |
||||
|
&& !string.IsNullOrWhiteSpace(input.StartDate) |
||||
|
&& !string.IsNullOrWhiteSpace(input.EndDate)) |
||||
|
{ |
||||
|
if (input.DateType == '1') |
||||
|
{ |
||||
|
query = query.Where(m => m.patientRegister.CreationTime >= Convert.ToDateTime(input.StartDate) |
||||
|
&& m.patientRegister.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
||||
|
} |
||||
|
else if (input.DateType == '2') |
||||
|
{ |
||||
|
query = query.Where(m => m.patientRegister.MedicalStartDate != null |
||||
|
&& m.patientRegister.MedicalStartDate.Value >= Convert.ToDateTime(input.StartDate) |
||||
|
&& m.patientRegister.MedicalStartDate.Value < Convert.ToDateTime(input.EndDate).AddDays(1)); |
||||
|
} |
||||
|
else if (input.DateType == '3') |
||||
|
{ |
||||
|
query = query.Where(m => m.patientRegister.SummaryDate != null |
||||
|
&& m.patientRegister.SummaryDate.Value >= Convert.ToDateTime(input.StartDate) |
||||
|
&& m.patientRegister.SummaryDate.Value < Convert.ToDateTime(input.EndDate).AddDays(1)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
var entListDto = query.ToList().Select(s => new GetPatientListDto |
||||
|
{ |
||||
|
Age = s.patientRegister.Age == null ? "" : s.patientRegister.Age.Value.ToString(), |
||||
|
CompleteFlag = s.patientRegister.CompleteFlag.ToString(), |
||||
|
IdNo = s.idNo, |
||||
|
MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(s.patientRegister.MaritalStatusId).GetAwaiter().GetResult(), |
||||
|
MedicalStartDate = DataHelper.ConversionDateToString(s.patientRegister.MedicalStartDate), |
||||
|
MedicalTimes = s.patientRegister.MedicalTimes, |
||||
|
MobileTelephone = s.mobileTelephone, |
||||
|
NationName = _cacheService.GetNationNameAsync(s.nationId).GetAwaiter().GetResult(), |
||||
|
PatientName = s.patientRegister.PatientName, |
||||
|
SexName = _cacheService.GetSexNameAsync(s.patientRegister.SexId).GetAwaiter().GetResult() |
||||
|
}).ToList(); |
||||
|
|
||||
|
return entListDto; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收入统计 查询某个时间断
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/DirectorManagement/GetRevenueReport")] |
||||
|
public async Task<GetRevenueReportDto> GetRevenueReportAsync(GetRevenueReportInputDto input) |
||||
|
{ |
||||
|
if (string.IsNullOrWhiteSpace(input.StartDate) || string.IsNullOrWhiteSpace(input.EndDate)) |
||||
|
{ |
||||
|
throw new UserFriendlyException("请选择查询时间段"); |
||||
|
} |
||||
|
var query = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() |
||||
|
join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId |
||||
|
join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId |
||||
|
where patientRegister.MedicalStartDate != null |
||||
|
&& patientRegister.MedicalStartDate.Value >= Convert.ToDateTime(input.StartDate) |
||||
|
&& patientRegister.MedicalStartDate.Value < Convert.ToDateTime(input.EndDate).AddDays(1) |
||||
|
select new |
||||
|
{ |
||||
|
patientRegisterId = patientRegister.Id, |
||||
|
customerOrgId = patientRegister.CustomerOrgId, |
||||
|
ischarge = registerCheckAsbitem.IsCharge, |
||||
|
standardPrice = registerCheckAsbitem.StandardPrice, |
||||
|
chargePrice = registerCheckAsbitem.ChargePrice, |
||||
|
amount = registerCheckAsbitem.Amount |
||||
|
}; |
||||
|
|
||||
|
if (input.IsCharge != null) |
||||
|
{ |
||||
|
query = query.Where(m => m.ischarge == input.IsCharge); |
||||
|
} |
||||
|
|
||||
|
var queryList = query.ToList(); |
||||
|
|
||||
|
if (queryList.Count == 0) |
||||
|
{ |
||||
|
return new GetRevenueReportDto |
||||
|
{ |
||||
|
ChargeMoney = 0, |
||||
|
CustomerOrgCount = 0, |
||||
|
PersonCount = 0, |
||||
|
StandardMoney = 0, |
||||
|
SumCount = 0 |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
var chargeMoney = queryList.Sum(s => s.chargePrice * s.amount); |
||||
|
var standardMoney = queryList.Sum(s => s.standardPrice * s.amount); |
||||
|
var sumCount = queryList.GroupBy(g => g.patientRegisterId).Count(); |
||||
|
var customerOrgCount = queryList.Where(m => m.customerOrgId != GuidFlag.PersonCustomerOrgId).GroupBy(g => g.patientRegisterId).Count(); |
||||
|
var personCount = queryList.Where(m => m.customerOrgId == GuidFlag.PersonCustomerOrgId).GroupBy(g => g.patientRegisterId).Count(); |
||||
|
var entDto = new GetRevenueReportDto |
||||
|
{ |
||||
|
ChargeMoney = chargeMoney, |
||||
|
StandardMoney = standardMoney, |
||||
|
SumCount = sumCount, |
||||
|
CustomerOrgCount = customerOrgCount, |
||||
|
PersonCount = personCount |
||||
|
}; |
||||
|
|
||||
|
return entDto; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue