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.

AccommodationBLL.cs 22 KiB

4 years ago
4 years ago
4 years ago
4 years ago
2 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
2 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
2 years ago
4 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  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. /// <summary>
  346. /// 获取左侧树形数据
  347. /// <summary>
  348. /// <returns></returns>
  349. public List<TreeModel> GetTree()
  350. {
  351. try
  352. {
  353. List<Acc_DormitoryBuildEntity> list = accommodationService.GetSqlTree();
  354. List<TreeModel> treeList = new List<TreeModel>();
  355. foreach (Acc_DormitoryBuildEntity item in list)
  356. {
  357. TreeModel node = new TreeModel
  358. {
  359. id = item.ID.ToString(),
  360. text = item.Name.ToString(),
  361. value = item.ID.ToString(),
  362. showcheck = false,
  363. checkstate = 0,
  364. isexpand = true,
  365. parentId = item.ParentID == null ? "" : item.ParentID,
  366. title = item.BuildType
  367. };
  368. treeList.Add(node);
  369. }
  370. return treeList.ToTree();
  371. }
  372. catch (Exception ex)
  373. {
  374. if (ex is ExceptionEx)
  375. {
  376. throw;
  377. }
  378. else
  379. {
  380. throw ExceptionEx.ThrowBusinessException(ex);
  381. }
  382. }
  383. }
  384. public List<TreeModel> GetTreeNew()
  385. {
  386. try
  387. {
  388. List<Acc_DormitoryBuildEntity> list = accommodationService.GetSqlTreeNew();
  389. List<TreeModel> treeList = new List<TreeModel>();
  390. foreach (Acc_DormitoryBuildEntity item in list)
  391. {
  392. TreeModel node = new TreeModel
  393. {
  394. id = item.ID.ToString(),
  395. text = item.Name.ToString(),
  396. value = item.ID.ToString(),
  397. showcheck = false,
  398. checkstate = 0,
  399. isexpand = false,
  400. parentId = item.ParentID == null ? "" : item.ParentID
  401. };
  402. treeList.Add(node);
  403. }
  404. return treeList.ToTree();
  405. }
  406. catch (Exception ex)
  407. {
  408. if (ex is ExceptionEx)
  409. {
  410. throw;
  411. }
  412. else
  413. {
  414. throw ExceptionEx.ThrowBusinessException(ex);
  415. }
  416. }
  417. }
  418. public List<TreeModel> GetClassifyTree()
  419. {
  420. try
  421. {
  422. List<Acc_DormitoryBuildEntity> list = accommodationService.GetClassifyTree();
  423. List<TreeModel> treeList = new List<TreeModel>();
  424. foreach (Acc_DormitoryBuildEntity item in list)
  425. {
  426. TreeModel node = new TreeModel
  427. {
  428. id = item.ID.ToString(),
  429. text = item.Name.ToString(),
  430. value = item.ID.ToString(),
  431. showcheck = false,
  432. checkstate = 0,
  433. isexpand = false,
  434. parentId = item.ParentID == null ? "" : item.ParentID,
  435. title = string.IsNullOrEmpty(item.BuildType) ? "" : (Convert.ToInt32(item.BuildType) + 1).ToString(),
  436. };
  437. treeList.Add(node);
  438. }
  439. return treeList.ToTree();
  440. }
  441. catch (Exception ex)
  442. {
  443. if (ex is ExceptionEx)
  444. {
  445. throw;
  446. }
  447. else
  448. {
  449. throw ExceptionEx.ThrowBusinessException(ex);
  450. }
  451. }
  452. }
  453. /// <summary>
  454. /// 根据父id 获取树形数据
  455. /// </summary>
  456. /// <param name="parentID"></param>
  457. /// <returns></returns>
  458. public List<TreeModel> GetTreeByParentID(string parentID)
  459. {
  460. try
  461. {
  462. DataTable list = accommodationService.GetTreeByParentId(parentID);
  463. List<TreeModel> treeList = new List<TreeModel>();
  464. foreach (DataRow item in list.Rows)
  465. {
  466. TreeModel node = new TreeModel
  467. {
  468. id = item["id"].ToString(),
  469. text = item["name"].ToString(),
  470. value = item["id"].ToString(),
  471. showcheck = false,
  472. checkstate = 0,
  473. isexpand = true,
  474. parentId = item["parentid"].ToString()
  475. };
  476. treeList.Add(node);
  477. }
  478. return treeList.ToTree();
  479. }
  480. catch (Exception ex)
  481. {
  482. if (ex is ExceptionEx)
  483. {
  484. throw;
  485. }
  486. else
  487. {
  488. throw ExceptionEx.ThrowBusinessException(ex);
  489. }
  490. }
  491. }
  492. /// <summary>
  493. /// 根据父id 获取树形数据
  494. /// </summary>
  495. /// <param name="parentID"></param>
  496. /// <returns></returns>
  497. public string GetDormitoryInfoByPlanStuNo(string stuNo)
  498. {
  499. try
  500. {
  501. return accommodationService.GetDormitoryInfoByPlanStuNo(stuNo);
  502. }
  503. catch (Exception ex)
  504. {
  505. if (ex is ExceptionEx)
  506. {
  507. throw;
  508. }
  509. else
  510. {
  511. throw ExceptionEx.ThrowBusinessException(ex);
  512. }
  513. }
  514. }
  515. public string GetDormitoryInfoByStuNo(string stuNo)
  516. {
  517. try
  518. {
  519. return accommodationService.GetDormitoryInfoByStuNo(stuNo);
  520. }
  521. catch (Exception ex)
  522. {
  523. if (ex is ExceptionEx)
  524. {
  525. throw;
  526. }
  527. else
  528. {
  529. throw ExceptionEx.ThrowBusinessException(ex);
  530. }
  531. }
  532. }
  533. public bool MatchDormitoryInfo(string stuNo, string dormitory, string unit, string floor, string room, string bed, List<Acc_DormitoryBuildEntity> data)
  534. {
  535. try
  536. {
  537. return accommodationService.MatchDormitoryInfo(stuNo, dormitory, unit, floor, room, bed, data);
  538. }
  539. catch (Exception ex)
  540. {
  541. if (ex is ExceptionEx)
  542. {
  543. throw;
  544. }
  545. else
  546. {
  547. throw ExceptionEx.ThrowBusinessException(ex);
  548. }
  549. }
  550. }
  551. #endregion
  552. #region 提交数据
  553. /// <summary>
  554. /// 删除实体数据
  555. /// <param name="keyValue">主键</param>
  556. /// <summary>
  557. /// <returns></returns>
  558. public void DeleteEntity(string keyValue)
  559. {
  560. try
  561. {
  562. accommodationService.DeleteEntity(keyValue);
  563. }
  564. catch (Exception ex)
  565. {
  566. if (ex is ExceptionEx)
  567. {
  568. throw;
  569. }
  570. else
  571. {
  572. throw ExceptionEx.ThrowBusinessException(ex);
  573. }
  574. }
  575. }
  576. /// <summary>
  577. /// 删除实体数据
  578. /// <param name="keyValue">主键</param>
  579. /// <summary>
  580. /// <returns></returns>
  581. public void DeleteBed(string keyValue, string ParentID)
  582. {
  583. try
  584. {
  585. accommodationService.DeleteBed(keyValue, ParentID);
  586. }
  587. catch (Exception ex)
  588. {
  589. if (ex is ExceptionEx)
  590. {
  591. throw;
  592. }
  593. else
  594. {
  595. throw ExceptionEx.ThrowBusinessException(ex);
  596. }
  597. }
  598. }
  599. /// <summary>
  600. /// 保存实体数据(新增、修改)
  601. /// <param name="keyValue">主键</param>
  602. /// <summary>
  603. /// <returns></returns>
  604. public void SaveEntity(string keyValue, Acc_DormitoryBuildEntity entity)
  605. {
  606. try
  607. {
  608. accommodationService.SaveEntity(keyValue, entity);
  609. }
  610. catch (Exception ex)
  611. {
  612. if (ex is ExceptionEx)
  613. {
  614. throw;
  615. }
  616. else
  617. {
  618. throw ExceptionEx.ThrowBusinessException(ex);
  619. }
  620. }
  621. }
  622. /// <summary>
  623. /// 保存实体数据(新增、修改)
  624. /// <param name="keyValue">主键</param>
  625. /// <summary>
  626. /// <returns></returns>
  627. public void SaveBedEntity(string keyValue, string ParentID, Acc_DormitoryBuildEntity entity)
  628. {
  629. try
  630. {
  631. accommodationService.SaveBedEntity(keyValue, ParentID, entity);
  632. }
  633. catch (Exception ex)
  634. {
  635. if (ex is ExceptionEx)
  636. {
  637. throw;
  638. }
  639. else
  640. {
  641. throw ExceptionEx.ThrowBusinessException(ex);
  642. }
  643. }
  644. }
  645. /// <summary>
  646. /// 分配系
  647. /// </summary>
  648. /// <param name="keyValue"></param>
  649. /// <param name="entity"></param>
  650. public void SaveDeptClass(string keyValue, Acc_DormitoryBuildEntity entity, int type)
  651. {
  652. try
  653. {
  654. accommodationService.SaveDeptClass(keyValue, entity, type);
  655. }
  656. catch (Exception ex)
  657. {
  658. if (ex is ExceptionEx)
  659. {
  660. throw;
  661. }
  662. else
  663. {
  664. throw ExceptionEx.ThrowBusinessException(ex);
  665. }
  666. }
  667. }
  668. public string SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list)
  669. {
  670. try
  671. {
  672. return accommodationService.SaveRoom(RoomId, list);
  673. }
  674. catch (Exception ex)
  675. {
  676. if (ex is ExceptionEx)
  677. {
  678. throw;
  679. }
  680. else
  681. {
  682. throw ExceptionEx.ThrowBusinessException(ex);
  683. }
  684. }
  685. }
  686. /// <summary>
  687. /// 批量添加单元、楼层、宿舍、床位
  688. /// </summary>
  689. /// <param name="keyValue"></param>
  690. /// <param name="elementNum"></param>
  691. /// <param name="floorNum"></param>
  692. /// <param name="roomNum"></param>
  693. /// <param name="bedNum"></param>
  694. public void DormitoryAdd(string keyValue, int elementNum, int floorNum, int roomNum, int bedNum)
  695. {
  696. try
  697. {
  698. accommodationService.DormitoryAdd(keyValue, elementNum, floorNum, roomNum, bedNum);
  699. }
  700. catch (Exception ex)
  701. {
  702. if (ex is ExceptionEx)
  703. {
  704. throw;
  705. }
  706. else
  707. {
  708. throw ExceptionEx.ThrowBusinessException(ex);
  709. }
  710. }
  711. }
  712. /// <summary>
  713. /// 随机分配床位给学生
  714. /// </summary>
  715. /// <param name="noNation">是否不许一个名族的在一起</param>
  716. /// <param name="noPlace">是否不许一个地方的在一起</param>
  717. public void Automatic_allocation_accommodation(bool noNation, bool noPlace)
  718. {
  719. try
  720. {
  721. accommodationService.Automatic_allocation_accommodation(noNation, noPlace, "1");
  722. accommodationService.Automatic_allocation_accommodation(noNation, noPlace, "0");
  723. }
  724. catch (Exception ex)
  725. {
  726. if (ex is ExceptionEx)
  727. {
  728. throw;
  729. }
  730. else
  731. {
  732. throw ExceptionEx.ThrowBusinessException(ex);
  733. }
  734. }
  735. }
  736. public void SyncData()
  737. {
  738. try
  739. {
  740. accommodationService.SyncData();
  741. }
  742. catch (Exception ex)
  743. {
  744. if (ex is ExceptionEx)
  745. {
  746. throw;
  747. }
  748. else
  749. {
  750. throw ExceptionEx.ThrowBusinessException(ex);
  751. }
  752. }
  753. }
  754. #endregion
  755. }
  756. }