|
|
|
|
@ -1,17 +1,21 @@
|
|
|
|
|
using ATS.NonCustodial.Application.Base; |
|
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.AppDictionaries; |
|
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Admins.User; |
|
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppCaseManagements.AppCaseManagement.Output; |
|
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.AppEarlyWarnings.Output; |
|
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.ViolationStatistics; |
|
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.ViolationStatistics.Input; |
|
|
|
|
using ATS.NonCustodial.Application.Contracts.Interfaces.Business.ViolationStatistics.Output; |
|
|
|
|
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; |
|
|
|
|
using ATS.NonCustodial.Domain.Shared.AggRootEntities.Dtos; |
|
|
|
|
using ATS.NonCustodial.Domain.Shared.Enums; |
|
|
|
|
using ATS.NonCustodial.Domain.Shared.OrmRepositories.Basic.EfCore; |
|
|
|
|
using ATS.NonCustodial.DynamicApi; |
|
|
|
|
using ATS.NonCustodial.DynamicApi.Attributes; |
|
|
|
|
using ATS.NonCustodial.Shared.Common.Auth; |
|
|
|
|
using ATS.NonCustodial.Shared.Common.Dtos; |
|
|
|
|
using ATS.NonCustodial.Shared.Common.UnifiedResults; |
|
|
|
|
using ATS.NonCustodial.Shared.Extensions; |
|
|
|
|
@ -40,6 +44,8 @@ namespace ATS.NonCustodial.Application.Impl.Business
|
|
|
|
|
private readonly IEfRepository<AppEarlyWarning, long> _appEarlyWarningRepository; |
|
|
|
|
private readonly IUserService _userService; |
|
|
|
|
private readonly IEfRepository<AppCaseSupervisedPerson, long> _appSupervisedPersonRepository; |
|
|
|
|
private readonly IEfRepository<AppCaseSupervisor, long> _appSupervisorRepository; |
|
|
|
|
private readonly IEfRepository<AppUser?, long> _userRepository; |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
@ -48,7 +54,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
|
|
|
|
|
/// <param name="appDictionaryService"></param> |
|
|
|
|
/// <param name="appEarlyWarningRepository"></param> |
|
|
|
|
/// <param name="userService"></param> |
|
|
|
|
public AppViolationStatisticsService(IEfRepository<AppViolationStatistics, long> appViolationStatisticsRepository, |
|
|
|
|
public AppViolationStatisticsService(IEfRepository<AppUser?, long> userRepository, IEfRepository<AppCaseSupervisor, long> appSupervisorRepository, IEfRepository<AppViolationStatistics, long> appViolationStatisticsRepository, |
|
|
|
|
IAppDictionaryService appDictionaryService, |
|
|
|
|
IEfRepository<AppEarlyWarning, long> appEarlyWarningRepository, |
|
|
|
|
IUserService userService, |
|
|
|
|
@ -63,11 +69,13 @@ namespace ATS.NonCustodial.Application.Impl.Business
|
|
|
|
|
appDictionaryService, |
|
|
|
|
asprl) |
|
|
|
|
{ |
|
|
|
|
_appSupervisorRepository = appSupervisorRepository; |
|
|
|
|
_appViolationStatisticsRepository = appViolationStatisticsRepository; |
|
|
|
|
_appDictionaryService = appDictionaryService; |
|
|
|
|
_appEarlyWarningRepository = appEarlyWarningRepository; |
|
|
|
|
_userService = userService; |
|
|
|
|
_appSupervisedPersonRepository = appCaseSupervisedPersonRepository; |
|
|
|
|
_userRepository = userRepository; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion Identity |
|
|
|
|
@ -308,6 +316,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
|
|
|
|
|
.Where(w => caseIdList.Contains(w.Id)) |
|
|
|
|
.WhereIf(input.CaseId.HasValue, w => w.Id == input.CaseId) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
var applicationType = await base.GetDictionariesOutput("early_warning_type", "notClocked"); |
|
|
|
|
|
|
|
|
|
List<NotClockListDto> notClockList = new List<NotClockListDto>(); |
|
|
|
|
foreach (var item in caseList) |
|
|
|
|
@ -320,7 +329,11 @@ namespace ATS.NonCustodial.Application.Impl.Business
|
|
|
|
|
notClockListDto.CaseName = item.Name; |
|
|
|
|
notClockListDto.CreatedTime = item.CreatedTime; |
|
|
|
|
notClockListDto.CaseTypeName = caseType.Name; |
|
|
|
|
notClockListDto.SupervisionUnit = ""; |
|
|
|
|
var unitList = await (from c in _appSupervisorRepository.AsQueryable(false, true) |
|
|
|
|
join u in _userRepository.AsQueryable(false, true) on c.SupervisorId equals u.Id |
|
|
|
|
where c.CaseId == item.Id |
|
|
|
|
select u.Unitname).FirstOrDefaultAsync(); |
|
|
|
|
notClockListDto.SupervisionUnit = unitList; |
|
|
|
|
//根据案件找到被监管 |
|
|
|
|
var supervisedPerson = await _appSupervisedPersonRepository |
|
|
|
|
.AsQueryable(false, true) |
|
|
|
|
@ -332,7 +345,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
|
|
|
|
|
notClockListDto.SupervisedPersonName = person.SupervisedPersonName; |
|
|
|
|
var earlyList = await _appEarlyWarningRepository |
|
|
|
|
.AsQueryable(false, true) |
|
|
|
|
.Where(w => w.Title == "未打卡" && w.SupervisedPersonId == person.SupervisedPersonId |
|
|
|
|
.Where(w => w.EarlyWarningTypeId == applicationType.Id && w.SupervisedPersonId == person.SupervisedPersonId |
|
|
|
|
&& w.CaseId == item.Id) |
|
|
|
|
.WhereIf(input.EndCreatedTime.HasValue, w => w.CreatedTime <= input.EndCreatedTime) |
|
|
|
|
.WhereIf(input.StartCreatedTime.HasValue, w => w.CreatedTime >= input.StartCreatedTime) |
|
|
|
|
@ -342,8 +355,83 @@ namespace ATS.NonCustodial.Application.Impl.Business
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
var pageData = notClockList.Skip((input.PageIndex - 1) * input.PageSize) |
|
|
|
|
.Take(input.PageSize).ToList(); |
|
|
|
|
var pageResult = new PagedList<NotClockListDto>() |
|
|
|
|
{ |
|
|
|
|
TotalCount = notClockList.Count(), |
|
|
|
|
Data = pageData |
|
|
|
|
}; |
|
|
|
|
return ResultOutput.Ok(pageResult); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 越界统计 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
[HttpPost] |
|
|
|
|
public async Task<IResultOutput> LeaveAreaStatisticsPageAsync(NotClockedInput input) |
|
|
|
|
{ |
|
|
|
|
//获取当前用户权限下的案件ids |
|
|
|
|
var limits = User.limits; |
|
|
|
|
var selectLimits = await _appCaseSupervisorRepository.AsQueryable(false, true) |
|
|
|
|
.Where(w => limits.Contains(w.UnitId.ToString())) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
var caseIdList = selectLimits.Select(w => w.CaseId).Distinct().ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var caseList = await _appCaseManagementRepository.AsQueryable(false, true) |
|
|
|
|
.Where(w => caseIdList.Contains(w.Id)) |
|
|
|
|
.WhereIf(input.CaseId.HasValue, w => w.Id == input.CaseId) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
var applicationType = await base.GetDictionariesOutput("early_warning_type", "LeaveArea"); |
|
|
|
|
|
|
|
|
|
return ResultOutput.Ok(notClockList); |
|
|
|
|
List<ViolationListDto> notClockList = new List<ViolationListDto>(); |
|
|
|
|
foreach (var item in caseList) |
|
|
|
|
{ |
|
|
|
|
if (item == null) continue; |
|
|
|
|
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) |
|
|
|
|
join u in _userRepository.AsQueryable(false, true) on c.SupervisorId equals u.Id |
|
|
|
|
where c.CaseId == item.Id |
|
|
|
|
select u.Unitname).FirstOrDefaultAsync(); |
|
|
|
|
notClockListDto.SupervisionUnit = unitList; |
|
|
|
|
//根据案件找到被监管 |
|
|
|
|
var supervisedPerson = await _appSupervisedPersonRepository |
|
|
|
|
.AsQueryable(false, true) |
|
|
|
|
.Where(w => w.CaseId == item.Id) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
foreach (var person in supervisedPerson) |
|
|
|
|
{ |
|
|
|
|
notClockListDto.SupervisedPersonId = person.SupervisedPersonId; |
|
|
|
|
notClockListDto.SupervisedPersonName = person.SupervisedPersonName; |
|
|
|
|
var earlyList = await _appEarlyWarningRepository |
|
|
|
|
.AsQueryable(false, true) |
|
|
|
|
.Where(w => w.EarlyWarningTypeId == applicationType.Id && w.SupervisedPersonId == person.SupervisedPersonId |
|
|
|
|
&& w.CaseId == item.Id) |
|
|
|
|
.WhereIf(input.EndCreatedTime.HasValue, w => w.CreatedTime <= input.EndCreatedTime) |
|
|
|
|
.WhereIf(input.StartCreatedTime.HasValue, w => w.CreatedTime >= input.StartCreatedTime) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
notClockListDto.ViolationCount = earlyList.Count; |
|
|
|
|
notClockList.Add(notClockListDto); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
var pageData = notClockList.Skip((input.PageIndex - 1) * input.PageSize) |
|
|
|
|
.Take(input.PageSize).ToList(); |
|
|
|
|
var pageResult = new PagedList<ViolationListDto>() |
|
|
|
|
{ |
|
|
|
|
TotalCount = notClockList.Count(), |
|
|
|
|
Data = pageData |
|
|
|
|
}; |
|
|
|
|
return ResultOutput.Ok(pageResult); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
@ -365,6 +453,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
|
|
|
|
|
.Where(w => caseIdList.Contains(w.Id)) |
|
|
|
|
.WhereIf(input.CaseId.HasValue, w => w.Id == input.CaseId) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
var applicationType = await base.GetDictionariesOutput("early_warning_type", "notClocked"); |
|
|
|
|
|
|
|
|
|
List<NotClockExportDto> notClockList = new List<NotClockExportDto>(); |
|
|
|
|
foreach (var item in caseList) |
|
|
|
|
@ -389,7 +478,7 @@ namespace ATS.NonCustodial.Application.Impl.Business
|
|
|
|
|
notClockListDto.SupervisedPersonName = person.SupervisedPersonName; |
|
|
|
|
var earlyList = await _appEarlyWarningRepository |
|
|
|
|
.AsQueryable(false, true) |
|
|
|
|
.Where(w => w.Title == "未打卡" && w.SupervisedPersonId == person.SupervisedPersonId |
|
|
|
|
.Where(w => w.EarlyWarningTypeId== applicationType.Id && w.SupervisedPersonId == person.SupervisedPersonId |
|
|
|
|
&& w.CaseId == item.Id) |
|
|
|
|
.WhereIf(input.EndCreatedTime.HasValue, w => w.CreatedTime <= input.EndCreatedTime) |
|
|
|
|
.WhereIf(input.StartCreatedTime.HasValue, w => w.CreatedTime >= input.StartCreatedTime) |
|
|
|
|
|