Merge branch 'main' of http://47.122.43.22:3000/wjn/mh_sms
This commit is contained in:
		
						commit
						68582da3bb
					
				@ -175,6 +175,10 @@ namespace APT.HM.WebApi.Controllers.Api
 | 
			
		||||
                //加入审批流
 | 
			
		||||
                if (entity.EVALUATE_TYPE == HMRiskTypeEnmu.危险源辨识)
 | 
			
		||||
                {
 | 
			
		||||
                    if (individuals.Count(t => t.IS_DELETED == false) == 0 && engineerings.Count(t => t.IS_DELETED == false) == 0 && managements.Count(t => t.IS_DELETED == false) == 0 && educations.Count(t => t.IS_DELETED == false) == 0 && emergencys.Count(t => t.IS_DELETED == false) == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        throw new Exception("五项管控措施请至少选择一项!");
 | 
			
		||||
                    }
 | 
			
		||||
                    MFlowPermitService.InsertApprove(entity.APPROVECODE, "HM122", "", entity.ID, "HM121_SHOWPRINT", null, isUpdate, () =>
 | 
			
		||||
                    {
 | 
			
		||||
                        if (entity != null)
 | 
			
		||||
 | 
			
		||||
@ -111,7 +111,26 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
 | 
			
		||||
        public int teamUndoneCount { get; set; }
 | 
			
		||||
        public double teamDoneRate { get; set; }
 | 
			
		||||
        public double teamOverDoneRate { get; set; }
 | 
			
		||||
        public string month { get; set; }
 | 
			
		||||
        public string name { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
    public class LoginInfo
 | 
			
		||||
    {
 | 
			
		||||
        public string NAME { get; set; }
 | 
			
		||||
        public DateTime? CREATE_TIME { get; set; }
 | 
			
		||||
        public string FROM { get; set; }
 | 
			
		||||
        public string VERSION { get; set; }
 | 
			
		||||
        public int QTY { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
    public class DepartmentInfo
 | 
			
		||||
    {
 | 
			
		||||
        public Guid? parent_departmentId { get; set; }
 | 
			
		||||
        public Guid departmentId { get; set; }
 | 
			
		||||
 | 
			
		||||
        public int departmentType { get; set; }
 | 
			
		||||
        public string departmentName { get; set; }
 | 
			
		||||
        public int num { get; set; }
 | 
			
		||||
        public List<DepartmentInfo> deptInfos { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    ///  
 | 
			
		||||
@ -7127,9 +7146,41 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
 | 
			
		||||
        {
 | 
			
		||||
            return SafeExecute<List<T_BI_DEPARTMENT_MONTH_RUN>>(() =>
 | 
			
		||||
            {
 | 
			
		||||
                if (string.IsNullOrEmpty(filter.Parameter1) || string.IsNullOrEmpty(filter.Parameter2))
 | 
			
		||||
                {
 | 
			
		||||
                    throw new Exception("请先选择时间段");
 | 
			
		||||
                }
 | 
			
		||||
                if (string.IsNullOrEmpty(filter.Keyword))
 | 
			
		||||
                {
 | 
			
		||||
                    throw new Exception("请先选择部门");
 | 
			
		||||
                }
 | 
			
		||||
                DateTime startTime = Convert.ToDateTime(filter.Parameter1);
 | 
			
		||||
                DateTime endTime = Convert.ToDateTime(filter.Parameter2);
 | 
			
		||||
                var diffTime = startTime.AddMonths(12).Date;
 | 
			
		||||
                if (diffTime < endTime.Date)
 | 
			
		||||
                {
 | 
			
		||||
                    throw new Exception("查询时间不能超过12个月!");
 | 
			
		||||
                }
 | 
			
		||||
                //int type = 1;
 | 
			
		||||
                //if (dayDidd <= 31)
 | 
			
		||||
                //{
 | 
			
		||||
                //    type = 5;//最近一周(显示最近一月的,最小单位为月)
 | 
			
		||||
                //}
 | 
			
		||||
                //if (dayDidd > 31 && dayDidd<=90)
 | 
			
		||||
                //{
 | 
			
		||||
                //    type = 10;//最近三月
 | 
			
		||||
                //}
 | 
			
		||||
                //if (dayDidd > 90 && dayDidd <= 180)
 | 
			
		||||
                //{
 | 
			
		||||
                //    type = 15;//最近半年
 | 
			
		||||
                //}
 | 
			
		||||
                //if (dayDidd > 180)
 | 
			
		||||
                //{
 | 
			
		||||
                //    type = 20;//最近一年
 | 
			
		||||
                //}
 | 
			
		||||
                List<T_BI_DEPARTMENT_MONTH_RUN> completionLists = new List<T_BI_DEPARTMENT_MONTH_RUN>();
 | 
			
		||||
                var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId.Value;
 | 
			
		||||
                var completions = GetEntities<T_BI_DEPARTMENT_MONTH_RUN>(t => !t.IS_DELETED, filter).OrderBy(m=>m.MONTH).ToList();
 | 
			
		||||
                var completions = GetEntities<T_BI_DEPARTMENT_MONTH_RUN>(t => !t.IS_DELETED && t.DEPARTMENT_NAME == filter.Keyword && t.MONTH >= startTime && t.MONTH < endTime, new BaseFilter(filter.OrgId)).OrderBy(m => m.MONTH).ToList();
 | 
			
		||||
                if (completions != null && completions.Any())
 | 
			
		||||
                {
 | 
			
		||||
                    foreach (var item in completions)
 | 
			
		||||
@ -7149,5 +7200,377 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
 | 
			
		||||
                return completions;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 部门完成情况、模块完成情况统计
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="entity"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost, Route("GetDepartMouldInfos")]
 | 
			
		||||
        public JsonActionResult<dynamic> GetDepartMouldInfos([FromBody] KeywordFilter filter)
 | 
			
		||||
        {
 | 
			
		||||
            return SafeExecute<dynamic>(() =>
 | 
			
		||||
            {
 | 
			
		||||
                //首页待办增加数量统计字段
 | 
			
		||||
                dynamic ret = new System.Dynamic.ExpandoObject();
 | 
			
		||||
                if (string.IsNullOrEmpty(filter.Parameter1) || string.IsNullOrEmpty(filter.Parameter2))
 | 
			
		||||
                {
 | 
			
		||||
                    throw new Exception("请先选择时间段");
 | 
			
		||||
                }
 | 
			
		||||
                var newFilter = new BaseFilter(filter.OrgId);
 | 
			
		||||
                newFilter.SelectField = new List<string> { "ID", "CODE", "NAME" };
 | 
			
		||||
                var formInfo = this.GetEntities<T_PF_FORM>(t => t.ENABLE_STATUS == 0, newFilter);
 | 
			
		||||
                DateTime startTime = Convert.ToDateTime(filter.Parameter1);
 | 
			
		||||
                DateTime endTime = Convert.ToDateTime(filter.Parameter2);
 | 
			
		||||
                var diffTime = startTime.AddMonths(11).Date;
 | 
			
		||||
                if (diffTime < endTime.Date)
 | 
			
		||||
                {
 | 
			
		||||
                    throw new Exception("查询时间不能超过12个月!");
 | 
			
		||||
                }
 | 
			
		||||
                var result = GetEntities<T_BI_NOTIFICATION_TASK_NEW>(s => !s.IS_DELETED && s.CREATE_DATE >= startTime && s.CREATE_DATE <= endTime, new BaseFilter(filter.OrgId)).ToList();
 | 
			
		||||
                var userIds = result.Select(t => t.USER_ID).Distinct().ToList();
 | 
			
		||||
                var userInfos = GetEntities<T_FM_USER>(s => userIds.Contains(s.ID) && s.ENABLE_STATUS == 0, newFilter);
 | 
			
		||||
                if (result.Any())
 | 
			
		||||
                {
 | 
			
		||||
                    List<T_BI_SYSTEM_RUN_SUMMARY> departSummary = new List<T_BI_SYSTEM_RUN_SUMMARY>();
 | 
			
		||||
                    List<T_BI_MOULD_RUN_SUMMARY> mouldSummary = new List<T_BI_MOULD_RUN_SUMMARY>();
 | 
			
		||||
                    newFilter.SelectField = new List<string> { "ID", "PARENT_ID", "NAME", "Nav_Parent", "DEPARTMENT_TYPE" };
 | 
			
		||||
                    var departmentInfos = this.GetEntities<T_FM_DEPARTMENT>(t => !t.IS_DELETED && t.ENABLE_STATUS == 0, newFilter).ToList();
 | 
			
		||||
                    var companyIds = departmentInfos.Where(t => t.DEPARTMENT_TYPE == 3).Select(m => m.ID).ToList();
 | 
			
		||||
                    //按部门
 | 
			
		||||
                    var departGroupYear = result.Where(t => t.DEPT_DEPARTMENT_ID != null && !companyIds.Contains((Guid)t.DEPT_DEPARTMENT_ID)).ToList();
 | 
			
		||||
                    //分组
 | 
			
		||||
                    if (departGroupYear.Any())
 | 
			
		||||
                    {
 | 
			
		||||
                        var groupYearDepart = departGroupYear.GroupBy(t => t.DEPT_DEPARTMENT_ID).ToList();
 | 
			
		||||
                        groupYearDepart.ForEach(t =>
 | 
			
		||||
                        {
 | 
			
		||||
                            T_BI_SYSTEM_RUN_SUMMARY sum = new T_BI_SYSTEM_RUN_SUMMARY();
 | 
			
		||||
                            sum.DEPARTMENT_ID = t.Key.Value;
 | 
			
		||||
                            sum.ORG_ID = filter.OrgId;
 | 
			
		||||
                            var depart = departmentInfos.FirstOrDefault(m => m.ID == t.Key.Value);
 | 
			
		||||
                            sum.DEPARTMENT_NAME = depart?.NAME;
 | 
			
		||||
                            sum.TYPE = MS.Domain.Enums.BI.BIEnums.FilterTimeType.LastYear;
 | 
			
		||||
                            sum.TOTAL_QTY = t.Where(m => m.DEPT_DEPARTMENT_ID == t.Key.Value).Count();
 | 
			
		||||
                            sum.FINISH_QTY = t.Where(m => m.DEPT_DEPARTMENT_ID == t.Key.Value && m.NOTICE_STATUS == 1).Count();
 | 
			
		||||
                            sum.OVER_FINISH_QTY = t.Where(m => m.DEPT_DEPARTMENT_ID == t.Key.Value && m.NOTICE_STATUS == 2).Count();
 | 
			
		||||
                            sum.UNFINISH_QTY = t.Where(m => m.DEPT_DEPARTMENT_ID == t.Key.Value && m.NOTICE_STATUS == 0).Count();
 | 
			
		||||
                            sum.DEPARTMENT_TYPE = FMDepartmentType.部门;
 | 
			
		||||
                            var temp = sum.TOTAL_QTY == 0 ? 0 : (double)(sum.FINISH_QTY + sum.OVER_FINISH_QTY) / sum.TOTAL_QTY * 100;
 | 
			
		||||
                            sum.FINISH_RATE = temp.ToString("0");
 | 
			
		||||
                            var temp2 = sum.TOTAL_QTY == 0 ? 0 : (double)sum.FINISH_QTY / sum.TOTAL_QTY * 100;
 | 
			
		||||
                            sum.NORMAL_FINISH_RATE = temp2.ToString("0");
 | 
			
		||||
                            departSummary.Add(sum);
 | 
			
		||||
                        });
 | 
			
		||||
                        ret.departData = departSummary;
 | 
			
		||||
                    }
 | 
			
		||||
                    //按模块
 | 
			
		||||
                    var mouldGroupYear = departGroupYear.Where(t => t.MOUDLE_NAME != null).ToList();
 | 
			
		||||
                    if (mouldGroupYear.Any())
 | 
			
		||||
                    {
 | 
			
		||||
                        //分组
 | 
			
		||||
                        var groupYearMould = mouldGroupYear.GroupBy(t => t.MOUDLE_NAME).ToList();
 | 
			
		||||
                        groupYearMould.ForEach(t =>
 | 
			
		||||
                        {
 | 
			
		||||
                            T_BI_MOULD_RUN_SUMMARY sum = new T_BI_MOULD_RUN_SUMMARY();
 | 
			
		||||
                            sum.MOUDLE_NAME = t.Key;
 | 
			
		||||
                            sum.ORG_ID = filter.OrgId;
 | 
			
		||||
                            sum.TYPE = MS.Domain.Enums.BI.BIEnums.FilterTimeType.LastYear;
 | 
			
		||||
                            sum.TOTAL_QTY = t.Where(m => m.MOUDLE_NAME == t.Key).Count();
 | 
			
		||||
                            sum.FINISH_QTY = t.Where(m => m.MOUDLE_NAME == t.Key && m.NOTICE_STATUS == 1).Count();
 | 
			
		||||
                            sum.OVER_FINISH_QTY = t.Where(m => m.MOUDLE_NAME == t.Key && m.NOTICE_STATUS == 2).Count();
 | 
			
		||||
                            sum.UNFINISH_QTY = sum.TOTAL_QTY - sum.FINISH_QTY - sum.OVER_FINISH_QTY;
 | 
			
		||||
                            var temp = sum.TOTAL_QTY == 0 ? 0 : (double)(sum.FINISH_QTY + sum.OVER_FINISH_QTY) / sum.TOTAL_QTY * 100;
 | 
			
		||||
                            sum.FINISH_RATE = temp.ToString("0");
 | 
			
		||||
                            var temp2 = sum.TOTAL_QTY == 0 ? 0 : (double)sum.FINISH_QTY / sum.TOTAL_QTY * 100;
 | 
			
		||||
                            sum.NORMAL_FINISH_RATE = temp2.ToString("0");
 | 
			
		||||
                            mouldSummary.Add(sum);
 | 
			
		||||
                        });
 | 
			
		||||
                        ret.mouldData = mouldSummary;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return ret;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 个人登录情况统计
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="entity"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost, Route("GetLoginInfos")]
 | 
			
		||||
        public JsonActionResult<dynamic> GetLoginInfos([FromBody] KeywordFilter filter)
 | 
			
		||||
        {
 | 
			
		||||
            return SafeExecute<dynamic>(() =>
 | 
			
		||||
            {
 | 
			
		||||
                //表格
 | 
			
		||||
                List<LoginInfo> completionSorts = new List<LoginInfo>();
 | 
			
		||||
                dynamic ret = new System.Dynamic.ExpandoObject();
 | 
			
		||||
                var dt = DateTime.Now.AddMonths(-1);
 | 
			
		||||
                var startTime = DateTime.Parse(dt.Year.ToString() + "-" + dt.Month + "-" + dt.Day + " 00:00:00");
 | 
			
		||||
                var endTime = DateTime.Parse(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + " 23:59:59");
 | 
			
		||||
                var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId.Value;
 | 
			
		||||
                var userID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value;
 | 
			
		||||
                var newfilter = new BaseFilter(orgId);
 | 
			
		||||
                newfilter.SelectField = new List<string> { "ID", "USER_ID", "DEPARTMENT_ID", "FROM", "VERSION", "CREATE_TIME" };
 | 
			
		||||
                if (!string.IsNullOrEmpty(filter.Keyword))
 | 
			
		||||
                {
 | 
			
		||||
                    userID = this.GetEntity<T_FM_USER>(t => !t.IS_DELETED && t.ENABLE_STATUS == 0 && t.NAME == filter.Keyword).ID;
 | 
			
		||||
                }
 | 
			
		||||
                var loginInfos = this.GetEntities<T_BI_LOGIN_RECORD>(t => !t.IS_DELETED && t.CREATE_TIME >= startTime && t.CREATE_TIME <= endTime && t.USER_ID == userID, newfilter);
 | 
			
		||||
                //表格
 | 
			
		||||
                var loginInfoTable = loginInfos.OrderByDescending(m => m.CREATE_TIME).Take(30);
 | 
			
		||||
                if (loginInfoTable != null && loginInfoTable.Any())
 | 
			
		||||
                {
 | 
			
		||||
                    foreach (var depart in loginInfoTable)
 | 
			
		||||
                    {
 | 
			
		||||
                        LoginInfo info = new LoginInfo();
 | 
			
		||||
                        info.CREATE_TIME = depart?.CREATE_TIME;
 | 
			
		||||
                        info.FROM = depart.FROM;
 | 
			
		||||
                        info.VERSION = depart.VERSION;
 | 
			
		||||
                        completionSorts.Add(info);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                ret.retDetailData = completionSorts;
 | 
			
		||||
                //走势图(近一个月)
 | 
			
		||||
                List<LoginInfo> completionSorts1 = new List<LoginInfo>();
 | 
			
		||||
                for (DateTime date = startTime; date <= DateTime.Now; date = date.AddDays(1))
 | 
			
		||||
                {
 | 
			
		||||
                    var dayEnd = DateTime.Parse(date.Year.ToString() + "-" + date.Month + "-" + date.Day + " 23:59:59");
 | 
			
		||||
                    var ksJantask = loginInfos.Where(t => t.CREATE_TIME >= date && t.CREATE_TIME <= dayEnd).ToList();
 | 
			
		||||
                    if (ksJantask.Any())
 | 
			
		||||
                    {
 | 
			
		||||
                        LoginInfo run = new LoginInfo();
 | 
			
		||||
                        run.CREATE_TIME = date;
 | 
			
		||||
                        run.QTY = ksJantask.Count();
 | 
			
		||||
                        completionSorts1.Add(run);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        LoginInfo run = new LoginInfo();
 | 
			
		||||
                        run.CREATE_TIME = date;
 | 
			
		||||
                        run.QTY = 0;
 | 
			
		||||
                        completionSorts1.Add(run);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                ret.retChartData = completionSorts1;
 | 
			
		||||
                //饼图(近一个月)
 | 
			
		||||
                ret.groupData = loginInfos.GroupBy(t => t.FROM).Select(m => new LoginInfo
 | 
			
		||||
                {
 | 
			
		||||
                    FROM = m.Key,
 | 
			
		||||
                    QTY = m.Where(p => p.FROM == m.Key).Count(),
 | 
			
		||||
                }).ToList();
 | 
			
		||||
                return ret;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 组织完成情况统计
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="entity"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost, Route("GetDepartmentAnalysis")]
 | 
			
		||||
        public JsonActionResult<dynamic> GetDepartmentAnalysis([FromBody] KeywordFilter filter)
 | 
			
		||||
        {
 | 
			
		||||
            return SafeExecute<dynamic>(() =>
 | 
			
		||||
            {
 | 
			
		||||
                //表格
 | 
			
		||||
                dynamic ret = new System.Dynamic.ExpandoObject();
 | 
			
		||||
                var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId.Value;
 | 
			
		||||
                T_FM_DEPARTMENT departInfo = null;
 | 
			
		||||
                Expression<Func<T_BI_NOTIFICATION_TASK_NEW, bool>> express = t => !t.IS_DELETED && (t.NOTICE_STATUS == 0 || t.NOTICE_STATUS == 1 || t.NOTICE_STATUS == 2);
 | 
			
		||||
                if (string.IsNullOrEmpty(filter.Keyword))
 | 
			
		||||
                {
 | 
			
		||||
                    //未选中组织,默认全公司
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    departInfo = this.GetEntity<T_FM_DEPARTMENT>(filter.Keyword);
 | 
			
		||||
                    if (departInfo != null && departInfo.IS_DELETED == false)
 | 
			
		||||
                    {
 | 
			
		||||
                        //部门
 | 
			
		||||
                        if (departInfo.DEPARTMENT_TYPE == 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            express = express.And(t => t.DEPT_DEPARTMENT_ID == departInfo.ID);
 | 
			
		||||
                        }
 | 
			
		||||
                        else if (departInfo.DEPARTMENT_TYPE == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            express = express.And(t => t.SHOP_DEPARTMENT_ID == departInfo.ID);
 | 
			
		||||
                        }
 | 
			
		||||
                        else if (departInfo.DEPARTMENT_TYPE == 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            express = express.And(t => t.CLASS_DEPARTMENT_ID == departInfo.ID);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                var dt = DateTime.Parse(DateTime.Now.Year + "-01-01 00:00:00");
 | 
			
		||||
                if (string.IsNullOrEmpty(filter.Parameter1))
 | 
			
		||||
                {
 | 
			
		||||
                    //未选择年份,默认当前年度
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    dt = DateTime.Parse(filter.Parameter1 + "-01-01 00:00:00");
 | 
			
		||||
                }
 | 
			
		||||
                express = express.And(t => t.CREATE_DATE.Value.Year == dt.Year);
 | 
			
		||||
                var result = this.GetEntities<T_BI_NOTIFICATION_TASK_NEW>(express, filter);
 | 
			
		||||
                if (result != null && result.Any())
 | 
			
		||||
                {
 | 
			
		||||
                    //总数
 | 
			
		||||
                    ret.TotalCount = result.Count();
 | 
			
		||||
                    //未完成数
 | 
			
		||||
                    var UnfinishCount = result.Count(t => t.NOTICE_STATUS == 0);
 | 
			
		||||
                    ret.UnfinishCount = UnfinishCount;
 | 
			
		||||
                    //超时完成数
 | 
			
		||||
                    var OverfinishCount = result.Count(t => t.NOTICE_STATUS == 2);
 | 
			
		||||
                    //及时完成数
 | 
			
		||||
                    var FinishCount = result.Count(t => t.NOTICE_STATUS == 1);
 | 
			
		||||
                    //总完成数
 | 
			
		||||
                    ret.finishCount = FinishCount + OverfinishCount;
 | 
			
		||||
                    //完成率
 | 
			
		||||
                    ret.FinishRate = ret.TotalCount == 0 ? 0 : (double)ret.finishCount / ret.TotalCount * 100;
 | 
			
		||||
                    //及时完成率
 | 
			
		||||
                    ret.NormalFinishRate = ret.TotalCount == 0 ? 0 : (double)FinishCount / ret.TotalCount * 100;
 | 
			
		||||
                    //未完成弹窗
 | 
			
		||||
                    ret.UnfinishData = result.Where(t => t.NOTICE_STATUS == 0).ToList();
 | 
			
		||||
                    //走势图(近一个月)
 | 
			
		||||
                    List<GroupbyDepartmentCompletion> completionSorts = new List<GroupbyDepartmentCompletion>();
 | 
			
		||||
                    var dtEnd = dt.AddYears(1);
 | 
			
		||||
                    for (DateTime date = dt; date < dtEnd; date = date.AddMonths(1))
 | 
			
		||||
                    {
 | 
			
		||||
                        var dayEnd = date.AddMonths(1);
 | 
			
		||||
                        var taskTotal = result.Where(t => t.CREATE_DATE >= date && t.CREATE_DATE < dayEnd).ToList();
 | 
			
		||||
                        var taskFinish = taskTotal.Count(t => t.NOTICE_STATUS == 1 || t.NOTICE_STATUS == 2);
 | 
			
		||||
                        var normalFinish = taskTotal.Count(t => t.NOTICE_STATUS == 1);
 | 
			
		||||
                        if (taskTotal.Any())
 | 
			
		||||
                        {
 | 
			
		||||
                            GroupbyDepartmentCompletion run = new GroupbyDepartmentCompletion();
 | 
			
		||||
                            run.month = date.Year.ToString() + "-" + date.Month.ToString();
 | 
			
		||||
                            run.teamDoneRate = taskTotal.Count() == 0 ? 0 : (double)taskFinish / taskTotal.Count() * 100;
 | 
			
		||||
                            run.teamOverDoneRate = taskTotal.Count() == 0 ? 0 : (double)normalFinish / taskTotal.Count() * 100;
 | 
			
		||||
                            completionSorts.Add(run);
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            GroupbyDepartmentCompletion run = new GroupbyDepartmentCompletion();
 | 
			
		||||
                            run.month = date.Year.ToString() + "-" + date.Month.ToString();
 | 
			
		||||
                            run.teamDoneRate = 0;
 | 
			
		||||
                            run.teamOverDoneRate = 0;
 | 
			
		||||
                            completionSorts.Add(run);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    ret.LineChart = completionSorts;
 | 
			
		||||
                    //按人分组
 | 
			
		||||
                    var groupTask = result.GroupBy(t => t.USER_NAME).Select(m => new GroupbyDepartmentCompletion
 | 
			
		||||
                    {
 | 
			
		||||
                        name = m.Key,
 | 
			
		||||
                        teamDoneRate = m.Count(p => p.USER_NAME == m.Key) == 0 ? 0 : m.Count(p => p.USER_NAME == m.Key && (p.NOTICE_STATUS == 1 || p.NOTICE_STATUS == 2)) / m.Count(p => p.USER_NAME == m.Key) * 100,
 | 
			
		||||
                        teamOverDoneRate = m.Count(p => p.USER_NAME == m.Key) == 0 ? 0 : m.Count(p => p.USER_NAME == m.Key && (p.NOTICE_STATUS == 1)) / m.Count(p => p.USER_NAME == m.Key) * 100
 | 
			
		||||
                    }).ToList();
 | 
			
		||||
                    if (groupTask.Count > 20)
 | 
			
		||||
                    {
 | 
			
		||||
                        //柱状图(前八)
 | 
			
		||||
                        ret.BarAsc = groupTask.OrderByDescending(t => t.teamOverDoneRate).Take(8).ToList();
 | 
			
		||||
                        //柱状图(后八)
 | 
			
		||||
                        ret.BarDesc = groupTask.OrderBy(t => t.teamOverDoneRate).Take(8).ToList();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        ret.BarAsc = groupTask.OrderByDescending(t => t.teamOverDoneRate).ToList();
 | 
			
		||||
                    }
 | 
			
		||||
                    ret.UserCount = groupTask.Count;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    ret.TotalCount = 0;
 | 
			
		||||
                    ret.UnfinishCount = 0;
 | 
			
		||||
                    ret.FinishRate = 0;
 | 
			
		||||
                    ret.NormalFinishRate = 0;
 | 
			
		||||
                    ret.LineChart = new List<GroupbyDepartmentCompletion>();
 | 
			
		||||
                    ret.BarAsc = new List<GroupbyDepartmentCompletion>();
 | 
			
		||||
                    ret.BarDesc = new List<GroupbyDepartmentCompletion>();
 | 
			
		||||
                    ret.UserCount = 0;
 | 
			
		||||
                }
 | 
			
		||||
                return ret;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 组织部门树
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="entity"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost, Route("GetDepartmentEntities")]
 | 
			
		||||
        public JsonActionResult<DepartmentInfo> GetDepartmentEntities([FromBody] KeywordFilter filter)
 | 
			
		||||
        {
 | 
			
		||||
            return SafeExecute<DepartmentInfo>(() =>
 | 
			
		||||
            {
 | 
			
		||||
                //表格
 | 
			
		||||
                DepartmentInfo ret = new DepartmentInfo();
 | 
			
		||||
                var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId.Value;
 | 
			
		||||
                var departInfos = this.GetEntities<T_FM_DEPARTMENT>(t => !t.IS_DELETED, new BaseFilter(orgId));
 | 
			
		||||
                var company = departInfos.FirstOrDefault(t => t.DEPARTMENT_TYPE == 3);
 | 
			
		||||
                if (company != null)
 | 
			
		||||
                {
 | 
			
		||||
                    //公司
 | 
			
		||||
                    ret.departmentId = company.ID;
 | 
			
		||||
                    ret.departmentName = company.NAME;
 | 
			
		||||
                    ret.parent_departmentId = null;
 | 
			
		||||
                    ret.departmentType = company.DEPARTMENT_TYPE;
 | 
			
		||||
                    ret.num = company.NUM;
 | 
			
		||||
                    //部门
 | 
			
		||||
                    var deptInfos = departInfos.Where(t => t.PARENT_ID == company.ID).OrderBy(m => m.NUM).ToList();
 | 
			
		||||
                    if (deptInfos != null && deptInfos.Any())
 | 
			
		||||
                    {
 | 
			
		||||
                        List<DepartmentInfo> deptLists = new List<DepartmentInfo>();
 | 
			
		||||
                        foreach (var dept in deptInfos)
 | 
			
		||||
                        {
 | 
			
		||||
                            DepartmentInfo deptList = new DepartmentInfo();
 | 
			
		||||
                            deptList.departmentId = dept.ID;
 | 
			
		||||
                            deptList.departmentName = dept.NAME;
 | 
			
		||||
                            deptList.parent_departmentId = company.ID;
 | 
			
		||||
                            deptList.departmentType = dept.DEPARTMENT_TYPE;
 | 
			
		||||
                            deptList.num = dept.NUM;
 | 
			
		||||
                            //车间
 | 
			
		||||
                            var shopInfos = departInfos.Where(t => t.PARENT_ID == dept.ID).OrderBy(m => m.NUM).ToList();
 | 
			
		||||
                            if (shopInfos != null && shopInfos.Any())
 | 
			
		||||
                            {
 | 
			
		||||
                                List<DepartmentInfo> shopLists = new List<DepartmentInfo>();
 | 
			
		||||
                                foreach (var shop in shopInfos)
 | 
			
		||||
                                {
 | 
			
		||||
                                    DepartmentInfo shopList = new DepartmentInfo();
 | 
			
		||||
                                    shopList.departmentId = shop.ID;
 | 
			
		||||
                                    shopList.departmentName = shop.NAME;
 | 
			
		||||
                                    shopList.parent_departmentId = dept.ID;
 | 
			
		||||
                                    shopList.departmentType = shop.DEPARTMENT_TYPE;
 | 
			
		||||
                                    shopList.num = shop.NUM;
 | 
			
		||||
                                    //班组
 | 
			
		||||
                                    var classInfos = departInfos.Where(t => t.PARENT_ID == shop.ID).OrderBy(m => m.NUM).ToList();
 | 
			
		||||
                                    if (classInfos != null && classInfos.Any())
 | 
			
		||||
                                    {
 | 
			
		||||
                                        List<DepartmentInfo> classLists = new List<DepartmentInfo>();
 | 
			
		||||
                                        foreach (var item in classInfos)
 | 
			
		||||
                                        {
 | 
			
		||||
                                            DepartmentInfo classList = new DepartmentInfo();
 | 
			
		||||
                                            classList.departmentId = item.ID;
 | 
			
		||||
                                            classList.departmentName = item.NAME;
 | 
			
		||||
                                            classList.parent_departmentId = shop.ID;
 | 
			
		||||
                                            classList.departmentType = item.DEPARTMENT_TYPE;
 | 
			
		||||
                                            classList.num = item.NUM;
 | 
			
		||||
                                            classLists.Add(classList);
 | 
			
		||||
                                        }
 | 
			
		||||
                                        shopList.deptInfos = classLists;
 | 
			
		||||
                                    }
 | 
			
		||||
                                    shopLists.Add(shopList);
 | 
			
		||||
                                }
 | 
			
		||||
                                deptList.deptInfos = shopLists;
 | 
			
		||||
                            }
 | 
			
		||||
                            deptLists.Add(deptList);
 | 
			
		||||
                        }
 | 
			
		||||
                        ret.deptInfos = deptLists;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return ret;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user