|
@@ -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)
|
|
|
{
|
|
|
|