Quellcode durchsuchen

教室课表连打

lxl vor 2 Jahren
Ursprung
Commit
8c3e0353bb

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

@@ -302,6 +302,7 @@
     <Compile Include="PaymentManage\WorktimeRateView.cs" />
     <Compile Include="PaymentManage\WorktimeSchedulingView.cs" />
     <Compile Include="Report\ClassmajorPrintingSchedulingReportView.cs" />
+    <Compile Include="Report\ClassroomSchedulingReportView.cs" />
     <Compile Include="Report\HighBaseAgeCountView.cs" />
     <Compile Include="Report\HighBaseFacultymajorStudentCountView.cs" />
     <Compile Include="Report\HighBaseRecruitTerriorialReportView.cs" />

+ 40 - 0
EMIS.ViewModel/Report/ClassroomSchedulingReportView.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace EMIS.ViewModel.Report
+{
+    public class ClassroomSchedulingReportView
+    {
+		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? 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? BuildingsInfoID { get; set; }
+		public string BuildingsName { get; set; }
+		public string CourseCode { get; set; }
+		public string CourseName { get; set; }
+		public int? StartWeeklyNum { get; set; }
+		public int? EndWeeklyNum { get; set; }
+		public Guid? ClassroomID { 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; }
+	}
+}

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

@@ -295,6 +295,13 @@ namespace EMIS.Web.Controllers.EducationSchedule
 
             return File(pdf.ToArray(), "application/pdf");
         }
+        public ActionResult ClassroomPrintReportPDF(Guid SchoolyearID, Guid? BuildingsInfoID)
+        {
+
+            var pdf = NewReportServices.ClassroomPrintingReportPDF(SchoolyearID, BuildingsInfoID);
+
+            return File(pdf.ToArray(), "application/pdf");
+        }
 
         public ActionResult DepartmentSchedulingPDF(Guid SchoolyearID, Guid CollegeID, Guid DepartmentID, Guid? HandleModeID)
         {

+ 22 - 5
EMIS.Web/Scripts/Business/SchedulingManage/ScheduleReport/ClassroomPrintingReport.js

@@ -11,11 +11,28 @@ function QueryBuildingsDropdownList(data) {
         }
     }
 }
-
-function reload() {
+function Report_Search() {
     var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
     var buildingID = $("#BuildingsDropdown").combogridX("getValue");
-    if (buildingID != nonSelect) {
-        $("#reportContent").attr("src", CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fClassroomSchedulingPrintView&BuildingsInfoID_RAP=" + buildingID + "&SchoolyearID_RAP=" + schoolYearID);
+    if (buildingID == -1 || buildingID == "") {
+        $.messager.alert("系统信息", "请选择所在建筑物");
+        //$("#ClassroomDropdown").combogridX("reload", eval("({'QueryParamsDatas':'BuildingsDropdown|*|" + $("#BuildingsDropdown").combogridX("getValue") + "|@|'})"));
+    }
+    else {
+        if (CMS_SystemConfig.ReportType == 1) {
+            $("#reportContent").attr("src", CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fClassroomSchedulingPrintView&BuildingsInfoID_RAP=" + buildingID + "&SchoolyearID_RAP=" + schoolYearID);
+        }
+        if (CMS_SystemConfig.ReportType == 2) {
+            var fileUrl = CMS_SystemConfig.VirtualDirectoryPath + "/EducationSchedulingReport/ClassroomPrintReportPDF?BuildingsInfoID=" + buildingID + "&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 buildingID = $("#BuildingsDropdown").combogridX("getValue");
+//    if (buildingID != nonSelect) {
+//        $("#reportContent").attr("src", CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fClassroomSchedulingPrintView&BuildingsInfoID_RAP=" + buildingID + "&SchoolyearID_RAP=" + schoolYearID);
+//    }
+//}

+ 7 - 4
EMIS.Web/Views/EducationSchedulingReport/ClassroomPrintingReport.cshtml

@@ -21,7 +21,7 @@
             <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;">所在建筑物:</li>
                 <li class="sv">
@@ -31,11 +31,10 @@
                         ValueField = "BuildingsInfoID",
                         ID = "BuildingsDropdown",
                         Name = "BuildingsDropdown",
-                        OnSelect = "reload",
                         GridOptions = new DataGridOptions
                         {
-                            Columns = new List<DataGridColumn>() 
-                            { 
+                            Columns = new List<DataGridColumn>()
+                            {
                                 new LinkButtonColumn { FieldName="Code", HeaderText="建筑物代码", Width=0.1, Align=AlignStyle.Center },
                                 new BoundFieldColumn { FieldName="Name", HeaderText="建筑物名称", Width=0.3, Align=AlignStyle.Center }
                             },
@@ -48,6 +47,10 @@
                         }
                     })
                 </li>
+                <li class="sv">
+                    <a class="easyui-linkbutton  l-btn" onclick="Report_Search()" href="#;"
+                       data-options="iconCls:'icon-search'">查询</a>
+                </li>
             </ul>
         </div>
     </div>

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

@@ -1136,6 +1136,191 @@ namespace EMIS.CommonLogic.Report
             return ms;
         }
 
+        public MemoryStream ClassroomPrintingReportPDF(Guid SchoolyearID, Guid? BuildingsInfoID)
+        {
+
+            try
+            {
+                ReportHelper rh = new ReportHelper();
+                MemoryStream ms = new MemoryStream();
+
+                string sql1 = rh.GetReportSql("EducationScheduling/University.sql");
+                string sql2 = rh.GetReportSql("EducationScheduling/ClassroomSchedulingView.sql");
+                var wk = rh.GetReportTemple("EducationScheduling/ClassroomSchedulingView.xlsx");
+                var templateSheetCount = wk.Worksheets.Count;
+
+                List<SqlParameter> roomParams = new List<SqlParameter>();
+
+                roomParams.Add(new SqlParameter("@SchoolyearID", SchoolyearID));
+                if (BuildingsInfoID.HasValue)
+                {
+                    roomParams.Add(new SqlParameter("@BuildingsInfoID", BuildingsInfoID));
+                }
+                else
+                {
+                    roomParams.Add(new SqlParameter("@BuildingsInfoID", DBNull.Value));
+                }
+                roomParams.Add(new SqlParameter("@ClassroomID", DBNull.Value));
+                var roomds = this.UnitOfWork.QuerySQL(sql2, roomParams);
+
+                var csReportViewList = DateTableHelper.DataTableToList<ClassroomSchedulingReportView>(roomds.Tables[0]);
+                List<Guid?> roomIDList = csReportViewList.Select(x => x.ClassroomID).Distinct().ToList();
+                for (int i = templateSheetCount; i < roomIDList.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 < roomIDList.Count(); m++)
+                {
+                    var roomID = roomIDList[m];
+                    List<SqlParameter> sParams = new List<SqlParameter>();
+
+                    sParams.Add(new SqlParameter("@SchoolyearID", SchoolyearID));
+                    if (BuildingsInfoID.HasValue)
+                    {
+                        sParams.Add(new SqlParameter("@BuildingsInfoID", BuildingsInfoID));
+                    }
+                    else
+                    {
+                        sParams.Add(new SqlParameter("@BuildingsInfoID", DBNull.Value));
+                    }
+                    sParams.Add(new SqlParameter("@ClassroomID", roomID));
+                    //if (ClassroomID.HasValue)
+                    //{
+                    //    sParams.Add(new SqlParameter("@ClassroomID", ClassroomID));
+                    //}
+                    //else
+                    //{
+                    //    sParams.Add(new SqlParameter("@ClassroomID", DBNull.Value));
+                    //}
+
+                    var ds = this.UnitOfWork.QuerySQL(sql1 + "\r\n" + sql2, sParams);
+
+                    var ws = wk.Worksheets[m];
+
+                    string title = "{0}{1}学期课程表-{2}", code = "", classroomName = "";
+
+                    if (ds.Tables[1].Rows.Count > 0)
+                    {
+                        code = ds.Tables[1].Rows[0]["Code"].ToString();
+                        classroomName = ds.Tables[1].Rows[0]["ClassroomName"].ToString();
+                    }
+
+                    ws.Cells[0, 0].Value = string.Format(title, ds.Tables[0].Rows[0]["Name"], code, classroomName);
+
+                    //聚合唯一
+                    //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++)
+                        {
+                            //Name
+                            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]["Name"] != 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();
+
+                                //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 DepartmentSchedulingPDF(Guid SchoolyearID, Guid CollegeID, Guid DepartmentID, Guid? HandleModeID)
         {
 

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

@@ -64,6 +64,13 @@ namespace EMIS.CommonLogic.Report
         /// <param name="ClassroomID"></param>
         /// <returns></returns>
         MemoryStream ClassroomReportPDF(Guid SchoolyearID, Guid? BuildingsInfoID, Guid? ClassroomID);
+        /// <summary>
+        /// 教室课表连打PDF
+        /// </summary>
+        /// <param name="SchoolyearID"></param>
+        /// <param name="BuildingsInfoID"></param>
+        /// <returns></returns>
+        MemoryStream ClassroomPrintingReportPDF(Guid SchoolyearID, Guid? BuildingsInfoID);
 
         /// <summary>
         /// 教研室课表PDF