|
@@ -1,12 +1,15 @@
|
|
|
using Hotline.Application.CallCenter;
|
|
|
+using Hotline.Article;
|
|
|
using Hotline.Caching.Interfaces;
|
|
|
using Hotline.CallCenter.Tels;
|
|
|
using Hotline.Realtimes;
|
|
|
using Hotline.Repository.SqlSugar.Extensions;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Share.Dtos;
|
|
|
+using Hotline.Share.Dtos.Article;
|
|
|
using Hotline.Share.Dtos.CallCenter;
|
|
|
using Hotline.Share.Dtos.Order;
|
|
|
+using Hotline.Share.Enums.Article;
|
|
|
using Hotline.Share.Enums.CallCenter;
|
|
|
using Hotline.Tools;
|
|
|
using MapsterMapper;
|
|
@@ -28,6 +31,7 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly ITelDomainService _telDomainService;
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly IRealtimeService _realtimeService;
|
|
|
+ private readonly ICircularRecordDomainService _circularRecordDomainService;
|
|
|
|
|
|
public TelRestController(ISystemDicDataCacheManager systemDicDataCacheManager,
|
|
|
IRepository<TelRestApply> telRestApplyRepository,
|
|
@@ -35,7 +39,8 @@ namespace Hotline.Api.Controllers
|
|
|
ISessionContext sessionContext,
|
|
|
ITelDomainService telDomainService,
|
|
|
IMapper mapper,
|
|
|
- IRealtimeService realtimeService)
|
|
|
+ IRealtimeService realtimeService,
|
|
|
+ ICircularRecordDomainService circularRecordDomainService)
|
|
|
{
|
|
|
_systemDicDataCacheManager = systemDicDataCacheManager;
|
|
|
_telRestApplyRepository = telRestApplyRepository;
|
|
@@ -44,6 +49,7 @@ namespace Hotline.Api.Controllers
|
|
|
_telDomainService = telDomainService;
|
|
|
_mapper = mapper;
|
|
|
_realtimeService = realtimeService;
|
|
|
+ _circularRecordDomainService = circularRecordDomainService;
|
|
|
}
|
|
|
|
|
|
#region 小休审批
|
|
@@ -70,17 +76,17 @@ namespace Hotline.Api.Controllers
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
[HttpPost("addtelrest")]
|
|
|
- public async Task AddTelRest([FromBody] TelRestApplyAddDto dto)
|
|
|
+ public async Task<string> AddTelRest([FromBody] TelRestApplyAddDto dto)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(dto.TelNo))
|
|
|
- throw new UserFriendlyException("分机号不能为空!");
|
|
|
+ return "分机号不能为空!";
|
|
|
if (dto.Reason == null)
|
|
|
- throw new UserFriendlyException("小休原因不能为空!");
|
|
|
+ return "小休原因不能为空!";
|
|
|
|
|
|
var data = await _telRestApplyRepository.GetAsync(p => p.TelNo == dto.TelNo && p.CreatorId == _sessionContext.RequiredUserId &&
|
|
|
p.AuditStatus == ETelRestAuditStatus.NoAudit, HttpContext.RequestAborted);
|
|
|
if (data != null)
|
|
|
- throw new UserFriendlyException("小休申请审批中,暂时无法操作!");
|
|
|
+ return "小休申请审批中,暂时无法操作!";
|
|
|
|
|
|
TelRestApply telRestApply = new()
|
|
|
{
|
|
@@ -90,7 +96,12 @@ namespace Hotline.Api.Controllers
|
|
|
StaffNo = _sessionContext.StaffNo,
|
|
|
AuditStatus = ETelRestAuditStatus.NoAudit
|
|
|
};
|
|
|
- await _telRestApplyRepository.AddAsync(telRestApply, HttpContext.RequestAborted);
|
|
|
+ var id = await _telRestApplyRepository.AddAsync(telRestApply, HttpContext.RequestAborted);
|
|
|
+ if (!string.IsNullOrEmpty(id))
|
|
|
+ return "小休申请成功!";
|
|
|
+ else
|
|
|
+ return "小休申请失败!";
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -100,26 +111,54 @@ namespace Hotline.Api.Controllers
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
[HttpPost("telrest_apply_audit")]
|
|
|
- public async Task TelRestApplyAudit([FromBody] TelRestApplyAuditDto dto)
|
|
|
+ public async Task<string> TelRestApplyAudit([FromBody] TelRestApplyAuditDto dto)
|
|
|
{
|
|
|
- if (dto.IsPass == false && string.IsNullOrEmpty(dto.AuditOpinion))
|
|
|
- throw new UserFriendlyException("审批原因不能为空!");
|
|
|
- var data = await _telRestApplyRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
- if (data == null)
|
|
|
- throw new UserFriendlyException("审批数据查询失败!");
|
|
|
- data.AuditUserName = _sessionContext.UserName;
|
|
|
- data.AuditUserId = _sessionContext.RequiredUserId;
|
|
|
- data.AuditOrgId = _sessionContext.RequiredOrgId;
|
|
|
- data.AuditOrgName = _sessionContext.OrgName;
|
|
|
- data.AuditTime = DateTime.Now;
|
|
|
- data.AuditOpinion = dto.AuditOpinion;
|
|
|
- data.AuditStatus = dto.IsPass == true ? ETelRestAuditStatus.Pass : ETelRestAuditStatus.NoPass;
|
|
|
- await _telRestApplyRepository.UpdateAsync(data, HttpContext.RequestAborted);
|
|
|
- if (dto.IsPass)
|
|
|
+ if (dto.IsPass != true && string.IsNullOrEmpty(dto.AuditOpinion))
|
|
|
+ return "审批原因不能为空!";
|
|
|
+ foreach (var item in dto.Ids)
|
|
|
{
|
|
|
- //通知前端休息通过
|
|
|
- await _realtimeService.RestApplyPassAsync(data.CreatorId, HttpContext.RequestAborted);
|
|
|
+ var data = await _telRestApplyRepository.GetAsync(item, HttpContext.RequestAborted);
|
|
|
+ if (data != null)
|
|
|
+ {
|
|
|
+ data.AuditUserName = _sessionContext.UserName;
|
|
|
+ data.AuditUserId = _sessionContext.RequiredUserId;
|
|
|
+ data.AuditOrgId = _sessionContext.RequiredOrgId;
|
|
|
+ data.AuditOrgName = _sessionContext.OrgName;
|
|
|
+ data.AuditTime = DateTime.Now;
|
|
|
+ data.AuditOpinion = dto.AuditOpinion;
|
|
|
+ data.AuditStatus = dto.IsPass == true ? ETelRestAuditStatus.Pass : ETelRestAuditStatus.NoPass;
|
|
|
+ await _telRestApplyRepository.UpdateAsync(data, HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ //发送消息
|
|
|
+ var ispasstext = dto.IsPass == true ? "已通过" : "不通过";
|
|
|
+ AddCircularDto circularDto = new()
|
|
|
+ {
|
|
|
+ Title = "小休审批",
|
|
|
+ Content = "您在" + data.CreationTime + "申请的小休审批" + ispasstext,
|
|
|
+ CircularTypeId = "7",
|
|
|
+ CircularTypeName = "小休审批",
|
|
|
+ IsMustRead = true,
|
|
|
+ SourceOrgId = _sessionContext.RequiredOrgId,
|
|
|
+ SourceOrgName = _sessionContext.OrgName,
|
|
|
+ CircularType = ECircularType.Person
|
|
|
+ };
|
|
|
+ List<CircularReadGroupDto> users = [];
|
|
|
+ users.Add(new CircularReadGroupDto()
|
|
|
+ {
|
|
|
+ UserId = data.CreatorId,
|
|
|
+ UserName = data.CreatorName
|
|
|
+ });
|
|
|
+ circularDto.CircularReadGroups = users;
|
|
|
+ //调用推送消息通用接口
|
|
|
+ await _circularRecordDomainService.AddCircularMessage(circularDto, HttpContext.RequestAborted);
|
|
|
+ if (dto.IsPass)
|
|
|
+ {
|
|
|
+ //通知前端休息通过
|
|
|
+ await _realtimeService.RestApplyPassAsync(data.CreatorId, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ return "审批完成";
|
|
|
}
|
|
|
|
|
|
/// <summary>
|