From 603a6ad3f40b6907e23826813ba72bd57b464d54 Mon Sep 17 00:00:00 2001
From: wxd <123@qq.com>
Date: Wed, 22 Apr 2026 11:21:52 +0800
Subject: [PATCH] =?UTF-8?q?=E5=BC=83=E6=A3=80=E7=AD=BE=E5=90=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../GetAsbitemListByPatientRegisterIdDto.cs | 15 +-
...CheckTemplateByGiveUpCheckTemplateIdDto.cs | 14 ++
...kGiveUpCheckPictureByRegisterCheckIdDto.cs | 14 ++
.../GiveCheckByRegisterCheckIdInputDto.cs | 6 +
.../Paperlesss/PaperlessAppService.cs | 173 +++++++++++++++++-
.../PeisHttpApiHostModule.cs | 14 ++
6 files changed, 229 insertions(+), 7 deletions(-)
create mode 100644 src/Shentun.Peis.Application.Contracts/Paperlesss/GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto.cs
create mode 100644 src/Shentun.Peis.Application.Contracts/Paperlesss/GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto.cs
diff --git a/src/Shentun.Peis.Application.Contracts/Paperlesss/GetAsbitemListByPatientRegisterIdDto.cs b/src/Shentun.Peis.Application.Contracts/Paperlesss/GetAsbitemListByPatientRegisterIdDto.cs
index 19abeb2d..26a38ce4 100644
--- a/src/Shentun.Peis.Application.Contracts/Paperlesss/GetAsbitemListByPatientRegisterIdDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/Paperlesss/GetAsbitemListByPatientRegisterIdDto.cs
@@ -41,20 +41,31 @@ namespace Shentun.Peis.Paperlesss
public char IsInformedConsent { get; set; }
///
- /// 是否签写 Y-以签写 N-未签
+ /// 是否签写知情同意书 Y-以签写 N-未签
///
public char IsSignInformedConsent { get; set; }
+
+ ///
+ /// 是否签写弃检内容 Y-以签写 N-未签
+ ///
+ public char IsSignGiveUpCheck { get; set; }
+
///
/// 知情同意书模板内容
///
public string InformedConsentTemplateContent { get; set; }
///
- /// 知情同意书模板内容
+ /// 知情同意书模板id
///
public Guid? InformedConsentTemplateId { get; set; }
+ ///
+ /// 弃检模板id
+ ///
+ public Guid? GiveUpCheckTemplateId { get; set; }
+
///
/// 检查状态
///
diff --git a/src/Shentun.Peis.Application.Contracts/Paperlesss/GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto.cs b/src/Shentun.Peis.Application.Contracts/Paperlesss/GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto.cs
new file mode 100644
index 00000000..3b00bc35
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/Paperlesss/GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.Paperlesss
+{
+ public class GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto
+ {
+ ///
+ /// 模板内容 去掉标签
+ ///
+ public string GiveUpCheckTemplateContent { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/Paperlesss/GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto.cs b/src/Shentun.Peis.Application.Contracts/Paperlesss/GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto.cs
new file mode 100644
index 00000000..bbb75720
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/Paperlesss/GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.Paperlesss
+{
+ public class GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto
+ {
+ ///
+ /// 弃检文件内容
+ ///
+ public string GiveUpCheckContent { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/Paperlesss/GiveCheckByRegisterCheckIdInputDto.cs b/src/Shentun.Peis.Application.Contracts/Paperlesss/GiveCheckByRegisterCheckIdInputDto.cs
index feafc536..3164d639 100644
--- a/src/Shentun.Peis.Application.Contracts/Paperlesss/GiveCheckByRegisterCheckIdInputDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/Paperlesss/GiveCheckByRegisterCheckIdInputDto.cs
@@ -9,5 +9,11 @@ namespace Shentun.Peis.Paperlesss
public Guid RegisterCheckId { get; set; }
public string SignImageBase64 { get; set; }
+
+ ///
+ /// 弃检模板id
+ ///
+ public Guid? GiveUpCheckTemplateId { get; set; }
+
}
}
diff --git a/src/Shentun.Peis.Application/Paperlesss/PaperlessAppService.cs b/src/Shentun.Peis.Application/Paperlesss/PaperlessAppService.cs
index 990b478d..d40e2df9 100644
--- a/src/Shentun.Peis.Application/Paperlesss/PaperlessAppService.cs
+++ b/src/Shentun.Peis.Application/Paperlesss/PaperlessAppService.cs
@@ -5,6 +5,7 @@ using NPOI.HPSF;
using NPOI.HSSF.Record;
using NPOI.HSSF.Record.Chart;
using Shentun.Peis.Enums;
+using Shentun.Peis.GiveUpCheckTemplates;
using Shentun.Peis.InformedConsentTemplates;
using Shentun.Peis.Migrations;
using Shentun.Peis.Models;
@@ -51,6 +52,7 @@ namespace Shentun.Peis.Paperlesss
private readonly IRepository _roomDetailRepository;
private readonly IRepository _queueRegisterRepository;
private readonly QueueRegisterAppService _queueRegisterAppService;
+ private readonly IRepository _giveUpCheckTemplateRepository;
public PaperlessAppService(
IRepository patientRegisterRepository,
IRepository patientRepository,
@@ -70,7 +72,8 @@ namespace Shentun.Peis.Paperlesss
IRepository doctorSignInRepository,
IRepository roomDetailRepository,
IRepository queueRegisterRepository,
- QueueRegisterAppService queueRegisterAppService)
+ QueueRegisterAppService queueRegisterAppService,
+ IRepository giveUpCheckTemplateRepository)
{
_patientRegisterRepository = patientRegisterRepository;
_patientRepository = patientRepository;
@@ -91,6 +94,7 @@ namespace Shentun.Peis.Paperlesss
_roomDetailRepository = roomDetailRepository;
_queueRegisterRepository = queueRegisterRepository;
_queueRegisterAppService = queueRegisterAppService;
+ _giveUpCheckTemplateRepository = giveUpCheckTemplateRepository;
}
#region 体检系统用
@@ -203,6 +207,51 @@ namespace Shentun.Peis.Paperlesss
return entDto;
}
+
+ ///
+ /// 获取人员签署的弃检内容 根据register_check_id 小程序公用
+ ///
+ ///
+ ///
+ [HttpPost("api/app/Paperless/GetRegisterCheckGiveUpCheckPictureByRegisterCheckId")]
+ public async Task GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdAsync(RegisterCheckIdInputDto input)
+ {
+
+ string icContent = "";
+ var queryFirst = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync()
+ join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId
+ where registerCheck.Id == input.RegisterCheckId
+ select new
+ {
+ registerCheck
+ }).FirstOrDefault();
+
+
+
+ if (queryFirst != null && !string.IsNullOrWhiteSpace(queryFirst.registerCheck.GiveUpCheckFile))
+ {
+
+ string fileName = queryFirst.registerCheck.GiveUpCheckFile.TrimStart('/'); // 去除开头的 /
+ // fileName: SignatureTemplate/3a209c4d-cad9-ad05-62af-c7824067d8f7.html
+
+ string physicalPath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
+
+
+ if (File.Exists(physicalPath))
+ {
+ icContent = await File.ReadAllTextAsync(physicalPath, Encoding.UTF8);
+ }
+ }
+
+
+ var entDto = new GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto
+ {
+ GiveUpCheckContent = icContent
+ };
+
+ return entDto;
+ }
+
#endregion
@@ -309,6 +358,7 @@ namespace Shentun.Peis.Paperlesss
//知情同意书模板
var informedConsentTemplateList = await _informedConsentTemplateRepository.GetListAsync();
+ var giveUpCheckTemplateFirst = await _giveUpCheckTemplateRepository.FirstOrDefaultAsync(f => f.IsActive == 'Y');
//前置项目
var preCheckAsbitemList = (from preCheckAsbitem in await _preCheckAsbitemRepository.GetQueryableAsync()
@@ -337,16 +387,22 @@ namespace Shentun.Peis.Paperlesss
PatientName = item.patientRegister.PatientName,
RegisterCheckId = item.registerCheck.Id,
IsBeforeEat = item.asbitem.IsBeforeEat,
- IsSignInformedConsent = 'N'
+ IsSignInformedConsent = 'N',
+ IsSignGiveUpCheck = 'N',
+ GiveUpCheckTemplateId = giveUpCheckTemplateFirst != null ? giveUpCheckTemplateFirst.Id : null
};
#region 是否签写知情同意书
- if (!string.IsNullOrWhiteSpace(item.registerCheck.InformedConsentFile) && !string.IsNullOrWhiteSpace(item.registerCheck.InformedConsentFile))
+ if (!string.IsNullOrWhiteSpace(item.registerCheck.InformedConsentFile) && !string.IsNullOrWhiteSpace(item.registerCheck.InformedConsentSignFile))
{
detailDto.IsSignInformedConsent = 'Y';
}
+ if (!string.IsNullOrWhiteSpace(item.registerCheck.GiveUpCheckFile) && !string.IsNullOrWhiteSpace(item.registerCheck.GiveUpCheckSignFile))
+ {
+ detailDto.IsSignGiveUpCheck = 'Y';
+ }
#endregion
@@ -493,6 +549,13 @@ namespace Shentun.Peis.Paperlesss
[HttpPost("api/app/Paperless/GiveCheckByRegisterCheckId")]
public async Task GiveCheckByRegisterCheckIdAsync(GiveCheckByRegisterCheckIdInputDto input)
{
+
+ if (input.GiveUpCheckTemplateId == null)
+ {
+ throw new UserFriendlyException("弃检模板id不能为空");
+ }
+
+
if (string.IsNullOrWhiteSpace(input.SignImageBase64))
{
throw new UserFriendlyException("签名数据不能为空");
@@ -515,17 +578,77 @@ namespace Shentun.Peis.Paperlesss
throw new UserFriendlyException("人员已总检,不允许弃检操作");
}
-
- #region 检查图片生成
+
+ #region 弃检签名图片生成
string imgurl = $"GiveUpSignFiles/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{registerCheck.PatientRegisterId}/give_up_sign";
var signUrl = ImageHelper.Base64StrToImage(input.SignImageBase64, imgurl);
if (string.IsNullOrEmpty(signUrl))
throw new UserFriendlyException("签名base64数据不正确");
#endregion
+
+
+ #region 整个弃检文件生成
+
+ var giveUpCheckTemplateFirst = await _giveUpCheckTemplateRepository.FirstOrDefaultAsync(f => f.Id == input.GiveUpCheckTemplateId);
+ if (giveUpCheckTemplateFirst == null)
+ {
+ throw new UserFriendlyException("弃检模板Id不正确");
+ }
+
+ if (string.IsNullOrWhiteSpace(giveUpCheckTemplateFirst.GiveUpCheckTemplateFile))
+ {
+ throw new UserFriendlyException("弃检模板不存在");
+ }
+
+ string giveUpCheckTemplateFileName = giveUpCheckTemplateFirst.GiveUpCheckTemplateFile.TrimStart('/');
+
+ string physicalPath = Path.Combine(Directory.GetCurrentDirectory(), giveUpCheckTemplateFileName);
+
+ if (!File.Exists(physicalPath))
+ {
+ throw new UserFriendlyException("弃检模板文件有误");
+ }
+
+ string content = await File.ReadAllTextAsync(physicalPath, Encoding.UTF8);
+
+ // 替换签名占位符为 img 标签
+ string imgTag = @$"
";
+ content = content.Replace("${signMan}", imgTag);
+
+ // 替换日期占位符为当前日期 (yyyy-MM-dd)
+ string currentDate = DateTime.Now.ToString("yyyy-MM-dd");
+ content = content.Replace("${signDate}", currentDate);
+
+
+ string saveML = $"/GiveUpCheckFiles/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{registerCheck.PatientRegisterId}";
+ string fileName = $"give_up_check{Path.GetExtension(giveUpCheckTemplateFirst.GiveUpCheckTemplateFile)}";
+ string giveUpCheckUrl = $"{saveML}/{fileName}";
+
+ // 创建目录(关键代码)
+ string fullDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), saveML.TrimStart('/'));
+ if (!Directory.Exists(fullDirectoryPath))
+ {
+ Directory.CreateDirectory(fullDirectoryPath);
+ }
+
+ // 4. 完整的文件路径
+ string fullFilePath = Path.Combine(fullDirectoryPath, fileName);
+ // 5. 写入HTML内容到文件
+ await File.WriteAllTextAsync(fullFilePath, content, Encoding.UTF8);
+
+
+
+
+ #endregion
+
+
+
+
registerCheck.CompleteFlag = RegisterCheckCompleteFlag.GiveUpChecked;
registerCheck.GiveUpCheckSignFile = signUrl;
+ registerCheck.GiveUpCheckFile = giveUpCheckUrl;
await _registerCheckRepository.UpdateAsync(registerCheck);
}
@@ -684,6 +807,46 @@ namespace Shentun.Peis.Paperlesss
}
+
+ ///
+ /// 获取弃检模板内容
+ ///
+ ///
+ ///
+ [HttpPost("api/app/Paperless/GetGiveUpCheckTemplateByGiveUpCheckTemplateId")]
+ public async Task GetGiveUpCheckTemplateByGiveUpCheckTemplateIdAsync(GiveUpCheckTemplateIdInputDto input)
+ {
+ //模板存储html文件
+
+ var giveUpCheckTemplateEnt = await _giveUpCheckTemplateRepository.GetAsync(input.GiveUpCheckTemplateId);
+
+ string giveUpCheckTemplateFileContent = "";
+ if (!string.IsNullOrWhiteSpace(giveUpCheckTemplateEnt.GiveUpCheckTemplateFile))
+ {
+
+ string fileName = giveUpCheckTemplateEnt.GiveUpCheckTemplateFile.TrimStart('/'); // 去除开头的 /
+ // fileName: SignatureTemplate/3a209c4d-cad9-ad05-62af-c7824067d8f7.html
+
+ string physicalPath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
+
+
+ if (File.Exists(physicalPath))
+ {
+ giveUpCheckTemplateFileContent = await File.ReadAllTextAsync(physicalPath, Encoding.UTF8);
+
+ giveUpCheckTemplateFileContent = giveUpCheckTemplateFileContent.Replace("${signMan}", "").Replace("${signDate}", "");
+ }
+
+
+ }
+ var entDto = new GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto
+ {
+ GiveUpCheckTemplateContent = giveUpCheckTemplateFileContent
+ };
+ return entDto;
+ }
+
+
///
/// 获取明细结果根据检查id
///
diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
index 9222c42e..4f506be3 100644
--- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
+++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
@@ -326,6 +326,11 @@ public class PeisHttpApiHostModule : AbpModule
Directory.CreateDirectory(informedConsentFilesPath);
}
+ var giveUpCheckFilesPath = Path.Combine(hostingEnvironment.ContentRootPath, "GiveUpCheckFiles");
+ if (!Directory.Exists(giveUpCheckFilesPath))
+ {
+ Directory.CreateDirectory(giveUpCheckFilesPath);
+ }
var informedConsentSignFilesPath = Path.Combine(hostingEnvironment.ContentRootPath, "InformedConsentSignFiles");
if (!Directory.Exists(informedConsentSignFilesPath))
{
@@ -734,12 +739,21 @@ public class PeisHttpApiHostModule : AbpModule
RequestPath = "/GiveUpSignFiles"
});
+ app.UseStaticFiles(new StaticFileOptions
+ {
+ FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "GiveUpCheckFiles")),
+ RequestPath = "/GiveUpCheckFiles"
+ });
+
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "InformedConsentFiles")),
RequestPath = "/InformedConsentFiles"
});
+
+
+
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "InformedConsentSignFiles")),