private string GetWhere() { string where = ""; string query = Request.Url.Query; if ((!SmallQIDs.Equals("")) || SmallQIDs != null) { where += "&SmallQIDs=" + BLL.Util.EscapeString(SmallQIDs); } if ((!QustionType.Equals("")) || QustionType != null) { where += "&QustionType=" + BLL.Util.EscapeString(QustionType); } if ((!QustionName.Equals("")) || QustionName != null) { where += "&QustionName=" + BLL.Util.EscapeString(QustionName); } if ((!KCID.Equals("")) || KCID != null) { where += "&KCID=" + BLL.Util.EscapeString(KCID); } where += "&random=" + (new Random()).Next().ToString(); return(where); }
public ActionResult ZiXiAction() { var Jih = jiHuaBLL.GetAllData().Where(p => p.ShiFouWanCheng == false).OrderByDescending(p => p.ID).First(); DateTime StartTime = (DateTime)Jih.KaiShiShiJian; DateTime EndTime = (DateTime)Jih.JieShuShiJian; TimeSpan time = EndTime - StartTime; //本次班级排课班级及次数集合 List <BenCiPaiKeBanJiJiCiShu> Class = PaiKeBanJiJiCiShuBLL.GetAllData(); //已安排上课的班级 var ClassList = PaiKeBLL.GetAllData(); //本次排课的班级 var ClassList2 = Class.ToList().Distinct(); var ClassList3 = ClassList2.ToList().OrderBy(i => Guid.NewGuid()).ToList(); try { foreach (var item in ClassList2) { for (int i = 0; i < time.Days; i++) { //查询当天的上午是否排课 var Count = ClassList.Where(p => p.BJ == item.BanJiMingChen && p.RQ == StartTime.AddDays(i) && p.SD == "上").Count(); var WeiAnPaiList = PaiKeBLL.List(StartTime.AddDays(i)); if (Count == 0) { if (PaiKeBLL.List(StartTime.AddDays(i), "上").Count() == 0) { PaikeLinshiBiao paikeLinshi = new PaikeLinshiBiao() { JS = "未安排", BJ = item.BanJiMingChen, KC = "放假", JY = "未安排", RQ = StartTime.AddDays(i), SD = "上" }; PaiKeBLL.Add(paikeLinshi); } else { var a = PaiKeBLL.List(StartTime.AddDays(i), "上").First();; PaikeLinshiBiao paikeLinshi = new PaikeLinshiBiao() { JS = a.KeYongZiYuanMingChen, BJ = item.BanJiMingChen, KC = "自习", JY = "未安排", RQ = StartTime.AddDays(i), SD = "上" }; PaiKeBLL.Add(paikeLinshi); } } //查询当天的下午是否排课 var XW = ClassList.Where(p => p.BJ == item.BanJiMingChen && p.RQ == StartTime.AddDays(i) && p.SD == "下").Count(); if (XW == 0) { if (PaiKeBLL.List(StartTime.AddDays(i), "下").Count() == 0) { PaikeLinshiBiao paikeLinshi = new PaikeLinshiBiao() { JS = "未安排", BJ = item.BanJiMingChen, KC = "自习", JY = "未安排", RQ = StartTime.AddDays(i), SD = "下" }; PaiKeBLL.Add(paikeLinshi); } else { var a = PaiKeBLL.List(StartTime.AddDays(i), "下").First(); PaikeLinshiBiao paikeLinshi = new PaikeLinshiBiao() { JS = a.KeYongZiYuanMingChen, BJ = item.BanJiMingChen, KC = "自习", JY = "未安排", RQ = StartTime.AddDays(i), SD = "下" }; PaiKeBLL.Add(paikeLinshi); } } //查询当天是否排课 var SD = PaiKeBLL.GetAllData().Where(p => p.BJ == item.BanJiMingChen && p.RQ == StartTime.AddDays(i)).Count(); if (SD == 0) { var a = PaiKeBLL.List(StartTime.AddDays(i)).First(); for (int Hi = 0; Hi < 2; Hi++) { string str2 = ""; if (i == 1) { str2 = "上"; } else { str2 = "下"; } PaikeLinshiBiao paikeLinshi = new PaikeLinshiBiao() { JS = a.KeYongZiYuanMingChen, BJ = item.BanJiMingChen, KC = "自习", JY = "0", RQ = StartTime.AddDays(i), SD = str2 }; PaiKeBLL.Add(paikeLinshi); } } } } ShangKeBiaoBLL.TruncateZhangZaiShangKeBiao(); //排课集合 var List = PaiKeBLL.GetAllData().OrderBy(p => p.RQ).Where(p => p.KC == "自习").ToList(); //添加到一次课表 foreach (var item in List) { string TeacherName = ""; int TeacherID = 0; YuanGongBiao Teacher; JiaoXueKeCheng KC; string KCName; int KCID; string ZJName = ""; int ZJID; if (item.JY == "未安排") { TeacherName = "未安排"; } else { Teacher = yuan.GetAllData().Where(p => p.ID == Convert.ToInt32(item.JY)).First(); TeacherName = Teacher.JiaoYuanMingChen; TeacherID = Teacher.ID; } if (item.KC == "自习") { KCName = "自习"; KCID = 0; ZJName = "无"; ZJID = 0; } else { var ZJ = KeChengJiHuaBiaoBLL.GetAllData().Where(p => p.BanJiMing == item.BJ && p.ZhangJieMingChen == item.KC).First(); KC = JiaoXueKeChengBLL.GetAllData().Where(p => p.ID == ZJ.KeChengMing).First(); KCName = KC.KeChengMing; KCID = KC.ID; ZJName = ZJ.ZhangJieMingChen; ZJID = (int)ZJ.ZhangJieBianHao; } //获取课程名 var ZY = ZiYuanGuanLiBLL.GetAllData().Where(p => p.ZiYuanMing == item.JS).First(); string SJMing = ""; if (item.SD == "上") { SJMing = "8:00-12:20"; } else { SJMing = "13:30 - 17:30"; } YiCiPaiKeDeKeBiaoXinXiBiao yiCiPaiKeDeKeBiaoXinXi = new YiCiPaiKeDeKeBiaoXinXiBiao { CanJiaRenYuan = TeacherName, BeiZhu = Jih.JiHuaMingChen, RiQi = item.RQ, ShiJianDuan = item.SD, ShiJianMing = SJMing, ZhuangTai = "待上课", JiaoYuanBianHao = TeacherID.ToString(), JiaoYuanMingChen = TeacherName, ShiShiShiJian = item.RQ.ToString(), ZhangJieBianHao = ZJID.ToString(), ZhangJieMingChen = ZJName, KeChengBianHao = KCID.ToString(), KeChengMingChen = KCName, ZiYuanBianHao = ZY.ID.ToString(), ZiYuanMingChen = item.JS, ClassName = item.BJ, }; bLL.Add(yiCiPaiKeDeKeBiaoXinXi); } } catch (Exception ex) { return(Json(new { errorInfo = "没有可安排排课的资源" + ex + "", errorNo = "0", }, JsonRequestBehavior.AllowGet)); } ShangKeBiaoBLL.Add(); return(Json(new { errorInfo = "设置本次自习课完成", errorNo = "0", }, JsonRequestBehavior.AllowGet)); }
public ActionResult PaiKe(int ID) { //根据ID获取教务选择的排课方案 var one = PaiKeFangAn.GetAllData().Where(p => p.ID == ID).First(); //排课时段与资源集合 List <PaiKeShiDuanYuZiYuanZuHe> shiDuanBiaos = PaiKeShiDuanYuZiYuan.GetAllData(); //本次班级排课班级及次数集合 List <BenCiPaiKeBanJiJiCiShu> Class = PaiKeBanJiJiCiShuBLL.GetAllData(); //本次排课默认课次表 List <BeCiPaiKeMorenKeCiBioa> KeCiList = KeCi.GetAllData(); var ZYuan = keYongZiYuanBLL.GetAllData(); var ZYuanCount = keYongZiYuanBLL.GetAllData().Count(); //可排三个班的教室 var three = KeCiList.Where(p => p.ClassCount == 3).ToList(); //可排两个班的教室 var two = KeCiList.Where(p => p.ClassCount == 2).ToList(); //可排一个班的教室 var one2 = KeCiList.Where(p => p.ClassCount == 1).ToList(); List <Hi> o = bLL.banJiKaiSheKeChengJiHuaBiaos(); //获取排课资源的次数 //删除零时表数据 PaiKeBLL.DeleteTable(); bLL.DeleteTable(); //形态 Dictionary <string, List <List <string> > > dicFA = new Dictionary <string, List <List <string> > > { //3个班排课方式只有一种 { "3-1", new List <List <string> >() { new List <string> { "1-上", "3-上", "4-上", "6-上" }, //第1个班 new List <string> { "1-下", "2-下", "4-下", "5-下" }, //第2个班 new List <string> { "2-上", "3-下", "5-上", "6-下" } //第3个班 } }, //2个班排课方式列出几种 { "2-1", new List <List <string> >() { new List <string> { "1-上", "3-上", "4-上", "6-上" }, //第1个班 new List <string> { "1-下", "3-下", "4-下", "6-下" } //第2个班 } }, { "2-2", new List <List <string> >() { new List <string> { "1-上", "3-上", "4-上", "6-上" }, //第1个班 new List <string> { "1-下", "2-下", "4-下", "5-下" } //第2个班 } }, { "2-3", new List <List <string> >() { new List <string> { "2-上", "3-上", "5-上", "6-上" }, //第1个班 new List <string> { "2-下", "3-下", "5-下", "6-下" } //第2个班 } }, //1个班排课方式列出几种 { "1-1", new List <List <string> >() { new List <string> { "1-上", "3-上", "4-上", "6-上" } //第1个班 } }, { "1-2", new List <List <string> >() { new List <string> { "1-下", "3-下", "4-下", "6-下" } //第1个班 } }, { "1-3", new List <List <string> >() { new List <string> { "1-上", "2-上", "4-上", "5-上" } //第1个班 } }, { "1-4", new List <List <string> >() { new List <string> { "1-下", "2-下", "4-下", "5-下" } //第1个班 } }, { "1-5", new List <List <string> >() { new List <string> { "2-下", "3-下", "5-下", "6-下" } //第1个班 } }, { "1-6", new List <List <string> >() { new List <string> { "2-上", "3-上", "5-上", "6-上" } //第1个班 } } }; //上课课表集合 List <JSPJJY> jsspjjyList = new List <JSPJJY>(); int n3_1 = 0; int n2_1 = 0; int n1_1 = 0; string str = ""; foreach (var item in o.OrderBy(p => p.AnPaiJiaoYuan)) { if (str != item.AnPaiJiaoYuan + "") { //根据安排教员查找出所带班级 var tempbjlist = bLL.List(item.AnPaiJiaoYuan); int bjcount = tempbjlist.Count();// //==========================// if (bjcount == 3) { var aaa = three[n3_1++];// for (int in1 = 0; in1 < tempbjlist.Count(); in1++) { JSPJJY jSPJJY = new JSPJJY { JS = aaa.ZiYuanMingChen, JY = item.AnPaiJiaoYuan + "", PBS = 3 + "", XD = "3-1", XDIndex = in1 + 1, BJ = tempbjlist[in1].BanJiMing }; jsspjjyList.Add(jSPJJY); } } //=========================// if (bjcount == 2) { var aaa = two[n2_1++];// for (int in1 = 0; in1 < tempbjlist.Count(); in1++) { JSPJJY jSPJJY = new JSPJJY { JS = aaa.ZiYuanMingChen, JY = item.AnPaiJiaoYuan + "", PBS = 2 + "", XD = "2-1", XDIndex = in1 + 1, BJ = tempbjlist[in1].BanJiMing }; jsspjjyList.Add(jSPJJY); } } //==================// if (bjcount == 1) { var aaa = one2[n1_1++];// // for (int in1 = 0; in1 < tempbjlist.Count(); in1++) { JSPJJY jSPJJY = new JSPJJY { JS = aaa.ZiYuanMingChen, JY = item.AnPaiJiaoYuan + "", PBS = 1 + "", XD = "1-1", XDIndex = in1 + 1, BJ = tempbjlist[in1].BanJiMing }; // jsspjjyList.Add(jSPJJY); } } str = item.AnPaiJiaoYuan + "";// } } //////////////////////// //开始排课时间 var Jih = jiHuaBLL.GetAllData().Where(p => p.ShiFouWanCheng == false).OrderByDescending(p => p.ID).First(); DateTime StartTime = (DateTime)Jih.KaiShiShiJian; DateTime EndTime = (DateTime)Jih.JieShuShiJian; TimeSpan time = EndTime - StartTime; //课表集合 List <KB> kBs = new List <KB>(); //安排上课教室 foreach (var item in jsspjjyList) { var obj = item; List <string> SD = dicFA[item.XD][item.XDIndex - 1]; int i = 0; foreach (var item2 in SD) { string[] s = item2.Split(new char[] { '-' }); int aday = Convert.ToInt32(s[0]); //开始时间+天数,为排课日期 string strsd = s[1]; //时段 i++; if (StartTime.AddDays(aday - 1) <= EndTime) { var ClassKC = KeChengJiHuaBiaoBLL.GetAllData().Where(p => p.BanJiMing == item.BJ && p.ShiFouYiWanCheng == false).Take(4).ToList(); KB kB = new KB() { BJ = item.BJ, RQ = StartTime.AddDays(aday - 1), SD = strsd, JS = item.JS, KC = ClassKC[i - 1].ZhangJieMingChen, JY = item.JY }; PaikeLinshiBiao paikeLinshiBiao = new PaikeLinshiBiao { BJ = kB.BJ, RQ = kB.RQ, SD = kB.SD, JS = kB.JS, KC = kB.KC, JY = kB.JY }; PaiKeBLL.Add(paikeLinshiBiao); kBs.Add(kB); } //设置自习课:实习方式,查询出没有进行排课的教室,设置为自习,并且不能出现时间冲突 } } //#region 无用 ////已安排上课的班级 //var ClassList = PaiKeBLL.GetAllData(); ////本次排课的班级 //var ClassList2 = Class.ToList().Distinct(); //foreach (var item in ClassList2) //{ // for (int i = 0; i < time.Days; i++) // { // //查询当天的上午是否排课 // var Count = ClassList.Where(p => p.BJ == item.BanJiMingChen && p.RQ == StartTime.AddDays(i) && p.SD == "上").Count(); // var WeiAnPaiList = PaiKeBLL.List(StartTime.AddDays(i)); // if (Count == 0) // { // var a = PaiKeBLL.List(StartTime.AddDays(i), "上").First(); ; // PaikeLinshiBiao paikeLinshi = new PaikeLinshiBiao() // { // JS = a.KeYongZiYuanMingChen, // BJ = item.BanJiMingChen, // KC = "自习", // JY = "未安排", // RQ = StartTime.AddDays(i), // SD = "上" // }; // PaiKeBLL.Add(paikeLinshi); // } // //查询当天的下午是否排课 // var XW = ClassList.Where(p => p.BJ == item.BanJiMingChen && p.RQ == StartTime.AddDays(i) && p.SD == "下").Count(); // if (XW == 0) // { // var a = PaiKeBLL.List(StartTime.AddDays(i), "下").First(); ; // PaikeLinshiBiao paikeLinshi = new PaikeLinshiBiao() // { // JS = a.KeYongZiYuanMingChen, // BJ = item.BanJiMingChen, // KC = "自习", // JY = "未安排", // RQ = StartTime.AddDays(i), // SD = "下" // }; // PaiKeBLL.Add(paikeLinshi); // } // //查询当天是否排课 // var SD = PaiKeBLL.GetAllData().Where(p => p.BJ == item.BanJiMingChen && p.RQ == StartTime.AddDays(i)).Count(); // if (SD == 0) // { // var a = PaiKeBLL.List(StartTime.AddDays(i)).First(); // for (int Hi = 0; Hi < 2; Hi++) // { // string str2 = ""; // if (i == 1) // { // str2 = "上"; // } // else // { // str2 = "下"; // } // PaikeLinshiBiao paikeLinshi = new PaikeLinshiBiao() // { // JS = a.KeYongZiYuanMingChen, // BJ = item.BanJiMingChen, // KC = "自习", // JY = "0", // RQ = StartTime.AddDays(i), // SD = str2 // }; // PaiKeBLL.Add(paikeLinshi); // } // } // } //} //#endregion //排课集合 var List = PaiKeBLL.GetAllData().OrderBy(p => p.RQ).ToList(); //添加到一次课表 foreach (var item in List) { string TeacherName = ""; int TeacherID = 0; YuanGongBiao Teacher; JiaoXueKeCheng KC; string KCName; int KCID; string ZJName = ""; int ZJID; Teacher = yuan.GetAllData().Where(p => p.ID == Convert.ToInt32(item.JY)).First(); TeacherName = Teacher.JiaoYuanMingChen; TeacherID = Teacher.ID; var ZJ = KeChengJiHuaBiaoBLL.GetAllData().Where(p => p.BanJiMing == item.BJ && p.ZhangJieMingChen == item.KC).First(); KC = JiaoXueKeChengBLL.GetAllData().Where(p => p.ID == ZJ.KeChengMing).First(); KCName = KC.KeChengMing; KCID = KC.ID; ZJName = ZJ.ZhangJieMingChen; ZJID = (int)ZJ.ZhangJieBianHao; //if (item.JY == "未安排") //{ // TeacherName = "未安排"; //} //else //{ //} //if (item.KC == "自习") //{ // KCName = "自习"; // KCID = 0; // ZJName = "无"; // ZJID = 0; //} //else //{ //} //获取课程名 var ZY = ZiYuanGuanLiBLL.GetAllData().Where(p => p.ZiYuanMing == item.JS).First(); string SJMing = ""; if (item.SD == "上") { SJMing = "8:00-12:20"; } else { SJMing = "13:30 - 17:30"; } YiCiPaiKeDeKeBiaoXinXiBiao yiCiPaiKeDeKeBiaoXinXi = new YiCiPaiKeDeKeBiaoXinXiBiao { CanJiaRenYuan = TeacherName, BeiZhu = Jih.JiHuaMingChen, RiQi = item.RQ, ShiJianDuan = item.SD, ShiJianMing = SJMing, ZhuangTai = "待上课", JiaoYuanBianHao = TeacherID.ToString(), JiaoYuanMingChen = TeacherName, ShiShiShiJian = item.RQ.ToString(), ZhangJieBianHao = ZJID.ToString(), ZhangJieMingChen = ZJName, KeChengBianHao = KCID.ToString(), KeChengMingChen = KCName, ZiYuanBianHao = ZY.ID.ToString(), ZiYuanMingChen = item.JS, ClassName = item.BJ, }; bLL.Add(yiCiPaiKeDeKeBiaoXinXi); } return(Json(new { errorInfo = "设置上课课表完成", errorNo = "0" }, JsonRequestBehavior.AllowGet)); }