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.

MeetingManagementService.cs 21 KiB

4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. using Dapper;
  2. using Learun.Application.Organization;
  3. using Learun.DataBase.Repository;
  4. using Learun.Util;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.PersonnelManagement
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  13. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2021-02-21 10:07
  16. /// 描 述:会议管理
  17. /// </summary>
  18. public class MeetingManagementService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表分页数据
  23. /// <summary>
  24. /// <param name="pagination">分页参数</param>
  25. /// <param name="queryJson">查询参数</param>
  26. /// <returns></returns>
  27. public IEnumerable<MeetingManagementEntity> GetPageList(Pagination pagination, string queryJson)
  28. {
  29. try
  30. {
  31. var strSql = new StringBuilder();
  32. strSql.Append("SELECT t.*,r.Name as ConferenceRoomName ");
  33. strSql.Append(" FROM MeetingManagement t left join ConferenceRoom r on t.MeetingPlace=r.ID ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["MeetingTitle"].IsEmpty())
  39. {
  40. dp.Add("MeetingTitle", "%" + queryParam["MeetingTitle"].ToString() + "%", DbType.String);
  41. strSql.Append(" AND t.MeetingTitle Like @MeetingTitle ");
  42. }
  43. if (!queryParam["MeetingPlace"].IsEmpty())
  44. {
  45. dp.Add("MeetingPlace", queryParam["MeetingPlace"].ToString(), DbType.String);
  46. strSql.Append(" AND t.MeetingPlace = @MeetingPlace ");
  47. }
  48. if (!queryParam["CreateUser"].IsEmpty())
  49. {
  50. dp.Add("CreateUser", queryParam["CreateUser"].ToString(), DbType.String);
  51. strSql.Append(" AND t.CreateUser = @CreateUser ");
  52. }
  53. if (!queryParam["InternalParticipants"].IsEmpty())
  54. {
  55. dp.Add("InternalParticipants", "%" + queryParam["InternalParticipants"].ToString() + "%", DbType.String);
  56. strSql.Append(" AND t.InternalParticipants Like @InternalParticipants ");
  57. }
  58. return this.BaseRepository("CollegeMIS").FindList<MeetingManagementEntity>(strSql.ToString(), dp, pagination);
  59. }
  60. catch (Exception ex)
  61. {
  62. if (ex is ExceptionEx)
  63. {
  64. throw;
  65. }
  66. else
  67. {
  68. throw ExceptionEx.ThrowServiceException(ex);
  69. }
  70. }
  71. }
  72. /// <summary>
  73. /// 获取页面显示列表数据
  74. /// <summary>
  75. /// <param name="queryJson">查询参数</param>
  76. /// <returns></returns>
  77. public IEnumerable<MeetingManagementEntity> GetList(string queryJson)
  78. {
  79. try
  80. {
  81. var strSql = new StringBuilder();
  82. strSql.Append("SELECT t.*");
  83. strSql.Append(" FROM MeetingManagement t ");
  84. strSql.Append(" WHERE 1=1 ");
  85. var queryParam = queryJson.ToJObject();
  86. // 虚拟参数
  87. var dp = new DynamicParameters(new { });
  88. if (!queryParam["MeetingTitle"].IsEmpty())
  89. {
  90. dp.Add("MeetingTitle", "%" + queryParam["MeetingTitle"].ToString() + "%", DbType.String);
  91. strSql.Append(" AND t.MeetingTitle Like @MeetingTitle ");
  92. }
  93. if (!queryParam["MeetingPlace"].IsEmpty())
  94. {
  95. dp.Add("MeetingPlace", queryParam["MeetingPlace"].ToString(), DbType.String);
  96. strSql.Append(" AND t.MeetingPlace = @MeetingPlace ");
  97. }
  98. if (!queryParam["CreateUser"].IsEmpty())
  99. {
  100. dp.Add("CreateUser", queryParam["CreateUser"].ToString(), DbType.String);
  101. strSql.Append(" AND t.CreateUser = @CreateUser ");
  102. }
  103. return this.BaseRepository("CollegeMIS").FindList<MeetingManagementEntity>(strSql.ToString(), dp);
  104. }
  105. catch (Exception ex)
  106. {
  107. if (ex is ExceptionEx)
  108. {
  109. throw;
  110. }
  111. else
  112. {
  113. throw ExceptionEx.ThrowServiceException(ex);
  114. }
  115. }
  116. }
  117. /// <summary>
  118. /// 获取MeetingManagement表实体数据
  119. /// <param name="keyValue">主键</param>
  120. /// <summary>
  121. /// <returns></returns>
  122. public MeetingManagementEntity GetMeetingManagementEntity(string keyValue)
  123. {
  124. try
  125. {
  126. return this.BaseRepository("CollegeMIS").FindEntity<MeetingManagementEntity>(keyValue);
  127. }
  128. catch (Exception ex)
  129. {
  130. if (ex is ExceptionEx)
  131. {
  132. throw;
  133. }
  134. else
  135. {
  136. throw ExceptionEx.ThrowServiceException(ex);
  137. }
  138. }
  139. }
  140. /// <summary>
  141. /// 获取MeetingManagement表实体数据
  142. /// <param name="keyValue">主键</param>
  143. /// <summary>
  144. /// <returns></returns>
  145. public MeetingManagementEntity GetMeetingManagementEntityByProcessId(string processId)
  146. {
  147. try
  148. {
  149. return this.BaseRepository("CollegeMIS").FindEntity<MeetingManagementEntity>(x => x.ProcessId == processId);
  150. }
  151. catch (Exception ex)
  152. {
  153. if (ex is ExceptionEx)
  154. {
  155. throw;
  156. }
  157. else
  158. {
  159. throw ExceptionEx.ThrowServiceException(ex);
  160. }
  161. }
  162. }
  163. /// <summary>
  164. /// 获取报表数据
  165. /// </summary>
  166. /// <param name="queryJson">查询参数</param>
  167. /// <returns></returns>
  168. public DataTable GetStatisticList(string queryJson)
  169. {
  170. try
  171. {
  172. var strSql = new StringBuilder();
  173. strSql.Append("SELECT ");
  174. strSql.Append(@"
  175. t.meetingtitle,
  176. t.begintime,
  177. t.endtime,
  178. t.正常,
  179. t.未到
  180. ");
  181. strSql.Append(" FROM (select m.MeetingTitle,isnull(t.正常,0) 正常,isnull(t.未到,0) 未到,m.BeginTime,m.EndTime from MeetingManagement m left join (select meetid,sum(case issignin when 1 then 1 else 0 end) as 正常, sum(case issignin when 0 then 1 else 0 end) as 未到 from MeetingSignInRecord group by meetid) t on t.MeetID=m.Id)t ");
  182. strSql.Append(" WHERE 1=1 ");
  183. var queryParam = queryJson.ToJObject();
  184. // 虚拟参数
  185. var dp = new DynamicParameters(new { });
  186. if (!queryParam["meetingtitle"].IsEmpty())
  187. {
  188. dp.Add("meetingtitle", "%" + queryParam["meetingtitle"].ToString() + "%", DbType.String);
  189. strSql.Append(" AND t.meetingtitle Like @meetingtitle ");
  190. }
  191. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  192. {
  193. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  194. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  195. strSql.Append(" AND ( t.begintime >= @startTime AND t.begintime <= @endTime ) ");
  196. }
  197. return this.BaseRepository("CollegeMIS").FindTable(strSql.ToString(), dp);
  198. }
  199. catch (Exception ex)
  200. {
  201. if (ex is ExceptionEx)
  202. {
  203. throw;
  204. }
  205. else
  206. {
  207. throw ExceptionEx.ThrowServiceException(ex);
  208. }
  209. }
  210. }
  211. #endregion
  212. #region 提交数据
  213. /// <summary>
  214. /// 删除实体数据
  215. /// <param name="keyValue">主键</param>
  216. /// <summary>
  217. /// <returns></returns>
  218. public void DeleteEntity(string keyValue)
  219. {
  220. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  221. try
  222. {
  223. //会议签到记录表中删除参会人员记录
  224. db.Delete<MeetingSignInRecordEntity>(x => x.MeetID == keyValue);
  225. //会议工作管理表删除会议
  226. db.Delete<MeetingManagementEntity>(t => t.Id == keyValue);
  227. db.Commit();
  228. }
  229. catch (Exception ex)
  230. {
  231. db.Rollback();
  232. if (ex is ExceptionEx)
  233. {
  234. throw;
  235. }
  236. else
  237. {
  238. throw ExceptionEx.ThrowServiceException(ex);
  239. }
  240. }
  241. }
  242. /// <summary>
  243. /// 保存实体数据(新增、修改)
  244. /// <param name="keyValue">主键</param>
  245. /// <summary>
  246. /// <returns></returns>
  247. public void SaveEntity(UserInfo userInfo, string keyValue, MeetingManagementEntity entity)
  248. {
  249. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  250. try
  251. {
  252. if (!string.IsNullOrEmpty(keyValue))
  253. {
  254. entity.Modify(keyValue, userInfo);
  255. db.Update(entity);
  256. }
  257. else
  258. {
  259. entity.Create(userInfo);
  260. db.Insert(entity);
  261. }
  262. db.Commit();
  263. }
  264. catch (Exception ex)
  265. {
  266. db.Rollback();
  267. if (ex is ExceptionEx)
  268. {
  269. throw;
  270. }
  271. else
  272. {
  273. throw ExceptionEx.ThrowServiceException(ex);
  274. }
  275. }
  276. }
  277. /// <summary>
  278. /// 审核实体数据
  279. /// <param name="keyValue">主键</param>
  280. /// <summary>
  281. /// <returns></returns>
  282. public void DoCheck(UserInfo userInfo, string keyValue, string status)
  283. {
  284. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  285. try
  286. {
  287. //修改会议工作管理表的审核字段;
  288. db.ExecuteBySql("update MeetingManagement set CheckStatus='" + status + "',CheckUser='" + userInfo.userId + "',CheckTime='" + DateTime.Now + "' where Id='" + keyValue + "' ");
  289. if (status == "1")//审核通过:会议签到记录表中增加参会人员;
  290. {
  291. var entity = db.FindEntity<MeetingManagementEntity>(x => x.Id == keyValue);
  292. if (entity != null)
  293. {
  294. //增加校内参入人员:
  295. if (!string.IsNullOrEmpty(entity.InternalParticipants))
  296. {
  297. if (entity.InternalParticipants.IndexOf(',') == -1)
  298. {
  299. var model = new MeetingSignInRecordEntity()
  300. {
  301. MeetID = entity.Id,
  302. ParticipantID = entity.InternalParticipants,
  303. ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == entity.InternalParticipants)?.F_RealName,
  304. IsSignIn = false
  305. };
  306. model.Create(userInfo);
  307. db.Insert(model);
  308. }
  309. else
  310. {
  311. foreach (var item in entity.InternalParticipants.Split(','))
  312. {
  313. var model = new MeetingSignInRecordEntity()
  314. {
  315. MeetID = entity.Id,
  316. ParticipantID = item,
  317. ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == item)?.F_RealName,
  318. IsSignIn = false
  319. };
  320. model.Create(userInfo);
  321. db.Insert(model);
  322. }
  323. }
  324. }
  325. //增加校外参入人员:
  326. if (!string.IsNullOrEmpty(entity.ExternalParticipants))
  327. {
  328. if (entity.ExternalParticipants.IndexOf(',') == -1)
  329. {
  330. var model = new MeetingSignInRecordEntity()
  331. {
  332. MeetID = entity.Id,
  333. ParticipantName = entity.ExternalParticipants,
  334. IsSignIn = false
  335. };
  336. model.Create(userInfo);
  337. db.Insert(model);
  338. }
  339. else
  340. {
  341. foreach (var item in entity.ExternalParticipants.Split(','))
  342. {
  343. var model = new MeetingSignInRecordEntity()
  344. {
  345. MeetID = entity.Id,
  346. ParticipantName = item,
  347. IsSignIn = false
  348. };
  349. model.Create(userInfo);
  350. db.Insert(model);
  351. }
  352. }
  353. }
  354. }
  355. }
  356. else if (status == "2") //审核不通过:会议签到记录表中删除参会人员记录;
  357. {
  358. db.Delete<MeetingSignInRecordEntity>(x => x.MeetID == keyValue);
  359. }
  360. db.Commit();
  361. }
  362. catch (Exception ex)
  363. {
  364. db.Rollback();
  365. if (ex is ExceptionEx)
  366. {
  367. throw;
  368. }
  369. else
  370. {
  371. throw ExceptionEx.ThrowServiceException(ex);
  372. }
  373. }
  374. }
  375. /// <summary>
  376. /// 提交实体数据
  377. /// <param name="keyValue">主键</param>
  378. /// <summary>
  379. /// <returns></returns>
  380. public void DoSubmit(string keyValue, string status, string processId)
  381. {
  382. try
  383. {
  384. this.BaseRepository("CollegeMIS").ExecuteBySql("update MeetingManagement set CheckStatus='" + status + "',ProcessId='" + processId + "' where Id='" + keyValue + "' ");
  385. }
  386. catch (Exception ex)
  387. {
  388. if (ex is ExceptionEx)
  389. {
  390. throw;
  391. }
  392. else
  393. {
  394. throw ExceptionEx.ThrowServiceException(ex);
  395. }
  396. }
  397. }
  398. /// <summary>
  399. /// 审核实体数据
  400. /// <param name="keyValue">主键</param>
  401. /// <summary>
  402. /// <returns></returns>
  403. public void ChangeStatusByProcessId(string processId, string status, string userId)
  404. {
  405. UserInfo userInfo = LoginUserInfo.Get();
  406. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  407. try
  408. {
  409. //修改会议工作管理表的审核字段;
  410. db.ExecuteBySql("update MeetingManagement set CheckStatus='" + status + "',CheckUser='" + userId + "',CheckTime='" + DateTime.Now + "' where ProcessId='" + processId + "' ");
  411. var entity = db.FindEntity<MeetingManagementEntity>(x => x.ProcessId == processId);
  412. if (entity != null)
  413. {
  414. if (status == "1")//审核通过:会议签到记录表中增加参会人员;
  415. {
  416. //增加校内参入人员:
  417. if (!string.IsNullOrEmpty(entity.InternalParticipants))
  418. {
  419. if (entity.InternalParticipants.IndexOf(',') == -1)
  420. {
  421. var model = new MeetingSignInRecordEntity()
  422. {
  423. MeetID = entity.Id,
  424. ParticipantID = entity.InternalParticipants,
  425. ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == entity.InternalParticipants)?.F_RealName,
  426. IsSignIn = false
  427. };
  428. model.Create(userInfo);
  429. db.Insert(model);
  430. }
  431. else
  432. {
  433. foreach (var item in entity.InternalParticipants.Split(','))
  434. {
  435. var model = new MeetingSignInRecordEntity()
  436. {
  437. MeetID = entity.Id,
  438. ParticipantID = item,
  439. ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == item)?.F_RealName,
  440. IsSignIn = false
  441. };
  442. model.Create(userInfo);
  443. db.Insert(model);
  444. }
  445. }
  446. }
  447. //增加校外参入人员:
  448. if (!string.IsNullOrEmpty(entity.ExternalParticipants))
  449. {
  450. if (entity.ExternalParticipants.IndexOf(',') == -1)
  451. {
  452. var model = new MeetingSignInRecordEntity()
  453. {
  454. MeetID = entity.Id,
  455. ParticipantName = entity.ExternalParticipants,
  456. IsSignIn = false
  457. };
  458. model.Create(userInfo);
  459. db.Insert(model);
  460. }
  461. else
  462. {
  463. foreach (var item in entity.ExternalParticipants.Split(','))
  464. {
  465. var model = new MeetingSignInRecordEntity()
  466. {
  467. MeetID = entity.Id,
  468. ParticipantName = item,
  469. IsSignIn = false
  470. };
  471. model.Create(userInfo);
  472. db.Insert(model);
  473. }
  474. }
  475. }
  476. }
  477. else if (status == "2") //审核不通过:会议签到记录表中删除参会人员记录;
  478. {
  479. db.Delete<MeetingSignInRecordEntity>(x => x.MeetID == entity.Id);
  480. }
  481. }
  482. db.Commit();
  483. }
  484. catch (Exception ex)
  485. {
  486. db.Rollback();
  487. if (ex is ExceptionEx)
  488. {
  489. throw;
  490. }
  491. else
  492. {
  493. throw ExceptionEx.ThrowServiceException(ex);
  494. }
  495. }
  496. }
  497. #endregion
  498. }
  499. }