修改统计数据以及解译数据导出
parent
93c9b29552
commit
440550044c
|
|
@ -248,6 +248,140 @@ namespace OpenAuth.App.ServiceApp
|
|||
return new Response<List<UserOrGroupTaskResp>>(); // 默认返回空列表
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 小组 人员 的任务数和图斑数
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="dateType"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Response<List<UserOrGroupTaskResp>>> GetGroupOrUserTaskAndTuBanByTime(DateTime beginTime, DateTime endTime)
|
||||
{
|
||||
var user = _auth.GetCurrentUser().User;
|
||||
var role = _auth.GetCurrentUser().Roles;
|
||||
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
{
|
||||
// 获取当前用户相关的所有小组用户
|
||||
var groupIds = await db.SysGroup.AsQueryable()
|
||||
.Where(r => r.GroupLeaderId == user.Id.ToString())
|
||||
.Select(r => r.Id)
|
||||
.ToListAsync();
|
||||
|
||||
var groupUser = await db.SysGroupuser.AsQueryable()
|
||||
.Where(r => groupIds.Contains(r.GroupId) || r.UserId == user.Id.ToString())
|
||||
.ToListAsync();
|
||||
|
||||
// 管理员角色
|
||||
if (role.Any(r => r.Name.Contains("管理员")) || user.Id == -1)
|
||||
{
|
||||
// 获取所有小组信息
|
||||
var groupInfo = await db.SysGroup.AsQueryable().ToListAsync();
|
||||
|
||||
// 获取任务和图斑信息
|
||||
var taskInfo = await db.InsTaskgroup.AsQueryable()
|
||||
.LeftJoin<SysGroupuser>((a, b) => a.ReciveUserId == b.UserId)
|
||||
.LeftJoin<SysGroup>((a, b, c) => b.GroupId == c.Id)
|
||||
.WhereIF(beginTime.Year != 0001, a => a.CreateTime >= beginTime && a.CreateTime <= endTime)
|
||||
.Where((a, b) => !string.IsNullOrEmpty(a.ReciveUserId))
|
||||
.Select((a, b, c) => new
|
||||
{
|
||||
a.Id,
|
||||
a.ReciveUserId,
|
||||
c.Name,
|
||||
a.IsComplate,
|
||||
a.EndNum,
|
||||
a.BeginNum
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// 组织任务信息
|
||||
var groupTaskStats = groupInfo.Select(group =>
|
||||
{
|
||||
var groupTaskInfo = taskInfo.Where(t => t.Name == group.Name).ToList();
|
||||
|
||||
var taskCount = groupTaskInfo.Count;
|
||||
var taskComplateCount = groupTaskInfo.Count(t => t.IsComplate);
|
||||
var taskNoComplateCount = taskCount - taskComplateCount;
|
||||
|
||||
var tuBanCount = groupTaskInfo.Sum(t => t.EndNum - t.BeginNum + 1);
|
||||
var tuBanComplateCount = groupTaskInfo.Where(t => t.IsComplate).Sum(t => t.EndNum - t.BeginNum + 1);
|
||||
var tuBanNoComplateCount = tuBanCount - tuBanComplateCount;
|
||||
|
||||
return new UserOrGroupTaskResp
|
||||
{
|
||||
UserName = group.Name,
|
||||
TaskCount = taskCount,
|
||||
TaskComplateCount = taskComplateCount,
|
||||
TaskNoComplateCount = taskNoComplateCount,
|
||||
TuBanCount = tuBanCount,
|
||||
TuBanComplateCount = tuBanComplateCount,
|
||||
TuBanNoComplateCount = tuBanNoComplateCount
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
return new Response<List<UserOrGroupTaskResp>>
|
||||
{
|
||||
Result = groupTaskStats
|
||||
};
|
||||
}
|
||||
else if (groupIds.Count > 0)//小组查看人员
|
||||
{
|
||||
var users = await db.User.AsQueryable().Where(r => groupUser.Select(r => r.UserId).ToList().Contains(r.Id.ToString())).ToListAsync();
|
||||
// 获取任务和图斑信息
|
||||
var taskInfo = await db.InsTaskgroup.AsQueryable()
|
||||
.WhereIF(beginTime.Year != 0001, a => a.CreateTime >= beginTime && a.CreateTime <= endTime)
|
||||
.WhereIF(groupUser.Any(), a => groupUser.Select(r => r.UserId).ToList().Contains(a.ReciveUserId))
|
||||
.Where((a) => !string.IsNullOrEmpty(a.ReciveUserId))
|
||||
.Select((a) => new
|
||||
{
|
||||
a.Id,
|
||||
a.ReciveUserId,
|
||||
a.IsComplate,
|
||||
a.EndNum,
|
||||
a.BeginNum
|
||||
}).ToListAsync();
|
||||
var groupTaskStats = users.Select(group =>
|
||||
{
|
||||
var groupTaskInfo = taskInfo.Where(t => t.ReciveUserId == group.Id.ToString()).ToList();
|
||||
|
||||
var taskCount = groupTaskInfo.Count;
|
||||
var taskComplateCount = groupTaskInfo.Count(t => t.IsComplate);
|
||||
var taskNoComplateCount = taskCount - taskComplateCount;
|
||||
|
||||
var tuBanCount = groupTaskInfo.Sum(t => t.EndNum - t.BeginNum + 1);
|
||||
var tuBanComplateCount = groupTaskInfo.Where(t => t.IsComplate).Sum(t => t.EndNum - t.BeginNum + 1);
|
||||
var tuBanNoComplateCount = tuBanCount - tuBanComplateCount;
|
||||
|
||||
return new UserOrGroupTaskResp
|
||||
{
|
||||
UserName = group.Name,
|
||||
TaskCount = taskCount,
|
||||
TaskComplateCount = taskComplateCount,
|
||||
TaskNoComplateCount = taskNoComplateCount,
|
||||
TuBanCount = tuBanCount,
|
||||
TuBanComplateCount = tuBanComplateCount,
|
||||
TuBanNoComplateCount = tuBanNoComplateCount
|
||||
};
|
||||
}).ToList();
|
||||
return new Response<List<UserOrGroupTaskResp>>
|
||||
{
|
||||
Result = groupTaskStats
|
||||
};
|
||||
}
|
||||
else//查看个人任务列表
|
||||
{
|
||||
//var taskInfo = await db.InsTaskgroup.AsQueryable().Where(r => r.ReciveUserId == user.Id.ToString() && r.CreateTime >= beginTime && r.CreateTime <= endTime).ToListAsync();
|
||||
//return new Response<List<UserOrGroupTaskResp>>
|
||||
//{
|
||||
// Result = taskInfo
|
||||
//};
|
||||
}
|
||||
}
|
||||
|
||||
return new Response<List<UserOrGroupTaskResp>>(); // 默认返回空列表
|
||||
}
|
||||
|
||||
|
||||
//public async Task<Response<List<AiShpDataExpenseAccountingTableResp>>> GetAiShpDataExpenseAccountingTableOld(DateTime beginTime, DateTime endTime)
|
||||
//{
|
||||
// using (var db = base.UnitWork.CreateContext())
|
||||
|
|
@ -357,7 +491,7 @@ namespace OpenAuth.App.ServiceApp
|
|||
return new AiShpDataExpenseAccountingResp
|
||||
{
|
||||
Number = dateList.IndexOf(date) + 1,
|
||||
ShapDate = date.ToString("yyyyMMdd"),
|
||||
ShapDate = date.ToString("MMdd"),
|
||||
AreaNum = areaNum,
|
||||
ShpCount = shpCount,
|
||||
IssuedCount = issuedCount,
|
||||
|
|
@ -467,10 +601,12 @@ namespace OpenAuth.App.ServiceApp
|
|||
CreateCellStyle(workbook, 12, "宋体", HorizontalAlignment.Center, VerticalAlignment.Center);
|
||||
ICellStyle titleStyle2 =
|
||||
CreateCellStyle2(workbook, 9, "宋体", HorizontalAlignment.Left, VerticalAlignment.Center);
|
||||
ICellStyle headerStyle21 = CreateCellStyle2(workbook, 18, "方正小标宋简体", HorizontalAlignment.Center,
|
||||
VerticalAlignment.Center);
|
||||
ICellStyle headerStyle21 = CreateCellStyle2(workbook, 16, "方正小标宋简体", HorizontalAlignment.Center,
|
||||
VerticalAlignment.Center, true);
|
||||
ICellStyle headerStyle23 =
|
||||
CreateCellStyle(workbook, 12, "黑体", HorizontalAlignment.Center, VerticalAlignment.Center);
|
||||
CreateCellStyle(workbook, 12, "国标宋体", HorizontalAlignment.Center, VerticalAlignment.Center, true);
|
||||
ICellStyle headerStyle24 =
|
||||
CreateCellStyle2(workbook, 12, "国标宋体", HorizontalAlignment.Left, VerticalAlignment.Center, true);
|
||||
ICellStyle beizhuStyle21 =
|
||||
CreateCellStyle2(workbook, 9, "宋体", HorizontalAlignment.Left, VerticalAlignment.Center);
|
||||
|
||||
|
|
@ -506,10 +642,23 @@ namespace OpenAuth.App.ServiceApp
|
|||
|
||||
#region 创建表头
|
||||
|
||||
IRow row20 = CreateRowWithHeight(sheet2, 0, 42);
|
||||
IRow row20 = CreateRowWithHeight(sheet2, 0, 29);
|
||||
row20.CreateCell(0).SetCellValue("解译分析数据交付与费用记账表");
|
||||
|
||||
IRow row22 = CreateRowWithHeight(sheet2, 2, 24);
|
||||
IRow row21 = CreateRowWithHeight(sheet2, 1, 22);
|
||||
row21.CreateCell(0);
|
||||
row21.CreateCell(1);
|
||||
row21.CreateCell(2);
|
||||
row21.CreateCell(3);
|
||||
row21.CreateCell(4);
|
||||
row21.CreateCell(5);
|
||||
row21.CreateCell(6);
|
||||
row21.CreateCell(7);
|
||||
row21.CreateCell(8);
|
||||
row21.CreateCell(9).SetCellValue("编号:");
|
||||
row21.CreateCell(10);
|
||||
row21.CreateCell(11);
|
||||
IRow row22 = CreateRowWithHeight(sheet2, 2, 25);
|
||||
|
||||
row22.CreateCell(0).SetCellValue("序号");
|
||||
row22.CreateCell(1).SetCellValue("日期");
|
||||
|
|
@ -526,52 +675,40 @@ namespace OpenAuth.App.ServiceApp
|
|||
// 设置样式
|
||||
SetCellStyle(row20, headerStyle21);
|
||||
SetCellStyle(row22, headerStyle23);
|
||||
SetCellStyle(row21, headerStyle24);
|
||||
// 合并单元格
|
||||
sheet2.AddMergedRegion(new CellRangeAddress(0, 0, 0, 11)); // 合并标题行
|
||||
// 设置列宽
|
||||
int[] normalColumns2 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
foreach (var index in normalColumns2) sheet2.SetColumnWidth(index, 14 * 256); // 设置列宽
|
||||
|
||||
sheet2.AddMergedRegion(new CellRangeAddress(1, 1, 9, 11));
|
||||
int[] normalColumns2 = { 1, 2, 3, 4, 5, 6, 10 };
|
||||
foreach (var index in normalColumns2) sheet2.SetColumnWidth(index, 11 * 256); // 设置列宽
|
||||
sheet2.SetColumnWidth(0, 6 * 256);
|
||||
sheet2.SetColumnWidth(7, 14 * 256);
|
||||
sheet2.SetColumnWidth(8, 14 * 256);
|
||||
sheet2.SetColumnWidth(9, 13 * 256);
|
||||
sheet2.SetColumnWidth(11, 8 * 256);
|
||||
#endregion
|
||||
|
||||
#region 填充数据
|
||||
for (int i = 0; i < list.Result.RespData.Count - 1; i++)
|
||||
{
|
||||
var rowIndex = i + 3; // 数据从第5行开始
|
||||
var row = CreateRowWithHeight(sheet2, rowIndex, 34);
|
||||
var row = CreateRowWithHeight(sheet2, rowIndex, 32);
|
||||
row.CreateCell(0).SetCellValue(list.Result.RespData[i].Number);
|
||||
row.CreateCell(1).SetCellValue(list.Result.RespData[i].ShapDate);
|
||||
row.CreateCell(1).SetCellValue(list.Result.RespData[i].ShapDate.ToString());
|
||||
row.CreateCell(2).SetCellValue(list.Result.RespData[i].ShpProduction);
|
||||
row.CreateCell(3).SetCellValue(list.Result.RespData[i].ShpInterpretation);
|
||||
row.CreateCell(4).SetCellValue(list.Result.RespData[i].Judgment);
|
||||
row.CreateCell(5).SetCellValue(list.Result.RespData[i].Push);
|
||||
row.CreateCell(6).SetCellValue(list.Result.RespData[i].Cost);
|
||||
//row.CreateCell(6).SetCellValue(list.Result.RespData[i].Cost);
|
||||
row.CreateCell(6).SetCellFormula($"F{rowIndex + 1}*9");
|
||||
row.CreateCell(7).SetCellValue(list.Result.RespData[i].ShpCount.ToString());
|
||||
row.CreateCell(8).SetCellValue(list.Result.RespData[i].IssuedCount);
|
||||
row.CreateCell(9).SetCellValue(list.Result.RespData[i].FolderPath);
|
||||
row.CreateCell(10).SetCellValue(list.Result.RespData[i].Format);
|
||||
row.CreateCell(11).SetCellValue(list.Result.RespData[i].Remark);
|
||||
SetCellStyle(row, contentStyle22);
|
||||
SetCellStyle(row, headerStyle23);
|
||||
}
|
||||
#endregion
|
||||
//for (int i = list.Result.RespData.Count; i < list.Result.RespData.Count + 4; i++)
|
||||
//{
|
||||
// var rowIndex = i + 2;
|
||||
// var row = CreateRowWithHeight(sheet2, rowIndex, 34);
|
||||
// row.CreateCell(0);
|
||||
// row.CreateCell(1);
|
||||
// row.CreateCell(2);
|
||||
// row.CreateCell(3);
|
||||
// row.CreateCell(4);
|
||||
// row.CreateCell(5);
|
||||
// row.CreateCell(6);
|
||||
// row.CreateCell(7);
|
||||
// row.CreateCell(8);
|
||||
// row.CreateCell(9);
|
||||
// row.CreateCell(10);
|
||||
// row.CreateCell(11);
|
||||
// SetCellStyle(row, contentStyle22);
|
||||
//}
|
||||
|
||||
//填充完数据,合并单元格
|
||||
sheet2.AddMergedRegion(new CellRangeAddress(list.Result.RespData.Count + 2, list.Result.RespData.Count + 2, 0, 1)); // 合并
|
||||
|
|
@ -590,21 +727,22 @@ namespace OpenAuth.App.ServiceApp
|
|||
sheet2.AddMergedRegion(new CellRangeAddress(list.Result.RespData.Count + 5, list.Result.RespData.Count + 5, 2, 6));
|
||||
sheet2.AddMergedRegion(new CellRangeAddress(list.Result.RespData.Count + 5, list.Result.RespData.Count + 5, 8, 11));
|
||||
|
||||
IRow rowhj = CreateRowWithHeight(sheet2, list.Result.RespData.Count + 2, 24);
|
||||
IRow rowhj = CreateRowWithHeight(sheet2, list.Result.RespData.Count + 2, 33);
|
||||
rowhj.CreateCell(0).SetCellValue("合计");
|
||||
rowhj.CreateCell(1);
|
||||
rowhj.CreateCell(2).SetCellValue(list.Result.TotalShpProduction);
|
||||
rowhj.CreateCell(3).SetCellValue(list.Result.TotalShpInterpretation);
|
||||
rowhj.CreateCell(4).SetCellValue(list.Result.TotalJudgment);
|
||||
rowhj.CreateCell(5).SetCellValue(list.Result.TotalPush);
|
||||
rowhj.CreateCell(6).SetCellValue(list.Result.TotalCost);
|
||||
//rowhj.CreateCell(6).SetCellValue(list.Result.TotalCost);
|
||||
rowhj.CreateCell(6).SetCellFormula($"SUM(G4:G{list.Result.RespData.Count + 2})");
|
||||
rowhj.CreateCell(7).SetCellValue(list.Result.TotalShpCount);
|
||||
rowhj.CreateCell(8).SetCellValue(list.Result.TotalIssuedCount);
|
||||
rowhj.CreateCell(9);
|
||||
rowhj.CreateCell(10);
|
||||
rowhj.CreateCell(11);
|
||||
SetCellStyle(rowhj, contentStyle22);
|
||||
IRow rowjf = CreateRowWithHeight(sheet2, list.Result.RespData.Count + 3, 24);
|
||||
SetCellStyle(rowhj, headerStyle23);
|
||||
IRow rowjf = CreateRowWithHeight(sheet2, list.Result.RespData.Count + 3, 33);
|
||||
rowjf.CreateCell(0).SetCellValue("交付单位");
|
||||
rowjf.CreateCell(1);
|
||||
rowjf.CreateCell(2);
|
||||
|
|
@ -617,8 +755,8 @@ namespace OpenAuth.App.ServiceApp
|
|||
rowjf.CreateCell(9);
|
||||
rowjf.CreateCell(10);
|
||||
rowjf.CreateCell(11);
|
||||
SetCellStyle(rowjf, contentStyle22);
|
||||
IRow rowjb = CreateRowWithHeight(sheet2, list.Result.RespData.Count + 4, 24);
|
||||
SetCellStyle(rowjf, headerStyle23);
|
||||
IRow rowjb = CreateRowWithHeight(sheet2, list.Result.RespData.Count + 4, 33);
|
||||
rowjb.CreateCell(0).SetCellValue("交付经办人");
|
||||
rowjb.CreateCell(1);
|
||||
rowjb.CreateCell(2);
|
||||
|
|
@ -631,8 +769,8 @@ namespace OpenAuth.App.ServiceApp
|
|||
rowjb.CreateCell(9);
|
||||
rowjb.CreateCell(10);
|
||||
rowjb.CreateCell(11);
|
||||
SetCellStyle(rowjb, contentStyle22);
|
||||
IRow rowrq = CreateRowWithHeight(sheet2, list.Result.RespData.Count + 5, 24);
|
||||
SetCellStyle(rowjb, headerStyle23);
|
||||
IRow rowrq = CreateRowWithHeight(sheet2, list.Result.RespData.Count + 5, 33);
|
||||
rowrq.CreateCell(0).SetCellValue("交付日期");
|
||||
rowrq.CreateCell(1);
|
||||
rowrq.CreateCell(2);
|
||||
|
|
@ -645,7 +783,7 @@ namespace OpenAuth.App.ServiceApp
|
|||
rowrq.CreateCell(9);
|
||||
rowrq.CreateCell(10);
|
||||
rowrq.CreateCell(11);
|
||||
SetCellStyle(rowrq, contentStyle22);
|
||||
SetCellStyle(rowrq, headerStyle23);
|
||||
#endregion
|
||||
|
||||
response.Result = new MemoryStream();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
using OpenAuth.Repository.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.Response
|
||||
{
|
||||
public class TaskForUserGroupResp: InsTaskgroup
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -12,5 +12,10 @@ namespace OpenAuth.App.ServiceApp.Response
|
|||
public string UserName { get; set; }
|
||||
public int TaskCount { get; set; }
|
||||
public int TuBanCount { get; set; }
|
||||
public int TaskComplateCount { get; set; }
|
||||
public int TaskNoComplateCount { get; set; }
|
||||
public int TuBanComplateCount { get; set; }
|
||||
public int TuBanNoComplateCount { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,27 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
return response;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据时间统计小组和个人任务及图斑
|
||||
/// </summary>
|
||||
/// <param name="beginTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<List<UserOrGroupTaskResp>>> GetGroupOrUserTaskAndTuBanByTime(DateTime beginTime, DateTime endTime)
|
||||
{
|
||||
Response<List<UserOrGroupTaskResp>> response = new Response<List<UserOrGroupTaskResp>>();
|
||||
try
|
||||
{
|
||||
return await _app.GetGroupOrUserTaskAndTuBanByTime(beginTime, endTime);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
/// <summary>
|
||||
/// 解译分析数据交付与费用记账表
|
||||
/// </summary>
|
||||
/// <param name="beginTime"></param>
|
||||
|
|
|
|||
Loading…
Reference in New Issue