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.
 
 
 
 
 
 

569 lines
15 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> GetAllList()
  43. {
  44. try
  45. {
  46. return accommodationService.GetAllList();
  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 object GetDormitoryList()
  61. {
  62. try
  63. {
  64. return accommodationService.GetDormitoryList();
  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 object GetUnitList(string ParentID)
  79. {
  80. try
  81. {
  82. return accommodationService.GetUnitList(ParentID);
  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 GetFloorList(string parentID)
  97. {
  98. try
  99. {
  100. return accommodationService.GetFloorList(parentID);
  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 GetRoomList(string parentID)
  115. {
  116. try
  117. {
  118. return accommodationService.GetRoomList(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 GetBedList(string parentID)
  133. {
  134. try
  135. {
  136. return accommodationService.GetBedList(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 string GetBuildType(string parentID)
  151. {
  152. try
  153. {
  154. return accommodationService.GetBuildType(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. /// <summary>
  169. /// 获取Acc_DormitoryBuild表实体数据
  170. /// <param name="keyValue">主键</param>
  171. /// <summary>
  172. /// <returns></returns>
  173. public Acc_DormitoryBuildEntity GetAcc_DormitoryBuildEntity(string keyValue)
  174. {
  175. try
  176. {
  177. return accommodationService.GetAcc_DormitoryBuildEntity(keyValue);
  178. }
  179. catch (Exception ex)
  180. {
  181. if (ex is ExceptionEx)
  182. {
  183. throw;
  184. }
  185. else
  186. {
  187. throw ExceptionEx.ThrowBusinessException(ex);
  188. }
  189. }
  190. }
  191. /// <summary>
  192. /// 获取Acc_DormitoryBuild表实体数据
  193. /// <param name="keyValue">主键</param>
  194. /// <summary>
  195. /// <returns></returns>
  196. public Acc_DormitoryBuildEntity GetAcc_DormitoryBuildEntityByName(string name)
  197. {
  198. try
  199. {
  200. return accommodationService.GetAcc_DormitoryBuildEntityByName(name);
  201. }
  202. catch (Exception ex)
  203. {
  204. if (ex is ExceptionEx)
  205. {
  206. throw;
  207. }
  208. else
  209. {
  210. throw ExceptionEx.ThrowBusinessException(ex);
  211. }
  212. }
  213. }
  214. /// <summary>
  215. /// 获取Acc_DormitoryBuild表实体数据
  216. /// <param name="keyValue">主键</param>
  217. /// <summary>
  218. /// <returns></returns>
  219. public List<Acc_DormitoryBuildEntity> GetList()
  220. {
  221. try
  222. {
  223. return accommodationService.GetSqlTree();
  224. }
  225. catch (Exception ex)
  226. {
  227. if (ex is ExceptionEx)
  228. {
  229. throw;
  230. }
  231. else
  232. {
  233. throw ExceptionEx.ThrowBusinessException(ex);
  234. }
  235. }
  236. }
  237. /// <summary>
  238. /// 获取左侧树形数据
  239. /// <summary>
  240. /// <returns></returns>
  241. public List<TreeModel> GetTree()
  242. {
  243. try
  244. {
  245. List<Acc_DormitoryBuildEntity> list = accommodationService.GetSqlTree();
  246. List<TreeModel> treeList = new List<TreeModel>();
  247. foreach (Acc_DormitoryBuildEntity item in list)
  248. {
  249. TreeModel node = new TreeModel
  250. {
  251. id = item.ID.ToString(),
  252. text = item.Name.ToString(),
  253. value = item.ID.ToString(),
  254. showcheck = false,
  255. checkstate = 0,
  256. isexpand = false,
  257. parentId = item.ParentID == null ? "" : item.ParentID
  258. };
  259. treeList.Add(node);
  260. }
  261. return treeList.ToTree();
  262. }
  263. catch (Exception ex)
  264. {
  265. if (ex is ExceptionEx)
  266. {
  267. throw;
  268. }
  269. else
  270. {
  271. throw ExceptionEx.ThrowBusinessException(ex);
  272. }
  273. }
  274. }
  275. public List<TreeModel> GetTreeNew()
  276. {
  277. try
  278. {
  279. List<Acc_DormitoryBuildEntity> list = accommodationService.GetSqlTreeNew();
  280. List<TreeModel> treeList = new List<TreeModel>();
  281. foreach (Acc_DormitoryBuildEntity item in list)
  282. {
  283. TreeModel node = new TreeModel
  284. {
  285. id = item.ID.ToString(),
  286. text = item.Name.ToString(),
  287. value = item.ID.ToString(),
  288. showcheck = false,
  289. checkstate = 0,
  290. isexpand = false,
  291. parentId = item.ParentID == null ? "" : item.ParentID
  292. };
  293. treeList.Add(node);
  294. }
  295. return treeList.ToTree();
  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. /// <summary>
  310. /// 根据父id 获取树形数据
  311. /// </summary>
  312. /// <param name="parentID"></param>
  313. /// <returns></returns>
  314. public List<TreeModel> GetTreeByParentID(string parentID)
  315. {
  316. try
  317. {
  318. DataTable list = accommodationService.GetTreeByParentId(parentID);
  319. List<TreeModel> treeList = new List<TreeModel>();
  320. foreach (DataRow item in list.Rows)
  321. {
  322. TreeModel node = new TreeModel
  323. {
  324. id = item["id"].ToString(),
  325. text = item["name"].ToString(),
  326. value = item["id"].ToString(),
  327. showcheck = false,
  328. checkstate = 0,
  329. isexpand = true,
  330. parentId = item["parentid"].ToString()
  331. };
  332. treeList.Add(node);
  333. }
  334. return treeList.ToTree();
  335. }
  336. catch (Exception ex)
  337. {
  338. if (ex is ExceptionEx)
  339. {
  340. throw;
  341. }
  342. else
  343. {
  344. throw ExceptionEx.ThrowBusinessException(ex);
  345. }
  346. }
  347. }
  348. /// <summary>
  349. /// 根据父id 获取树形数据
  350. /// </summary>
  351. /// <param name="parentID"></param>
  352. /// <returns></returns>
  353. public string GetDormitoryInfoByPlanStuNo(string stuNo)
  354. {
  355. try
  356. {
  357. return accommodationService.GetDormitoryInfoByPlanStuNo(stuNo);
  358. }
  359. catch (Exception ex)
  360. {
  361. if (ex is ExceptionEx)
  362. {
  363. throw;
  364. }
  365. else
  366. {
  367. throw ExceptionEx.ThrowBusinessException(ex);
  368. }
  369. }
  370. }
  371. public string GetDormitoryInfoByStuNo(string stuNo)
  372. {
  373. try
  374. {
  375. return accommodationService.GetDormitoryInfoByStuNo(stuNo);
  376. }
  377. catch (Exception ex)
  378. {
  379. if (ex is ExceptionEx)
  380. {
  381. throw;
  382. }
  383. else
  384. {
  385. throw ExceptionEx.ThrowBusinessException(ex);
  386. }
  387. }
  388. }
  389. public bool MatchDormitoryInfo(string stuNo,string dormitory,string unit,string floor,string room,string bed ,List<Acc_DormitoryBuildEntity> data)
  390. {
  391. try
  392. {
  393. return accommodationService.MatchDormitoryInfo(stuNo,dormitory,unit,floor,room,bed,data);
  394. }
  395. catch (Exception ex)
  396. {
  397. if (ex is ExceptionEx)
  398. {
  399. throw;
  400. }
  401. else
  402. {
  403. throw ExceptionEx.ThrowBusinessException(ex);
  404. }
  405. }
  406. }
  407. #endregion
  408. #region 提交数据
  409. /// <summary>
  410. /// 删除实体数据
  411. /// <param name="keyValue">主键</param>
  412. /// <summary>
  413. /// <returns></returns>
  414. public void DeleteEntity(string keyValue)
  415. {
  416. try
  417. {
  418. accommodationService.DeleteEntity(keyValue);
  419. }
  420. catch (Exception ex)
  421. {
  422. if (ex is ExceptionEx)
  423. {
  424. throw;
  425. }
  426. else
  427. {
  428. throw ExceptionEx.ThrowBusinessException(ex);
  429. }
  430. }
  431. }
  432. /// <summary>
  433. /// 保存实体数据(新增、修改)
  434. /// <param name="keyValue">主键</param>
  435. /// <summary>
  436. /// <returns></returns>
  437. public void SaveEntity(string keyValue, Acc_DormitoryBuildEntity entity)
  438. {
  439. try
  440. {
  441. accommodationService.SaveEntity(keyValue, entity);
  442. }
  443. catch (Exception ex)
  444. {
  445. if (ex is ExceptionEx)
  446. {
  447. throw;
  448. }
  449. else
  450. {
  451. throw ExceptionEx.ThrowBusinessException(ex);
  452. }
  453. }
  454. }
  455. /// <summary>
  456. /// 批量添加单元、楼层、宿舍、床位
  457. /// </summary>
  458. /// <param name="keyValue"></param>
  459. /// <param name="elementNum"></param>
  460. /// <param name="floorNum"></param>
  461. /// <param name="roomNum"></param>
  462. /// <param name="bedNum"></param>
  463. public void DormitoryAdd(string keyValue, int elementNum, int floorNum, int roomNum, int bedNum)
  464. {
  465. try
  466. {
  467. accommodationService.DormitoryAdd(keyValue, elementNum, floorNum, roomNum, bedNum);
  468. }
  469. catch (Exception ex)
  470. {
  471. if (ex is ExceptionEx)
  472. {
  473. throw;
  474. }
  475. else
  476. {
  477. throw ExceptionEx.ThrowBusinessException(ex);
  478. }
  479. }
  480. }
  481. /// <summary>
  482. /// 随机分配床位给学生
  483. /// </summary>
  484. /// <param name="noNation">是否不许一个名族的在一起</param>
  485. /// <param name="noPlace">是否不许一个地方的在一起</param>
  486. public void Automatic_allocation_accommodation(bool noNation, bool noPlace)
  487. {
  488. try
  489. {
  490. accommodationService.Automatic_allocation_accommodation(noNation, noPlace, "1");
  491. accommodationService.Automatic_allocation_accommodation(noNation, noPlace, "0");
  492. }
  493. catch (Exception ex)
  494. {
  495. if (ex is ExceptionEx)
  496. {
  497. throw;
  498. }
  499. else
  500. {
  501. throw ExceptionEx.ThrowBusinessException(ex);
  502. }
  503. }
  504. }
  505. #endregion
  506. }
  507. }