From c81f885f3445fa618f2e3461827f03656b7046e0 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Tue, 5 Sep 2023 13:36:11 +0800 Subject: [PATCH] bak0905 --- ...tRegistrationPersonnelWorkLoadReportDto.cs | 24 +++++++ ...rationPersonnelWorkLoadReportRequestDto.cs | 24 +++++++ .../InternalReportAppService.cs | 44 +++++++++++- .../OrganizationUnitsAppService.cs | 71 ++++++------------- .../RegisterAsbitemAppService.cs | 1 + .../AsbitemGuides/AsbitemGuideManager.cs | 3 + 6 files changed, 116 insertions(+), 51 deletions(-) create mode 100644 src/Shentun.Peis.Application.Contracts/InternalReports/GetRegistrationPersonnelWorkLoadReportDto.cs create mode 100644 src/Shentun.Peis.Application.Contracts/InternalReports/GetRegistrationPersonnelWorkLoadReportRequestDto.cs diff --git a/src/Shentun.Peis.Application.Contracts/InternalReports/GetRegistrationPersonnelWorkLoadReportDto.cs b/src/Shentun.Peis.Application.Contracts/InternalReports/GetRegistrationPersonnelWorkLoadReportDto.cs new file mode 100644 index 0000000..50a1c90 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/InternalReports/GetRegistrationPersonnelWorkLoadReportDto.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.InternalReports +{ + public class GetRegistrationPersonnelWorkLoadReportDto + { + /// + /// 人员名称 + /// + public string PersonnelName { get; set; } + + /// + /// 登记数量 + /// + public int RegisterCount { get; set; } + + /// + /// 占百分比 + /// + public string Percentage { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/InternalReports/GetRegistrationPersonnelWorkLoadReportRequestDto.cs b/src/Shentun.Peis.Application.Contracts/InternalReports/GetRegistrationPersonnelWorkLoadReportRequestDto.cs new file mode 100644 index 0000000..874667b --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/InternalReports/GetRegistrationPersonnelWorkLoadReportRequestDto.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.InternalReports +{ + public class GetRegistrationPersonnelWorkLoadReportRequestDto + { + /// + /// 登记人员ID 集合 + /// + public List UserIds { get; set;} + + /// + /// 开始登记日期 + /// + public string StartDate { get; set; } + + /// + /// 结束登记日期 + /// + public string EndDate { get; set; } + } +} diff --git a/src/Shentun.Peis.Application/InternalReports/InternalReportAppService.cs b/src/Shentun.Peis.Application/InternalReports/InternalReportAppService.cs index 2ab5166..8f376a8 100644 --- a/src/Shentun.Peis.Application/InternalReports/InternalReportAppService.cs +++ b/src/Shentun.Peis.Application/InternalReports/InternalReportAppService.cs @@ -1,11 +1,15 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Shentun.Peis.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Identity; namespace Shentun.Peis.InternalReports { @@ -16,12 +20,50 @@ namespace Shentun.Peis.InternalReports [Authorize] public class InternalReportAppService : ApplicationService { + private readonly IRepository _userRepository; + private readonly IRepository _patientRegisterRepository; + public InternalReportAppService( + IRepository userRepository, + IRepository patientRegisterRepository ) { + this._userRepository = userRepository; + this._patientRegisterRepository = patientRegisterRepository; } + /// + /// 登记人员工作量统计 + /// + /// + /// + [HttpPost("api/app/internalreport/getregistrationpersonnelworkloadreport")] + public async Task> GetRegistrationPersonnelWorkLoadReportAsync(GetRegistrationPersonnelWorkLoadReportRequestDto input) + { + var query = (from a in await _patientRegisterRepository.GetQueryableAsync() + join b in await _userRepository.GetQueryableAsync() on a.CreatorId equals b.Id into bb + from ab in bb.DefaultIfEmpty() + where (a.CreationTime >= Convert.ToDateTime(input.StartDate) && + a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)) + select new { a, PersonnelName = ab != null ? ab.UserName : "" }); + + var sumCount = query.Count(); //总数 + + if (input.UserIds.Count > 0) + { + query = query.Where(m => input.UserIds.Contains(m.a.CreatorId.Value)); + } + + var entlistdto = query.GroupBy(g => new { g.a.CreatorId, g.PersonnelName }) + .Select(s => new GetRegistrationPersonnelWorkLoadReportDto + { + PersonnelName = s.Key.PersonnelName, + RegisterCount = s.Count(), + Percentage = Math.Round(Convert.ToDecimal(s.Count() * 100) / sumCount, 2).ToString() + }).ToList(); + + return entlistdto; + } - } } diff --git a/src/Shentun.Peis.Application/OrganizationUnits/OrganizationUnitsAppService.cs b/src/Shentun.Peis.Application/OrganizationUnits/OrganizationUnitsAppService.cs index ac4ccba..1918398 100644 --- a/src/Shentun.Peis.Application/OrganizationUnits/OrganizationUnitsAppService.cs +++ b/src/Shentun.Peis.Application/OrganizationUnits/OrganizationUnitsAppService.cs @@ -252,7 +252,7 @@ namespace Shentun.Peis.OrganizationUnits /// - /// 检查是否可以设置为体检中心 + /// 检查是否可以设置为体检中心 创建时用 无下级数据 /// /// 上级数据ID /// Ture 可以设置 False 不能设置 @@ -262,41 +262,6 @@ namespace Shentun.Peis.OrganizationUnits return !CheckParentIsPeis(dataList, parentid); } - ///// - ///// 检查是否可以设置为体检中心 - ///// - ///// - ///// - ///// Ture 可以设置 False 不能设置 - //private bool CheckIsPeis(List datalist, Guid? parentid) - //{ - // if (parentid != null && parentid != Guid.Empty) - // { - // var parentEnt = datalist.FirstOrDefault(m => m.Id == parentid); - // if (parentEnt != null) - // { - // var IsPeis = parentEnt.GetProperty("IsPeis"); - // if (IsPeis == 'Y') - // { - // return false; //上级为体检中心,不能设置为体检中心 - // } - // else - // { - // return CheckIsPeis(datalist, parentEnt.ParentId); - // } - // } - // else - // { - // return true; //无上级,可以设置为体检中心 - // } - // } - // else - // { - // return true; //无上级,可以设置为体检中心 - // } - - //} - /// /// 检查上级有没有体检中心 @@ -334,7 +299,7 @@ namespace Shentun.Peis.OrganizationUnits } /// - /// 检查下级可以设置为体检中心 + /// 检查下级是否有体检中心 /// /// /// @@ -345,30 +310,36 @@ namespace Shentun.Peis.OrganizationUnits GetChildren(datalist, id, datalisttemp); + datalisttemp = datalisttemp.Where(m => m.Id != id).ToList(); //剔除自身 + if (datalisttemp.Any()) { - foreach (var ent in datalisttemp) - { - var IsPeis = ent.GetProperty("IsPeis"); - - if (IsPeis == 'Y') - { - return true; //下级为体检中心,不能设置为体检中心 - } - } + return true; + } + else + { + return false; } - - return false; } - + /// + /// 递归查找下级的设置为体检中心的数据 + /// + /// + /// + /// private void GetChildren(List datalist, Guid id, List datalisttemp) { var ent = datalist.Find(m => m.Id == id); if (ent != null) { - datalisttemp.Add(ent); + var IsPeis = ent.GetProperty("IsPeis"); + if (IsPeis == 'Y') + { + datalisttemp.Add(ent); + } + } var entlist = datalist.Where(m => m.ParentId == id).ToList(); diff --git a/src/Shentun.Peis.Application/RegisterAsbitems/RegisterAsbitemAppService.cs b/src/Shentun.Peis.Application/RegisterAsbitems/RegisterAsbitemAppService.cs index 3e35cc5..9ee4e41 100644 --- a/src/Shentun.Peis.Application/RegisterAsbitems/RegisterAsbitemAppService.cs +++ b/src/Shentun.Peis.Application/RegisterAsbitems/RegisterAsbitemAppService.cs @@ -409,6 +409,7 @@ namespace Shentun.Peis.RegisterAsbitems ChargePrice = item.ChargePrice }); + registerAsbitems.Find(f => f.Id == item.RegisterAsbitemId).ChargePrice = item.ChargePrice; } diff --git a/src/Shentun.Peis.Domain/AsbitemGuides/AsbitemGuideManager.cs b/src/Shentun.Peis.Domain/AsbitemGuides/AsbitemGuideManager.cs index 2c15b24..4732ea2 100644 --- a/src/Shentun.Peis.Domain/AsbitemGuides/AsbitemGuideManager.cs +++ b/src/Shentun.Peis.Domain/AsbitemGuides/AsbitemGuideManager.cs @@ -54,5 +54,8 @@ namespace Shentun.Peis.AsbitemGuides return ""; } } + + + } }