You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AccommodationController.cs 17 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.LogisticsManagement;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using System.Web.Helpers;
  7. using Newtonsoft.Json;
  8. using Newtonsoft.Json.Linq;
  9. using System;
  10. using System.Linq;
  11. using System.IO;
  12. using NPOI.HSSF.UserModel;
  13. using NPOI.SS.UserModel;
  14. using Learun.Application.Base.SystemModule;
  15. using System.Drawing;
  16. namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers
  17. {
  18. /// <summary>
  19. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  20. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  21. /// 创 建:超级管理员
  22. /// 日 期:2019-04-26 15:02
  23. /// 描 述:学生宿舍管理
  24. /// </summary>
  25. public class AccommodationController : MvcControllerBase
  26. {
  27. private AccommodationIBLL accommodationIBLL = new AccommodationBLL();
  28. private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  29. #region 视图功能
  30. /// <summary>
  31. /// 主页面
  32. /// <summary>
  33. /// <returns></returns>
  34. [HttpGet]
  35. public ActionResult Index()
  36. {
  37. return View();
  38. }
  39. /// <summary>
  40. /// 分配宿舍
  41. /// <summary>
  42. /// <returns></returns>
  43. [HttpGet]
  44. public ActionResult IndexDistribution()
  45. {
  46. return View();
  47. }
  48. /// <summary>
  49. /// 带参数的表单页
  50. /// <summary>
  51. /// <returns></returns>
  52. [HttpGet]
  53. public ActionResult Form(string ParentID = null, string ParentName = null, string keyValue = null)
  54. {
  55. ViewBag.ParentID = ParentID;
  56. ViewBag.ParentName = ParentName;
  57. ViewBag.BuildType = accommodationIBLL.GetBuildType(ParentID);
  58. if (!string.IsNullOrEmpty(keyValue))
  59. {
  60. ViewBag.BuildType = accommodationIBLL.GetParentBuildType(keyValue);
  61. }
  62. return View();
  63. }
  64. /// <summary>
  65. /// 宿舍楼
  66. /// </summary>
  67. /// <returns></returns>
  68. [HttpGet]
  69. public ActionResult Floor()
  70. {
  71. return View();
  72. }
  73. /// <summary>
  74. /// 单元
  75. /// </summary>
  76. /// <returns></returns>
  77. [HttpGet]
  78. public ActionResult Unit(string ID)
  79. {
  80. ViewBag.ParentID = ID;
  81. return View();
  82. }
  83. /// <summary>
  84. /// 楼层
  85. /// </summary>
  86. /// <returns></returns>
  87. [HttpGet]
  88. public ActionResult Corridor(string ID)
  89. {
  90. ViewBag.ParentID = ID;
  91. return View();
  92. }
  93. /// <summary>
  94. /// 房间
  95. /// </summary>
  96. /// <returns></returns>
  97. [HttpGet]
  98. public ActionResult Dormitory(string ID)
  99. {
  100. ViewBag.ParentID = ID;
  101. return View();
  102. }
  103. /// <summary>
  104. /// 床位
  105. /// </summary>
  106. /// <returns></returns>
  107. [HttpGet]
  108. public ActionResult Room(string ID)
  109. {
  110. ViewBag.ParentID = ID;
  111. return View();
  112. }
  113. /// <summary>
  114. /// 批量添加单元、楼层、房间、床位
  115. /// </summary>
  116. /// <param name="ParentID"></param>
  117. /// <returns></returns>
  118. [HttpGet]
  119. public ActionResult DormitoryAdd(string ParentID)
  120. {
  121. return View();
  122. }
  123. /// <summary>
  124. /// 自动分配宿舍
  125. /// </summary>
  126. /// <returns></returns>
  127. [HttpGet]
  128. public ActionResult Allocation()
  129. {
  130. return View();
  131. }
  132. /// <summary>
  133. /// 分配系
  134. /// </summary>
  135. /// <returns></returns>
  136. [HttpGet]
  137. public ActionResult FormDept()
  138. {
  139. return View();
  140. }
  141. /// <summary>
  142. /// 分配专业和班级
  143. /// </summary>
  144. /// <returns></returns>
  145. [HttpGet]
  146. public ActionResult FormClass()
  147. {
  148. return View();
  149. }
  150. /// <summary>
  151. /// 分配宿舍
  152. /// </summary>
  153. /// <returns></returns>
  154. [HttpGet]
  155. public ActionResult FormRoom()
  156. {
  157. return View();
  158. }
  159. /// <summary>
  160. /// 床位管理
  161. /// </summary>
  162. /// <returns></returns>
  163. [HttpGet]
  164. public ActionResult IndexBed()
  165. {
  166. return View();
  167. }
  168. /// <summary>
  169. /// 床位管理
  170. /// </summary>
  171. /// <returns></returns>
  172. [HttpGet]
  173. public ActionResult FormBed()
  174. {
  175. return View();
  176. }
  177. /// <summary>
  178. /// 分类管理
  179. /// </summary>
  180. /// <returns></returns>
  181. [HttpGet]
  182. public ActionResult FormClassify()
  183. {
  184. return View();
  185. }
  186. /// <summary>
  187. /// 分类管理
  188. /// </summary>
  189. /// <returns></returns>
  190. [HttpGet]
  191. public ActionResult IndexClassify()
  192. {
  193. return View();
  194. }
  195. /// <summary>
  196. /// 导入宿舍
  197. /// </summary>
  198. /// <returns></returns>
  199. [HttpGet]
  200. public ActionResult IndexImport()
  201. {
  202. return View();
  203. }
  204. #endregion
  205. #region 获取数据
  206. /// <summary>
  207. /// 获取页面显示列表数据
  208. /// <summary>
  209. /// <param name="queryJson">查询参数</param>
  210. /// <returns></returns>
  211. [HttpGet]
  212. [AjaxOnly]
  213. public ActionResult GetPageList(string pagination, string queryJson)
  214. {
  215. Pagination paginationobj = pagination.ToObject<Pagination>();
  216. var data = accommodationIBLL.GetPageList(paginationobj, queryJson);
  217. var jsonData = new
  218. {
  219. rows = data,
  220. total = paginationobj.total,
  221. page = paginationobj.page,
  222. records = paginationobj.records
  223. };
  224. return Success(jsonData);
  225. }
  226. /// <summary>
  227. /// 获取床位数据
  228. /// <summary>
  229. /// <param name="RoomId">查询参数</param>
  230. /// <returns></returns>
  231. [HttpGet]
  232. [AjaxOnly]
  233. public ActionResult GetBedListByRoomId(string RoomId)
  234. {
  235. var data = accommodationIBLL.GetBedListByRoomId(RoomId).OrderBy(x => Convert.ToInt32(x.DNo));
  236. return Success(data);
  237. }
  238. /// <summary>
  239. /// 获取分类数据
  240. /// <summary>
  241. /// <param name="queryJson"></param>
  242. /// <returns></returns>
  243. [HttpGet]
  244. [AjaxOnly]
  245. public ActionResult GetClassifyList(string pagination, string queryJson)
  246. {
  247. Pagination paginationobj = pagination.ToObject<Pagination>();
  248. var data = accommodationIBLL.GetClassifyList(paginationobj, queryJson).OrderBy(x => x.DNo);
  249. //var jsonData = new
  250. //{
  251. // rows = data,
  252. // total = paginationobj.total,
  253. // page = paginationobj.page,
  254. // records = paginationobj.records
  255. //};
  256. return Success(data);
  257. }
  258. /// <summary>
  259. /// 获取宿舍楼数据
  260. /// </summary>
  261. /// <returns></returns>
  262. [HttpGet]
  263. [AjaxOnly]
  264. public ActionResult GetDormitoryList()
  265. {
  266. var data = accommodationIBLL.GetDormitoryList();
  267. return Success(data);
  268. }
  269. /// <summary>
  270. /// 获取单元数据
  271. /// </summary>
  272. /// <param name="ParentID"></param>
  273. /// <returns></returns>
  274. [HttpGet]
  275. [AjaxOnly]
  276. public ActionResult GetUnitList(string ParentID)
  277. {
  278. var data = accommodationIBLL.GetUnitList(ParentID);
  279. return Success(data);
  280. }
  281. /// <summary>
  282. /// 获取楼层数据
  283. /// </summary>
  284. /// <param name="ParentID"></param>
  285. /// <returns></returns>
  286. [HttpGet]
  287. [AjaxOnly]
  288. public ActionResult GetFloorList(string ParentID)
  289. {
  290. var data = accommodationIBLL.GetFloorList(ParentID);
  291. return Success(data);
  292. }
  293. /// <summary>
  294. /// 获取房间数据
  295. /// </summary>
  296. /// <param name="ParentID"></param>
  297. /// <returns></returns>
  298. [HttpGet]
  299. [AjaxOnly]
  300. public ActionResult GetRoomList(string ParentID)
  301. {
  302. var data = accommodationIBLL.GetRoomList(ParentID);
  303. return Success(data);
  304. }
  305. public ActionResult GetBedList(string ParentID)
  306. {
  307. var data = accommodationIBLL.GetBedList(ParentID);
  308. return Success(data);
  309. }
  310. /// <summary>
  311. /// 获取表单数据
  312. /// <summary>
  313. /// <returns></returns>
  314. [HttpGet]
  315. [AjaxOnly]
  316. public ActionResult GetFormData(string keyValue)
  317. {
  318. var Acc_DormitoryBuildData = accommodationIBLL.GetAcc_DormitoryBuildEntity(keyValue);
  319. var jsonData = new
  320. {
  321. Acc_DormitoryBuild = Acc_DormitoryBuildData,
  322. };
  323. return Success(jsonData);
  324. }
  325. /// <summary>
  326. /// 获取左侧树形数据
  327. /// <summary>
  328. /// <returns></returns>
  329. [HttpGet]
  330. [AjaxOnly]
  331. public ActionResult GetTree()
  332. {
  333. var data = accommodationIBLL.GetTree();
  334. return Success(data);
  335. }
  336. /// <summary>
  337. /// 获取左侧树形数据
  338. /// <summary>
  339. /// <returns></returns>
  340. [HttpGet]
  341. [AjaxOnly]
  342. public ActionResult GetTreeNew()
  343. {
  344. var data = accommodationIBLL.GetTreeNew();
  345. return Success(data);
  346. }
  347. /// <summary>
  348. /// 获取上级树形数据
  349. /// <summary>
  350. /// <returns></returns>
  351. [HttpGet]
  352. [AjaxOnly]
  353. public ActionResult GetClassifyTree()
  354. {
  355. var data = accommodationIBLL.GetClassifyTree();
  356. return Success(data);
  357. }
  358. #endregion
  359. #region 提交数据
  360. /// <summary>
  361. /// 删除实体数据
  362. /// <param name="keyValue">主键</param>
  363. /// <summary>
  364. /// <returns></returns>
  365. [HttpPost]
  366. [AjaxOnly]
  367. public ActionResult DeleteForm(string keyValue)
  368. {
  369. accommodationIBLL.DeleteEntity(keyValue);
  370. return Success("删除成功!");
  371. }
  372. /// <summary>
  373. /// 删除
  374. /// <param name="keyValue">主键</param>
  375. /// <summary>
  376. /// <returns></returns>
  377. [HttpPost]
  378. [AjaxOnly]
  379. public ActionResult DeleteBed(string keyValue, string ParentID)
  380. {
  381. accommodationIBLL.DeleteBed(keyValue, ParentID);
  382. return Success("删除成功!");
  383. }
  384. /// <summary>
  385. /// 保存实体数据(新增、修改)
  386. /// <param name="keyValue">主键</param>
  387. /// <summary>
  388. /// <returns></returns>
  389. [HttpPost]
  390. [ValidateAntiForgeryToken]
  391. [AjaxOnly]
  392. public ActionResult SaveForm(string keyValue, string strEntity)
  393. {
  394. Acc_DormitoryBuildEntity entity = strEntity.ToObject<Acc_DormitoryBuildEntity>();
  395. accommodationIBLL.SaveEntity(keyValue, entity);
  396. return Success("保存成功!");
  397. }
  398. /// <summary>
  399. /// 保存实体数据(新增、修改)
  400. /// <param name="keyValue">主键</param>
  401. /// <summary>
  402. /// <returns></returns>
  403. [HttpPost]
  404. [ValidateAntiForgeryToken]
  405. [AjaxOnly]
  406. public ActionResult SaveBedForm(string keyValue, string ParentID, string strEntity)
  407. {
  408. Acc_DormitoryBuildEntity entity = strEntity.ToObject<Acc_DormitoryBuildEntity>();
  409. if (entity.Name.Contains("床"))
  410. {
  411. entity.DNo = entity.Name.Replace("床", "");
  412. }
  413. accommodationIBLL.SaveBedEntity(keyValue, ParentID, entity);
  414. return Success("保存成功!");
  415. }
  416. /// <summary>
  417. /// 寝室分配系
  418. /// <param name="keyValue">主键</param>
  419. /// <summary>
  420. /// <returns></returns>
  421. [HttpPost]
  422. [ValidateAntiForgeryToken]
  423. [AjaxOnly]
  424. public ActionResult SaveDeptClass(string keyValue, string strEntity, int type)
  425. {
  426. Acc_DormitoryBuildEntity entity = strEntity.ToObject<Acc_DormitoryBuildEntity>();
  427. accommodationIBLL.SaveDeptClass(keyValue, entity, type);
  428. return Success("保存成功!");
  429. }
  430. /// <summary>
  431. /// 寝室分配床位
  432. /// <summary>
  433. /// <returns></returns>
  434. [HttpPost]
  435. [ValidateAntiForgeryToken]
  436. [AjaxOnly]
  437. public ActionResult SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list)
  438. {
  439. //List<Acc_DormitoryBuildEntity> list = strEntity.ToObject<List<Acc_DormitoryBuildEntity>>();
  440. string res = accommodationIBLL.SaveRoom(RoomId, list);
  441. if (!string.IsNullOrEmpty(res))
  442. {
  443. return Fail(res);
  444. }
  445. return Success("保存成功!");
  446. }
  447. /// <summary>
  448. /// 学生宿舍的单元、楼层、房间、床位添加
  449. /// </summary>
  450. /// <param name="keyValue">主键</param>
  451. /// <param name="strEntity">参数 (单元、楼层、房间、床位)数量</param>
  452. /// <returns></returns>
  453. [HttpPost]
  454. [ValidateAntiForgeryToken]
  455. [AjaxOnly]
  456. public ActionResult DormitoryAdd(string keyValue, string strEntity)
  457. {
  458. JObject jsonEntity = JObject.Parse(strEntity);
  459. var elementNum = int.Parse(jsonEntity["ElementNum"].ToString());
  460. var floorNum = int.Parse(jsonEntity["FloorNum"].ToString());
  461. var roomNum = int.Parse(jsonEntity["RoomNum"].ToString());
  462. var bedNum = int.Parse(jsonEntity["BedNum"].ToString());
  463. accommodationIBLL.DormitoryAdd(keyValue, elementNum, floorNum, roomNum, bedNum);
  464. return Success("添加成功");
  465. }
  466. /// <summary>
  467. /// 自动分配学生宿舍
  468. /// </summary>
  469. /// <returns></returns>
  470. public ActionResult Automatic(string strEntity)
  471. {
  472. JObject jsonEntity = JObject.Parse(strEntity);
  473. bool noNation = jsonEntity["noNation"].ToString() == "1" ? true : false;
  474. bool noPlace = jsonEntity["noPlace"].ToString() == "1" ? true : false;
  475. accommodationIBLL.Automatic_allocation_accommodation(noNation, noPlace);
  476. return Success("分配成功");
  477. }
  478. /// <summary>
  479. /// 同步宿舍信息数据
  480. /// </summary>
  481. /// <returns></returns>
  482. public ActionResult SyncData()
  483. {
  484. accommodationIBLL.SyncData();
  485. return Success("同步成功");
  486. }
  487. /// <summary>
  488. /// 宿舍信息导入模板
  489. /// </summary>
  490. /// <returns></returns>
  491. public ActionResult DownTemplate()
  492. {
  493. FileStreamResult result = null;
  494. try
  495. {
  496. var path = Server.MapPath("~/Content/excel/");
  497. var pathoffull = path + "AccommodationImport.xls";
  498. FileStream fsread = fsread = new FileStream(pathoffull, FileMode.OpenOrCreate, FileAccess.ReadWrite);
  499. result = File(fsread, "application/ms-excel", "宿舍信息导入.xls");
  500. return result;
  501. }
  502. catch (Exception ex)
  503. {
  504. return null;
  505. }
  506. }
  507. /// <summary>
  508. /// 宿舍信息excel文件导入
  509. /// </summary>
  510. /// <param name="templateId"></param>
  511. /// <param name="Filedata"></param>
  512. /// <returns></returns>
  513. [HttpPost]
  514. [ValidateAntiForgeryToken]
  515. public ActionResult ExecuteImportExcel(string fileGuid, int chunks)
  516. {
  517. string path = annexesFileIBLL.SaveAnnexes(fileGuid, fileGuid, chunks, LoginUserInfo.Get());
  518. if (!string.IsNullOrEmpty(path))
  519. {
  520. DataTable dt = ExcelHelper.ExcelImport(path);
  521. var res = accommodationIBLL.ExecuteImportExcel(dt, fileGuid);
  522. var data = new
  523. {
  524. Success = res.snum,
  525. Fail = res.failDt.Rows.Count
  526. };
  527. return Success(data);
  528. }
  529. else
  530. {
  531. return Fail("导入数据失败!");
  532. }
  533. }
  534. #endregion
  535. }
  536. }