|
|
|
@ -316,16 +316,20 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="isReCalc">是否强制计算</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<List<TaskUserStatItem>> GetCurrentTotalStat(bool isReCalc = false)
|
|
|
|
|
[HttpGet("/TaskManage/GetCurrentTotalStat")]
|
|
|
|
|
public async Task<TaskUserStatResultInfo> GetCurrentTotalStat([FromQuery]bool isReCalc = false)
|
|
|
|
|
{
|
|
|
|
|
List<TaskUserStatItem> resultList = new List<TaskUserStatItem>();
|
|
|
|
|
TaskUserStatResultInfo resultInfo = new TaskUserStatResultInfo {
|
|
|
|
|
LevelTop = new List<TaskUserStatItem>(),
|
|
|
|
|
LevelNext = new List<TaskUserStatItemNext>(),
|
|
|
|
|
LevelTree = new List<TaskUserStatItemTree>()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
1、首先判断当前登陆人是否有统计记录,如果没有触发统计生成统计记录。
|
|
|
|
|
2、如果isReCalc=true,表示强制重新统计数据,并重新更新统计数据。
|
|
|
|
|
3、按照统计类型(个人/公共)、任务状态、是否异常分组汇总,并写入统计表。
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var userTendInfo = await _sysUserRepository.AsQueryable()
|
|
|
|
@ -337,9 +341,9 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Oh($"当前用户关联租户信息获取失败");
|
|
|
|
|
|
|
|
|
|
var statList = _taskStatManageInfoRepository.AsQueryable().Where(t => (t.USER_ID == userTendInfo.User.Id
|
|
|
|
|
&& t.STAT_TYPE == "PERSONAL") || (t.COMP_ID == userTendInfo.Tend.Id && t.STAT_TYPE == "PUBLIC")).ToList();
|
|
|
|
|
&& t.STAT_TYPE == TaskStatLevelEnum.PERSON.ToString()) || (t.COMP_ID == userTendInfo.Tend.Id && t.STAT_TYPE == TaskStatLevelEnum.PUBLIC.ToString())).ToList();
|
|
|
|
|
|
|
|
|
|
if (!isReCalc)
|
|
|
|
|
if (isReCalc)
|
|
|
|
|
{
|
|
|
|
|
//任务列表分组统计
|
|
|
|
|
var groupList = _taskBaseInfoRepository.AsQueryable()
|
|
|
|
@ -348,10 +352,167 @@ namespace Myshipping.Application
|
|
|
|
|
.Select(p => new
|
|
|
|
|
{
|
|
|
|
|
Total = SqlFunc.AggregateCount(p.PK_ID),
|
|
|
|
|
TaskType = p
|
|
|
|
|
TaskType = p.TASK_TYPE,
|
|
|
|
|
Status = p.STATUS,
|
|
|
|
|
IsExcept = p.IS_EXCEPT,
|
|
|
|
|
IsPublic = p.IS_PUBLIC
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
var exceptList = groupList
|
|
|
|
|
.Where(t => t.IsExcept == 1).ToList();
|
|
|
|
|
|
|
|
|
|
var personList = groupList
|
|
|
|
|
.Where(t => t.IsExcept == 0 && t.IsPublic == 0).ToList();
|
|
|
|
|
|
|
|
|
|
var publicList = groupList
|
|
|
|
|
.Where(t => t.IsExcept == 1 && t.IsPublic == 1).ToList();
|
|
|
|
|
|
|
|
|
|
#region 异常
|
|
|
|
|
if (exceptList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
resultInfo.LevelTop.Add(new TaskUserStatItem
|
|
|
|
|
{
|
|
|
|
|
Key = TaskStatLevelEnum.EXCPTION.ToString(),
|
|
|
|
|
Name = TaskStatLevelEnum.EXCPTION.GetDescription(),
|
|
|
|
|
Total = exceptList.Sum(t=>t.Total),
|
|
|
|
|
SortNo = (int)TaskStatLevelEnum.EXCPTION,
|
|
|
|
|
ActionKey = TaskStatLevelEnum.EXCPTION.ToString()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
exceptList.GroupBy(t => t.Status)
|
|
|
|
|
.Select(t => new { Key = t.Key, Total = t.ToList().Sum(p => p.Total) })
|
|
|
|
|
.ToList().ForEach(t => {
|
|
|
|
|
TaskStatusEnum currEnum = (TaskStatusEnum)System.Enum.Parse(typeof(TaskStatusEnum), t.Key);
|
|
|
|
|
|
|
|
|
|
resultInfo.LevelNext.Add(new TaskUserStatItemNext
|
|
|
|
|
{
|
|
|
|
|
TopKey = TaskStatLevelEnum.EXCPTION.ToString(),
|
|
|
|
|
Key = currEnum.ToString(),
|
|
|
|
|
Name = currEnum.GetDescription(),
|
|
|
|
|
Total = t.Total,
|
|
|
|
|
SortNo = (int)currEnum,
|
|
|
|
|
ActionKey = $"{TaskStatLevelEnum.EXCPTION.ToString()}#{currEnum.ToString()}"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
exceptList.GroupBy(t => new { t.Status,t.TaskType})
|
|
|
|
|
.Select(t => new { Key = t.Key, Total = t.ToList().Sum(p => p.Total) })
|
|
|
|
|
.ToList().ForEach(t => {
|
|
|
|
|
TaskBusiTypeEnum currEnum = (TaskBusiTypeEnum)System.Enum.Parse(typeof(TaskBusiTypeEnum), t.Key.TaskType);
|
|
|
|
|
|
|
|
|
|
resultInfo.LevelTree.Add(new TaskUserStatItemTree
|
|
|
|
|
{
|
|
|
|
|
TopKey = TaskStatLevelEnum.EXCPTION.ToString(),
|
|
|
|
|
NextKey = t.Key.Status,
|
|
|
|
|
Key = currEnum.ToString(),
|
|
|
|
|
Name = currEnum.GetDescription(),
|
|
|
|
|
Total = t.Total,
|
|
|
|
|
SortNo = (int)currEnum,
|
|
|
|
|
ActionKey = $"{TaskStatLevelEnum.EXCPTION.ToString()}#{t.Key.Status}#{currEnum.ToString()}"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 个人
|
|
|
|
|
if (personList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
resultInfo.LevelTop.Add(new TaskUserStatItem
|
|
|
|
|
{
|
|
|
|
|
Key = TaskStatLevelEnum.PERSON.ToString(),
|
|
|
|
|
Name = TaskStatLevelEnum.PERSON.GetDescription(),
|
|
|
|
|
Total = personList.Sum(t => t.Total),
|
|
|
|
|
SortNo = (int)TaskStatLevelEnum.PERSON,
|
|
|
|
|
ActionKey = TaskStatLevelEnum.PERSON.ToString()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
personList.GroupBy(t => t.Status)
|
|
|
|
|
.Select(t => new { Key = t.Key, Total = t.ToList().Sum(p => p.Total) })
|
|
|
|
|
.ToList().ForEach(t => {
|
|
|
|
|
TaskStatusEnum currEnum = (TaskStatusEnum)System.Enum.Parse(typeof(TaskStatusEnum), t.Key);
|
|
|
|
|
|
|
|
|
|
resultInfo.LevelNext.Add(new TaskUserStatItemNext
|
|
|
|
|
{
|
|
|
|
|
TopKey = TaskStatLevelEnum.PERSON.ToString(),
|
|
|
|
|
Key = currEnum.ToString(),
|
|
|
|
|
Name = currEnum.GetDescription(),
|
|
|
|
|
Total = t.Total,
|
|
|
|
|
SortNo = (int)currEnum,
|
|
|
|
|
ActionKey = $"{TaskStatLevelEnum.PERSON.ToString()}#{currEnum.ToString()}"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
personList.GroupBy(t => new { t.Status, t.TaskType })
|
|
|
|
|
.Select(t => new { Key = t.Key, Total = t.ToList().Sum(p => p.Total) })
|
|
|
|
|
.ToList().ForEach(t => {
|
|
|
|
|
TaskBusiTypeEnum currEnum = (TaskBusiTypeEnum)System.Enum.Parse(typeof(TaskBusiTypeEnum), t.Key.TaskType);
|
|
|
|
|
|
|
|
|
|
resultInfo.LevelTree.Add(new TaskUserStatItemTree
|
|
|
|
|
{
|
|
|
|
|
TopKey = TaskStatLevelEnum.PERSON.ToString(),
|
|
|
|
|
NextKey = t.Key.Status,
|
|
|
|
|
Key = currEnum.ToString(),
|
|
|
|
|
Name = currEnum.GetDescription(),
|
|
|
|
|
Total = t.Total,
|
|
|
|
|
SortNo = (int)currEnum,
|
|
|
|
|
ActionKey = $"{TaskStatLevelEnum.PERSON.ToString()}#{t.Key.Status}#{currEnum.ToString()}"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 公共
|
|
|
|
|
if (publicList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
resultInfo.LevelTop.Add(new TaskUserStatItem
|
|
|
|
|
{
|
|
|
|
|
Key = TaskStatLevelEnum.PUBLIC.ToString(),
|
|
|
|
|
Name = TaskStatLevelEnum.PUBLIC.GetDescription(),
|
|
|
|
|
Total = publicList.Sum(t => t.Total),
|
|
|
|
|
SortNo = (int)TaskStatLevelEnum.PUBLIC,
|
|
|
|
|
ActionKey = TaskStatLevelEnum.PUBLIC.ToString()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
publicList.GroupBy(t => t.Status)
|
|
|
|
|
.Select(t => new { Key = t.Key, Total = t.ToList().Sum(p => p.Total) })
|
|
|
|
|
.ToList().ForEach(t => {
|
|
|
|
|
TaskStatusEnum currEnum = (TaskStatusEnum)System.Enum.Parse(typeof(TaskStatusEnum), t.Key);
|
|
|
|
|
|
|
|
|
|
resultInfo.LevelNext.Add(new TaskUserStatItemNext
|
|
|
|
|
{
|
|
|
|
|
TopKey = TaskStatLevelEnum.PUBLIC.ToString(),
|
|
|
|
|
Key = currEnum.ToString(),
|
|
|
|
|
Name = currEnum.GetDescription(),
|
|
|
|
|
Total = t.Total,
|
|
|
|
|
SortNo = (int)currEnum,
|
|
|
|
|
ActionKey = $"{TaskStatLevelEnum.PUBLIC.ToString()}#{currEnum.ToString()}"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
publicList.GroupBy(t => new { t.Status, t.TaskType })
|
|
|
|
|
.Select(t => new { Key = t.Key, Total = t.ToList().Sum(p => p.Total) })
|
|
|
|
|
.ToList().ForEach(t => {
|
|
|
|
|
TaskBusiTypeEnum currEnum = (TaskBusiTypeEnum)System.Enum.Parse(typeof(TaskBusiTypeEnum), t.Key.TaskType);
|
|
|
|
|
|
|
|
|
|
resultInfo.LevelTree.Add(new TaskUserStatItemTree
|
|
|
|
|
{
|
|
|
|
|
TopKey = TaskStatLevelEnum.PUBLIC.ToString(),
|
|
|
|
|
NextKey = t.Key.Status,
|
|
|
|
|
Key = currEnum.ToString(),
|
|
|
|
|
Name = currEnum.GetDescription(),
|
|
|
|
|
Total = t.Total,
|
|
|
|
|
SortNo = (int)currEnum,
|
|
|
|
|
ActionKey = $"{TaskStatLevelEnum.PUBLIC.ToString()}#{t.Key.Status}#{currEnum.ToString()}"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -359,7 +520,7 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Bah($"获取登陆人相关的任务统计信息异常,{0}", ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resultList;
|
|
|
|
|
return resultInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|