diff --git a/src/Shentun.ColumnReferencePlugIns/Sms/CreateThirdPartySmsTaskInputDto.cs b/src/Shentun.ColumnReferencePlugIns/Sms/CreateThirdPartySmsTaskInputDto.cs
new file mode 100644
index 0000000..2339422
--- /dev/null
+++ b/src/Shentun.ColumnReferencePlugIns/Sms/CreateThirdPartySmsTaskInputDto.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Shentun.Peis.PlugIns.Sms
+{
+ public class CreateThirdPartySmsTaskInputDto
+ {
+ ///
+ /// 短信类别ID
+ ///
+ public Guid SmsTypeId { get; set; }
+
+ ///
+ /// 人员ID
+ ///
+ public string PersonId { get; set; }
+
+ ///
+ /// 姓名
+ ///
+ public string PersonName { get; set; }
+
+ ///
+ /// 手机号国家代码
+ ///
+ public string CountryCode { get; set; }
+
+ ///
+ /// 手机号
+ ///
+ public string MobileTelephone { get; set; }
+
+ ///
+ /// 短信内容
+ ///
+ public string Content { get; set; }
+
+
+ ///
+ /// 应用ID
+ ///
+ public Guid SmsAppId { get; set; }
+
+
+ ///
+ /// 第三方系统唯一ID
+ ///
+ public string? ThirdId { get; set; }
+
+
+
+ ///
+ /// 任务周期类别
+ ///
+ public char TaskCycleType { get; set; }
+
+
+ ///
+ /// 任务表达式
+ ///
+ public string? TaskCorn { get; set; }
+
+
+ ///
+ /// 停止执行时间
+ ///
+ public string? StopTime { get; set; }
+
+
+
+ ///
+ /// 发送者用户ID
+ ///
+ public string? SenderId { get; set; }
+
+ ///
+ /// 发送者用户名
+ ///
+ public string? SenderName { get; set; }
+
+ ///
+ /// 计划发送时间集合
+ ///
+ public List PlanSendTimes { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application/SmsSends/SmsSendAppService.cs b/src/Shentun.Peis.Application/SmsSends/SmsSendAppService.cs
index a80f87e..e117665 100644
--- a/src/Shentun.Peis.Application/SmsSends/SmsSendAppService.cs
+++ b/src/Shentun.Peis.Application/SmsSends/SmsSendAppService.cs
@@ -1,11 +1,14 @@
using Cronos;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
using Shentun.Peis.Enums;
using Shentun.Peis.Models;
+using Shentun.Peis.PlugIns.Sms;
using Shentun.Peis.SmsSends;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -27,19 +30,22 @@ namespace Shentun.Peis.SmsSends
private readonly IRepository _followUpRepository;
private readonly IRepository _patientRegisterRepository;
private readonly IRepository _patientRepository;
+ private readonly IRepository _thirdInterfaceRepository;
public SmsSendAppService(
CacheService cacheService,
IRepository followUpRepository,
IRepository patientRegisterRepository,
IRepository smsSendRepository,
- IRepository patientRepository)
+ IRepository patientRepository,
+ IRepository thirdInterfaceRepository)
{
_cacheService = cacheService;
_followUpRepository = followUpRepository;
_patientRegisterRepository = patientRegisterRepository;
_smsSendRepository = smsSendRepository;
_patientRepository = patientRepository;
+ _thirdInterfaceRepository = thirdInterfaceRepository;
}
@@ -158,6 +164,7 @@ namespace Shentun.Peis.SmsSends
where followUp.Id == input.FollowUpId
select new
{
+ patientRegister = patientRegister,
patientName = patientRegister.PatientName,
mobileTelephone = patient.MobileTelephone,
patientId = patient.Id
@@ -189,7 +196,7 @@ namespace Shentun.Peis.SmsSends
PatientId = patientRegisterEnt.patientId,
PlanSendDate = occurrence,
SmsTypeId = "01",
- IsComplete = 'N'
+ IsComplete = 'Y'
};
smsSendList.Add(smsSendEntity);
@@ -235,7 +242,7 @@ namespace Shentun.Peis.SmsSends
planFollowDate = planFollowDate.AddYears(i);
}
-
+
var smsSendEntity = new SmsSend(GuidGenerator.Create())
{
FollowUpId = input.FollowUpId,
@@ -245,7 +252,7 @@ namespace Shentun.Peis.SmsSends
PatientId = patientRegisterEnt.patientId,
PlanSendDate = planFollowDate,
SmsTypeId = "01",
- IsComplete = 'N'
+ IsComplete = 'Y'
};
smsSendList.Add(smsSendEntity);
@@ -255,6 +262,10 @@ namespace Shentun.Peis.SmsSends
if (smsSendList.Any())
{
await _smsSendRepository.InsertManyAsync(smsSendList);
+
+
+ //生成短信平台推送计划
+ await PushCriticalSmsAsync(patientRegisterEnt.patientRegister, smsSendList.Select(s => DataHelper.ConversionDateToString(s.PlanSendDate)).ToList());
}
}
@@ -272,5 +283,58 @@ namespace Shentun.Peis.SmsSends
}
+ ///
+ /// 推送体检报告通知短信
+ ///
+ ///
+ ///
+ ///
+ private async Task PushCriticalSmsAsync(PatientRegister patientRegister, List planSendTimes)
+ {
+ var smsThirdInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(o => o.ThirdInterfaceType ==
+ ThirdInterfaceTypeFlag.CriticalSmsPush);
+ if (smsThirdInterface != null && smsThirdInterface.IsActive == 'Y')
+ {
+
+ var parmValue = smsThirdInterface.ParmValue;
+ var configurationBuilder = new ConfigurationBuilder()
+ .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
+ var interfaceConfig = configurationBuilder.Build();
+ var pushApiAddress = interfaceConfig.GetSection("Interface").GetSection("PushApiAddress").Value;
+ var isEnableSms = interfaceConfig.GetSection("Interface").GetSection("IsActive").Value;
+ if (!string.IsNullOrWhiteSpace(isEnableSms)
+ && isEnableSms == "Y")
+ {
+ SmsPlugIns smsPlugIns = new SmsPlugIns(smsThirdInterface.Id);
+ var smsAppId = Guid.Parse(interfaceConfig.GetSection("Interface").GetSection("SmsAppId").Value);
+ var smsTypeId = Guid.Parse(interfaceConfig.GetSection("Interface").GetSection("SmsTypeId").Value);
+ var patientEnt = await _patientRepository.FirstOrDefaultAsync(f => f.Id == patientRegister.PatientId);
+ if (patientEnt != null)
+ {
+ var inputDto = new CreateThirdPartySmsTaskInputDto
+ {
+ SmsAppId = smsAppId,
+ SmsTypeId = smsTypeId,
+ Content = patientRegister.PatientName,
+ CountryCode = "86",
+ MobileTelephone = patientEnt.MobileTelephone,
+ PersonId = patientRegister.PatientId.ToString(),
+ PersonName = patientRegister.PatientName,
+ SenderId = "admin",
+ SenderName = "体检",
+ StopTime = "",
+ TaskCorn = "",
+ TaskCycleType = '2',
+ ThirdId = patientRegister.Id.ToString(),
+ PlanSendTimes = planSendTimes
+ };
+
+ await smsPlugIns.CallSmsAppServiceAsync(pushApiAddress, inputDto);
+ }
+ }
+ }
+ }
+
+
}
}
diff --git a/src/Shentun.Peis.Domain.Shared/Enums/ThirdInterfaceTypeFlag.cs b/src/Shentun.Peis.Domain.Shared/Enums/ThirdInterfaceTypeFlag.cs
index a4ff062..0eecde4 100644
--- a/src/Shentun.Peis.Domain.Shared/Enums/ThirdInterfaceTypeFlag.cs
+++ b/src/Shentun.Peis.Domain.Shared/Enums/ThirdInterfaceTypeFlag.cs
@@ -36,7 +36,10 @@ namespace Shentun.Peis.Enums
[Description("同步组合项目价格")]
public const string SyncAsbitemPrice = "09";
- [Description("短信推送")]
+ [Description("报告短信推送")]
public const string SmsPush = "10";
+
+ [Description("危急值随访短信推送")]
+ public const string CriticalSmsPush = "11";
}
}