123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using Bowin.Web.Controls.Mvc;
- using EMIS.CommonLogic.EvaluationManage;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EvaluationManage;
- using EMIS.Web.Controls;
- using Bowin.Common.Data;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.CommonLogic.EducationManagement;
- using EMIS.ViewModel.EvaluationManage.EvaluationEnter;
- using System.Text;
- using System.Collections;
- using EMIS.Utility;
- using Bowin.Common.JSON;
- using EMIS.Entities;
- using System.Text.RegularExpressions;
- using EMIS.Utility.FormValidate;
- namespace EMIS.Web.Controllers.EvaluationManage.EvaluationEnter
- {
- [Authorization]
- public class EvaluationEnterController : Controller
- {
- public IEvaluationEnterServices EvaluationEnterServices { get; set; }
- public IEvaluationTargetServices EvaluationTargetServices { get; set; }
- public IEvaluationProjectServices EvaluationProjectServices { get; set; }
- public IEvaluationTableServices EvaluationTableServices { get; set; }
- public IEvaluationNormServices EvaluationNormServices { get; set; }
- //public IEvaluationNeedServices EvaluationNeedServices { get; set; }
- public IEvaluationTypeServices EvaluationTypeServices { get; set; }
- public IEvaluationSettingServices EvaluationSettingServices { get; set; }
- Guid? educationMissionID = Guid.Empty;
-
- /// <summary>
- /// 进入评价页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult List()
- {
- return View();
- }
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var curUser = CustomPrincipal.Current;
- var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
- var result = EvaluationEnterServices.GetEvaluationEnterViewGrid(configuretView, schoolyearID, curUser.UserID, curUser.RoleID, curUser.IsStudent, (int)pararms.page, (int)pararms.rows);
- return Json(result);
- }
- /// <summary>
- /// 学生平台进入评价
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult StudentList()
- {
- return View();
- }
- /// <summary>
- /// 查询列表
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult StudentList(QueryParamsModel pararms)
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- return base.Json(EvaluationEnterServices.GetEvaluationEnterViewGrid(configuretView, null, curUser.UserID, curUser.RoleID, curUser.IsStudent, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="evaluationSettingID"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="evaluationEnterID"></param>
- /// <param name="IsEvaluation"></param>
- /// <returns></returns>
- public ActionResult Edit(Guid? evaluationSettingID, Guid? evaluationTableID, Guid? evaluationEnterID, bool IsEvaluation/*是否在可评时间内*/)
- {
- var vm = new EvaluationEnterView();
- try
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- bool isStudent = curUser.IsStudent;//获取当前用户是否是学生
- // Guid? typeID = isStudent == true ? Guid.Parse("AAF0A913-3A57-431A-8D4B-CAF11B130759")/*学生评*/ : Guid.Parse("B6D2461D-6F6E-4F6A-AF4F-2A9F34830F56")/*同行评*/;
- EM_EvaluationTable EvaluationTable = null;
- EvaluationEnterView evaluationEnterEntity = EvaluationEnterServices.GetEvaluationSettingOrEnterView(evaluationSettingID, curUser.UserID, curUser.RoleID, isStudent);//加载进入评价的被评教师、课程名称、教研室、相关信息
- Guid? educationMissionClassID = evaluationEnterEntity.EducationMissionClassID;
- if (evaluationEnterEntity != null)
- {
- educationMissionClassID = evaluationEnterEntity.EducationMissionClassID;
- evaluationTableID = evaluationEnterEntity.EvaluationTableID;
- }
- if (evaluationTableID == null || evaluationTableID == Guid.Empty)
- {
- throw new Exception("评价类型与评价表不匹配,请检查。");
- }
- ViewBag.EducationMissionClassID = educationMissionClassID;
- educationMissionID = educationMissionClassID;
- ViewBag.EvaluationTableID = evaluationTableID;
- EvaluationTable = EvaluationTableServices.GetEvaluationTable(evaluationTableID);
- ViewBag.TableWeight = EvaluationTable.Weight;//评价表权重;
- ViewBag.TableName = EvaluationTable.Name;
- //var evaluationTableLsit = EvaluationEnterServices.GetCreateEvaluationEnterTable(evaluationTableID, configuretView);//评价表ID、获取对应评价表
- //ViewData["evaluationTableLsit"] = evaluationTableLsit;
-
- //根据教学任务班ID、获取相关课程、教师、教研室内容
- ViewBag.UserNames = evaluationEnterEntity.UserNames;//教师名称
- ViewBag.CourseName = evaluationEnterEntity.CourseName;//课程名称
- ViewBag.Remark = evaluationEnterEntity.DepartmentName;//教研室
- ViewBag.LimitMore = evaluationEnterEntity.LimitMore;//限制评价次数
- int modifyTimeCount = 0;//已评次数
- if (evaluationEnterID != Guid.Empty)
- {
- ViewBag.evaluationEnterID = evaluationEnterID;
- EM_EvaluationEnter evaluationEnterOrProjectEntity = EvaluationEnterServices.GetEvaluationEnterView(evaluationEnterID);
- if (evaluationEnterOrProjectEntity != null)
- {
- vm.EvaluationTableID = evaluationEnterOrProjectEntity.EvaluationTableID;
- vm.EducationMissionClassID = evaluationEnterOrProjectEntity.EducationMissionClassID;
- vm.EvaluationEnterID = evaluationEnterOrProjectEntity.EvaluationEnterID;
- vm.Remark = evaluationEnterOrProjectEntity.Remark;
- ViewBag.evaluationEnterID = evaluationEnterOrProjectEntity.EvaluationEnterID;
- modifyTimeCount = EvaluationEnterServices.GetEvaluationEnter_EM_EvaluationProjectList(evaluationEnterOrProjectEntity.EvaluationEnterID).GroupBy(x => x.ModifyTime).Select(x => x).Count();
- }
- // EvaluationTypeView evaluationTypeEntity = EvaluationTypeServices.GetEvaluationTypeView(EvaluationTable.TypeID);
- }
- //判断是否是管理员 如果是管理员、那么禁用保存按钮
- if (!curUser.IsStudent)
- {
- IsEvaluation = EvaluationEnterServices.GteDataRange(curUser.RoleID);
- }
- if (modifyTimeCount >= evaluationEnterEntity.LimitMore)
- {
- IsEvaluation = false;//如果已评次数大于 限评次数、那么隐藏保存按钮
- }
- vm.PhotoUrl = evaluationEnterEntity.PhotoUrl;//教师照片
- EM_EvaluationNeed evaluationNeedEntity = null;
- ViewBag.ContentStr = "评价需知内容";//教师评价需知内容
- //EM_EvaluationNeed evaluationNeedEntity = EvaluationNeedServices.GetEvaluationNeedByRole(isStudent == true ? (int)SYS_RoleType.Student : (int)SYS_RoleType.Teacher);
- //if (evaluationNeedEntity != null)
- //{
- // ViewBag.ContentStr = evaluationNeedEntity.Content;//教师评价需知内容
- //}
- //else
- //{
- // throw new Exception("对应的评价需知信息不能为空。");
- //}
- // ViewBag.RoleType = isStudent == true ? "学生用" : "教师用";
- ViewBag.YP = modifyTimeCount;
- ViewBag.IsEvaluation = IsEvaluation;
- }
- catch (Exception ex)
- {
- return RedirectToAction("MsgShow", "Common", new
- {
- WindowID = Request["WindowID"],
- msg = "请求失败:" + ex.Message,
- url = Url.Action("List").AddMenuParameter()
- });
- }
- return View(vm);
- }
- /// <summary>
- /// 新增或更新
- /// </summary>
- /// <param name="vm"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(EvaluationEnterView vm)
- {
- try
- {
- vm.UserID = CustomPrincipal.Current.UserID;
- EvaluationEnterServices.Save(vm, CustomPrincipal.Current.IsStudent);//保存或更新进入评价数据
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public JsonResult GetTitle()
- {
- ArrayList arUpList = new ArrayList();
- arUpList.Add(new { field = "OrderID", title = "次序", align = "center", width = "150" });
- arUpList.Add(new { field = "ProjectName", title = "评价项目", align = "center", width = "300" });
- arUpList.Add(new { field = "NormNameProjectID", title = "评价项目ID", align = "center", width = "50" });
- arUpList.Add(new { field = "TargetID", title = "评价指标ID", align = "center", width = "50" });
- arUpList.Add(new { field = "TargetWeight", title = "评价指标分数", align = "center", width = "50" });
- arUpList.Add(new { field = "Weight", title = "权重", align = "center", width = "150" });
- arUpList.Add(new { field = "NormNames", title = "评分标准", align = "center", width = "250" });
- return Json(new { UpTitle = JsonHelper.ToJSON(arUpList) }, JsonRequestBehavior.AllowGet);
- }
- /// <summary>
- /// 根据对应的评价表创建表格
- /// </summary>
- /// <param name="tableID"></param>
- /// <returns></returns>
- public JsonResult GetList(string tableID, string evaluationEnterID)
- {
- StringBuilder strRows = new StringBuilder();
- Guid TableID = Guid.Parse(tableID);
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var dataTargetList = EvaluationTargetServices.GetEvaluationTargetViewList(configuretView, TableID, null).Select(x => new
- {
- x.TargetID,
- x.NormID,
- x.Name,
- x.Weight
- }).ToList();
- int i = 1;
- foreach (var dataTarget in dataTargetList)
- {
- var NormNames = string.Join(" ", EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select(s => s.Name + s.Weight));
- var NormNamesWeight = string.Join(",", EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select(s => s.Weight));
- StringBuilder strRow = new StringBuilder();
- strRow.Append("{");
- strRow.Append("\"OrderID\":\"" + dataTarget.Name + "\"");
- strRow.Append(",\"ProjectName\":\"\"");
- strRow.Append(",\"NormNameProjectID\":\"\"");
- strRow.Append(",\"TargetID\":\"" + dataTarget.TargetID + "\"");
- strRow.Append(",\"TargetWeight\":\"\"");
- strRow.Append(",\"Weight\":\"" + dataTarget.Weight + "\"");
- strRow.Append(",\"NormNames\":\"" + NormNames + "\"");
- strRow.Append("}");
- if (string.IsNullOrEmpty(strRows.ToString()))
- {
- strRows.Append(strRow);
- }
- else
- {
- strRows.Append("," + strRow);
- }
- var dataProjectList = EvaluationProjectServices.GetEvaluationProjectViewList(configuretView, dataTarget.TargetID, TableID, null).Select(x => new
- {
- x.ProjectID,
- x.OrderID,
- x.Name,
- x.Weight,
- x.Code,
- x.TargetID,
- x.TargetWeight
- }).ToList();
- int j = 1;
- foreach (var dataProject in dataProjectList)
- {
- string[] NormNamesArry = NormNamesWeight.Split(',').ToArray();
- string strSplit1 = "", strSplit2 = "";
- //foreach (var NormName in NormNamesArry)
- //{
- // strSplit2 = Regex.Replace(NormName, "[0-9]", "", RegexOptions.IgnoreCase);//级别
- // strSplit1 = Regex.Replace(NormName, "[\u4e00-\u9fa5]", "", RegexOptions.IgnoreCase); //力度
- //}
- //保存以后加载、默认选中
- var NormNames1 = "";
- if (evaluationEnterID != "")
- {
- Guid evaluationEnterIDs = Guid.Parse(evaluationEnterID);
- IList<EvaluationEnterView> tieleList = EvaluationEnterServices.GetEvaluationEnterByNormDetail(evaluationEnterIDs, TableID, dataTarget.NormID.Value).Where(x => x.ProjectID == dataProject.ProjectID).ToList();
- string htmlStr = "";
- string str = "";
- if (tieleList.Count > 0)
- {
- // var evaluationNormList = EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value);
- //兼容默认还原之前选中值
- IList<EvaluationNormDetailView> evaluationNormList = EvaluationNormServices.GetEvaluationNormOrProjectDetailViewList(dataTarget.NormID.Value);
- evaluationNormList = evaluationNormList.Where(x => x.ProjectID == dataProject.ProjectID).ToList();
- foreach (var evaluationNorm in evaluationNormList)
- {
- foreach (var tiele in tieleList)
- {
- if (evaluationNorm.Weight == tiele.EvaluationScore && evaluationNorm.ProjectID == tiele.ProjectID)
- {
- str = evaluationNorm.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + dataProject.TargetID + "' value='" + evaluationNorm.Weight + "' checked='checked' >";
- }
- else
- {
- str = evaluationNorm.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + dataProject.TargetID + "' value='" + evaluationNorm.Weight + "'>";
- }
- }
- htmlStr += " " + str;
- }
- NormNames1 = htmlStr;
- }
- else
- {
- NormNames1 = string.Join(" ", EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + dataProject.TargetID + "' value='" + s.Weight + "'>"));
- }
- }
- else
- {
- NormNames1 = string.Join(" ", EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "_" + dataProject.TargetID + "' value='" + s.Weight + "'>"));
- }
- // string.Join(" ", EvaluationNormServices.GetEvaluationNormDetailViewList(dataTarget.NormID.Value).Select((s, index) => s.Name + "<input type='radio' onclick='getonclick(this)' name='radioButtonName_" + j + "" + i + "' value='" + dataProject.Code + "'>"));
- j++;
- StringBuilder strRow1 = new StringBuilder();
- strRow1.Append("{");
- strRow1.Append("\"OrderID\":\"" + dataProject.OrderID + "\"");
- strRow1.Append(",\"ProjectName\":\"" + dataProject.Name + "\"");
- strRow1.Append(",\"NormNameProjectID\":\"" + dataProject.ProjectID + "\"");
- strRow1.Append(",\"TargetID\":\"" + dataTarget.TargetID + "\"");
- strRow1.Append(",\"TargetWeight\":\"" + dataTarget.Weight + "\"");
- strRow1.Append(",\"Weight\":\"" + dataProject.Weight + "\"");
- strRow1.Append(",\"NormNames\":\"" + NormNames1 + "\"");
- strRow1.Append("}");
- if (string.IsNullOrEmpty(strRows.ToString()))
- {
- strRows.Append(strRow1);
- }
- else
- {
- strRows.Append("," + strRow1);
- }
- }
- i++;
- }
- return Json(new { rows = strRows.ToString(), total = 0 }, JsonRequestBehavior.AllowGet);
- //var tableStrList = strRows.ToString().JsonToObject<List<CreateTable>>();//将json转实体集合
- //return tableStrList;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="targetIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetWeightSum(string targetIDs)
- {
- List<Guid> list = new List<Guid>();
- for (int i = 0; i < targetIDs.Split(',').Length; i++)
- {
- string id = targetIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid targetID = new Guid(id);
- list.Add(targetID);
- }
- }
- decimal? WeightSum = EvaluationTargetServices.GetEvaluationTargetList(list).Select(x => x.Weight).Sum();
- return base.Json(WeightSum.ToString());
- }
- [HttpPost]
- public ActionResult GetProjectWeightSum(string targetID)
- {
- Guid TargetID = Guid.Parse(targetID);
- List<Guid> list = new List<Guid>();
- list.Add(TargetID);
- decimal? WeightSum = EvaluationTargetServices.GetEvaluationProjectList(TargetID).Select(x => x.Weight).Sum();
- return base.Json(WeightSum.ToString());
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- try
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
- var dt = EvaluationEnterServices.GetEvaluationEnterViewList(configuretView, schoolyearID, CustomPrincipal.Current.UserID, CustomPrincipal.Current.RoleID, CustomPrincipal.Current.IsStudent).Select(x => new
- {
- x.EvaluationSettingCode,
- x.CourseName,
- x.EvaluationTableTypeName,
- x.UserCodes,
- x.UserNames,
- x.EvaluationTypeName,
- x.EvaluationCount
- }).ToTable();
- string[] liststring = { "评价编号", "课程名称", "评价类型 ", "被评教师号", "被评教师", "参评类型 ", "已评次数" };
- neh.Export(dt, liststring, "进入评价信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/EvaluationEnter/List").AddMenuParameter()
- });
- }
- catch (Exception ex)
- {
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出失败,原因:" + ex.Message + "!",
- url = Url.Content("~/EvaluationEnter/List").AddMenuParameter()
- });
- }
- }
- }
- }
|