From 4da7126ee3910c9e0735c5873ac81cf67e4f5671 Mon Sep 17 00:00:00 2001
From: wxd <123@qq.com>
Date: Wed, 16 Oct 2024 10:38:43 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E6=8A=A5=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...tCompanyOccupationalDiseaseDataExcelDto.cs | 66 ++++++++++
...mpanyOccupationalDiseaseDetailReportDto.cs | 21 +++
.../OccupationalDiseaseReportAppService.cs | 122 +++++++++++++++++-
3 files changed, 208 insertions(+), 1 deletion(-)
create mode 100644 src/Shentun.Peis.Application.Contracts/OccupationalDiseaseReports/GetCompanyOccupationalDiseaseDataExcelDto.cs
diff --git a/src/Shentun.Peis.Application.Contracts/OccupationalDiseaseReports/GetCompanyOccupationalDiseaseDataExcelDto.cs b/src/Shentun.Peis.Application.Contracts/OccupationalDiseaseReports/GetCompanyOccupationalDiseaseDataExcelDto.cs
new file mode 100644
index 0000000..3a30801
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/OccupationalDiseaseReports/GetCompanyOccupationalDiseaseDataExcelDto.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.OccupationalDiseaseReports
+{
+ public class GetCompanyOccupationalDiseaseDataExcelDto
+ {
+ ///
+ /// 人员条码号
+ ///
+ public string PatientRegisterNo { get; set; }
+
+ ///
+ /// 姓名
+ ///
+ public string PatientName { get; set; }
+
+ ///
+ /// 工种
+ ///
+ public string JobType { get; set; }
+
+ ///
+ /// 接害工龄
+ ///
+ public string PoisonWorkTime { get; set; }
+
+ ///
+ /// 毒害因素 A、B格式
+ ///
+ public string PoisonNames { get; set; }
+
+ ///
+ /// 异常指标
+ ///
+ public string AnomalyIndex { get; set; }
+
+ ///
+ /// 处理意见
+ ///
+ public string HandlingSuggestions { get; set; }
+
+ ///
+ /// 体检结论
+ ///
+ public string MedicalConclusion { get; set; }
+
+ ///
+ /// 职业病检查类别
+ ///
+ public string OcCheckTypeName { get; set; }
+
+
+ ///
+ /// 体检日期
+ ///
+ public string MedicalStartDate { get; set; }
+
+ ///
+ /// 总检医生
+ ///
+ public string SummaryDoctorName { get; set; }
+
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/OccupationalDiseaseReports/GetCompanyOccupationalDiseaseDetailReportDto.cs b/src/Shentun.Peis.Application.Contracts/OccupationalDiseaseReports/GetCompanyOccupationalDiseaseDetailReportDto.cs
index e279be4..c03832d 100644
--- a/src/Shentun.Peis.Application.Contracts/OccupationalDiseaseReports/GetCompanyOccupationalDiseaseDetailReportDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/OccupationalDiseaseReports/GetCompanyOccupationalDiseaseDetailReportDto.cs
@@ -181,6 +181,27 @@ namespace Shentun.Peis.OccupationalDiseaseReports
///
public string HandlingSuggestions { get; set; }
+ /////
+ ///// 体检结论
+ /////
+ //public string MedicalConclusion { get; set; }
+
+ /////
+ ///// 职业病检查类别
+ /////
+ //public string OcCheckTypeName { get; set; }
+
+
+ /////
+ ///// 体检日期
+ /////
+ //public string MedicalStartDate { get; set; }
+
+ /////
+ ///// 总检医生
+ /////
+ //public string SummaryDoctorName { get; set; }
+
///
/// 排序
///
diff --git a/src/Shentun.Peis.Application/OccupationalDiseaseReports/OccupationalDiseaseReportAppService.cs b/src/Shentun.Peis.Application/OccupationalDiseaseReports/OccupationalDiseaseReportAppService.cs
index 03e7528..cd92f58 100644
--- a/src/Shentun.Peis.Application/OccupationalDiseaseReports/OccupationalDiseaseReportAppService.cs
+++ b/src/Shentun.Peis.Application/OccupationalDiseaseReports/OccupationalDiseaseReportAppService.cs
@@ -454,7 +454,7 @@ namespace Shentun.Peis.OccupationalDiseaseReports
PatientName = s.FirstOrDefault().patientRegister.PatientName,
PatientRegisterNo = s.FirstOrDefault().patientRegister.PatientRegisterNo,
PoisonNames = string.Join(",", s.Select(ss => ss.posionHaveEmpty.DisplayName).Distinct()),
- PoisonWorkTime = s.Key.PoisonWorkTime
+ PoisonWorkTime = s.Key.PoisonWorkTime,
}).ToList();
msg.MedicalResultDetails = medicalResultDetails;
#endregion
@@ -658,6 +658,126 @@ namespace Shentun.Peis.OccupationalDiseaseReports
+ return msg;
+ }
+
+
+
+
+ ///
+ /// 获取单位职业病结果Excel数据
+ ///
+ ///
+ [HttpPost("api/app/OccupationalDiseaseReport/GetCompanyOccupationalDiseaseDataExcel")]
+ public async Task> GetCompanyOccupationalDiseaseDataExcelAsync(GetCompanyOccupationalDiseaseDetailReportInputDto input)
+ {
+
+ if (!input.CustomerOrgs.Any())
+ throw new UserFriendlyException("单位信息不能为空");
+
+ var customerOrgPara = input.CustomerOrgs.First();
+ if (customerOrgPara.CustomerOrgId == null || customerOrgPara.CustomerOrgId == Guid.Empty)
+ throw new UserFriendlyException("单位不能为空");
+ if (customerOrgPara.CustomerOrgRegisterId == null || customerOrgPara.CustomerOrgRegisterId == Guid.Empty)
+ throw new UserFriendlyException("单位体检次数不能为空");
+
+ #region 人员信息
+ var query = from patientRegister in await _patientRegisterRepository.GetQueryableAsync()
+ join patientOccupationalDisease in await _patientOccupationalDiseaseRepository.GetQueryableAsync() on patientRegister.Id equals patientOccupationalDisease.PatientRegisterId
+ join patientPoison in await _patientPoisonRepository.GetQueryableAsync() on patientRegister.Id equals patientPoison.PatientRegisterId into patientPoisonTemp
+ from patientPoisonHaveEmpty in patientPoisonTemp.DefaultIfEmpty()
+ join poison in await _poisonRepository.GetQueryableAsync() on patientPoisonHaveEmpty.PoisonId equals poison.Id into poisonTemp
+ from posionHaveEmpty in poisonTemp.DefaultIfEmpty()
+ join occupationalAbnormal in await _occupationalAbnormalRepository.GetQueryableAsync() on patientPoisonHaveEmpty.OccupationalAbnormalId equals occupationalAbnormal.Id into occupationalAbnormalTemp
+ from occupationalAbnormalHaveEmpty in occupationalAbnormalTemp.DefaultIfEmpty()
+ join ocCheckType in await _ocCheckTypeRepository.GetQueryableAsync() on patientOccupationalDisease.OcCheckTypeId equals ocCheckType.Id into ocCheckTypeTemp
+ from ocCheckTypeHaveEmpty in ocCheckTypeTemp.DefaultIfEmpty()
+ join sumSummaryHeader in (await _sumSummaryHeaderRepository.GetQueryableAsync()).Include(x => x.SumSummaryContents) on patientRegister.Id equals sumSummaryHeader.PatientRegisterId into sumSummaryHeaderTemp
+ from sumSummaryHeaderHaveEmpty in sumSummaryHeaderTemp.DefaultIfEmpty()
+ where patientRegister.CustomerOrgRegisterId == customerOrgPara.CustomerOrgRegisterId
+ && patientRegister.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration
+ select new
+ {
+ patientRegister,
+ patientOccupationalDisease,
+ posionHaveEmpty,
+ patientPoisonHaveEmpty,
+ occupationalAbnormalHaveEmpty,
+ ocCheckTypeHaveEmpty,
+ sumSummaryHeaderHaveEmpty
+ };
+
+
+ if (!string.IsNullOrEmpty(customerOrgPara.StartDate) && !string.IsNullOrEmpty(customerOrgPara.EndDate))
+ {
+ if (customerOrgPara.DateType == '1')
+ {
+ query = query.Where(m => m.patientRegister.CreationTime >= Convert.ToDateTime(customerOrgPara.StartDate) &&
+ m.patientRegister.CreationTime < Convert.ToDateTime(customerOrgPara.EndDate).AddDays(1));
+ }
+ else if (customerOrgPara.DateType == '2')
+ {
+ query = query.Where(m => m.patientRegister.MedicalStartDate != null && m.patientRegister.MedicalStartDate.Value >= Convert.ToDateTime(customerOrgPara.StartDate) &&
+ m.patientRegister.MedicalStartDate.Value < Convert.ToDateTime(customerOrgPara.EndDate).AddDays(1));
+ }
+ else if (customerOrgPara.DateType == '3')
+ {
+ query = query.Where(m => m.patientRegister.SummaryDate != null && m.patientRegister.SummaryDate.Value >= Convert.ToDateTime(customerOrgPara.StartDate) &&
+ m.patientRegister.SummaryDate.Value < Convert.ToDateTime(customerOrgPara.EndDate).AddDays(1));
+ }
+ }
+
+
+ if (customerOrgPara.CustomerOrgGroupId.Any())
+ {
+ query = query.Where(m => m.patientRegister.CustomerOrgGroupId != null && customerOrgPara.CustomerOrgGroupId.Contains(m.patientRegister.CustomerOrgGroupId.Value));
+ }
+
+ #endregion
+
+
+ var patientRegisterList = query.ToList();
+
+
+ var msg = new List();
+
+
+ if (patientRegisterList.Any())
+ {
+ ////人员
+ //var patientRegisters = patientRegisterList.Select(m => m.patientRegister).Distinct().ToList();
+
+ //var patientRegisterfisrt = patientRegisterList.First();
+
+
+
+ #region 体检结果一览表
+ var medicalResultDetails = patientRegisterList.GroupBy(g => g.patientOccupationalDisease)
+ .Select((s, index) => new GetCompanyOccupationalDiseaseDataExcelDto
+ {
+ AnomalyIndex = $"{SetSumSummarys(s.Select(ss => ss.sumSummaryHeaderHaveEmpty).Distinct().ToList())}",
+ MedicalConclusion = s.Key.OccupationalAbnormal,
+ OcCheckTypeName = s.FirstOrDefault().ocCheckTypeHaveEmpty != null ? s.FirstOrDefault().ocCheckTypeHaveEmpty.DisplayName : "",
+ HandlingSuggestions = s.Key.OccupationalAbSuggestion,
+ JobType = s.Key.JobType,
+ PatientName = s.FirstOrDefault().patientRegister.PatientName,
+ PatientRegisterNo = s.FirstOrDefault().patientRegister.PatientRegisterNo,
+ PoisonNames = string.Join(",", s.Select(ss => ss.posionHaveEmpty.DisplayName).Distinct()),
+ PoisonWorkTime = s.Key.PoisonWorkTime,
+ MedicalStartDate = DataHelper.ConversionDateShortToString(s.FirstOrDefault().patientRegister.MedicalStartDate),
+ SummaryDoctorName = _cacheService.GetSurnameAsync(s.FirstOrDefault().patientRegister.SummaryDoctorId).GetAwaiter().GetResult()
+ }).OrderBy(o => o.MedicalConclusion).ToList();
+ msg = medicalResultDetails;
+ #endregion
+
+
+ }
+
+
+
+
+
+
return msg;
}