Преглед изворни кода

修改获取开启流程时判断是不是随手拍流程

qinchaoyue пре 1 месец
родитељ
комит
31b25d8a13

+ 2 - 4
src/Hotline.Api/Controllers/OrderController.cs

@@ -4995,7 +4995,7 @@ public class OrderController : BaseController
     [HttpGet("startflow")]
     public async Task<NextStepsDto> GetFlowStartOptions([FromQuery] string? orderId)
     {
-        var dto = await _workflowApplication.GetStartStepsAsync(WorkflowModuleConsts.OrderHandle,
+        var dto = await _workflowApplication.GetStartStepsAsync(await _orderSnapshotApplication.GetStartflowAsync(orderId, HttpContext.RequestAborted),
             HttpContext.RequestAborted);
         if (orderId.NotNullOrEmpty())
         {
@@ -5003,10 +5003,8 @@ public class OrderController : BaseController
             dto.Content = (await _orderRepository.GetAsync(orderId, HttpContext.RequestAborted))?.Content;
         }
 
-        //随手拍
-        var isSnapshotEnable = _systemSettingCacheManager.Snapshot;
         var isAqyh = false;//行业类型是否为随手拍安全隐患
-        if (isSnapshotEnable)
+        if (_systemSettingCacheManager.Snapshot)
         {
             var orderSnapShot = await _orderSnapshotRepository.GetAsync(orderId, HttpContext.RequestAborted);
             if (orderSnapShot != null && string.CompareOrdinal(orderSnapShot.IndustryName, "安全隐患") == 0)

+ 2 - 0
src/Hotline.Application/Snapshot/Contracts/IOrderSnapshotApplication.cs

@@ -146,4 +146,6 @@ public interface IOrderSnapshotApplication
     Task UpdateIsEmphasisAsync(UpdateIsEmphasisInDto dto);
 
     Task GetOrderDetailAsync(string id, Share.Dtos.Order.OrderDto dto, CancellationToken token);
+
+    Task<string> GetStartflowAsync(string? orderId, CancellationToken requestAborted);
 }

+ 38 - 1
src/Hotline.Application/Snapshot/SnapshotOrderApplication.cs

@@ -33,6 +33,11 @@ using XF.Utility.EnumExtensions;
 using Hotline.Snapshot.IRepository;
 using Hotline.Application.Snapshot.Contracts;
 using Microsoft.AspNetCore.Http;
+using Hotline.Configurations;
+using Microsoft.Extensions.Options;
+using Hotline.FlowEngine.WorkflowModules;
+using System.Reflection.Metadata.Ecma335;
+using Microsoft.Extensions.Logging;
 
 namespace Hotline.Application.Snapshot;
 public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDependency
@@ -48,8 +53,10 @@ public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDepende
     private readonly IFileRepository _fileRepository;
     private readonly ISnapshotLabelLogRepository _snapshotLabelLogRepository;
     private readonly IRedPackAuditRepository _redPackAuditRepository;
+    private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
+    private readonly ILogger<SnapshotOrderApplication> _logger;
 
-    public SnapshotOrderApplication(IOrderSnapshotRepository orderSnapshotRepository, IOrderRepository orderRepository, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, ISessionContext sessionContext, ISystemSettingCacheManager systemSettingCacheManager, IIndustryCaseRepository industryCaseRepository, ISystemDicDataCacheManager systemDicDataCacheManager, IIndustryRepository industryRepository, IFileRepository fileRepository, ISnapshotLabelLogRepository snapshotLabelLogRepository, IRedPackAuditRepository redPackAuditRepository)
+    public SnapshotOrderApplication(IOrderSnapshotRepository orderSnapshotRepository, IOrderRepository orderRepository, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, ISessionContext sessionContext, ISystemSettingCacheManager systemSettingCacheManager, IIndustryCaseRepository industryCaseRepository, ISystemDicDataCacheManager systemDicDataCacheManager, IIndustryRepository industryRepository, IFileRepository fileRepository, ISnapshotLabelLogRepository snapshotLabelLogRepository, IRedPackAuditRepository redPackAuditRepository, IOptionsSnapshot<AppConfiguration> appOptions, ILogger<SnapshotOrderApplication> logger)
     {
         _orderSnapshotRepository = orderSnapshotRepository;
         _orderRepository = orderRepository;
@@ -62,6 +69,8 @@ public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDepende
         _fileRepository = fileRepository;
         _snapshotLabelLogRepository = snapshotLabelLogRepository;
         _redPackAuditRepository = redPackAuditRepository;
+        _appOptions = appOptions;
+        _logger = logger;
     }
 
     /// <summary>
@@ -648,4 +657,32 @@ public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDepende
             });
 
     }
+
+    public async Task<string> GetStartflowAsync(string? orderId, CancellationToken token)
+    {
+        try
+        {
+            if (orderId.IsNullOrEmpty()) return WorkflowModuleConsts.OrderHandle;
+            if (_systemSettingCacheManager.Snapshot == false) return WorkflowModuleConsts.OrderHandle;
+            if (_appOptions.Value.IsZiGong == false) return WorkflowModuleConsts.OrderHandle;
+
+            var order = await _orderSnapshotRepository.Queryable()
+                .LeftJoin<Industry>((snapshot, industry) => snapshot.IndustryId == industry.Id)
+                .Where((snapshot, industry) => snapshot.Id == orderId)
+                .Select((snapshot, industry) => new { snapshot.Id, industry.IndustryType })
+                .FirstAsync(token);
+            if (order == null) return WorkflowModuleConsts.OrderHandle;
+
+            if (order.IndustryType == EIndustryType.Declare) // 作业申报类型
+            {
+                return WorkflowModuleConsts.OrderHandleSnapshot;
+            }
+            return WorkflowModuleConsts.OrderHandle;
+        }
+        catch (Exception e)
+        {
+            _logger.LogError("获取随手拍开启流程参数异常", e);
+            return WorkflowModuleConsts.OrderHandle;
+        }
+    }
 }