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.
 
 
 
 
 
 

916 lines
25 KiB

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