Browse Source

[MODIFY]增加短线提示,短信配置提到外层

dev-zzj
zhaozhenjing 2 months ago
parent
commit
925a4486b9
  1. 6
      src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseManagement.cs
  2. 7
      src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseSupervisedPerson.cs
  3. 35
      src/2.services/ATS.NonCustodial.Application/Impl/Business/AppEarlyWarningService.cs
  4. 39
      src/2.services/ATS.NonCustodial.Application/Impl/Business/AppManagementService.cs
  5. 64
      src/2.services/ATS.NonCustodial.Application/Impl/Business/AppPunchRecordService.cs
  6. 13
      src/2.services/ATS.NonCustodial.Application/Impl/Business/CaseManagements/AppCaseManagementService.cs
  7. 5
      src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Input/AppCaseManagementCreateOrModifyInput.cs
  8. 5
      src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Output/AppCaseManagementGetDto.cs
  9. 5
      src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Output/AppCaseManagementListDto.cs
  10. 4
      src/4.apps/ATS.NonCustodial.Admin.Api/configs/appsettings.json

6
src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseManagement.cs

@ -57,11 +57,15 @@ namespace ATS.NonCustodial.Domain.Entities.Business.CaseManagements
/// </summary> /// </summary>
public long JudgmentStatusId { get; set; } public long JudgmentStatusId { get; set; }
/// <summary>
/// 预警阈值字段 Threshold
/// </summary>
public long Threshold { get; set; } = 5;
/// <summary> /// <summary>
/// 接近等级(米) /// 接近等级(米)
/// </summary> /// </summary>
public double ProximityLevel { get; set; } public double ProximityLevel { get; set; }
/// <summary> /// <summary>
/// 休息开始时间(格式:时分) /// 休息开始时间(格式:时分)
/// </summary> /// </summary>

7
src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseSupervisedPerson.cs

@ -116,6 +116,13 @@ namespace ATS.NonCustodial.Domain.Entities.Business.CaseManagements
/// </summary> /// </summary>
public int PrivacyLevel { get; set; } public int PrivacyLevel { get; set; }
/// <summary>
/// 未打卡记录,用来和预警阈值做比较
/// 按时打卡,此值清零
/// 未打卡预警一次,此值+1
/// 当未打卡记录值大于预警阈值时,触发短信通知
/// </summary>
public int AttendanceRecord { get; set; } = 0;
/// <summary> /// <summary>
/// 绑定提交时录入的人脸照片地址 /// 绑定提交时录入的人脸照片地址
/// </summary> /// </summary>

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

@ -1,6 +1,7 @@
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;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.AppDictionaries.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.AppDictionaries.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.Business.AppCaseManagements.AppCaseManagement; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement.Input; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement.Input;
@ -13,7 +14,9 @@ using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppEarlyWarning
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.Apps.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.Apps.Output;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.IM.Notifies; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.IM.Notifies;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Input; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Input;
using ATS.NonCustodial.Application.Impl.Admins;
using ATS.NonCustodial.Application.Impl.Business.IM; using ATS.NonCustodial.Application.Impl.Business.IM;
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.Entities.Business.EarlyWarning;
@ -72,6 +75,9 @@ namespace ATS.NonCustodial.Application.Impl.Business
private readonly IEfRepository<AppEarlyWarningRule, long> _appEarlyWarningRuleRepository; private readonly IEfRepository<AppEarlyWarningRule, long> _appEarlyWarningRuleRepository;
private readonly IAppCaseManagementService _appCaseManagementService; private readonly IAppCaseManagementService _appCaseManagementService;
private readonly IUserService _userService; private readonly IUserService _userService;
private readonly ISMSService _smsService;
private readonly IEfRepository<AppCaseSupervisor, long> _appSupervisorRepository;
private readonly IEfRepository<AppUser, long> _appUserRepository;
/// <summary> /// <summary>
/// ///
@ -86,7 +92,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
/// <param name="appDeviceManagementRepository"></param> /// <param name="appDeviceManagementRepository"></param>
/// <param name="appSessionInformationRepository"></param> /// <param name="appSessionInformationRepository"></param>
/// <param name="appCommonFenceService"></param> /// <param name="appCommonFenceService"></param>
public AppEarlyWarningService(IEfRepository<AppEarlyWarning, long> appEarlyWarningRepository, public AppEarlyWarningService(IEfRepository<AppCaseSupervisor, long> appSupervisorRepository, IEfRepository<AppEarlyWarning, long> appEarlyWarningRepository,
IEfRepository<AppEarlyWarningPushResult, long> appEarlyWarningPushResultRepository, IEfRepository<AppEarlyWarningPushResult, long> appEarlyWarningPushResultRepository,
IHubContext<NonCustodialHub> hubContext, IHubContext<NonCustodialHub> hubContext,
IEfRepository<AppCaseManagement, long> appCaseManagementRepository, IEfRepository<AppCaseManagement, long> appCaseManagementRepository,
@ -97,13 +103,14 @@ namespace ATS.NonCustodial.Application.Impl.Business
IEfRepository<AppDeviceManagement, long> appDeviceManagementRepository, IEfRepository<AppDeviceManagement, long> appDeviceManagementRepository,
IEfRepository<AppSessionInformation, long> appSessionInformationRepository, IEfRepository<AppSessionInformation, long> appSessionInformationRepository,
IAppCommonFenceService appCommonFenceService, IAppCommonFenceService appCommonFenceService,
IEfRepository<AppUser, long> appUserRepository,
IAppCaseManagementService appCaseManagementService, IAppCaseManagementService appCaseManagementService,
IEfRepository<AppBusinessApplication, long> appBusinessApplicationRepository, IEfRepository<AppBusinessApplication, long> appBusinessApplicationRepository,
IEfRepository<AppSupervisedPersonRealTimeLocation, long> appSupervisedPersonRealTimeLocationRepository, IEfRepository<AppSupervisedPersonRealTimeLocation, long> appSupervisedPersonRealTimeLocationRepository,
IClientNotifyService clientNotifyService, IClientNotifyService clientNotifyService,
IEfRepository<AppEarlyWarningViewStatistics, long> appEarlyWarningViewStatisticsRepository, IEfRepository<AppEarlyWarningViewStatistics, long> appEarlyWarningViewStatisticsRepository,
IEfRepository<AppEarlyWarningRule, long> appEarlyWarningRuleRepository) IEfRepository<AppEarlyWarningRule, long> appEarlyWarningRuleRepository,
ISMSService smsService)
: base( : base(
appCaseManagementRepository, appCaseManagementRepository,
appCaseSupervisorRepository, appCaseSupervisorRepository,
@ -113,6 +120,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
appSupervisedPersonRealTimeLocationRepository appSupervisedPersonRealTimeLocationRepository
) )
{ {
_appSupervisorRepository = appSupervisorRepository;
_appEarlyWarningRepository = appEarlyWarningRepository; _appEarlyWarningRepository = appEarlyWarningRepository;
_appEarlyWarningPushResultRepository = appEarlyWarningPushResultRepository; _appEarlyWarningPushResultRepository = appEarlyWarningPushResultRepository;
_hubContext = hubContext; _hubContext = hubContext;
@ -124,6 +132,9 @@ namespace ATS.NonCustodial.Application.Impl.Business
_appEarlyWarningRuleRepository = appEarlyWarningRuleRepository; _appEarlyWarningRuleRepository = appEarlyWarningRuleRepository;
_appCaseManagementService = appCaseManagementService; _appCaseManagementService = appCaseManagementService;
_userService = userService; _userService = userService;
_smsService = smsService;
_appUserRepository = appUserRepository;
} }
#endregion Identity #endregion Identity
@ -144,6 +155,24 @@ namespace ATS.NonCustodial.Application.Impl.Business
//字典 //字典
var dictionaryGetOutput = await _appDictionaryService.GetDicByDicId(input.EarlyWarningTypeId); var dictionaryGetOutput = await _appDictionaryService.GetDicByDicId(input.EarlyWarningTypeId);
#region 短信通知逻辑
//被监管人在APP上打卡的时候发现脱离监管区域,后台会有一个实时预警。同时,监管人和被监管人都将收到脱离监管区域的短信。
//根据案件找监管人,找到多个,均发送消息提醒
var supervisorList = await _appSupervisorRepository
.AsQueryable(false, true)
.Where(w => w.CaseId == caseInfo.CaseId)
.ToListAsync();
foreach (var item in supervisorList)
{
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.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();
await _smsService.SendMessageSMS(MessageAlertTypeEnum.Alert, "", supervisedPerson.FirstOrDefault().Phone, DateTime.Now, dictionaryGetOutput.Name.Length > 6 ? dictionaryGetOutput.Name.Substring(0, 6) : dictionaryGetOutput.Name, "", caseInfo.SupervisedPersonName);
#endregion
//公共逻辑 //公共逻辑
return await EarlyWarningCommLogic(caseInfo, dictionaryGetOutput, null, input.address == null ? "" : input.address); return await EarlyWarningCommLogic(caseInfo, dictionaryGetOutput, null, input.address == null ? "" : input.address);

39
src/2.services/ATS.NonCustodial.Application/Impl/Business/AppManagementService.cs

@ -20,12 +20,9 @@ using ATS.NonCustodial.Application.Contracts.Interfaces.Business.Apps;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.Apps.Input; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.Apps.Input;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.Apps.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.Apps.Output;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.MaterialManager.Directories; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.MaterialManager.Directories;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.MaterialManager.Directories.Output;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Input; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Input;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Output;
using ATS.NonCustodial.Application.Impl.Admins;
using ATS.NonCustodial.Application.Impl.Business.CaseManagements;
using ATS.NonCustodial.Application.Impl.Business.IM; using ATS.NonCustodial.Application.Impl.Business.IM;
using ATS.NonCustodial.Domain.Entities.Admins; using ATS.NonCustodial.Domain.Entities.Admins;
using ATS.NonCustodial.Domain.Entities.Business; using ATS.NonCustodial.Domain.Entities.Business;
@ -51,8 +48,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NPOI.SS.UserModel;
using System.IO;
namespace ATS.NonCustodial.Application.Impl.Business namespace ATS.NonCustodial.Application.Impl.Business
{ {
@ -319,9 +314,9 @@ namespace ATS.NonCustodial.Application.Impl.Business
{ {
var userCase = await base.GetCurrentSupervisePersonProcessingCase(input.SupervisedPersonId ?? User.Id); var userCase = await base.GetCurrentSupervisePersonProcessingCase(input.SupervisedPersonId ?? User.Id);
if (userCase == null) return new ResultOutput<PagedList<AppPunchRecordListDto>>(); return userCase == null
? new ResultOutput<PagedList<AppPunchRecordListDto>>()
return (IResultOutput<PagedList<AppPunchRecordListDto>>)await _appPunchRecordService.GetPageAsync(new AppPunchRecordGetPageInput() : (IResultOutput<PagedList<AppPunchRecordListDto>>)await _appPunchRecordService.GetPageAsync(new AppPunchRecordGetPageInput()
{ {
Id = userCase.CaseId, Id = userCase.CaseId,
SupervisedPersonId = input.SupervisedPersonId ?? User.Id, SupervisedPersonId = input.SupervisedPersonId ?? User.Id,
@ -560,14 +555,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
{ {
item.CheckStatus = input.CheckStatus; item.CheckStatus = input.CheckStatus;
if (input.CheckStatus == CheckStatusEnum.Checked) item.CheckTime = input.CheckStatus == CheckStatusEnum.Checked ? DateTime.Now : null;
{
item.CheckTime = DateTime.Now;
}
else
{
item.CheckTime = null;
}
} }
await _appBusinessApplicationViewStatisticsRepository.UpdateAsync(busViewList); await _appBusinessApplicationViewStatisticsRepository.UpdateAsync(busViewList);
@ -639,10 +627,10 @@ namespace ATS.NonCustodial.Application.Impl.Business
//职位名字 //职位名字
if (User.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson) return item; if (User.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson) return item;
{ {
var positionName = receiverList.FirstOrDefault(w => w.Id == item.ReceiverId)?.PositionName; var positionName = receiverList.FirstOrDefault(w => w.Id == item.ReceiverId)?.PositionName ?? "未知职位";
if (postDict.ContainsKey(positionName)) if (postDict.TryGetValue(positionName, out int count))
{ {
postDict[positionName] += 1; postDict[positionName] = count + 1;
} }
else else
{ {
@ -710,9 +698,9 @@ namespace ATS.NonCustodial.Application.Impl.Business
spcr.SupervisedPersonId spcr.SupervisedPersonId
}).FirstOrDefaultAsync(); }).FirstOrDefaultAsync();
if (data == null) return new ResultOutput<GetSuperPersonCaseDetailDto>(); return data == null
? new ResultOutput<GetSuperPersonCaseDetailDto>()
return await this.GetSuperPersonCaseDetail(new GetSuperPersonCaseDetailInput() : await this.GetSuperPersonCaseDetail(new GetSuperPersonCaseDetailInput()
{ {
CaseId = data!.Id, CaseId = data!.Id,
SuperPersonId = data.SupervisedPersonId SuperPersonId = data.SupervisedPersonId
@ -958,7 +946,10 @@ namespace ATS.NonCustodial.Application.Impl.Business
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
public async Task<IResultOutput> AddPunchRecord(AppPunchRecordAddInput input) => await _appPunchRecordService.AddAsync(input); public async Task<IResultOutput> AddPunchRecord(AppPunchRecordAddInput input)
{
return await _appPunchRecordService.AddAsync(input);
}
/// <summary> /// <summary>
/// 被监管人登录 /// 被监管人登录
@ -1010,7 +1001,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
if (!string.IsNullOrEmpty(input.phone)) if (!string.IsNullOrEmpty(input.phone))
{ {
bool checkCode = await _smsService.CheckCodeAsync(input.phone, input.checkCode, "CheckCode"); bool checkCode = await _smsService.CheckCodeAsync(input.phone, input.checkCode, "CheckCode");
if (!checkCode) return ResultOutput.NotOk("无效验证码"); if (!checkCode) return ResultOutput.NotOk("验证码错误");
} }
//[1]校验当前账户是否是第一次绑定 //[1]校验当前账户是否是第一次绑定
//if (!await _appSupervisedPersonRepository.AnyAsync(w => w.IdCard == input.IdCard && !w.IsBound)) return ResultOutput.NotOk("当前身份没有被监管,请检查身份证是否输入正确"); //if (!await _appSupervisedPersonRepository.AnyAsync(w => w.IdCard == input.IdCard && !w.IsBound)) return ResultOutput.NotOk("当前身份没有被监管,请检查身份证是否输入正确");

64
src/2.services/ATS.NonCustodial.Application/Impl/Business/AppPunchRecordService.cs

@ -1,11 +1,7 @@
using System.Linq; using ATS.NonCustodial.Application.Base;
using System.Net;
using System.Net.Cache;
using System.Security.Policy;
using System.Text;
using System.Text.RegularExpressions;
using ATS.NonCustodial.Application.Base;
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.AppDictionaries; 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.User; using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppEarlyWarnings; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppEarlyWarnings;
@ -15,7 +11,6 @@ using ATS.NonCustodial.Application.Contracts.Interfaces.Business.IM.Notifies;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Input; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Input;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Output; using ATS.NonCustodial.Application.Contracts.Interfaces.Business.PunchRecordServices.Output;
using ATS.NonCustodial.Application.Impl.Admins;
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;
@ -32,13 +27,10 @@ using ATS.NonCustodial.Shared.Extensions;
using ATS.NonCustodial.Shared.Extensions.Collection; using ATS.NonCustodial.Shared.Extensions.Collection;
using AutoMapper.QueryableExtensions; using AutoMapper.QueryableExtensions;
using Castle.Components.DictionaryAdapter; using Castle.Components.DictionaryAdapter;
using ICSharpCode.SharpZipLib.Zip;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json; using System.Dynamic;
using Newtonsoft.Json.Linq;
using NPOI.SS.Formula.PTG;
using Yitter.IdGenerator; using Yitter.IdGenerator;
namespace ATS.NonCustodial.Application.Impl.Business namespace ATS.NonCustodial.Application.Impl.Business
@ -60,7 +52,9 @@ namespace ATS.NonCustodial.Application.Impl.Business
private readonly IEfRepository<AppUser, long> _appuserRepository; private readonly IEfRepository<AppUser, long> _appuserRepository;
private readonly IEfRepository<AppEarlyWarning, long> _appEarlyWarningRepository; private readonly IEfRepository<AppEarlyWarning, long> _appEarlyWarningRepository;
private readonly IEfRepository<appauditrecords, long> _appauditrecordsRepository; private readonly IEfRepository<appauditrecords, long> _appauditrecordsRepository;
private readonly IEfRepository<AppUser, long> _appUserRepository;
private readonly ISMSService _smsService;
public AppPunchRecordService(IEfRepository<AppPunchRecordStatistics, long> appPunchRecordStatisticsRepository, public AppPunchRecordService(IEfRepository<AppPunchRecordStatistics, long> appPunchRecordStatisticsRepository,
IAppCaseManagementService appCaseManagementService, IAppCaseManagementService appCaseManagementService,
IEfRepository<AppCaseManagement, long> appCaseManagementRepository, IEfRepository<AppCaseManagement, long> appCaseManagementRepository,
@ -69,10 +63,12 @@ namespace ATS.NonCustodial.Application.Impl.Business
IEfRepository<AppCaseSupervisor, long> appCaseSupervisorRepository, IEfRepository<AppCaseSupervisor, long> appCaseSupervisorRepository,
IUserService userService, IUserService userService,
IAppDictionaryService appDictionaryService, IAppDictionaryService appDictionaryService,
IEfRepository<AppUser, long> appUserRepository,
IEfRepository<AppSupervisedPersonRealTimeLocation, long> asprl, IEfRepository<AppSupervisedPersonRealTimeLocation, long> asprl,
IEfRepository<AppUser, long> appuserRepository, IEfRepository<AppUser, long> appuserRepository,
IAppEarlyWarningService appEarlyWarningService, IEfRepository<appauditrecords, long> appauditrecords, IAppEarlyWarningService appEarlyWarningService, IEfRepository<appauditrecords, long> appauditrecords,
IEfRepository<AppEarlyWarning, long> appEarlyWarningRepository) IEfRepository<AppEarlyWarning, long> appEarlyWarningRepository,
ISMSService smsService)
: base( : base(
appCaseManagementRepository, appCaseManagementRepository,
appCaseSupervisorRepository, appCaseSupervisorRepository,
@ -88,6 +84,8 @@ namespace ATS.NonCustodial.Application.Impl.Business
_appEarlyWarningRepository = appEarlyWarningRepository; _appEarlyWarningRepository = appEarlyWarningRepository;
_appauditrecordsRepository = appauditrecords; _appauditrecordsRepository = appauditrecords;
_appuserRepository = appuserRepository; _appuserRepository = appuserRepository;
_smsService = smsService;
_appUserRepository = appUserRepository;
} }
#endregion Identity #endregion Identity
@ -229,6 +227,14 @@ namespace ATS.NonCustodial.Application.Impl.Business
await _appPunchRecordStatisticsRepository.InsertAsync(entity); await _appPunchRecordStatisticsRepository.InsertAsync(entity);
#region 每次打卡成功,清空未打卡记录次数
var person = await _appSupervisedPersonRepository.AsQueryable(false, true).Where(w => w.CaseId == caseInfo.CaseId && w.SupervisedPersonId == caseInfo.SupervisedPersonId).ToListAsync();
if (person.Count > 0)
{
person.FirstOrDefault().AttendanceRecord = 0;
await _appSupervisedPersonRepository.UpdateAsync(person);
}
#endregion
#region 打卡消息推送手机通知栏 #region 打卡消息推送手机通知栏
//被监管人id //被监管人id
var list = new List<long>(); var list = new List<long>();
@ -549,12 +555,12 @@ namespace ATS.NonCustodial.Application.Impl.Business
[HttpGet, AllowAnonymous] [HttpGet, AllowAnonymous]
public async Task<IResultOutput> CheckPunchRecordForJob() public async Task<IResultOutput> CheckPunchRecordForJob()
{ {
var limits = User.limits; // var limits = User.limits;
//[1]获取所有正在执行中的被监管人案件 //[1]获取所有正在执行中的被监管人案件
var allCaseList = await (from c in _appCaseManagementRepository.AsQueryable(false, true) var allCaseList = await (from c in _appCaseManagementRepository.AsQueryable(false, true)
join csr in _appCaseSupervisorRepository.AsQueryable(false, true) on c.Id equals csr.CaseId join csr in _appCaseSupervisorRepository.AsQueryable(false, true) on c.Id equals csr.CaseId
join cspr in _appSupervisedPersonRepository.AsQueryable(false, true) on c.Id equals cspr.CaseId join cspr in _appSupervisedPersonRepository.AsQueryable(false, true) on c.Id equals cspr.CaseId
where c.CaseProgress != CaseProgressEnum.Pending && c.CaseProgress != CaseProgressEnum.Closed && cspr.ApprovalStatus == ApprovalStatusEnum.PassReview && limits.Contains(csr.UnitId.ToString()) where c.CaseProgress != CaseProgressEnum.Pending && c.CaseProgress != CaseProgressEnum.Closed && cspr.ApprovalStatus == ApprovalStatusEnum.PassReview
select new CheckPunchRecordForJobOutput() select new CheckPunchRecordForJobOutput()
{ {
CaseId = c.Id, CaseId = c.Id,
@ -669,7 +675,35 @@ namespace ATS.NonCustodial.Application.Impl.Business
earlyEntity.Content!.Contains(w.Content))).ToList(); earlyEntity.Content!.Contains(w.Content))).ToList();
await _earlyWarningService.BatchAddAsync(earlyEntities); await _earlyWarningService.BatchAddAsync(earlyEntities);
#region 循环判断每一个未打卡预警,对app_case_supervised_person表的AttendanceRecord字段加一,若AttendanceRecord大于预警阈值,进行短信通知
foreach (var item in earlyEntities)
{
var person = await _appSupervisedPersonRepository.AsQueryable(false, true).Where(w => w.CaseId == item.CaseId && w.SupervisedPersonId == item.SupervisedPersonId).ToListAsync();
if (person.Count > 0)
{
person.FirstOrDefault().AttendanceRecord +=1;
await _appSupervisedPersonRepository.UpdateAsync(person);
var appCase = await _appCaseManagementRepository.AsQueryable(false, true).Where(w => w.Id == item.CaseId).ToListAsync();
if(appCase.FirstOrDefault().Threshold<= person.FirstOrDefault().AttendanceRecord)
{
var supervisedPerson = await _appUserRepository.AsQueryable(false, true).Where(w => w.Id == item.SupervisedPersonId).ToListAsync();
//通知被监管人
await _smsService.SendMessageSMS(MessageAlertTypeEnum.Alert, "", supervisedPerson.FirstOrDefault().Phone, DateTime.Now, "连续未打卡", "", item.SupervisedPersonName);
var supervisorList = await _appCaseSupervisorRepository.AsQueryable(false, true).Where(w => w.CaseId == item.CaseId).ToListAsync();
foreach (var sup in supervisorList)
{
var supervisor = await _appUserRepository.AsQueryable(false, true).Where(w => w.Id == sup.SupervisorId).ToListAsync();
//发短信给监管人,提醒被监管人脱离监管区域
await _smsService.SendMessageSMS(MessageAlertTypeEnum.RegulatoryAlert, supervisor.FirstOrDefault().UserName, supervisor.FirstOrDefault().Phone, DateTime.Now, "连续未打卡", "", item.SupervisedPersonName);
}
}
}
}
#endregion
//根据当前被监管人员的预警信息,计算出应该被通知的人员(被监管人员自己、监管人、管理员) //根据当前被监管人员的预警信息,计算出应该被通知的人员(被监管人员自己、监管人、管理员)
var earlyWarningRecord = await base.GetEarlyWarningRecord(earlyEntities); var earlyWarningRecord = await base.GetEarlyWarningRecord(earlyEntities);

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

@ -30,6 +30,7 @@ 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 Microsoft.EntityFrameworkCore.ChangeTracking;
using SixLabors.ImageSharp; using SixLabors.ImageSharp;
using System.Linq; using System.Linq;
using Yitter.IdGenerator; using Yitter.IdGenerator;
@ -516,6 +517,14 @@ namespace ATS.NonCustodial.Application.Impl.Business.CaseManagements
var validSpCase = await ValidSupervisedPerson(input); var validSpCase = await ValidSupervisedPerson(input);
if (!validSpCase.Success) return validSpCase; if (!validSpCase.Success) return validSpCase;
if(input.Threshold>=int.MaxValue)
{
return ResultOutput.NotOk("预警阈值输入数字过大");
}
if (input.Threshold <0)
{
return ResultOutput.NotOk("预警阈值不能为负数");
}
#endregion Valid #endregion Valid
var caseId = input.Id; var caseId = input.Id;
@ -532,6 +541,10 @@ namespace ATS.NonCustodial.Application.Impl.Business.CaseManagements
else else
{ {
var entity = Mapper.Map<AppCaseManagement>(input); var entity = Mapper.Map<AppCaseManagement>(input);
if(entity.Threshold==0)
{
entity.Threshold = 5;
}
caseId = (await _appCaseManagementRepository.InsertAsync(entity)).Id; caseId = (await _appCaseManagementRepository.InsertAsync(entity)).Id;
} }

5
src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Input/AppCaseManagementCreateOrModifyInput.cs

@ -45,7 +45,10 @@ namespace ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseMana
/// 接近等级(米) /// 接近等级(米)
/// </summary> /// </summary>
public double ProximityLevel { get; set; } public double ProximityLevel { get; set; }
/// <summary>
/// 预警阈值字段 Threshold
/// </summary>
public long Threshold { get; set; }
/// <summary> /// <summary>
/// 休息开始时间(格式:时分) /// 休息开始时间(格式:时分)
/// </summary> /// </summary>

5
src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Output/AppCaseManagementGetDto.cs

@ -41,6 +41,11 @@ namespace ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseMana
/// </summary> /// </summary>
public double ProximityLevel { get; set; } public double ProximityLevel { get; set; }
/// <summary>
/// 预警阈值字段 Threshold
/// </summary>
public long Threshold { get; set; }
/// <summary> /// <summary>
/// 休息开始时间(时分) /// 休息开始时间(时分)
/// </summary> /// </summary>

5
src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Output/AppCaseManagementListDto.cs

@ -38,6 +38,11 @@ namespace ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseMana
/// </summary> /// </summary>
public long JudgmentStatusId { get; set; } public long JudgmentStatusId { get; set; }
/// <summary>
/// 预警阈值字段 Threshold
/// </summary>
public long Threshold { get; set; }
/// <summary> /// <summary>
/// 接近等级(米) /// 接近等级(米)
/// </summary> /// </summary>

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

@ -201,12 +201,12 @@
//Swagger //Swagger
"SwaggerConfiguration": { "SwaggerConfiguration": {
// //
"Enable": false, "Enable": true,
// //
/* Url["http://localhost:api端口号"] */ /* Url["http://localhost:api端口号"] */
"Url": "http://localhost:8006", "Url": "http://localhost:8006",
"Footer": "\"Copyright<a-icon type=\\\"copyright\\\" /> 2022-<a target=\\\"_blank\\\" href=\\\"https://XXXX\\\">ATS.NonCustodial.Admin</a>\"", "Footer": "\"Copyright<a-icon type=\\\"copyright\\\" /> 2022-<a target=\\\"_blank\\\" href=\\\"https://XXXX\\\">ATS.NonCustodial.Admin</a>\"",
"EnableMiniProfiler": false "EnableMiniProfiler": true
}, },
// //

Loading…
Cancel
Save