修改我的任务统计

optimize
jianghaiqing 2 years ago
parent 530dba46da
commit fb0f2ab637

@ -115,5 +115,15 @@ namespace Myshipping.Application.Entity
/// 商品名称
/// </summary>
public string GoodsName { get; set; }
/// <summary>
/// Master Bol Indicator名称
/// </summary>
public string MasterBolIndicatorName { get; set; }
/// <summary>
/// 销售EDI名称
/// </summary>
public string SalerCodeName { get; set; }
}
}

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 任务统计分类枚举
/// </summary>
public enum TaskStatLevelEnum
{
/// <summary>
/// 异常
/// </summary>
[Description("异常")]
EXCPTION,
/// <summary>
/// 个人
/// </summary>
[Description("个人")]
PERSON,
/// <summary>
/// 公共
/// </summary>
[Description("公共")]
PUBLIC
}
}

@ -2355,6 +2355,16 @@
商品名称
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingEDIExt.MasterBolIndicatorName">
<summary>
Master Bol Indicator名称
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingEDIExt.SalerCodeName">
<summary>
销售EDI名称
</summary>
</member>
<member name="T:Myshipping.Application.Entity.BookingExcelTemplate">
<summary>
EXCEl打印模板
@ -4696,6 +4706,26 @@
系统
</summary>
</member>
<member name="T:Myshipping.Application.TaskStatLevelEnum">
<summary>
任务统计分类枚举
</summary>
</member>
<member name="F:Myshipping.Application.TaskStatLevelEnum.EXCPTION">
<summary>
异常
</summary>
</member>
<member name="F:Myshipping.Application.TaskStatLevelEnum.PERSON">
<summary>
个人
</summary>
</member>
<member name="F:Myshipping.Application.TaskStatLevelEnum.PUBLIC">
<summary>
公共
</summary>
</member>
<member name="T:Myshipping.Application.TaskStatusEnum">
<summary>
任务状态枚举
@ -11316,14 +11346,24 @@
称重方式
</summary>
</member>
<member name="T:Myshipping.Application.TaskUserStatItem">
<member name="P:Myshipping.Application.TaskUserStatResultInfo.LevelTop">
<summary>
用户任务统计展示
第一层(异常/个人/公共)
</summary>
</member>
<member name="P:Myshipping.Application.TaskUserStatResultInfo.LevelNext">
<summary>
第二层(待处理/已完成/已取消/已挂起)
</summary>
</member>
<member name="P:Myshipping.Application.TaskUserStatItem.Level">
<member name="P:Myshipping.Application.TaskUserStatResultInfo.LevelTree">
<summary>
级别分层1-异常/个人/公共 2-待处理/已完成/已取消/已挂起 3-按照任务类型展示)
任务类型树(按照任务类型展示)
</summary>
</member>
<member name="T:Myshipping.Application.TaskUserStatItem">
<summary>
用户任务统计展示
</summary>
</member>
<member name="P:Myshipping.Application.TaskUserStatItem.SortNo">

@ -6,16 +6,28 @@ using System.Threading.Tasks;
namespace Myshipping.Application
{
public class TaskUserStatResultInfo
{
/// <summary>
/// 第一层(异常/个人/公共)
/// </summary>
public List<TaskUserStatItem> LevelTop { get; set; }
/// <summary>
/// 第二层(待处理/已完成/已取消/已挂起)
/// </summary>
public List<TaskUserStatItemNext> LevelNext { get; set; }
/// <summary>
/// 任务类型树(按照任务类型展示)
/// </summary>
public List<TaskUserStatItemTree> LevelTree { get; set; }
}
/// <summary>
/// 用户任务统计展示
/// </summary>
public class TaskUserStatItem
{
/// <summary>
/// 级别分层1-异常/个人/公共 2-待处理/已完成/已取消/已挂起 3-按照任务类型展示)
/// </summary>
public int Level { get; set; }
/// <summary>
/// 排序值
/// </summary>
@ -42,4 +54,15 @@ namespace Myshipping.Application
public string ActionKey { get; set; }
}
public class TaskUserStatItemNext: TaskUserStatItem
{
public string TopKey { get; set; }
}
public class TaskUserStatItemTree : TaskUserStatItemNext
{
public string NextKey { get; set; }
}
}

@ -30,6 +30,6 @@ namespace Myshipping.Application
/// </summary>
/// <param name="isReCalc">是否强制计算</param>
/// <returns>返回回执</returns>
Task<List<TaskUserStatItem>> GetCurrentTotalStat(bool isReCalc = false);
Task<TaskUserStatResultInfo> GetCurrentTotalStat(bool isReCalc = false);
}
}

@ -316,16 +316,19 @@ namespace Myshipping.Application
/// </summary>
/// <param name="isReCalc">是否强制计算</param>
/// <returns>返回回执</returns>
public async Task<List<TaskUserStatItem>> GetCurrentTotalStat(bool isReCalc = false)
public async Task<TaskUserStatResultInfo> GetCurrentTotalStat(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
2isReCalc=true
3/
*/
try
{
var userTendInfo = await _sysUserRepository.AsQueryable()
@ -337,9 +340,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 +351,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 = exceptList.Sum(t => 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 = exceptList.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 = exceptList.Sum(t => 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 = exceptList.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 = exceptList.Sum(t => 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 +519,7 @@ namespace Myshipping.Application
throw Oops.Bah($"获取登陆人相关的任务统计信息异常,{0}", ex.Message);
}
return resultList;
return resultInfo;
}
}
}

Loading…
Cancel
Save