diff --git a/src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseManagement.cs b/src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseManagement.cs
index cc29088..cad69ed 100644
--- a/src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseManagement.cs
+++ b/src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseManagement.cs
@@ -57,11 +57,15 @@ namespace ATS.NonCustodial.Domain.Entities.Business.CaseManagements
///
public long JudgmentStatusId { get; set; }
+ ///
+ /// 预警阈值字段 Threshold
+ ///
+ public long Threshold { get; set; } = 5;
+
///
/// 接近等级(米)
///
public double ProximityLevel { get; set; }
-
///
/// 休息开始时间(格式:时分)
///
diff --git a/src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseSupervisedPerson.cs b/src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseSupervisedPerson.cs
index 08c9438..4a82a6b 100644
--- a/src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseSupervisedPerson.cs
+++ b/src/1.datas/ATS.NonCustodial.Domain/Entities/Business/CaseManagements/AppCaseSupervisedPerson.cs
@@ -116,6 +116,13 @@ namespace ATS.NonCustodial.Domain.Entities.Business.CaseManagements
///
public int PrivacyLevel { get; set; }
+ ///
+ /// 未打卡记录,用来和预警阈值做比较
+ /// 按时打卡,此值清零
+ /// 未打卡预警一次,此值+1
+ /// 当未打卡记录值大于预警阈值时,触发短信通知
+ ///
+ public int AttendanceRecord { get; set; } = 0;
///
/// 绑定提交时录入的人脸照片地址
///
diff --git a/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppEarlyWarningService.cs b/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppEarlyWarningService.cs
index 7e7b965..6cdde37 100644
--- a/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppEarlyWarningService.cs
+++ b/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppEarlyWarningService.cs
@@ -1,6 +1,7 @@
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.User;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement;
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.IM.Notifies;
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.Domain.Entities.Admins;
using ATS.NonCustodial.Domain.Entities.Business;
using ATS.NonCustodial.Domain.Entities.Business.CaseManagements;
using ATS.NonCustodial.Domain.Entities.Business.EarlyWarning;
@@ -72,6 +75,9 @@ namespace ATS.NonCustodial.Application.Impl.Business
private readonly IEfRepository _appEarlyWarningRuleRepository;
private readonly IAppCaseManagementService _appCaseManagementService;
private readonly IUserService _userService;
+ private readonly ISMSService _smsService;
+ private readonly IEfRepository _appSupervisorRepository;
+ private readonly IEfRepository _appUserRepository;
///
///
@@ -86,7 +92,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
///
///
///
- public AppEarlyWarningService(IEfRepository appEarlyWarningRepository,
+ public AppEarlyWarningService(IEfRepository appSupervisorRepository, IEfRepository appEarlyWarningRepository,
IEfRepository appEarlyWarningPushResultRepository,
IHubContext hubContext,
IEfRepository appCaseManagementRepository,
@@ -97,13 +103,14 @@ namespace ATS.NonCustodial.Application.Impl.Business
IEfRepository appDeviceManagementRepository,
IEfRepository appSessionInformationRepository,
IAppCommonFenceService appCommonFenceService,
-
+ IEfRepository appUserRepository,
IAppCaseManagementService appCaseManagementService,
IEfRepository appBusinessApplicationRepository,
IEfRepository appSupervisedPersonRealTimeLocationRepository,
IClientNotifyService clientNotifyService,
IEfRepository appEarlyWarningViewStatisticsRepository,
- IEfRepository appEarlyWarningRuleRepository)
+ IEfRepository appEarlyWarningRuleRepository,
+ ISMSService smsService)
: base(
appCaseManagementRepository,
appCaseSupervisorRepository,
@@ -113,6 +120,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
appSupervisedPersonRealTimeLocationRepository
)
{
+ _appSupervisorRepository = appSupervisorRepository;
_appEarlyWarningRepository = appEarlyWarningRepository;
_appEarlyWarningPushResultRepository = appEarlyWarningPushResultRepository;
_hubContext = hubContext;
@@ -124,6 +132,9 @@ namespace ATS.NonCustodial.Application.Impl.Business
_appEarlyWarningRuleRepository = appEarlyWarningRuleRepository;
_appCaseManagementService = appCaseManagementService;
_userService = userService;
+ _smsService = smsService;
+ _appUserRepository = appUserRepository;
+
}
#endregion Identity
@@ -144,6 +155,24 @@ namespace ATS.NonCustodial.Application.Impl.Business
//字典
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);
diff --git a/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppManagementService.cs b/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppManagementService.cs
index 02e2d7d..5f0c5ac 100644
--- a/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppManagementService.cs
+++ b/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.Output;
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.Input;
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.Domain.Entities.Admins;
using ATS.NonCustodial.Domain.Entities.Business;
@@ -51,8 +48,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
-using NPOI.SS.UserModel;
-using System.IO;
namespace ATS.NonCustodial.Application.Impl.Business
{
@@ -189,7 +184,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
public async Task>> GetSupervisedPersonListByName(string? name)
{
//CaseProgressEnum案件已结束的不再展示
- var rtn = (await GetCaseListDetail(name)).Where(w => w.Latitude != null && w.Longitude != null&&w.CaseProgress!= CaseProgressEnum.Closed).ToList();
+ var rtn = (await GetCaseListDetail(name)).Where(w => w.Latitude != null && w.Longitude != null && w.CaseProgress != CaseProgressEnum.Closed).ToList();
//返回结果
return (IResultOutput>)ResultOutput.Ok(rtn);
@@ -319,15 +314,15 @@ namespace ATS.NonCustodial.Application.Impl.Business
{
var userCase = await base.GetCurrentSupervisePersonProcessingCase(input.SupervisedPersonId ?? User.Id);
- if (userCase == null) return new ResultOutput>();
-
- return (IResultOutput>)await _appPunchRecordService.GetPageAsync(new AppPunchRecordGetPageInput()
- {
- Id = userCase.CaseId,
- SupervisedPersonId = input.SupervisedPersonId ?? User.Id,
- PageIndex = input.PageIndex,
- PageSize = input.PageSize
- });
+ return userCase == null
+ ? new ResultOutput>()
+ : (IResultOutput>)await _appPunchRecordService.GetPageAsync(new AppPunchRecordGetPageInput()
+ {
+ Id = userCase.CaseId,
+ SupervisedPersonId = input.SupervisedPersonId ?? User.Id,
+ PageIndex = input.PageIndex,
+ PageSize = input.PageSize
+ });
}
///
@@ -560,14 +555,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
{
item.CheckStatus = input.CheckStatus;
- if (input.CheckStatus == CheckStatusEnum.Checked)
- {
- item.CheckTime = DateTime.Now;
- }
- else
- {
- item.CheckTime = null;
- }
+ item.CheckTime = input.CheckStatus == CheckStatusEnum.Checked ? DateTime.Now : null;
}
await _appBusinessApplicationViewStatisticsRepository.UpdateAsync(busViewList);
@@ -639,10 +627,10 @@ namespace ATS.NonCustodial.Application.Impl.Business
//职位名字
if (User.ChatPersonType != ChatPersonTypeEnum.SupervisedPerson) return item;
{
- var positionName = receiverList.FirstOrDefault(w => w.Id == item.ReceiverId)?.PositionName;
- if (postDict.ContainsKey(positionName))
+ var positionName = receiverList.FirstOrDefault(w => w.Id == item.ReceiverId)?.PositionName ?? "未知职位";
+ if (postDict.TryGetValue(positionName, out int count))
{
- postDict[positionName] += 1;
+ postDict[positionName] = count + 1;
}
else
{
@@ -710,13 +698,13 @@ namespace ATS.NonCustodial.Application.Impl.Business
spcr.SupervisedPersonId
}).FirstOrDefaultAsync();
- if (data == null) return new ResultOutput();
-
- return await this.GetSuperPersonCaseDetail(new GetSuperPersonCaseDetailInput()
- {
- CaseId = data!.Id,
- SuperPersonId = data.SupervisedPersonId
- });
+ return data == null
+ ? new ResultOutput()
+ : await this.GetSuperPersonCaseDetail(new GetSuperPersonCaseDetailInput()
+ {
+ CaseId = data!.Id,
+ SuperPersonId = data.SupervisedPersonId
+ });
}
///
@@ -730,7 +718,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
List rtn;
var totalCount = 0;
//如果SupervisedPersonId不为空并查询结果为空执行下面查询
- var currentCase = await GetCurrentSupervisePersonProcessingCase(input.SupervisedPersonId!=null ? (long)input.SupervisedPersonId : User.Id);
+ var currentCase = await GetCurrentSupervisePersonProcessingCase(input.SupervisedPersonId != null ? (long)input.SupervisedPersonId : User.Id);
if (input.RemindType == AppRemindTypeEnum.EarlyWarning)
{
var earlyWarningList = (from ew in _appEarlyWarningRepository.AsQueryable(false, true)
@@ -858,7 +846,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
//发短信给监管人,提醒处理审批
await _smsService.SendMessageSMS(MessageAlertTypeEnum.ReviewNotification, user.FirstOrDefault().UserName, user.FirstOrDefault().Phone, DateTime.Now, applicationType.Name, "", currentUserCase.SupervisedPersonName);
}
- return await _appBusinessApplicationService.CreateOrModify(input);
+ return await _appBusinessApplicationService.CreateOrModify(input);
}
///
@@ -873,7 +861,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
join ba in _appBusinessApplicationRepository.AsQueryable(false, true) on c.Id equals ba.CaseId
select ba)
.WhereIf(input.AuditStatus != null, w => w.AuditStatus == input.AuditStatus)
- .Where(w => w.SupervisedPersonId == (input.SupervisedPersonId!=null ? input.SupervisedPersonId : User.Id))
+ .Where(w => w.SupervisedPersonId == (input.SupervisedPersonId != null ? input.SupervisedPersonId : User.Id))
.OrderByDescending(w => w.CreatedTime);
//正在进行的案件
@@ -906,14 +894,14 @@ namespace ATS.NonCustodial.Application.Impl.Business
join a in _appSupervisedPersonRepository.AsQueryable(false, true) on c.Id equals a.CaseId
join ba in _appFileAccessRecordsRepository.AsQueryable(false, true) on a.SupervisedPersonId equals ba.SupervisedPersonId
select ba)
- .Where(w => w.SupervisedPersonId == (input.SupervisedPersonId!=null ? input.SupervisedPersonId : User.Id))
+ .Where(w => w.SupervisedPersonId == (input.SupervisedPersonId != null ? input.SupervisedPersonId : User.Id))
.OrderByDescending(w => w.CreatedTime);
var Direclist = (from c in _appDirectoryDescriptorRepository.AsQueryable(false, true)
join a in _appFileDescriptorRepository.AsQueryable(false, true) on c.Id equals a.DirectoryId
- select new{ typename=c.Name, a.Name,a.Id,a.DirectoryId }).ToList();
+ select new { typename = c.Name, a.Name, a.Id, a.DirectoryId }).ToList();
foreach (var item in Direclist)
{
- var Direcbol = query.ToList().Where(q => q.FileDescriptorId == item.Id&&q.CaseId==(input.CaseId!=null? input.CaseId:0)).OrderByDescending(q=>q.CreatedTime).ToList();
+ var Direcbol = query.ToList().Where(q => q.FileDescriptorId == item.Id && q.CaseId == (input.CaseId != null ? input.CaseId : 0)).OrderByDescending(q => q.CreatedTime).ToList();
if (Direcbol.Count > 0)
{
list.Add(new
@@ -924,21 +912,21 @@ namespace ATS.NonCustodial.Application.Impl.Business
bol = true
});
}
- else
+ else
{
list.Add(new
{
typename = $"{item.typename}",
name = $"{item.Name}",
- time="",
+ time = "",
bol = false
});
}
}
var totalCount = list.Count();
- var pagelist = list.Skip((input.PageIndex - 1) * input.PageSize)
- .Take(input.PageSize);
+ var pagelist = list.Skip((input.PageIndex - 1) * input.PageSize)
+ .Take(input.PageSize);
return ResultOutput.Ok(new
{
TotalCount = totalCount,
@@ -958,7 +946,10 @@ namespace ATS.NonCustodial.Application.Impl.Business
///
///
///
- public async Task AddPunchRecord(AppPunchRecordAddInput input) => await _appPunchRecordService.AddAsync(input);
+ public async Task AddPunchRecord(AppPunchRecordAddInput input)
+ {
+ return await _appPunchRecordService.AddAsync(input);
+ }
///
/// 被监管人登录
@@ -1010,7 +1001,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
if (!string.IsNullOrEmpty(input.phone))
{
bool checkCode = await _smsService.CheckCodeAsync(input.phone, input.checkCode, "CheckCode");
- if (!checkCode) return ResultOutput.NotOk("无效验证码");
+ if (!checkCode) return ResultOutput.NotOk("验证码错误");
}
//[1]校验当前账户是否是第一次绑定
//if (!await _appSupervisedPersonRepository.AnyAsync(w => w.IdCard == input.IdCard && !w.IsBound)) return ResultOutput.NotOk("当前身份没有被监管,请检查身份证是否输入正确");
@@ -1043,10 +1034,10 @@ namespace ATS.NonCustodial.Application.Impl.Business
spData.EnterFace = input.EnterFace;
spData.IMEI = input.IMEI;
var userdata = _appUserRepository.AsQueryable(false, true).Where(q => q.Id == spData.SupervisedPersonId).FirstOrDefault();
- if (userdata!=null)
+ if (userdata != null)
{
userdata.CId = input.CId;
- await _appUserRepository.UpdateAsync(userdata,UpdatingProps(q=>q.CId));
+ await _appUserRepository.UpdateAsync(userdata, UpdatingProps(q => q.CId));
}
await _appSupervisedPersonRepository.UpdateAsync(spData);
@@ -1196,7 +1187,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
.WhereIf(input.CheckStatus.HasValue, w => w.CheckStatus == input.CheckStatus)
.ToListAsync();
earlyList = earlyList.Distinct((x, y) => x.CaseId == y.CaseId && x.SupervisedPersonId == y.SupervisedPersonId && x.CreatedTime == y.CreatedTime).OrderByDescending(q => q.CreatedTime).ToList();
- if (!input.CheckStatus.HasValue)
+ if (!input.CheckStatus.HasValue)
{
var WarningList = new List();
var NotChecked = earlyList.Where(q => q.CheckStatus == CheckStatusEnum.NotChecked).OrderByDescending(q => q.CreatedTime).ToList();
@@ -1231,9 +1222,9 @@ namespace ATS.NonCustodial.Application.Impl.Business
var caseIdList = selectLimits.Select(w => w.CaseId).Distinct().ToList();
var data = (await base.GetCurrentUserCaseListAsync())
- .Where(W => W.AppCaseManagement!=null&& W.AppCaseManagement.CaseProgress != CaseProgressEnum.Closed && caseIdList.Contains(W.AppCaseManagement.Id))
- .Where(W => W.AppCaseSupervisedPerson != null&& caseIdList.Contains(W.AppCaseSupervisedPerson.CaseId))
- .Where(W=>W.AppCaseSupervisor!=null && caseIdList.Contains(W.AppCaseSupervisor.CaseId))
+ .Where(W => W.AppCaseManagement != null && W.AppCaseManagement.CaseProgress != CaseProgressEnum.Closed && caseIdList.Contains(W.AppCaseManagement.Id))
+ .Where(W => W.AppCaseSupervisedPerson != null && caseIdList.Contains(W.AppCaseSupervisedPerson.CaseId))
+ .Where(W => W.AppCaseSupervisor != null && caseIdList.Contains(W.AppCaseSupervisor.CaseId))
.WhereIf(name.NotNull(), w => w.AppCaseSupervisedPerson.SupervisedPersonName!.Contains(name))
.Select(w => new
{
@@ -1315,7 +1306,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
var caseIdList = selectLimits.Select(w => w.CaseId).Distinct().ToList();
var data = (await base.GetCurrentUserCaseListAsync())
- .Where(W => W.AppCaseManagement!=null&& W.AppCaseSupervisedPerson != null && W.AppCaseSupervisor != null && W.AppCaseManagement.CaseProgress != CaseProgressEnum.Pending && caseIdList.Contains(W.AppCaseManagement.Id)&&caseIdList.Contains(W.AppCaseSupervisedPerson.CaseId)&&caseIdList.Contains(W.AppCaseSupervisor.CaseId))
+ .Where(W => W.AppCaseManagement != null && W.AppCaseSupervisedPerson != null && W.AppCaseSupervisor != null && W.AppCaseManagement.CaseProgress != CaseProgressEnum.Pending && caseIdList.Contains(W.AppCaseManagement.Id) && caseIdList.Contains(W.AppCaseSupervisedPerson.CaseId) && caseIdList.Contains(W.AppCaseSupervisor.CaseId))
.WhereIf(name.NotNull(), w => w.AppCaseSupervisedPerson.SupervisedPersonName!.Contains(name))
.Select(w => new
{
diff --git a/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppPunchRecordService.cs b/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppPunchRecordService.cs
index bf2f086..975ce9a 100644
--- a/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppPunchRecordService.cs
+++ b/src/2.services/ATS.NonCustodial.Application/Impl/Business/AppPunchRecordService.cs
@@ -1,11 +1,7 @@
-using System.Linq;
-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.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.User;
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement;
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.Input;
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.Business;
using ATS.NonCustodial.Domain.Entities.Business.CaseManagements;
@@ -32,13 +27,10 @@ using ATS.NonCustodial.Shared.Extensions;
using ATS.NonCustodial.Shared.Extensions.Collection;
using AutoMapper.QueryableExtensions;
using Castle.Components.DictionaryAdapter;
-using ICSharpCode.SharpZipLib.Zip;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using NPOI.SS.Formula.PTG;
+using System.Dynamic;
using Yitter.IdGenerator;
namespace ATS.NonCustodial.Application.Impl.Business
@@ -60,7 +52,9 @@ namespace ATS.NonCustodial.Application.Impl.Business
private readonly IEfRepository _appuserRepository;
private readonly IEfRepository _appEarlyWarningRepository;
private readonly IEfRepository _appauditrecordsRepository;
+ private readonly IEfRepository _appUserRepository;
+ private readonly ISMSService _smsService;
public AppPunchRecordService(IEfRepository appPunchRecordStatisticsRepository,
IAppCaseManagementService appCaseManagementService,
IEfRepository appCaseManagementRepository,
@@ -69,10 +63,12 @@ namespace ATS.NonCustodial.Application.Impl.Business
IEfRepository appCaseSupervisorRepository,
IUserService userService,
IAppDictionaryService appDictionaryService,
+ IEfRepository appUserRepository,
IEfRepository asprl,
IEfRepository appuserRepository,
IAppEarlyWarningService appEarlyWarningService, IEfRepository appauditrecords,
- IEfRepository appEarlyWarningRepository)
+ IEfRepository appEarlyWarningRepository,
+ ISMSService smsService)
: base(
appCaseManagementRepository,
appCaseSupervisorRepository,
@@ -88,6 +84,8 @@ namespace ATS.NonCustodial.Application.Impl.Business
_appEarlyWarningRepository = appEarlyWarningRepository;
_appauditrecordsRepository = appauditrecords;
_appuserRepository = appuserRepository;
+ _smsService = smsService;
+ _appUserRepository = appUserRepository;
}
#endregion Identity
@@ -190,7 +188,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
.ToListAsync();
var caseIds = selectLimits.Select(w => w.CaseId).Distinct().ToList();
- // var caseIds = await (await base.GetCurrentUserCaseListAsync()).Select(w => w.AppCaseManagement.Id).ToListAsync();
+ // var caseIds = await (await base.GetCurrentUserCaseListAsync()).Select(w => w.AppCaseManagement.Id).ToListAsync();
//var list= await base._appSupervisedPersonRepository.AsQueryable(false, true).Where(q=> caseIds.Contains(q.CaseId)).ToListAsync();
var data = await _appPunchRecordStatisticsRepository
@@ -229,6 +227,14 @@ namespace ATS.NonCustodial.Application.Impl.Business
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 打卡消息推送手机通知栏
//被监管人id
var list = new List();
@@ -241,8 +247,8 @@ namespace ATS.NonCustodial.Application.Impl.Business
SupervisedIds.Add(q.SupervisedId);
});
//获取监管人手机唯一id
- var supervisecids=_appuserRepository.AsQueryable(false, true).ToList().Where(q => SupervisedIds.Contains(q.Id));
- if (supervisecids.Where(q=>!string.IsNullOrEmpty(q.CId)).Count()>0)
+ var supervisecids = _appuserRepository.AsQueryable(false, true).ToList().Where(q => SupervisedIds.Contains(q.Id));
+ if (supervisecids.Where(q => !string.IsNullOrEmpty(q.CId)).Count() > 0)
{
try
{
@@ -254,7 +260,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
base.GettoekenQuery();
var tokenstr = Cache.Get("token");
var msg_list = new List();
- foreach (var item in supervisecids.Where(q=> !string.IsNullOrEmpty(q.CId)))
+ foreach (var item in supervisecids.Where(q => !string.IsNullOrEmpty(q.CId)))
{
//随机生成数
var request_id = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 32).ToString();
@@ -365,7 +371,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
var spIds = await spList.Where(q => q.AppCaseSupervisedPerson != null && caseIdList.Contains(q.AppCaseSupervisedPerson.CaseId)).Select(w => w.AppCaseSupervisedPerson!.SupervisedPersonId).ToListAsync();
//查询记录
var query = await _appPunchRecordStatisticsRepository
- .AsQueryable(false, true).Where(q => spIds.Contains(q.SupervisedPersonId)&& caseIdList.Contains(q.CaseId))
+ .AsQueryable(false, true).Where(q => spIds.Contains(q.SupervisedPersonId) && caseIdList.Contains(q.CaseId))
.WhereIf(input.CaseId != default, a => a.CaseId == input.CaseId)
.WhereIf(input.SupervisedPersonId != default, w => w.SupervisedPersonId == input.SupervisedPersonId)
.WhereIf(startTime != DateTime.MinValue, w => w.CreatedTime >= startTime)
@@ -421,7 +427,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
var allCaseList = await (from c in _appCaseManagementRepository.AsQueryable(false, true)
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
- where c.CaseProgress != CaseProgressEnum.Pending&& c.CaseProgress != CaseProgressEnum.Closed && limits.Contains((char)csr.UnitId)
+ where c.CaseProgress != CaseProgressEnum.Pending && c.CaseProgress != CaseProgressEnum.Closed && limits.Contains((char)csr.UnitId)
select new CheckPunchRecordForJobOutput()
{
CaseId = c.Id,
@@ -549,12 +555,12 @@ namespace ATS.NonCustodial.Application.Impl.Business
[HttpGet, AllowAnonymous]
public async Task CheckPunchRecordForJob()
{
- var limits = User.limits;
+ // var limits = User.limits;
//[1]获取所有正在执行中的被监管人案件
var allCaseList = await (from c in _appCaseManagementRepository.AsQueryable(false, true)
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
- 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()
{
CaseId = c.Id,
@@ -669,7 +675,35 @@ namespace ATS.NonCustodial.Application.Impl.Business
earlyEntity.Content!.Contains(w.Content))).ToList();
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);
diff --git a/src/2.services/ATS.NonCustodial.Application/Impl/Business/CaseManagements/AppCaseManagementService.cs b/src/2.services/ATS.NonCustodial.Application/Impl/Business/CaseManagements/AppCaseManagementService.cs
index d1b42f4..0ad33c7 100644
--- a/src/2.services/ATS.NonCustodial.Application/Impl/Business/CaseManagements/AppCaseManagementService.cs
+++ b/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.Mvc;
using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.ChangeTracking;
using SixLabors.ImageSharp;
using System.Linq;
using Yitter.IdGenerator;
@@ -516,6 +517,14 @@ namespace ATS.NonCustodial.Application.Impl.Business.CaseManagements
var validSpCase = await ValidSupervisedPerson(input);
if (!validSpCase.Success) return validSpCase;
+ if(input.Threshold>=int.MaxValue)
+ {
+ return ResultOutput.NotOk("预警阈值输入数字过大");
+ }
+ if (input.Threshold <0)
+ {
+ return ResultOutput.NotOk("预警阈值不能为负数");
+ }
#endregion Valid
var caseId = input.Id;
@@ -532,6 +541,10 @@ namespace ATS.NonCustodial.Application.Impl.Business.CaseManagements
else
{
var entity = Mapper.Map(input);
+ if(entity.Threshold==0)
+ {
+ entity.Threshold = 5;
+ }
caseId = (await _appCaseManagementRepository.InsertAsync(entity)).Id;
}
diff --git a/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Input/AppCaseManagementCreateOrModifyInput.cs b/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Input/AppCaseManagementCreateOrModifyInput.cs
index 952ef11..74a69c3 100644
--- a/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Input/AppCaseManagementCreateOrModifyInput.cs
+++ b/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
/// 接近等级(米)
///
public double ProximityLevel { get; set; }
-
+ ///
+ /// 预警阈值字段 Threshold
+ ///
+ public long Threshold { get; set; }
///
/// 休息开始时间(格式:时分)
///
diff --git a/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Output/AppCaseManagementGetDto.cs b/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Output/AppCaseManagementGetDto.cs
index f532369..998d142 100644
--- a/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Output/AppCaseManagementGetDto.cs
+++ b/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
///
public double ProximityLevel { get; set; }
+ ///
+ /// 预警阈值字段 Threshold
+ ///
+ public long Threshold { get; set; }
+
///
/// 休息开始时间(时分)
///
diff --git a/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Output/AppCaseManagementListDto.cs b/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Output/AppCaseManagementListDto.cs
index 10aaae4..6a4d73e 100644
--- a/src/3.contracts/ATS.NonCustodial.Application.Contracts/Interfaces/Business/AppCaseManagements/AppCaseManagement/Output/AppCaseManagementListDto.cs
+++ b/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
///
public long JudgmentStatusId { get; set; }
+ ///
+ /// 预警阈值字段 Threshold
+ ///
+ public long Threshold { get; set; }
+
///
/// 接近等级(米)
///
diff --git a/src/4.apps/ATS.NonCustodial.Admin.Api/configs/appsettings.json b/src/4.apps/ATS.NonCustodial.Admin.Api/configs/appsettings.json
index 8f159a3..583fbb8 100644
--- a/src/4.apps/ATS.NonCustodial.Admin.Api/configs/appsettings.json
+++ b/src/4.apps/ATS.NonCustodial.Admin.Api/configs/appsettings.json
@@ -201,12 +201,12 @@
//Swagger文档
"SwaggerConfiguration": {
//启用
- "Enable": false,
+ "Enable": true,
//地址
/* Url:["http://localhost:api端口号"] */
"Url": "http://localhost:8006",
"Footer": "\"Copyright 2022-ATS.NonCustodial.Admin\"",
- "EnableMiniProfiler": false
+ "EnableMiniProfiler": true
},
//日志配置