예제 #1
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 }));
        }
예제 #2
0
        public ActionResult GetToolInfoPageListJson()
        {
            Operator user = OperatorProvider.Provider.Current();

            if (string.IsNullOrEmpty(user.DeptCode))
            {
                user.DeptCode = "0";
            }
            DepartmentBLL deptBll  = new DepartmentBLL();
            var           page     = int.Parse(this.Request.QueryString.Get("page") ?? "1");
            var           pagesize = int.Parse(this.Request.QueryString.Get("rows") ?? "20");
            var           from     = this.Request.QueryString.Get("from");
            var           to       = this.Request.QueryString.Get("to");
            var           result   = this.Request.QueryString.Get("result");
            var           state    = this.Request.QueryString.Get("state");
            var           code     = this.Request.QueryString.Get("code");
            var           total    = 0;
            var           watch    = CommonHelper.TimerStart();

            if (string.IsNullOrEmpty(code))
            {
                code = user.DeptCode;
            }
            var groups    = deptBll.GetAllGroups().Where(x => x.EnCode.StartsWith(code)).Select(x => x.DepartmentId);
            var data      = ibll.GetList("").Where(x => groups.Contains(x.BZID));
            var checklist = new List <ToolCheckEntity>();

            foreach (ToolInfoEntity t in data)
            {
                DateTime start = new DateTime();
                t.CheckCycle = t.CheckCycle == null ? "" : t.CheckCycle;
                //if (t.CheckCycle.Contains("月"))
                //{
                //    start = t.ValiDate.AddMonths(-(int.Parse(t.CheckCycle.Replace("个月", ""))));
                //}
                //if (t.CheckCycle.Contains("年"))
                //{
                //    start = t.ValiDate.AddMonths(-(int.Parse(t.CheckCycle.Replace("年", ""))));
                //}

                //checklist = tcbll.GetList().Where(x => x.ToolId == t.ID && x.CheckDate >= start && x.CheckDate < t.ValiDate).ToList();
                var check = tcbll.GetList().Where(x => x.ToolId == t.ID).OrderByDescending(x => x.CheckDate).FirstOrDefault();
                if (DateTime.Now < t.ValiDate && check != null)
                {
                    t.CheckState  = "已检验";
                    t.CheckDate   = check.CheckDate;
                    t.CheckResult = check.CheckResult;
                    t.CheckPeople = check.CheckPeople;
                }
                else
                {
                    t.CheckState  = "未检验";
                    t.CheckDate   = null;
                    t.CheckResult = "";
                }
            }
            if (!string.IsNullOrEmpty(from))
            {
                DateTime f = Convert.ToDateTime(from);
                data = data.Where(x => x.CheckDate > f);
            }
            if (!string.IsNullOrEmpty(to))
            {
                DateTime t = Convert.ToDateTime(to).AddDays(1);
                data = data.Where(x => x.CheckDate < t);
            }
            if (!string.IsNullOrEmpty(result))
            {
                data = data.Where(x => x.CheckResult == result);
            }
            if (!string.IsNullOrEmpty(state))
            {
                data = data.Where(x => x.CheckState == state);
            }
            total = data.Count();
            data  = data.Skip(pagesize * (page - 1)).Take(pagesize).ToList();
            return(Json(new { rows = data, records = total, page = page, total = Math.Ceiling((decimal)total / pagesize), costtime = CommonHelper.TimerEnd(watch) }, JsonRequestBehavior.AllowGet));
        }