From a91fb9f0f9d209eecfe0fb09484ac0c78507f375 Mon Sep 17 00:00:00 2001
From: wxd <123@qq.com>
Date: Fri, 1 Nov 2024 16:36:45 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8D=B1=E6=80=A5=E5=80=BC=E7=94=9F=E6=88=90?=
=?UTF-8?q?=E8=A7=84=E5=88=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../AutoCreatePhoneFollowUpDto.cs | 50 +++++++--
.../PhoneFollowUps/CreatePhoneFollowUpDto.cs | 4 -
.../SmsSends/AutoCreateSmsSendDto.cs | 19 ++--
.../PhoneFollowUps/PhoneFollowUpAppService.cs | 97 +++--------------
.../SmsSends/SmsSendAppService.cs | 103 ++++--------------
5 files changed, 87 insertions(+), 186 deletions(-)
diff --git a/src/Shentun.Peis.Application.Contracts/PhoneFollowUps/AutoCreatePhoneFollowUpDto.cs b/src/Shentun.Peis.Application.Contracts/PhoneFollowUps/AutoCreatePhoneFollowUpDto.cs
index 8568b87..e386ce8 100644
--- a/src/Shentun.Peis.Application.Contracts/PhoneFollowUps/AutoCreatePhoneFollowUpDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/PhoneFollowUps/AutoCreatePhoneFollowUpDto.cs
@@ -6,22 +6,56 @@ using System.Text;
namespace Shentun.Peis.PhoneFollowUps
{
+ //public class AutoCreatePhoneFollowUpDto
+ //{
+ // ///
+ // /// 0-corn表达式 1-按天 2-按周 3-按月 4-按年
+ // ///
+ // public char FollowUpMode { get; set; } = '0';
+
+ // ///
+ // /// FollowUpMode为0时 为corn表达式 其他模式为具体数字
+ // ///
+ // public string ModeValue { get; set; }
+
+ // ///
+ // /// 截止时间 采用corn表达式时需要截止日期
+ // ///
+ // public string EndDate { get; set; }
+
+ // ///
+ // /// 随访主表ID
+ // ///
+ // public Guid FollowUpId { get; set; }
+
+ // ///
+ // /// 随访内容
+ // ///
+ // public string FollowUpContent { get; set; }
+
+ // ///
+ // /// 回复内容
+ // ///
+ // public string ReplyContent { get; set; }
+ //}
+
public class AutoCreatePhoneFollowUpDto
{
///
- /// 0-corn表达式 1-按天 2-按周 3-按月 4-按年
+ /// 开始时间
///
- public char FollowUpMode { get; set; } = '0';
+ public string StartDate { get; set; }
///
- /// FollowUpMode为0时 为corn表达式 其他模式为具体数字
+ /// 间隔天数
///
- public string ModeValue { get; set; }
+ public int IntervalDays { get; set; } = 1;
///
- /// 截止时间 采用corn表达式时需要截止日期
+ /// 生成次数
///
- public string EndDate { get; set; }
+ public int GenerateCount { get; set; } = 1;
+
///
/// 随访主表ID
@@ -33,9 +67,5 @@ namespace Shentun.Peis.PhoneFollowUps
///
public string FollowUpContent { get; set; }
- ///
- /// 回复内容
- ///
- public string ReplyContent { get; set; }
}
}
diff --git a/src/Shentun.Peis.Application.Contracts/PhoneFollowUps/CreatePhoneFollowUpDto.cs b/src/Shentun.Peis.Application.Contracts/PhoneFollowUps/CreatePhoneFollowUpDto.cs
index 4b3246c..7e85f56 100644
--- a/src/Shentun.Peis.Application.Contracts/PhoneFollowUps/CreatePhoneFollowUpDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/PhoneFollowUps/CreatePhoneFollowUpDto.cs
@@ -16,10 +16,6 @@ namespace Shentun.Peis.PhoneFollowUps
///
public string FollowUpContent { get; set; }
- ///
- /// 回复内容
- ///
- public string ReplyContent { get; set; }
///
/// 随访日期 yyyy-MM-dd
diff --git a/src/Shentun.Peis.Application.Contracts/SmsSends/AutoCreateSmsSendDto.cs b/src/Shentun.Peis.Application.Contracts/SmsSends/AutoCreateSmsSendDto.cs
index 902a651..8653a50 100644
--- a/src/Shentun.Peis.Application.Contracts/SmsSends/AutoCreateSmsSendDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/SmsSends/AutoCreateSmsSendDto.cs
@@ -7,24 +7,27 @@ namespace Shentun.Peis.SmsSends
public class AutoCreateSmsSendDto
{
///
- /// 0-corn表达式 1-按天 2-按周 3-按月 4-按年
+ /// 开始时间
///
- public char FollowUpMode { get; set; } = '0';
+ public string StartDate { get; set; }
///
- /// FollowUpMode为0时 为corn表达式 其他模式为具体数字
+ /// 间隔天数
///
- public string ModeValue { get; set; }
+ public int IntervalDays { get; set; } = 1;
///
- /// 短信内容,默认是患者姓名
+ /// 生成次数
///
- public string Content { get; set; }
+ public int GenerateCount { get; set; } = 1;
+
///
- /// 截止时间
+ /// 短信内容,默认是患者姓名
///
- public string EndDate { get; set; }
+ public string Content { get; set; }
+
+
///
/// 随访主表ID
diff --git a/src/Shentun.Peis.Application/PhoneFollowUps/PhoneFollowUpAppService.cs b/src/Shentun.Peis.Application/PhoneFollowUps/PhoneFollowUpAppService.cs
index 146579a..96110a1 100644
--- a/src/Shentun.Peis.Application/PhoneFollowUps/PhoneFollowUpAppService.cs
+++ b/src/Shentun.Peis.Application/PhoneFollowUps/PhoneFollowUpAppService.cs
@@ -143,7 +143,6 @@ namespace Shentun.Peis.PhoneFollowUps
}
-
///
/// 获取所有危急值列表
///
@@ -363,17 +362,11 @@ namespace Shentun.Peis.PhoneFollowUps
[HttpPost("api/app/PhoneFollowUp/AutoCreate")]
public async Task AutoCreateAsync(AutoCreatePhoneFollowUpDto input)
{
- if (string.IsNullOrWhiteSpace(input.ModeValue))
- {
- throw new UserFriendlyException("计划周期不能为空");
- }
-
- if (input.FollowUpMode == FollowUpModeFlag.Corn && string.IsNullOrWhiteSpace(input.EndDate))
+ if (string.IsNullOrWhiteSpace(input.StartDate))
{
- throw new UserFriendlyException("采用corn表达式时需要截止日期");
+ throw new UserFriendlyException("开始时间不能为空");
}
-
var isPhoneFollowUp = await _phoneFollowUpRepository.CountAsync(c => c.FollowUpId == input.FollowUpId);
if (isPhoneFollowUp > 0)
{
@@ -389,83 +382,27 @@ namespace Shentun.Peis.PhoneFollowUps
List phoneFollowUpList = new List();
- if (input.FollowUpMode == FollowUpModeFlag.Corn)
- {
- //corn表达式
- #region 解析Cron表达式
- try
- {
- var schedule = CronExpression.Parse(input.ModeValue, CronFormat.IncludeSeconds);
- var occurrences = schedule.GetOccurrences(DateTime.UtcNow, Convert.ToDateTime(input.EndDate).ToUniversalTime()); //获取截止时间前所有的计划时间
- foreach (var occurrence in occurrences)
- {
- var phoneFollowUpEntity = new PhoneFollowUp(GuidGenerator.Create())
- {
- FollowUpContent = input.FollowUpContent,
- FollowUpId = input.FollowUpId,
- ReplyContent = input.ReplyContent,
- PlanFollowDate = occurrence,
- IsComplete = 'N'
- };
-
- phoneFollowUpList.Add(phoneFollowUpEntity);
- }
- }
- catch (Exception ex)
- {
- throw new UserFriendlyException("Corn表达式不正确");
- }
- #endregion
- }
- else
+ for (int i = 0; i < input.GenerateCount; i++)
{
- //其他模式
- int planCount = 0;
- try
- {
- planCount = Convert.ToInt32(input.ModeValue);
- }
- catch (Exception ex)
- {
- throw new UserFriendlyException("Corn表达式不正确");
- }
+ DateTime planFollowDate = Convert.ToDateTime(input.StartDate);
+
+ planFollowDate = planFollowDate.AddDays(i * input.IntervalDays);
- for (int i = 0; i < planCount; i++)
+ var phoneFollowUpEntity = new PhoneFollowUp(GuidGenerator.Create())
{
- DateTime planFollowDate = DateTime.Now;
- if (input.FollowUpMode == FollowUpModeFlag.Day)
- {
- planFollowDate = planFollowDate.AddDays(i);
- }
- else if (input.FollowUpMode == FollowUpModeFlag.Week)
- {
- planFollowDate = planFollowDate.AddDays(7 * i);
- }
- else if (input.FollowUpMode == FollowUpModeFlag.Month)
- {
- planFollowDate = planFollowDate.AddMonths(i);
- }
- else if (input.FollowUpMode == FollowUpModeFlag.Year)
- {
- planFollowDate = planFollowDate.AddYears(i);
- }
-
- var phoneFollowUpEntity = new PhoneFollowUp(GuidGenerator.Create())
- {
- FollowUpContent = input.FollowUpContent,
- FollowUpId = input.FollowUpId,
- ReplyContent = input.ReplyContent,
- PlanFollowDate = planFollowDate,
- IsComplete = 'N'
- };
-
- phoneFollowUpList.Add(phoneFollowUpEntity);
- }
+ FollowUpContent = input.FollowUpContent,
+ FollowUpId = input.FollowUpId,
+ PlanFollowDate = planFollowDate,
+ IsComplete = 'N'
+ };
+
+ phoneFollowUpList.Add(phoneFollowUpEntity);
}
+
if (phoneFollowUpList.Any())
{
await _phoneFollowUpRepository.InsertManyAsync(phoneFollowUpList);
@@ -474,8 +411,8 @@ namespace Shentun.Peis.PhoneFollowUps
await _followUpRepository.UpdateAsync(followUpEnt);
}
- }
+ }
///
/// 新增电话随访记录
///
@@ -500,7 +437,6 @@ namespace Shentun.Peis.PhoneFollowUps
{
FollowUpContent = input.FollowUpContent,
FollowUpId = input.FollowUpId,
- ReplyContent = input.ReplyContent,
PlanFollowDate = Convert.ToDateTime(input.PlanFollowDate),
IsComplete = 'N'
};
@@ -556,5 +492,6 @@ namespace Shentun.Peis.PhoneFollowUps
await _phoneFollowUpRepository.DeleteAsync(input.PhoneFollowUpId);
}
+
}
}
diff --git a/src/Shentun.Peis.Application/SmsSends/SmsSendAppService.cs b/src/Shentun.Peis.Application/SmsSends/SmsSendAppService.cs
index d77ff6d..742f23b 100644
--- a/src/Shentun.Peis.Application/SmsSends/SmsSendAppService.cs
+++ b/src/Shentun.Peis.Application/SmsSends/SmsSendAppService.cs
@@ -138,17 +138,11 @@ namespace Shentun.Peis.SmsSends
[HttpPost("api/app/SmsSend/AutoCreate")]
public async Task AutoCreateAsync(AutoCreateSmsSendDto input)
{
- if (string.IsNullOrWhiteSpace(input.ModeValue))
+ if (string.IsNullOrWhiteSpace(input.StartDate))
{
- throw new UserFriendlyException("计划周期不能为空");
+ throw new UserFriendlyException("开始时间不能为空");
}
- if (input.FollowUpMode == FollowUpModeFlag.Corn && string.IsNullOrWhiteSpace(input.EndDate))
- {
- throw new UserFriendlyException("采用corn表达式时需要截止日期");
- }
-
-
var isSmsSend = await _smsSendRepository.CountAsync(c => c.FollowUpId == input.FollowUpId);
if (isSmsSend > 0)
{
@@ -182,90 +176,31 @@ namespace Shentun.Peis.SmsSends
throw new UserFriendlyException("随访数据不存在");
}
- if (input.FollowUpMode == FollowUpModeFlag.Corn)
- {
- //corn表达式
- #region 解析Cron表达式
- try
- {
- var schedule = CronExpression.Parse(input.ModeValue, CronFormat.IncludeSeconds);
- var occurrences = schedule.GetOccurrences(DateTime.UtcNow, Convert.ToDateTime(input.EndDate).ToUniversalTime()); //获取截止时间前所有的计划时间
- foreach (var occurrence in occurrences)
- {
- var smsSendEntity = new SmsSend(GuidGenerator.Create())
- {
- FollowUpId = input.FollowUpId,
- Content = string.IsNullOrWhiteSpace(input.Content) ? patientRegisterEnt.patientName : input.Content,
- MobileTelephone = patientRegisterEnt.mobileTelephone,
- PatientName = patientRegisterEnt.patientName,
- PatientId = patientRegisterEnt.patientId,
- PlanSendDate = occurrence,
- SmsTypeId = "01",
- IsComplete = 'Y'
- };
-
- smsSendList.Add(smsSendEntity);
- }
- }
- catch (Exception ex)
- {
- throw new UserFriendlyException("Corn表达式不正确");
- }
-
- #endregion
- }
- else
+ for (int i = 0; i < input.GenerateCount; i++)
{
- //其他模式
- int planCount = 0;
- try
- {
- planCount = Convert.ToInt32(input.ModeValue);
- }
- catch (Exception ex)
- {
- throw new UserFriendlyException("Corn表达式不正确");
- }
+ DateTime planFollowDate = Convert.ToDateTime(input.StartDate);
- for (int i = 0; i < planCount; i++)
- {
- DateTime planFollowDate = DateTime.Now;
- if (input.FollowUpMode == FollowUpModeFlag.Day)
- {
- planFollowDate = planFollowDate.AddDays(i);
- }
- else if (input.FollowUpMode == FollowUpModeFlag.Week)
- {
- planFollowDate = planFollowDate.AddDays(7 * i);
- }
- else if (input.FollowUpMode == FollowUpModeFlag.Month)
- {
- planFollowDate = planFollowDate.AddMonths(i);
- }
- else if (input.FollowUpMode == FollowUpModeFlag.Year)
- {
- planFollowDate = planFollowDate.AddYears(i);
- }
+ planFollowDate = planFollowDate.AddDays(i * input.IntervalDays);
- var smsSendEntity = new SmsSend(GuidGenerator.Create())
- {
- FollowUpId = input.FollowUpId,
- Content = string.IsNullOrWhiteSpace(input.Content) ? patientRegisterEnt.patientName : input.Content,
- MobileTelephone = patientRegisterEnt.mobileTelephone,
- PatientName = patientRegisterEnt.patientName,
- PatientId = patientRegisterEnt.patientId,
- PlanSendDate = planFollowDate,
- SmsTypeId = "01",
- IsComplete = 'Y'
- };
-
- smsSendList.Add(smsSendEntity);
- }
+ var smsSendEntity = new SmsSend(GuidGenerator.Create())
+ {
+ FollowUpId = input.FollowUpId,
+ Content = string.IsNullOrWhiteSpace(input.Content) ? patientRegisterEnt.patientName : input.Content,
+ MobileTelephone = patientRegisterEnt.mobileTelephone,
+ PatientName = patientRegisterEnt.patientName,
+ PatientId = patientRegisterEnt.patientId,
+ PlanSendDate = planFollowDate,
+ SmsTypeId = "01",
+ IsComplete = 'Y'
+ };
+
+ smsSendList.Add(smsSendEntity);
}
+
if (smsSendList.Any())
{
await _smsSendRepository.InsertManyAsync(smsSendList);