コード例 #1
0
        protected void InitData()
        {
            ActivityBLL activitybll = new ActivityBLL();

            if (WebUserAuth.IsAuthenticated)
            {
                this.UserId = WebUserAuth.UserId.Value;

                TuanDai.PortalSystem.BLL.UserBLL userbll = new TuanDai.PortalSystem.BLL.UserBLL();
                userModel = userbll.GetUserBasicInfoModelById(UserId);


                UserGrowthBLL userGrowthbll = new UserGrowthBLL();
                TuanDai.VipSystem.BLL.UserBLL vipuserbll = new TuanDai.VipSystem.BLL.UserBLL();
                //List<int> typeList = userGrowthbll.GetUserRecord(UserId);
                //UserValidInfo Validmodel = vipuserbll.GetUserValidInfo(UserId);

                this.model = vipuserbll.GetUserInfo(this.UserId);

                this.GetUserPrivileges(this.model.Level);

                this.list       = new UserPrivilegeBLL().GetUserPrivilegeInfo(this.UserId);
                this.recordList = activitybll.QueryActivityReceiveRecord(this.UserId);
                this.strAction  = this.GetAction();
                if (this.model != null)
                {
                    this.percent = this.model.Growth == 0 || this.model.CurLevelMaxGrowth == 0 ? "0" : (Convert.ToDecimal(this.model.Growth) / this.model.CurLevelMaxGrowth * 100).ToString("0.00");
                }
                if (list != null)
                {
                    this.count = list.Select(p => p.TypeId).Distinct().Count();
                }
                else
                {
                    this.count = 0;
                }
            }
            this.activityList = activitybll.GetActivityList();
            this.GetActivityInfo();
        }
コード例 #2
0
        public JsonResult GetSSJKNumbers()
        {
            //System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            //stopwatch.Start();


            int month = 1;

            if (DateTime.Now.Month < 4)
            {
                month = 1;
            }
            else if (DateTime.Now.Month < 7)
            {
                month = 4;
            }
            else if (DateTime.Now.Month < 10)
            {
                month = 7;
            }
            else if (DateTime.Now.Month <= 12)
            {
                month = 10;
            }
            DateTime sdt  = new DateTime(DateTime.Now.Year, month, 1); //当前季度开始日期
            DateTime nsdt = new DateTime(DateTime.Now.Year, month, 1);
            var      user = OperatorProvider.Provider.Current();

            if (user.DeptId == "0")
            {
                user.DeptCode = "0";
            }
            //var all = service.GetMeeting(user.DeptCode, sdt.ToString("yyyy-MM-dd")); //各班组开展班会数量
            var ldt   = service.GetLllegals(user.DeptId, sdt.ToString("yyyy-MM-dd"));     //各班组未整改违章数量
            var edudt = service.GetEducations(user.DeptCode, sdt.ToString("yyyy-MM-dd")); //各班组未评价的教育培训活动

            var acdt = service.GetActivitys(user.DeptCode, sdt.ToString("yyyy-MM-dd"));

            var kytdt = service.GetDanger(user.DeptCode, sdt.ToString("yyyy-MM-dd"));


            var edt  = DateTime.Now;
            int days = (edt - sdt).Days;
            int wd   = 0;

            while (sdt < edt) //循环比较,获得工作日数量
            {
                if (sdt.DayOfWeek != DayOfWeek.Saturday && sdt.DayOfWeek != DayOfWeek.Sunday)
                {
                    ++wd;
                }
                sdt = sdt.AddDays(1);
            }


            int           s         = wd * 2; //应开展班会数量
            int           bzcount   = 0;
            int           meetings  = 0;
            DepartmentBLL deptBll   = new DepartmentBLL();
            var           groups    = deptBll.GetAllGroups().Where(x => x.EnCode.Contains(user.DeptCode));
            int           meet      = 0;
            int           undo      = 0;
            int           undogroup = 0;

            foreach (DepartmentEntity d in groups)
            {
                bool b = false;
                for (int i = 0; i < s; i++)
                {
                    meet = service.GetUndoMeeting(d.DepartmentId, nsdt.AddDays(i).ToString("yyyy-MM-dd"), nsdt.AddDays(i + 1).ToString("yyyy-MM-dd"));
                    if (meet == 0)
                    {
                        b = true;
                        undo++;
                    }
                }
                if (b)           //该班组有未开展的活动
                {
                    undogroup++; //班组数量+1
                }
            }
            bzcount = undogroup;
            var total1 = undo;

            //违章
            int count1 = 0;
            int count2 = 0;

            foreach (DataRow row in ldt.Rows)
            {
                if (Convert.ToInt32(row[2]) != 0)
                {
                    ++count1;
                    count2 += Convert.ToInt32(row[2]);
                }
            }

            //教育培训
            int count3 = 0;
            int count4 = 0;

            foreach (DataRow row in edudt.Rows)
            {
                if (Convert.ToInt32(row[2]) != 0)
                {
                    ++count3;
                    count4 += Convert.ToInt32(row[2]);
                }
            }


            //安全日活动

            DateTime dtWeekSt1; //季度开始日,周开始日期
            DateTime dtWeekSt2; //当前周开始日期
            int      w1 = (int)nsdt.DayOfWeek;
            int      w2 = (int)DateTime.Now.DayOfWeek;

            if (w1 == 0)
            {
                w1 = 7;
            }
            if (w2 == 0)
            {
                w2 = 7;
            }
            dtWeekSt1 = nsdt.AddDays(1 - w1);
            dtWeekSt2 = DateTime.Now.AddDays(1 - w2);
            TimeSpan ts     = dtWeekSt2 - dtWeekSt1;
            int      weeks  = (int)ts.Days / 7; //周数 == 应开展数量
            int      count5 = 0;
            int      count6 = 0;
            int      acs    = 0;



            var total = 0;
            int g     = 0;
            int n     = 0;
            var data  = new List <newActivity>();

            var bll = new ActivityBLL();

            foreach (DepartmentEntity d in groups)
            {
                var  dept = deptBll.GetEntity(d.ParentId);
                bool b    = false;
                for (int i = 0; i < weeks; i++)
                {
                    n = bll.GetActivityList(d.DepartmentId, nsdt.AddDays(i * 7).ToString("yyyy-MM-dd"), nsdt.AddDays((i + 1) * 7).ToString("yyyy-MM-dd"));
                    if (n == 0)
                    {
                        b = true;
                        total++;
                        //data.Add(new newActivity { GroupName = d.FullName, FromTo = sdt.AddDays(i * 7).ToString("yyyy-MM-dd") + "至" + sdt.AddDays((i + 1) * 7).ToString("yyyy-MM-dd"), Remark = "", DeptName = dept == null ? "" : dept.FullName });
                    }
                }
                if (b)   //该班组有未开展的活动
                {
                    g++; //班组数量+1
                }
            }
            count5 = g;
            count6 = total;


            //KYT
            int count7 = 0;
            int count8 = 0;

            foreach (DataRow row in kytdt.Rows)
            {
                if (Convert.ToInt32(row[2]) != 0)
                {
                    ++count7;
                    count8 += Convert.ToInt32(row[2]);
                }
            }

            //stopwatch.Stop();
            //var sec = stopwatch.Elapsed.TotalSeconds;


            var    abll    = new ActivityService();
            var    ebll    = new EduBaseInfoService();
            var    mbll    = new WorkmeetingService();
            string code    = user.DeptCode;
            var    alist   = service.GetActs(code);
            var    edulist = service.GetEdus(code);
            var    mlist   = service.GetDangers(code);
            var    entity  = new NewEntity();
            var    data1   = new List <string>();

            foreach (ActivityEntity a in alist)
            {
                data1.Add(a.GroupId);
            }
            foreach (EduBaseInfoEntity a in edulist)
            {
                data1.Add(a.BZId);
            }
            foreach (DangerEntity a in mlist)
            {
                data1.Add(a.GroupId);
            }
            count4 = data1.Count;
            count3 = data1.Distinct().Count();
            var res = service.FindCount(code);

            return(Json(new { meeting1 = bzcount, meeting2 = total1, lllegals1 = count1, lllegals2 = count2, edu1 = count3, edu2 = count4, activity1 = count5, activity2 = count6, kyt1 = count7, kyt2 = count8 }));
        }