Compare commits

..

No commits in common. 'd45a891f41720c816447788f66314c14e474cf76' and '4fb3f4ae2003dde8110083fbd176e293b22f47d9' have entirely different histories.

  1. 446
      src/2.services/ATS.NonCustodial.Application/Impl/Admins/SMSService.cs
  2. 80
      src/2.services/ATS.NonCustodial.Application/Impl/Admins/UserService.cs
  3. 4
      src/2.services/ATS.NonCustodial.Application/Impl/Business/AppEarlyWarningService.cs
  4. 63
      src/2.services/ATS.NonCustodial.Application/Impl/Business/AppViolationStatisticsService.cs
  5. 19
      src/2.services/ATS.NonCustodial.Application/Impl/Business/CaseManagements/AppCaseManagementService.cs
  6. 9
      src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/ISMSService.cs
  7. 5
      src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/User/Input/UserAddInput.cs
  8. 5
      src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/User/Input/UserUpdateInput.cs
  9. 4
      src/4.apps/ATS.NonCustodial.Admin.Api/appsettings.json
  10. 26
      src/4.apps/ATS.NonCustodial.Admin.Api/configs/appsettings.json
  11. 14
      src/5.shared/ATS.NonCustodial.Shared/Configurations/Options/SmsConfiguration.cs

446
src/2.services/ATS.NonCustodial.Application/Impl/Admins/SMSService.cs

@ -1,11 +1,13 @@
using ATS.NonCustodial.Application.Base; using ATS.NonCustodial.Application.Base;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.AppDictionaries;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.AppDictionaries.Output;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS.Input; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS.Input;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS.Output;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement.Input;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement.Output;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppEarlyWarnings.Input;
using ATS.NonCustodial.Domain.Entities.Admins; using ATS.NonCustodial.Domain.Entities.Admins;
using ATS.NonCustodial.Domain.Entities.Business.CaseManagements; using ATS.NonCustodial.Domain.Entities.Business.CaseManagements;
using ATS.NonCustodial.Domain.Entities.Business.EarlyWarning;
using ATS.NonCustodial.Domain.Shared.Enums; using ATS.NonCustodial.Domain.Shared.Enums;
using ATS.NonCustodial.Domain.Shared.OrmRepositories.Basic.EfCore; using ATS.NonCustodial.Domain.Shared.OrmRepositories.Basic.EfCore;
using ATS.NonCustodial.DynamicApi; using ATS.NonCustodial.DynamicApi;
@ -17,7 +19,10 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using StackExchange.Profiling.Internal; using StackExchange.Profiling.Internal;
using System.Web; using TencentCloud.Common;
using TencentCloud.Common.Profile;
using TencentCloud.Sms.V20210111;
using TencentCloud.Sms.V20210111.Models;
namespace ATS.NonCustodial.Application.Impl.Admins namespace ATS.NonCustodial.Application.Impl.Admins
{ {
@ -31,31 +36,15 @@ namespace ATS.NonCustodial.Application.Impl.Admins
private readonly IEfRepository<AppUser, long> _appUserRepository; private readonly IEfRepository<AppUser, long> _appUserRepository;
protected readonly IEfRepository<AppCaseManagement, long> _appCaseManagementRepository; protected readonly IEfRepository<AppCaseManagement, long> _appCaseManagementRepository;
protected readonly IEfRepository<AppCaseSupervisedPerson, long> _appSupervisedPersonRepository; protected readonly IEfRepository<AppCaseSupervisedPerson, long> _appSupervisedPersonRepository;
private readonly HttpClient _httpClient;
protected readonly IAppDictionaryService _appDictionaryService;
public SMSService(IEfRepository<AppCaseManagement, long> appCaseManagementRepository, public SMSService(IEfRepository<AppCaseManagement, long> appCaseManagementRepository,
IEfRepository<AppCaseSupervisedPerson, long> appSupervisedPersonRepository, IEfRepository<AppCaseSupervisedPerson, long> appSupervisedPersonRepository,
IEfRepository<AppSMS?, long> appSMSRepository, IEfRepository<AppSMS?, long> appSMSRepository,
IAppDictionaryService appDictionaryService,
IEfRepository<AppUser, long> appUserRepository) IEfRepository<AppUser, long> appUserRepository)
{ {
_appSMSRepository = appSMSRepository; _appSMSRepository = appSMSRepository;
_appUserRepository = appUserRepository; _appUserRepository = appUserRepository;
_appCaseManagementRepository = appCaseManagementRepository; _appCaseManagementRepository = appCaseManagementRepository;
_appSupervisedPersonRepository = appSupervisedPersonRepository; _appSupervisedPersonRepository = appSupervisedPersonRepository;
_appDictionaryService = appDictionaryService;
// 配置HttpClient,忽略SSL证书验证(仅用于测试环境)
var handler = new HttpClientHandler()
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
};
_httpClient = new HttpClient(handler);
_httpClient.Timeout = TimeSpan.FromSeconds(30);
} }
@ -73,7 +62,7 @@ namespace ATS.NonCustodial.Application.Impl.Admins
// .ToListAsync(); // .ToListAsync();
//var caseIdList = selectLimits.Select(w => w.CaseId).Distinct().ToList(); //var caseIdList = selectLimits.Select(w => w.CaseId).Distinct().ToList();
var express = await GetExpression(input, _appSMSRepository.AsQueryable(false, true)); var express =await GetExpression(input, _appSMSRepository.AsQueryable(false, true));
var rtn = await base.GetPageAsync<AppSMS, SmsGetpageInput, SmsListDto>(input, express); var rtn = await base.GetPageAsync<AppSMS, SmsGetpageInput, SmsListDto>(input, express);
@ -97,21 +86,35 @@ namespace ATS.NonCustodial.Application.Impl.Admins
default: default:
break; break;
} }
if (item.Result.Split("|")[0].Equals("OK")) if(item.Result.Contains("Code"))
{ {
item.Message = item.Result; int codeStart = item.Result.IndexOf("\"Code\":\"") + 8;
int codeEnd = item.Result.IndexOf("\"", codeStart);
string code = item.Result.Substring(codeStart, codeEnd - codeStart);
int msgStart = item.Result.IndexOf("\"Message\":\"") + 11;
int msgEnd = item.Result.IndexOf("\"", msgStart);
string message = item.Result.Substring(msgStart, msgEnd - msgStart); // "send success"
if (code.Equals("Ok"))
{
item.Message = message;
item.Result = "短信发送成功"; item.Result = "短信发送成功";
} }
else else
{ {
item.Message = item.Result; item.Message = message;
item.Result = "短信发送异常"; item.Result = "短信发送异常";
} }
} }
else
{
item.Message = item.Result;
item.Result ="短信发送异常";
}
}
var filteredList = rtn.Data var filteredList = rtn.Data
.WhereIf(input.Name.HasValue(), item => item.Name == input.Name) // 筛选条件 .WhereIf(input.Name.HasValue(),item => item.Name == input.Name) // 筛选条件
.ToList(); .ToList();
rtn.Data = filteredList; rtn.Data = filteredList;
return ResultOutput.Ok(rtn); return ResultOutput.Ok(rtn);
@ -130,8 +133,9 @@ namespace ATS.NonCustodial.Application.Impl.Admins
.WhereIf(pageInput.SendTimeTo.HasValue, w => w.sendTime <= pageInput.SendTimeTo); .WhereIf(pageInput.SendTimeTo.HasValue, w => w.sendTime <= pageInput.SendTimeTo);
return query; return query;
} }
/// <summary> /// <summary>
/// 被监管人登录发送验证码 /// 发送验证码
/// </summary> /// </summary>
/// <param name="phone"></param> /// <param name="phone"></param>
/// <param name="ipAddress"></param> /// <param name="ipAddress"></param>
@ -141,76 +145,30 @@ namespace ATS.NonCustodial.Application.Impl.Admins
[AllowAnonymous] [AllowAnonymous]
public async Task<IResultOutput> SendCheckCodeSMS(string phone, string ipAddress = "", string type = "CheckCode") public async Task<IResultOutput> SendCheckCodeSMS(string phone, string ipAddress = "", string type = "CheckCode")
{ {
// 检查是否可以发送(一分钟内只能发送一次)
if (!await CanSendCodeAsync(phone))
{
return ResultOutput.NotOk("请求过于频繁,请稍后再试");
}
var personList = await _appUserRepository.AsQueryable(false, true).Where(w => w.Phone == phone).ToListAsync(); var personList = await _appUserRepository.AsQueryable(false, true).Where(w => w.Phone == phone).ToListAsync();
if (personList.Count == 0) return ResultOutput.NotOk("请检查手机号是否输入正确"); if (personList.Count == 0) return ResultOutput.NotOk("请检查手机号是否输入正确");
var datalist = await (from a in _appCaseManagementRepository.AsQueryable(false, true) var datalist = await (from a in _appCaseManagementRepository.AsQueryable(false, true)
.Where(w => w.CaseProgress != CaseProgressEnum.Closed) .Where(w=>w.CaseProgress !=CaseProgressEnum.Closed)
join b in _appSupervisedPersonRepository.AsQueryable(false, true) join b in _appSupervisedPersonRepository.AsQueryable(false, true)
.Where(w => personList.Select(s => s.Id).ToList().Contains(w.SupervisedPersonId)) .Where(w=> personList.Select(s=>s.Id).ToList().Contains(w.SupervisedPersonId))
on a.Id equals b.CaseId on a.Id equals b.CaseId
select new { b.SupervisedPersonId }).ToListAsync(); select new { b.SupervisedPersonId }).ToListAsync();
if (datalist.Count == 0) return ResultOutput.NotOk("该手机号不存在运行中的案件"); if (datalist.Count == 0) return ResultOutput.NotOk("该手机号不存在运行中的案件");
// 生成随机验证码(6位数字)
var random = new Random();
var code = random.Next(100000, 999999).ToString();
var name = personList.Where(w => datalist.Select(s => s.SupervisedPersonId).Contains(w.Id))?.FirstOrDefault().UserName ?? "";
var sendMessage = $"您的验证码为:{code},请于五分钟内填写,若非本人操作,请勿泄露。";
// 创建验证码记录
var addSMS = new AppSMS
{
phone = phone,
code = code,
sendTime = DateTime.Now,
expiresTime = DateTime.Now.AddMinutes(5), // 5分钟有效期
ipAddress = ipAddress,
type = type,
receiver = name,
content = sendMessage
};
var sendResult = SendSmsAsync(sendMessage, phone);
// 发送短信
// var sendResult = SendSMS(phone, new string[] { code, "5" }, "2524683");
addSMS.result = sendResult.Result;
var sms = await _appSMSRepository.InsertAsync(addSMS);
return ResultOutput.Ok(true);
}
/// <summary>
/// 监管人创建新用户或更改手机号发送验证码
/// </summary>
/// <param name="phone"></param>
/// <param name="ipAddress"></param>
/// <param name="type"></param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<IResultOutput> SendCheckCode(string phone, string ipAddress = "", string type = "CheckCode")
{
// 检查是否可以发送(一分钟内只能发送一次) // 检查是否可以发送(一分钟内只能发送一次)
if (!await CanSendCodeAsync(phone)) if (!await CanSendCodeAsync(phone))
{ {
return ResultOutput.NotOk("请求过于频繁,请稍后再试"); return ResultOutput.NotOk("请求过于频繁,请稍后再试");
} }
// 生成随机验证码(6位数字) // 生成随机验证码(6位数字)
var random = new Random(); var random = new Random();
var code = random.Next(100000, 999999).ToString(); var code = random.Next(100000, 999999).ToString();
var name = "新用户注册"; var name = personList.Where(w => datalist.Select(s => s.SupervisedPersonId).Contains(w.Id))?.FirstOrDefault().UserName??"";
var sendMessage = $"您的验证码为:{code},请于五分钟内填写,若非本人操作,请勿泄露。";
// 创建验证码记录 // 创建验证码记录
var addSMS = new AppSMS var addSMS = new AppSMS
{ {
@ -220,14 +178,12 @@ namespace ATS.NonCustodial.Application.Impl.Admins
expiresTime = DateTime.Now.AddMinutes(5), // 5分钟有效期 expiresTime = DateTime.Now.AddMinutes(5), // 5分钟有效期
ipAddress = ipAddress, ipAddress = ipAddress,
type = type, type = type,
receiver = name, receiver = name
content = sendMessage
}; };
var sendResult = SendSmsAsync(sendMessage, phone);
// 发送短信 // 发送短信
// var sendResult = SendSMS(phone, new string[] { code, "5" }, "2524683"); var sendResult = SendSMS(phone, new string[] { code, "5" }, "2524683");
addSMS.result = sendResult.Result; addSMS.result = sendResult;
var sms = await _appSMSRepository.InsertAsync(addSMS); var sms = await _appSMSRepository.InsertAsync(addSMS);
return ResultOutput.Ok(true); return ResultOutput.Ok(true);
@ -243,7 +199,7 @@ namespace ATS.NonCustodial.Application.Impl.Admins
/// <param name="ipAddress"></param> /// <param name="ipAddress"></param>
/// <param name="supervisedPerson">被监管人姓名</param> /// <param name="supervisedPerson">被监管人姓名</param>
/// <returns></returns> /// <returns></returns>
public async Task<IResultOutput> SendMessageSMS(MessageAlertTypeEnum alert, string supervisor, string phone, DateTime? dateTime, string msg = "", string ipAddress = "", string supervisedPerson = "") public async Task<IResultOutput> SendMessageSMS(MessageAlertTypeEnum alert, string supervisor, string phone,DateTime? dateTime, string msg = "", string ipAddress = "",string supervisedPerson = "")
{ {
// 检查是否可以发送(一分钟内只能发送一次) // 检查是否可以发送(一分钟内只能发送一次)
if (!await CanSendCodeAsync(phone)) if (!await CanSendCodeAsync(phone))
@ -258,20 +214,34 @@ namespace ATS.NonCustodial.Application.Impl.Admins
expiresTime = DateTime.Now.AddMinutes(5), // 5分钟有效期 expiresTime = DateTime.Now.AddMinutes(5), // 5分钟有效期
ipAddress = ipAddress ipAddress = ipAddress
}; };
string sendMessage = string.Empty; string[] sendMessage;
var date = dateTime.HasValue ? dateTime : DateTime.Now; string templateId = string.Empty;
string year , month , day ;
if(dateTime.HasValue)
{
year = dateTime.Value.Year.ToString();
month = dateTime.Value.Month.ToString();
day = dateTime.Value.Day.ToString();
}
else
{
year=DateTime.Now.Year.ToString();
month = DateTime.Now.Month.ToString();
day = DateTime.Now.Day.ToString();
}
if (alert == MessageAlertTypeEnum.Alert) if (alert == MessageAlertTypeEnum.Alert)
{ {
//[预警处理提醒] {1}您好,您于{2}年{3}月{4}日触发的{5}预警需及时处理,请尽快核查并修正相关事项。 //[预警处理提醒] {1}您好,您于{2}年{3}月{4}日触发的{5}预警需及时处理,请尽快核查并修正相关事项。
sendMessage = $"[预警处理提醒] {supervisedPerson}您好,您于{date}触发的{msg}预警需及时处理,请尽快核查并遵守规定。"; sendMessage = new string[] { supervisedPerson, year, month, day, msg };
templateId = "2534751";
addSMS.type = "Alert"; addSMS.type = "Alert";
addSMS.receiver = supervisedPerson; addSMS.receiver = supervisedPerson;
} }
else if (alert == MessageAlertTypeEnum.Approved) else if (alert == MessageAlertTypeEnum.Approved)
{ {
//[审批完成通知] {1}您好,您于{2}年{3}月{4}日提交的{5}申请已完成审批,请及时登录系统查看处理结果。 //[审批完成通知] {1}您好,您于{2}年{3}月{4}日提交的{5}申请已完成审批,请及时登录系统查看处理结果。
sendMessage = $"[审批完成通知] {supervisedPerson}您好,您于{date}提交的{msg}申请已完成审批,请及时登录系统查看处理结果。"; sendMessage = new string[] { supervisedPerson, year, month, day, msg };
templateId = "2535130";
addSMS.type = "Approved"; addSMS.type = "Approved";
addSMS.receiver = supervisedPerson; addSMS.receiver = supervisedPerson;
@ -279,7 +249,8 @@ namespace ATS.NonCustodial.Application.Impl.Admins
else if (alert == MessageAlertTypeEnum.ReviewNotification) else if (alert == MessageAlertTypeEnum.ReviewNotification)
{ {
//[待审批提醒] {1}您好,{2}于{3}年{4}月{5}日提交的{6}申请待您审批,请及时处理。 //[待审批提醒] {1}您好,{2}于{3}年{4}月{5}日提交的{6}申请待您审批,请及时处理。
sendMessage = $"[待审批提醒] {supervisor}您好,{supervisedPerson}于{date}提交的{msg}申请待您审批,请及时处理。"; sendMessage = new string[] { supervisor, supervisedPerson, year, month, day, msg };
templateId = "2535127";
addSMS.type = "ReviewNotification"; addSMS.type = "ReviewNotification";
addSMS.receiver = supervisor; addSMS.receiver = supervisor;
@ -287,15 +258,14 @@ namespace ATS.NonCustodial.Application.Impl.Admins
else else
{ {
//[监管预警通知] {1}您好,被监管人{2}于{3}年{4}月{5}日已触发{6}预警,请尽快核查处理。 //[监管预警通知] {1}您好,被监管人{2}于{3}年{4}月{5}日已触发{6}预警,请尽快核查处理。
sendMessage = $"[监管预警通知] {supervisor}您好,被监管人{supervisedPerson}于{date}已触发{msg}预警,请尽快核查处理。"; sendMessage = new string[] { supervisor, supervisedPerson, year, month, day, msg };
templateId = "2535150";
addSMS.type = "RegulatoryAlert"; addSMS.type = "RegulatoryAlert";
addSMS.receiver = supervisor; addSMS.receiver = supervisor;
} }
// 发送短信 // 发送短信
var sendResult = SendSmsAsync(sendMessage, phone); var sendResult = SendSMS(phone, sendMessage, templateId);
addSMS.result = sendResult.Result; addSMS.result = sendResult;
addSMS.content = sendMessage;
//发送记录入库 //发送记录入库
var sms = await _appSMSRepository.InsertAsync(addSMS); var sms = await _appSMSRepository.InsertAsync(addSMS);
@ -362,120 +332,6 @@ namespace ATS.NonCustodial.Application.Impl.Admins
#region Private #region Private
/// <summary>
/// 发送短信接口
/// </summary>
/// <param name="content">短信内容</param>
/// <param name="phone">电话号码</param>
/// <returns>接口返回消息</returns>
public async Task<string> SendSmsAsync(string content, string phone)
{
try
{
var smsConfig = LazyGetRequiredService<SmsConfiguration>();
var signName = await GetDictionariesOutput("sms_config", "SignName");
var feeType = await GetDictionariesOutput("sms_config", "FeeType");
var baseUrl = await GetDictionariesOutput("sms_config", "BaseUrl");
var pwd = await GetDictionariesOutput("sms_config", "Pwd");
var loginName = await GetDictionariesOutput("sms_config", "LoginName");
var parameters = new SmsParameters()
{
Pwd = pwd.Value ?? smsConfig.Pwd,
Content = content,
FeeType = feeType.Value ?? smsConfig.FeeType,
LoginName = loginName.Value ?? smsConfig.LoginName,
SignName = signName.Value ?? smsConfig.SignName,
Mobile = phone
};
// 构建查询字符串
var queryString = BuildQueryString(parameters);
var requestUrl = $"{baseUrl.Value ?? smsConfig.BaseUrl}?{queryString}";
// 发送HTTP GET请求
var response = await _httpClient.GetAsync(requestUrl);
// 确保响应成功
response.EnsureSuccessStatusCode();
// 读取响应内容
return await response.Content.ReadAsStringAsync();
}
catch (HttpRequestException ex)
{
throw new Exception($"HTTP请求失败: {ex.Message}", ex);
}
catch (TaskCanceledException ex)
{
throw new Exception($"请求超时: {ex.Message}", ex);
}
catch (Exception ex)
{
throw new Exception($"发送短信失败: {ex.Message}", ex);
}
}
/// <summary>
/// 构建查询字符串参数
/// </summary>
private string BuildQueryString(SmsParameters parameters)
{
var query = HttpUtility.ParseQueryString(string.Empty);
query["LoginName"] = parameters.LoginName ?? "";
query["Pwd"] = parameters.Pwd ?? "";
query["FeeType"] = parameters.FeeType ?? "";
query["Mobile"] = parameters.Mobile ?? "";
query["Content"] = parameters.Content ?? "";
query["SignName"] = parameters.SignName ?? "";
query["TimingDate"] = parameters.TimingDate ?? "";
query["ExtCode"] = parameters.ExtCode ?? "";
return query.ToString();
}
/// <summary>
/// 带重试机制的发送方法
/// </summary>
public async Task<string> SendSmsWithRetryAsync(string phone, string content, int maxRetries = 3)
{
for (int i = 0; i < maxRetries; i++)
{
try
{
return await SendSmsAsync(content, phone);
}
catch (Exception ex) when (i < maxRetries - 1)
{
Console.WriteLine($"第{i + 1}次尝试失败: {ex.Message}");
await Task.Delay(1000 * (i + 1)); // 递增延迟
}
}
throw new Exception($"发送短信失败,已重试{maxRetries}次");
}
/// <summary>
/// 根据字典类型Code和字典Code获取字典数据
/// </summary>
/// <param name="dicTypeCode">字典类型Code</param>
/// <param name="dicCode">字典Code</param>
/// <returns></returns>
private async Task<DictionaryGetOutput> GetDictionariesOutput(string dicTypeCode, string dicCode)
{
var dataDict = await _appDictionaryService.GetListNoApiAsync(null);
//被监管人职位字典
var dicData = dataDict
.FirstOrDefault(w => w.Code == dicTypeCode)?.Dictionaries!
.FirstOrDefault(w => w.Code == dicCode);
//返回数据
return dicData;
}
/// <summary> /// <summary>
/// 发送短信 /// 发送短信
///【审批完成通知】 ///【审批完成通知】
@ -491,103 +347,89 @@ namespace ATS.NonCustodial.Application.Impl.Admins
/// <param name="messages">消息列表</param> /// <param name="messages">消息列表</param>
/// <param name="templateId">模版编号</param> /// <param name="templateId">模版编号</param>
/// <returns></returns> /// <returns></returns>
//private string SendSMS(string phone, string[] messages, string templateId) private string SendSMS(string phone, string[] messages, string templateId)
//{ {
// try try
// { {
// var smsConfig = LazyGetRequiredService<SmsConfiguration>(); var smsConfig = LazyGetRequiredService<SmsConfiguration>();
// // 密钥信息从环境变量读取,需要提前在环境变量中设置 TENCENTCLOUD_SECRET_ID 和 TENCENTCLOUD_SECRET_KEY // 密钥信息从环境变量读取,需要提前在环境变量中设置 TENCENTCLOUD_SECRET_ID 和 TENCENTCLOUD_SECRET_KEY
// // 使用环境变量方式可以避免密钥硬编码在代码中,提高安全性 // 使用环境变量方式可以避免密钥硬编码在代码中,提高安全性
// // 生产环境建议使用更安全的密钥管理方案,如密钥管理系统(KMS)、容器密钥注入等 // 生产环境建议使用更安全的密钥管理方案,如密钥管理系统(KMS)、容器密钥注入等
// // 请参见:https://cloud.tencent.com/document/product/1278/85305 // 请参见:https://cloud.tencent.com/document/product/1278/85305
// // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
// Credential cred = new Credential Credential cred = new Credential
// { {
// SecretId = smsConfig.SecretId,// "AKID52ovuoUzINL7g2A4mGYdHhtsfGdmhQv8", SecretId = smsConfig.SecretId,// "AKID52ovuoUzINL7g2A4mGYdHhtsfGdmhQv8",
// SecretKey = smsConfig.SecretKey// "96qPlxzta3JL9j5D7oHWXN6f9D9sOiog" SecretKey = smsConfig.SecretKey// "96qPlxzta3JL9j5D7oHWXN6f9D9sOiog"
// }; };
// // 使用临时密钥示例 // 使用临时密钥示例
// /* /*
// Credential cred = new Credential { Credential cred = new Credential {
// SecretId = "SecretId", SecretId = "SecretId",
// SecretKey = "SecretKey", SecretKey = "SecretKey",
// Token = "Token" Token = "Token"
// }; };
// */ */
// // 实例化一个client选项,可选的,没有特殊需求可以跳过 // 实例化一个client选项,可选的,没有特殊需求可以跳过
// ClientProfile clientProfile = new ClientProfile(); ClientProfile clientProfile = new ClientProfile();
// // 实例化一个http选项,可选的,没有特殊需求可以跳过 // 实例化一个http选项,可选的,没有特殊需求可以跳过
// HttpProfile httpProfile = new HttpProfile(); HttpProfile httpProfile = new HttpProfile();
// //"sms.tencentcloudapi.com" //"sms.tencentcloudapi.com"
// httpProfile.Endpoint = (smsConfig.Endpoint); httpProfile.Endpoint = (smsConfig.Endpoint);
// clientProfile.HttpProfile = httpProfile; clientProfile.HttpProfile = httpProfile;
// // 实例化要请求产品的client对象,clientProfile是可选的 // 实例化要请求产品的client对象,clientProfile是可选的
// //Region = "ap-guangzhou" //Region = "ap-guangzhou"
// SmsClient client = new SmsClient(cred, smsConfig.Region , clientProfile); SmsClient client = new SmsClient(cred, smsConfig.Region , clientProfile);
// // 实例化一个请求对象,每个接口都会对应一个request对象 // 实例化一个请求对象,每个接口都会对应一个request对象
// SendSmsRequest req = new SendSmsRequest(); SendSmsRequest req = new SendSmsRequest();
// /* 基本类型的设置: /* :
// * SDK采用的是指针风格指定参数,即使对于基本类型您也需要用指针来对参数赋值。 * SDK采用的是指针风格指定参数使
// * SDK提供对基本类型的指针引用封装函数 * SDK提供对基本类型的指针引用封装函数
// * 帮助链接: *
// * 短信控制台: https://console.cloud.tencent.com/smsv2 * : https://console.cloud.tencent.com/smsv2
// * 腾讯云短信小助手: https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81 */ * : https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81 */
// /* 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666 */ /* 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666 */
// // 应用 ID 可前往 [短信控制台](https://console.cloud.tencent.com/smsv2/app-manage) 查看 // 应用 ID 可前往 [短信控制台](https://console.cloud.tencent.com/smsv2/app-manage) 查看
// req.SmsSdkAppId = smsConfig.SmsSdkAppId;// "1401039888"; req.SmsSdkAppId = smsConfig.SmsSdkAppId;// "1401039888";
// /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名 */ /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名 */
// // 签名信息可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-sign) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-sign) 的签名管理查看 // 签名信息可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-sign) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-sign) 的签名管理查看
// req.SignName = smsConfig.SignName;// "成都阿凯思信息技术"; req.SignName = smsConfig.SignName;// "成都阿凯思信息技术";
// /* 模板 ID: 必须填写已审核通过的模板 ID */ /* 模板 ID: 必须填写已审核通过的模板 ID */
// // 模板 ID 可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-template) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-template) 的正文模板管理查看 // 模板 ID 可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-template) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-template) 的正文模板管理查看
// req.TemplateId = templateId;// "2524683"; req.TemplateId = templateId;// "2524683";
// /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */ /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
// req.TemplateParamSet = messages;// new string[] { msg, expires.ToString() }; req.TemplateParamSet = messages;// new string[] { msg, expires.ToString() };
// /* 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号] /* E.164 +[][]
// * 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号*/ * +8613711112222 + 8613711112222200*/
// req.PhoneNumberSet = new string[] { smsConfig.PhoneNumberSet + phone }; req.PhoneNumberSet = new string[] { smsConfig.PhoneNumberSet + phone };
// /* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息,server 会原样返回 */ /* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
// req.SessionContext = ""; req.SessionContext = "";
// /* 短信码号扩展号(无需要可忽略): 默认未开通,如需开通请联系 [腾讯云短信小助手] */ /* 短信码号扩展号(无需要可忽略): 默认未开通,如需开通请联系 [腾讯云短信小助手] */
// req.ExtendCode = ""; req.ExtendCode = "";
// /* 国内短信无需填写该项;国际/港澳台短信已申请独立 SenderId 需要填写该字段,默认使用公共 SenderId,无需填写该字段。注:月度使用量达到指定量级可申请独立 SenderId 使用,详情请联系 [腾讯云短信小助手](https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81)。 */ /* 国内短信无需填写该项;国际/港澳台短信已申请独立 SenderId 需要填写该字段,默认使用公共 SenderId,无需填写该字段。注:月度使用量达到指定量级可申请独立 SenderId 使用,详情请联系 [腾讯云短信小助手](https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81)。 */
// req.SenderId = ""; req.SenderId = "";
// // 返回的resp是一个SendSmsResponse的实例,与请求对象对应 // 返回的resp是一个SendSmsResponse的实例,与请求对象对应
// SendSmsResponse resp = client.SendSmsSync(req); SendSmsResponse resp = client.SendSmsSync(req);
// // 输出json格式的字符串回包 // 输出json格式的字符串回包
// return AbstractModel.ToJsonString(resp); return AbstractModel.ToJsonString(resp);
// }
// catch (Exception ex)
// {
// return ex.Message;
// }
//}
#endregion
} }
/// <summary> catch (Exception ex)
/// 短信接口参数类
/// </summary>
public class SmsParameters
{ {
public string LoginName { get; set; } return ex.Message;
public string Pwd { get; set; } }
public string FeeType { get; set; } }
public string Mobile { get; set; }
public string Content { get; set; } #endregion
public string SignName { get; set; }
public string TimingDate { get; set; }
public string ExtCode { get; set; }
} }
} }

80
src/2.services/ATS.NonCustodial.Application/Impl/Admins/UserService.cs

@ -4,17 +4,11 @@ using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.AppDictionaries.O
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Auth.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Auth.Output;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Menu.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Menu.Output;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Role.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.Role.Output;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User.Input; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User.Input;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User.Output;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Output;
using ATS.NonCustodial.Application.Impl.Business.CaseManagements;
using ATS.NonCustodial.Domain.Entities.Admins; using ATS.NonCustodial.Domain.Entities.Admins;
using ATS.NonCustodial.Domain.Entities.Business.CaseManagements;
using ATS.NonCustodial.Domain.Shared.AggRootEntities.Dtos; using ATS.NonCustodial.Domain.Shared.AggRootEntities.Dtos;
using ATS.NonCustodial.Domain.Shared.Enums;
using ATS.NonCustodial.Domain.Shared.OrmRepositories.Basic.EfCore; using ATS.NonCustodial.Domain.Shared.OrmRepositories.Basic.EfCore;
using ATS.NonCustodial.DynamicApi; using ATS.NonCustodial.DynamicApi;
using ATS.NonCustodial.DynamicApi.Attributes; using ATS.NonCustodial.DynamicApi.Attributes;
@ -34,7 +28,6 @@ using Castle.Components.DictionaryAdapter;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using StackExchange.Profiling.Internal;
using Yitter.IdGenerator; using Yitter.IdGenerator;
namespace ATS.NonCustodial.Application.Impl.Admins namespace ATS.NonCustodial.Application.Impl.Admins
@ -57,21 +50,16 @@ namespace ATS.NonCustodial.Application.Impl.Admins
private readonly IEfRepository<AppRolePermission?, long> _rolePermissionRepository; private readonly IEfRepository<AppRolePermission?, long> _rolePermissionRepository;
private readonly IEfRepository<App_Menu?, long> _MenuRepository; private readonly IEfRepository<App_Menu?, long> _MenuRepository;
private readonly IAppDictionaryService _appDictionaryService; private readonly IAppDictionaryService _appDictionaryService;
private readonly ISMSService _smsService;
private readonly IEfRepository<AppCaseManagement, long> _appCaseManagementRepository;
private readonly IEfRepository<AppCaseSupervisedPerson, long> _appSupervisedPersonRepository;
public UserService( public UserService(
IEfRepository<AppUser?, long> userRepository, IEfRepository<AppCaseManagement, long> appCaseManagementRepository, IEfRepository<AppUser?, long> userRepository,
IEfRepository<AppCaseSupervisedPerson, long> appSupervisedPersonRepository,
IEfRepository<AppUserRole?, long> userRoleRepository, IEfRepository<AppUserRole?, long> userRoleRepository,
IEfRepository<AppApi?, long> apiRepository, IEfRepository<AppApi?, long> apiRepository,
IEfRepository<AppRole?, long> roleRepository, IEfRepository<AppRole?, long> roleRepository,
IEfRepository<AppPermissionApi?, long> permissionApiRepository, IEfRepository<AppPermissionApi?, long> permissionApiRepository,
IEfRepository<AppRolePermission?, long> rolePermissionRepository, IEfRepository<AppRolePermission?, long> rolePermissionRepository,
IEfRepository<App_Menu?, long> MenuRepository, IEfRepository<App_Menu?, long> MenuRepository,
IAppDictionaryService appDictionaryService, IAppDictionaryService appDictionaryService
ISMSService smsService
) )
{ {
_userRepository = userRepository; _userRepository = userRepository;
@ -82,10 +70,6 @@ namespace ATS.NonCustodial.Application.Impl.Admins
_rolePermissionRepository = rolePermissionRepository; _rolePermissionRepository = rolePermissionRepository;
_appDictionaryService = appDictionaryService; _appDictionaryService = appDictionaryService;
_MenuRepository = MenuRepository; _MenuRepository = MenuRepository;
_smsService = smsService;
_appCaseManagementRepository = appCaseManagementRepository;
_appSupervisedPersonRepository = appSupervisedPersonRepository;
} }
#endregion Identity #endregion Identity
@ -397,14 +381,7 @@ namespace ATS.NonCustodial.Application.Impl.Admins
{ {
//if (await _userRepository.AnyAsync(x => x.ReceiveName == input.ReceiveName)) return ResultOutput.NotOk("账号已经存在"); //if (await _userRepository.AnyAsync(x => x.ReceiveName == input.ReceiveName)) return ResultOutput.NotOk("账号已经存在");
if (await _userRepository.AnyAsync(w => w.UserName == input.UserName)) return ResultOutput.NotOk("姓名已经存在"); if (await _userRepository.AnyAsync(w => w.UserName == input.UserName)) return ResultOutput.NotOk("姓名已经存在");
if (!input.Phone.HasValue()) return ResultOutput.NotOk("请输入手机号");
var result = await CheckPhone(input.Phone);
if (!result) { return ResultOutput.NotOk("手机号已在系统中已存在"); }
if (!input.Code.HasValue()) return ResultOutput.NotOk("请输入验证码");
result = await _smsService.CheckCodeAsync(input.Phone, input.Code, "CheckCode");
if (!result) { return ResultOutput.NotOk("验证码错误"); }
var entity = Mapper.Map<AppUser>(input); var entity = Mapper.Map<AppUser>(input);
entity.Id = YitIdHelper.NextId(); entity.Id = YitIdHelper.NextId();
entity.PasswordSalt = InfraHelper.Security.GenerateRandomCode(5); entity.PasswordSalt = InfraHelper.Security.GenerateRandomCode(5);
@ -547,16 +524,7 @@ namespace ATS.NonCustodial.Application.Impl.Admins
if (!(user?.Id > 0)) return ResultOutput.NotOk("用户不存在!"); if (!(user?.Id > 0)) return ResultOutput.NotOk("用户不存在!");
//监管人和管理员手机号不能重复 //监管人和管理员手机号不能重复
if (await _userRepository.AnyAsync(w => w.Id != input.Id && w.UserName == input.UserName && w.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson)) return ResultOutput.NotOk("姓名不能重复"); if (await _userRepository.AnyAsync(w => w.Id != input.Id && w.UserName == input.UserName && w.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson)) return ResultOutput.NotOk("姓名不能重复");
if (!input.Phone.HasValue()) return ResultOutput.NotOk("请输入手机号");
if (user.Phone != input.Phone)
{
var result = await CheckPhone(input.Phone);
if (!result) { return ResultOutput.NotOk("手机号已在系统中已存在"); }
if (!input.Code.HasValue()) return ResultOutput.NotOk("请输入验证码");
result = await _smsService.CheckCodeAsync(input.Phone, input.Code, "CheckCode");
if (!result) { return ResultOutput.NotOk("验证码错误"); }
}
Mapper.Map(input, user); Mapper.Map(input, user);
await _userRepository.UpdateAsync(user, UpdatingProps<AppUser>( await _userRepository.UpdateAsync(user, UpdatingProps<AppUser>(
@ -571,8 +539,8 @@ namespace ATS.NonCustodial.Application.Impl.Admins
if (input.RoleIds != null && input.RoleIds.Count() > 0) if (input.RoleIds != null && input.RoleIds.Count() > 0)
{ {
var roleList = await _roleRepository.AsQueryable(false, true) var roleList = await _roleRepository.AsQueryable(false, true)
.Where(w => w.Code == "admin" || w.Code == "supervisor") .Where(w=> w.Code == "admin" || w.Code == "supervisor")
.Select(s => s.Id).ToListAsync(); .Select(s=>s.Id).ToListAsync();
await _userRoleRepository.DeleteAsync(a => a.UserId == user.Id && roleList.Contains(a.RoleId)); await _userRoleRepository.DeleteAsync(a => a.UserId == user.Id && roleList.Contains(a.RoleId));
@ -590,44 +558,6 @@ namespace ATS.NonCustodial.Application.Impl.Admins
return ResultOutput.Ok(); return ResultOutput.Ok();
} }
/// <summary>
/// 校验手机号是否有运行中的按键
/// </summary>
/// <param name="phone"></param>
/// <returns></returns>
private async Task<bool> CheckPhone(string phone)
{
var allUsers = await _userRepository.Where(w => w.Phone == phone && !string.IsNullOrEmpty(w.RoleName)).ToListAsync();
if (allUsers.Any())
{
foreach (var item in allUsers)
{
var caseList = await (from c in _appCaseManagementRepository.AsQueryable(false, true)
join cspr in _appSupervisedPersonRepository.AsQueryable(false, true) on c.Id equals cspr.CaseId
where c.CaseProgress != CaseProgressEnum.Closed
&& item.Id == cspr.SupervisedPersonId
select new CheckPunchRecordForJobOutput()
{
CaseId = c.Id,
CaseName = c.Name,
CaseBeginTime = c.CaseBeginTime,
CheckInFrequency = c.CheckInFrequency,
RestBeginTime = c.RestBeginTime,
RestEndTime = c.RestEndTime,
SupervisedPersonId = cspr.SupervisedPersonId,
SupervisedPersonName = cspr.SupervisedPersonName,
TimedClock = c.TimedClock
}).ToListAsync();
if(caseList.Any())
{
return false;
}
}
}
return true;
}
/// <summary> /// <summary>
/// 更新用户基本信息 /// 更新用户基本信息
/// </summary> /// </summary>
@ -933,7 +863,7 @@ namespace ATS.NonCustodial.Application.Impl.Admins
var rtn = await _userRepository.AsQueryable(false, true) var rtn = await _userRepository.AsQueryable(false, true)
.Where(w => w.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson && w.DataStatus != DataStatusEnum.Disable && !w.UserName.Contains("_aks")) .Where(w => w.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson && w.DataStatus != DataStatusEnum.Disable && !w.UserName.Contains("_aks"))
.WhereIf(codeList.Count > 0, w => w.PositionId == codeList.FirstOrDefault().Id) .WhereIf(codeList.Count>0,w=> w.PositionId == codeList.FirstOrDefault().Id)
// .WhereIf(!userRoles.IsAdmin, w => w.Id == User.Id) 2025 -10-20 段肖确认修改 // .WhereIf(!userRoles.IsAdmin, w => w.Id == User.Id) 2025 -10-20 段肖确认修改
.Select(w => new KeyValueDto() .Select(w => new KeyValueDto()
{ {

4
src/2.services/ATS.NonCustodial.Application/Impl/Business/AppEarlyWarningService.cs

@ -167,11 +167,11 @@ namespace ATS.NonCustodial.Application.Impl.Business
{ {
var supervisor = await _appUserRepository.AsQueryable(false, true).Where(w => w.Id == item.SupervisorId).ToListAsync(); var supervisor = await _appUserRepository.AsQueryable(false, true).Where(w => w.Id == item.SupervisorId).ToListAsync();
//发短信给监管人,提醒被监管人脱离监管区域 //发短信给监管人,提醒被监管人脱离监管区域
await _smsService.SendMessageSMS(MessageAlertTypeEnum.RegulatoryAlert, supervisor.FirstOrDefault().UserName, supervisor.FirstOrDefault().Phone, DateTime.Now, dictionaryGetOutput.Name, "", caseInfo.SupervisedPersonName); await _smsService.SendMessageSMS(MessageAlertTypeEnum.RegulatoryAlert, supervisor.FirstOrDefault().UserName, supervisor.FirstOrDefault().Phone, DateTime.Now, dictionaryGetOutput.Name.Length>6 ? dictionaryGetOutput.Name.Substring(0,6) : dictionaryGetOutput.Name, "", caseInfo.SupervisedPersonName);
} }
//通知被监管人 //通知被监管人
var supervisedPerson = await _appUserRepository.AsQueryable(false, true).Where(w => w.Id == input.SupervisedPersonId).ToListAsync(); var supervisedPerson = await _appUserRepository.AsQueryable(false, true).Where(w => w.Id == input.SupervisedPersonId).ToListAsync();
await _smsService.SendMessageSMS(MessageAlertTypeEnum.Alert, "", supervisedPerson.FirstOrDefault().Phone, DateTime.Now, dictionaryGetOutput.Name, "", caseInfo.SupervisedPersonName); await _smsService.SendMessageSMS(MessageAlertTypeEnum.Alert, "", supervisedPerson.FirstOrDefault().Phone, DateTime.Now, dictionaryGetOutput.Name.Length > 6 ? dictionaryGetOutput.Name.Substring(0, 6) : dictionaryGetOutput.Name, "", caseInfo.SupervisedPersonName);
#endregion #endregion
//公共逻辑 //公共逻辑

63
src/2.services/ATS.NonCustodial.Application/Impl/Business/AppViolationStatisticsService.cs

@ -327,11 +327,17 @@ namespace ATS.NonCustodial.Application.Impl.Business
{ {
if (item == null) continue; if (item == null) continue;
var caseType= await _appDictionaryService.GetDicByDicId(item.CaseTypeId); var caseType= await _appDictionaryService.GetDicByDicId(item.CaseTypeId);
NotClockListDto notClockListDto = new NotClockListDto();
notClockListDto.Bmsah = item.Bmsah;
notClockListDto.CaseId = item.Id;
notClockListDto.CaseName = item.Name;
notClockListDto.CreatedTime = item.CreatedTime;
notClockListDto.CaseTypeName = caseType.Name;
var unitList = await (from c in _appSupervisorRepository.AsQueryable(false, true) var unitList = await (from c in _appSupervisorRepository.AsQueryable(false, true)
join u in _userRepository.AsQueryable(false, true) on c.SupervisorId equals u.Id join u in _userRepository.AsQueryable(false, true) on c.SupervisorId equals u.Id
where c.CaseId == item.Id where c.CaseId == item.Id
select u.Unitname).FirstOrDefaultAsync(); select u.Unitname).FirstOrDefaultAsync();
notClockListDto.SupervisionUnit = unitList;
//根据案件找到被监管 //根据案件找到被监管
var supervisedPerson = await _appSupervisedPersonRepository var supervisedPerson = await _appSupervisedPersonRepository
.AsQueryable(false, true) .AsQueryable(false, true)
@ -339,16 +345,8 @@ namespace ATS.NonCustodial.Application.Impl.Business
.ToListAsync(); .ToListAsync();
foreach (var person in supervisedPerson) foreach (var person in supervisedPerson)
{ {
NotClockListDto notClockListDto = new NotClockListDto();
notClockListDto.Bmsah = item.Bmsah;
notClockListDto.CaseId = item.Id;
notClockListDto.CaseName = item.Name;
notClockListDto.CreatedTime = item.CreatedTime;
notClockListDto.CaseTypeName = caseType.Name;
notClockListDto.SupervisedPersonId = person.SupervisedPersonId; notClockListDto.SupervisedPersonId = person.SupervisedPersonId;
notClockListDto.SupervisedPersonName = person.SupervisedPersonName; notClockListDto.SupervisedPersonName = person.SupervisedPersonName;
notClockListDto.SupervisionUnit = unitList;
var earlyList = await _appEarlyWarningRepository var earlyList = await _appEarlyWarningRepository
.AsQueryable(false, true) .AsQueryable(false, true)
.Where(w => w.EarlyWarningTypeId == applicationType.Id && w.SupervisedPersonId == person.SupervisedPersonId .Where(w => w.EarlyWarningTypeId == applicationType.Id && w.SupervisedPersonId == person.SupervisedPersonId
@ -400,12 +398,18 @@ namespace ATS.NonCustodial.Application.Impl.Business
{ {
if (item == null) continue; if (item == null) continue;
var caseType = await _appDictionaryService.GetDicByDicId(item.CaseTypeId); var caseType = await _appDictionaryService.GetDicByDicId(item.CaseTypeId);
ViolationListDto notClockListDto = new ViolationListDto();
notClockListDto.Bmsah = item.Bmsah;
notClockListDto.CaseId = item.Id;
notClockListDto.CaseName = item.Name;
notClockListDto.CreatedTime = item.CreatedTime;
notClockListDto.CaseTypeName = caseType.Name;
var unitList =await (from c in _appSupervisorRepository.AsQueryable(false, true) var unitList =await (from c in _appSupervisorRepository.AsQueryable(false, true)
join u in _userRepository.AsQueryable(false, true) on c.SupervisorId equals u.Id join u in _userRepository.AsQueryable(false, true) on c.SupervisorId equals u.Id
where c.CaseId == item.Id where c.CaseId == item.Id
select u.Unitname).FirstOrDefaultAsync(); select u.Unitname).FirstOrDefaultAsync();
notClockListDto.SupervisionUnit = unitList;
//根据案件找到被监管 //根据案件找到被监管
var supervisedPerson = await _appSupervisedPersonRepository var supervisedPerson = await _appSupervisedPersonRepository
.AsQueryable(false, true) .AsQueryable(false, true)
@ -413,14 +417,6 @@ namespace ATS.NonCustodial.Application.Impl.Business
.ToListAsync(); .ToListAsync();
foreach (var person in supervisedPerson) foreach (var person in supervisedPerson)
{ {
ViolationListDto notClockListDto = new ViolationListDto();
notClockListDto.Bmsah = item.Bmsah;
notClockListDto.CaseId = item.Id;
notClockListDto.CaseName = item.Name;
notClockListDto.CreatedTime = item.CreatedTime;
notClockListDto.CaseTypeName = caseType.Name;
notClockListDto.SupervisionUnit = unitList;
notClockListDto.SupervisedPersonId = person.SupervisedPersonId; notClockListDto.SupervisedPersonId = person.SupervisedPersonId;
notClockListDto.SupervisedPersonName = person.SupervisedPersonName; notClockListDto.SupervisedPersonName = person.SupervisedPersonName;
var earlyList = await _appEarlyWarningRepository var earlyList = await _appEarlyWarningRepository
@ -475,11 +471,18 @@ namespace ATS.NonCustodial.Application.Impl.Business
{ {
if (item == null) continue; if (item == null) continue;
var caseType = await _appDictionaryService.GetDicByDicId(item.CaseTypeId); var caseType = await _appDictionaryService.GetDicByDicId(item.CaseTypeId);
ViolationExportDto notClockListDto = new ViolationExportDto();
notClockListDto.Bmsah = item.Bmsah;
notClockListDto.CaseId = item.Id;
notClockListDto.CaseName = item.Name;
notClockListDto.CreatedTime = item.CreatedTime;
notClockListDto.CaseTypeName = caseType.Name;
var unitList = await (from c in _appSupervisorRepository.AsQueryable(false, true) var unitList = await (from c in _appSupervisorRepository.AsQueryable(false, true)
join u in _userRepository.AsQueryable(false, true) on c.SupervisorId equals u.Id join u in _userRepository.AsQueryable(false, true) on c.SupervisorId equals u.Id
where c.CaseId == item.Id where c.CaseId == item.Id
select u.Unitname).FirstOrDefaultAsync(); select u.Unitname).FirstOrDefaultAsync();
notClockListDto.SupervisionUnit = unitList;
//根据案件找到被监管 //根据案件找到被监管
var supervisedPerson = await _appSupervisedPersonRepository var supervisedPerson = await _appSupervisedPersonRepository
.AsQueryable(false, true) .AsQueryable(false, true)
@ -487,14 +490,6 @@ namespace ATS.NonCustodial.Application.Impl.Business
.ToListAsync(); .ToListAsync();
foreach (var person in supervisedPerson) foreach (var person in supervisedPerson)
{ {
ViolationExportDto notClockListDto = new ViolationExportDto();
notClockListDto.Bmsah = item.Bmsah;
notClockListDto.CaseId = item.Id;
notClockListDto.CaseName = item.Name;
notClockListDto.CreatedTime = item.CreatedTime;
notClockListDto.CaseTypeName = caseType.Name;
notClockListDto.SupervisionUnit = unitList;
notClockListDto.SupervisedPersonId = person.SupervisedPersonId; notClockListDto.SupervisedPersonId = person.SupervisedPersonId;
notClockListDto.SupervisedPersonName = person.SupervisedPersonName; notClockListDto.SupervisedPersonName = person.SupervisedPersonName;
var earlyList = await _appEarlyWarningRepository var earlyList = await _appEarlyWarningRepository
@ -543,11 +538,17 @@ namespace ATS.NonCustodial.Application.Impl.Business
{ {
if (item == null) continue; if (item == null) continue;
var caseType = await _appDictionaryService.GetDicByDicId(item.CaseTypeId); var caseType = await _appDictionaryService.GetDicByDicId(item.CaseTypeId);
NotClockExportDto notClockListDto = new NotClockExportDto();
notClockListDto.Bmsah = item.Bmsah;
notClockListDto.CaseId = item.Id;
notClockListDto.CaseName = item.Name;
notClockListDto.CreatedTime = item.CreatedTime;
notClockListDto.CaseTypeName = caseType.Name;
var unitList = await (from c in _appSupervisorRepository.AsQueryable(false, true) var unitList = await (from c in _appSupervisorRepository.AsQueryable(false, true)
join u in _userRepository.AsQueryable(false, true) on c.SupervisorId equals u.Id join u in _userRepository.AsQueryable(false, true) on c.SupervisorId equals u.Id
where c.CaseId == item.Id where c.CaseId == item.Id
select u.Unitname).FirstOrDefaultAsync(); select u.Unitname).FirstOrDefaultAsync();
notClockListDto.SupervisionUnit = unitList;
//根据案件找到被监管 //根据案件找到被监管
var supervisedPerson = await _appSupervisedPersonRepository var supervisedPerson = await _appSupervisedPersonRepository
.AsQueryable(false, true) .AsQueryable(false, true)
@ -555,16 +556,8 @@ namespace ATS.NonCustodial.Application.Impl.Business
.ToListAsync(); .ToListAsync();
foreach (var person in supervisedPerson) foreach (var person in supervisedPerson)
{ {
NotClockExportDto notClockListDto = new NotClockExportDto();
notClockListDto.Bmsah = item.Bmsah;
notClockListDto.CaseId = item.Id;
notClockListDto.CaseName = item.Name;
notClockListDto.CreatedTime = item.CreatedTime;
notClockListDto.CaseTypeName = caseType.Name;
notClockListDto.SupervisedPersonId = person.SupervisedPersonId; notClockListDto.SupervisedPersonId = person.SupervisedPersonId;
notClockListDto.SupervisedPersonName = person.SupervisedPersonName; notClockListDto.SupervisedPersonName = person.SupervisedPersonName;
notClockListDto.SupervisionUnit = unitList;
var earlyList = await _appEarlyWarningRepository var earlyList = await _appEarlyWarningRepository
.AsQueryable(false, true) .AsQueryable(false, true)
.Where(w => w.EarlyWarningTypeId== applicationType.Id && w.SupervisedPersonId == person.SupervisedPersonId .Where(w => w.EarlyWarningTypeId== applicationType.Id && w.SupervisedPersonId == person.SupervisedPersonId

19
src/2.services/ATS.NonCustodial.Application/Impl/Business/CaseManagements/AppCaseManagementService.cs

@ -10,7 +10,6 @@ using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManageme
using ATS.NonCustodial.Domain.Entities.Admins; using ATS.NonCustodial.Domain.Entities.Admins;
using ATS.NonCustodial.Domain.Entities.Business; using ATS.NonCustodial.Domain.Entities.Business;
using ATS.NonCustodial.Domain.Entities.Business.CaseManagements; using ATS.NonCustodial.Domain.Entities.Business.CaseManagements;
using ATS.NonCustodial.Domain.Entities.Business.EarlyWarning;
using ATS.NonCustodial.Domain.Shared.AggRootEntities.Dtos; using ATS.NonCustodial.Domain.Shared.AggRootEntities.Dtos;
using ATS.NonCustodial.Domain.Shared.Common.Dtos; using ATS.NonCustodial.Domain.Shared.Common.Dtos;
using ATS.NonCustodial.Domain.Shared.Enums; using ATS.NonCustodial.Domain.Shared.Enums;
@ -61,7 +60,6 @@ namespace ATS.NonCustodial.Application.Impl.Business.CaseManagements
private readonly IEfRepository<AppUser, long> _appUserRepository; private readonly IEfRepository<AppUser, long> _appUserRepository;
private readonly IEfRepository<AppDeviceManagement, long> _appDeviceManagementRepository; private readonly IEfRepository<AppDeviceManagement, long> _appDeviceManagementRepository;
private readonly IEfRepository<AppUser, long> _appuserRepository; private readonly IEfRepository<AppUser, long> _appuserRepository;
private readonly IEfRepository<AppEarlyWarningViewStatistics, long> _appEarlyWarningViewStatisticsRepository;
/// <summary> /// <summary>
/// ///
@ -91,7 +89,6 @@ namespace ATS.NonCustodial.Application.Impl.Business.CaseManagements
IEfRepository<AppCommonFence, long> appCommonFenceRepository, IEfRepository<AppCommonFence, long> appCommonFenceRepository,
IEfRepository<AppUser, long> appUserRepository, IEfRepository<AppUser, long> appUserRepository,
IEfRepository<AppSupervisedPersonRealTimeLocation, long> appSupervisedPersonRealTimeLocationRepository, IEfRepository<AppSupervisedPersonRealTimeLocation, long> appSupervisedPersonRealTimeLocationRepository,
IEfRepository<AppEarlyWarningViewStatistics, long> appEarlyWarningViewStatisticsRepository,
IEfRepository<AppDeviceManagement, long> appDeviceManagementRepository) IEfRepository<AppDeviceManagement, long> appDeviceManagementRepository)
: base( : base(
appCaseManagementRepository, appCaseManagementRepository,
@ -108,7 +105,6 @@ namespace ATS.NonCustodial.Application.Impl.Business.CaseManagements
_appUserRepository = appUserRepository; _appUserRepository = appUserRepository;
_appDeviceManagementRepository = appDeviceManagementRepository; _appDeviceManagementRepository = appDeviceManagementRepository;
_appuserRepository = appuserRepository; _appuserRepository = appuserRepository;
_appEarlyWarningViewStatisticsRepository = appEarlyWarningViewStatisticsRepository;
} }
#endregion Identity #endregion Identity
@ -493,20 +489,7 @@ namespace ATS.NonCustodial.Application.Impl.Business.CaseManagements
//案子结束时间 //案子结束时间
item.CaseClosedTime = input.CaseProgress == CaseProgressEnum.Closed ? DateTime.Now : null; item.CaseClosedTime = input.CaseProgress == CaseProgressEnum.Closed ? DateTime.Now : null;
}); });
//if (input.CaseProgress == CaseProgressEnum.Closed)
//{
// var statisticsList= await _appEarlyWarningViewStatisticsRepository.AsQueryable().Where(w=> input.Ids.Contains(w.CaseId.Value)).ToListAsync();
// foreach (var item in statisticsList)
// {
// item.CheckStatus = CheckStatusEnum.Checked;
// item.CheckTime = DateTime.Now;
// }
// if (statisticsList!=null && statisticsList.Count > 0)
// {
// //关闭案件时,将案件的未查阅状态改为已查阅
// await _appEarlyWarningViewStatisticsRepository.UpdateAsync(statisticsList);
// }
//}
await _appCaseManagementRepository.UpdateAsync(dataList); await _appCaseManagementRepository.UpdateAsync(dataList);
return ResultOutput.Ok(); return ResultOutput.Ok();

9
src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/SMS/ISMSService.cs

@ -14,14 +14,7 @@ namespace ATS.NonCustodial.Application.Contracts.Interfaces.Admins.SMS
/// <param name="phone"></param> /// <param name="phone"></param>
/// <returns></returns> /// <returns></returns>
Task<IResultOutput> SendCheckCodeSMS(string phone, string ipAddress = "", string type = "CheckCode"); Task<IResultOutput> SendCheckCodeSMS(string phone, string ipAddress = "", string type = "CheckCode");
/// <summary>
/// 监管人创建新用户或更改手机号发送验证码
/// </summary>
/// <param name="phone"></param>
/// <param name="ipAddress"></param>
/// <param name="type"></param>
/// <returns></returns>
Task<IResultOutput> SendCheckCode(string phone, string ipAddress = "", string type = "CheckCode");
/// <summary> /// <summary>
/// 校验验证码 /// 校验验证码
/// </summary> /// </summary>

5
src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/User/Input/UserAddInput.cs

@ -49,10 +49,7 @@ namespace ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User.Input
/// 部门名称 /// 部门名称
/// </summary> /// </summary>
public string? Deptcodename { get; set; } public string? Deptcodename { get; set; }
/// <summary>
/// 验证码
/// </summary>
public string? Code { get; set; }
/// <summary> /// <summary>
/// 角色 /// 角色
/// </summary> /// </summary>

5
src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Admins/User/Input/UserUpdateInput.cs

@ -34,11 +34,6 @@ namespace ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User.Input
/// </summary> /// </summary>
public string? Unitname { get; set; } public string? Unitname { get; set; }
/// <summary>
/// 验证码
/// </summary>
public string? Code { get; set; }
/// <summary> /// <summary>
/// 部门id /// 部门id
/// </summary> /// </summary>

4
src/4.apps/ATS.NonCustodial.Admin.Api/appsettings.json

@ -10,8 +10,8 @@
//<EFBFBD>? //<EFBFBD>?
"ConnectionStringsConfiguration": { "ConnectionStringsConfiguration": {
"AdminAuditLogDbConnection": "Server=localhost;database=fsl_cs;uid=root;pwd=sa@admin;pooling=true;CharSet=utf8;port=3306;SslMode=none;Allow User Variables=True;AllowPublicKeyRetrieval=True;", "AdminAuditLogDbConnection": "Server=localhost;database=fjy_sl;uid=root;pwd=sa@admin;pooling=true;CharSet=utf8;port=3306;SslMode=none;Allow User Variables=True;AllowPublicKeyRetrieval=True;",
"AdminDbConnection": "Server=localhost;database=fsl_cs;uid=root;pwd=sa@admin;pooling=true;CharSet=utf8;port=3306;SslMode=none;Allow User Variables=True;AllowPublicKeyRetrieval=True;" "AdminDbConnection": "Server=localhost;database=fjy_sl;uid=root;pwd=sa@admin;pooling=true;CharSet=utf8;port=3306;SslMode=none;Allow User Variables=True;AllowPublicKeyRetrieval=True;"
}, },
"DatabaseProviderConfiguration": { "DatabaseProviderConfiguration": {
"ProviderType": "MySql" "ProviderType": "MySql"

26
src/4.apps/ATS.NonCustodial.Admin.Api/configs/appsettings.json

@ -257,15 +257,21 @@
}, },
// //
"SmsConfiguration": { "SmsConfiguration": {
// // https://cloud.tencent.com/document/product/1278/85305
"LoginName": "DSCJKCSZH", // https://console.cloud.tencent.com/cam/capi
// "SecretId": "AKID52ovuoUzINL7g2A4mGYdHhtsfGdmhQv8",
"Pwd": "Scmf@000731", "SecretKey": "96qPlxzta3JL9j5D7oHWXN6f9D9sOiog",
// //
"BaseUrl": "https://dxsdk.028lk.com:8082/Api/SendSms", "Endpoint": "sms.tencentcloudapi.com",
// 2 3 //Region name, such as "ap-guangzhou"
"FeeType": "2", "Region": "ap-guangzhou",
//:(使,UrlencodeUTF-8) //ID: SdkAppId [] SdkAppId1400006666
"SignName": "【灵讯通】" "SmsSdkAppId": "1401039888",
//: 使 UTF-8
"SignName": "成都阿凯思信息技术",
// E.164 +[][]
//+8613711112222 +
//8613711112222200
"PhoneNumberSet": "+86"
} }
} }

14
src/5.shared/ATS.NonCustodial.Shared/Configurations/Options/SmsConfiguration.cs

@ -8,14 +8,20 @@ namespace ATS.NonCustodial.Shared.Configurations.Options
{ {
public class SmsConfiguration public class SmsConfiguration
{ {
public string LoginName { get; set; } public string SecretId { get; set; }
public string Pwd { get; set; } public string SecretKey { get; set; }
public string BaseUrl { get; set; } public string Endpoint { get; set; }
public string FeeType { get; set; } public string Region { get; set; }
public string SmsSdkAppId { get; set; }
/// <summary>
/// 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名
/// </summary>
public string SignName { get; set; } public string SignName { get; set; }
public string PhoneNumberSet { get; set; }
} }
} }

Loading…
Cancel
Save