CollegeClassroomServices.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using Bowin.Common.Linq;
  7. using Bowin.Common.Linq.Entity;
  8. using EMIS.Utility;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  12. using EMIS.ViewModel.UniversityManage.ClassroomManage;
  13. using EMIS.DataLogic.SchedulingManage.SchedulingSettings;
  14. namespace EMIS.CommonLogic.SchedulingManage.SchedulingSettings
  15. {
  16. public class CollegeClassroomServices : BaseServices, ICollegeClassroomServices
  17. {
  18. public CollegeClassroomDAL CollegeClassroomDAL { get; set; }
  19. /// <summary>
  20. /// 查询院系教室信息CollegeClassroomView
  21. /// </summary>
  22. /// <param name="configuretView"></param>
  23. /// <param name="collegeCampusID"></param>
  24. /// <param name="collegeID"></param>
  25. /// <param name="buildingsInfoID"></param>
  26. /// <param name="classroomName"></param>
  27. /// <param name="classroomTypeID"></param>
  28. /// <param name="isConcurrentUse"></param>
  29. /// <param name="isReserve"></param>
  30. /// <param name="isAvailable"></param>
  31. /// <param name="pageIndex"></param>
  32. /// <param name="pageSize"></param>
  33. /// <returns></returns>
  34. public IGridResultSet<CollegeClassroomView> GetCollegeClassroomViewGrid(ConfiguretView configuretView, Guid? collegeCampusID, Guid? collegeID,
  35. Guid? buildingsInfoID, string classroomName, int? classroomTypeID, int? isConcurrentUse, int? isReserve, int? isAvailable, int pageIndex, int pageSize)
  36. {
  37. Expression<Func<ES_CollegeClassroom, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  38. if (collegeID.HasValue)
  39. {
  40. exp = exp.And(x => x.CollegeID == collegeID);
  41. }
  42. var query = CollegeClassroomDAL.GetCollegeClassroomViewQueryable(exp);
  43. if (collegeCampusID.HasValue)
  44. {
  45. query = query.Where(x => x.CollegeCampusID == collegeCampusID);
  46. }
  47. if (buildingsInfoID.HasValue)
  48. {
  49. query = query.Where(x => x.BuildingsInfoID == buildingsInfoID);
  50. }
  51. if (!string.IsNullOrEmpty(classroomName) && classroomName != "-1")
  52. {
  53. //教室名称
  54. query = query.Where(x => x.ClassroomName == classroomName);
  55. }
  56. if (classroomTypeID.HasValue)
  57. {
  58. //教室类型(模糊查询)
  59. query = query.Where(x => x.CF_ClassroomType.Select(w => w.ClassroomType).Contains(classroomTypeID));
  60. }
  61. if (isConcurrentUse.HasValue)
  62. {
  63. //可否多班教学
  64. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsYes)
  65. {
  66. query = query.Where(x => x.IsConcurrentUse == true);
  67. }
  68. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsNo)
  69. {
  70. query = query.Where(x => x.IsConcurrentUse != true);
  71. }
  72. }
  73. if (isReserve.HasValue)
  74. {
  75. //是否预留(排课用)
  76. if (isReserve.Value == (int)CF_GeneralPurpose.IsYes)
  77. {
  78. query = query.Where(x => x.IsReserve == true);
  79. }
  80. if (isReserve.Value == (int)CF_GeneralPurpose.IsNo)
  81. {
  82. query = query.Where(x => x.IsReserve != true);
  83. }
  84. }
  85. if (isAvailable.HasValue)
  86. {
  87. //是否可用
  88. if (isAvailable.Value == (int)CF_GeneralPurpose.IsYes)
  89. {
  90. query = query.Where(x => x.IsAvailable == true);
  91. }
  92. if (isAvailable.Value == (int)CF_GeneralPurpose.IsNo)
  93. {
  94. query = query.Where(x => x.IsAvailable != true);
  95. }
  96. }
  97. //查询条件
  98. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  99. {
  100. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  101. }
  102. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  103. .ThenBy(x => x.ClassroomCode.Length).ThenBy(x => x.ClassroomCode).ThenBy(x => x.RoomUseID)
  104. .ThenBy(x => x.BuildingsInfoCode.Length).ThenBy(x => x.BuildingsInfoCode)
  105. .ToGridResultSet<CollegeClassroomView>(pageIndex, pageSize);
  106. }
  107. /// <summary>
  108. /// 查询院系教室信息List
  109. /// </summary>
  110. /// <param name="configuretView"></param>
  111. /// <param name="collegeCampusID"></param>
  112. /// <param name="collegeID"></param>
  113. /// <param name="buildingsInfoID"></param>
  114. /// <param name="classroomName"></param>
  115. /// <param name="classroomTypeID"></param>
  116. /// <param name="isConcurrentUse"></param>
  117. /// <param name="isReserve"></param>
  118. /// <param name="isAvailable"></param>
  119. /// <returns></returns>
  120. public IList<CollegeClassroomView> GetCollegeClassroomViewList(ConfiguretView configuretView, Guid? collegeCampusID, Guid? collegeID,
  121. Guid? buildingsInfoID, string classroomName, int? classroomTypeID, int? isConcurrentUse, int? isReserve, int? isAvailable)
  122. {
  123. Expression<Func<ES_CollegeClassroom, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  124. if (collegeID.HasValue)
  125. {
  126. exp = exp.And(x => x.CollegeID == collegeID);
  127. }
  128. var query = CollegeClassroomDAL.GetCollegeClassroomViewQueryable(exp);
  129. if (collegeCampusID.HasValue)
  130. {
  131. query = query.Where(x => x.CollegeCampusID == collegeCampusID);
  132. }
  133. if (buildingsInfoID.HasValue)
  134. {
  135. query = query.Where(x => x.BuildingsInfoID == buildingsInfoID);
  136. }
  137. if (!string.IsNullOrEmpty(classroomName) && classroomName != "-1")
  138. {
  139. //教室名称
  140. query = query.Where(x => x.ClassroomName == classroomName);
  141. }
  142. if (classroomTypeID.HasValue)
  143. {
  144. //教室类型(模糊查询)
  145. query = query.Where(x => x.CF_ClassroomType.Select(w => w.ClassroomType).Contains(classroomTypeID));
  146. }
  147. if (isConcurrentUse.HasValue)
  148. {
  149. //可否多班教学
  150. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsYes)
  151. {
  152. query = query.Where(x => x.IsConcurrentUse == true);
  153. }
  154. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsNo)
  155. {
  156. query = query.Where(x => x.IsConcurrentUse != true);
  157. }
  158. }
  159. if (isReserve.HasValue)
  160. {
  161. //是否预留(排课用)
  162. if (isReserve.Value == (int)CF_GeneralPurpose.IsYes)
  163. {
  164. query = query.Where(x => x.IsReserve == true);
  165. }
  166. if (isReserve.Value == (int)CF_GeneralPurpose.IsNo)
  167. {
  168. query = query.Where(x => x.IsReserve != true);
  169. }
  170. }
  171. if (isAvailable.HasValue)
  172. {
  173. //是否可用
  174. if (isAvailable.Value == (int)CF_GeneralPurpose.IsYes)
  175. {
  176. query = query.Where(x => x.IsAvailable == true);
  177. }
  178. if (isAvailable.Value == (int)CF_GeneralPurpose.IsNo)
  179. {
  180. query = query.Where(x => x.IsAvailable != true);
  181. }
  182. }
  183. //查询条件
  184. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  185. {
  186. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  187. }
  188. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  189. .ThenBy(x => x.ClassroomCode.Length).ThenBy(x => x.ClassroomCode).ThenBy(x => x.RoomUseID)
  190. .ThenBy(x => x.BuildingsInfoCode.Length).ThenBy(x => x.BuildingsInfoCode).ToList();
  191. }
  192. /// <summary>
  193. /// 查询对应的院系教室信息CollegeClassroomView(根据院系教室ID)
  194. /// </summary>
  195. /// <param name="collegeClassroomID"></param>
  196. /// <returns></returns>
  197. public CollegeClassroomView GetCollegeClassroomView(Guid? collegeClassroomID)
  198. {
  199. try
  200. {
  201. var query = CollegeClassroomDAL.GetCollegeClassroomViewQueryable(x => x.CollegeClassroomID == collegeClassroomID).SingleOrDefault();
  202. return query;
  203. }
  204. catch (Exception ex)
  205. {
  206. throw new Exception(ex.Message);
  207. }
  208. }
  209. /// <summary>
  210. /// 编辑(新增、修改)
  211. /// </summary>
  212. /// <param name="collegeClassroomView"></param>
  213. public void CollegeClassroomEdit(CollegeClassroomView collegeClassroomView)
  214. {
  215. try
  216. {
  217. //查询数据库进行验证
  218. var collegeClassroomVerify = CollegeClassroomDAL.CollegeClassroomRepository
  219. .GetList(x => x.CollegeClassroomID != collegeClassroomView.CollegeClassroomID
  220. && x.CollegeID == collegeClassroomView.CollegeID
  221. && x.ClassroomID == collegeClassroomView.ClassroomID).SingleOrDefault();
  222. if (collegeClassroomVerify == null)
  223. {
  224. //数据有误验证
  225. if (collegeClassroomView.CollegeClassroomID != Guid.Empty)
  226. {
  227. var collegeClassroom = CollegeClassroomDAL.CollegeClassroomRepository
  228. .GetList(x => x.CollegeClassroomID == collegeClassroomView.CollegeClassroomID).SingleOrDefault();
  229. if (collegeClassroom == null)
  230. {
  231. throw new Exception("数据有误,请核查。");
  232. }
  233. else
  234. {
  235. //表示修改
  236. collegeClassroom.CollegeID = collegeClassroomView.CollegeID;
  237. collegeClassroom.ClassroomID = collegeClassroomView.ClassroomID;
  238. SetModifyStatus(collegeClassroom);
  239. }
  240. }
  241. else
  242. {
  243. //表示新增
  244. var newCollegeClassroom = new ES_CollegeClassroom();
  245. newCollegeClassroom.CollegeClassroomID = Guid.NewGuid();
  246. newCollegeClassroom.CollegeID = collegeClassroomView.CollegeID;
  247. newCollegeClassroom.ClassroomID = collegeClassroomView.ClassroomID;
  248. SetNewStatus(newCollegeClassroom);
  249. UnitOfWork.Add(newCollegeClassroom);
  250. }
  251. }
  252. else
  253. {
  254. throw new Exception("已存在相同的院系教室信息,请核查。");
  255. }
  256. //事务提交
  257. UnitOfWork.Commit();
  258. }
  259. catch (Exception ex)
  260. {
  261. throw new Exception(ex.Message);
  262. }
  263. }
  264. /// <summary>
  265. /// 院系教室信息批量新增(根据院系所信息选择教室信息新增)
  266. /// </summary>
  267. /// <param name="classroomIDList"></param>
  268. /// <param name="collegeClassroomView"></param>
  269. /// <returns></returns>
  270. public string CollegeClassroomBatchAdd(List<Guid?> classroomIDList, CollegeClassroomView collegeClassroomView)
  271. {
  272. try
  273. {
  274. //查询对应的院系教室信息List
  275. var collegeClassroomList = CollegeClassroomDAL.CollegeClassroomRepository
  276. .GetList(x => classroomIDList.Contains(x.ClassroomID)).ToList();
  277. int success = 0; //成功
  278. int fail = 0; //失败
  279. string tipMessage = null; //提示消息
  280. List<ES_CollegeClassroom> collegeClassroomInList = new List<ES_CollegeClassroom>();
  281. foreach (var classroomID in classroomIDList)
  282. {
  283. var collegeClassroomVerify = collegeClassroomList.Where(x => x.CollegeID == collegeClassroomView.CollegeID
  284. && x.ClassroomID == classroomID).SingleOrDefault();
  285. if (collegeClassroomVerify == null)
  286. {
  287. //新增
  288. var newCollegeClassroom = new ES_CollegeClassroom();
  289. newCollegeClassroom.CollegeClassroomID = Guid.NewGuid();
  290. newCollegeClassroom.CollegeID = collegeClassroomView.CollegeID;
  291. newCollegeClassroom.ClassroomID = classroomID;
  292. SetNewStatus(newCollegeClassroom);
  293. collegeClassroomInList.Add(newCollegeClassroom);
  294. success++;
  295. }
  296. else
  297. {
  298. //表示已存在相同的院系教室信息
  299. fail++;
  300. }
  301. }
  302. //批量插入
  303. UnitOfWork.BulkInsert<ES_CollegeClassroom>(collegeClassroomInList);
  304. if (success > 0 && fail <= 0)
  305. {
  306. tipMessage = success + "条";
  307. }
  308. else
  309. {
  310. tipMessage = success + "条," + fail + "条失败,原因:已存在相同的院系教室信息,请检查";
  311. }
  312. return tipMessage;
  313. }
  314. catch (Exception ex)
  315. {
  316. throw new Exception(ex.Message);
  317. }
  318. }
  319. /// <summary>
  320. /// 查询院系教室中未新增的教室信息ClassroomView
  321. /// </summary>
  322. /// <param name="configuretView"></param>
  323. /// <param name="campusID"></param>
  324. /// <param name="buildingsInfoID"></param>
  325. /// <param name="classroomName"></param>
  326. /// <param name="classroomTypeID"></param>
  327. /// <param name="isConcurrentUse"></param>
  328. /// <param name="isReserve"></param>
  329. /// <param name="isAvailable"></param>
  330. /// <param name="collegeID"></param>
  331. /// <param name="pageIndex"></param>
  332. /// <param name="pageSize"></param>
  333. /// <returns></returns>
  334. public IGridResultSet<ClassroomView> GetClassroomViewNoAddGrid(ConfiguretView configuretView, Guid? campusID, Guid? buildingsInfoID,
  335. string classroomName, int? classroomTypeID, int? isConcurrentUse, int? isReserve, int? isAvailable, Guid? collegeID, int pageIndex, int pageSize)
  336. {
  337. //教室信息
  338. Expression<Func<CF_Classroom, bool>> expClassroom = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  339. if (buildingsInfoID.HasValue)
  340. {
  341. //建筑信息
  342. expClassroom = expClassroom.And(x => x.BuildingsInfoID == buildingsInfoID);
  343. }
  344. if (!string.IsNullOrEmpty(classroomName) && classroomName != "-1")
  345. {
  346. //教室名称
  347. expClassroom = expClassroom.And(x => x.Name == classroomName);
  348. }
  349. if (classroomTypeID.HasValue)
  350. {
  351. //教室类型(模糊查询)
  352. expClassroom = expClassroom.And(x => x.CF_ClassroomType.Select(w => w.ClassroomType).Contains(classroomTypeID));
  353. }
  354. if (isConcurrentUse.HasValue)
  355. {
  356. //可否多班教学
  357. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsYes)
  358. {
  359. expClassroom = expClassroom.And(x => x.IsConcurrentUse == true);
  360. }
  361. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsNo)
  362. {
  363. expClassroom = expClassroom.And(x => x.IsConcurrentUse != true);
  364. }
  365. }
  366. if (isAvailable.HasValue)
  367. {
  368. //是否可用
  369. if (isAvailable.Value == (int)CF_GeneralPurpose.IsYes)
  370. {
  371. expClassroom = expClassroom.And(x => x.IsAvailable == true);
  372. }
  373. if (isAvailable.Value == (int)CF_GeneralPurpose.IsNo)
  374. {
  375. expClassroom = expClassroom.And(x => x.IsAvailable != true);
  376. }
  377. }
  378. //院系教室
  379. Expression<Func<ES_CollegeClassroom, bool>> expCollegeClassroom = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  380. if (collegeID.HasValue)
  381. {
  382. expCollegeClassroom = expCollegeClassroom.And(x => x.CollegeID == collegeID);
  383. }
  384. var query = CollegeClassroomDAL.GetClassroomViewNoAddQueryable(expClassroom, expCollegeClassroom);
  385. if (campusID.HasValue)
  386. {
  387. //校区
  388. query = query.Where(x => x.CampusID == campusID);
  389. }
  390. if (isReserve.HasValue)
  391. {
  392. //是否预留(排课用)
  393. if (isReserve.Value == (int)CF_GeneralPurpose.IsYes)
  394. {
  395. query = query.Where(x => x.IsReserve == true);
  396. }
  397. if (isReserve.Value == (int)CF_GeneralPurpose.IsNo)
  398. {
  399. query = query.Where(x => x.IsReserve != true);
  400. }
  401. }
  402. //查询条件
  403. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  404. {
  405. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  406. }
  407. return this.GetQueryByDataRangeByCampus(query)
  408. .OrderBy(x => x.CampusCode.Length).ThenBy(x => x.CampusCode)
  409. .ThenBy(x => x.Code.Length).ThenBy(x => x.Code)
  410. .ThenBy(x => x.RoomUseID).ToGridResultSet<ClassroomView>(pageIndex, pageSize);
  411. }
  412. /// <summary>
  413. /// 查询院系教室中未新增的教室信息List
  414. /// </summary>
  415. /// <param name="configuretView"></param>
  416. /// <param name="campusID"></param>
  417. /// <param name="buildingsInfoID"></param>
  418. /// <param name="classroomName"></param>
  419. /// <param name="classroomTypeID"></param>
  420. /// <param name="isConcurrentUse"></param>
  421. /// <param name="isReserve"></param>
  422. /// <param name="isAvailable"></param>
  423. /// <param name="collegeID"></param>
  424. /// <returns></returns>
  425. public IList<ClassroomView> GetClassroomViewNoAddList(ConfiguretView configuretView, Guid? campusID, Guid? buildingsInfoID,
  426. string classroomName, int? classroomTypeID, int? isConcurrentUse, int? isReserve, int? isAvailable, Guid? collegeID)
  427. {
  428. //教室信息
  429. Expression<Func<CF_Classroom, bool>> expClassroom = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  430. if (buildingsInfoID.HasValue)
  431. {
  432. //建筑信息
  433. expClassroom = expClassroom.And(x => x.BuildingsInfoID == buildingsInfoID);
  434. }
  435. if (!string.IsNullOrEmpty(classroomName) && classroomName != "-1")
  436. {
  437. //教室名称
  438. expClassroom = expClassroom.And(x => x.Name == classroomName);
  439. }
  440. if (classroomTypeID.HasValue)
  441. {
  442. //教室类型(模糊查询)
  443. expClassroom = expClassroom.And(x => x.CF_ClassroomType.Select(w => w.ClassroomType).Contains(classroomTypeID));
  444. }
  445. if (isConcurrentUse.HasValue)
  446. {
  447. //可否多班教学
  448. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsYes)
  449. {
  450. expClassroom = expClassroom.And(x => x.IsConcurrentUse == true);
  451. }
  452. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsNo)
  453. {
  454. expClassroom = expClassroom.And(x => x.IsConcurrentUse != true);
  455. }
  456. }
  457. if (isAvailable.HasValue)
  458. {
  459. //是否可用
  460. if (isAvailable.Value == (int)CF_GeneralPurpose.IsYes)
  461. {
  462. expClassroom = expClassroom.And(x => x.IsAvailable == true);
  463. }
  464. if (isAvailable.Value == (int)CF_GeneralPurpose.IsNo)
  465. {
  466. expClassroom = expClassroom.And(x => x.IsAvailable != true);
  467. }
  468. }
  469. //院系教室
  470. Expression<Func<ES_CollegeClassroom, bool>> expCollegeClassroom = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  471. if (collegeID.HasValue)
  472. {
  473. expCollegeClassroom = expCollegeClassroom.And(x => x.CollegeID == collegeID);
  474. }
  475. var query = CollegeClassroomDAL.GetClassroomViewNoAddQueryable(expClassroom, expCollegeClassroom);
  476. if (campusID.HasValue)
  477. {
  478. //校区
  479. query = query.Where(x => x.CampusID == campusID);
  480. }
  481. if (isReserve.HasValue)
  482. {
  483. //是否预留(排课用)
  484. if (isReserve.Value == (int)CF_GeneralPurpose.IsYes)
  485. {
  486. query = query.Where(x => x.IsReserve == true);
  487. }
  488. if (isReserve.Value == (int)CF_GeneralPurpose.IsNo)
  489. {
  490. query = query.Where(x => x.IsReserve != true);
  491. }
  492. }
  493. //查询条件
  494. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  495. {
  496. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  497. }
  498. return this.GetQueryByDataRangeByCampus(query)
  499. .OrderBy(x => x.CampusCode.Length).ThenBy(x => x.CampusCode)
  500. .ThenBy(x => x.Code.Length).ThenBy(x => x.Code)
  501. .ThenBy(x => x.RoomUseID).ToList();
  502. }
  503. /// <summary>
  504. /// 院系教室信息批量新增(根据院系教室信息CollegeClassroomView)
  505. /// </summary>
  506. /// <param name="collegeClassroomViewList"></param>
  507. /// <param name="collegeClassroomView"></param>
  508. /// <returns></returns>
  509. public string CollegeClassroomBatchAdd(List<CollegeClassroomView> collegeClassroomViewList, CollegeClassroomView collegeClassroomView)
  510. {
  511. try
  512. {
  513. //查询对应的院系所信息IDList
  514. var collegeIDList = collegeClassroomViewList.Select(x => x.CollegeID).Distinct().ToList();
  515. //查询对应的院系教室信息List(暂时只匹配院系所信息ID)
  516. var collegeClassroomList = CollegeClassroomDAL.CollegeClassroomRepository
  517. .GetList(x => collegeIDList.Contains(x.CollegeID)).ToList();
  518. int success = 0; //成功
  519. int fail = 0; //失败
  520. string tipMessage = null; //提示消息
  521. List<ES_CollegeClassroom> collegeClassroomInList = new List<ES_CollegeClassroom>();
  522. foreach (var newCollegeClassroomView in collegeClassroomViewList)
  523. {
  524. var collegeClassroomVerify = collegeClassroomList.Where(x => x.CollegeID == newCollegeClassroomView.CollegeID
  525. && x.ClassroomID == newCollegeClassroomView.ClassroomID).SingleOrDefault();
  526. if (collegeClassroomVerify == null)
  527. {
  528. //新增
  529. var newCollegeClassroom = new ES_CollegeClassroom();
  530. newCollegeClassroom.CollegeClassroomID = newCollegeClassroomView.CollegeClassroomID;
  531. newCollegeClassroom.CollegeID = newCollegeClassroomView.CollegeID;
  532. newCollegeClassroom.ClassroomID = newCollegeClassroomView.ClassroomID;
  533. SetNewStatus(newCollegeClassroom);
  534. collegeClassroomInList.Add(newCollegeClassroom);
  535. success++;
  536. }
  537. else
  538. {
  539. //表示已存在相同的院系教室信息
  540. fail++;
  541. }
  542. }
  543. //批量插入
  544. UnitOfWork.BulkInsert<ES_CollegeClassroom>(collegeClassroomInList);
  545. if (success > 0 && fail <= 0)
  546. {
  547. tipMessage = success + "条";
  548. }
  549. else
  550. {
  551. tipMessage = success + "条," + fail + "条失败,原因:已存在相同的院系教室信息,请检查";
  552. }
  553. return tipMessage;
  554. }
  555. catch (Exception ex)
  556. {
  557. throw new Exception(ex.Message);
  558. }
  559. }
  560. /// <summary>
  561. /// 查询未新增的院系教室信息CollegeClassroomView
  562. /// </summary>
  563. /// <param name="configuretView"></param>
  564. /// <param name="buildingsInfoCampusID"></param>
  565. /// <param name="buildingsInfoID"></param>
  566. /// <param name="classroomName"></param>
  567. /// <param name="classroomTypeID"></param>
  568. /// <param name="isConcurrentUse"></param>
  569. /// <param name="isReserve"></param>
  570. /// <param name="isAvailable"></param>
  571. /// <param name="collegeID"></param>
  572. /// <param name="pageIndex"></param>
  573. /// <param name="pageSize"></param>
  574. /// <returns></returns>
  575. public IGridResultSet<CollegeClassroomView> GetCollegeClassroomViewNoAddGrid(ConfiguretView configuretView, Guid? buildingsInfoCampusID,
  576. Guid? buildingsInfoID, string classroomName, int? classroomTypeID, int? isConcurrentUse, int? isReserve,
  577. int? isAvailable, Guid? collegeID, int pageIndex, int pageSize)
  578. {
  579. //院系所信息
  580. Expression<Func<CF_College, bool>> expCollege = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  581. expCollege = expCollege.And(x => x.CF_CollegeProfile.UnitCategoryID == (int)CF_UnitCategory.College);
  582. if (collegeID.HasValue)
  583. {
  584. expCollege = expCollege.And(x => x.CollegeID == collegeID);
  585. }
  586. //教室信息
  587. Expression<Func<CF_Classroom, bool>> expClassroom = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  588. if (buildingsInfoID.HasValue)
  589. {
  590. //建筑信息
  591. expClassroom = expClassroom.And(x => x.BuildingsInfoID == buildingsInfoID);
  592. }
  593. if (!string.IsNullOrEmpty(classroomName) && classroomName != "-1")
  594. {
  595. //教室名称
  596. expClassroom = expClassroom.And(x => x.Name == classroomName);
  597. }
  598. if (classroomTypeID.HasValue)
  599. {
  600. //教室类型(模糊查询)
  601. expClassroom = expClassroom.And(x => x.CF_ClassroomType.Select(w => w.ClassroomType).Contains(classroomTypeID));
  602. }
  603. if (isConcurrentUse.HasValue)
  604. {
  605. //可否多班教学
  606. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsYes)
  607. {
  608. expClassroom = expClassroom.And(x => x.IsConcurrentUse == true);
  609. }
  610. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsNo)
  611. {
  612. expClassroom = expClassroom.And(x => x.IsConcurrentUse != true);
  613. }
  614. }
  615. if (isAvailable.HasValue)
  616. {
  617. //是否可用
  618. if (isAvailable.Value == (int)CF_GeneralPurpose.IsYes)
  619. {
  620. expClassroom = expClassroom.And(x => x.IsAvailable == true);
  621. }
  622. if (isAvailable.Value == (int)CF_GeneralPurpose.IsNo)
  623. {
  624. expClassroom = expClassroom.And(x => x.IsAvailable != true);
  625. }
  626. }
  627. var query = CollegeClassroomDAL.GetCollegeClassroomViewNoAddQueryable(expCollege, expClassroom);
  628. if (buildingsInfoCampusID.HasValue)
  629. {
  630. query = query.Where(x => x.CampusID == buildingsInfoCampusID);
  631. }
  632. if (isReserve.HasValue)
  633. {
  634. //是否预留(排课用)
  635. if (isReserve.Value == (int)CF_GeneralPurpose.IsYes)
  636. {
  637. query = query.Where(x => x.IsReserve == true);
  638. }
  639. if (isReserve.Value == (int)CF_GeneralPurpose.IsNo)
  640. {
  641. query = query.Where(x => x.IsReserve != true);
  642. }
  643. }
  644. //查询条件
  645. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  646. {
  647. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  648. }
  649. return this.GetQueryByDataRangeByCampus(GetQueryByDataRangeByCollege(query))
  650. .OrderBy(x => x.BuildingsInfoCode.Length).ThenBy(x => x.BuildingsInfoCode)
  651. .ThenBy(x => x.ClassroomCode.Length).ThenBy(x => x.ClassroomCode).ThenBy(x => x.RoomUseID)
  652. .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  653. .ToGridResultSet<CollegeClassroomView>(pageIndex, pageSize);
  654. }
  655. /// <summary>
  656. /// 查询未新增的院系教室信息List
  657. /// </summary>
  658. /// <param name="configuretView"></param>
  659. /// <param name="buildingsInfoCampusID"></param>
  660. /// <param name="buildingsInfoID"></param>
  661. /// <param name="classroomName"></param>
  662. /// <param name="classroomTypeID"></param>
  663. /// <param name="isConcurrentUse"></param>
  664. /// <param name="isReserve"></param>
  665. /// <param name="isAvailable"></param>
  666. /// <param name="collegeID"></param>
  667. /// <returns></returns>
  668. public IList<CollegeClassroomView> GetCollegeClassroomViewNoAddList(ConfiguretView configuretView, Guid? buildingsInfoCampusID,
  669. Guid? buildingsInfoID, string classroomName, int? classroomTypeID, int? isConcurrentUse, int? isReserve,
  670. int? isAvailable, Guid? collegeID)
  671. {
  672. //院系所信息
  673. Expression<Func<CF_College, bool>> expCollege = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  674. expCollege = expCollege.And(x => x.CF_CollegeProfile.UnitCategoryID == (int)CF_UnitCategory.College);
  675. if (collegeID.HasValue)
  676. {
  677. expCollege = expCollege.And(x => x.CollegeID == collegeID);
  678. }
  679. //教室信息
  680. Expression<Func<CF_Classroom, bool>> expClassroom = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  681. if (buildingsInfoID.HasValue)
  682. {
  683. //建筑信息
  684. expClassroom = expClassroom.And(x => x.BuildingsInfoID == buildingsInfoID);
  685. }
  686. if (!string.IsNullOrEmpty(classroomName) && classroomName != "-1")
  687. {
  688. //教室名称
  689. expClassroom = expClassroom.And(x => x.Name == classroomName);
  690. }
  691. if (classroomTypeID.HasValue)
  692. {
  693. //教室类型(模糊查询)
  694. expClassroom = expClassroom.And(x => x.CF_ClassroomType.Select(w => w.ClassroomType).Contains(classroomTypeID));
  695. }
  696. if (isConcurrentUse.HasValue)
  697. {
  698. //可否多班教学
  699. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsYes)
  700. {
  701. expClassroom = expClassroom.And(x => x.IsConcurrentUse == true);
  702. }
  703. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsNo)
  704. {
  705. expClassroom = expClassroom.And(x => x.IsConcurrentUse != true);
  706. }
  707. }
  708. if (isAvailable.HasValue)
  709. {
  710. //是否可用
  711. if (isAvailable.Value == (int)CF_GeneralPurpose.IsYes)
  712. {
  713. expClassroom = expClassroom.And(x => x.IsAvailable == true);
  714. }
  715. if (isAvailable.Value == (int)CF_GeneralPurpose.IsNo)
  716. {
  717. expClassroom = expClassroom.And(x => x.IsAvailable != true);
  718. }
  719. }
  720. var query = CollegeClassroomDAL.GetCollegeClassroomViewNoAddQueryable(expCollege, expClassroom);
  721. if (buildingsInfoCampusID.HasValue)
  722. {
  723. query = query.Where(x => x.CampusID == buildingsInfoCampusID);
  724. }
  725. if (isReserve.HasValue)
  726. {
  727. //是否预留(排课用)
  728. if (isReserve.Value == (int)CF_GeneralPurpose.IsYes)
  729. {
  730. query = query.Where(x => x.IsReserve == true);
  731. }
  732. if (isReserve.Value == (int)CF_GeneralPurpose.IsNo)
  733. {
  734. query = query.Where(x => x.IsReserve != true);
  735. }
  736. }
  737. //查询条件
  738. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  739. {
  740. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  741. }
  742. return this.GetQueryByDataRangeByCampus(GetQueryByDataRangeByCollege(query))
  743. .OrderBy(x => x.BuildingsInfoCode.Length).ThenBy(x => x.BuildingsInfoCode)
  744. .ThenBy(x => x.ClassroomCode.Length).ThenBy(x => x.ClassroomCode).ThenBy(x => x.RoomUseID)
  745. .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  746. .ToList();
  747. }
  748. /// <summary>
  749. /// 删除
  750. /// </summary>
  751. /// <param name="collegeClassroomIDs"></param>
  752. /// <returns></returns>
  753. public bool CollegeClassroomDelete(List<Guid?> collegeClassroomIDs)
  754. {
  755. try
  756. {
  757. UnitOfWork.Delete<ES_CollegeClassroom>(x => collegeClassroomIDs.Contains(x.CollegeClassroomID));
  758. UnitOfWork.Commit();
  759. return true;
  760. }
  761. catch (Exception)
  762. {
  763. throw;
  764. }
  765. }
  766. }
  767. }