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.
 
 
 
 
 
 

475 lines
18 KiB

  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. #endregion
  164. #region 提交数据
  165. /// <summary>
  166. /// 删除实体数据
  167. /// <param name="keyValue">主键</param>
  168. /// <summary>
  169. /// <returns></returns>
  170. public void DeleteEntity(string keyValue)
  171. {
  172. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  173. try
  174. {
  175. //会议签到记录表中删除参会人员记录
  176. db.Delete<MeetingSignInRecordEntity>(x => x.MeetID == keyValue);
  177. //会议工作管理表删除会议
  178. db.Delete<MeetingManagementEntity>(t => t.Id == keyValue);
  179. db.Commit();
  180. }
  181. catch (Exception ex)
  182. {
  183. db.Rollback();
  184. if (ex is ExceptionEx)
  185. {
  186. throw;
  187. }
  188. else
  189. {
  190. throw ExceptionEx.ThrowServiceException(ex);
  191. }
  192. }
  193. }
  194. /// <summary>
  195. /// 保存实体数据(新增、修改)
  196. /// <param name="keyValue">主键</param>
  197. /// <summary>
  198. /// <returns></returns>
  199. public void SaveEntity(UserInfo userInfo, string keyValue, MeetingManagementEntity entity)
  200. {
  201. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  202. try
  203. {
  204. if (!string.IsNullOrEmpty(keyValue))
  205. {
  206. entity.Modify(keyValue, userInfo);
  207. db.Update(entity);
  208. }
  209. else
  210. {
  211. entity.Create(userInfo);
  212. db.Insert(entity);
  213. }
  214. db.Commit();
  215. }
  216. catch (Exception ex)
  217. {
  218. db.Rollback();
  219. if (ex is ExceptionEx)
  220. {
  221. throw;
  222. }
  223. else
  224. {
  225. throw ExceptionEx.ThrowServiceException(ex);
  226. }
  227. }
  228. }
  229. /// <summary>
  230. /// 审核实体数据
  231. /// <param name="keyValue">主键</param>
  232. /// <summary>
  233. /// <returns></returns>
  234. public void DoCheck(UserInfo userInfo, string keyValue, string status)
  235. {
  236. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  237. try
  238. {
  239. //修改会议工作管理表的审核字段;
  240. db.ExecuteBySql("update MeetingManagement set CheckStatus='" + status + "',CheckUser='" + userInfo.userId + "',CheckTime='" + DateTime.Now + "' where Id='" + keyValue + "' ");
  241. if (status == "1")//审核通过:会议签到记录表中增加参会人员;
  242. {
  243. var entity = db.FindEntity<MeetingManagementEntity>(x => x.Id == keyValue);
  244. if (entity != null)
  245. {
  246. //增加校内参入人员:
  247. if (!string.IsNullOrEmpty(entity.InternalParticipants))
  248. {
  249. if (entity.InternalParticipants.IndexOf(',') == -1)
  250. {
  251. var model = new MeetingSignInRecordEntity()
  252. {
  253. MeetID = entity.Id,
  254. ParticipantID = entity.InternalParticipants,
  255. ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == entity.InternalParticipants)?.F_RealName,
  256. IsSignIn = false
  257. };
  258. model.Create(userInfo);
  259. db.Insert(model);
  260. }
  261. else
  262. {
  263. foreach (var item in entity.InternalParticipants.Split(','))
  264. {
  265. var model = new MeetingSignInRecordEntity()
  266. {
  267. MeetID = entity.Id,
  268. ParticipantID = item,
  269. ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == item)?.F_RealName,
  270. IsSignIn = false
  271. };
  272. model.Create(userInfo);
  273. db.Insert(model);
  274. }
  275. }
  276. }
  277. //增加校外参入人员:
  278. if (!string.IsNullOrEmpty(entity.ExternalParticipants))
  279. {
  280. if (entity.ExternalParticipants.IndexOf(',') == -1)
  281. {
  282. var model = new MeetingSignInRecordEntity()
  283. {
  284. MeetID = entity.Id,
  285. ParticipantName = entity.ExternalParticipants,
  286. IsSignIn = false
  287. };
  288. model.Create(userInfo);
  289. db.Insert(model);
  290. }
  291. else
  292. {
  293. foreach (var item in entity.ExternalParticipants.Split(','))
  294. {
  295. var model = new MeetingSignInRecordEntity()
  296. {
  297. MeetID = entity.Id,
  298. ParticipantName = item,
  299. IsSignIn = false
  300. };
  301. model.Create(userInfo);
  302. db.Insert(model);
  303. }
  304. }
  305. }
  306. }
  307. }
  308. else if (status == "2") //审核不通过:会议签到记录表中删除参会人员记录;
  309. {
  310. db.Delete<MeetingSignInRecordEntity>(x => x.MeetID == keyValue);
  311. }
  312. db.Commit();
  313. }
  314. catch (Exception ex)
  315. {
  316. db.Rollback();
  317. if (ex is ExceptionEx)
  318. {
  319. throw;
  320. }
  321. else
  322. {
  323. throw ExceptionEx.ThrowServiceException(ex);
  324. }
  325. }
  326. }
  327. /// <summary>
  328. /// 提交实体数据
  329. /// <param name="keyValue">主键</param>
  330. /// <summary>
  331. /// <returns></returns>
  332. public void DoSubmit(string keyValue, string status, string processId)
  333. {
  334. try
  335. {
  336. this.BaseRepository("CollegeMIS").ExecuteBySql("update MeetingManagement set CheckStatus='" + status + "',ProcessId='" + processId + "' where Id='" + keyValue + "' ");
  337. }
  338. catch (Exception ex)
  339. {
  340. if (ex is ExceptionEx)
  341. {
  342. throw;
  343. }
  344. else
  345. {
  346. throw ExceptionEx.ThrowServiceException(ex);
  347. }
  348. }
  349. }
  350. /// <summary>
  351. /// 审核实体数据
  352. /// <param name="keyValue">主键</param>
  353. /// <summary>
  354. /// <returns></returns>
  355. public void ChangeStatusByProcessId(string processId, string status, string userId)
  356. {
  357. UserInfo userInfo = LoginUserInfo.Get();
  358. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  359. try
  360. {
  361. //修改会议工作管理表的审核字段;
  362. db.ExecuteBySql("update MeetingManagement set CheckStatus='" + status + "',CheckUser='" + userId + "',CheckTime='" + DateTime.Now + "' where ProcessId='" + processId + "' ");
  363. var entity = db.FindEntity<MeetingManagementEntity>(x => x.ProcessId == processId);
  364. if (entity != null)
  365. {
  366. if (status == "1")//审核通过:会议签到记录表中增加参会人员;
  367. {
  368. //增加校内参入人员:
  369. if (!string.IsNullOrEmpty(entity.InternalParticipants))
  370. {
  371. if (entity.InternalParticipants.IndexOf(',') == -1)
  372. {
  373. var model = new MeetingSignInRecordEntity()
  374. {
  375. MeetID = entity.Id,
  376. ParticipantID = entity.InternalParticipants,
  377. ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == entity.InternalParticipants)?.F_RealName,
  378. IsSignIn = false
  379. };
  380. model.Create(userInfo);
  381. db.Insert(model);
  382. }
  383. else
  384. {
  385. foreach (var item in entity.InternalParticipants.Split(','))
  386. {
  387. var model = new MeetingSignInRecordEntity()
  388. {
  389. MeetID = entity.Id,
  390. ParticipantID = item,
  391. ParticipantName = this.BaseRepository().FindEntity<UserEntity>(x => x.F_UserId == item)?.F_RealName,
  392. IsSignIn = false
  393. };
  394. model.Create(userInfo);
  395. db.Insert(model);
  396. }
  397. }
  398. }
  399. //增加校外参入人员:
  400. if (!string.IsNullOrEmpty(entity.ExternalParticipants))
  401. {
  402. if (entity.ExternalParticipants.IndexOf(',') == -1)
  403. {
  404. var model = new MeetingSignInRecordEntity()
  405. {
  406. MeetID = entity.Id,
  407. ParticipantName = entity.ExternalParticipants,
  408. IsSignIn = false
  409. };
  410. model.Create(userInfo);
  411. db.Insert(model);
  412. }
  413. else
  414. {
  415. foreach (var item in entity.ExternalParticipants.Split(','))
  416. {
  417. var model = new MeetingSignInRecordEntity()
  418. {
  419. MeetID = entity.Id,
  420. ParticipantName = item,
  421. IsSignIn = false
  422. };
  423. model.Create(userInfo);
  424. db.Insert(model);
  425. }
  426. }
  427. }
  428. }
  429. else if (status == "2") //审核不通过:会议签到记录表中删除参会人员记录;
  430. {
  431. db.Delete<MeetingSignInRecordEntity>(x => x.MeetID == entity.Id);
  432. }
  433. }
  434. db.Commit();
  435. }
  436. catch (Exception ex)
  437. {
  438. db.Rollback();
  439. if (ex is ExceptionEx)
  440. {
  441. throw;
  442. }
  443. else
  444. {
  445. throw ExceptionEx.ThrowServiceException(ex);
  446. }
  447. }
  448. }
  449. #endregion
  450. }
  451. }