AppMeetingController.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Datory;
  6. using GxPress.Auth;
  7. using GxPress.Common.Tools;
  8. using GxPress.Entity.WorkMeeting;
  9. using GxPress.Repository.Interface;
  10. using GxPress.Repository.Interface.WorkMeeting;
  11. using GxPress.Request.App.WorkMeeting;
  12. using GxPress.Result;
  13. using Microsoft.AspNetCore.Authorization;
  14. using Microsoft.AspNetCore.Mvc;
  15. using GxPress.Service.Interface.Meeting;
  16. using GxPress.Repository.Interface.MeetingSummaryTodo;
  17. using GxPress.Repository.Interface.FlowAttachment;
  18. using GxPress.Service.Interface.UserMiddle;
  19. using GxPress.Service.Interface.Analyze;
  20. using GxPress.Request.Analyze;
  21. namespace GxPress.Api.AppControllers
  22. {
  23. /// <summary>
  24. /// 会议
  25. /// </summary>
  26. [Route("api/app/meeting")]
  27. [ApiController]
  28. [Authorize]
  29. public class AppMeetingController : ControllerBase
  30. {
  31. private readonly ILoginContext _loginContext;
  32. private readonly IMeetingLocationRepository _meetingLocationRepository;
  33. private readonly IMeetingOrderRepository _meetingOrderRepository;
  34. private readonly IMeetingRepository _meetingRepository;
  35. private readonly IMeetingRoomRepository _meetingRoomRepository;
  36. private readonly IMeetingSummaryRepository _meetingSummaryRepository;
  37. private readonly IUserRepository _userRepository;
  38. private readonly IMeetingService meetingService;
  39. private readonly IMeetingSummaryTodoRepository meetingSummaryTodoRepository;
  40. private readonly IFlowAttachmentRepository flowAttachmentRepository;
  41. private readonly IUserMiddleService _userMiddleService;
  42. private readonly IAnalyzeService _analyzeService;
  43. private readonly ICommentRepository _commentRepository;
  44. public AppMeetingController(ILoginContext loginContext, IMeetingLocationRepository meetingLocationRepository, IMeetingOrderRepository meetingOrderRepository, IMeetingRepository meetingRepository, IMeetingRoomRepository meetingRoomRepository, IMeetingSummaryRepository meetingSummaryRepository, IUserRepository userRepository, IMeetingService meetingService, IMeetingSummaryTodoRepository meetingSummaryTodoRepository, IFlowAttachmentRepository flowAttachmentRepository, IUserMiddleService userMiddleService, IAnalyzeService analyzeService, ICommentRepository commentRepository)
  45. {
  46. _loginContext = loginContext;
  47. _meetingLocationRepository = meetingLocationRepository;
  48. _meetingOrderRepository = meetingOrderRepository;
  49. _meetingRepository = meetingRepository;
  50. _meetingRoomRepository = meetingRoomRepository;
  51. _meetingSummaryRepository = meetingSummaryRepository;
  52. _userRepository = userRepository;
  53. this.meetingService = meetingService;
  54. this.meetingSummaryTodoRepository = meetingSummaryTodoRepository;
  55. this.flowAttachmentRepository = flowAttachmentRepository;
  56. _userMiddleService = userMiddleService;
  57. _analyzeService = analyzeService;
  58. _commentRepository = commentRepository;
  59. }
  60. /// <summary>
  61. /// 获取会议室列表
  62. /// </summary>
  63. /// <returns></returns>
  64. [HttpGet("rooms")]
  65. [AllowAnonymous]
  66. public async Task<MeetingRoomsResult> ListRoom([FromQuery] MeetingRoomRequest request)
  67. {
  68. var locations = await _meetingLocationRepository.GetListAsync();
  69. var rooms = await _meetingRoomRepository.GetListAsync(request.LocationId);
  70. foreach (var room in rooms)
  71. {
  72. room.Address = await _meetingLocationRepository.GetAddress(room.LocationId);
  73. }
  74. return new MeetingRoomsResult
  75. {
  76. Locations = locations,
  77. Rooms = rooms
  78. };
  79. }
  80. /// <summary>
  81. /// 获取会议室
  82. /// </summary>
  83. /// <returns></returns>
  84. [HttpGet("rooms/{id}")]
  85. public async Task<MeetingRoomResult> RoomGet([FromRoute] int id)
  86. {
  87. var room = await _meetingRoomRepository.GetAsync(id);
  88. room.Address = await _meetingLocationRepository.GetAddress(room.LocationId);
  89. var orderList = await _meetingOrderRepository.GetListAsyncSinceNow(room.Id);
  90. var orders = new SortedDictionary<string, List<int>>();
  91. foreach (var meetingOrder in orderList)
  92. {
  93. var data = meetingOrder.Date.ToString().Insert(4, "-").Insert(7, "-");
  94. var key = StringUtils.GetDate(Convert.ToDateTime(data)).ToString();
  95. // var key = StringUtils.GetDate(meetingOrder.CreatedDate).ToString();
  96. if (orders.TryGetValue(key, out var hourList))
  97. {
  98. hourList.Add(meetingOrder.Hour);
  99. }
  100. else
  101. {
  102. orders[key] = new List<int>
  103. {
  104. meetingOrder.Hour
  105. };
  106. }
  107. }
  108. var orderLists = new List<TimeDictionary>();
  109. //新版
  110. foreach (var item in orderList)
  111. {
  112. if (orderLists.Any(n => n.TimeKey == item.Date.ToString()))
  113. continue;
  114. var timeDictionary = new TimeDictionary()
  115. {
  116. TimeKey = item.Date.ToString(),
  117. };
  118. foreach (var data in orderList.Where(n => n.Date == Convert.ToInt32(item.Date)).Distinct().ToList())
  119. {
  120. timeDictionary.TimeValues.Add(data.Hour);
  121. timeDictionary.NewTimeValues.Add(new TimeValue { Key = data.Hour, Value = data.UserName });
  122. }
  123. orderLists.Add(timeDictionary);
  124. }
  125. // foreach (var item in orderLists)
  126. // {
  127. // foreach (var data in orderList.Where(n => n.Date == Convert.ToInt32(item.TimeKey)).Distinct().ToList())
  128. // item.TimeValues.Add(new TimeValue { Key = data.Hour, Value = data.UserName });
  129. // }
  130. return new MeetingRoomResult
  131. {
  132. RoomName = room.Name,
  133. Disabled = room.Disabled,
  134. Orders = orders,
  135. OrderList = orderLists.Distinct().ToList()
  136. };
  137. }
  138. /// <summary>
  139. /// 预定会议室 添加/编辑
  140. /// </summary>
  141. /// <returns></returns>
  142. [HttpPost("rooms/{id}/actions/order")]
  143. public async Task<DefaultResult> Order([FromRoute] int id, [FromBody] MeetingOrderRequest request)
  144. {
  145. var room = await _meetingRoomRepository.GetAsync(id);
  146. var meeting = new Meeting();
  147. if (request.MeetingId == 0)
  148. {
  149. meeting = new Meeting
  150. {
  151. Name = request.Name,
  152. LocationId = room.LocationId,
  153. RoomId = room.Id,
  154. Description = request.Description,
  155. UserId = _loginContext.AccountId,
  156. FileIds = request.FileIds,
  157. UserIds = request.UserIds
  158. };
  159. meeting.Id = await _meetingRepository.InsertAsync(meeting);
  160. }
  161. else
  162. {
  163. meeting = await _meetingRepository.GetAsync(request.MeetingId);
  164. if (!string.IsNullOrWhiteSpace(request.Name))
  165. meeting.Name = request.Name;
  166. if (!string.IsNullOrWhiteSpace(request.Description))
  167. meeting.Description = request.Description;
  168. //删除参会人员
  169. await meetingSummaryTodoRepository.DeleteAsync(Q.Where(nameof(Entity.WorkMeeting.MeetingSummaryTodo.TypeId), 1).Where(nameof(Entity.WorkMeeting.MeetingSummaryTodo.MeetingSummaryId), request.MeetingId));
  170. //删除附件
  171. await flowAttachmentRepository.DeleteAsync(Q.Where(nameof(Entity.WorkFlow.FlowAttachment.TypeId), 2).Where(nameof(Entity.WorkFlow.FlowAttachment.FlowId), request.MeetingId));
  172. //删除会议时间
  173. if (request.Orders.Count > 0)
  174. await _meetingOrderRepository.DeleteAsync(Q.Where(nameof(Entity.WorkMeeting.MeetingOrder.MeetingId), request.MeetingId));
  175. }
  176. //创建附件
  177. foreach (var item in request.flowAttachments)
  178. {
  179. item.FlowId = meeting.Id;
  180. item.TypeId = 2;
  181. }
  182. await flowAttachmentRepository.InsertsAsync(request.flowAttachments);
  183. //新增关联
  184. var meetingSummaryTodos = new List<Entity.WorkMeeting.MeetingSummaryTodo>();
  185. var meetingSummaryTodo = new MeetingSummaryTodo();
  186. meetingSummaryTodo.UserId = _loginContext.AccountId;
  187. meetingSummaryTodo.TypeId = 1;
  188. meetingSummaryTodo.IsAdmin = true;
  189. meetingSummaryTodo.MeetingSummaryId = meeting.Id;
  190. meetingSummaryTodos.Add(meetingSummaryTodo);
  191. foreach (var item in request.UserIds)
  192. {
  193. meetingSummaryTodo = new MeetingSummaryTodo();
  194. meetingSummaryTodo.UserId = item;
  195. meetingSummaryTodo.IsAdmin = false;
  196. meetingSummaryTodo.TypeId = 1;
  197. meetingSummaryTodo.MeetingSummaryId = meeting.Id;
  198. meetingSummaryTodos.Add(meetingSummaryTodo);
  199. }
  200. await meetingSummaryTodoRepository.InsertsAsync(meetingSummaryTodos);
  201. DateTime? startDate = null;
  202. DateTime? endDate = null;
  203. foreach (var requestOrder in request.Orders)
  204. {
  205. if (startDate.HasValue)
  206. {
  207. if (requestOrder < startDate)
  208. {
  209. startDate = requestOrder;
  210. }
  211. }
  212. else
  213. {
  214. startDate = requestOrder;
  215. }
  216. if (endDate.HasValue)
  217. {
  218. if (requestOrder > endDate)
  219. {
  220. endDate = requestOrder;
  221. }
  222. }
  223. else
  224. {
  225. endDate = requestOrder;
  226. }
  227. var order = new MeetingOrder
  228. {
  229. RoomId = room.Id,
  230. MeetingId = meeting.Id,
  231. Date = StringUtils.GetDate(requestOrder),
  232. Hour = requestOrder.Hour
  233. };
  234. await _meetingOrderRepository.InsertAsync(order);
  235. }
  236. meeting.StartDateTime = startDate;
  237. meeting.EndDateTime = endDate;
  238. await _meetingRepository.UpdateAsync(meeting);
  239. return new DefaultResult
  240. {
  241. Value = true
  242. };
  243. }
  244. /// <summary>
  245. /// 删除会议纪要
  246. /// </summary>
  247. /// <param name="id"></param>
  248. /// <returns></returns>
  249. [HttpDelete("summary/{id}")]
  250. public async Task<bool> DeleteSummary(int id)
  251. {
  252. return await _meetingSummaryRepository.DeleteAsync(id);
  253. }
  254. /// <summary>
  255. /// 新增会议纪要
  256. /// </summary>
  257. /// <returns></returns>
  258. [HttpPost("summary")]
  259. public async Task<MeetingSummary> AddSummary([FromBody] MeetingSummaryRequest request)
  260. {
  261. var meeting = await _meetingRepository.GetAsync(request.MeetingId);
  262. var summary = new MeetingSummary
  263. {
  264. MeetingId = meeting.Id,
  265. RoomId = meeting.RoomId,
  266. UserId = _loginContext.AccountId,
  267. Title = request.Title,
  268. Content = request.Content,
  269. UserIds = request.UserIds
  270. };
  271. summary.Id = await _meetingSummaryRepository.InsertAsync(summary);
  272. //判断是不是新版通知
  273. if (request.AddresseeUserMiddles.Count > 0)
  274. {
  275. foreach (var item in request.AddresseeUserMiddles)
  276. {
  277. item.DataSourceId = summary.Id;
  278. item.MiddleType = GxPress.EnumConst.AllTypeConst.MeetingSummary.GetHashCode();
  279. }
  280. await _userMiddleService.AddUserMiddleAsync(request.AddresseeUserMiddles);
  281. //获取用户
  282. var users = await _userMiddleService.FindUsersAsync(request.AddresseeUserMiddles, _loginContext.AccountId);
  283. request.UserIds = users.Select(n => n.Id).ToList();
  284. }
  285. //新增关联
  286. var meetingSummaryTodos = new List<Entity.WorkMeeting.MeetingSummaryTodo>();
  287. var meetingSummaryTodo = new MeetingSummaryTodo();
  288. meetingSummaryTodo.UserId = _loginContext.AccountId;
  289. meetingSummaryTodo.IsAdmin = true;
  290. meetingSummaryTodo.TypeId = 2;
  291. meetingSummaryTodo.MeetingSummaryId = summary.Id;
  292. meetingSummaryTodos.Add(meetingSummaryTodo);
  293. foreach (var item in request.UserIds)
  294. {
  295. if (_loginContext.AccountId == item)
  296. continue;
  297. meetingSummaryTodo = new MeetingSummaryTodo();
  298. meetingSummaryTodo.UserId = item;
  299. meetingSummaryTodo.IsAdmin = false;
  300. meetingSummaryTodo.TypeId = 2;
  301. meetingSummaryTodo.MeetingSummaryId = summary.Id;
  302. meetingSummaryTodos.Add(meetingSummaryTodo);
  303. }
  304. await meetingSummaryTodoRepository.InsertsAsync(meetingSummaryTodos);
  305. return summary;
  306. }
  307. /// <summary>
  308. /// 获取会议纪要
  309. /// </summary>
  310. /// <param name="keyword"></param>
  311. /// <param name="typeId">0 是全部 1我发起 2 别人 </param>
  312. /// <param name="meetingId">会议ID</param>
  313. /// <param name="page">页码数</param>
  314. /// <param name="perPage">数量</param>
  315. /// <returns></returns>
  316. [HttpGet("summary/list")]
  317. [AllowAnonymous]
  318. public async Task<IEnumerable<MeetingSummaryResult>> ListSummary(string keyword, int typeId, int meetingId, int page = 1, int perPage = 10)
  319. {
  320. // var summaries = await _meetingSummaryRepository.GetListAsync(keyword, _loginContext.AccountId, typeId, meetingId, page, perPage);
  321. // var userId = _loginContext.AccountId;
  322. // var list = new List<MeetingSummaryResult>();
  323. // foreach (var summary in summaries)
  324. // {
  325. // var meeting = await _meetingRepository.GetAsync(summary.MeetingId);
  326. // if (meeting == null) continue;
  327. // var address = await _meetingLocationRepository.GetAddress(meeting.LocationId);
  328. // if (address == null) continue;
  329. // var userName = await _userRepository.GetNameAsync(summary.UserId);
  330. // if (!string.IsNullOrEmpty(keyword))
  331. // {
  332. // if (!summary.Title.Contains(keyword) && !summary.Content.Contains(keyword) &&
  333. // !userName.Contains(keyword) && !address.Contains(keyword))
  334. // {
  335. // continue;
  336. // }
  337. // }
  338. // var orderList = await _meetingOrderRepository.GetListByMeetingIdAsync(meeting.Id);
  339. // var meetingTimeDictionary = meetingService.GetMeetingTimeDictionary(orderList);
  340. // var meetingSummaryResult = new MeetingSummaryResult()
  341. // {
  342. // Id = summary.Id,
  343. // UserId = summary.UserId,
  344. // UserName = userName,
  345. // Title = summary.Title,
  346. // Content = summary.Content,
  347. // MeetingId = summary.MeetingId,
  348. // UserIds = summary.UserIds,
  349. // MeetingName = meeting.Name,
  350. // Address = address,
  351. // CreatedDate = summary.CreatedDate,
  352. // MeetingTimes = meetingTimeDictionary.Values.First()
  353. // };
  354. // list.Add(meetingSummaryResult);
  355. // }
  356. var summaries = await _meetingSummaryRepository.GetListMeetingSummaryResultAsync(keyword, _loginContext.AccountId, typeId, meetingId, page, perPage);
  357. foreach (var item in summaries)
  358. {
  359. var orderList = await _meetingOrderRepository.GetListByMeetingIdAsync(item.MeetingId);
  360. var meetingTimeDictionary = meetingService.GetMeetingTimeDictionary(orderList);
  361. item.MeetingTimes = meetingTimeDictionary.Values.First();
  362. }
  363. return summaries;
  364. }
  365. /// <summary>
  366. /// 修改会议纪要
  367. /// </summary>
  368. /// <returns></returns>
  369. [HttpPut("summary/{id}")]
  370. public async Task<MeetingSummary> EditSummary([FromRoute] int id, [FromBody] MeetingSummaryRequest request)
  371. {
  372. var summary = await _meetingSummaryRepository.GetAsync(id);
  373. summary.Title = request.Title;
  374. summary.Content = request.Content;
  375. summary.UserIds = request.UserIds;
  376. //获取新版
  377. if (request.AddresseeUserMiddles.Count > 0)
  378. {
  379. await _userMiddleService.DeleteAsync(Q.Where(nameof(Entity.UserMiddle.UserMiddle.MiddleType), GxPress.EnumConst.AllTypeConst.MeetingSummary.GetHashCode()).Where(nameof(Entity.UserMiddle.UserMiddle.DataSourceId), id));
  380. foreach (var item in request.AddresseeUserMiddles)
  381. {
  382. item.DataSourceId = id;
  383. item.MiddleType = GxPress.EnumConst.AllTypeConst.MeetingSummary.GetHashCode();
  384. }
  385. await _userMiddleService.AddUserMiddleAsync(request.AddresseeUserMiddles);
  386. var users = await _userMiddleService.FindUsersAsync(request.AddresseeUserMiddles, summary.UserId);
  387. request.UserIds = users.Select(n => n.Id).ToList();
  388. request.UserIds.Remove(summary.UserId);
  389. }
  390. //删除会议纪要关联用户
  391. await meetingSummaryTodoRepository.DeleteAsync(Q.Where(nameof(Entity.WorkMeeting.MeetingSummaryTodo.TypeId), 2).Where(nameof(Entity.WorkMeeting.MeetingSummaryTodo.MeetingSummaryId), id));
  392. //新增关联
  393. var meetingSummaryTodos = new List<Entity.WorkMeeting.MeetingSummaryTodo>();
  394. var meetingSummaryTodo = new MeetingSummaryTodo();
  395. meetingSummaryTodo.UserId = _loginContext.AccountId;
  396. meetingSummaryTodo.IsAdmin = true;
  397. meetingSummaryTodo.TypeId = 2;
  398. meetingSummaryTodo.MeetingSummaryId = summary.Id;
  399. meetingSummaryTodos.Add(meetingSummaryTodo);
  400. foreach (var item in request.UserIds)
  401. {
  402. meetingSummaryTodo = new MeetingSummaryTodo();
  403. meetingSummaryTodo.UserId = item;
  404. meetingSummaryTodo.IsAdmin = false;
  405. meetingSummaryTodo.TypeId = 2;
  406. meetingSummaryTodo.MeetingSummaryId = summary.Id;
  407. meetingSummaryTodos.Add(meetingSummaryTodo);
  408. }
  409. await meetingSummaryTodoRepository.InsertsAsync(meetingSummaryTodos);
  410. await _meetingSummaryRepository.UpdateAsync(summary);
  411. return summary;
  412. }
  413. /// <summary>
  414. /// 获取会议纪要详情
  415. /// </summary>
  416. /// <returns></returns>
  417. [HttpGet("summary/{id}")]
  418. public async Task<MeetingSummaryResult> GetSummary([FromRoute] int id)
  419. {
  420. var summary = await _meetingSummaryRepository.GetAsync(id);
  421. if (summary == null)
  422. throw new Common.Exceptions.BusinessException("会议纪要不存在");
  423. var meeting = await _meetingRepository.GetAsync(summary.MeetingId);
  424. var address = await _meetingLocationRepository.GetAddress(meeting.LocationId);
  425. //获取新版
  426. var addresseeUserMiddles = await _userMiddleService.FindUserMiddlesAsync(GxPress.EnumConst.AllTypeConst.MeetingSummary.GetHashCode(), id);
  427. var meetingSummaryResult = new MeetingSummaryResult
  428. {
  429. Id = summary.Id,
  430. UserId = summary.UserId,
  431. UserName = await _userRepository.GetNameAsync(summary.UserId),
  432. Title = summary.Title,
  433. Content = summary.Content,
  434. MeetingId = summary.MeetingId,
  435. UserIds = summary.UserIds,
  436. MeetingName = meeting.Name,
  437. Address = address,
  438. CreatedDate = summary.CreatedDate,
  439. AddresseeUserMiddles = addresseeUserMiddles.ToList()
  440. };
  441. //是否是自己创建
  442. meetingSummaryResult.IsAdmin = _loginContext.AccountId == summary.UserId;
  443. var analyzeRequest = new Request.App.Analyze.AnalyzeRequest();
  444. analyzeRequest.TypeValue = GxPress.EnumConst.AllTypeConst.MeetingSummary.GetHashCode();
  445. analyzeRequest.AnalyzeType = 1;
  446. analyzeRequest.SourceId = meetingSummaryResult.Id;
  447. analyzeRequest.UserId = _loginContext.AccountId;
  448. //点赞数量
  449. meetingSummaryResult.PraiseCount = await _analyzeService.CountAsync(analyzeRequest);
  450. //获取话题的评论数量
  451. var commentCount =
  452. await _commentRepository.CountAsync(Q.Where(nameof(Entity.Comment.ArticleId), meetingSummaryResult.Id).Where(nameof(Entity.Comment.TypeValue), analyzeRequest.TypeValue).Where(nameof(Entity.Comment.Pid), 0));
  453. meetingSummaryResult.CommentCount = commentCount;
  454. //获取话题的转发数量
  455. analyzeRequest.AnalyzeType = 4;
  456. var retransmissionCount = await _analyzeService.CountAsync(analyzeRequest);
  457. meetingSummaryResult.RetransmissionCount = retransmissionCount;
  458. meetingSummaryResult.IsRetransmission = await _analyzeService.ExistsAsync(analyzeRequest);
  459. //获取话题的收藏数量
  460. analyzeRequest.AnalyzeType = 3;
  461. var collectCount = await _analyzeService.CountAsync(analyzeRequest);
  462. meetingSummaryResult.CollectCount = collectCount;
  463. //是否收藏
  464. meetingSummaryResult.IsCollect = await _analyzeService.ExistsAsync(analyzeRequest);
  465. //获取话题的点赞数量
  466. analyzeRequest.AnalyzeType = 1;
  467. var praiseCount = await _analyzeService.CountAsync(analyzeRequest);
  468. meetingSummaryResult.PraiseCount = praiseCount;
  469. //是否点赞
  470. meetingSummaryResult.IsPraise = await _analyzeService.ExistsAsync(analyzeRequest);
  471. //获取点赞数据
  472. var request = new PraisePageSearchRequest { SourceId = id, TypeValue = analyzeRequest.TypeValue, Page = 1, PerPage = 3 };
  473. meetingSummaryResult.PraisePagedList = await _analyzeService.GetPraisePageAsync(request);
  474. return meetingSummaryResult;
  475. }
  476. /// <summary>
  477. /// 获取会议纪要详情 web专属
  478. /// </summary>
  479. /// <returns></returns>
  480. [HttpGet("summary/web/{id}")]
  481. [AllowAnonymous]
  482. public async Task<MeetingSummaryResult> GetWebSummary([FromRoute] int id)
  483. {
  484. var summary = await _meetingSummaryRepository.GetAsync(id);
  485. var meeting = await _meetingRepository.GetAsync(summary.MeetingId);
  486. var address = await _meetingLocationRepository.GetAddress(meeting.LocationId);
  487. //获取新版
  488. var addresseeUserMiddles = await _userMiddleService.FindUserMiddlesAsync(400, id);
  489. var meetingSummaryResult = new MeetingSummaryResult
  490. {
  491. Id = summary.Id,
  492. UserId = summary.UserId,
  493. UserName = await _userRepository.GetNameAsync(summary.UserId),
  494. Title = summary.Title,
  495. Content = summary.Content,
  496. MeetingId = summary.MeetingId,
  497. UserIds = summary.UserIds,
  498. MeetingName = meeting.Name,
  499. Address = address,
  500. CreatedDate = summary.CreatedDate,
  501. AddresseeUserMiddles = addresseeUserMiddles.ToList()
  502. };
  503. var analyzeRequest = new Request.App.Analyze.AnalyzeRequest();
  504. return meetingSummaryResult;
  505. }
  506. /// <summary>
  507. /// 获取我的会议
  508. /// </summary>
  509. /// <param name="keyword"></param>
  510. /// <returns></returns>
  511. [HttpGet("current")]
  512. public async Task<IEnumerable<MeetingResult>> ListCurrentMeeting([FromQuery] string keyword)
  513. {
  514. var meetings = await _meetingRepository.GetCurrentListAsync(_loginContext.AccountId, keyword);
  515. var list = new List<MeetingResult>();
  516. foreach (var meeting in meetings)
  517. {
  518. //获取会议房间
  519. var room = await _meetingRoomRepository.GetAsync(meeting.RoomId);
  520. var address = await _meetingLocationRepository.GetAddress(meeting.LocationId);
  521. var orderList = await _meetingOrderRepository.GetListByMeetingIdAsync(meeting.Id);
  522. var orders = new SortedDictionary<string, List<int>>();
  523. foreach (var meetingOrder in orderList)
  524. {
  525. var data = meetingOrder.Date.ToString().Insert(4, "-").Insert(7, "-");
  526. var key = StringUtils.GetDate(Convert.ToDateTime(data)).ToString();
  527. if (orders.TryGetValue(key, out var hourList))
  528. {
  529. hourList.Add(meetingOrder.Hour);
  530. }
  531. else
  532. {
  533. orders[key] = new List<int>
  534. {
  535. meetingOrder.Hour
  536. };
  537. }
  538. }
  539. var meetingTimeDictionary = meetingService.GetMeetingTimeDictionary(orderList);
  540. //状态
  541. var status = 0;
  542. var meetingTimeList = meetingTimeDictionary.Keys.First();
  543. if (meetingTimeList.Count > 0)
  544. {
  545. var meetingTime = meetingTimeList.FirstOrDefault();
  546. var TimeValuelast = meetingTime.TimeValues.Last();
  547. var data = meetingTime.TimeKey.ToString().Insert(4, "-").Insert(7, "-");
  548. var key = Convert.ToDateTime(data).AddHours(TimeValuelast);
  549. if (key < DateTime.Now)
  550. status = 1;
  551. }
  552. list.Add(new MeetingResult
  553. {
  554. Id = meeting.Id,
  555. UserId = meeting.UserId,
  556. UserName = await _userRepository.GetNameAsync(meeting.UserId),
  557. Name = meeting.Name,
  558. Description = meeting.Description,
  559. UserIds = meeting.UserIds,
  560. Address = address,
  561. OrderList = meetingTimeDictionary.Keys.First(),
  562. MeetingTimes = meetingTimeDictionary.Values.First(),
  563. Status = status,
  564. CreatedDate = meeting.CreatedDate,
  565. RoomName = room == null ? "" : room.Name,
  566. Orders = orders
  567. });
  568. }
  569. return list;
  570. }
  571. /// <summary>
  572. /// 获取历史会议
  573. /// </summary>
  574. /// <returns></returns>
  575. [HttpGet("history")]
  576. public async Task<IEnumerable<MeetingResult>> ListHistoryMeeting([FromQuery] string keyword, int page = 1, int perPage = 10)
  577. {
  578. var meetings = await _meetingRepository.GetHistoryListAsync(_loginContext.AccountId, keyword, page, perPage);
  579. var list = new List<MeetingResult>();
  580. foreach (var meeting in meetings)
  581. {
  582. var address = await _meetingLocationRepository.GetAddress(meeting.LocationId);
  583. //获取会议房间
  584. var room = await _meetingRoomRepository.GetAsync(meeting.RoomId);
  585. var orderList = await _meetingOrderRepository.GetListByMeetingIdAsync(meeting.Id);
  586. var orders = new SortedDictionary<string, List<int>>();
  587. foreach (var meetingOrder in orderList)
  588. {
  589. var key = StringUtils.GetDate(meetingOrder.CreatedDate).ToString();
  590. if (orders.TryGetValue(key, out var hourList))
  591. {
  592. hourList.Add(meetingOrder.Hour);
  593. }
  594. else
  595. {
  596. orders[key] = new List<int>
  597. {
  598. meetingOrder.Hour
  599. };
  600. }
  601. }
  602. var meetingTimeDictionary = meetingService.GetMeetingTimeDictionary(orderList);
  603. var meetingTimes = meetingTimeDictionary.Values.First();
  604. //状态
  605. var status = 0;
  606. var meetingTimeList = meetingTimeDictionary.Keys.First();
  607. if (meetingTimeList.Count > 0)
  608. {
  609. var meetingTime = meetingTimeList.FirstOrDefault();
  610. var TimeValuelast = meetingTime.TimeValues.Last();
  611. var data = meetingTime.TimeKey.ToString().Insert(4, "-").Insert(7, "-");
  612. var key = Convert.ToDateTime(data).AddHours(TimeValuelast);
  613. if (key < DateTime.Now)
  614. status = 1;
  615. }
  616. list.Add(new MeetingResult
  617. {
  618. Id = meeting.Id,
  619. UserId = meeting.UserId,
  620. UserName = await _userRepository.GetNameAsync(meeting.UserId),
  621. Name = meeting.Name,
  622. Description = meeting.Description,
  623. UserIds = meeting.UserIds,
  624. Address = address,
  625. CreatedDate = meeting.CreatedDate,
  626. MeetingTimes = meetingTimes,
  627. RoomName = room == null ? "" : room.Name,
  628. Orders = orders,
  629. Status = 1
  630. });
  631. }
  632. return list;
  633. }
  634. /// <summary>
  635. /// 获取会议详情
  636. /// </summary>
  637. /// <returns></returns>
  638. [HttpGet("{id}")]
  639. public async Task<MeetingResult> GetMeeting([FromRoute] int id)
  640. {
  641. var meeting = await _meetingRepository.GetAsync(id);
  642. var room = await _meetingRoomRepository.GetAsync(meeting.RoomId);
  643. var address = await _meetingLocationRepository.GetAddress(meeting.LocationId);
  644. //获取当前会议时间段
  645. var orderList = await _meetingOrderRepository.GetListByMeetingIdAsync(id);
  646. var orders = new SortedDictionary<string, List<int>>();
  647. foreach (var meetingOrder in orderList)
  648. {
  649. var key = StringUtils.GetDate(meetingOrder.CreatedDate).ToString();
  650. if (orders.TryGetValue(key, out var hourList))
  651. {
  652. hourList.Add(meetingOrder.Hour);
  653. }
  654. else
  655. {
  656. orders[key] = new List<int>
  657. {
  658. meetingOrder.Hour
  659. };
  660. }
  661. }
  662. //获取会议上传的文件流
  663. var flowAttachments = await flowAttachmentRepository.GetAllAsync(Q.Where(nameof(Entity.WorkFlow.FlowAttachment.TypeId), 2).Where(nameof(Entity.WorkFlow.FlowAttachment.FlowId), id).OrderByDesc(nameof(Entity.WorkFlow.FlowAttachment.CreatedDate)));
  664. var meetingTimeDictionary = meetingService.GetMeetingTimeDictionary(orderList);
  665. #region //获取当前房间的所有时间
  666. var orderLists = new List<TimeDictionary>();
  667. var orderAllList = await _meetingOrderRepository.GetListAsyncSinceNow(room.Id);
  668. //新版
  669. foreach (var item in orderAllList)
  670. {
  671. if (orderLists.Any(n => n.TimeKey == item.Date.ToString()))
  672. continue;
  673. var timeDictionary = new TimeDictionary();
  674. timeDictionary.TimeKey = item.Date.ToString();
  675. foreach (var date in orderAllList.Where(n => n.Date == item.Date).OrderBy(n => n.Hour).Select(n => n.Hour).Distinct().ToList())
  676. {
  677. timeDictionary.TimeValues.Add(date);
  678. timeDictionary.NewTimeValues.Add(new TimeValue { Key = date, Value = item.UserName });
  679. }
  680. orderLists.Add(timeDictionary);
  681. }
  682. #endregion
  683. #region 参会人员
  684. var meetingUsersRequest = new MeetingUsersRequest();
  685. meetingUsersRequest.MeetingId = id;
  686. var meetingUserResults = await _meetingRepository.GetUserByMeeting(meetingUsersRequest);
  687. #endregion
  688. return new MeetingResult
  689. {
  690. Id = meeting.Id,
  691. UserId = meeting.UserId,
  692. UserName = await _userRepository.GetNameAsync(meeting.UserId),
  693. Name = meeting.Name,
  694. Description = meeting.Description,
  695. UserIds = meeting.UserIds,
  696. Address = address,
  697. CreatedDate = meeting.CreatedDate,
  698. ImageUrl = room.ImageUrl,
  699. OrderList = meetingTimeDictionary.Keys.First(),
  700. OrderAllList = orderLists,
  701. Orders = orders,
  702. MeetingRoom = room,
  703. FlowAttachments = flowAttachments.ToList(),
  704. MeetingTimes = meetingTimeDictionary.Values.First(),
  705. MeetingUserResults = meetingUserResults,
  706. Disabled = room.Disabled,
  707. Status = meeting.EndDateTime < DateTime.Now ? 1 : 0
  708. };
  709. }
  710. /// <summary>
  711. /// 取消预定
  712. /// </summary>
  713. /// <returns></returns>
  714. [HttpPost("{id}/actions/cancel")]
  715. public async Task<DefaultResult> Cancel([FromRoute] int id)
  716. {
  717. await _meetingRepository.DeleteAsync(id);
  718. return new DefaultResult
  719. {
  720. Value = true
  721. };
  722. }
  723. /// <summary>
  724. /// 获取用户
  725. /// </summary>
  726. /// <returns></returns>
  727. [HttpPost("actions/users")]
  728. public async Task<IEnumerable<MeetingUserResult>> GetUsers([FromBody] MeetingUsersRequest request)
  729. {
  730. return await _meetingRepository.GetUserByMeeting(request);
  731. }
  732. }
  733. }