diff --git a/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetPatientListDto.cs b/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetPatientListDto.cs new file mode 100644 index 0000000..f436e20 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetPatientListDto.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.DirectorManagement +{ + public class GetPatientListDto + { + /// + /// 姓名 + /// + public string PatientName { get; set; } + + + /// + /// 体检日期 + /// + public string MedicalStartDate { get; set; } + + /// + /// 体检状态 + /// + public string CompleteFlag { get; set; } + + + /// + /// 体检次数 + /// + public short MedicalTimes { get; set; } + + /// + /// 性别 + /// + public string SexName { get; set; } + + /// + /// 年龄 + /// + public string Age { get; set; } + + /// + /// 婚姻状况 + /// + public string MaritalStatusName { get; set; } + + /// + /// 民族 + /// + public string NationName { get; set; } + + /// + /// 身份证号码 + /// + public string IdNo { get; set; } + + /// + /// 手机号码 + /// + public string MobileTelephone { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetPatientListInputDto.cs b/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetPatientListInputDto.cs new file mode 100644 index 0000000..e7ddee9 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetPatientListInputDto.cs @@ -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; } + + /// + /// 日期类型(1、登记日期 2、体检日期 3、总检日期) + /// + public char? DateType { get; set; } + + /// + /// 开始日期 + /// + public string StartDate { get; set; } + + + /// + /// 结束日期 + /// + public string EndDate { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetRevenueReportDto.cs b/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetRevenueReportDto.cs new file mode 100644 index 0000000..6c9b445 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetRevenueReportDto.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.DirectorManagement +{ + public class GetRevenueReportDto + { + /// + /// 标准价格统计金额 + /// + public decimal StandardMoney { get; set; } + /// + /// 实收价格统计金额 + /// + public decimal ChargeMoney { get; set; } + + /// + /// 体检人数 + /// + public int SumCount { get; set; } + + /// + /// 个人体检数量 + /// + public int PersonCount { get; set; } + + /// + /// 单位体检数量 + /// + public int CustomerOrgCount { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetRevenueReportInputDto.cs b/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetRevenueReportInputDto.cs new file mode 100644 index 0000000..b822b3e --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/DirectorManagement/GetRevenueReportInputDto.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.DirectorManagement +{ + public class GetRevenueReportInputDto + { + /// + /// 收费标记 查询所有传 null + /// + public char? IsCharge { get; set; } + + /// + /// 开始日期 + /// + public string StartDate { get; set; } + + + /// + /// 结束日期 + /// + public string EndDate { get; set; } + } +} diff --git a/src/Shentun.Peis.Application/DirectorManagements/DirectorManagementAppService.cs b/src/Shentun.Peis.Application/DirectorManagements/DirectorManagementAppService.cs new file mode 100644 index 0000000..7fc3be0 --- /dev/null +++ b/src/Shentun.Peis.Application/DirectorManagements/DirectorManagementAppService.cs @@ -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 +{ + /// + /// 主任管理报表数据 + /// + [ApiExplorerSettings(GroupName = "Work")] + [Authorize] + public class DirectorManagementAppService : ApplicationService + { + private readonly IRepository _patientRegisterRepository; + private readonly IRepository _patientRepository; + private readonly CacheService _cacheService; + private readonly IRepository _registerCheckRepository; + private readonly IRepository _registerCheckAsbitemRepository; + public DirectorManagementAppService( + IRepository patientRegisterRepository, + IRepository patientRepository, + CacheService cacheService, + IRepository registerCheckRepository, + IRepository registerCheckAsbitemRepository) + { + _patientRegisterRepository = patientRegisterRepository; + _patientRepository = patientRepository; + _cacheService = cacheService; + _registerCheckRepository = registerCheckRepository; + _registerCheckAsbitemRepository = registerCheckAsbitemRepository; + } + + /// + /// 查询客户信息 + /// + /// + [HttpPost("api/app/DirectorManagement/GetPatientList")] + public async Task> 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; + } + + + /// + /// 收入统计 查询某个时间断 + /// + /// + /// + [HttpPost("api/app/DirectorManagement/GetRevenueReport")] + public async Task 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; + } + + + } +}