|
|
|
@ -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>(); |
|
|
|
@ -241,8 +247,8 @@ namespace ATS.NonCustodial.Application.Impl.Business |
|
|
|
SupervisedIds.Add(q.SupervisedId); |
|
|
|
SupervisedIds.Add(q.SupervisedId); |
|
|
|
}); |
|
|
|
}); |
|
|
|
//获取监管人手机唯一id |
|
|
|
//获取监管人手机唯一id |
|
|
|
var supervisecids=_appuserRepository.AsQueryable(false, true).ToList().Where(q => SupervisedIds.Contains(q.Id)); |
|
|
|
var supervisecids = _appuserRepository.AsQueryable(false, true).ToList().Where(q => SupervisedIds.Contains(q.Id)); |
|
|
|
if (supervisecids.Where(q=>!string.IsNullOrEmpty(q.CId)).Count()>0) |
|
|
|
if (supervisecids.Where(q => !string.IsNullOrEmpty(q.CId)).Count() > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -254,7 +260,7 @@ namespace ATS.NonCustodial.Application.Impl.Business |
|
|
|
base.GettoekenQuery(); |
|
|
|
base.GettoekenQuery(); |
|
|
|
var tokenstr = Cache.Get("token"); |
|
|
|
var tokenstr = Cache.Get("token"); |
|
|
|
var msg_list = new List<dynamic>(); |
|
|
|
var msg_list = new List<dynamic>(); |
|
|
|
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(); |
|
|
|
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 spIds = await spList.Where(q => q.AppCaseSupervisedPerson != null && caseIdList.Contains(q.AppCaseSupervisedPerson.CaseId)).Select(w => w.AppCaseSupervisedPerson!.SupervisedPersonId).ToListAsync(); |
|
|
|
//查询记录 |
|
|
|
//查询记录 |
|
|
|
var query = await _appPunchRecordStatisticsRepository |
|
|
|
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.CaseId != default, a => a.CaseId == input.CaseId) |
|
|
|
.WhereIf(input.SupervisedPersonId != default, w => w.SupervisedPersonId == input.SupervisedPersonId) |
|
|
|
.WhereIf(input.SupervisedPersonId != default, w => w.SupervisedPersonId == input.SupervisedPersonId) |
|
|
|
.WhereIf(startTime != DateTime.MinValue, w => w.CreatedTime >= startTime) |
|
|
|
.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) |
|
|
|
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 && limits.Contains((char)csr.UnitId) |
|
|
|
where c.CaseProgress != CaseProgressEnum.Pending && c.CaseProgress != CaseProgressEnum.Closed && limits.Contains((char)csr.UnitId) |
|
|
|
select new CheckPunchRecordForJobOutput() |
|
|
|
select new CheckPunchRecordForJobOutput() |
|
|
|
{ |
|
|
|
{ |
|
|
|
CaseId = c.Id, |
|
|
|
CaseId = c.Id, |
|
|
|
@ -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); |
|
|
|
|
|
|
|
|
|
|
|
|