コード例 #1
0
ファイル: TableController.cs プロジェクト: 727841493/Bp
        /// <summary>
        ///删除预览图片
        /// </summary>
        public string deleteLookPic()
        {
            //目标文件夹配置路径
            string load = System.Configuration.ConfigurationManager.AppSettings["loadSrc"];

            //目标文件夹的文件名
            string desdir = Server.MapPath(load) + CookieResult.CookieName();

            DirectoryInfo dir = new DirectoryInfo(desdir);

            FileSystemInfo[] fileinfo = dir.GetFileSystemInfos();  //返回目录中所有文件和子目录
            foreach (FileSystemInfo i in fileinfo)
            {
                if (i is DirectoryInfo)            //判断是否文件夹
                {
                    DirectoryInfo subdir = new DirectoryInfo(i.FullName);
                    subdir.Delete(true);          //删除子目录和文件
                }
                else
                {
                    System.IO.File.Delete(i.FullName);      //删除指定文件
                }
            }
            return(AjaxResult.Success(null, "删除成功").ToString());
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: 727841493/Bp
        //查询判断
        public string queryByName(string name)
        {
            var cookie = CookieResult.CookieName();
            var user   = db.Users.Where(x => x.登录名 == name).FirstOrDefault();

            if (name != cookie && user != null)
            {
                return(AjaxResult.Error("已存在该用户").ToString());
            }
            return(AjaxResult.Success(null, "可以使用").ToString());
        }
コード例 #3
0
        //查询通知
        public JsonResult QueryMessages(string id)
        {
            var    name       = CookieResult.CookieName();
            int    pageSize   = int.Parse(Request["pageSize"] ?? "10");
            int    pageNumber = int.Parse(Request["pageNumber"] ?? "1");
            string sortOrder  = Request["sortOrder"];
            string searchText = Request["searchText"];
            string sortName   = Request["sortName"];
            var    list       = from msg in db.Bp_通知
                                select new
            {
                状态   = msg.查看人.IndexOf(name),
                ID   = msg.ID,
                标题   = msg.标题,
                内容   = msg.内容,
                发布时间 = msg.发布时间,
                发布人  = msg.发布人,
                查看人  = msg.查看人,
            };

            //查询本月通知
            //DateTime now = DateTime.Now;
            //DateTime d1 = new DateTime(now.Year, now.Month, 1);
            //string startTime = d1.ToString();
            //list = list.Where(x => String.Compare(startTime, x.发布时间) <= 0);
            if (!string.IsNullOrEmpty(id))
            {
                list = list.Where(x => x.ID == id);
                if (list.Count() > 0)
                {
                    ChangeStatus(id, name);
                }
            }
            switch (sortOrder)
            {
            case "desc":
                list = list.OrderByDescending(w => w.发布时间);
                break;

            case "asc":
                list = list.OrderBy(w => w.发布时间);
                break;

            default:
                list = list.OrderByDescending(w => w.发布时间);
                break;
            }
            ;
            return(Json(list));
        }
コード例 #4
0
        /// <summary>
        ///重命名查看图片
        /// </summary>
        /// <param name="id">guid</param>
        /// <returns>图片</returns>
        public JsonResult QueryFile(string id)
        {
            //根据项目编码查询符合条件的资料
            var list = db.Bp_分享资料.Where(x => x.ID == id).FirstOrDefault();
            //存放查询出来的文件
            List <string> files = new List <string>();
            //文件根目录
            var homePath = System.Configuration.ConfigurationManager.AppSettings["shareFile"];
            //目标文件夹配置路径
            string load = System.Configuration.ConfigurationManager.AppSettings["loadSrc"];
            //目标文件夹的文件名
            string desdir = Server.MapPath(load) + CookieResult.CookieName();

            //判断文件夹是否存在
            if (!Directory.Exists(desdir))
            {
                // 目录不存在,建立目录
                Directory.CreateDirectory(desdir);
            }
            //动态拼接文件路径
            string path = homePath + list.ID;
            //文件路径集合
            var ls = Directory.GetFiles(path).ToList().FirstOrDefault();

            try
            {
                //判断文件是否是图片格式
                System.Drawing.Image img = System.Drawing.Image.FromFile(ls);
                //目标图片保存的路径和名称
                String imgPath = desdir + '\\' + list.资料名称;

                //true 覆盖已存在的同名文件,false则反之
                bool isrewrite = true;

                //从源文件复制到目标文件中
                System.IO.File.Copy(ls, imgPath, isrewrite);

                //绝对路径转换为相对路径
                int    j   = imgPath.IndexOf("Data");
                string str = imgPath.Substring(j);
                string url = str.Replace(@"\", @"/");
                //添加到查询文件集合中
                files.Add("../" + url);
            }
            catch (Exception)
            {
                return(Json(files));
            }
            return(Json(files));
        }
コード例 #5
0
ファイル: TableController.cs プロジェクト: 727841493/Bp
        /// <summary>
        ///添加爆破评分
        /// </summary>
        /// <param name="id">项目编码</param>
        /// <param name="kd">块度分数</param>
        /// <param name="pz">抛掷分数</param>
        /// <param name="gd">根底分数</param>
        /// <param name="sy">伞岩分数</param>
        /// <param name="test">评价</param>
        /// <returns>添加是否成功</returns>
        public string AddComment(string id, double?kd, double?pz, double?gd, double?sy, string text)
        {
            var name = CookieResult.CookieName();

            if (kd == null)
            {
                kd = 0;
            }
            if (pz == null)
            {
                pz = 0;
            }
            if (gd == null)
            {
                gd = 0;
            }
            if (sy == null)
            {
                sy = 0;
            }
            var xm          = db.Bp_项目.Where(x => x.项目编码 == id).FirstOrDefault();
            var userComment = db.Bp_Data_comment.FirstOrDefault(x => x.项目编码 == id && x.项目ID == xm.ID && x.评论人 == name);

            if (userComment != null)
            {
                return(AjaxResult.Error("你已给该次爆破评过分了!").ToString());
            }
            try
            {
                Bp_Data_comment comment = new Bp_Data_comment
                {
                    ID   = Guid.NewGuid().ToString(),
                    项目ID = xm.ID,
                    项目编码 = id,
                    评论人  = name,
                    块度评分 = kd,
                    抛掷评分 = pz,
                    根底评分 = gd,
                    伞岩评分 = sy,
                    评论   = text,
                };
                db.Bp_Data_comment.Add(comment);
                db.SaveChanges();
                return(AjaxResult.Success(null, "添加成功").ToString());
            }
            catch (Exception e)
            {
                return(AjaxResult.Error("添加失败", e).ToString());
            }
        }
コード例 #6
0
        /// <summary>
        ///删除共享文件
        /// </summary>
        /// <param name="id">文档的guid</param>
        public string DeleteShareFile(string id)
        {
            var name = CookieResult.CookieName();
            var user = db.Users.Where(x => x.登录名 == name).FirstOrDefault();

            var list = db.Bp_分享资料.Where(x => x.ID == id);

            //文件根目录
            var homePath = System.Configuration.ConfigurationManager.AppSettings["shareFile"];

            try
            {
                foreach (var l in list)
                {
                    //文件路径
                    string        path = homePath + l.ID;
                    DirectoryInfo dir  = new DirectoryInfo(path);
                    if (dir.Exists)
                    {
                        DirectoryInfo[] childs = dir.GetDirectories();
                        foreach (DirectoryInfo child in childs)
                        {
                            child.Delete(true);
                        }
                        dir.Delete(true);
                    }
                }

                if (user.级别 == 1)
                {
                    db.Bp_分享资料.RemoveRange(list);
                    db.SaveChanges();
                    return(AjaxResult.Success(null, "删除成功").ToString());
                }
                else
                {
                    return(AjaxResult.Error("权限不足!").ToString());
                }
            }
            catch (Exception)
            {
                return(AjaxResult.Error("删除失败").ToString());
            }
        }
コード例 #7
0
ファイル: TableController.cs プロジェクト: 727841493/Bp
 /// <summary>
 ///删除该年成本
 ///<param name="id">年份</param>
 /// </summary>
 public string deleteYear(string id)
 {
     try
     {
         var flag = false;
         var name = CookieResult.CookieName();
         var i    = int.Parse(id);
         var user = db.Users.Where(x => x.登录名 == name).FirstOrDefault();
         var ye   = db.Bp_成本年份.Where(x => x.年份 == i).FirstOrDefault();
         var list = db.Bp_成本统计.Where(x => x.yearID == ye.id);
         foreach (var l in list)
         {
             if (l.合计 != null)
             {
                 flag = true;
             }
         }
         if (flag)
         {
             if (user.级别 == 1)
             {
                 db.Bp_成本统计.RemoveRange(list);
                 db.Bp_成本年份.Remove(ye);
                 db.SaveChanges();
                 return(AjaxResult.Success(null, "删除成功").ToString());
             }
             else
             {
                 return(AjaxResult.Error("权限不足").ToString());
             }
         }
         else
         {
             db.Bp_成本统计.RemoveRange(list);
             db.Bp_成本年份.Remove(ye);
             db.SaveChanges();
             return(AjaxResult.Success(null, "删除成功").ToString());
         }
     }
     catch (Exception)
     {
         return(AjaxResult.Error("删除失败").ToString());
     }
 }
コード例 #8
0
 //删除通知
 public string DeleteMessage(string id, string title)
 {
     try
     {
         var name = CookieResult.CookieName();
         var user = db.Users.Where(x => x.登录名 == name).FirstOrDefault();
         var list = db.Bp_通知.Where(x => x.ID == id && x.标题 == title);
         if (user.级别 == 1)
         {
             db.Bp_通知.RemoveRange(list);
             db.SaveChanges();
             return(AjaxResult.Success(null, "删除成功").ToString());
         }
         else
         {
             return(AjaxResult.Error("权限不足!").ToString());
         }
     }
     catch (Exception)
     {
         return(AjaxResult.Error("删除失败!").ToString());
     }
 }
コード例 #9
0
ファイル: TableController.cs プロジェクト: 727841493/Bp
        /// <summary>
        ///删除文件中的图片
        /// </summary>
        /// <param name="id">资料ID</param>
        /// <param name="name">资料名称</param>
        /// <returns>图片</returns>
        public string deletePic(string id)
        {
            var user = CookieResult.CookieName();
            var list = db.Bp_项目资料.Where(x => x.资料ID == id).FirstOrDefault();

            if (list == null)
            {
                return(AjaxResult.Error("图片不存在或已被删除").ToString());
            }
            else
            {
                if (list.人 != user)
                {
                    return(AjaxResult.Error("无权删除该图片").ToString());
                }
                else
                {
                    try
                    {
                        var homePath = System.Configuration.ConfigurationManager.AppSettings["imageSrc"];

                        var path = homePath + list.资料ID;

                        DirectoryInfo di = new DirectoryInfo(path);
                        di.Delete(true);

                        db.Bp_项目资料.Remove(list);
                        db.SaveChanges();
                        return(AjaxResult.Success(null, "删除成功").ToString());
                    }
                    catch (Exception e)
                    {
                        return(AjaxResult.Error("删除失败" + e).ToString());
                    }
                }
            }
        }
コード例 #10
0
        //查询共享文件
        public JsonResult QueryAllShare()
        {
            var    name       = CookieResult.CookieName();
            int    pageSize   = int.Parse(Request["pageSize"] ?? "10");
            int    pageNumber = int.Parse(Request["pageNumber"] ?? "1");
            string sortOrder  = Request["sortOrder"];
            string searchText = Request["searchText"];
            string sortName   = Request["sortName"];

            var list = from s in db.Bp_分享资料
                       select new
            {
                ID   = s.ID,
                资料名称 = s.资料名称,
                时间   = s.时间,
                人    = s.人,
                别名   = s.别名,
            };

            switch (sortOrder)
            {
            case "desc":
                list = list.OrderByDescending(w => w.时间);
                break;

            case "asc":
                list = list.OrderBy(w => w.时间);
                break;

            default:
                list = list.OrderByDescending(w => w.时间);
                break;
            }
            ;
            return(Json(list));
        }
コード例 #11
0
 //添加通知
 public string AddMessages(string title, string context)
 {
     try
     {
         var   name = CookieResult.CookieName();
         var   time = DateTime.Now;
         Bp_通知 msg  = new Bp_通知
         {
             ID   = Guid.NewGuid().ToString(),
             标题   = title,
             内容   = context,
             发布人  = name,
             查看人  = name,
             发布时间 = time.ToString(),
         };
         db.Bp_通知.Add(msg);
         db.SaveChanges();
         return(AjaxResult.Success(null, "发布成功").ToString());
     }
     catch (Exception)
     {
         return(AjaxResult.Error("发布失败!").ToString());
     }
 }
コード例 #12
0
        public void Upload(FormCollection form)
        {
            //if (Request.Files.Count == 0)
            //{
            //Request.Files.Count 文件数为0上传不成功
            //Response.Write("<script>alert('上传失败');window.location.href='/Home/Index';</script>");
            //}
            var file  = Request.Files["file"];
            var alias = form["alias"];
            var list  = db.Bp_分享资料.Where(x => x.别名 == alias);

            if (list.Count() > 0 || alias == null || alias == "")
            {
                //别名已存在或没写别名
                Response.Write("<script>alert('上传失败');window.location.href='/Home/Index';</script>");
            }
            else
            {
                if (file.ContentLength == 0)
                {
                    //文件大小大(以字节为单位)为0时,做一些操作
                    Response.Write("<script>alert('上传失败');window.location.href='/Home/Index';</script>");
                }
                else
                {
                    //上传人
                    var name = CookieResult.CookieName();

                    //上传时间
                    var time = DateTime.Now;
                    //文件存放路径
                    var homePath = System.Configuration.ConfigurationManager.AppSettings["shareFile"];
                    var guid     = Guid.NewGuid().ToString();

                    //文件大小不为0
                    file = Request.Files["file"];
                    string target = homePath + guid; //取得目标文件夹的路径
                                                     //取得文件名字
                    var filename = file.FileName;
                    try
                    {
                        Bp_分享资料 fxzl = new Bp_分享资料
                        {
                            ID   = guid,
                            资料名称 = filename,
                            时间   = time,
                            人    = name,
                            别名   = alias,
                        };
                        db.Bp_分享资料.Add(fxzl);
                        db.SaveChanges();
                        //判断文件夹是否存在
                        if (!Directory.Exists(target))
                        {
                            // 目录不存在,建立目录
                            Directory.CreateDirectory(target);
                        }
                        //获取存储的目标地址
                        string path = target + "\\" + filename;
                        file.SaveAs(path);
                        Response.Write("<script>alert('上传成功');window.location.href='/Home/Index';</script>");
                    }
                    catch (Exception)
                    {
                        Response.Write("<script>alert('上传失败');window.location.href='/Home/Index';</script>");
                    }
                }
            }
        }
コード例 #13
0
        //报表查询
        public JsonResult QueryStatistics()
        {
            try
            {
                var    name       = CookieResult.CookieName();
                int    pageSize   = int.Parse(Request["pageSize"] ?? "10");
                int    pageNumber = int.Parse(Request["pageNumber"] ?? "1");
                string sortOrder  = Request["sortOrder"];
                string searchText = Request["searchText"];
                string sortName   = Request["sortName"];

                var info = db.Bp_项目数据.ToList();

                if (info.Count != 0)
                {
                    db.Bp_项目数据.RemoveRange(info);
                    db.SaveChanges();
                }

                var lists = from xm in db.Bp_项目
                            join lp in db.BP_Data_lbastpreset on xm.ID equals lp.项目ID
                            join bb in db.BP_Data_Cal_BlastsDynamiteSet_Base on lp.项目ID equals bb.项目ID
                            //join bv in db.BP_Data_Cal_BlastsDynamiteSet_VolBase on bb.项目ID equals bv.项目ID
                            join bd in db.BP_Data_Cal_BlastsDynamiteSet_Detail on bb.项目ID equals bd.项目ID
                            select new
                {
                    项目ID = xm.ID,
                    项目编码 = xm.项目编码,
                    台阶水平 = lp.Z1,
                    日期   = lp.lbastpresetname,
                    岩性   = bb.mainRock,
                    //孔距 = bv.VolNo == "B" ? bv.ColLength : 0,
                    //排距 = bv.VolNo == "B" ? bv.VolLength : 0,
                    孔距   = db.BP_Data_Cal_BlastsDynamiteSet_VolBase.Where(x => x.项目ID == bb.项目ID).Select(x => x.ColLength).Average(),
                    排距   = db.BP_Data_Cal_BlastsDynamiteSet_VolBase.Where(x => x.VolNo != "A" && x.项目ID == bb.项目ID).Select(x => x.VolLength).Average(),
                    孔数   = bb.countBlast,
                    平均孔深 = bb.LbastDepth,
                    炸药量  = bb.countlg,
                    //抵抗线 = bv.VolNo == "A" ? bv.VolDikang : 0,
                    //超深 = bv.VolNo == "A" ? bv.BlastAddDepth : 0,
                    抵抗线 = db.BP_Data_Cal_BlastsDynamiteSet_VolBase.Where(x => x.VolNo == "A" && x.项目ID == bb.项目ID).Select(x => x.VolDikang).FirstOrDefault(),
                    超深  = db.BP_Data_Cal_BlastsDynamiteSet_VolBase.Where(x => x.项目ID == bb.项目ID).Select(x => x.BlastAddDepth).Average(),
                    填充  = bd.l1,
                };
                List <Bp_项目数据> list = new List <Bp_项目数据>();
                List <string>  id   = new List <string>();
                List <string>  bm   = new List <string>();
                foreach (var item in lists)
                {
                    if (bm.IndexOf(item.项目编码) == -1 && id.IndexOf(item.项目ID) == -1)
                    {
                        bm.Add(item.项目编码);
                        id.Add(item.项目ID);
                        Bp_项目数据 bp = new Bp_项目数据();
                        bp.项目ID = item.项目ID;
                        bp.项目编码 = item.项目编码;
                        bp.台阶水平 = item.台阶水平;
                        bp.日期   = item.日期;
                        bp.岩性   = item.岩性;
                        bp.孔距   = item.孔距;
                        bp.排距   = item.排距;
                        bp.孔数   = item.孔数;
                        bp.平均孔深 = item.平均孔深;
                        bp.炸药量  = item.炸药量;
                        bp.抵抗线  = item.抵抗线;
                        bp.超深   = item.超深;
                        bp.填充   = item.填充;
                        bp.数量   = 1;
                        list.Add(bp);
                    }
                    else
                    {
                        foreach (var i in list)
                        {
                            if (i.项目编码 == item.项目编码)
                            {
                                i.孔距  = i.孔距 + item.孔距;
                                i.排距  = i.排距 + item.排距;
                                i.抵抗线 = i.抵抗线 + item.抵抗线;
                                i.超深  = i.超深 + item.超深;
                                i.数量  = i.数量 + 1;
                            }
                        }
                    }
                }
                foreach (var item in list)
                {
                    string value = item.日期;
                    if (value.IndexOf(".") > -1)
                    {
                        value = value.Substring(0, value.IndexOf("."));
                    }
                    string[] valList = value.Split('-');
                    string   time    = "";
                    for (int t = 0; t < valList.Length; t++)
                    {
                        if (t < 3)
                        {
                            if (valList[t].IndexOf(".") > -1)
                            {
                                time += valList[t].Substring(0, valList[t].IndexOf("."));
                            }
                            else
                            {
                                time += valList[t];
                            }
                        }
                    }
                    //替换
                    //string time = value.Replace("-", "");
                    DateTime dt = new DateTime();
                    if (time.Length > 8)
                    {
                        continue;
                    }
                    if (time.Length == 8)
                    {
                        continue;
                    }
                    else
                    {
                        if (time.Length == 6)
                        {
                            dt = DateTime.ParseExact(value, "yyyy-M-d", System.Globalization.CultureInfo.CurrentCulture);
                        }
                        else if (time.Length == 7)
                        {
                            try
                            {
                                dt = DateTime.ParseExact(time, "yyyyMdd", System.Globalization.CultureInfo.CurrentCulture);
                            }
                            catch (Exception)
                            {
                                dt = DateTime.ParseExact(time, "yyyyMMd", System.Globalization.CultureInfo.CurrentCulture);
                            }
                        }
                    }
                    item.日期 = dt.ToString("yyyy-MM-dd");
                }

                foreach (var i in list)
                {
                    var n = 1;
                    foreach (var j in list)
                    {
                        if (i.日期 == j.日期 && i.项目编码 != j.项目编码)
                        {
                            if (n == 1)
                            {
                                i.日期 = i.日期 + "(" + n + ")";
                                n   += 1;
                                j.日期 = j.日期 + "(" + n + ")";
                            }
                            else
                            {
                                n   += 1;
                                j.日期 = j.日期 + "(" + n + ")";
                            }
                        }
                    }
                }

                db.Bp_项目数据.AddRange(list);
                db.SaveChanges();

                var xmsj = from sj in db.Bp_项目数据
                           select new
                {
                    项目编码 = sj.项目编码,
                    台阶水平 = sj.台阶水平,
                    日期   = sj.日期,
                    岩性   = sj.岩性,
                    孔距   = sj.孔距 / sj.数量,
                    排距   = sj.排距 / sj.数量,
                    孔数   = sj.孔数,
                    平均孔深 = sj.平均孔深,
                    炸药量  = sj.炸药量,
                    抵抗线  = sj.抵抗线 / sj.数量,
                    超深   = sj.超深 / sj.数量,
                    填充   = sj.填充,
                    孔总深  = sj.平均孔深 * sj.孔数,
                    爆破量  = (sj.孔距 / sj.数量) * (sj.排距 / sj.数量) * (sj.平均孔深 - (sj.超深 / sj.数量)) * sj.孔数 * 2.65,
                    炸药单耗 = ((sj.孔距 / sj.数量) * (sj.排距 / sj.数量) * (sj.平均孔深 - (sj.超深 / sj.数量)) * sj.孔数 * 2.65) == 0 ? 0 : sj.炸药量 / (((sj.孔距 / sj.数量) * (sj.排距 / sj.数量) * (sj.平均孔深 - (sj.超深 / sj.数量)) * sj.孔数 * 2.65) / 2.65)
                };
                switch (sortOrder)
                {
                case "a":
                    xmsj = xmsj.OrderByDescending(w => w.日期);
                    break;

                case "last_desc":
                    xmsj = xmsj.OrderByDescending(w => w.日期);
                    break;

                case "last":
                    xmsj = xmsj.OrderBy(w => w.日期);
                    break;

                default:
                    xmsj = xmsj.OrderByDescending(w => w.日期);
                    break;
                }
                ;
                return(Json(xmsj));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #14
0
ファイル: TableController.cs プロジェクト: 727841493/Bp
        /// <summary>
        ///爆破设计统计数据表的显示和筛选
        /// </summary>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="steps">台阶水平</param>
        /// <param name="lithology">岩性</param>
        /// <param name="avg">平均分</param>
        /// <returns>查询报表数据</returns>
        public JsonResult QueryStatistics(string startTime, string endTime, double?steps, string lithology, string avg)
        {
            try
            {
                var    name       = CookieResult.CookieName();
                int    pageSize   = int.Parse(Request["pageSize"] ?? "10");
                int    pageNumber = int.Parse(Request["pageNumber"] ?? "1");
                string sortOrder  = Request["sortOrder"];
                string searchText = Request["searchText"];
                string sortName   = Request["sortName"];
                var    list       = from sj in db.Bp_项目数据
                                    select new
                {
                    项目编码  = sj.项目编码,
                    台阶水平  = sj.台阶水平,
                    日期    = sj.日期,
                    岩性    = sj.岩性,
                    孔距    = sj.孔距 / sj.数量,
                    排距    = sj.排距 / sj.数量,
                    孔数    = sj.孔数,
                    平均孔深  = sj.平均孔深,
                    炸药量   = sj.炸药量,
                    抵抗线   = sj.抵抗线 / sj.数量,
                    超深    = sj.超深 / sj.数量,
                    填充    = sj.填充,
                    孔总深   = sj.平均孔深 * sj.孔数,
                    爆破量   = (sj.孔距 / sj.数量) * (sj.排距 / sj.数量) * (sj.平均孔深 - (sj.超深 / sj.数量)) * sj.孔数 * 2.65,
                    炸药单耗  = ((sj.孔距 / sj.数量) * (sj.排距 / sj.数量) * (sj.平均孔深 - (sj.超深 / sj.数量)) * sj.孔数 * 2.65) == 0 ? 0 : sj.炸药量 / (((sj.孔距 / sj.数量) * (sj.排距 / sj.数量) * (sj.平均孔深 - (sj.超深 / sj.数量)) * sj.孔数 * 2.65) / 2.65),
                    块度平均分 = db.Bp_Data_comment.Where(b => b.项目编码 == sj.项目编码 && b.项目ID == sj.项目ID).Select(b => b.块度评分).Average(),
                    抛掷平均分 = db.Bp_Data_comment.Where(b => b.项目编码 == sj.项目编码 && b.项目ID == sj.项目ID).Select(b => b.抛掷评分).Average(),
                    根底平均分 = db.Bp_Data_comment.Where(b => b.项目编码 == sj.项目编码 && b.项目ID == sj.项目ID).Select(b => b.根底评分).Average(),
                    伞岩平均分 = db.Bp_Data_comment.Where(b => b.项目编码 == sj.项目编码 && b.项目ID == sj.项目ID).Select(b => b.伞岩评分).Average(),
                    总平均分  = (db.Bp_Data_comment.Where(b => b.项目编码 == sj.项目编码 && b.项目ID == sj.项目ID).Select(b => b.块度评分).Average() + db.Bp_Data_comment.Where(b => b.项目编码 == sj.项目编码 && b.项目ID == sj.项目ID).Select(b => b.抛掷评分).Average() + db.Bp_Data_comment.Where(b => b.项目编码 == sj.项目编码 && b.项目ID == sj.项目ID).Select(b => b.根底评分).Average() + db.Bp_Data_comment.Where(b => b.项目编码 == sj.项目编码 && b.项目ID == sj.项目ID).Select(b => b.伞岩评分).Average()) / 4,
                    打分    = !db.Bp_Data_comment.Any(x => x.项目编码 == sj.项目编码 && x.项目ID == sj.项目ID && x.评论人 == name),
                    查看    = db.Bp_Data_comment.Any(x => x.项目编码 == sj.项目编码 && x.项目ID == sj.项目ID),
                    载     = db.Bp_项目资料.Any(x => x.项目编码 == sj.项目编码),
                    预览    = db.Bp_项目资料.Where(x => x.项目编码 == sj.项目编码).Select(x => x.资料名称),
                };
                if (!string.IsNullOrEmpty(startTime))
                {
                    list = list.Where(x => String.Compare(startTime, x.日期) <= 0);
                }
                if (!string.IsNullOrEmpty(endTime))
                {
                    list = list.Where(x => String.Compare(x.日期, endTime) <= 0);
                }
                if (steps != null)
                {
                    list = list.Where(lp => lp.台阶水平 == steps);
                }
                if (!string.IsNullOrEmpty(lithology))
                {
                    list = list.Where(bb => bb.岩性.Equals(lithology));
                }
                if (!string.IsNullOrEmpty(avg))
                {
                    if (avg.Equals("优"))
                    {
                        list = list.Where(b => b.总平均分 >= 4.5 && b.总平均分 <= 5);
                    }
                    if (avg.Equals("良"))
                    {
                        list = list.Where(b => b.总平均分 >= 4 && b.总平均分 < 4.5);
                    }
                    if (avg.Equals("中"))
                    {
                        list = list.Where(b => b.总平均分 >= 3 && b.总平均分 < 4);
                    }
                    if (avg.Equals("差"))
                    {
                        list = list.Where(b => b.总平均分 < 3);
                    }
                }
                switch (sortOrder)
                {
                case "a":
                    list = list.OrderByDescending(w => w.日期);
                    break;

                case "last_desc":
                    list = list.OrderByDescending(w => w.日期);
                    break;

                case "last":
                    list = list.OrderBy(w => w.日期);
                    break;

                default:
                    list = list.OrderByDescending(w => w.日期);
                    break;
                }
                ;
                return(Json(list));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }