李昊 il y a 4 ans
Parent
commit
c4305e2fd8

+ 25 - 12
GxPress/Api/GxPress.Api/AppControllers/AppMeetingController.cs

@@ -86,7 +86,7 @@ namespace GxPress.Api.AppControllers
         /// </summary>
         /// <returns></returns>
         [HttpGet("rooms/{id}")]
-        public async Task<MeetingRoomResult> RoomGet([FromRoute]int id)
+        public async Task<MeetingRoomResult> RoomGet([FromRoute] int id)
         {
             var room = await _meetingRoomRepository.GetAsync(id);
             room.Address = await _meetingLocationRepository.GetAddress(room.LocationId);
@@ -114,14 +114,21 @@ namespace GxPress.Api.AppControllers
             }
             var orderLists = new List<TimeDictionary>();
             //新版
-            foreach (var item in orderList.Select(n => n.Date).Distinct())
+            foreach (var item in orderList)
             {
-                var timeDictionary = new TimeDictionary();
-                timeDictionary.TimeKey = item.ToString();
-                timeDictionary.TimeValues = orderList.Where(n => n.Date == item).Select(n => n.Hour).Distinct().ToList();
+                if (orderLists.Any(n => n.TimeKey == item.Date.ToString()))
+                    continue;
+                var timeDictionary = new TimeDictionary()
+                {
+                    TimeKey = item.Date.ToString(),
+                };
+                foreach (var data in orderList.Where(n => n.Date == Convert.ToInt32(item.Date)).Distinct().ToList())
+                {
+                    timeDictionary.TimeValues.Add(data.Hour);
+                    timeDictionary.NewTimeValues.Add(new TimeValue { Key = data.Hour, Value = data.UserName });
+                }
                 orderLists.Add(timeDictionary);
             }
-
             return new MeetingRoomResult
             {
                 RoomName = room.Name,
@@ -136,7 +143,7 @@ namespace GxPress.Api.AppControllers
         /// </summary>
         /// <returns></returns>
         [HttpPost("rooms/{id}/actions/order")]
-        public async Task<DefaultResult> Order([FromRoute]int id, [FromBody] MeetingOrderRequest request)
+        public async Task<DefaultResult> Order([FromRoute] int id, [FromBody] MeetingOrderRequest request)
         {
             var room = await _meetingRoomRepository.GetAsync(id);
             var meeting = new Meeting();
@@ -682,11 +689,17 @@ namespace GxPress.Api.AppControllers
             var orderLists = new List<TimeDictionary>();
             var orderAllList = await _meetingOrderRepository.GetListAsyncSinceNow(room.Id);
             //新版
-            foreach (var item in orderAllList.Select(n => n.Date).Distinct())
+            foreach (var item in orderAllList)
             {
+                if (orderLists.Any(n => n.TimeKey == item.Date.ToString()))
+                    continue;
                 var timeDictionary = new TimeDictionary();
-                timeDictionary.TimeKey = item.ToString();
-                timeDictionary.TimeValues = orderAllList.Where(n => n.Date == item).OrderBy(n => n.Hour).Select(n => n.Hour).Distinct().ToList();
+                timeDictionary.TimeKey = item.Date.ToString();
+                foreach (var date in orderAllList.Where(n => n.Date == item.Date).OrderBy(n => n.Hour).Select(n => n.Hour).Distinct().ToList())
+                {
+                    timeDictionary.TimeValues.Add(date);
+                    timeDictionary.NewTimeValues.Add(new TimeValue { Key = date, Value = item.UserName });
+                }
                 orderLists.Add(timeDictionary);
             }
             #endregion
@@ -723,7 +736,7 @@ namespace GxPress.Api.AppControllers
         /// </summary>
         /// <returns></returns>
         [HttpPost("{id}/actions/cancel")]
-        public async Task<DefaultResult> Cancel([FromRoute]int id)
+        public async Task<DefaultResult> Cancel([FromRoute] int id)
         {
             await _meetingRepository.DeleteAsync(id);
 
@@ -738,7 +751,7 @@ namespace GxPress.Api.AppControllers
         /// </summary>
         /// <returns></returns>
         [HttpPost("actions/users")]
-        public async Task<IEnumerable<MeetingUserResult>> GetUsers([FromBody]MeetingUsersRequest request)
+        public async Task<IEnumerable<MeetingUserResult>> GetUsers([FromBody] MeetingUsersRequest request)
         {
             return await _meetingRepository.GetUserByMeeting(request);
         }

+ 18 - 0
GxPress/Model/GxPress.Request/App/WorkMeeting/MeetingRoomResult.cs

@@ -48,5 +48,23 @@ namespace GxPress.Request.App.WorkMeeting
         /// </summary>
         /// <value></value>
         public List<int> TimeValues { get; set; }
+        /// <summary>
+        /// 时间
+        /// </summary>
+        /// <value></value>
+        public List<TimeValue> NewTimeValues { get; set; }
+    }
+    public class TimeValue
+    {
+        /// <summary>
+        /// 小时
+        /// </summary>
+        /// <value></value>
+        public int Key { get; set; }
+        /// <summary>
+        /// 用户名称
+        /// </summary>
+        /// <value></value>
+        public string Value { get; set; }
     }
 }

+ 40 - 0
GxPress/Model/GxPress.Result/Meeting/MeetingOrderResult.cs

@@ -0,0 +1,40 @@
+namespace GxPress.Result.Meeting
+{
+    public class MeetingOrderResult
+    {
+         /// <summary>
+        /// 用户Id
+        /// </summary>
+
+        public int UserId { get; set; }
+
+        /// <summary>
+        /// 会议室Id
+        /// </summary>
+
+        public int RoomId { get; set; }
+
+        /// <summary>
+        /// 会议Id
+        /// </summary>
+
+        public int MeetingId { get; set; }
+
+        /// <summary>
+        /// 预定时段
+        /// </summary>
+
+        public int Date { get; set; }
+
+        /// <summary>
+        /// 预定时段
+        /// </summary>
+
+        public int Hour { get; set; }
+        /// <summary>
+        /// 用户名称
+        /// </summary>
+        /// <value></value>
+        public string UserName { get; set; }
+    }
+}

+ 16 - 5
GxPress/Repository/GxPress.Repository.Implement/WorkMeeting/MeetingOrderRepository.cs

@@ -1,11 +1,13 @@
 using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using Dapper;
 using Datory;
 using GxPress.Common.AppOptions;
 using GxPress.Common.Tools;
 using GxPress.Entity.WorkMeeting;
 using GxPress.Repository.Interface.WorkMeeting;
+using GxPress.Result.Meeting;
 using Microsoft.Extensions.Caching.Distributed;
 using Microsoft.Extensions.Options;
 using SqlKata;
@@ -42,12 +44,21 @@ namespace GxPress.Repository.Implement.WorkMeeting
             return await _repository.GetAllAsync(Q.Where(nameof(MeetingOrder.MeetingId), meetingId).OrderByDesc(nameof(MeetingOrder.Date)));
         }
 
-        public async Task<IEnumerable<MeetingOrder>> GetListAsyncSinceNow(int roomId)
+        public async Task<IEnumerable<MeetingOrderResult>> GetListAsyncSinceNow(int roomId)
         {
-            return await _repository.GetAllAsync(Q
-                .Where(nameof(MeetingOrder.Date), ">=",
-                StringUtils.GetDate(DateTime.Now)).Where(nameof(MeetingOrder.RoomId), roomId)
-            );
+            string sql = $@"SELECT 
+                                a.*,c.Id as UserId,c.Name as UserName
+                            FROM
+                                tede_meeting_order a
+                                    INNER JOIN
+                                tede_meeting b ON a.MeetingId = b.Id
+                                    INNER JOIN
+                                tede_user c ON c.Id = b.UserId
+                            WHERE
+                                a.RoomId ={roomId} AND a.Date >= date_format(NOW() , '%Y%m%d')";
+            var database = new Database(DatabaseType.MySql, ConfigHelper.GetValue("Database:ConnectionString"));
+            var connection = database.GetConnection();
+            return await connection.QueryAsync<MeetingOrderResult>(sql);
         }
 
 

+ 2 - 1
GxPress/Repository/GxPress.Repository.Interface/WorkMeeting/IMeetingOrderRepository.cs

@@ -4,6 +4,7 @@ using GxPress.Entity.WorkFlow;
 using GxPress.Request.App.Flow;
 using Datory;
 using GxPress.Entity.WorkMeeting;
+using GxPress.Result.Meeting;
 
 namespace GxPress.Repository.Interface.WorkMeeting
 {
@@ -15,7 +16,7 @@ namespace GxPress.Repository.Interface.WorkMeeting
 
         Task<IEnumerable<MeetingOrder>> GetListByMeetingIdAsync(int meetingId);
 
-        Task<IEnumerable<MeetingOrder>> GetListAsyncSinceNow(int roomId);
+        Task<IEnumerable<MeetingOrderResult>> GetListAsyncSinceNow(int roomId);
 
         Task<bool> DeleteAsync(int orderId);
         Task<bool> DeleteAsync(SqlKata.Query query);

+ 11 - 6
GxPress/Service/GxPress.Service.Implement/Meeting/MeetingService.cs

@@ -58,14 +58,19 @@ namespace GxPress.Service.Implement.Meeting
             Dictionary<List<TimeDictionary>, List<MeetingTime>> result = new Dictionary<List<TimeDictionary>, List<MeetingTime>>();
             var orderLists = new List<TimeDictionary>();
             List<MeetingTime> meetingTimes = new List<MeetingTime>();
-            //
-            var dataList = orderList.OrderByDescending(n => n.Date).Select(n => n.Date).Distinct();
             //新版
-            foreach (var item in dataList)
+            foreach (var item in orderList)
             {
+                if (orderLists.Any(n => n.TimeKey == item.Date.ToString()))
+                    continue;
                 var timeDictionary = new TimeDictionary();
-                timeDictionary.TimeKey = item.ToString();
-                timeDictionary.TimeValues = orderList.Where(n => n.Date == item).OrderBy(n => n.Hour).Select(n => n.Hour).Distinct().ToList();
+                timeDictionary.TimeKey = item.Date.ToString();
+                var timeValues = orderList.Where(n => n.Date == item.Date).OrderBy(n => n.Hour).Select(n => n.Hour).Distinct().ToList();
+                foreach (var timeValue in timeValues)
+                {
+                    timeDictionary.TimeValues.Add(timeValue);
+                    timeDictionary.NewTimeValues.Add(new TimeValue { Key = timeValue, Value = "" });
+                }
                 orderLists.Add(timeDictionary);
                 //获取相邻的
                 var nearTimeDictionary = GetDictionary(timeDictionary.TimeValues);
@@ -87,7 +92,7 @@ namespace GxPress.Service.Implement.Meeting
                     meetingTime.WeekValue = week;
                     //获取相邻的数据集
                     meetingTime.BeginHour = ntd.Value.First();
-                    meetingTime.EndHour = ntd.Value.Last()+1;
+                    meetingTime.EndHour = ntd.Value.Last() + 1;
                     meetingTimes.Add(meetingTime);
                 }
             }