AppMeetingController.cs 34 KB

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