|
|
|
@ -143,7 +143,6 @@ namespace Shentun.Peis.PhoneFollowUps |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取所有危急值列表
|
|
|
|
/// </summary>
|
|
|
|
@ -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<PhoneFollowUp> phoneFollowUpList = new List<PhoneFollowUp>(); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 新增电话随访记录
|
|
|
|
/// </summary>
|
|
|
|
@ -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); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |