Beispiel #1
0
        public string DrillplanFinish()
        {
            Operator user       = ERCHTMS.Code.OperatorProvider.Provider.Current();
            var      year       = int.Parse(Request["year"] ?? "0");
            var      deptId     = Request["deptId"] ?? "";
            var      jd         = int.Parse(Request["jd"] ?? "0");
            var      monthCK    = int.Parse(Request["month"] ?? "0");
            var      type       = int.Parse(Request["type"] ?? "0");
            var      starttime  = Request["starttime"] ?? "";
            var      endtime    = Request["endtime"] ?? "";
            var      returnList = new List <Object>();

            //权限
            #region 权限
            string where = new AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value, "CREATEUSERDEPTCODE", "CREATEUSERORGCODE");
            string sqlwhere = " and 1=1 ";
            if (!string.IsNullOrEmpty(where))
            {
                sqlwhere += " and " + where;
            }
            else
            {
                sqlwhere += string.Format(" and CREATEUSERDEPTCODE like '{0}%'", user.DeptCode);
            }
            #endregion
            string cwhere  = string.Empty;
            string cyear   = Request["year"] ?? "";
            string cdeptid = Request["deptId"] ?? "";
            string cmonth  = Request["month"] ?? "";

            if (user.RoleName.Contains("公司级用户") || user.RoleName.Contains("厂级部门用户"))
            {
                cwhere += string.Format("  and  a.createuserdeptcode like '{0}%'", user.OrganizeCode);
            }
            else
            {
                cwhere += string.Format("  and  a.createuserdeptcode like '{0}%'", user.DeptCode);
            }

            if (!string.IsNullOrEmpty(cyear))
            {
                cwhere += string.Format(@" and to_char(a.drilltime,'yyyy') = '{0}' ", cyear);
            }
            if (!string.IsNullOrEmpty(cdeptid))
            {
                cwhere += string.Format(@" and a.departid  like  '%{0}%' ", cdeptid);
            }
            if (!string.IsNullOrEmpty(starttime))
            {
                cwhere += string.Format(@" and a.drilltime >=  to_date('{0}','yyyy-mm-dd hh24:mi:ss') ", starttime);
            }
            if (!string.IsNullOrEmpty(endtime))
            {
                cwhere += string.Format(@" and a.drilltime  <=  to_date('{0}','yyyy-mm-dd hh24:mi:ss') ", endtime);
            }
            if (type == 0) //应急演练预案类型统计
            {
                var seriesList    = new List <Object>();
                var drilldownList = new List <Object>();

                // var stable = new List<Object>();
                var dt = drillplanrecordbll.GetDrillPlanRecordTypeSta(cwhere, 0);

                foreach (DataRow row in dt.Rows)
                {
                    // stable.Add(new { id =  row["itemname"].ToString() ,name = row["itemname"].ToString(), value = int.Parse(row["num"].ToString()) });
                    if (row["itemname"].ToString() == "现场处置方案")
                    {
                        string twhere = cwhere + string.Format("  and a.drilltypename ='{0}' ", row["itemname"].ToString());

                        var drilldt = drillplanrecordbll.GetDrillPlanRecordTypeSta(twhere, 1);

                        var drilldowndata = new List <object>();

                        foreach (DataRow drow in drilldt.Rows)
                        {
                            // stable.Add(new { id = drow["itemname"].ToString(), name = drow["itemname"].ToString(), value = int.Parse(drow["num"].ToString()), parentid = row["itemname"].ToString() });
                            drilldowndata.Add(new { name = drow["itemname"].ToString(), y = int.Parse(drow["num"].ToString()), p = 0 });
                        }

                        drilldownList.Add(new { name = row["itemname"].ToString(), id = row["itemname"].ToString(), data = drilldowndata });

                        seriesList.Add(new { name = row["itemname"].ToString(), y = int.Parse(row["num"].ToString()), p = 0, drilldown = row["itemname"].ToString() });
                    }
                    else
                    {
                        seriesList.Add(new { name = row["itemname"].ToString(), y = int.Parse(row["num"].ToString()), p = 0 });
                    }
                }

                #region MyRegion
                //var treeList = new List<TreeGridEntity>();
                //foreach (DataRow row in dt.Rows)
                //{
                //    //TreeListForHidden tentity = new TreeListForHidden();
                //    //tentity.createuserdeptcode = row["createuserdeptcode"].ToString();
                //    //tentity.fullname = row["fullname"].ToString();
                //    //tentity.sortcode = row["sortcode"].ToString();
                //    //tentity.departmentid = row["departmentid"].ToString();
                //    //if (row["parentid"].ToString() != "0")
                //    //{
                //    //    tentity.parent = row["parentid"].ToString();
                //    //}
                //    //tentity.importanhid = Convert.ToDecimal(row["importanhid"].ToString());
                //    //tentity.ordinaryhid = Convert.ToDecimal(row["ordinaryhid"].ToString());
                //    //tentity.total = Convert.ToDecimal(row["total"].ToString());
                //    TreeGridEntity tree = new TreeGridEntity();
                //    bool hasChildren = dt.Select(string.Format(" parentid ='{0}'", tentity.departmentid)).Count() == 0 ? false : true;
                //    tentity.haschild = hasChildren;
                //    tree.id = row["departmentid"].ToString();
                //    tree.parentId = row["parentid"].ToString();
                //    string itemJson = tentity.ToJson();
                //    tree.entityJson = itemJson;
                //    tree.expanded = false;
                //    tree.hasChildren = hasChildren;
                //    treeList.Add(tree);
                //}
                #endregion

                returnList.Add(new { seriesdata = seriesList, drilldowndata = drilldownList });
            }
            else if (type == 1) //参加演练人次统计
            {
                var dt = drillplanrecordbll.GetDrillPlanRecordTypeSta(cwhere, 2);
                foreach (DataRow row in dt.Rows)
                {
                    returnList.Add(new { name = row["itemname"].ToString(), y = int.Parse(row["num"].ToString()), p = 0 });
                }
            }
            else if (type == 5) //外委跟单位内部分析
            {
                var bll  = new ReserverplanBLL();
                var list = bll.GetList(sqlwhere).GroupBy(e => e.ORGXZNAME);
                foreach (var item in list)
                {
                    returnList.Add(new { text = item.Key, value = item.Count() });
                }
            }
            else
            {
                //计划的数量
                var list_JH             = drillplanbll.GetList(sqlwhere).Where(e => e.PLANTIME.Value.Year == year && (deptId.Length > 0 ? e.DEPARTID == deptId : 1 == 1));
                DrillplanrecordBLL dbll = new DrillplanrecordBLL();
                //统计实际计划数量
                var list_SJ = dbll.GetList(sqlwhere).Where(e => e.DRILLTIME.Value.Year == year && (deptId.Length > 0 ? e.DEPARTID == deptId : 1 == 1));
                if (type == 2 || type == 3)
                {
                    #region  季度统计
                    //开始统计,计划的数量
                    decimal[] jd_JH = { 0, 0, 0, 0 };
                    foreach (var item in list_JH)
                    {
                        if (deptId.Length > 0 && item.DEPARTID != deptId)
                        {
                            continue;
                        }
                        if (year > 0 && item.PLANTIME.Value.Year != year)
                        {
                            continue;
                        }
                        var month = item.PLANTIME.Value.Month;

                        if (month >= 1 && month <= 3)
                        {
                            jd_JH[0]++;
                        }

                        if (month >= 4 && month <= 6)
                        {
                            jd_JH[1]++;
                        }

                        if (month >= 7 && month <= 9)
                        {
                            jd_JH[2]++;
                        }

                        if (month >= 10 && month <= 12)
                        {
                            jd_JH[3]++;
                        }
                    }

                    //开始统计,实际的数量
                    decimal[] jd_SJ = { 0, 0, 0, 0 };
                    foreach (var item in list_SJ)
                    {
                        if (deptId.Length > 0 && item.DEPARTID != deptId)
                        {
                            continue;
                        }
                        if (year > 0 && item.DRILLTIME.Value.Year != year)
                        {
                            continue;
                        }
                        var month = item.DRILLTIME.Value.Month;

                        if (month >= 1 && month <= 3)
                        {
                            jd_SJ[0]++;
                        }

                        if (month >= 4 && month <= 6)
                        {
                            jd_SJ[1]++;
                        }

                        if (month >= 7 && month <= 9)
                        {
                            jd_SJ[2]++;
                        }

                        if (month >= 10 && month <= 12)
                        {
                            jd_SJ[3]++;
                        }
                    }
                    List <string> xValues = new List <string>();

                    if (jd == 0)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            xValues.Add("第" + (i + 1) + "季度");
                        }
                        for (int i = 0; i < xValues.Count; i++)
                        {
                            var jhNum = 0M;
                            var value = 0M;

                            if (jd_JH[i] == 0)
                            {
                                jhNum = 0;
                                value = 0;
                            }
                            else
                            {
                                jhNum = jd_JH[i];
                                value = (jd_SJ[i] / jd_JH[i]) * 100;
                            }
                            var finish = new { text = xValues[i], jhNum = jhNum, value = decimal.Round(value, 2), sjNum = jd_SJ[i] };
                            returnList.Add(finish);
                        }
                    }
                    else
                    {
                        var jhNum = 0M;
                        var value = 0M;

                        if (jd_JH[jd - 1] == 0)
                        {
                            jhNum = 0;
                            value = 0;
                        }
                        else
                        {
                            jhNum = jd_JH[jd - 1];
                            value = (jd_SJ[jd - 1] / jd_JH[jd - 1]) * 100;
                        }
                        var finish = new { text = "第" + jd + "季度", jhNum = jhNum, value = decimal.Round(value, 2), sjNum = jd_SJ[jd - 1] };
                        returnList.Add(finish);
                    }
                    #endregion
                }
                if (type == 4)
                {
                    #region 方式统计

                    ////判断月份
                    var drillmode = dataItemCache.GetDataItemList("MAE_DirllMode");
                    foreach (var item in drillmode)
                    {
                        var dpf = new { text = item.ItemName, jhNum = list_JH.Where(e => (year > 0 ? e.PLANTIME.Value.Year == year : 1 == 1) && (monthCK > 0 ? e.PLANTIME.Value.Month == monthCK : 1 == 1) && e.DRILLMODENAME == item.ItemName).Count(), sjNum = list_SJ.Where(e => (year > 0 ? e.DRILLTIME.Value.Year == year : 1 == 1) && (monthCK > 0 ? e.DRILLTIME.Value.Month == monthCK : 1 == 1) && e.DRILLMODENAME == item.ItemName).Count() };
                        returnList.Add(dpf);
                    }
                    #endregion
                }
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(returnList));
        }
Beispiel #2
0
        public ActionResult GetListJson(string queryJson)
        {
            var data = reserverplanbll.GetList(queryJson);

            return(ToJsonResult(data));
        }