|
@@ -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;
|
|
@@ -33,7 +34,8 @@ namespace Hotline.Api.Controllers;
|
|
|
/// </summary>
|
|
|
public class OrderController : BaseController
|
|
|
{
|
|
|
- private readonly IOrderDomainService _orderDomainService;
|
|
|
+
|
|
|
+ private readonly IOrderDomainService _orderDomainService;
|
|
|
private readonly IOrderRepository _orderRepository;
|
|
|
private readonly IWorkflowApplication _workflowApplication;
|
|
|
private readonly IWorkflowDomainService _workflowDomainService;
|
|
@@ -53,6 +55,9 @@ public class OrderController : BaseController
|
|
|
private readonly ITimeLimitApplication _timeLimitApplication;
|
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
private readonly IOrderRedoRepository _orderRedoRepository;
|
|
|
+ private readonly IOrderSuperviseRepository _orderSuperviseRepository;
|
|
|
+ private readonly IOrderUrgeRepository _orderUrgeRepository;
|
|
|
+
|
|
|
|
|
|
public OrderController(
|
|
|
IOrderDomainService orderDomainService,
|
|
@@ -74,7 +79,10 @@ public class OrderController : BaseController
|
|
|
IOrderDelayRepository orderDelayRepository,
|
|
|
ITimeLimitApplication timeLimitApplication,
|
|
|
ISystemSettingCacheManager systemSettingCacheManager,
|
|
|
- IOrderRedoRepository orderRedoRepository)
|
|
|
+ IOrderRedoRepository orderRedoRepository,
|
|
|
+ IOrderSuperviseRepository orderSuperviseRepository,
|
|
|
+ IOrderUrgeRepository orderUrgeRepository
|
|
|
+ )
|
|
|
{
|
|
|
_orderDomainService = orderDomainService;
|
|
|
_orderRepository = orderRepository;
|
|
@@ -96,6 +104,8 @@ public class OrderController : BaseController
|
|
|
_timeLimitApplication = timeLimitApplication;
|
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
_orderRedoRepository = orderRedoRepository;
|
|
|
+ _orderSuperviseRepository = orderSuperviseRepository;
|
|
|
+ _orderUrgeRepository = orderUrgeRepository;
|
|
|
}
|
|
|
|
|
|
#region 工单发布
|
|
@@ -510,8 +520,209 @@ public class OrderController : BaseController
|
|
|
|
|
|
#region 工单督办
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 工单督办列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.SuperviseOrderList)]
|
|
|
+ [HttpGet("supervise")]
|
|
|
+ public async Task<PagedDto<SuperviseOrderDto>> SuperviseList([FromQuery] SuperviseListDto dto)
|
|
|
+ {
|
|
|
+ var (total, items) = await _orderSuperviseRepository.Queryable()
|
|
|
+ .Includes(x => x.Order)
|
|
|
+ .Includes(x => x.Organize)
|
|
|
+ .Includes(x => x.CrOrganize)
|
|
|
+ .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<SuperviseOrderDto>(total, _mapper.Map<IReadOnlyList<SuperviseOrderDto>>(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);
|
|
|
+ model.State = 0;
|
|
|
+ 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("无效督办");
|
|
|
+ if (supervise.State > 0)
|
|
|
+ throw UserFriendlyException.SameMessage("督办已回复,请勿重复回复");
|
|
|
+
|
|
|
+ var model = _mapper.Map<OrderSupervise>(dto);
|
|
|
+ model.ReplyId = _sessionContext.UserId;
|
|
|
+ model.ReplyTime = DateTime.Now;
|
|
|
+ model.State = 1;
|
|
|
+ model.Id = dto.Id;
|
|
|
+ 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;
|
|
|
+ model.Id = dto.Id;
|
|
|
+ await _orderSuperviseRepository.UpdateAsync(model, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 督办详情
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.SuperviseEntity)]
|
|
|
+ [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
|
|
|
+
|
|
|
+ #region 工单催办
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 工单催办列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.UrgeOrderList)]
|
|
|
+ [HttpGet("urge")]
|
|
|
+ public async Task<PagedDto<UrgeOrderDto>> UrgeList([FromQuery] UrgeListDto dto)
|
|
|
+ {
|
|
|
+ var (total, items) = await _orderUrgeRepository.Queryable()
|
|
|
+ .Includes(x => x.Order)
|
|
|
+ .Includes(x => x.Organize)
|
|
|
+ .Includes(x => x.CrOrganize)
|
|
|
+ .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<UrgeOrderDto>(total, _mapper.Map<IReadOnlyList<UrgeOrderDto>>(items));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 申请催办
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.ApplyUrge)]
|
|
|
+ [HttpPost("urge/apply")]
|
|
|
+ public async Task ApplyUrge([FromBody] ApplyOrderUrgeDto dto)
|
|
|
+ {
|
|
|
+ //验证工单是否可以申请
|
|
|
+ var order = await _orderRepository.GetAsync(dto.OrderId, HttpContext.RequestAborted);
|
|
|
+ if (order is null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效工单");
|
|
|
+
|
|
|
+ var model = _mapper.Map<OrderUrge>(dto);
|
|
|
+ await _orderUrgeRepository.AddAsync(model, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 回复催办
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.ReplyUrge)]
|
|
|
+ [HttpPost("urge/reply")]
|
|
|
+ public async Task ReplyUrge([FromBody] ReplyOrderUrgeDto dto)
|
|
|
+ {
|
|
|
+ //验证是否存在催办
|
|
|
+ var urge = await _orderUrgeRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
+ if (urge is null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效催办");
|
|
|
+ if (urge.State > 0)
|
|
|
+ throw UserFriendlyException.SameMessage("督办已回复,请勿重复回复");
|
|
|
+
|
|
|
+ var model = _mapper.Map<OrderUrge>(dto);
|
|
|
+ model.ReplyId = _sessionContext.UserId;
|
|
|
+ model.ReplyTime = DateTime.Now;
|
|
|
+ model.State = 1;
|
|
|
+ model.Id = dto.Id;
|
|
|
+ await _orderUrgeRepository.UpdateAsync(model, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 签收催办
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.SignUrge)]
|
|
|
+ [HttpPost("urge/sign")]
|
|
|
+ public async Task SignUrge([FromBody] SignOrderUrgeDto dto)
|
|
|
+ {
|
|
|
+ //验证是否存在催办
|
|
|
+ var urge = await _orderUrgeRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
+ if (urge is null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效催办");
|
|
|
+
|
|
|
+ var model = _mapper.Map<OrderUrge>(dto);
|
|
|
+ model.SignTime = DateTime.Now;
|
|
|
+ model.Id = dto.Id;
|
|
|
+ await _orderUrgeRepository.UpdateAsync(model, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 催办详情
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.UrgeEntity)]
|
|
|
+ [HttpGet("urge/{id}")]
|
|
|
+ public async Task<OrderUrge> UrgeEntity(string id)
|
|
|
+ {
|
|
|
+ return await _orderUrgeRepository.Queryable()
|
|
|
+ .Includes(x => x.Order)
|
|
|
+ .Includes(x => x.Organize)
|
|
|
+ .FirstAsync(x => x.Id == id);
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 工单办理
|