报表统计修改
parent
154c157725
commit
d6ef0d77cf
|
|
@ -903,7 +903,7 @@ namespace OpenAuth.App
|
|||
#endregion
|
||||
|
||||
#region 报表导出
|
||||
public async Task<List<PunchStatistics>> GetPunchStatistics()
|
||||
public async Task<List<PunchStatistics>> GetPunchStatistics(DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
using (var uow = UnitWork.CreateContext())
|
||||
{
|
||||
|
|
@ -931,7 +931,9 @@ namespace OpenAuth.App
|
|||
ps.UserName = item.Name;
|
||||
ps.UserId = item.Id;
|
||||
//巡查信息
|
||||
var punchdata = uow.MiPunchRecord.AsQueryable().Where(r => r.UserId == item.Id);
|
||||
var punchdata = uow.MiPunchRecord.AsQueryable()
|
||||
.Where(r => r.UserId == item.Id)
|
||||
.WhereIF(begindate != null && enddate != null, r => r.PunchTime >= begindate && r.PunchTime <= enddate);
|
||||
if (punchdata.Any())
|
||||
{
|
||||
// 假设 PunchTime 是 DateTime 类型
|
||||
|
|
@ -944,24 +946,29 @@ namespace OpenAuth.App
|
|||
ps.PunchScope = $"{mintime}-{maxtime}";
|
||||
var punchcount = punchdata.Count();
|
||||
ps.PunchCount = punchcount;
|
||||
ps.ReportCount = punchdata.Where(r => r.PunchStatus == 1).Count();
|
||||
}
|
||||
else
|
||||
{
|
||||
ps.PunchScope = "";
|
||||
ps.PunchCount = 0;
|
||||
ps.ReportCount = 0;
|
||||
}
|
||||
//违法信息
|
||||
var violatedata = uow.MiViolationReport.AsQueryable().Where(r => r.Reporter == item.Id.ToString());
|
||||
var violatedata = uow.MiViolationReport.AsQueryable().
|
||||
Where(r => r.Reporter == item.Id.ToString())
|
||||
.WhereIF(begindate != null && enddate != null, r => r.ReportTime >= begindate && r.ReportTime <= enddate);
|
||||
if (violatedata.Any())
|
||||
{
|
||||
var violatecount = violatedata.Count();
|
||||
ps.ReportCount = violatecount;
|
||||
var dealCount = violatedata.Where(r => r.Status == 3 || r.Status > 4).Count();
|
||||
ps.DealCount = dealCount;
|
||||
ps.DealCount = violatecount;
|
||||
//var dealCount = violatedata.Where(r => r.Status == 3 || r.Status > 4).Count();
|
||||
//ps.DealCount = dealCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
ps.ReportCount = 0; ps.DealCount = 0;
|
||||
//ps.ReportCount = 0;
|
||||
ps.DealCount = 0;
|
||||
}
|
||||
plist.Add(ps);
|
||||
}
|
||||
|
|
@ -980,7 +987,7 @@ namespace OpenAuth.App
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public async Task<List<PunchPointStatistics>> GetPointPunchStatistics()
|
||||
public async Task<List<PunchPointStatistics>> GetPointPunchStatistics(DateTime? begindate,DateTime? enddate)
|
||||
{
|
||||
using (var uow = UnitWork.CreateContext())
|
||||
{
|
||||
|
|
@ -1005,7 +1012,9 @@ namespace OpenAuth.App
|
|||
ps.CountyName = item.CountyName;
|
||||
ps.PointId = item.Id;
|
||||
//巡查信息
|
||||
var punchdata = uow.MiPunchRecord.AsQueryable().Where(r => r.MinePointId == item.Id);
|
||||
var punchdata = uow.MiPunchRecord.AsQueryable()
|
||||
.Where(r => r.MinePointId == item.Id)
|
||||
.WhereIF(begindate != null && enddate != null, r => r.PunchTime >= begindate && r.PunchTime <= enddate);
|
||||
if (punchdata.Any())
|
||||
{
|
||||
// 假设 PunchTime 是 DateTime 类型
|
||||
|
|
@ -1018,24 +1027,30 @@ namespace OpenAuth.App
|
|||
ps.PunchScope = $"{mintime}-{maxtime}";
|
||||
var punchcount = punchdata.Count();
|
||||
ps.PunchCount = punchcount;
|
||||
ps.ReportCount = punchdata.Where(r=>r.PunchStatus==1).Count();
|
||||
}
|
||||
else
|
||||
{
|
||||
ps.PunchScope = "";
|
||||
ps.PunchCount = 0;
|
||||
ps.ReportCount = 0;
|
||||
}
|
||||
//违法信息
|
||||
var violatedata = uow.MiViolationReport.AsQueryable().Where(r => r.MinePointId == item.Id);
|
||||
var violatedata = uow.MiViolationReport.AsQueryable()
|
||||
.Where(r => r.MinePointId == item.Id)
|
||||
.WhereIF(begindate != null && enddate != null, r => r.ReportTime >= begindate && r.ReportTime <= enddate);
|
||||
|
||||
if (violatedata.Any())
|
||||
{
|
||||
var violatecount = violatedata.Count();
|
||||
ps.ReportCount = violatecount;
|
||||
var dealCount = violatedata.Where(r => r.Status == 3||r.Status>4).Count();
|
||||
ps.DealCount = dealCount;
|
||||
ps.DealCount = violatecount;
|
||||
//var dealCount = violatedata.Where(r => r.Status == 3||r.Status>4).Count();
|
||||
//ps.DealCount = dealCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
ps.ReportCount = 0; ps.DealCount = 0;
|
||||
//ps.ReportCount = 0;
|
||||
ps.DealCount = 0;
|
||||
}
|
||||
plist.Add(ps);
|
||||
}
|
||||
|
|
@ -1144,12 +1159,13 @@ namespace OpenAuth.App
|
|||
/// </summary>
|
||||
/// <param name="reportid"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> GetPunchDetailData(long userid)
|
||||
public async Task<dynamic> GetPunchDetailData(long userid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
using (var uow = UnitWork.CreateContext())
|
||||
{
|
||||
var result = await uow.MiPunchRecord.AsQueryable()
|
||||
.Where(p => p.UserId == userid)
|
||||
.WhereIF(begindate != null && enddate != null, p => p.PunchTime >= begindate && p.PunchTime <= enddate)
|
||||
.OrderByDescending(p => p.PunchTime)
|
||||
.Select<dynamic>((p) => new
|
||||
{
|
||||
|
|
@ -1164,13 +1180,14 @@ namespace OpenAuth.App
|
|||
/// </summary>
|
||||
/// <param name="reportid"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> GetReportDetailData(long userid)
|
||||
public async Task<dynamic> GetReportDetailData(long userid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
using (var uow = UnitWork.CreateContext())
|
||||
{
|
||||
var result = await uow.MiViolationReport.AsQueryable()
|
||||
.Where(p => p.Reporter == userid.ToString())
|
||||
.OrderByDescending(p => p.ReportTime)
|
||||
var result = await uow.MiPunchRecord.AsQueryable()
|
||||
.Where(p => p.UserId == userid&&p.PunchStatus==1)
|
||||
.WhereIF(begindate != null && enddate != null, p => p.PunchTime >= begindate && p.PunchTime <= enddate)
|
||||
.OrderByDescending(p => p.PunchTime)
|
||||
.Select<dynamic>((p) => new
|
||||
{
|
||||
Id = p.Id.SelectAll()
|
||||
|
|
@ -1184,12 +1201,13 @@ namespace OpenAuth.App
|
|||
/// </summary>
|
||||
/// <param name="reportid"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> GetDealDetailData(long userid)
|
||||
public async Task<dynamic> GetDealDetailData(long userid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
using (var uow = UnitWork.CreateContext())
|
||||
{
|
||||
var result = await uow.MiViolationReport.AsQueryable()
|
||||
.Where(p => p.Reporter == userid.ToString()&&(p.Status==3||p.Status>4))
|
||||
.Where(p => p.Reporter == userid.ToString())
|
||||
.WhereIF(begindate != null && enddate != null, p => p.ReportTime >= begindate && p.ReportTime <= enddate)
|
||||
.OrderByDescending(p => p.ReportTime)
|
||||
.Select<dynamic>((p) => new
|
||||
{
|
||||
|
|
@ -1205,12 +1223,13 @@ namespace OpenAuth.App
|
|||
/// </summary>
|
||||
/// <param name="pointid">点位id</param>
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> GetPointPunchDetailData(string pointid)
|
||||
public async Task<dynamic> GetPointPunchDetailData(string pointid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
using (var uow = UnitWork.CreateContext())
|
||||
{
|
||||
var result = await uow.MiPunchRecord.AsQueryable()
|
||||
.Where(r=>r.MinePointId==pointid)
|
||||
.WhereIF(begindate != null && enddate != null, r => r.PunchTime >= begindate && r.PunchTime <= enddate)
|
||||
.LeftJoin<SysUser>((r, u) => r.UserId == u.Id)
|
||||
.LeftJoin<MiMinePoint>((r, u, p) => r.MinePointId == p.Id)
|
||||
.OrderByDescending((r, u, p) => r.PunchTime)
|
||||
|
|
@ -1234,17 +1253,27 @@ namespace OpenAuth.App
|
|||
/// </summary>
|
||||
/// <param name="reportid"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> GetPointReportDetailData(string pointid)
|
||||
public async Task<dynamic> GetPointReportDetailData(string pointid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
using (var uow = UnitWork.CreateContext())
|
||||
{
|
||||
var result = await uow.MiViolationReport.AsQueryable()
|
||||
.Where(p => p.MinePointId==pointid)
|
||||
.OrderByDescending(p => p.ReportTime)
|
||||
.Select<dynamic>((p) => new
|
||||
{
|
||||
Id = p.Id.SelectAll()
|
||||
}).ToListAsync();
|
||||
var result = await uow.MiPunchRecord.AsQueryable()
|
||||
.Where(r => r.MinePointId == pointid&&r.PunchStatus==1)
|
||||
.WhereIF(begindate != null && enddate != null, r => r.PunchTime >= begindate && r.PunchTime <= enddate)
|
||||
.LeftJoin<SysUser>((r, u) => r.UserId == u.Id)
|
||||
.LeftJoin<MiMinePoint>((r, u, p) => r.MinePointId == p.Id)
|
||||
.OrderByDescending((r, u, p) => r.PunchTime)
|
||||
.Select<dynamic>((r, u, p) => new
|
||||
{
|
||||
Id = r.Id.SelectAll(),
|
||||
UserName = u.Name,
|
||||
PointName = p.Name,
|
||||
StreetName = p.StreetName,
|
||||
p.CountyName,
|
||||
p.CommunityName,
|
||||
StatusName = SqlFunc.Subqueryable<SysDataItemDetail>().Where(a => a.ItemCode == "JGMinePointStatus" && a.ItemValue == r.PunchStatus.ToString()).Select(a => a.ItemName)
|
||||
})
|
||||
.ToListAsync();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -1254,12 +1283,13 @@ namespace OpenAuth.App
|
|||
/// </summary>
|
||||
/// <param name="reportid"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> GetPointDealDetailData(string pointid)
|
||||
public async Task<dynamic> GetPointDealDetailData(string pointid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
using (var uow = UnitWork.CreateContext())
|
||||
{
|
||||
var result = await uow.MiViolationReport.AsQueryable()
|
||||
.Where(p => p.MinePointId == pointid &&( p.Status == 3 || p.Status > 4))
|
||||
.Where(p => p.MinePointId == pointid)
|
||||
.WhereIF(begindate != null && enddate != null, p => p.ReportTime >= begindate && p.ReportTime <= enddate)
|
||||
.OrderByDescending(p => p.ReportTime)
|
||||
.Select<dynamic>((p) => new
|
||||
{
|
||||
|
|
@ -1272,7 +1302,7 @@ namespace OpenAuth.App
|
|||
|
||||
#region
|
||||
//导出 巡查台账--人员
|
||||
public async Task<Response<MemoryStream>> ExportPunchStatistics()
|
||||
public async Task<Response<MemoryStream>> ExportPunchStatistics(DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
Response<MemoryStream> response = new Response<MemoryStream>();
|
||||
try
|
||||
|
|
@ -1310,7 +1340,7 @@ namespace OpenAuth.App
|
|||
#endregion
|
||||
|
||||
// 获取统计数据
|
||||
var list = await GetPunchStatistics();
|
||||
var list = await GetPunchStatistics(begindate,enddate);
|
||||
int totalCount = list.Count;
|
||||
int pageSize = 60000; // 每个Sheet最大行数
|
||||
int sheetCount = (totalCount / pageSize) + (totalCount % pageSize > 0 ? 1 : 0);
|
||||
|
|
@ -1389,7 +1419,7 @@ namespace OpenAuth.App
|
|||
}
|
||||
|
||||
|
||||
public async Task<Response<MemoryStream>> ExportPointPunchStatistics()
|
||||
public async Task<Response<MemoryStream>> ExportPointPunchStatistics(DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
Response<MemoryStream> response = new Response<MemoryStream>();
|
||||
try
|
||||
|
|
@ -1427,7 +1457,7 @@ namespace OpenAuth.App
|
|||
#endregion
|
||||
|
||||
// 获取统计数据
|
||||
var list = await GetPointPunchStatistics();
|
||||
var list = await GetPointPunchStatistics(begindate,enddate);
|
||||
int totalCount = list.Count;
|
||||
int pageSize = 60000; // 每个Sheet最大行数
|
||||
int sheetCount = (totalCount / pageSize) + (totalCount % pageSize > 0 ? 1 : 0);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using DocumentFormat.OpenXml.EMMA;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
|
@ -238,12 +239,12 @@ namespace OpenAuth.WebApi.Controllers
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<List<PunchStatistics>>> GetPunchStatistics()
|
||||
public async Task<Response<List<PunchStatistics>>> GetPunchStatistics(DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
var result = new Response<List<PunchStatistics>>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.GetPunchStatistics();
|
||||
result.Result = await _app.GetPunchStatistics(begindate, enddate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -259,12 +260,12 @@ namespace OpenAuth.WebApi.Controllers
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<List<PunchPointStatistics>>> GetPointPunchStatistics()
|
||||
public async Task<Response<List<PunchPointStatistics>>> GetPointPunchStatistics(DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
var result = new Response<List<PunchPointStatistics>>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.GetPointPunchStatistics();
|
||||
result.Result = await _app.GetPointPunchStatistics(begindate, enddate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -322,12 +323,34 @@ namespace OpenAuth.WebApi.Controllers
|
|||
/// <param name="userid">人员id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<dynamic>> GetPunchDetailData(long userid)
|
||||
public async Task<Response<dynamic>> GetPunchDetailData(long userid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
var result = new Response<dynamic>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.GetPunchDetailData(userid);
|
||||
result.Result = await _app.GetPunchDetailData(userid, begindate, enddate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 巡查台账-人员-巡查异常次数
|
||||
/// </summary>
|
||||
/// <param name="userid">人员id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<dynamic>> GetReportDetailData(long userid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
var result = new Response<dynamic>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.GetReportDetailData(userid, begindate, enddate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -344,34 +367,12 @@ namespace OpenAuth.WebApi.Controllers
|
|||
/// <param name="userid">人员id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<dynamic>> GetReportDetailData(long userid)
|
||||
public async Task<Response<dynamic>> GetDealDetailData(long userid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
var result = new Response<dynamic>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.GetReportDetailData(userid);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 巡查台账-人员-违法处理次数
|
||||
/// </summary>
|
||||
/// <param name="userid">人员id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<dynamic>> GetDealDetailData(long userid)
|
||||
{
|
||||
var result = new Response<dynamic>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.GetDealDetailData(userid);
|
||||
result.Result = await _app.GetDealDetailData(userid, begindate, enddate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -388,12 +389,34 @@ namespace OpenAuth.WebApi.Controllers
|
|||
/// <param name="pointid">巡查点id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<dynamic>> GetPointPunchDetailData(string pointid)
|
||||
public async Task<Response<dynamic>> GetPointPunchDetailData(string pointid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
var result = new Response<dynamic>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.GetPointPunchDetailData(pointid);
|
||||
result.Result = await _app.GetPointPunchDetailData(pointid, begindate, enddate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 巡查台账-点位-巡查异常次数
|
||||
/// </summary>
|
||||
/// <param name="pointid">巡查点id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<dynamic>> GetPointReportDetailData(string pointid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
var result = new Response<dynamic>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.GetPointReportDetailData(pointid, begindate, enddate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -410,34 +433,12 @@ namespace OpenAuth.WebApi.Controllers
|
|||
/// <param name="pointid">巡查点id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<dynamic>> GetPointReportDetailData(string pointid)
|
||||
public async Task<Response<dynamic>> GetPointDealDetailData(string pointid, DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
var result = new Response<dynamic>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.GetPointReportDetailData(pointid);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 巡查台账-点位-违法处理次数
|
||||
/// </summary>
|
||||
/// <param name="pointid">巡查点id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<dynamic>> GetPointDealDetailData(string pointid)
|
||||
{
|
||||
var result = new Response<dynamic>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.GetPointDealDetailData(pointid);
|
||||
result.Result = await _app.GetPointDealDetailData(pointid, begindate, enddate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -454,10 +455,10 @@ namespace OpenAuth.WebApi.Controllers
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> ExportPunchStatistics()
|
||||
public async Task<IActionResult> ExportPunchStatistics(DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
var res = new Response();
|
||||
var excelRes = await _app.ExportPunchStatistics();
|
||||
var excelRes = await _app.ExportPunchStatistics(begindate, enddate);
|
||||
if (excelRes.Code == 200)
|
||||
{
|
||||
return File(excelRes.Result.ToArray(),
|
||||
|
|
@ -477,10 +478,10 @@ namespace OpenAuth.WebApi.Controllers
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> ExportPointPunchStatistics()
|
||||
public async Task<IActionResult> ExportPointPunchStatistics(DateTime? begindate, DateTime? enddate)
|
||||
{
|
||||
var res = new Response();
|
||||
var excelRes = await _app.ExportPointPunchStatistics();
|
||||
var excelRes = await _app.ExportPointPunchStatistics(begindate, enddate);
|
||||
if (excelRes.Code == 200)
|
||||
{
|
||||
return File(excelRes.Result.ToArray(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue