Browse Source

教师课表连打

lxl 2 years ago
parent
commit
61607ec73b

+ 1 - 0
EMIS.ViewModel/EMIS.ViewModel.csproj

@@ -308,6 +308,7 @@
     <Compile Include="Report\HighBaseStudentOriginCountView.cs" />
     <Compile Include="Report\StudentCountReportView.cs" />
     <Compile Include="Report\StudentStatisticsDataView.cs" />
+    <Compile Include="Report\TeacherSchedulingView.cs" />
     <Compile Include="RetakeManage\RetakeDivideIntoClassesView.cs" />
     <Compile Include="RetakeManage\RetakeConditionPageView.cs" />
     <Compile Include="RetakeManage\RetakeConditionView.cs" />

+ 43 - 0
EMIS.ViewModel/Report/TeacherSchedulingView.cs

@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace EMIS.ViewModel.Report
+{
+    public class TeacherSchedulingView
+    {
+		public Guid? CoursesTimeID { get; set; }
+		public int? StartTimes { get; set; }
+		public string Times { get; set; }
+		public string TimeDesc { get; set; }
+		public int? Weekday { get; set; }
+		public string WeekdayDesc { get; set; }
+		public Guid? SchoolyearID { get; set; }
+		public string Code { get; set; }
+		public Guid? ClassroomID { get; set; }
+		public Guid? EducationSchedulingClassID { get; set; }
+		public string TaskGroupName { get; set; }
+		public int? StudentCount { get; set; }
+		public Guid? EducationMissionClassID { get; set; }
+		public int? OrderNo { get; set; }
+		public string Name { get; set; }
+		public int? TeachingModeID { get; set; }
+		public Guid? EducationMissionID { get; set; }
+		public Guid? CollegeID { get; set; }
+		public string CollegeName { get; set; }
+		public Guid? DepartmentID { get; set; }
+		public string DepartmentName { get; set; }
+		public string CourseCode { get; set; }
+		public string CourseName { get; set; }
+		public int? StartWeeklyNum { get; set; }
+		public int? EndWeeklyNum { get; set; }
+		public string ClassroomName { get; set; }
+		public Guid? UserID { get; set; }
+		public string StaffName { get; set; }
+		public string TeacherName { get; set; }
+		public string WeekNums { get; set; }
+		public int? MinWeekNum { get; set; }
+		public string StopWeekNumStr { get; set; }
+	}
+}

+ 5 - 0
EMIS.Web/Controllers/EducationSchedule/EducationSchedulingReportController.cs

@@ -282,6 +282,11 @@ namespace EMIS.Web.Controllers.EducationSchedule
             var pdf = NewReportServices.TeacherSchedulingPDF(SchoolyearID, CollegeID, UserID);
             return File(pdf.ToArray(), "application/pdf");
         }
+        public ActionResult TeacherPrintSchedulingPDF(Guid SchoolyearID, Guid? CollegeID)
+        {
+            var pdf = NewReportServices.TeacherPrintingSchedulingPDF(SchoolyearID, CollegeID);
+            return File(pdf.ToArray(), "application/pdf");
+        }
 
         public ActionResult ClassroomReportPDF(Guid SchoolyearID, Guid? BuildingsInfoID, Guid? ClassroomID) 
         {

+ 22 - 4
EMIS.Web/Scripts/Business/SchedulingManage/ScheduleReport/TeacherPrintingReport.js

@@ -12,12 +12,30 @@ function QueryCollegeDropdownList(data) {
             }
         }
 
-        reload();
+        //reload();
     }
 }
 
-function reload() {
+function Report_Search() {
     var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
     var collegeID = $("#CollegeDropdown").combobox("getValue");
-    $("#reportContent").attr("src", CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fTeacherSchedulingPrintView&CollegeID_RAP=" + collegeID + "&SchoolyearID_RAP=" + schoolYearID);
-}
+    collegeID = collegeID == -1 ? "=" : "=" + collegeID;
+
+    if (collegeID == -1 || collegeID == "")
+        $.messager.alert("系统信息", "请选择院系所");
+    else {
+
+        if (CMS_SystemConfig.ReportType == 1) {
+            $("#reportContent").attr("src", CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fTeacherSchedulingPrintView&CollegeID_RAP" + collegeID + "&SchoolyearID_RAP=" + schoolYearID);
+        }
+        if (CMS_SystemConfig.ReportType == 2) {
+            var fileUrl = CMS_SystemConfig.VirtualDirectoryPath + "/EducationSchedulingReport/TeacherPrintSchedulingPDF?CollegeID=" + collegeID + "&SchoolyearID=" + schoolYearID;
+            $("#reportContent").attr("src", CMS_SystemConfig.VirtualDirectoryPath + "/Scripts/pdf.js/web/viewer.html?file=" + encodeURIComponent(fileUrl));
+        }
+    }
+}
+//function reload() {
+//    var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
+//    var collegeID = $("#CollegeDropdown").combobox("getValue");
+//    $("#reportContent").attr("src", CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fTeacherSchedulingPrintView&CollegeID_RAP=" + collegeID + "&SchoolyearID_RAP=" + schoolYearID);
+//}

+ 3 - 2
EMIS.Web/Views/EducationSchedulingReport/TeacherPrintingReport.cshtml

@@ -21,12 +21,13 @@
             <ul>
                 <li class="sn" style="padding-left: 5px;">学年学期:</li>
                 <li class="sv">
-                    @Html.DropdownList(new DropdownListOptions { BindType = DropdownListBindType.None, ItemSourceUrl = Url.Content("~/SchoolYear/DropDown"), SelectedValue = @ViewBag.SchoolYearID, ID = "SchoolYearDropdown", Name = "SchoolYearDropdown", OnSelect = "reload" })
+                    @Html.DropdownList(new DropdownListOptions { BindType = DropdownListBindType.None, ItemSourceUrl = Url.Content("~/SchoolYear/DropDown"), SelectedValue = @ViewBag.SchoolYearID, ID = "SchoolYearDropdown", Name = "SchoolYearDropdown" })
                 </li>
                 <li class="sn" style="padding-left: 5px;">@EMIS.Utility.RSL.Get("College"):</li>
                 <li class="sv">
-                    @Html.DropdownList(new DropdownListOptions { BindType = DropdownListBindType.None, ItemSourceUrl = Url.Content("~/College/CollegeDropdownListBanids"), ID = "CollegeDropdown", Name = "CollegeDropdown", OnSelect = "reload", OnLoadSuccess = "QueryCollegeDropdownList" })
+                    @Html.DropdownList(new DropdownListOptions { BindType = DropdownListBindType.None, ItemSourceUrl = Url.Content("~/College/CollegeDropdownListBanids"), ID = "CollegeDropdown", Name = "CollegeDropdown", OnLoadSuccess = "QueryCollegeDropdownList" })
                 </li>
+                <li class="sv">@Html.Button(new ButtonOptions { OnClick = "Report_Search()", Icon = ButtonIcon.Search, Text = "查询" })</li>
             </ul>
         </div>
     </div>

+ 187 - 0
ServiceLogic/EMIS.CommonLogic/Report/NewReportServices.cs

@@ -449,6 +449,193 @@ namespace EMIS.CommonLogic.Report
 
             return ms;
         }
+        public MemoryStream TeacherPrintingSchedulingPDF(Guid SchoolyearID, Guid? CollegeID)
+        {
+            try
+            {
+                ReportHelper rh = new ReportHelper();
+
+                MemoryStream ms = new MemoryStream();
+
+                string sql1 = rh.GetReportSql("EducationScheduling/University.sql");
+                string sql2 = rh.GetReportSql("EducationScheduling/TeacherSchedulingView.sql");
+                var wk = rh.GetReportTemple("EducationScheduling/TeacherSchedulingView.xlsx");
+
+                var templateSheetCount = wk.Worksheets.Count;
+                List<SqlParameter> teacherParams = new List<SqlParameter>();
+
+                teacherParams.Add(new SqlParameter("@SchoolyearID", SchoolyearID));
+                if (CollegeID.HasValue)
+                {
+                    teacherParams.Add(new SqlParameter("@CollegeID", CollegeID));
+                }
+                else
+                {
+                    teacherParams.Add(new SqlParameter("@CollegeID", DBNull.Value));
+                }
+                teacherParams.Add(new SqlParameter("@UserID", DBNull.Value));
+                var teacherds = this.UnitOfWork.QuerySQL(sql2, teacherParams);
+                var tsReportViewList = DateTableHelper.DataTableToList<TeacherSchedulingView>(teacherds.Tables[0]);
+                List<Guid?> teacherIDList = tsReportViewList.Select(x => x.UserID).Distinct().ToList();
+                for (int i = templateSheetCount; i < teacherIDList.Count; i += templateSheetCount)
+                {
+                    for (int index = 0; index < templateSheetCount; index++)
+                    {
+                        wk.Worksheets.AddCopy(index); //.CopyTo(wk, "Sheet" + (i + 1).ToString(), true, true);
+                    }
+                }
+
+                for (int m = 0; m < teacherIDList.Count(); m++)
+                {
+                    var userID = teacherIDList[m];
+                    List<SqlParameter> sParams = new List<SqlParameter>();
+
+                    sParams.Add(new SqlParameter("@SchoolyearID", SchoolyearID));
+                    if (CollegeID.HasValue)
+                    {
+                        sParams.Add(new SqlParameter("@CollegeID", CollegeID));
+                    }
+                    else
+                    {
+                        sParams.Add(new SqlParameter("@CollegeID", DBNull.Value));
+                    }
+                    sParams.Add(new SqlParameter("@UserID", userID));
+                    //if (UserID.HasValue)
+                    //{
+                    //    sParams.Add(new SqlParameter("@UserID", UserID));
+                    //}
+                    //else
+                    //{
+                    //    sParams.Add(new SqlParameter("@UserID", DBNull.Value));
+                    //}
+
+                    var ds = this.UnitOfWork.QuerySQL(sql1 + "\r\n" + sql2, sParams);
+
+                    var ws = wk.Worksheets[m];
+
+                    string title = "{0}{1}学期课程表-{2}", code = "", staffName = "";
+
+                    if (ds.Tables[1].Rows.Count > 0)
+                    {
+                        code = ds.Tables[1].Rows[0]["Code"].ToString();
+                        staffName = ds.Tables[1].Rows[0]["StaffName"].ToString();
+                    }
+
+                    ws.Cells[0, 0].Value = string.Format(title, ds.Tables[0].Rows[0]["Name"], code, staffName);
+
+                    //聚合唯一
+                    //ds.Tables[1].DefaultView.Sort = "StartTimes asc";
+                    var dtShow = ds.Tables[1].DefaultView.ToTable(true, "StartTimes", "TimeDesc", "Times");
+
+                    dtShow.DefaultView.Sort = "StartTimes asc";
+
+                    dtShow = dtShow.DefaultView.ToTable();
+
+                    int lineEnd = 2;
+
+                    for (int i = 0; i < dtShow.Rows.Count; i++)
+                    {
+                        string col1Format = "{0}\n{1}";
+
+                        ws.Cells[lineEnd, 0].PutValue(string.Format(col1Format, dtShow.Rows[i]["TimeDesc"], dtShow.Rows[i]["Times"] == DBNull.Value ? "" : "<" + dtShow.Rows[i]["Times"].ToString() + ">"));
+
+                        string condition = "StartTimes='{0}'";
+
+                        var weekRows = ds.Tables[1].Select(string.Format(condition, dtShow.Rows[i]["StartTimes"]), "StartTimes asc");
+
+                        int lineMax = 0;
+
+                        for (int j = 0; j < weekRows.Count(); j++)
+                        {
+                            int weekDay = (int)weekRows[j]["Weekday"];
+                            //weekDay += 1;
+                            var curCell = GetLastCell(ws, weekDay, 0, lineEnd, ref lineMax);
+
+                            try
+                            {
+                                StringBuilder sbCell = new StringBuilder();
+
+                                sbCell.AppendLine(weekRows[j]["Name"].ToString());
+
+                                sbCell.Append(weekRows[j]["StudentCount"] == DBNull.Value ? "" : "(" + weekRows[j]["StudentCount"].ToString() + "人)\n");
+
+                                if (weekRows[j]["ClassroomName"] != DBNull.Value)
+                                {
+                                    sbCell.Append(weekRows[j]["ClassroomName"].ToString() + "\n");
+                                }
+
+                                if (weekRows[j]["WeekNums"] != DBNull.Value)
+                                {
+                                    string weekNum = rh.SetNumberMerge(weekRows[j]["WeekNums"].ToString().Split(',').Select(s => int.Parse(s)).ToList());
+
+                                    sbCell.AppendFormat("第{0}周\n", weekNum);
+
+                                }
+
+                                if (weekRows[j]["TeacherName"] != DBNull.Value)
+                                {
+                                    sbCell.AppendFormat("<{0}>\n", weekRows[j]["TeacherName"]);
+                                }
+
+
+
+                                curCell.Value += sbCell.ToString();
+
+                                if (weekRows[j]["StopWeekNumStr"] != DBNull.Value)
+                                {
+                                    string stopStr = rh.SetNumberMerge(weekRows[j]["StopWeekNumStr"].ToString().Split(',').Select(s => int.Parse(s)).ToList());
+                                    curCell.HtmlString += string.Format("<Br><Font Style=\"COLOR: #FF0000;\">({0}停课)</Font>", stopStr);
+                                }
+
+                                //curCell.PutValue(sbCell.ToString());
+                            }
+                            catch
+                            {
+
+                            }
+                        }
+
+                        var mergeRange = ws.Cells.CreateRange(lineEnd, 0, lineMax + 1, 1);
+
+                        mergeRange.Merge();
+
+                        var style1 = rh.BuildBorderStyle(wk);
+                        StyleFlag stFlag1 = new StyleFlag();
+                        stFlag1.Borders = true;
+
+                        mergeRange.ApplyStyle(style1, stFlag1);
+
+                        var weekRange = ws.Cells.CreateRange(lineEnd, 1, lineMax + 1, 7);
+
+                        StyleFlag stFlag2 = new StyleFlag();
+                        stFlag2.LeftBorder = true;
+                        stFlag2.RightBorder = true;
+
+                        weekRange.ApplyStyle(style1, stFlag2);
+
+                        StyleFlag stFlag3 = new StyleFlag();
+                        stFlag3.BottomBorder = true;
+
+                        ws.Cells.CreateRange(lineEnd + lineMax, 1, 1, 7).ApplyStyle(style1, stFlag3);
+
+                        lineEnd = lineEnd + lineMax + 1;
+
+
+                    }
+
+                    ws.AutoFitRows();
+                }
+
+                wk.Save(ms, Aspose.Cells.SaveFormat.Pdf);
+
+                return ms;
+            }
+            catch (Exception ex)
+            {
+
+                throw ex;
+            }
+        }
         public MemoryStream ClassmajorSchedulingPDF(Guid SchoolyearID, Guid? CollegeID, Guid? ClassmajorID, int? Years)
         {
             ReportHelper rh = new ReportHelper();

+ 7 - 0
ServiceLogic/EMIS.ICommonLogic/Report/INewReportServices.cs

@@ -48,6 +48,13 @@ namespace EMIS.CommonLogic.Report
         /// <param name="UserID"></param>
         /// <returns></returns>
         MemoryStream TeacherSchedulingPDF(Guid SchoolyearID, Guid? CollegeID, Guid? UserID);
+        /// <summary>
+        /// 教师课标连打PDF
+        /// </summary>
+        /// <param name="SchoolyearID"></param>
+        /// <param name="CollegeID"></param>
+        /// <returns></returns>
+        MemoryStream TeacherPrintingSchedulingPDF(Guid SchoolyearID, Guid? CollegeID);
 
         /// <summary>
         /// 教室课表PDF