فهرست منبع

发布工单时保存随手拍工单标记

qinchaoyue 4 ماه پیش
والد
کامیت
ae3d497b4c

+ 10 - 8
src/Hotline.Api/Controllers/OrderController.cs

@@ -74,6 +74,7 @@ using Hotline.Share.Dtos.Org;
 using Hotline.Snapshot.Interfaces;
 using Hotline.Snapshot.Notifications;
 using Hotline.Snapshot;
+using Hotline.Application.Snapshot;
 
 namespace Hotline.Api.Controllers;
 
@@ -150,6 +151,7 @@ public class OrderController : BaseController
     private readonly ISystemLogApplication _systemLogApplication;
     private readonly IRepository<OrderCarboncopy> _orderCarboncopy;
     private readonly IOrderSnapshotRepository _orderSnapshotRepository;
+    private readonly IOrderSnapshotApplication _orderSnapshotApplication;
     private readonly IIndustryRepository _industryRepository;
 
     public OrderController(
@@ -220,7 +222,8 @@ public class OrderController : BaseController
         ITypedCache<string> typeCache,
         ISystemLogApplication systemLogApplication,
         IOrderSnapshotRepository orderSnapshotRepository,
-        IIndustryRepository industryRepository)
+        IIndustryRepository industryRepository,
+        IOrderSnapshotApplication orderSnapshotApplication)
     {
         _orderDomainService = orderDomainService;
         _orderRepository = orderRepository;
@@ -290,6 +293,7 @@ public class OrderController : BaseController
         _systemLogApplication = systemLogApplication;
         _orderSnapshotRepository = orderSnapshotRepository;
         _industryRepository = industryRepository;
+        _orderSnapshotApplication = orderSnapshotApplication;
     }
 
     #endregion
@@ -567,10 +571,8 @@ public class OrderController : BaseController
         }
 
         string visitId = await _orderVisitRepository.AddAsync(orderVisit);
-        if (_systemSettingCacheManager.Snapshot && dto.SnapshotLabels.NotNullOrEmpty())
-        {
-            await _orderSnapshotRepository.UpdateLabelAsync(order.Id, dto.SnapshotLabels);
-        }
+        await _orderSnapshotApplication.UpdateLabelAsync(order.Id, dto.SnapshotLabels);
+
 
         //新增回访信息
         var visitedDetail = new List<OrderVisitDetail>();
@@ -4146,13 +4148,13 @@ public class OrderController : BaseController
 
                 //抄送
                 var ccs = orderHandleFlowDto.Copys
-                     .Where(d => !string.IsNullOrEmpty(d.OrgId) 
-                                 || !string.IsNullOrEmpty(d.RoleId) 
+                     .Where(d => !string.IsNullOrEmpty(d.OrgId)
+                                 || !string.IsNullOrEmpty(d.RoleId)
                                  || !string.IsNullOrEmpty(d.UserId))
                      .Select(d => _mapper.Map<OrderCarboncopy>(d))
                      .Distinct()
                      .ToList();
-                ccs.ForEach(d=>d.OrderId = order.Id);
+                ccs.ForEach(d => d.OrderId = order.Id);
                 await _orderCarboncopy.AddRangeAsync(ccs, HttpContext.RequestAborted);
 
                 break;

+ 10 - 1
src/Hotline.Application/Snapshot/IOrderSnapshotApplication.cs

@@ -1,4 +1,5 @@
-using Hotline.Share.Dtos.Snapshot;
+using Hotline.Share.Dtos;
+using Hotline.Share.Dtos.Snapshot;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -70,4 +71,12 @@ public interface IOrderSnapshotApplication
     /// </summary>
     /// <returns></returns>
     Task UpdateOrderSnapshotPublishStatusAsync(UpdateOrderSnapshotPublishStatusInDto dto);
+
+    /// <summary>
+    /// 随手拍工单标记
+    /// </summary>
+    /// <param name="id"></param>
+    /// <param name="snapshotLabels"></param>
+    /// <returns></returns>
+    Task UpdateLabelAsync(string id, IList<Kv>? snapshotLabels);
 }

+ 27 - 3
src/Hotline.Application/Snapshot/OrderSnapshotApplication.cs

@@ -1,6 +1,8 @@
-using Hotline.FlowEngine.Notifications;
+using Hotline.Caching.Interfaces;
+using Hotline.FlowEngine.Notifications;
 using Hotline.FlowEngine.Workflows;
 using Hotline.Orders;
+using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums.FlowEngine;
 using Hotline.Share.Enums.Order;
@@ -28,13 +30,15 @@ public class OrderSnapshotApplication : IOrderSnapshotApplication, IScopeDepende
     private readonly IOrderRepository _orderRepository;
     private readonly ISnapshotOrderPublishRepository _snapshotOrderPublishRepository;
     private readonly ISessionContext _sessionContext;
+    private readonly ISystemSettingCacheManager _systemSettingCacheManager;
 
-    public OrderSnapshotApplication(IOrderSnapshotRepository orderSnapshotRepository, IOrderRepository orderRepository, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, ISessionContext sessionContext)
+    public OrderSnapshotApplication(IOrderSnapshotRepository orderSnapshotRepository, IOrderRepository orderRepository, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, ISessionContext sessionContext, ISystemSettingCacheManager systemSettingCacheManager)
     {
         _orderSnapshotRepository = orderSnapshotRepository;
         _orderRepository = orderRepository;
         _snapshotOrderPublishRepository = snapshotOrderPublishRepository;
         _sessionContext = sessionContext;
+        _systemSettingCacheManager = systemSettingCacheManager;
     }
 
     /// <summary>
@@ -101,7 +105,7 @@ public class OrderSnapshotApplication : IOrderSnapshotApplication, IScopeDepende
             .WhereIF(dto.Status == 2, publish => publish.Status == EOrderSnapshotPublishStatus.Refuse)
             .OrderByDescending((publish, order) => new { publish.Status, publish.CreationTime })
             .Select((publish, order) => new GetOrderSnapshotPublishAuditItemsOutDto
-            { 
+            {
                 Id = publish.Id,
                 No = order.No,
                 Title = order.Title
@@ -234,4 +238,24 @@ public class OrderSnapshotApplication : IOrderSnapshotApplication, IScopeDepende
         audit.AuditTime = DateTime.Now;
         await _snapshotOrderPublishRepository.UpdateAsync(audit);
     }
+
+    /// <summary>
+    /// 随手拍工单标记
+    /// </summary>
+    /// <param name="id"></param>
+    /// <param name="snapshotLabels"></param>
+    /// <returns></returns>
+    /// <exception cref="NotImplementedException"></exception>
+    public async Task UpdateLabelAsync(string id, IList<Kv>? snapshotLabels)
+    {
+        if (_systemSettingCacheManager.Snapshot == false) return;
+
+        var isSnapshot = await _orderSnapshotRepository.AnyAsync(m => m.Id == id);
+        if (isSnapshot && snapshotLabels == null)
+        {
+            throw UserFriendlyException.SameMessage("随手拍工单标记不能为空");
+        }
+        if (isSnapshot == true)
+            await _orderSnapshotRepository.UpdateLabelAsync(id, snapshotLabels!);
+    }
 }

+ 17 - 2
src/Hotline.Repository.SqlSugar/Snapshot/OrderSnapshotRepository.cs

@@ -1,5 +1,6 @@
 using Hotline.Repository.SqlSugar.DataPermissions;
 using Hotline.Share.Dtos;
+using Hotline.Share.Tools;
 using Hotline.Snapshot;
 using Hotline.Snapshot.Interfaces;
 using SqlSugar;
@@ -31,9 +32,23 @@ public class OrderSnapshotRepository : BaseRepository<OrderSnapshot>, IOrderSnap
     public async Task UpdateLabelAsync(string id, IList<Kv> labels)
     {
         var labelName = string.Join('|', labels.Select(m => m.Value));
-        await Updateable()
+        var query = Updateable()
             .SetColumns(m => m.Labels, labels)
-            .SetColumns(m => m.LabelName, labelName)
+            .SetColumns(m => m.LabelName, labelName);
+
+        if (labels.NotNullOrEmpty())
+        {
+            if (labels.Any(m => m.Key == "yzg"))
+                query.SetColumns(m => m.IsRectifyDepartment, true);
+            if (labels.Any(m => m.Key == "wzg"))
+                query.SetColumns(m => m.IsRectifyDepartment, false);
+            if (labels.Any(m => m.Key == "ss"))
+                query.SetColumns(m => m.IsTruthDepartment, true);
+            if (labels.Any(m => m.Key == "bss"))
+                query.SetColumns(m => m.IsTruthDepartment, false);
+        }
+
+        await query
             .Where(m => m.Id == id)
             .ExecuteCommandAsync();
     }

+ 2 - 2
src/Hotline/Snapshot/OrderSnapshot.cs

@@ -135,13 +135,13 @@ public class OrderSnapshot : CreationSoftDeleteEntity
     /// 发布工单时标记的工单标签
     /// </summary>
     [SugarColumn(ColumnDescription = "工单标签", ColumnDataType = "json", IsJson = true)]
-    public List<Kv> Labels { get; set; }
+    public List<Kv>? Labels { get; set; }
 
     /// <summary>
     /// 发布工单时标记的工单标签(多个使用 | 分隔)
     /// </summary>
     [SugarColumn(ColumnDescription = "工单标签")]
-    public string LabelName { get; set; }
+    public string? LabelName { get; set; }
 
     #region 网格员回复