SpecialityScoreByFinalScoreServices.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.ScoreManage;
  6. using EMIS.DataLogic.Common.Students;
  7. using EMIS.ViewModel.ScoreManage;
  8. using System.Linq.Expressions;
  9. using EMIS.ViewModel;
  10. using EMIS.Entities;
  11. using Bowin.Common.Linq;
  12. using EMIS.ViewModel.CacheManage;
  13. using Bowin.Common.Utility;
  14. using System.Data;
  15. using NPOI.HSSF.UserModel;
  16. using NPOI.SS.UserModel;
  17. using NPOI.HSSF.Util;
  18. namespace EMIS.CommonLogic.ScoreManage
  19. {
  20. public class SpecialityScoreByFinalScoreServices : BaseServices, ISpecialityScoreByFinalScoreServices
  21. {
  22. public SpecialityScoreSumDAL specialityScoreSumDAL { get; set; }
  23. public StudentsDAL StudentsDAL { get; set; }
  24. public SpecialityScoreGTView SpecialityScoreSumTable(Guid? collegeID, int? years, int? standardID, int? schoolyearNumID, int? schoolcodeID, Guid? classmajorID, List<int> CourseTypeIDList)
  25. {
  26. Expression<Func<CF_Student, bool>> studentExp = (x => true);
  27. Expression<Func<CF_Grademajor, bool>> grademajorExp = (x => true);
  28. Expression<Func<CF_Facultymajor, bool>> facultyExp = (x => true);
  29. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolyearExp = (x => true);
  30. Expression<Func<ER_FinallyScore, bool>> scoreExp = x => true;
  31. Expression<Func<EM_EducationMissionClass, bool>> missionClassExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  32. SpecialityScoreGTView summaryView = new SpecialityScoreGTView();
  33. if (collegeID.HasValue)
  34. {
  35. facultyExp = facultyExp.And(x => x.CollegeID == collegeID);
  36. }
  37. if (years.HasValue)
  38. {
  39. grademajorExp = grademajorExp.And(x => x.GradeID == years);
  40. }
  41. if (standardID.HasValue)
  42. {
  43. facultyExp = facultyExp.And(x => x.StandardID == standardID);
  44. }
  45. if (classmajorID.HasValue)
  46. {
  47. studentExp = studentExp.And(x => x.ClassmajorID == classmajorID);
  48. }
  49. if (schoolyearNumID.HasValue)
  50. {
  51. scoreExp = scoreExp.And(x => x.SchoolyearNumID == schoolyearNumID);
  52. }
  53. if (schoolcodeID.HasValue)
  54. {
  55. schoolyearExp = schoolyearExp.And(x => x.SchoolcodeID == schoolcodeID);
  56. }
  57. if (CourseTypeIDList.Count > 0)
  58. {
  59. scoreExp = scoreExp.And(x => CourseTypeIDList.Contains((int)x.CourseTypeID));
  60. }
  61. var courseQuery = specialityScoreSumDAL.GetCoursematerialViewQueryable(scoreExp, studentExp, grademajorExp, facultyExp, schoolyearExp);
  62. courseQuery = courseQuery.OrderBy(x => x.StartTermID).ThenBy(x => x.CourseName);
  63. //先获取当前院系所、学年、专业、学年数、学期
  64. var queryCoursematerialPlan = courseQuery.ToList();
  65. var queryFinallyScore = specialityScoreSumDAL.GetFinalScoreQueryable(scoreExp, studentExp, grademajorExp, facultyExp, schoolyearExp).ToList();
  66. var queryCredit= specialityScoreSumDAL.GetCreditQueryable(scoreExp, studentExp, grademajorExp, facultyExp, schoolyearExp).ToList();
  67. var studentList = StudentsDAL.GetBaseStudentViewQueryable(studentExp, grademajorExp, facultyExp).ToList();
  68. summaryView.StudentList = studentList.OrderBy(x => x.LoginID).ToList();
  69. summaryView.SchoolyearNums = new List<SpecialityScoreSummaryYearView>();
  70. summaryView.SpecialityCreditView = new List<SpecialityCreditView>();
  71. //开始建立树形结构,顶层是学年数,从大到小排序
  72. List<SpecialityCreditView> specialityCreditView = new List<SpecialityCreditView>();
  73. //specialityCreditView.Tital = "学分统计";
  74. if (queryCredit.Count() > 0)
  75. {
  76. var creditList = (from s in studentList
  77. join credit in queryCredit
  78. on s.UserID equals credit.UserID into scr
  79. from a in scr.DefaultIfEmpty()
  80. orderby s.LoginID
  81. select new SpecialityCreditView
  82. {
  83. UserID = s.UserID,
  84. RequiredCredit = a == null ? 0 : ((a.RequiredCredit ?? 0) - (a.PractiseCredit ?? 0)),
  85. OptionalCourseCredit = a == null ? 0 : (((a.OptionalCourseCredit ?? 0) - (a.SchoolbasedCredit ?? 0) - (a.ElectiveCredit ?? 0) - (a.GeneralEducationCredit ?? 0))),
  86. FreeSelectionCourseCredit = a == null ? 0 : (((a.FreeSelectionCourseCredit ?? 0) - (a.ElectivePublicCredit ?? 0))),
  87. GeneralEducationCredit = a == null ? 0 : (a.GeneralEducationCredit ?? 0),
  88. ElectiveCredit = a == null ? 0 : (a.ElectiveCredit ?? 0),
  89. ElectivePublicCredit = a == null ? 0 : (a.ElectivePublicCredit ?? 0),
  90. SchoolbasedWithClub = a == null ? 0 : (a.SchoolbasedWithClub ?? 0),
  91. SchoolbasedTotalCredit = a == null ? 0 : (a.SchoolbasedNotCredit ?? 0 + a.SchoolbasedCredit ?? 0),
  92. SchoolbasedNotCredit = a == null ? 0 : (a.SchoolbasedNotCredit ?? 0),
  93. SchoolbasedCredit = a == null ? 0 : (a.SchoolbasedCredit ?? 0),
  94. SchoolbasedRealCredit = a == null ? 0 : (a.SchoolbasedRealCredit ?? 0),
  95. PractiseWithClub = a == null ? 0 : (a.PractiseWithClub ?? 0),
  96. PractiseTotalCredit = a == null ? 0 : (a.PractiseNotCredit ?? 0 + a.PractiseCredit ?? 0),
  97. PractiseNotCredit = a == null ? 0 : (a.PractiseNotCredit ?? 0),
  98. PractiseCredit = a == null ? 0 : (a.PractiseCredit ?? 0),
  99. PractiseRealCredit = a == null ? 0 : (a.PractiseRealCredit ?? 0),
  100. ClubWithSchoolbasedCredit = a == null ? 0 : (((a.PractiseWithClub ?? 0) > 4 ? 4 : (a.PractiseWithClub ?? 0)) + ((a.SchoolbasedWithClub ?? 0) > 4 ? 4 : (a.SchoolbasedWithClub ?? 0)) + (a.SchoolbasedNotCredit ?? 0)),
  101. TotalCredit = a == null ? 0 : ((a.RequiredCredit ?? 0) + (a.OptionalCourseCredit ?? 0) + (a.FreeSelectionCourseCredit ?? 0) - (a.PractiseCredit ?? 0) - (a.SchoolbasedCredit ?? 0)
  102. + (a.PractiseNotCredit ?? 0) + ((a.PractiseWithClub ?? 0) > 4 ? 4 : (a.PractiseWithClub ?? 0)) + (a.SchoolbasedNotCredit ?? 0) + ((a.SchoolbasedWithClub ?? 0) > 4 ? 4 : (a.SchoolbasedWithClub ?? 0))),
  103. AvgScore = a == null ? 0 : (Math.Round((decimal)(a.AvgScore ?? 0), 2)),
  104. });
  105. specialityCreditView = creditList.ToList();
  106. }
  107. //foreach()
  108. summaryView.SpecialityCreditView = specialityCreditView;
  109. //var schoolyearNums = queryCoursematerialPlan.Select(x => x.SchoolyearNumID).Distinct().OrderBy(x => x).ToList();
  110. var startTermIDs = queryCoursematerialPlan.Select(x => x.StartTermID).Distinct().OrderBy(x => x).ToList();
  111. foreach (var startTermID in startTermIDs)
  112. {
  113. SpecialityScoreSummaryYearView schoolyearNumView = new SpecialityScoreSummaryYearView();
  114. schoolyearNumView.Title = IdNameExt.GetName(DictionaryItem.CF_Startterm, startTermID);
  115. //schoolyearNumView. = schoolyearNum;
  116. schoolyearNumView.CoursematerialNum = 0;
  117. //第二层,学期,按开课学期排序,不是按学期ID
  118. schoolyearNumView.SchoolCodeView = new List<SpecialityScoreSummarySchoolcodeView>();
  119. var schoolcodeList = queryCoursematerialPlan.Where(x => x.StartTermID == startTermID)
  120. .GroupBy(x => new { x.StartTermID })
  121. .Select(x => x.Key).OrderBy(x => x.StartTermID).ToList();
  122. foreach (var schoolCode in schoolcodeList)
  123. {
  124. SpecialityScoreSummarySchoolcodeView schoolCodeView = new SpecialityScoreSummarySchoolcodeView();
  125. schoolCodeView.Title = IdNameExt.GetName(DictionaryItem.CF_Startterm, schoolCode.StartTermID);
  126. //schoolCodeView.SchoolCodeID = schoolCode.SchoolcodeID;
  127. schoolCodeView.StartTermID = schoolCode.StartTermID;
  128. //第三层,课程,按名称排序
  129. schoolCodeView.CoursematerialList = new List<SpecialityScoreSummaryCoursematerialView>();
  130. schoolCodeView.CourseTypeList = new List<SpecialityCreditCourseTypeView>();
  131. List<SpecialityCreditCourseTypeView> creditCourseTypeViewList = new List<SpecialityCreditCourseTypeView>();
  132. var coursematerialList = queryCoursematerialPlan.Where(x => x.StartTermID == schoolCode.StartTermID)
  133. .GroupBy(x => new { x.CoursematerialID, x.CourseName, x.Credit, x.CourseTypeID })
  134. .Select(x => x.Key).OrderBy(x => x.CourseName).ToList();
  135. foreach (var coursematerial in coursematerialList)
  136. {
  137. SpecialityScoreSummaryCoursematerialView coursematerialView = new SpecialityScoreSummaryCoursematerialView();
  138. coursematerialView.Title = coursematerial.CourseName;
  139. coursematerialView.CoursematerialID = coursematerial.CoursematerialID;
  140. coursematerialView.Credit = coursematerial.Credit;
  141. coursematerialView.Tag = specialityScoreSumDAL.GetIsByCourseTypeID((int)coursematerial.CourseTypeID);
  142. //该课程所有学生均未录入成绩时,不汇总到专业成绩里
  143. var scoreCount = queryFinallyScore.Where(x => x.StarttermID == schoolCode.StartTermID && x.CoursematerialID == coursematerialView.CoursematerialID).ToList().Count();
  144. if (scoreCount == 0)
  145. continue;
  146. //最后一层,成绩,按学生学号排序
  147. var scoreList = (from s in studentList
  148. join fs in queryFinallyScore.Where(x => x.StarttermID == schoolCode.StartTermID && x.CoursematerialID == coursematerialView.CoursematerialID)
  149. on s.UserID equals fs.UserID into dfs
  150. from efs in dfs.DefaultIfEmpty()
  151. orderby s.LoginID
  152. select new SpecialityScoreSummaryScoreView
  153. {
  154. UserID = s.UserID,
  155. Score = (efs == null) ? null : efs.TotalScoreStr,
  156. //Credit = efs.ScoreCredit,
  157. //Score = (efs == null ) ? (int?)null : Convert.ToInt32(Math.Round((Convert.ToDecimal(efs.TotalScore)), 0))
  158. }).ToList();
  159. coursematerialView.ScoreList = scoreList;
  160. schoolCodeView.CoursematerialList.Add(coursematerialView);
  161. schoolyearNumView.CoursematerialNum += 1;
  162. }
  163. //schoolyearNumView.SchoolCodeView.Add(schoolCodeView);
  164. //因为某课程所有学生均未录入成绩时,不汇总到专业成绩里,如果某学期和学年数所有课程没有录入成绩时,不显示一二层学期和学年标题
  165. if (schoolCodeView.CoursematerialList.Count > 0)
  166. schoolyearNumView.SchoolCodeView.Add(schoolCodeView);
  167. }
  168. //summaryView.SchoolyearNums.Add(schoolyearNumView);
  169. //因为某课程所有学生均未录入成绩时,不汇总到专业成绩里,如果某学期和学年数所有课程没有录入成绩时,不显示一二层学期和学年标题
  170. if (schoolyearNumView.SchoolCodeView.Count > 0)
  171. summaryView.SchoolyearNums.Add(schoolyearNumView);
  172. }
  173. return summaryView;
  174. }
  175. public List<int> GetCourseTypeID()
  176. {
  177. return specialityScoreSumDAL.GetCourseTypeQueryble();
  178. }
  179. public void ExportSpecialityScoreSumTable(Guid? collegeID, int? years, int? standardID, int? schoolyearNumID, int? schoolcodeID, Guid? classmajorID, List<int> courseTypeIDList, bool isCredit)
  180. {
  181. string html = "";
  182. NpoiExcelHelper neh = new NpoiExcelHelper();
  183. var specialtyScoreSummaryView = this.SpecialityScoreSumTable(collegeID, years, standardID, schoolyearNumID, schoolcodeID, classmajorID, courseTypeIDList);
  184. Func<IWorkbook, HSSFCellStyle> noPassStyleFunc = (x =>
  185. {
  186. var style = (HSSFCellStyle)x.CreateCellStyle();
  187. style.BorderBottom = BorderStyle.THIN;
  188. style.BorderLeft = BorderStyle.THIN;
  189. style.BorderRight = BorderStyle.THIN;
  190. style.BorderTop = BorderStyle.THIN;
  191. style.Alignment = HorizontalAlignment.CENTER;
  192. style.VerticalAlignment = VerticalAlignment.CENTER;
  193. var font = (HSSFFont)x.CreateFont();
  194. font.FontHeightInPoints = 12;
  195. font.Boldweight = (short)FontBoldWeight.BOLD;
  196. font.Color = HSSFColor.RED.index;
  197. style.SetFont(font);
  198. return style;
  199. });
  200. List<NpoiExcelCellStyle> styleList = new List<NpoiExcelCellStyle>();
  201. var dtResult = new DataTable();
  202. if (specialtyScoreSummaryView != null)
  203. {
  204. var detail = new List<string>();
  205. var firstRow = new List<string>();
  206. var secondRow = new List<string>();
  207. var thirdRow = new List<string>();
  208. var thirdRow1 = new List<string>();
  209. var thirdRow2 = new List<string>();
  210. var forthRow = new List<List<string>>();
  211. var detailRow = new List<string>();
  212. //生成第一、二、三行表头,学年和学期和课程
  213. //第一行开头
  214. firstRow.Add("<tr>");
  215. firstRow.Add("<td rowspan=\"2\" colspan=\"3\" row=\"0\" col=\"0\">学期</td>");
  216. if (isCredit)
  217. {
  218. firstRow.Add("<td rowspan=\"2\" colspan=\"10\" row=\"0\" col=\"3\">学分统计</td>");
  219. }
  220. //第二行开头
  221. secondRow.Add("<tr>");
  222. //第三行开头
  223. thirdRow.Add("<tr>");
  224. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"0\">次序</td>");
  225. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"1\">学号</td>");
  226. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"2\">姓名</td>");
  227. if (isCredit)
  228. {
  229. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"3\">总学分</td>");
  230. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"4\">必修学分</td>");
  231. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"5\">限选学分</td>");
  232. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"6\">通识教育</td>");
  233. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"7\">任选学分</td>");
  234. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"8\">方向选修</td>");
  235. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"9\">公共选修</td>");
  236. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"10\">实践环节</td>");
  237. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"11\">俱乐部(含校本)</td>");
  238. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"12\">平均分</td>");
  239. }
  240. //第四行(第三行附加)
  241. thirdRow1.Add("<tr>");
  242. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"0\"></td>");
  243. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"1\"></td>");
  244. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"2\"></td>");
  245. if (isCredit)
  246. {
  247. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"3\"></td>");
  248. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"4\"></td>");
  249. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"5\"></td>");
  250. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"6\"></td>");
  251. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"7\"></td>");
  252. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"8\"></td>");
  253. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"9\"></td>");
  254. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"10\"></td>");
  255. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"11\"></td>");
  256. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"12\"></td>");
  257. }
  258. //第五行(第三行附加)
  259. thirdRow2.Add("<tr>");
  260. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"0\"></td>");
  261. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"1\"></td>");
  262. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"2\"></td>");
  263. if (isCredit)
  264. {
  265. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"3\"></td>");
  266. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"4\"></td>");
  267. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"5\"></td>");
  268. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"6\"></td>");
  269. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"7\"></td>");
  270. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"8\"></td>");
  271. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"9\"></td>");
  272. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"10\"></td>");
  273. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"11\"></td>");
  274. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"12\"></td>");
  275. }
  276. for (var i = 0; i < specialtyScoreSummaryView.StudentList.Count; i++)
  277. {
  278. var student = specialtyScoreSummaryView.StudentList[i];
  279. var credit = specialtyScoreSummaryView.SpecialityCreditView[i];
  280. var studentColumns = new List<string>();
  281. studentColumns.Add("<tr>");
  282. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"0\">" + (i + 1).ToString() + "</td>");
  283. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"1\">" + student.LoginID + "</td>");
  284. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"2\">" + student.UserName + "</td>");
  285. if (isCredit)
  286. {
  287. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"3\">" + credit.TotalCredit + "</td>");
  288. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"4\">" + credit.RequiredCredit + "</td>");
  289. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"5\">" + credit.OptionalCourseCredit + "</td>");
  290. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"6\">" + credit.GeneralEducationCredit + "</td>");
  291. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"7\">" + credit.FreeSelectionCourseCredit + "</td>");
  292. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"8\">" + credit.ElectiveCredit + "</td>");
  293. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"9\">" + credit.ElectivePublicCredit + "</td>");
  294. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"10\">" + credit.PractiseNotCredit + "</td>");
  295. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"11\">" + credit.ClubWithSchoolbasedCredit + "</td>");
  296. studentColumns.Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (5 + i).ToString() + "\" col=\"12\">" + credit.AvgScore + "</td>");
  297. }
  298. forthRow.Add(studentColumns);
  299. }
  300. //前三行明细
  301. var index = 3;
  302. if (isCredit)
  303. {
  304. index = 13;
  305. }
  306. for (var i = 0; i < specialtyScoreSummaryView.SchoolyearNums.Count; i++)
  307. {
  308. var schoolyearNum = specialtyScoreSummaryView.SchoolyearNums[i];
  309. firstRow.Add("<td rowspan=\"2\" colspan=\"" + schoolyearNum.CoursematerialNum + "\" row=\"0\" col=\"" + index.ToString() + "\">" + schoolyearNum.Title + "</td>");
  310. for (var j = 0; j < schoolyearNum.SchoolCodeView.Count; j++)
  311. {
  312. var schoolcode = schoolyearNum.SchoolCodeView[j];
  313. secondRow.Add("<td rowspan=\"1\" colspan=\"" + schoolcode.CoursematerialList.Count + "\" row=\"1\" col=\"" + index.ToString() + "\">" + schoolcode.Title + "</td>");
  314. for (var k = 0; k < schoolcode.CoursematerialList.Count; k++)
  315. {
  316. var coursematerial = schoolcode.CoursematerialList[k];
  317. thirdRow.Add("<td rowspan=\"0\" colspan=\"0\" row=\"2\" col=\"" + index.ToString() + "\">" + coursematerial.Title + "</td>");
  318. thirdRow1.Add("<td rowspan=\"0\" colspan=\"0\" row=\"3\" col=\"" + index.ToString() + "\">" + coursematerial.Tag + "</td>");
  319. thirdRow2.Add("<td rowspan=\"0\" colspan=\"0\" row=\"4\" col=\"" + index.ToString() + "\">" + coursematerial.Credit + "</td>");
  320. for (var l = 0; l < coursematerial.ScoreList.Count; l++)
  321. {
  322. var score = coursematerial.ScoreList[l];
  323. if (score.Score != "" && score.Score != null)
  324. {
  325. decimal tmpScore;
  326. if (decimal.TryParse(score.Score, out tmpScore))
  327. {
  328. if (tmpScore < 60)
  329. {
  330. styleList.Add(new NpoiExcelCellStyle { ColumnIndex = index, RowIndex = l + 5, StyleFunc = noPassStyleFunc });
  331. }
  332. }
  333. else
  334. {
  335. styleList.Add(new NpoiExcelCellStyle { ColumnIndex = index, RowIndex = l + 5, StyleFunc = noPassStyleFunc });
  336. }
  337. forthRow[l].Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (l + 5).ToString() + "\" col=\"" + index.ToString() + "\">" + score.Score.ToString() + "</td>");
  338. }
  339. else
  340. {
  341. forthRow[l].Add("<td rowspan=\"0\" colspan=\"0\" row=\"" + (l + 5).ToString() + "\" col=\"" + index.ToString() + "\"></td>");
  342. }
  343. }
  344. index++;
  345. }
  346. }
  347. }
  348. //第一行结尾
  349. firstRow.Add("</tr>");
  350. //第二行结尾
  351. secondRow.Add("</tr>");
  352. //第三行结尾
  353. thirdRow.Add("</tr>");
  354. thirdRow1.Add("</tr>");
  355. thirdRow2.Add("</tr>");
  356. html += string.Join("", firstRow);
  357. html += string.Join("", secondRow);
  358. html += string.Join("", thirdRow);
  359. html += string.Join("", thirdRow1);
  360. html += string.Join("", thirdRow2);
  361. for (var i = 0; i < specialtyScoreSummaryView.StudentList.Count; i++)
  362. {
  363. html += string.Join("", forthRow[i]);
  364. html += "</tr>";
  365. }
  366. }
  367. neh.PresetCellStyle(styleList);
  368. neh.ExportTable(html, "专业成绩汇总");
  369. }
  370. }
  371. }