From fb0f2ab6373967ec6ef554f2fd4184378c75b88a Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 29 Dec 2022 15:50:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=88=91=E7=9A=84=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BookingEDIExt.cs | 10 + .../Enum/TaskStatLevelEnum.cs | 31 ++++ .../Myshipping.Application.xml | 48 ++++- .../TaskManagePlat/Dtos/TaskUserStatItem.cs | 33 +++- .../Interface/ITaskManageService.cs | 2 +- .../TaskManagePlat/TaskManageService.cs | 174 +++++++++++++++++- 6 files changed, 281 insertions(+), 17 deletions(-) create mode 100644 Myshipping.Application/Enum/TaskStatLevelEnum.cs diff --git a/Myshipping.Application/Entity/BookingEDIExt.cs b/Myshipping.Application/Entity/BookingEDIExt.cs index ccdc178d..2afa51d2 100644 --- a/Myshipping.Application/Entity/BookingEDIExt.cs +++ b/Myshipping.Application/Entity/BookingEDIExt.cs @@ -115,5 +115,15 @@ namespace Myshipping.Application.Entity /// 商品名称 /// public string GoodsName { get; set; } + + /// + /// Master Bol Indicator名称 + /// + public string MasterBolIndicatorName { get; set; } + + /// + /// 销售EDI名称 + /// + public string SalerCodeName { get; set; } } } diff --git a/Myshipping.Application/Enum/TaskStatLevelEnum.cs b/Myshipping.Application/Enum/TaskStatLevelEnum.cs new file mode 100644 index 00000000..bce76d20 --- /dev/null +++ b/Myshipping.Application/Enum/TaskStatLevelEnum.cs @@ -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 +{ + /// + /// 任务统计分类枚举 + /// + public enum TaskStatLevelEnum + { + /// + /// 异常 + /// + [Description("异常")] + EXCPTION, + /// + /// 个人 + /// + [Description("个人")] + PERSON, + /// + /// 公共 + /// + [Description("公共")] + PUBLIC + } +} diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml index e56efd4f..f381ee7a 100644 --- a/Myshipping.Application/Myshipping.Application.xml +++ b/Myshipping.Application/Myshipping.Application.xml @@ -2355,6 +2355,16 @@ 商品名称 + + + Master Bol Indicator名称 + + + + + 销售EDI名称 + + EXCEl打印模板 @@ -4696,6 +4706,26 @@ 系统 + + + 任务统计分类枚举 + + + + + 异常 + + + + + 个人 + + + + + 公共 + + 任务状态枚举 @@ -11316,14 +11346,24 @@ 称重方式 - + - 用户任务统计展示 + 第一层(异常/个人/公共) + + + + + 第二层(待处理/已完成/已取消/已挂起) - + - 级别分层(1-异常/个人/公共 2-待处理/已完成/已取消/已挂起 3-按照任务类型展示) + 任务类型树(按照任务类型展示) + + + + + 用户任务统计展示 diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskUserStatItem.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskUserStatItem.cs index 41febe26..de180b4f 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskUserStatItem.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskUserStatItem.cs @@ -6,16 +6,28 @@ using System.Threading.Tasks; namespace Myshipping.Application { + public class TaskUserStatResultInfo + { + /// + /// 第一层(异常/个人/公共) + /// + public List LevelTop { get; set; } + + /// + /// 第二层(待处理/已完成/已取消/已挂起) + /// + public List LevelNext { get; set; } + + /// + /// 任务类型树(按照任务类型展示) + /// + public List LevelTree { get; set; } + } /// /// 用户任务统计展示 /// public class TaskUserStatItem { - /// - /// 级别分层(1-异常/个人/公共 2-待处理/已完成/已取消/已挂起 3-按照任务类型展示) - /// - public int Level { get; set; } - /// /// 排序值 /// @@ -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; } + } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs index 92900767..4a76bdd2 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs @@ -30,6 +30,6 @@ namespace Myshipping.Application /// /// 是否强制计算 /// 返回回执 - Task> GetCurrentTotalStat(bool isReCalc = false); + Task GetCurrentTotalStat(bool isReCalc = false); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 6468761a..f96b7a3d 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -316,16 +316,19 @@ namespace Myshipping.Application /// /// 是否强制计算 /// 返回回执 - public async Task> GetCurrentTotalStat(bool isReCalc = false) + public async Task GetCurrentTotalStat(bool isReCalc = false) { - List resultList = new List(); + TaskUserStatResultInfo resultInfo = new TaskUserStatResultInfo { + LevelTop = new List(), + LevelNext = new List(), + LevelTree = new List() + }; /* 1、首先判断当前登陆人是否有统计记录,如果没有触发统计生成统计记录。 2、如果isReCalc=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; } } }