Browse Source

工单督办

田爽 1 year ago
parent
commit
a19bc9799b

+ 98 - 3
src/Hotline.Api/Controllers/OrderController.cs

@@ -20,6 +20,7 @@ using Hotline.Share.Mq;
 using MapsterMapper;
 using MediatR;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.IdentityModel.Tokens;
 using SqlSugar;
 using XF.Domain.Authentications;
 using XF.Domain.Constants;
@@ -53,8 +54,9 @@ public class OrderController : BaseController
     private readonly ITimeLimitApplication _timeLimitApplication;
     private readonly ISystemSettingCacheManager _systemSettingCacheManager;
     private readonly IOrderRedoRepository _orderRedoRepository;
+    private readonly IOrderSuperviseRepository _orderSuperviseRepository;
 
-    public OrderController(
+	public OrderController(
         IOrderDomainService orderDomainService,
         IOrderRepository orderRepository,
         IWorkflowApplication workflowApplication,
@@ -74,7 +76,8 @@ public class OrderController : BaseController
         IOrderDelayRepository orderDelayRepository,
         ITimeLimitApplication timeLimitApplication,
         ISystemSettingCacheManager systemSettingCacheManager,
-        IOrderRedoRepository orderRedoRepository)
+        IOrderRedoRepository orderRedoRepository,
+        IOrderSuperviseRepository orderSuperviseRepository)
     {
         _orderDomainService = orderDomainService;
         _orderRepository = orderRepository;
@@ -96,7 +99,9 @@ public class OrderController : BaseController
         _timeLimitApplication = timeLimitApplication;
         _systemSettingCacheManager = systemSettingCacheManager;
         _orderRedoRepository = orderRedoRepository;
-    }
+        _orderSuperviseRepository = orderSuperviseRepository;
+
+	}
 
     #region 工单发布
 
@@ -510,7 +515,97 @@ public class OrderController : BaseController
 
     #region 工单督办
 
+    /// <summary>
+    /// 工单督办列表
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [Permission(EPermission.SuperviseOrderList)]
+    [HttpGet("supervise")]
+    public async Task<PagedDto<OrderSupervise>> SuperviseList([FromQuery] SuperviseListDto dto)
+    {
+        var (total, items) = await _orderSuperviseRepository.Queryable()
+            .Includes(x => x.Order)
+            .Includes(x => x.Organize)
+            .WhereIF(!string.IsNullOrEmpty(dto.Keyword), d => d.Order.Title.Contains(dto.Keyword!) || d.Order.No.Contains(dto.Keyword!))
+            .WhereIF(dto.SuperviseState > 0, x => x.State == dto.SuperviseState)
+            .OrderByDescending(x => x.CreationTime)
+            .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
+
+        return new PagedDto<OrderSupervise>(total, _mapper.Map<IReadOnlyList<OrderSupervise>>(items));
+    }
+
+    /// <summary>
+    /// 申请督办
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [Permission(EPermission.ApplySupervise)]
+    [HttpPost("supervise/apply")]
+    public async Task ApplySupervise([FromBody] ApplyOrderSuperviseDto dto)
+    {
+        //验证工单是否可以申请
+        var order = await _orderRepository.GetAsync(dto.OrderId, HttpContext.RequestAborted);
+        if (order is null)
+            throw UserFriendlyException.SameMessage("无效工单");
+
+        var model = _mapper.Map<OrderSupervise>(dto);
+        await _orderSuperviseRepository.AddAsync(model, HttpContext.RequestAborted);
+    }
 
+    /// <summary>
+    /// 回复督办
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [Permission(EPermission.ReplySupervise)]
+    [HttpPost("supervise/reply")]
+    public async Task ReplySupervise([FromBody] ReplyOrderSuperviseDto dto)
+    {
+        //验证是否存在督办
+        var supervise = await _orderSuperviseRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
+        if (supervise is null)
+            throw UserFriendlyException.SameMessage("无效督办");
+
+        var model = _mapper.Map<OrderSupervise>(dto);
+        model.ReplyId = _sessionContext.UserId;
+        await _orderSuperviseRepository.UpdateAsync(model, HttpContext.RequestAborted);
+    }
+
+    /// <summary>
+    /// 签收督办
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [Permission(EPermission.SignSupervise)]
+    [HttpPost("supervise/sign")]
+    public async Task SignSupervise([FromBody] SignOrderSuperviseDto dto)
+    {
+        //验证是否存在督办
+        var supervise = await _orderSuperviseRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
+        if (supervise is null)
+            throw UserFriendlyException.SameMessage("无效督办");
+
+        var model = _mapper.Map<OrderSupervise>(dto);
+        model.SignTime = DateTime.Now;
+        await _orderSuperviseRepository.UpdateAsync(model, HttpContext.RequestAborted);
+    }
+
+
+    /// <summary>
+    /// 督办详情
+    /// </summary>
+    /// <param name="id"></param>
+    /// <returns></returns>
+    [Permission(EPermission.DelayEntity)]
+    [HttpGet("supervise/{id}")]
+    public async Task<OrderSupervise> SuperviseEntity(string id)
+    {
+        return await _orderSuperviseRepository.Queryable()
+            .Includes(x => x.Order)
+            .Includes(x => x.Organize)
+            .FirstAsync(x => x.Id == id);
+    }
 
     #endregion
 

+ 69 - 0
src/Hotline.Share/Dtos/Order/OrderSuperviseDto.cs

@@ -0,0 +1,69 @@
+using Hotline.Share.Requests;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Dtos.Order
+{
+	public class OrderSuperviseDto
+	{
+
+		/// <summary>
+		/// 工单ID
+		/// </summary>
+		public string OrderId { get; set; }
+
+		/// <summary>
+		/// 被督办部门ID
+		/// </summary>
+		public string OrgId { get; set; }
+
+		/// <summary> 
+		/// 督办状态
+		/// </summary>
+		public int state { get; set; }
+
+		/// <summary>
+		/// 附件
+		/// </summary>
+		public List<string>? Additions { get; set; } = new();
+	}
+
+	public class ApplyOrderSuperviseDto : OrderSuperviseDto
+	{
+		/// <summary>
+		/// 督办回复时限
+		/// </summary>
+		public DateTime ReplyLimitTime { get; set; }
+
+		/// <summary>
+		/// 督办申请内容
+		/// </summary>
+		public string ApplyContent { get; set; }
+	}
+	public class ReplyOrderSuperviseDto : OrderSuperviseDto
+	{
+
+		public string Id { get; set; }
+
+		/// <summary>
+		/// 督办回复内容
+		/// </summary>
+		public string ReplyContent { get; set; }
+
+
+		/// <summary>
+		/// 回复人
+		/// </summary>
+		public string ReplyId { get; set; }
+	}
+
+	public class SignOrderSuperviseDto 
+	{
+		public string Id { get; set; }
+	}
+
+
+}

+ 24 - 1
src/Hotline.Share/Dtos/Order/QueryOrderDto.cs

@@ -248,8 +248,31 @@ namespace Hotline.Share.Dtos.Order
         public bool IsApply { get; set; }
     }
 
+    public record SuperviseOrderListDto : PagedKeywordRequest
+    {
+		/// <summary>
+		/// 受理时间(工单创建时间)
+		/// </summary>
+		public DateTime? CreationTimeStart { get; set; }
+		public DateTime? CreationTimeEnd { get; set; }
+	}
+
+
+    public record ApplySuperviseDto
+	{
+	    public string OrderId { get; set; }
+    }
+
+    public record SuperviseListDto : PagedKeywordRequest
+    {
+	    /// <summary>
+	    /// 督办回复状态
+	    /// </summary>
+	    public int? SuperviseState { get; set; }
+    }
+
 
-    public enum EVisitStateQuery
+	public enum EVisitStateQuery
     {
         /// <summary>
         /// 全部

+ 13 - 0
src/Hotline/Orders/IOrderSuperviseRepository.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using XF.Domain.Repository;
+
+namespace Hotline.Orders
+{
+	public  interface IOrderSuperviseRepository : IRepository<OrderSupervise>
+	{
+	}
+}

+ 77 - 2
src/Hotline/Orders/OrderSupervise.cs

@@ -1,9 +1,84 @@
-using System.ComponentModel;
+using Hotline.Settings;
+using Hotline.Users;
+using SqlSugar;
+using System.ComponentModel;
+using XF.Domain.Repository;
 
 namespace Hotline.Orders;
 
 [Description("督办")]
-public class OrderSupervise
+public partial class OrderSupervise: FullStateEntity
 {
+	/// <summary>
+	/// 工单ID
+	/// </summary>
+	[SugarColumn(ColumnDescription = "工单ID")]
+	public string OrderId { get; set; }
 
+	/// <summary>
+	/// 督办回复时限
+	/// </summary>
+	[SugarColumn(ColumnDescription = "督办回复时限")]
+	public DateTime ReplyLimitTime { get; set; }
+
+	/// <summary>
+	/// 被督办部门ID
+	/// </summary>
+	[SugarColumn(ColumnDescription = "被督办部门ID")]
+	public string OrgId { get; set; }
+
+	/// <summary>
+	/// 督办状态
+	/// </summary>
+	[SugarColumn(ColumnDescription = "督办状态   0 待回复  1 已回复")]
+	public int State { get; set; }
+
+	/// <summary>
+	/// 督办签收时间
+	/// </summary>
+	[SugarColumn(ColumnDescription = "督办签收时间")]
+	public DateTime? SignTime { get; set; }
+
+	/// <summary>
+	/// 督办回复时间
+	/// </summary>
+	[SugarColumn(ColumnDescription = "督办回复时间")]
+	public DateTime? ReplyTime { get; set; }
+
+	/// <summary>
+	/// 督办申请内容
+	/// </summary>
+	[SugarColumn(ColumnDescription = "督办申请内容", ColumnDataType = "varchar(2000)")]
+	public string? ApplyContent { get; set; }
+
+	/// <summary>
+	/// 督办回复内容
+	/// </summary>
+	[SugarColumn(ColumnDescription = "督办回复内容", ColumnDataType = "varchar(2000)")]
+	public string? ReplyContent { get; set; }
+
+	/// <summary>
+	/// 回复人
+	/// </summary>
+	[SugarColumn(ColumnDescription = "回复人")]
+	public string? ReplyId { get; set; }
+
+	/// <summary>
+	/// 附件
+	/// </summary>
+	[SugarColumn(ColumnDataType = "json", IsJson = true)]
+	public List<string>? Additions { get; set; } = new();
+
+
+	/// <summary>
+	/// 
+	/// </summary>
+	[Navigate(NavigateType.OneToOne, nameof(OrderId))]
+	public Order? Order { get; set; }
+
+	/// <summary>
+	/// 
+	/// </summary>
+	[Navigate(NavigateType.OneToOne, nameof(OrgId))]
+	public SystemOrganize? Organize { get; set; }
 }

+ 38 - 6
src/Hotline/Permissions/EPermission.cs

@@ -960,16 +960,48 @@ namespace Hotline.Permissions
         /// </summary>
         [Display(GroupName = "OrderDelay",Name = "延期详情",Description ="延期详情")]
         DelayEntity = 500403,
-        #endregion
+		#endregion
 
-        #endregion
+		#region 工单督办管理
+        /// <summary>
+        ///工单督办列表
+        /// </summary>
+		[Display(GroupName = "OrderSupervise", Name = "工单督办列表", Description = "工单督办列表")]
+		SuperviseOrderList = 500601,
+
+		/// <summary>
+		/// 申请督办
+		/// </summary>
+		[Display(GroupName = "OrderSupervise", Name = "申请督办", Description = "申请督办")]
+		ApplySupervise = 500602,
 
-        #region 公用(999)
-        #region 上/下班
         /// <summary>
-        /// 上班
+        /// 回复督办
         /// </summary>
-        [Display(GroupName = "公用", Name = "上班", Description = "上班")]
+		[Display(GroupName = "OrderSupervise", Name = "回复督办", Description = "回复督办")]
+        ReplySupervise = 500603,
+
+		/// <summary>
+		/// 签收督办
+		/// </summary>
+		[Display(GroupName = "OrderSupervise", Name = "签收督办", Description = "签收督办")]
+		SignSupervise = 500604,
+
+		/// <summary>
+		/// 延期详情
+		/// </summary>
+		[Display(GroupName = "OrderDelay", Name = "督办详情", Description = "督办详情")]
+		SuperviseEntity = 500605,
+		#endregion
+
+		#endregion
+
+		#region 公用(999)
+		#region 上/下班
+		/// <summary>
+		/// 上班
+		/// </summary>
+		[Display(GroupName = "公用", Name = "上班", Description = "上班")]
         OnDuty = 999101,
         /// <summary>
         /// 下班