StaffController.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Web;
  7. using System.Web.Mvc;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.Exceptions;
  10. using Bowin.Common.Utility;
  11. using Bowin.Web.Controls.Mvc;
  12. using EMIS.Utility;
  13. using EMIS.Web.Controls;
  14. using EMIS.ViewModel;
  15. using EMIS.ViewModel.UniversityManage.TeacherManage;
  16. using EMIS.CommonLogic.UniversityManage.TeacherManage;
  17. namespace EMIS.Web.Controllers.UniversityManage.TeacherManage
  18. {
  19. [Authorization]
  20. public class StaffController : Controller
  21. {
  22. public Lazy<IStaffServices> staffServices { get; set; }
  23. /// <summary>
  24. /// 教师信息页面
  25. /// </summary>
  26. /// <returns></returns>
  27. public ActionResult List()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 教师信息页面列表查询
  33. /// </summary>
  34. /// <param name="pararms"></param>
  35. /// <returns></returns>
  36. [HttpPost]
  37. public ActionResult List(QueryParamsModel pararms)
  38. {
  39. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  40. var campusID = pararms.getExtraGuid("CampusDropdown");
  41. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  42. var departmentID = pararms.getExtraGuid("DepartmentDropdown");
  43. var isPhotoUrl = pararms.getExtraInt("IsPhotoUrlDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsPhotoUrlDropdown");
  44. var teacherTypeID = pararms.getExtraInt("DictionaryTeacherType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeacherType");
  45. var incumbencyState = pararms.getExtraInt("DictionaryIncumbencyState") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIncumbencyState");
  46. var titleID = pararms.getExtraInt("DictionaryTitle") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTitle");
  47. var isDualTeacher = pararms.getExtraInt("IsDualTeacherDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDualTeacherDropdown");
  48. return base.Json(staffServices.Value.GetStaffViewGrid(configuretView, campusID, collegeID, departmentID, isPhotoUrl, teacherTypeID,
  49. incumbencyState, titleID, isDualTeacher, (int)pararms.page, (int)pararms.rows));
  50. }
  51. /// <summary>
  52. /// 教师信息页面列表查询(无数据范围)
  53. /// </summary>
  54. /// <param name="pararms"></param>
  55. /// <returns></returns>
  56. [HttpPost]
  57. public ActionResult ListWithNoDataRange(QueryParamsModel pararms)
  58. {
  59. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  60. var campusID = pararms.getExtraGuid("CampusDropdown");
  61. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  62. var departmentID = pararms.getExtraGuid("DepartmentDropdown");
  63. var isPhotoUrl = pararms.getExtraInt("IsPhotoUrlDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsPhotoUrlDropdown");
  64. var teacherTypeID = pararms.getExtraInt("DictionaryTeacherType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeacherType");
  65. var incumbencyState = pararms.getExtraInt("DictionaryIncumbencyState") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIncumbencyState");
  66. var titleID = pararms.getExtraInt("DictionaryTitle") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTitle");
  67. var isDualTeacher = pararms.getExtraInt("IsDualTeacherDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDualTeacherDropdown");
  68. return base.Json(staffServices.Value.GetStaffViewGridWithNoDataRange(configuretView, campusID, collegeID, departmentID, isPhotoUrl,
  69. teacherTypeID, incumbencyState, titleID, isDualTeacher, (int)pararms.page, (int)pararms.rows));
  70. }
  71. /// <summary>
  72. /// 教师信息列表
  73. /// </summary>
  74. /// <param name="pararms"></param>
  75. /// <returns></returns>
  76. [HttpPost]
  77. public ActionResult ListForTeacherEdit(QueryParamsModel pararms)
  78. {
  79. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  80. var campusID = pararms.getExtraGuid("CampusDropdown");
  81. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  82. var loginID = pararms.getExtraString("LoginID");
  83. var name = pararms.getExtraString("Name");
  84. return base.Json(staffServices.Value.GetStaffViewGrid(configuretView, campusID, collegeID, loginID, name, (int)pararms.page, (int)pararms.rows));
  85. }
  86. /// <summary>
  87. /// 教师信息查询
  88. /// </summary>
  89. /// <param name="bindType"></param>
  90. /// <param name="userID"></param>
  91. /// <returns></returns>
  92. [HttpPost]
  93. public ActionResult GetStaffDataBind(DropdownListBindType? bindType, Guid? userID)
  94. {
  95. List<DropdownListItem> list = new List<DropdownListItem>();
  96. list = staffServices.Value.GetListStaffView(userID).Select(x => new DropdownListItem
  97. {
  98. Text = x.Name,
  99. Value = x.UserID.ToString()
  100. }).ToList();
  101. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  102. DropdownList.FormatDropdownItemList(dbt, list);
  103. return base.Json(list);
  104. }
  105. /// <summary>
  106. /// 教师信息查询
  107. /// </summary>
  108. /// <param name="pararms"></param>
  109. /// <returns></returns>
  110. [HttpPost]
  111. public ActionResult GetAllStaffDataBind(QueryParamsModel pararms)
  112. {
  113. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  114. return base.Json(staffServices.Value.GetAllStaffView(configuretView, (int)pararms.page, (int)pararms.rows));
  115. }
  116. /// <summary>
  117. /// 教师信息查询
  118. /// </summary>
  119. /// <param name="bindType"></param>
  120. /// <param name="departmentID"></param>
  121. /// <returns></returns>
  122. [HttpPost]
  123. public ActionResult GetDepartmentStaffDataBind(DropdownListBindType? bindType, Guid? departmentID)
  124. {
  125. List<DropdownListItem> list = new List<DropdownListItem>();
  126. list = staffServices.Value.GetStaffViewList(new ConfiguretView(), null, null, departmentID, null, null, null, null, null)
  127. .Select(x => new DropdownListItem
  128. {
  129. Text = x.Name,
  130. Value = x.UserID.ToString()
  131. }).ToList();
  132. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  133. DropdownList.FormatDropdownItemList(dbt, list);
  134. return base.Json(list);
  135. }
  136. /// <summary>
  137. /// 复制新增
  138. /// </summary>
  139. /// <param name="userID"></param>
  140. /// <returns></returns>
  141. public ActionResult CopyAdd(Guid userID)
  142. {
  143. StaffView staffView = new StaffView();
  144. staffView = staffServices.Value.GetStaffView(userID);
  145. return View("Edit", staffView);
  146. }
  147. /// <summary>
  148. /// 复制新增
  149. /// </summary>
  150. /// <param name="staffView"></param>
  151. /// <returns></returns>
  152. [HttpPost]
  153. public ActionResult CopyAdd(StaffView staffView)
  154. {
  155. staffView.UserID = Guid.Empty;
  156. return this.Edit(staffView);
  157. }
  158. /// <summary>
  159. /// 编辑、复制新增(新增、修改,业务主键:教职工号或证件号码)
  160. /// </summary>
  161. /// <param name="newUserID"></param>
  162. /// <param name="type"></param>
  163. /// <returns></returns>
  164. [HttpGet]
  165. public ActionResult Edit(Guid? newUserID, string type)
  166. {
  167. StaffView staffView = new StaffView();
  168. if (newUserID.HasValue && newUserID != Guid.Empty)
  169. {
  170. staffView = staffServices.Value.GetStaffView(newUserID);
  171. if (type == "copyAdd")
  172. {
  173. staffView.UserID = Guid.Empty;
  174. staffView.StaffCode = null;
  175. staffView.Name = null;
  176. staffView.CertificatesType = (int)CF_CertificatesType.IdCrad;
  177. staffView.CertificatesNum = null;
  178. staffView.CollegeID = null;
  179. staffView.DepartmentID = null;
  180. staffView.PhotoUrl = null;
  181. }
  182. }
  183. else
  184. {
  185. staffView.NationID = (int)CF_Nation.Han;
  186. staffView.PoliticsID = (int)CF_Politics.YouthLeague;
  187. staffView.CertificatesType = (int)CF_CertificatesType.IdCrad;
  188. staffView.TeacherTypeID = (int)CF_TeacherType.Internal;
  189. staffView.IncumbencyState = (int)CF_IncumbencyState.Incumbency;
  190. staffView.HealthStateID = (int)CF_HealthState.Healthy;
  191. }
  192. return View(staffView);
  193. }
  194. /// <summary>
  195. /// 编辑、复制新增(新增、修改,业务主键:教职工号或证件号码)
  196. /// </summary>
  197. /// <param name="staffView"></param>
  198. /// <returns></returns>
  199. [HttpPost]
  200. public ActionResult Edit(StaffView staffView)
  201. {
  202. try
  203. {
  204. var accepts = new List<string> { ".jpg", ".jpeg", ".png", ".bmp" };
  205. var postedFile = Request.Files["PhotoUrl"];
  206. if (postedFile != null && !string.IsNullOrEmpty(postedFile.FileName) && !accepts.Contains(Path.GetExtension(postedFile.FileName).ToLower()))
  207. {
  208. throw new Exception("只允许上传.jpg、.jpeg、.png、.bmp格式的文件。");
  209. }
  210. string photoUrl = FileUploadHelper.UploadFile(postedFile);
  211. staffServices.Value.StaffEdit(staffView, photoUrl);
  212. return RedirectToAction("MsgShow", "Common", new
  213. {
  214. WindowID = Request["WindowID"],
  215. msg = "保存成功。",
  216. url = Url.Action("List").AddMenuParameter()
  217. });
  218. }
  219. catch (Exception ex)
  220. {
  221. return RedirectToAction("MsgShowAndOpen", "Common", new
  222. {
  223. WindowID = Request["WindowID"],
  224. msg = "保存失败,原因:" + ex.Message
  225. });
  226. }
  227. }
  228. /// <summary>
  229. /// 删除
  230. /// </summary>
  231. /// <param name="userIDs"></param>
  232. /// <returns></returns>
  233. [HttpPost]
  234. public ActionResult Delete(string userIDs)
  235. {
  236. try
  237. {
  238. List<Guid?> list = userIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  239. staffServices.Value.StaffDelete(list);
  240. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  241. }
  242. catch (Exception ex)
  243. {
  244. string mge = ex.Message;
  245. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  246. if (num != null)
  247. {
  248. if (num.Number == 547)
  249. {
  250. mge = "请先删除与其关联的数据,如:期末设定、补考设定、教学任务、教师课表等。";
  251. }
  252. }
  253. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
  254. }
  255. }
  256. /// <summary>
  257. /// 验证
  258. /// </summary>
  259. /// <param name="collegeID"></param>
  260. /// <param name="departmentID"></param>
  261. /// <returns></returns>
  262. [HttpPost]
  263. public ActionResult Verification(Guid? collegeID, Guid? departmentID)
  264. {
  265. return Json(staffServices.Value.GetVerification(collegeID, departmentID));
  266. }
  267. /// <summary>
  268. /// 删除照片(单个删除)
  269. /// </summary>
  270. /// <param name="userID"></param>
  271. /// <returns></returns>
  272. [HttpPost]
  273. public ActionResult DeletePhoto(Guid? userID)
  274. {
  275. try
  276. {
  277. this.staffServices.Value.DeletePhoto(userID);
  278. return Json(new ReturnMessage()
  279. {
  280. IsSuccess = true,
  281. Message = "删除照片成功。"
  282. });
  283. }
  284. catch (Exception ex)
  285. {
  286. return Json(new ReturnMessage()
  287. {
  288. IsSuccess = false,
  289. Message = "删除照片失败:" + ex.Message
  290. });
  291. }
  292. }
  293. /// <summary>
  294. /// 删除照片(批量删除)
  295. /// </summary>
  296. /// <param name="userIDs"></param>
  297. /// <returns></returns>
  298. [HttpPost]
  299. public ActionResult PicDelete(string userIDs)
  300. {
  301. try
  302. {
  303. List<Guid?> list = userIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  304. staffServices.Value.PicDelete(list);
  305. return Json(new ReturnMessage()
  306. {
  307. IsSuccess = true,
  308. Message = "删除照片成功。"
  309. });
  310. }
  311. catch (Exception ex)
  312. {
  313. return Json(new ReturnMessage()
  314. {
  315. IsSuccess = false,
  316. Message = "删除照片失败:" + ex.Message
  317. });
  318. }
  319. }
  320. /// <summary>
  321. /// 导入照片
  322. /// </summary>
  323. /// <returns></returns>
  324. [HttpGet]
  325. public ActionResult PicImport()
  326. {
  327. return View();
  328. }
  329. /// <summary>
  330. /// 导入照片
  331. /// </summary>
  332. /// <param name="file"></param>
  333. /// <param name="importPicType"></param>
  334. /// <returns></returns>
  335. [HttpPost]
  336. public ActionResult PicImport(HttpPostedFileBase file, string importPicType)
  337. {
  338. try
  339. {
  340. if (file.ContentLength <= 0)
  341. {
  342. throw new Exception("请选择你要上传的照片(注:格式为zip或rar的压缩包文件)。");
  343. }
  344. var acceptFileExtensions = new[] { ".zip", ".rar" };
  345. var p = Path.GetExtension(file.FileName);
  346. if (!acceptFileExtensions.Contains(p))
  347. {
  348. throw new Exception("格式错误,只允许上传zip或rar格式的压缩包文件。");
  349. }
  350. var photoPaths = FileUploadHelper.UploadFileAndExtractFile(file);
  351. if (photoPaths.Count <= 0)
  352. {
  353. throw new Exception("压缩包中没有相关格式的文件。");
  354. }
  355. List<string> listphotoPaths = new List<string>();
  356. var acceptPicExtensions = new[] { ".jpg", ".jpeg", ".png", ".bmp" };
  357. foreach (var path in photoPaths)
  358. {
  359. string pathName = Path.GetExtension(path).ToLower();
  360. if (acceptPicExtensions.Contains(pathName))
  361. {
  362. listphotoPaths.Add(path);
  363. }
  364. //{
  365. // throw new Exception("压缩包中含有不支持的照片格式。");
  366. //}
  367. //if (!acceptPicExtensions.Contains(Path.GetExtension(path)))
  368. //{
  369. // throw new Exception("压缩包中含有不支持的照片格式。");
  370. //}
  371. }
  372. staffServices.Value.StaffPicImport(listphotoPaths, importPicType);
  373. return RedirectToAction("MsgShow", "Common", new
  374. {
  375. WindowID = Request["WindowID"],
  376. msg = "导入照片成功。",
  377. url = Url.Action("List").AddMenuParameter()
  378. });
  379. }
  380. catch (Exception ex)
  381. {
  382. return RedirectToAction("MsgShow", "Common", new
  383. {
  384. WindowID = "none",
  385. msg = "导入照片失败,原因:" + ex.Message,
  386. url = Url.Action("PicImport").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  387. });
  388. }
  389. }
  390. /// <summary>
  391. /// Excel导入
  392. /// </summary>
  393. /// <param name="errorFile"></param>
  394. /// <param name="operationTips"></param>
  395. /// <returns></returns>
  396. [HttpGet]
  397. public ActionResult Import(string errorFile, string operationTips)
  398. {
  399. ViewBag.ErrorFile = errorFile;
  400. if (string.IsNullOrEmpty(operationTips))
  401. {
  402. operationTips = "点击查看失败原因...";
  403. }
  404. ViewBag.operationTips = operationTips;
  405. return View();
  406. }
  407. /// <summary>
  408. /// Excel导入
  409. /// </summary>
  410. /// <param name="file"></param>
  411. /// <returns></returns>
  412. [HttpPost]
  413. public ActionResult Import(HttpPostedFileBase file)
  414. {
  415. try
  416. {
  417. if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
  418. {
  419. throw new Exception("格式错误,只允许导入xls或xlsx格式的Excel文件。");
  420. }
  421. Dictionary<string, string> cellheader = new Dictionary<string, string>
  422. {
  423. { "StaffCode", "教职工号" },
  424. { "Name", "姓名" },
  425. { "UsedName", "曾用名" },
  426. { "SexStr", "性别" },
  427. { "BirthDateStr", "出生日期" },
  428. { "NationStr", "民族" },
  429. { "PoliticsStr", "政治面貌" },
  430. { "CollegeName", RSL.Get("College") },
  431. { "DepartmentName", "所属教研室" },
  432. { "CertificatesTypeStr", "证件类型" },
  433. { "CertificatesNum", "证件号码" },
  434. { "TeacherTypeStr", "教师类型" },
  435. { "IncumbencyStateStr", "在职状态" },
  436. { "SituationStr", "任课状况" },
  437. { "TitleStr", "职称" },
  438. { "LiteracyLevelStr", "文化程度" },
  439. { "LearnPositionStr", "学位" },
  440. { "IsDualTeacherStr", "是否双师型" },
  441. { "PaymentLevelStr", "课酬级别" },
  442. { "Nationality", "国籍" },
  443. { "Place", "籍贯" },
  444. { "WorkDateStr", "参加工作年月" },
  445. { "ComeSchoolDateStr", "来校年月" },
  446. { "Email", "电子邮箱" },
  447. { "ZIPCode", "邮政编码" },
  448. { "WeChatNum", "微信号" },
  449. { "QQ", "QQ" },
  450. { "Telephone", "家庭电话" },
  451. { "OfficeTelephone", "办公电话" },
  452. { "HousePhone", "住宅电话" },
  453. { "Mobile", "移动电话" },
  454. { "HealthStateStr", "健康状况" },
  455. { "ReligionStr", "宗教信仰" },
  456. { "Speciality", "特长" },
  457. { "Account", "银行卡号" },
  458. { "Residence", "户口所在地" },
  459. { "HomeAddress", "家庭住址" },
  460. { "Address", "通信地址" },
  461. { "NowAddress", "现住地址" },
  462. { "Profile", "简介" },
  463. { "Remark", "备注" },
  464. { "ErrorMessage", "未导入原因" }
  465. };
  466. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  467. string sourceWebPath = FileUploadHelper.UploadFile(file);
  468. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  469. List<StaffView> errList = new List<StaffView>();
  470. List<StaffView> dataList = new List<StaffView>();
  471. int? inCount = 0; //导入个数
  472. int? upCount = 0; //更新个数
  473. int? errCount = 0; //失败个数
  474. //导入
  475. staffServices.Value.StaffImport(cellheader, out inCount, out upCount, out errList, out errCount, sourcePhysicalPath);
  476. System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
  477. if (errList.Count() > 0)
  478. {
  479. //获取错误数据文件路径
  480. string errorWebPath = string.Format("{0}", NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "教师信息导入失败文件", sourcePhysicalPath));
  481. ViewBag.ErrorFile = errorWebPath;
  482. string Errinfo = string.Format("提示:{0}条教师信息导入成功,{1}条教师信息更新成功,{2}条教师信息导入失败,点击查看。", inCount, upCount, errCount);
  483. ViewBag.operationTips = Errinfo;
  484. return RedirectToAction("MsgShow", "Common", new
  485. {
  486. WindowID = "none",
  487. msg = Errinfo,
  488. url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips=" + Errinfo + "&WindowID=" + Request["WindowID"]
  489. });
  490. }
  491. else
  492. {
  493. string successInfo = string.Format("提示:{0}条教师信息导入成功,{1}条教师信息更新成功。", inCount, upCount);
  494. return RedirectToAction("MsgShow", "Common", new
  495. {
  496. WindowID = Request["WindowID"],
  497. msg = successInfo,
  498. url = Url.Action("List").AddMenuParameter()
  499. });
  500. }
  501. }
  502. catch (Exception ex)
  503. {
  504. return RedirectToAction("MsgShow", "Common", new
  505. {
  506. WindowID = "none",
  507. msg = "导入失败,原因:" + ex.Message,
  508. url = Url.Action("Import").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  509. });
  510. }
  511. }
  512. /// <summary>
  513. /// 教师对应的角色信息
  514. /// </summary>
  515. /// <returns></returns>
  516. public ActionResult RoleList()
  517. {
  518. return View();
  519. }
  520. /// <summary>
  521. /// 教师对应的角色信息
  522. /// </summary>
  523. /// <param name="pararms"></param>
  524. /// <returns></returns>
  525. [HttpPost]
  526. public ActionResult RoleList(QueryParamsModel pararms)
  527. {
  528. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  529. var userID = Request["userID"].ParseStrTo<Guid>();
  530. var roleID = pararms.getExtraGuid("RoleDropdown");
  531. var dataRange = pararms.getExtraInt("DictionaryDataRange") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryDataRange");
  532. var roleStatus = pararms.getExtraInt("DictionaryRoleStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryRoleStatus");
  533. return base.Json(staffServices.Value.GetRoleListViewGrid(configuretView, userID, roleID, dataRange, roleStatus, (int)pararms.page, (int)pararms.rows));
  534. }
  535. /// <summary>
  536. /// 教师对应的角色信息Excel导出
  537. /// </summary>
  538. /// <returns></returns>
  539. [HttpPost]
  540. public ActionResult RoleListExcel()
  541. {
  542. return null;
  543. }
  544. /// <summary>
  545. /// Excel导出
  546. /// </summary>
  547. /// <returns></returns>
  548. [HttpPost]
  549. public ActionResult Excel()
  550. {
  551. NpoiExcelHelper neh = new NpoiExcelHelper();
  552. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  553. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  554. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  555. var departmentID = Request.Form["DepartmentDropdown"].ParseStrTo<Guid>();
  556. var isPhotoUrl = Request.Form["IsPhotoUrlDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsPhotoUrlDropdown"].ParseStrTo<int>();
  557. var teacherTypeID = Request.Form["DictionaryTeacherType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryTeacherType"].ParseStrTo<int>();
  558. var incumbencyState = Request.Form["DictionaryIncumbencyState"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIncumbencyState"].ParseStrTo<int>();
  559. var titleID = Request.Form["DictionaryTitle"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryTitle"].ParseStrTo<int>();
  560. var isDualTeacher = Request.Form["IsDualTeacherDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsDualTeacherDropdown"].ParseStrTo<int>();
  561. var dt = staffServices.Value.GetStaffViewList(configuretView, campusID, collegeID, departmentID, isPhotoUrl, teacherTypeID, incumbencyState, titleID, isDualTeacher)
  562. .Select(x => new
  563. {
  564. x.StaffCode,
  565. x.Name,
  566. x.UsedName,
  567. x.SexName,
  568. BirthDate = x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyy-MM-dd") : "",
  569. x.NationName,
  570. x.PoliticsName,
  571. x.CampusCode,
  572. x.CampusName,
  573. x.CollegeNo,
  574. x.CollegeName,
  575. x.DepartmentCode,
  576. x.DepartmentName,
  577. x.CertificatesTypeName,
  578. x.CertificatesNum,
  579. x.TeacherTypeName,
  580. x.IncumbencyStateName,
  581. x.SituationName,
  582. x.TitleName,
  583. x.LiteracyLevelName,
  584. x.LearnPositionName,
  585. x.IsDualTeacherName,
  586. x.PaymentLevelName,
  587. x.Nationality,
  588. x.Place,
  589. WorkDate = x.WorkDate.HasValue ? x.WorkDate.Value.ToString("yyyy-MM") : "",
  590. ComeSchoolDate = x.ComeSchoolDate.HasValue ? x.ComeSchoolDate.Value.ToString("yyyy-MM") : "",
  591. x.Email,
  592. x.ZIPCode,
  593. x.WeChatNum,
  594. x.QQ,
  595. x.Telephone,
  596. x.OfficeTelephone,
  597. x.HousePhone,
  598. x.Mobile,
  599. x.HealthStateName,
  600. x.ReligionName,
  601. x.Speciality,
  602. x.Account,
  603. x.Residence,
  604. x.HomeAddress,
  605. x.Address,
  606. x.NowAddress,
  607. x.PhotoUrl,
  608. x.Profile,
  609. x.RoleCount,
  610. x.AccountStatusName,
  611. x.Remark
  612. }).ToTable();
  613. string[] liststring = {
  614. "教职工号", "姓名", "曾用名", "性别", "出生日期", "民族", "政治面貌", RSL.Get("CampusCode"),
  615. RSL.Get("Campus"), RSL.Get("CollegeCode"), RSL.Get("College"), "所属教研室代码", "所属教研室",
  616. "证件类型", "证件号码", "教师类型", "在职状态", "任课状况", "职称", "文化程度", "学位", "是否双师型",
  617. "课酬级别", "国籍", "籍贯", "参加工作年月", "来校年月", "电子邮箱", "邮政编码", "微信号", "QQ",
  618. "家庭电话", "办公电话", "住宅电话", "移动电话", "健康状况", "宗教信仰", "特长", "银行卡号",
  619. "户口所在地", "家庭住址", "通信地址", "现住地址", "照片地址", "简介", "角色数", "帐号状态", "备注"
  620. };
  621. neh.Export(dt, liststring, "教职工信息" + DateTime.Now.ToString("yyyyMMdd"));
  622. return Json(new ReturnMessage()
  623. {
  624. IsSuccess = true,
  625. Message = "导出成功。"
  626. });
  627. }
  628. }
  629. }