You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
512 lines
27 KiB
512 lines
27 KiB
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; |
|
using ATS.NonCustodial.Shared.Extensions.Collection; |
|
using ATS.NonCustodial.Shared.Helpers; |
|
using AutoMapper.QueryableExtensions; |
|
using Microsoft.AspNetCore.Mvc; |
|
using Microsoft.EntityFrameworkCore; |
|
using StackExchange.Profiling.Internal; |
|
using static System.Runtime.InteropServices.JavaScript.JSType; |
|
|
|
namespace ATS.NonCustodial.Application.Impl.Business |
|
{ |
|
/// <summary> |
|
/// 违规统计服务管理 |
|
/// </summary> |
|
/// Author:mxg |
|
/// CreatedTimed:2022-06-06 05:35 PM |
|
[DynamicApi(Area = "admin")] |
|
public class AppViolationStatisticsService : AdminCommonService, IAppViolationStatisticsService, IDynamicApi |
|
{ |
|
#region Identity |
|
|
|
private readonly IEfRepository<AppViolationStatistics, long> _appViolationStatisticsRepository; |
|
private readonly IAppDictionaryService _appDictionaryService; |
|
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> |
|
/// |
|
/// </summary> |
|
/// <param name="appViolationStatisticsRepository"></param> |
|
/// <param name="appDictionaryService"></param> |
|
/// <param name="appEarlyWarningRepository"></param> |
|
/// <param name="userService"></param> |
|
public AppViolationStatisticsService(IEfRepository<AppUser?, long> userRepository, IEfRepository<AppCaseSupervisor, long> appSupervisorRepository, IEfRepository<AppViolationStatistics, long> appViolationStatisticsRepository, |
|
IAppDictionaryService appDictionaryService, |
|
IEfRepository<AppEarlyWarning, long> appEarlyWarningRepository, |
|
IUserService userService, |
|
IEfRepository<AppSupervisedPersonRealTimeLocation, long> asprl, |
|
IEfRepository<AppCaseManagement, long> appCaseManagementRepository, |
|
IEfRepository<AppCaseSupervisedPerson, long> appCaseSupervisedPersonRepository, |
|
IEfRepository<AppCaseSupervisor, long> appCaseSupervisorRepository |
|
) : base(appCaseManagementRepository, |
|
appCaseSupervisorRepository, |
|
appCaseSupervisedPersonRepository, |
|
userService, |
|
appDictionaryService, |
|
asprl) |
|
{ |
|
_appSupervisorRepository = appSupervisorRepository; |
|
_appViolationStatisticsRepository = appViolationStatisticsRepository; |
|
_appDictionaryService = appDictionaryService; |
|
_appEarlyWarningRepository = appEarlyWarningRepository; |
|
_userService = userService; |
|
_appSupervisedPersonRepository = appCaseSupervisedPersonRepository; |
|
_userRepository = userRepository; |
|
} |
|
|
|
#endregion Identity |
|
|
|
/// <summary> |
|
/// 根据被监管人员违规明细Id分页查询 |
|
/// </summary> |
|
/// <param name="input"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
public async Task<IResultOutput> GetPageAsync(AppViolationStatisticsGetPageInput input) |
|
{ |
|
var data = await _appEarlyWarningRepository.AsQueryable(false, true) |
|
.Where(w => w.CaseId == input.Id && w.SupervisedPersonId == input.SupervisedPersonId) |
|
.OrderByDescending(r => r.CreatedTime) |
|
.ProjectTo<AppEarlyWarningListDto>(Mapper.ConfigurationProvider) |
|
.PagedAsync(input) |
|
.ConfigureAwait(false); |
|
|
|
return ResultOutput.Ok(data); |
|
} |
|
|
|
/// <summary> |
|
/// 违规记录统计 |
|
/// </summary> |
|
/// <returns></returns> |
|
[HttpPost] |
|
public async Task<IResultOutput> ViolationStatisticsPageAsync(ViolationStatisticsPageInput 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 spList = await base.GetCurrentUserCaseListAsync(); |
|
//获取案件信息 |
|
var casebaselist = await spList.Where(q => q.AppCaseManagement != null && caseIdList.Contains(q.AppCaseManagement.Id)).Select(q => q.AppCaseManagement).ToListAsync(); |
|
//获取案件id |
|
var casebase = await spList |
|
.Where(q => q.AppCaseManagement != null && caseIdList.Contains(q.AppCaseManagement.Id)) |
|
.WhereIf(input.CaseProgress != null, a => a.AppCaseManagement.CaseProgress == input.CaseProgress).Select(q => q.AppCaseManagement.Id).ToListAsync(); |
|
var spIds = await spList.Where(q => q.AppCaseSupervisedPerson != null && casebase.Contains(q.AppCaseSupervisedPerson.CaseId)).Select(w => w.AppCaseSupervisedPerson!.SupervisedPersonId).ToListAsync(); |
|
//查询记录 |
|
var query = await _appEarlyWarningRepository |
|
.AsQueryable(false, true).Where(q => spIds.Contains(q.SupervisedPersonId)) |
|
.WhereIf(input.CaseId != default, a => a.CaseId == input.CaseId) |
|
.WhereIf(input.SupervisedPersonId != default, w => w.SupervisedPersonId == input.SupervisedPersonId) |
|
.WhereIf(input.SupervisedPersonName.HasValue(), w => w.SupervisedPersonName.Contains(input.SupervisedPersonName)) |
|
.WhereIf(input.TimeSearch?.BeginTime != null && input.TimeSearch?.EndTime != null, q => q.CreatedTime >= input.TimeSearch.BeginTime && q.CreatedTime <= $"{input.TimeSearch.EndTime.Value.ToString("yyyy-MM-dd")} 23:59:59".ToDateTime()) |
|
.ToListAsync(); |
|
|
|
//分组 |
|
var dataGroup = query |
|
.GroupBy(w => new { w.CaseId, w.SupervisedPersonId, w.CaseName, w.SupervisedPersonName }); |
|
|
|
var pageData = dataGroup.Skip((input.PageIndex - 1) * input.PageSize) |
|
.Take(input.PageSize); |
|
//处理身份证字段 |
|
var userList = await _userService.GetAllByConditionAsync(new BatchIdsInput() |
|
{ |
|
Ids = pageData.Select(w => w.Key.SupervisedPersonId).ToList() |
|
}); |
|
|
|
var dataList = pageData.Select(data => new ViolationStatisticsListDto() |
|
{ |
|
CaseId = data.Key.CaseId, |
|
SupervisedPersonId = data.Key.SupervisedPersonId, |
|
CaseName = casebaselist.Where(q => q.Id == data.Key.CaseId).First()?.Name, |
|
//data.Key.CaseName, |
|
SupervisedPersonName = data.Key.SupervisedPersonName, |
|
CaseProgress = casebaselist.Where(q => q.Id == data.Key.CaseId).First()?.CaseProgress, |
|
Violations = data.Count(), |
|
IdCard = userList.FirstOrDefault(w => w.Id == data.Key.SupervisedPersonId)?.IdCard |
|
}).ToList(); |
|
|
|
var pageResult = new PagedList<ViolationStatisticsListDto>() |
|
{ |
|
TotalCount = dataGroup.Count(), |
|
Data = dataList |
|
}; |
|
|
|
return ResultOutput.Ok(pageResult); |
|
} |
|
/// <summary> |
|
/// 违规记录统计导出 |
|
/// </summary> |
|
/// <returns></returns> |
|
[HttpPost] |
|
public async Task<IActionResult> ViolationStatisticsExportAsync(ViolationStatisticsPageInput 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 spList = await base.GetCurrentUserCaseListAsync(); |
|
//获取案件信息 |
|
var casebaselist = await spList.Where(q => q.AppCaseManagement != null && caseIdList.Contains(q.AppCaseManagement.Id)).Select(q => q.AppCaseManagement).ToListAsync(); |
|
//获取案件id |
|
var casebase = await spList |
|
.Where(q => q.AppCaseManagement != null && caseIdList.Contains(q.AppCaseManagement.Id)) |
|
.WhereIf(input.CaseProgress != null, a => a.AppCaseManagement.CaseProgress == input.CaseProgress).Select(q => q.AppCaseManagement.Id).ToListAsync(); |
|
var spIds = await spList.Where(q => q.AppCaseSupervisedPerson != null && casebase.Contains(q.AppCaseSupervisedPerson.CaseId)).Select(w => w.AppCaseSupervisedPerson!.SupervisedPersonId).ToListAsync(); |
|
//查询记录 |
|
var query = await _appEarlyWarningRepository |
|
.AsQueryable(false, true).Where(q => spIds.Contains(q.SupervisedPersonId)) |
|
.WhereIf(input.CaseId != default, a => a.CaseId == input.CaseId) |
|
.WhereIf(input.SupervisedPersonId != default, w => w.SupervisedPersonId == input.SupervisedPersonId) |
|
.WhereIf(input.SupervisedPersonName.HasValue(), w => w.SupervisedPersonName.Contains(input.SupervisedPersonName)) |
|
.WhereIf(input.TimeSearch?.BeginTime != null && input.TimeSearch?.EndTime != null, q => q.CreatedTime >= input.TimeSearch.BeginTime && q.CreatedTime <= $"{input.TimeSearch.EndTime.Value.ToString("yyyy-MM-dd")} 23:59:59".ToDateTime()) |
|
.ToListAsync(); |
|
|
|
//分组 |
|
var dataGroup = query |
|
.GroupBy(w => new { w.CaseId, w.SupervisedPersonId, w.CaseName, w.SupervisedPersonName }); |
|
|
|
var pageData = dataGroup.Skip((input.PageIndex - 1) * input.PageSize) |
|
.Take(input.PageSize); |
|
//处理身份证字段 |
|
var userList = await _userService.GetAllByConditionAsync(new BatchIdsInput() |
|
{ |
|
Ids = pageData.Select(w => w.Key.SupervisedPersonId).ToList() |
|
}); |
|
//(0:待执行 1:侦查阶段 2:已结束,3:审查起诉阶段,4:审理阶段) |
|
|
|
|
|
|
|
|
|
var dataList = pageData.Select(data => new ViolationStatisticsExportDto() |
|
{ |
|
CaseId = data.Key.CaseId, |
|
SupervisedPersonId = data.Key.SupervisedPersonId, |
|
CaseName = casebaselist.Where(q => q.Id == data.Key.CaseId).First()?.Name, |
|
//data.Key.CaseName, |
|
SupervisedPersonName = data.Key.SupervisedPersonName, |
|
CaseProgress = casebaselist.Where(q => q.Id == data.Key.CaseId).First()?.CaseProgress.ToDescription(), |
|
Violations = data.Count(), |
|
IdCard = userList.FirstOrDefault(w => w.Id == data.Key.SupervisedPersonId)?.IdCard |
|
}).ToList(); |
|
|
|
var memorySystem = ExcelHelper.ToExcel(dataList); |
|
return new FileController().File(memorySystem.ToArray(), "application/ms-excel", DateTime.Now.ToString("f") + ".xlsx"); |
|
} |
|
|
|
/// <summary> |
|
/// 违规人数分页查询 |
|
/// </summary> |
|
/// <returns></returns> |
|
[HttpPost] |
|
public async Task<IResultOutput> AppEarlyWarningPageAsync(ViolationStatisticsPageInput input) |
|
{ |
|
//根据当前登录人查看其手里的案件被监管人 |
|
var spList = await _appCaseManagementRepository.AsQueryable(false, true).Where(q => q.IsDeleted == false).ToListAsync(); |
|
//获取案件id |
|
var casebase = spList.Select(q => q.Id); |
|
//查询记录 |
|
var query = await _appEarlyWarningRepository |
|
.AsQueryable(false, true).Where(q => casebase.Contains(q.CaseId) && !string.IsNullOrEmpty(q.Title)) |
|
.WhereIf(input.CaseId != default, a => a.CaseId == input.CaseId) |
|
.WhereIf(input.Wglx != null, a => a.EarlyWarningTypeId == input.Wglx) |
|
.WhereIf(input.SupervisedPersonId != default, w => w.SupervisedPersonId == input.SupervisedPersonId) |
|
.WhereIf(input.TimeSearch?.BeginTime != null && input.TimeSearch?.EndTime != null, q => q.CreatedTime >= input.TimeSearch.BeginTime && q.CreatedTime <= $"{input.TimeSearch.EndTime.Value.ToString("yyyy-MM-dd")} 23:59:59".ToDateTime()) |
|
.OrderByDescending(q => q.CreatedTime) |
|
.ToListAsync(); |
|
|
|
//分组 |
|
var dataGroup = query.Distinct((a, b) => a.SupervisedPersonId == b.SupervisedPersonId && a.Title == b.Title); |
|
|
|
var pageData = dataGroup.Skip((input.PageIndex - 1) * input.PageSize) |
|
.Take(input.PageSize); |
|
//处理身份证字段 |
|
var userList = await _userService.GetAllByConditionAsync(new BatchIdsInput() |
|
{ |
|
Ids = pageData.Select(w => w.SupervisedPersonId).ToList() |
|
}); |
|
|
|
var dataList = pageData.Select(data => new ViolationStatisticsListDto() |
|
{ |
|
SupervisedPersonId = data.SupervisedPersonId, |
|
CaseName = spList.FirstOrDefault(q => q.Id == data.CaseId)?.Name, |
|
CaseProgress = spList.FirstOrDefault(q => q.Id == data.CaseId)?.CaseProgress, |
|
//data.Key.CaseName, |
|
SupervisedPersonName = data.SupervisedPersonName, |
|
IdCard = userList.FirstOrDefault(w => w.Id == data.SupervisedPersonId)?.IdCard, |
|
Wgtime = data?.CreatedTime, |
|
Wglx = data?.Title, |
|
|
|
}).ToList(); |
|
|
|
var pageResult = new PagedList<ViolationStatisticsListDto>() |
|
{ |
|
TotalCount = dataGroup.Count(), |
|
Data = dataList |
|
}; |
|
|
|
return ResultOutput.Ok(pageResult); |
|
} |
|
|
|
/// <summary> |
|
/// 违规人数统计 |
|
/// </summary> |
|
/// <returns></returns> |
|
[HttpPost] |
|
public async Task<IResultOutput> ViolationStatisticsAsync(ViolationStatisticsPageInput input) |
|
{ |
|
var caseIds = await _appCaseManagementRepository.AsQueryable(false, true).Where(q => q.IsDeleted == false).Select(q => q.Id).ToListAsync(); |
|
//查询记录 |
|
var list = await _appEarlyWarningRepository |
|
.AsQueryable(false, true) |
|
.WhereIf(input.TimeSearch.BeginTime != null && input.TimeSearch.EndTime != null, q => q.CreatedTime >= input.TimeSearch.BeginTime && q.CreatedTime <= $"{input.TimeSearch.EndTime.Value.ToString("yyyy-MM-dd")} 23:59:59".ToDateTime()) |
|
.WhereIf(input.Wglx != null, q => q.EarlyWarningTypeId == input.Wglx) |
|
.Where(q => caseIds.Contains(q.CaseId)).ToListAsync(); |
|
|
|
var geruplist = list.Where(q => !string.IsNullOrEmpty(q.Title)).GroupBy(q => q.Title).Select(q => new { name = q.Key, value = q.Distinct((a, b) => a.SupervisedPersonId == b.SupervisedPersonId).Count() }); |
|
var count = geruplist.Sum(q => q.value); |
|
return ResultOutput.Ok(new { count = count, data = geruplist, list = list.Distinct((a, b) => a.SupervisedPersonId == b.SupervisedPersonId && a.Title == b.Title).ToList() }); |
|
} |
|
/// <summary> |
|
/// 未打卡统计 |
|
/// </summary> |
|
/// <returns></returns> |
|
[HttpPost] |
|
public async Task<IResultOutput> NotClockedStatisticsPageAsync(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", "notClocked"); |
|
|
|
List<NotClockListDto> notClockList = new List<NotClockListDto>(); |
|
foreach (var item in caseList) |
|
{ |
|
if (item == null) continue; |
|
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) |
|
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.NotClockedCount= earlyList.Count; |
|
notClockList.Add(notClockListDto); |
|
} |
|
|
|
} |
|
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"); |
|
|
|
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> |
|
/// 未打卡统计导出 |
|
/// </summary> |
|
/// <param name="input"></param> |
|
/// <returns></returns> |
|
public async Task<IActionResult> NotClockedStatisticsExportAsync(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", "notClocked"); |
|
|
|
List<NotClockExportDto> notClockList = new List<NotClockExportDto>(); |
|
foreach (var item in caseList) |
|
{ |
|
if (item == null) continue; |
|
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; |
|
notClockListDto.SupervisionUnit = ""; |
|
//根据案件找到被监管 |
|
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.NotClockedCount = earlyList.Count; |
|
notClockList.Add(notClockListDto); |
|
} |
|
|
|
} |
|
var memorySystem = ExcelHelper.ToExcel(notClockList); |
|
return new FileController().File(memorySystem.ToArray(), "application/ms-excel", DateTime.Now.ToString("f") + ".xlsx"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
/// 添加违规记录 |
|
/// </summary> |
|
/// <param name="input"></param> |
|
/// <returns></returns> |
|
public async Task<IResultOutput> AddAsync(AppViolationStatisticsAddInput input) => await base.AddAsync(input, _appViolationStatisticsRepository); |
|
} |
|
public class FileController : ControllerBase |
|
{ |
|
|
|
} |
|
} |