Explorar o código

处理配置冲突

TANG JIANG %!s(int64=2) %!d(string=hai) anos
pai
achega
b032475b70

+ 32 - 0
src/Hotline.Api/Controllers/PbxController.cs

@@ -532,6 +532,38 @@ namespace Hotline.Api.Controllers
 
         #endregion
 
+        #region 静音和取消静音
+
+        /// <summary>
+        /// 静音
+        /// </summary>
+        /// <returns></returns>
+        [Permission(EPermission.Mute)]
+        [HttpGet("mute")]
+        public async Task Mute()
+        {
+            var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
+            if (work is null)
+                throw UserFriendlyException.SameMessage("当前坐席暂未进行工作");
+            await _deviceManager.MuteAsync(work.TelNo, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 取消静音
+        /// </summary>
+        /// <returns></returns>
+        [Permission(EPermission.UnMute)]
+        [HttpGet("unmute")]
+        public async Task UnMute()
+        {
+            var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
+            if (work is null)
+                throw UserFriendlyException.SameMessage("当前坐席暂未进行工作");
+            await _deviceManager.UnMuteAsync(work.TelNo, HttpContext.RequestAborted);
+        }
+
+        #endregion
+
         #endregion
     }
 }

+ 1 - 0
src/Hotline.Api/Hotline.Api.csproj

@@ -17,6 +17,7 @@
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.10" />
     <PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="6.0.8" />
     <PackageReference Include="Serilog.Sinks.Exceptionless" Version="3.1.5" />
+    <PackageReference Include="Serilog.Sinks.MongoDB" Version="5.3.1" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
     <PackageReference Include="XF.Utility.AppIdentityModel" Version="1.0.2" />
   </ItemGroup>

+ 14 - 0
src/Hotline.Api/Permissions/EPermission.cs

@@ -525,6 +525,20 @@ namespace Hotline.Permissions
         TelPanel = 999125,
 
         #endregion
+
+        #region 静音和取消静音
+        /// <summary>
+        /// 静音
+        /// </summary>
+        [Display(GroupName ="公用",Name ="静音",Description ="静音")]
+        Mute = 999126,
+        /// <summary>
+        /// 取消静音
+        /// </summary>
+        [Display(GroupName ="公用",Name ="取消静音",Description ="取消静音")]
+        UnMute = 999127,
+        #endregion
+
         #endregion
     }
 }

+ 2 - 1
src/Hotline.Api/Realtimes/CallCenterHub.cs

@@ -29,7 +29,8 @@ public class CallCenterHub : Hub
     public override async Task OnConnectedAsync()
     {
         var userId = _sessionContext.RequiredUserId;
-        var work = await _workRepository.GetCurrentWorkByUserAsync(userId, Context.ConnectionAborted);
+        //var work = await _workRepository.GetCurrentWorkByUserAsync(userId, Context.ConnectionAborted);
+        var work = _userCacheManager.GetWorkByUser(userId);
         if (work == null)
             throw new UserFriendlyException($"未查询到上班记录, userId: {userId}");
         work.SignalRId = Context.ConnectionId;

+ 5 - 4
src/Hotline.Api/appsettings.Development.json

@@ -28,14 +28,14 @@
       },
       {
         "Name": "Exceptionless"
-      }
+      },
       //{
       //  "Name": "File",
       //  "Args": {
       //    "path": "logs/log-.txt",
       //    "rollingInterval": "Day"
       //  }
-      //}
+      //},
     ],
     "Enrich": [ "FromLogContext", "WithSpan" ]
   },
@@ -45,11 +45,12 @@
     "Authorize": true,
     "ReceiveKey": "E1BBD1BB-A269-44",
     "SendKey": "2A-BA92-160A3B1D",
-    "Expired": 86400 //认证过期时间(秒)
+    "Expired": 1440 //认证过期时间(秒)
   },
   "ConnectionStrings": {
     "Hotline": "server=db.fengwo.com;Database=hotline;Uid=dev;Pwd=fengwo11!!;SslMode=none;",
-    "Redis": "192.168.100.223:6379"
+    "Redis": "192.168.100.223:6379",
+    "MongoDB": "mongodb://192.168.100.121:27017"
   },
   "Swagger": true,
   "Cors": {

+ 17 - 8
src/Hotline.Api/appsettings.json

@@ -26,9 +26,6 @@
           "theme": "Serilog.Sinks.SystemConsole.Themes.ConsoleTheme::None, Serilog.Sinks.Console"
         }
       },
-      {
-        "Name": "Exceptionless"
-      }
       //{
       //  "Name": "Exeptionless",
       //  "Args": {
@@ -43,7 +40,18 @@
       //    "path": "logs/log-.txt",
       //    "rollingInterval": "Day"
       //  }
-      //}
+      //},
+      {
+        "Name": "MongoDBBson",
+        "Args": {
+          "databaseUrl": "mongodb://192.168.100.121:27017/hotline_logs",
+          "collectionName": "logs",
+          "cappedMaxSizeMb": "1024",
+          "cappedMaxDocuments": "50000",
+          "rollingInterval": "Month",
+          "outputTemplate": "[{Timestamp:HH:mm:ss} {Level}] {SourceContext} [{TraceId}]{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}"
+        }
+      } 
     ],
     "Enrich": [ "FromLogContext", "WithSpan" ]
   },
@@ -53,11 +61,12 @@
     "Authorize": true,
     "ReceiveKey": "E1BBD1BB-A269-44",
     "SendKey": "2A-BA92-160A3B1D",
-    "Expired": 86400 //认证过期时间(秒)
+    "Expired": 1440 //认证过期时间(秒)
   },
   "ConnectionStrings": {
-    "Hotline": "server=db.fengwo.com;Database=hotline;Uid=dev;Pwd=fengwo11!!;SslMode=none;",
-    "Redis": "192.168.100.223:6379"
+    "Hotline": "server=192.168.100.121;port=3306;Database=hotline;Uid=dev;Pwd=fengwo11!!;SslMode=none;",
+    "Redis": "192.168.100.223:6379",
+    "MongoDB": "mongodb://192.168.100.121:27017"
   },
   "Swagger": true,
   "Cors": {
@@ -73,7 +82,7 @@
     "RestCategory": "08daa5f5-ac7a-4ced-8295-1c78baa15f9e"
   },
   "Exceptionless": {
-    "InUse": true,
+    "InUse": false,
     "ServerUrl": "http://log.fw.com",
     "ApiKey": "zrSsxjdFC1Uv2WBckZn3RYxjpKKdxfYAN50aFiuV"
   },

+ 1 - 1
src/Hotline/Orders/Order.cs

@@ -7,7 +7,7 @@ namespace Hotline.Orders
     /// <summary>
     /// 工单
     /// </summary>
-    public partial class Order : PositionEntity
+    public partial class Order : PositionWorkflowEntity
     {
         #region 来电信息
 

+ 16 - 2
src/XF.Domain.Repository/Entity.cs

@@ -121,7 +121,7 @@ public abstract class CreationModificationEntity : CreationEntity, IHasModificat
 /// <summary>
 /// 全状态实体(创建时间、更新时间、软删除)
 /// </summary>
-public abstract class FullStateEntity : CreationSoftDeleteEntity, IHasModificationTime, IWorkflow
+public abstract class FullStateEntity : CreationSoftDeleteEntity, IHasModificationTime
 {
     /// <summary>
     /// 最近更新时间
@@ -130,7 +130,10 @@ public abstract class FullStateEntity : CreationSoftDeleteEntity, IHasModificati
     public DateTime? LastModificationTime { get; set; }
 
     public void Modified() => LastModificationTime = DateTime.Now;
+}
 
+public abstract class WorkflowEntity : FullStateEntity, IWorkflow
+{
     [SugarColumn(IsNullable = true)]
     public string? WorkflowId { get; set; }
 
@@ -141,7 +144,7 @@ public abstract class FullStateEntity : CreationSoftDeleteEntity, IHasModificati
     public List<string> AssignUserIds { get; set; } = new();
 }
 
-public class PositionEntity : FullStateEntity
+public abstract class PositionEntity : FullStateEntity
 {
     /// <summary>
     /// 经度
@@ -177,3 +180,14 @@ public class PositionEntity : FullStateEntity
     public string Address => $"{Province ?? string.Empty}{City ?? string.Empty}{County ?? string.Empty}{Street ?? string.Empty}";
 }
 
+public abstract class PositionWorkflowEntity : PositionEntity, IWorkflow
+{
+    [SugarColumn(IsNullable = true)]
+    public string? WorkflowId { get; set; }
+
+    [SugarColumn(ColumnDataType = "varchar(4000)", IsJson = true)]
+    public List<string> AssignDepCodes { get; set; } = new();
+
+    [SugarColumn(ColumnDataType = "varchar(4000)", IsJson = true)]
+    public List<string> AssignUserIds { get; set; } = new();
+}