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.
 
 
 
 
 
 

898 lines
24 KiB

  1. using Learun.Util;
  2. using System;
  3. using System.Data;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using Learun.Application.TwoDevelopment.EducationalAdministration;
  7. namespace Learun.Application.TwoDevelopment.LogisticsManagement
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  11. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  12. /// 创 建:超级管理员
  13. /// 日 期:2019-04-26 15:02
  14. /// 描 述:学生宿舍管理
  15. /// </summary>
  16. public class AccommodationBLL : AccommodationIBLL
  17. {
  18. private AccommodationService accommodationService = new AccommodationService();
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<Acc_DormitoryBuildEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. return accommodationService.GetPageList(pagination, queryJson);
  30. }
  31. catch (Exception ex)
  32. {
  33. if (ex is ExceptionEx)
  34. {
  35. throw;
  36. }
  37. else
  38. {
  39. throw ExceptionEx.ThrowBusinessException(ex);
  40. }
  41. }
  42. }
  43. public IEnumerable<Acc_DormitoryBuildEntity> GetDromStu(string keyValue)
  44. {
  45. try
  46. {
  47. return accommodationService.GetDromStu(keyValue);
  48. }
  49. catch (Exception ex)
  50. {
  51. if (ex is ExceptionEx)
  52. {
  53. throw;
  54. }
  55. else
  56. {
  57. throw ExceptionEx.ThrowBusinessException(ex);
  58. }
  59. }
  60. }
  61. public IEnumerable<Acc_DormitoryBuildEntity> GetBedListByRoomId(string RoomId)
  62. {
  63. try
  64. {
  65. return accommodationService.GetBedListByRoomId(RoomId);
  66. }
  67. catch (Exception ex)
  68. {
  69. if (ex is ExceptionEx)
  70. {
  71. throw;
  72. }
  73. else
  74. {
  75. throw ExceptionEx.ThrowBusinessException(ex);
  76. }
  77. }
  78. }
  79. public IEnumerable<Acc_DormitoryBuildEntity> GetAllList()
  80. {
  81. try
  82. {
  83. return accommodationService.GetAllList();
  84. }
  85. catch (Exception ex)
  86. {
  87. if (ex is ExceptionEx)
  88. {
  89. throw;
  90. }
  91. else
  92. {
  93. throw ExceptionEx.ThrowBusinessException(ex);
  94. }
  95. }
  96. }
  97. public IEnumerable<Acc_DormitoryBuildEntity> GetClassifyList(Pagination paginationobj, string queryJson)
  98. {
  99. try
  100. {
  101. return accommodationService.GetClassifyList(paginationobj, queryJson);
  102. }
  103. catch (Exception ex)
  104. {
  105. if (ex is ExceptionEx)
  106. {
  107. throw;
  108. }
  109. else
  110. {
  111. throw ExceptionEx.ThrowBusinessException(ex);
  112. }
  113. }
  114. }
  115. public object GetDormitoryList()
  116. {
  117. try
  118. {
  119. return accommodationService.GetDormitoryList();
  120. }
  121. catch (Exception ex)
  122. {
  123. if (ex is ExceptionEx)
  124. {
  125. throw;
  126. }
  127. else
  128. {
  129. throw ExceptionEx.ThrowBusinessException(ex);
  130. }
  131. }
  132. }
  133. public object GetUnitList(string ParentID)
  134. {
  135. try
  136. {
  137. return accommodationService.GetUnitList(ParentID);
  138. }
  139. catch (Exception ex)
  140. {
  141. if (ex is ExceptionEx)
  142. {
  143. throw;
  144. }
  145. else
  146. {
  147. throw ExceptionEx.ThrowBusinessException(ex);
  148. }
  149. }
  150. }
  151. public object GetFloorList(string parentID)
  152. {
  153. try
  154. {
  155. return accommodationService.GetFloorList(parentID);
  156. }
  157. catch (Exception ex)
  158. {
  159. if (ex is ExceptionEx)
  160. {
  161. throw;
  162. }
  163. else
  164. {
  165. throw ExceptionEx.ThrowBusinessException(ex);
  166. }
  167. }
  168. }
  169. public object GetRoomList(string parentID)
  170. {
  171. try
  172. {
  173. return accommodationService.GetRoomList(parentID);
  174. }
  175. catch (Exception ex)
  176. {
  177. if (ex is ExceptionEx)
  178. {
  179. throw;
  180. }
  181. else
  182. {
  183. throw ExceptionEx.ThrowBusinessException(ex);
  184. }
  185. }
  186. }
  187. public object GetBedList(string parentID)
  188. {
  189. try
  190. {
  191. return accommodationService.GetBedList(parentID);
  192. }
  193. catch (Exception ex)
  194. {
  195. if (ex is ExceptionEx)
  196. {
  197. throw;
  198. }
  199. else
  200. {
  201. throw ExceptionEx.ThrowBusinessException(ex);
  202. }
  203. }
  204. }
  205. public string GetBuildType(string parentID)
  206. {
  207. try
  208. {
  209. return accommodationService.GetBuildType(parentID);
  210. }
  211. catch (Exception ex)
  212. {
  213. if (ex is ExceptionEx)
  214. {
  215. throw;
  216. }
  217. else
  218. {
  219. throw ExceptionEx.ThrowBusinessException(ex);
  220. }
  221. }
  222. }
  223. public string GetParentBuildType(string keyValue)
  224. {
  225. try
  226. {
  227. return accommodationService.GetParentBuildType(keyValue);
  228. }
  229. catch (Exception ex)
  230. {
  231. if (ex is ExceptionEx)
  232. {
  233. throw;
  234. }
  235. else
  236. {
  237. throw ExceptionEx.ThrowBusinessException(ex);
  238. }
  239. }
  240. }
  241. /// <summary>
  242. /// 获取Acc_DormitoryBuild表实体数据
  243. /// <param name="keyValue">主键</param>
  244. /// <summary>
  245. /// <returns></returns>
  246. public Acc_DormitoryBuildEntity GetAcc_DormitoryBuildEntity(string keyValue)
  247. {
  248. try
  249. {
  250. return accommodationService.GetAcc_DormitoryBuildEntity(keyValue);
  251. }
  252. catch (Exception ex)
  253. {
  254. if (ex is ExceptionEx)
  255. {
  256. throw;
  257. }
  258. else
  259. {
  260. throw ExceptionEx.ThrowBusinessException(ex);
  261. }
  262. }
  263. }
  264. /// <summary>
  265. /// 获取Acc_DormitoryBuild表实体数据
  266. /// <param name="keyValue">主键</param>
  267. /// <summary>
  268. /// <returns></returns>
  269. public Acc_DormitoryBuildEntity GetAcc_DormitoryBuildEntityByName(string name)
  270. {
  271. try
  272. {
  273. return accommodationService.GetAcc_DormitoryBuildEntityByName(name);
  274. }
  275. catch (Exception ex)
  276. {
  277. if (ex is ExceptionEx)
  278. {
  279. throw;
  280. }
  281. else
  282. {
  283. throw ExceptionEx.ThrowBusinessException(ex);
  284. }
  285. }
  286. }
  287. /// <summary>
  288. /// 获取Acc_DormitoryBuild表实体数据
  289. /// <param name="keyValue">主键</param>
  290. /// <summary>
  291. /// <returns></returns>
  292. public List<Acc_DormitoryBuildEntity> GetList()
  293. {
  294. try
  295. {
  296. return accommodationService.GetSqlTree();
  297. }
  298. catch (Exception ex)
  299. {
  300. if (ex is ExceptionEx)
  301. {
  302. throw;
  303. }
  304. else
  305. {
  306. throw ExceptionEx.ThrowBusinessException(ex);
  307. }
  308. }
  309. }
  310. public List<Acc_DormitoryBuildEntity> GetDept()
  311. {
  312. try
  313. {
  314. return accommodationService.GetDeptOrMajorOrClass("").Select(x => new Acc_DormitoryBuildEntity { Dept = x.Dept, DeptName = x.DeptName }).Distinct().ToList();
  315. }
  316. catch (Exception ex)
  317. {
  318. if (ex is ExceptionEx)
  319. {
  320. throw;
  321. }
  322. else
  323. {
  324. throw ExceptionEx.ThrowBusinessException(ex);
  325. }
  326. }
  327. }
  328. public List<Acc_DormitoryBuildEntity> GetMajor(string strWhere)
  329. {
  330. try
  331. {
  332. return accommodationService.GetDeptOrMajorOrClass(strWhere).Select(x => new Acc_DormitoryBuildEntity { Major = x.Major, MajorName = x.MajorName }).Distinct().ToList();
  333. }
  334. catch (Exception ex)
  335. {
  336. if (ex is ExceptionEx)
  337. {
  338. throw;
  339. }
  340. else
  341. {
  342. throw ExceptionEx.ThrowBusinessException(ex);
  343. }
  344. }
  345. }
  346. public List<Acc_DormitoryBuildEntity> GetClass(string strWhere)
  347. {
  348. try
  349. {
  350. return accommodationService.GetDeptOrMajorOrClass(strWhere).Select(x => new Acc_DormitoryBuildEntity { Class = x.Class, ClassName = x.ClassName }).Distinct().ToList();
  351. }
  352. catch (Exception ex)
  353. {
  354. if (ex is ExceptionEx)
  355. {
  356. throw;
  357. }
  358. else
  359. {
  360. throw ExceptionEx.ThrowBusinessException(ex);
  361. }
  362. }
  363. }
  364. /// <summary>
  365. /// 获取左侧树形数据
  366. /// <summary>
  367. /// <returns></returns>
  368. public List<TreeModel> GetTree()
  369. {
  370. try
  371. {
  372. List<Acc_DormitoryBuildEntity> list = accommodationService.GetSqlTree();
  373. List<TreeModel> treeList = new List<TreeModel>();
  374. foreach (Acc_DormitoryBuildEntity item in list)
  375. {
  376. TreeModel node = new TreeModel
  377. {
  378. id = item.ID.ToString(),
  379. text = item.Name.ToString(),
  380. value = item.ID.ToString(),
  381. showcheck = false,
  382. checkstate = 0,
  383. isexpand = true,
  384. parentId = item.ParentID == null ? "" : item.ParentID,
  385. title = item.BuildType
  386. };
  387. treeList.Add(node);
  388. }
  389. return treeList.ToTree();
  390. }
  391. catch (Exception ex)
  392. {
  393. if (ex is ExceptionEx)
  394. {
  395. throw;
  396. }
  397. else
  398. {
  399. throw ExceptionEx.ThrowBusinessException(ex);
  400. }
  401. }
  402. }
  403. public List<TreeModel> GetTreeNew()
  404. {
  405. try
  406. {
  407. List<Acc_DormitoryBuildEntity> list = accommodationService.GetSqlTreeNew();
  408. List<TreeModel> treeList = new List<TreeModel>();
  409. foreach (Acc_DormitoryBuildEntity item in list)
  410. {
  411. TreeModel node = new TreeModel
  412. {
  413. id = item.ID.ToString(),
  414. text = item.Name.ToString(),
  415. value = item.ID.ToString(),
  416. showcheck = false,
  417. checkstate = 0,
  418. isexpand = false,
  419. parentId = item.ParentID == null ? "" : item.ParentID
  420. };
  421. treeList.Add(node);
  422. }
  423. return treeList.ToTree();
  424. }
  425. catch (Exception ex)
  426. {
  427. if (ex is ExceptionEx)
  428. {
  429. throw;
  430. }
  431. else
  432. {
  433. throw ExceptionEx.ThrowBusinessException(ex);
  434. }
  435. }
  436. }
  437. public List<TreeModel> GetClassifyTree()
  438. {
  439. try
  440. {
  441. List<Acc_DormitoryBuildEntity> list = accommodationService.GetClassifyTree();
  442. List<TreeModel> treeList = new List<TreeModel>();
  443. foreach (Acc_DormitoryBuildEntity item in list)
  444. {
  445. TreeModel node = new TreeModel
  446. {
  447. id = item.ID.ToString(),
  448. text = item.Name.ToString(),
  449. value = item.ID.ToString(),
  450. showcheck = false,
  451. checkstate = 0,
  452. isexpand = false,
  453. parentId = item.ParentID == null ? "" : item.ParentID,
  454. title = string.IsNullOrEmpty(item.BuildType) ? "" : (Convert.ToInt32(item.BuildType) + 1).ToString(),
  455. };
  456. treeList.Add(node);
  457. }
  458. return treeList.ToTree();
  459. }
  460. catch (Exception ex)
  461. {
  462. if (ex is ExceptionEx)
  463. {
  464. throw;
  465. }
  466. else
  467. {
  468. throw ExceptionEx.ThrowBusinessException(ex);
  469. }
  470. }
  471. }
  472. /// <summary>
  473. /// 根据父id 获取树形数据
  474. /// </summary>
  475. /// <param name="parentID"></param>
  476. /// <returns></returns>
  477. public List<TreeModel> GetTreeByParentID(string parentID)
  478. {
  479. try
  480. {
  481. DataTable list = accommodationService.GetTreeByParentId(parentID);
  482. List<TreeModel> treeList = new List<TreeModel>();
  483. foreach (DataRow item in list.Rows)
  484. {
  485. TreeModel node = new TreeModel
  486. {
  487. id = item["id"].ToString(),
  488. text = item["name"].ToString(),
  489. value = item["id"].ToString(),
  490. showcheck = false,
  491. checkstate = 0,
  492. isexpand = true,
  493. parentId = item["parentid"].ToString()
  494. };
  495. treeList.Add(node);
  496. }
  497. return treeList.ToTree();
  498. }
  499. catch (Exception ex)
  500. {
  501. if (ex is ExceptionEx)
  502. {
  503. throw;
  504. }
  505. else
  506. {
  507. throw ExceptionEx.ThrowBusinessException(ex);
  508. }
  509. }
  510. }
  511. /// <summary>
  512. /// 根据父id 获取树形数据
  513. /// </summary>
  514. /// <param name="parentID"></param>
  515. /// <returns></returns>
  516. public string GetDormitoryInfoByPlanStuNo(string stuNo)
  517. {
  518. try
  519. {
  520. return accommodationService.GetDormitoryInfoByPlanStuNo(stuNo);
  521. }
  522. catch (Exception ex)
  523. {
  524. if (ex is ExceptionEx)
  525. {
  526. throw;
  527. }
  528. else
  529. {
  530. throw ExceptionEx.ThrowBusinessException(ex);
  531. }
  532. }
  533. }
  534. public string GetDormitoryInfoByStuNo(string stuNo)
  535. {
  536. try
  537. {
  538. return accommodationService.GetDormitoryInfoByStuNo(stuNo);
  539. }
  540. catch (Exception ex)
  541. {
  542. if (ex is ExceptionEx)
  543. {
  544. throw;
  545. }
  546. else
  547. {
  548. throw ExceptionEx.ThrowBusinessException(ex);
  549. }
  550. }
  551. }
  552. public bool MatchDormitoryInfo(string stuNo, string dormitory, string unit, string floor, string room, string bed, List<Acc_DormitoryBuildEntity> data)
  553. {
  554. try
  555. {
  556. return accommodationService.MatchDormitoryInfo(stuNo, dormitory, unit, floor, room, bed, data);
  557. }
  558. catch (Exception ex)
  559. {
  560. if (ex is ExceptionEx)
  561. {
  562. throw;
  563. }
  564. else
  565. {
  566. throw ExceptionEx.ThrowBusinessException(ex);
  567. }
  568. }
  569. }
  570. #endregion
  571. #region 提交数据
  572. /// <summary>
  573. /// 删除实体数据
  574. /// <param name="keyValue">主键</param>
  575. /// <summary>
  576. /// <returns></returns>
  577. public void DeleteEntity(string keyValue)
  578. {
  579. try
  580. {
  581. accommodationService.DeleteEntity(keyValue);
  582. }
  583. catch (Exception ex)
  584. {
  585. if (ex is ExceptionEx)
  586. {
  587. throw;
  588. }
  589. else
  590. {
  591. throw ExceptionEx.ThrowBusinessException(ex);
  592. }
  593. }
  594. }
  595. /// <summary>
  596. /// 删除实体数据
  597. /// <param name="keyValue">主键</param>
  598. /// <summary>
  599. /// <returns></returns>
  600. public void DeleteBed(string keyValue, string ParentID)
  601. {
  602. try
  603. {
  604. accommodationService.DeleteBed(keyValue, ParentID);
  605. }
  606. catch (Exception ex)
  607. {
  608. if (ex is ExceptionEx)
  609. {
  610. throw;
  611. }
  612. else
  613. {
  614. throw ExceptionEx.ThrowBusinessException(ex);
  615. }
  616. }
  617. }
  618. /// <summary>
  619. /// 保存实体数据(新增、修改)
  620. /// <param name="keyValue">主键</param>
  621. /// <summary>
  622. /// <returns></returns>
  623. public void SaveEntity(string keyValue, Acc_DormitoryBuildEntity entity)
  624. {
  625. try
  626. {
  627. accommodationService.SaveEntity(keyValue, entity);
  628. }
  629. catch (Exception ex)
  630. {
  631. if (ex is ExceptionEx)
  632. {
  633. throw;
  634. }
  635. else
  636. {
  637. throw ExceptionEx.ThrowBusinessException(ex);
  638. }
  639. }
  640. }
  641. /// <summary>
  642. /// 保存实体数据(新增、修改)
  643. /// <param name="keyValue">主键</param>
  644. /// <summary>
  645. /// <returns></returns>
  646. public void SaveBedEntity(string keyValue, string ParentID, Acc_DormitoryBuildEntity entity)
  647. {
  648. try
  649. {
  650. accommodationService.SaveBedEntity(keyValue, ParentID, entity);
  651. }
  652. catch (Exception ex)
  653. {
  654. if (ex is ExceptionEx)
  655. {
  656. throw;
  657. }
  658. else
  659. {
  660. throw ExceptionEx.ThrowBusinessException(ex);
  661. }
  662. }
  663. }
  664. /// <summary>
  665. /// 分配系
  666. /// </summary>
  667. /// <param name="keyValue"></param>
  668. /// <param name="entity"></param>
  669. public void SaveDeptClass(string keyValue, Acc_DormitoryBuildEntity entity, int type)
  670. {
  671. try
  672. {
  673. accommodationService.SaveDeptClass(keyValue, entity, type);
  674. }
  675. catch (Exception ex)
  676. {
  677. if (ex is ExceptionEx)
  678. {
  679. throw;
  680. }
  681. else
  682. {
  683. throw ExceptionEx.ThrowBusinessException(ex);
  684. }
  685. }
  686. }
  687. public string SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list)
  688. {
  689. try
  690. {
  691. return accommodationService.SaveRoom(RoomId, list);
  692. }
  693. catch (Exception ex)
  694. {
  695. if (ex is ExceptionEx)
  696. {
  697. throw;
  698. }
  699. else
  700. {
  701. throw ExceptionEx.ThrowBusinessException(ex);
  702. }
  703. }
  704. }
  705. /// <summary>
  706. /// 批量添加单元、楼层、宿舍、床位
  707. /// </summary>
  708. /// <param name="keyValue"></param>
  709. /// <param name="elementNum"></param>
  710. /// <param name="floorNum"></param>
  711. /// <param name="roomNum"></param>
  712. /// <param name="bedNum"></param>
  713. public void DormitoryAdd(string keyValue, int elementNum, int floorNum, int roomNum, int bedNum)
  714. {
  715. try
  716. {
  717. accommodationService.DormitoryAdd(keyValue, elementNum, floorNum, roomNum, bedNum);
  718. }
  719. catch (Exception ex)
  720. {
  721. if (ex is ExceptionEx)
  722. {
  723. throw;
  724. }
  725. else
  726. {
  727. throw ExceptionEx.ThrowBusinessException(ex);
  728. }
  729. }
  730. }
  731. /// <summary>
  732. /// 随机分配床位给学生
  733. /// </summary>
  734. /// <param name="noNation">是否不许一个名族的在一起</param>
  735. /// <param name="noPlace">是否不许一个地方的在一起</param>
  736. public void Automatic_allocation_accommodation(bool noNation, bool noPlace)
  737. {
  738. try
  739. {
  740. accommodationService.Automatic_allocation_accommodation(noNation, noPlace, "1");
  741. accommodationService.Automatic_allocation_accommodation(noNation, noPlace, "0");
  742. }
  743. catch (Exception ex)
  744. {
  745. if (ex is ExceptionEx)
  746. {
  747. throw;
  748. }
  749. else
  750. {
  751. throw ExceptionEx.ThrowBusinessException(ex);
  752. }
  753. }
  754. }
  755. public void SyncData()
  756. {
  757. try
  758. {
  759. accommodationService.SyncData();
  760. }
  761. catch (Exception ex)
  762. {
  763. if (ex is ExceptionEx)
  764. {
  765. throw;
  766. }
  767. else
  768. {
  769. throw ExceptionEx.ThrowBusinessException(ex);
  770. }
  771. }
  772. }
  773. public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid)
  774. {
  775. try
  776. {
  777. return accommodationService.ExecuteImportExcel(dt, fileGuid);
  778. }
  779. catch (Exception ex)
  780. {
  781. if (ex is ExceptionEx)
  782. {
  783. throw;
  784. }
  785. else
  786. {
  787. throw ExceptionEx.ThrowBusinessException(ex);
  788. }
  789. }
  790. }
  791. public List<ClassInfoEntity> GetClassNo(string MainClass)
  792. {
  793. try
  794. {
  795. return accommodationService.GetClassNo(MainClass).Select(x => new ClassInfoEntity { ClassNo = x.ClassNo, ClassName = x.ClassName }).ToList();
  796. }
  797. catch (Exception ex)
  798. {
  799. if (ex is ExceptionEx)
  800. {
  801. throw;
  802. }
  803. else
  804. {
  805. throw ExceptionEx.ThrowBusinessException(ex);
  806. }
  807. }
  808. }
  809. #endregion
  810. }
  811. }