Explorar el Código

地市基础信息配置

田爽 hace 7 meses
padre
commit
a647a539d2

+ 19 - 17
src/Hotline.Api/Controllers/OrderController.cs

@@ -133,8 +133,9 @@ public class OrderController : BaseController
     private readonly IOrderAnalysisApplication _orderAnalysisApplication;
     private readonly ICalcExpireTime _expireTime;
     private readonly IRepository<OrderPushType> _orderPushTypeRepository;
+    private readonly IOptions<CityBaseConfiguration> _cityBaseConfiguration;
 
-    public OrderController(
+	public OrderController(
         IOrderDomainService orderDomainService,
         IOrderRepository orderRepository,
         IWorkflowApplication workflowApplication,
@@ -193,7 +194,8 @@ public class OrderController : BaseController
         Publisher publisher,
         IOrderAnalysisApplication orderAnalysisApplication,
         ICalcExpireTime expireTime,
-        IRepository<OrderPushType> orderPushTypeRepository)
+        IRepository<OrderPushType> orderPushTypeRepository,
+        IOptions<CityBaseConfiguration> cityBaseConfiguration)
     {
         _orderDomainService = orderDomainService;
         _orderRepository = orderRepository;
@@ -254,8 +256,8 @@ public class OrderController : BaseController
         _orderAnalysisApplication = orderAnalysisApplication;
         _expireTime = expireTime;
         _orderPushTypeRepository = orderPushTypeRepository;
-
-    }
+        _cityBaseConfiguration = cityBaseConfiguration;
+	}
     #endregion 
 
     #region 工单发布
@@ -2282,7 +2284,7 @@ public class OrderController : BaseController
             }
 
             //推省上
-            if (!string.IsNullOrEmpty(model.Id) && ("001171".Equals(model.OrgId) || "001178".Equals(model.OrgId)))
+            if (!string.IsNullOrEmpty(model.Id) && (_cityBaseConfiguration.Value.CityProvince.OrgId.Equals(model.OrgId) || _cityBaseConfiguration.Value.CityProvinceAssign.OrgId.Equals(model.OrgId)))
             {
                 var orderDto = _mapper.Map<OrderDto>(order);
                 var supervise = await _orderSuperviseRepository.GetAsync(x => x.Id == model.Id);
@@ -2527,7 +2529,7 @@ public class OrderController : BaseController
             }
 
             //推省上
-            if (!string.IsNullOrEmpty(model.Id) && ("001171".Equals(model.OrgId) || "001178".Equals(model.OrgId)))
+            if (!string.IsNullOrEmpty(model.Id) && (_cityBaseConfiguration.Value.CityProvince.OrgId.Equals(model.OrgId) || _cityBaseConfiguration.Value.CityProvinceAssign.OrgId.Equals(model.OrgId)))
             {
                 var orderDto = _mapper.Map<OrderDto>(order);
                 var urge = await _orderUrgeRepository.GetAsync(x => x.Id == model.Id);
@@ -3223,7 +3225,7 @@ public class OrderController : BaseController
             throw new UserFriendlyException($"该工单已开启办理流程, No:{order.No}", "该工单已开启办理流程");
 
         ExpiredTimeWithConfig expiredTimeConfig;
-        if (dto.Workflow.NextHandlers.Any(d => d.Key == "001171" || d.Key == "001178"))
+        if (dto.Workflow.NextHandlers.Any(d => d.Key == _cityBaseConfiguration.Value.CityProvince.OrgId || d.Key == _cityBaseConfiguration.Value.CityProvinceAssign.OrgId))
         {
             // var timeResult = _timeLimitDomainService.CalcEndTime(DateTime.Now, ETimeType.WorkDay, 45, 80, 50);
             var timeResult = await _expireTime.CalcEndTime(DateTime.Now, ETimeType.WorkDay, 45, 80, 50);
@@ -3338,7 +3340,7 @@ public class OrderController : BaseController
         }
 
         ExpiredTimeWithConfig? expiredTimeConfig = null;
-        if (dto.NextHandlers.Any(d => d.Key == "001171" || d.Key == "001178"))
+        if (dto.NextHandlers.Any(d => d.Key == _cityBaseConfiguration.Value.CityProvince.OrgId || d.Key == _cityBaseConfiguration.Value.CityProvinceAssign.OrgId))
         {
             // var timeResult = _timeLimitDomainService.CalcEndTime(DateTime.Now, ETimeType.WorkDay, 45, 80, 50);
             var timeResult = await _expireTime.CalcEndTime(DateTime.Now, ETimeType.WorkDay, 45, 80, 50);
@@ -4626,9 +4628,9 @@ public class OrderController : BaseController
                 }
             }
 
-            if (order != null && ("001171".Equals(special.OrgId) ||
-                                  "001178".Equals(special.OrgId) || "001181".Equals(special.OrgId) ||
-                                  "001180".Equals(special.OrgId)))
+            if (order != null && (_cityBaseConfiguration.Value.CityProvince.OrgId.Equals(special.OrgId) ||
+                                  _cityBaseConfiguration.Value.CityProvinceAssign.OrgId.Equals(special.OrgId) || _cityBaseConfiguration.Value.CityEnterprise.OrgId.Equals(special.OrgId) ||
+                                  _cityBaseConfiguration.Value.PublicSecurity.OrgId.Equals(special.OrgId)))
             {
                 await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderFlowRecalled,
                     new PublishSpecialDto { Order = _mapper.Map<OrderDto>(order), Special = _mapper.Map<OrderSpecialDto>(model) },
@@ -4872,9 +4874,9 @@ public class OrderController : BaseController
                 }
             }
 
-            if (order != null && ("001171".Equals(special.OrgId) ||
-                                  "001178".Equals(special.OrgId) || "001181".Equals(special.OrgId) ||
-                                  "001180".Equals(special.OrgId)))
+            if (order != null && (_cityBaseConfiguration.Value.CityProvince.OrgId.Equals(special.OrgId) ||
+                                  _cityBaseConfiguration.Value.CityProvinceAssign.OrgId.Equals(special.OrgId) || _cityBaseConfiguration.Value.CityEnterprise.OrgId.Equals(special.OrgId) ||
+                                  _cityBaseConfiguration.Value.PublicSecurity.OrgId.Equals(special.OrgId)))
             {
                 await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderFlowRecalled,
                     new PublishSpecialDto { Order = _mapper.Map<OrderDto>(order), Special = _mapper.Map<OrderSpecialDto>(special) },
@@ -4985,9 +4987,9 @@ public class OrderController : BaseController
                     }
                 }
 
-                if (order != null && ("001171".Equals(special.OrgId) ||
-                                     "001178".Equals(special.OrgId) || "001181".Equals(special.OrgId) ||
-                                     "001180".Equals(special.OrgId)))
+                if (order != null && (_cityBaseConfiguration.Value.CityProvince.OrgId.Equals(special.OrgId) ||
+                                      _cityBaseConfiguration.Value.CityProvinceAssign.OrgId.Equals(special.OrgId) || _cityBaseConfiguration.Value.CityEnterprise.OrgId.Equals(special.OrgId) ||
+                                      _cityBaseConfiguration.Value.PublicSecurity.OrgId.Equals(special.OrgId)))
                 {
                     await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderFlowRecalled,
                         new PublishSpecialDto { Order = _mapper.Map<OrderDto>(order), Special = _mapper.Map<OrderSpecialDto>(special) },

+ 4 - 3
src/Hotline.Api/StartupExtensions.cs

@@ -57,10 +57,11 @@ internal static class StartupExtensions
         var callCenterConfiguration = callCenterConfigurationSection.Get<CallCenterConfiguration>();
         services.Configure<CallCenterConfiguration>(d => callCenterConfigurationSection.Bind(d));
 
-        //services.Configure<SendSmsConfiguration>(d => configuration.GetSection("SendSms").Bind(d));
+        services.Configure<CityBaseConfiguration>(d => configuration.GetSection(nameof(CityBaseConfiguration)).Bind(d));
+		//services.Configure<SendSmsConfiguration>(d => configuration.GetSection("SendSms").Bind(d));
 
-        // Add services to the container.
-        services
+		// Add services to the container.
+		services
             .BatchInjectServices(d =>
             {
                 var attr = d.GetCustomAttribute(typeof(InjectionAttribute)) as InjectionAttribute;

+ 33 - 1
src/Hotline.Api/config/appsettings.Development.json

@@ -1,4 +1,36 @@
 {
+  "CityBaseConfiguration": {
+    "CityProvince": {
+      "UserId": "03aba148-e7b1-cd03-bf00-3a1177930508",
+      "UserName": "省12345平台",
+      "OrgId": "001171",
+      "OrgName": "省12345平台"
+    },
+    "CityProvinceAssign": {
+      "UserId": "",
+      "UserName": "",
+      "OrgId": "001178",
+      "OrgName": "省12345交办"
+    },
+    "PublicSecurity": {
+      "UserId": "e90501d7-c453-e18a-f1fa-3a1177930699",
+      "UserName": "市公安局110",
+      "OrgId": "001180",
+      "OrgName": "市公安局110"
+    },
+    "CityEnterprise": {
+      "UserId": "ce42562c-afc1-764b-1dc8-3a1177930346",
+      "UserName": "联系服务企业",
+      "OrgId": "001181",
+      "OrgName": "联系服务企业"
+    },
+    "ComprehensiveTreatment": {
+      "UserId": "d4cb7151-41fa-a810-6c1e-3a117792fc0c",
+      "UserName": "综治平台",
+      "OrgId": "001143",
+      "OrgName": "综治平台"
+    }
+  },
   "AllowedHosts": "*",
   "AppConfiguration": {
     "AppScope": "ZiGong",
@@ -123,7 +155,7 @@
   "FwClient": {
     "ClientId": "hotline",
     "ClientSecret": "08db29cc-0da0-4adf-850c-1b2689bd535d"
-  },
+  }
   //"ConfigCenter": {
   //  "ServerAddresses": [ "http://110.188.24.28:8848" ],
   //  "Namespace": "17503980-9b0d-4d3e-8e35-c842c41fb888", //debug

+ 3 - 2
src/Hotline.Application.Tests/Startup.cs

@@ -88,10 +88,11 @@ public class Startup
             var callCenterConfigurationSection = configuration.GetRequiredSection(nameof(CallCenterConfiguration));
             var callCenterConfiguration = callCenterConfigurationSection.Get<CallCenterConfiguration>();
 
-            services.Configure<AppConfiguration>(d => appConfigurationSection.Bind(d));
+			services.Configure<AppConfiguration>(d => appConfigurationSection.Bind(d));
             services.Configure<IdentityConfiguration>(d => configuration.GetSection(nameof(IdentityConfiguration)).Bind(d));
+            services.Configure<CityBaseConfiguration>(d => configuration.GetSection(nameof(CityBaseConfiguration)).Bind(d));
 
-            services.RegisterMapper();
+			services.RegisterMapper();
 
             //sqlsugar
             services.AddSqlSugar(configuration);

+ 8 - 4
src/Hotline.Application/FlowEngine/WorkflowApplication.cs

@@ -30,6 +30,8 @@ using Hotline.Share.Dtos.File;
 using Microsoft.Extensions.Logging;
 using System.Text;
 using System.Diagnostics;
+using Hotline.Configurations;
+using Microsoft.Extensions.Options;
 using NPOI.SS.Formula.Functions;
 
 namespace Hotline.Application.FlowEngine;
@@ -57,6 +59,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
     private readonly IFileRepository _fileRepository;
     private readonly ILogger<WorkflowApplication> _logger;
     private readonly ISystemSettingCacheManager _systemSettingCacheManager;
+    private readonly IOptions<CityBaseConfiguration> _cityBaseConfiguration;
 
 	public WorkflowApplication(
         IDefinitionDomainService definitionDomainService,
@@ -77,7 +80,8 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         IMapper mapper,
         IFileRepository fileRepository,
         ISystemSettingCacheManager systemSettingCacheManager,
-		ILogger<WorkflowApplication> logger)
+		ILogger<WorkflowApplication> logger,
+        IOptions<CityBaseConfiguration> cityBaseConfiguration)
     {
         _definitionDomainService = definitionDomainService;
         _workflowDomainService = workflowDomainService;
@@ -98,7 +102,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         _fileRepository = fileRepository;
         _logger = logger;
         _systemSettingCacheManager = systemSettingCacheManager;
-
+        _cityBaseConfiguration = cityBaseConfiguration;
 	}
 
     public async Task<string> StartWorkflowAsync(StartWorkflowDto dto, ISessionContext current, string externalId,
@@ -1694,8 +1698,8 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         var workflow = await _workflowDomainService.GetWorkflowAsync(workflowId, withSteps: true, withTraces: true,
             cancellationToken: cancellationToken);
         var step = workflow.Steps.FirstOrDefault(d =>
-            //d.StepHandlers.Any(d => d.OrgId == "001171" || d.OrgId == "001178"));
-            d.HandlerOrgId == "001171" || d.HandlerOrgId == "001178");
+			//d.StepHandlers.Any(d => d.OrgId == _cityBaseConfiguration.Value.CityProvince.OrgId || d.OrgId == _cityBaseConfiguration.Value.CityProvinceAssign.OrgId));
+			d.HandlerOrgId == _cityBaseConfiguration.Value.CityProvince.OrgId || d.HandlerOrgId == _cityBaseConfiguration.Value.CityProvinceAssign.OrgId);
         if (step is not null)
         {
             step.FileJson = await _fileRepository.AddFileAsync(files, workflow.ExternalId, step.Id, cancellationToken);

+ 7 - 4
src/Hotline.Application/Subscribers/DatasharingSubscriber.cs

@@ -63,8 +63,9 @@ namespace Hotline.Application.Subscribers
         private readonly IRepository<ContingencyManagementOrders> _contingencyManagementOrdersRepository;
         private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
         private readonly ICallApplication _callApplication;
+        private readonly IOptions<CityBaseConfiguration> _cityBaseConfiguration;
 
-        public DataSharingSubscriber(
+		public DataSharingSubscriber(
             IRepository<OrderVisit> orderVisitRepository,
             IMapper mapper,
             IOrderRepository orderRepository,
@@ -91,7 +92,8 @@ namespace Hotline.Application.Subscribers
              IRepository<OrderRevoke> orderRevokeRepository,
              IRepository<ContingencyManagementOrders> contingencyManagementOrdersRepository,
             IOptionsSnapshot<AppConfiguration> appOptions,
-            ICallApplication callApplication)
+            ICallApplication callApplication,
+            IOptions<CityBaseConfiguration> cityBaseConfiguration)
         {
             _orderSendBackRepository = orderSendBackRepository;
             _workflowApplication = workflowApplication;
@@ -120,7 +122,8 @@ namespace Hotline.Application.Subscribers
             _contingencyManagementOrdersRepository = contingencyManagementOrdersRepository;
             _appOptions = appOptions;
             _callApplication = callApplication;
-        }
+            _cityBaseConfiguration = cityBaseConfiguration;
+		}
 
         /// <summary>
         /// 接收工单退回结果
@@ -168,7 +171,7 @@ namespace Hotline.Application.Subscribers
                     //order.File(now, handleDuration, fileDuration, allDuration);
                     //await _orderRepository.UpdateAsync(order, cancellationToken);
 
-                    var current = SessionContextCreator.CreateSessionContext(dto.Source);
+                    var current = SessionContextCreator.CreateSessionContext(dto.Source, _cityBaseConfiguration.Value);
                     if (string.IsNullOrEmpty(order.WorkflowId))
                     {
                         var startDto = new StartWorkflowDto

+ 7 - 6
src/Hotline/Authentications/Police110SessionContext.cs

@@ -1,15 +1,16 @@
-using XF.Domain.Authentications;
+using Hotline.Configurations;
+using XF.Domain.Authentications;
 
 namespace Hotline.Authentications
 {
     public class Police110SessionContext : ISessionContext
     {
-        public Police110SessionContext()
+        public Police110SessionContext(PublicSecurityConfiguration config)
         {
-            UserId = "e90501d7-c453-e18a-f1fa-3a1177930699";
-            UserName = "市公安局110";
-            OrgId = "001180";
-            OrgName = "市公安局110";
+            UserId = config.UserId;
+            UserName = config.UserName;
+            OrgId = config.OrgId;
+            OrgName = config.OrgName;
             OrgLevel = 1;
         }
 

+ 7 - 6
src/Hotline/Authentications/ProvinceSessionContext.cs

@@ -1,15 +1,16 @@
-using XF.Domain.Authentications;
+using Hotline.Configurations;
+using XF.Domain.Authentications;
 
 namespace Hotline.Authentications
 {
     public class ProvinceSessionContext : ISessionContext
     {
-        public ProvinceSessionContext()
+        public ProvinceSessionContext(CityProvinceConfiguration config)
         {
-            UserId = "03aba148-e7b1-cd03-bf00-3a1177930508";
-            UserName = "省12345平台";
-            OrgId = "001171";
-            OrgName = "省12345平台";
+            UserId = config.UserId;
+            UserName = config.UserName;
+            OrgId = config.OrgId;
+            OrgName = config.OrgName;
             OrgLevel = 1;
         }
 

+ 6 - 5
src/Hotline/Authentications/SessionContextCreator.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Hotline.Configurations;
 using Hotline.Share.Enums.Order;
 using XF.Domain.Authentications;
 
@@ -10,18 +11,18 @@ namespace Hotline.Authentications
 {
     public class SessionContextCreator
     {
-        public static ISessionContext CreateSessionContext(string source)
+        public static ISessionContext CreateSessionContext(string source, CityBaseConfiguration cityBase)
         {
             switch (source)
             {
                 case "province":
-                    return new ProvinceSessionContext();
+                    return new ProvinceSessionContext(cityBase.CityProvince);
                 case "110":
-                    return new Police110SessionContext();
+                    return new Police110SessionContext(cityBase.PublicSecurity);
                 case "yb-enterprise":
-                    return new YbEnterpriseSessionContext();
+                    return new YbEnterpriseSessionContext(cityBase.CityEnterprise);
                 case "zzpt":
-                    return new ZzptSessionContext();
+                    return new ZzptSessionContext(cityBase.ComprehensiveTreatment);
                 default:
                     throw new ArgumentOutOfRangeException(nameof(source), source, null);
             }

+ 7 - 6
src/Hotline/Authentications/YbEnterpriseSessionContext.cs

@@ -1,15 +1,16 @@
-using XF.Domain.Authentications;
+using Hotline.Configurations;
+using XF.Domain.Authentications;
 
 namespace Hotline.Authentications
 {
     public class YbEnterpriseSessionContext : ISessionContext
     {
-        public YbEnterpriseSessionContext()
+        public YbEnterpriseSessionContext(CityEnterpriseConfiguration config)
         {
-            UserId = "ce42562c-afc1-764b-1dc8-3a1177930346";
-            UserName = "联系服务企业";
-            OrgId = "001181";
-            OrgName = "联系服务企业";
+            UserId = config.UserId;
+            UserName = config.UserName;
+            OrgId = config.OrgId;
+            OrgName = config.OrgName;
             OrgLevel = 1;
         }
 

+ 7 - 6
src/Hotline/Authentications/ZzptSessionContext.cs

@@ -1,15 +1,16 @@
-using XF.Domain.Authentications;
+using Hotline.Configurations;
+using XF.Domain.Authentications;
 
 namespace Hotline.Authentications
 {
     public class ZzptSessionContext : ISessionContext
     {
-        public ZzptSessionContext()
+        public ZzptSessionContext(ComprehensiveTreatmentConfiguration config)
         {
-            UserId = "d4cb7151-41fa-a810-6c1e-3a117792fc0c";
-            UserName = "综治平台";
-            OrgId = "001143";
-            OrgName = "综治平台";
+            UserId = config.UserId;
+            UserName = config.UserName;
+            OrgId = config.OrgId;
+            OrgName = config.OrgName;
             OrgLevel = 1;
         }
 

+ 42 - 0
src/Hotline/Configurations/CityBaseConfiguration.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Configurations
+{
+	public class CityBaseConfiguration
+	{
+		public CityProvinceConfiguration CityProvince { get; set; }
+
+		public CityProvinceAssignConfiguration CityProvinceAssign { get; set; }
+		public PublicSecurityConfiguration PublicSecurity { get; set; }
+		public CityEnterpriseConfiguration CityEnterprise { get; set; }
+		public ComprehensiveTreatmentConfiguration ComprehensiveTreatment { get; set; }
+	}
+
+	public class CityProvinceConfiguration : DefaultCityBaseConfiguration
+	{
+	}
+	public class CityProvinceAssignConfiguration : DefaultCityBaseConfiguration
+	{
+	}
+	public class PublicSecurityConfiguration : DefaultCityBaseConfiguration
+	{
+	}
+	public class CityEnterpriseConfiguration : DefaultCityBaseConfiguration
+	{
+	}
+	public class ComprehensiveTreatmentConfiguration : DefaultCityBaseConfiguration
+	{
+	}
+
+	public abstract class DefaultCityBaseConfiguration
+	{
+		public string UserId { get; set; }
+		public string UserName { get; set; }
+		public string OrgId { get; set; }
+		public string OrgName { get; set; }
+	}
+}