|
@@ -0,0 +1,368 @@
|
|
|
|
+using Hotline.Api.Filter;
|
|
|
|
+using Hotline.Application.Identity;
|
|
|
|
+using Hotline.Application.Systems;
|
|
|
|
+using Hotline.Application.Tools;
|
|
|
|
+using Hotline.Caching.Interfaces;
|
|
|
|
+using Hotline.Caching.Services;
|
|
|
|
+using Hotline.FlowEngine.Workflows;
|
|
|
|
+using Hotline.Orders;
|
|
|
|
+using Hotline.Share.Dtos.Identity;
|
|
|
|
+using Hotline.Share.Dtos.Order;
|
|
|
|
+using Hotline.Share.Enums.FlowEngine;
|
|
|
|
+using Hotline.Share.Enums.Order;
|
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
|
+using NPOI.POIFS.Macros;
|
|
|
|
+using SqlSugar;
|
|
|
|
+using XF.Domain.Authentications;
|
|
|
|
+using XF.Domain.Entities;
|
|
|
|
+using XF.Domain.Exceptions;
|
|
|
|
+using XF.Domain.Repository;
|
|
|
|
+
|
|
|
|
+namespace Hotline.Api.Controllers
|
|
|
|
+{
|
|
|
|
+ public class OldHotlineController: BaseController
|
|
|
|
+ {
|
|
|
|
+ private readonly IIdentityAppService _identityAppService;
|
|
|
|
+ private readonly ISystemLogApplication _iSystemLogApplication;
|
|
|
|
+ private readonly IOrderRepository _orderRepository;
|
|
|
|
+ private readonly IOrderVisitRepository _orderVisitRepository;
|
|
|
|
+ private readonly IOrderDelayRepository _orderDelayRepository;
|
|
|
|
+ private readonly IOrderScreenRepository _orderScreenRepository;
|
|
|
|
+ private readonly IRepository<OrderSendBackAudit> _orderSendBackAuditRepository;
|
|
|
|
+ private readonly IRepository<OrderVisitDetail> _orderVisitedDetailRepository;
|
|
|
|
+
|
|
|
|
+ public OldHotlineController(IIdentityAppService identityAppService, ISystemLogApplication iSystemLogApplication, IOrderRepository orderRepository, IOrderVisitRepository orderVisitRepository, IOrderDelayRepository orderDelayRepository, IOrderScreenRepository orderScreenRepository, IRepository<OrderSendBackAudit> orderSendBackAuditRepository, IRepository<OrderVisitDetail> orderVisitedDetailRepository)
|
|
|
|
+ {
|
|
|
|
+ _identityAppService = identityAppService;
|
|
|
|
+ _iSystemLogApplication = iSystemLogApplication;
|
|
|
|
+ _orderRepository = orderRepository;
|
|
|
|
+ _orderVisitRepository = orderVisitRepository;
|
|
|
|
+ _orderDelayRepository = orderDelayRepository;
|
|
|
|
+ _orderScreenRepository = orderScreenRepository;
|
|
|
|
+ _orderSendBackAuditRepository = orderSendBackAuditRepository;
|
|
|
|
+ _orderVisitedDetailRepository = orderVisitedDetailRepository;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 老系统登录新系统
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [AllowAnonymous]
|
|
|
|
+ [HttpPost("loing-oldtonew")]
|
|
|
|
+ [LogFilter("",false)]
|
|
|
|
+ public async Task<string> HotlineLoginOldToNew([FromBody] HotlineLoginOldToNewDto dto)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ dto.UserName = RSA.RSADecrypt(dto.UserName, RSA_Create.RSA_PRIVATE_KEY, "PEM");
|
|
|
|
+ }
|
|
|
|
+ catch
|
|
|
|
+ {
|
|
|
|
+ throw UserFriendlyException.SameMessage("帐号解密失败");
|
|
|
|
+ }
|
|
|
|
+ var res = await _identityAppService.OldToNewLoginAsync(dto, HttpContext.RequestAborted);
|
|
|
|
+ await _iSystemLogApplication.AddLog("账号登录", res, dto, HttpContext, dto.UserName);
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 是否存在可办信息
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [AllowAnonymous]
|
|
|
|
+ [HttpGet("ishas_canhandler")]
|
|
|
|
+ public async Task<bool> IsHasCanHandler([FromBody] HotlineLoginOldToNewDto dto)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ dto.UserName = RSA.RSADecrypt(dto.UserName, RSA_Create.RSA_PRIVATE_KEY, "PEM");
|
|
|
|
+ }
|
|
|
|
+ catch
|
|
|
|
+ {
|
|
|
|
+ throw UserFriendlyException.SameMessage("帐号解密失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var isHas = false;
|
|
|
|
+
|
|
|
|
+ var (isAdmin, isCenter, user) = await _identityAppService.IsCheckAdmin(dto.UserName);
|
|
|
|
+ List<string> Roles = user.Roles.Select(x => x.Name).ToList();
|
|
|
|
+ if (isCenter)
|
|
|
|
+ {
|
|
|
|
+ #region 待办
|
|
|
|
+ //待办
|
|
|
|
+ var waitedDataList = await _orderRepository
|
|
|
|
+ .Queryable(hasHandled: false, isAdmin: isAdmin)
|
|
|
|
+ .Where(d => SqlFunc.Subqueryable<WorkflowStep>()
|
|
|
|
+ .Where(step => step.ExternalId == d.Id && step.Status != EWorkflowStepStatus.Handled &&
|
|
|
|
+ ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == user.Id) ||
|
|
|
|
+ (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == user.OrgId) ||
|
|
|
|
+ (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && Roles.Contains(step.RoleId))))
|
|
|
|
+ .Any())
|
|
|
|
+ .Includes(d => d.OrderSpecials)
|
|
|
|
+ .Where(d => d.Status != EOrderStatus.WaitForAccept && d.Status != EOrderStatus.BackToUnAccept && d.Status != EOrderStatus.SpecialToUnAccept && d.Status != EOrderStatus.HandOverToUnAccept)
|
|
|
|
+ .Where(d => d.Source < ESource.MLSQ || d.Source > ESource.WZSC)
|
|
|
|
+ .Where(d => d.Status != EOrderStatus.BackToProvince && d.Status < EOrderStatus.Filed)
|
|
|
|
+ .Where(d => d.OrderSpecials.Any() == false || d.OrderSpecials.Any(s => s.State > 0))
|
|
|
|
+ .OrderByDescending(d => new { d.IsUrgent, d.StartTime })
|
|
|
|
+ .Select(d => new HomeOrderDto
|
|
|
|
+ {
|
|
|
|
+ No = d.No,
|
|
|
|
+ OrderId = d.Id,
|
|
|
|
+ Title = d.Title,
|
|
|
|
+ AcceptType = d.AcceptType,
|
|
|
|
+ HotspotName = d.HotspotName,
|
|
|
|
+ Type = "Waited",
|
|
|
|
+ Time = d.ExpiredTime,
|
|
|
|
+ Status = d.Status,
|
|
|
|
+ ActualHandleTime = d.ActualHandleTime,
|
|
|
|
+ CounterSignType = d.CounterSignType
|
|
|
|
+ })
|
|
|
|
+ .ToListAsync();
|
|
|
|
+ isHas = waitedDataList.Any();
|
|
|
|
+
|
|
|
|
+ //待办是否有数据
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 已超期
|
|
|
|
+ // 已超期
|
|
|
|
+ isHas = waitedDataList.Any(x => (x.Time < DateTime.Now && x.Status < EOrderStatus.Filed) ||
|
|
|
|
+ (x.Time < x.ActualHandleTime && x.Status >= EOrderStatus.Filed));
|
|
|
|
+ //超期是否有待办
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 回访待办
|
|
|
|
+ //回访待办
|
|
|
|
+ isHas = await _orderVisitRepository.Queryable()
|
|
|
|
+ .AnyAsync(d => (d.VisitState == EVisitState.WaitForVisit || d.VisitState == EVisitState.NoSatisfiedWaitForVisit) && d.EmployeeId == user.Id);
|
|
|
|
+
|
|
|
|
+ //回访待办是否有数据
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 会签待办
|
|
|
|
+ //会签待办
|
|
|
|
+ isHas = waitedDataList.Any(x => x.CounterSignType == ECounterSignType.Center || x.CounterSignType == ECounterSignType.Department);
|
|
|
|
+
|
|
|
|
+ //会签待办是否有数据
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 延期待审批
|
|
|
|
+ //延期待审批
|
|
|
|
+ isHas = await _orderDelayRepository.Queryable(canView: true, isAdmin: isAdmin)
|
|
|
|
+ .AnyAsync(d => d.DelayState == EDelayState.Examining);
|
|
|
|
+
|
|
|
|
+ //延期待审批是否有数据
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 部门即将超期
|
|
|
|
+ //部门即将超期
|
|
|
|
+ isHas = await _orderRepository.Queryable(canView: !isCenter)
|
|
|
|
+ .AnyAsync(d => SqlFunc.Subqueryable<WorkflowStep>()
|
|
|
|
+ .Where(step => step.ExternalId == d.Id && step.Status != EWorkflowStepStatus.Handled &&
|
|
|
|
+ ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == user.Id) ||
|
|
|
|
+ (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == user.OrgId) ||
|
|
|
|
+ (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && Roles.Contains(step.RoleId))))
|
|
|
|
+ .Any()
|
|
|
|
+ && d.Status < EOrderStatus.Filed && DateTime.Now > d.NearlyExpiredTime && DateTime.Now < d.ExpiredTime);
|
|
|
|
+
|
|
|
|
+ //部门即将超期是否有数据
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 甄别待审批
|
|
|
|
+ //甄别待审批
|
|
|
|
+ isHas = await _orderScreenRepository.Queryable(hasHandled: !true, isAdmin: isAdmin)
|
|
|
|
+ .Includes(d => d.Order)
|
|
|
|
+ .Includes(d => d.ScreenDetails.Where(sd => sd.AuditUserId == user.Id).OrderByDescending(sd => sd.AuditTime).Take(1).ToList())
|
|
|
|
+ .AnyAsync(d => (d.Status == EScreenStatus.Apply || d.Status == EScreenStatus.Approval || (d.Status == EScreenStatus.SendBack && d.SendBackApply == false)));
|
|
|
|
+
|
|
|
|
+ //甄别待审批是否有数据
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 退回待审批
|
|
|
|
+ //退回待审批
|
|
|
|
+ isHas = await _orderSendBackAuditRepository.Queryable()
|
|
|
|
+ .Where(d => d.State == ESendBackAuditState.Apply)
|
|
|
|
+ .WhereIF(Roles.Contains("role_sysadmin") == false, x => x.SendBackOrgId == user.Id) // 123 系统管理员;
|
|
|
|
+ .AnyAsync();
|
|
|
|
+
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ #region 待办
|
|
|
|
+ //待办
|
|
|
|
+ var waitedDataList = await _orderRepository
|
|
|
|
+ .Queryable(hasHandled: false, isAdmin: isAdmin)
|
|
|
|
+ .Where(d => SqlFunc.Subqueryable<WorkflowStep>()
|
|
|
|
+ .Where(step => step.ExternalId == d.Id && step.Status != EWorkflowStepStatus.Handled &&
|
|
|
|
+ ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == user.Id) ||
|
|
|
|
+ (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == user.OrgId) ||
|
|
|
|
+ (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && Roles.Contains(step.RoleId))))
|
|
|
|
+ .Any())
|
|
|
|
+ .Includes(d => d.OrderSpecials)
|
|
|
|
+ .Where(d => d.Status != EOrderStatus.WaitForAccept && d.Status != EOrderStatus.BackToUnAccept && d.Status != EOrderStatus.SpecialToUnAccept && d.Status != EOrderStatus.HandOverToUnAccept)
|
|
|
|
+ .Where(d => d.Source < ESource.MLSQ || d.Source > ESource.WZSC)
|
|
|
|
+ .Where(d => d.Status != EOrderStatus.BackToProvince && d.Status < EOrderStatus.Filed)
|
|
|
|
+ .Where(d => d.OrderSpecials.Any() == false || d.OrderSpecials.Any(s => s.State > 0))
|
|
|
|
+ .OrderByDescending(d => new { d.IsUrgent, d.StartTime })
|
|
|
|
+ .Select(d => new HomeOrderDto
|
|
|
|
+ {
|
|
|
|
+ No = d.No,
|
|
|
|
+ OrderId = d.Id,
|
|
|
|
+ Title = d.Title,
|
|
|
|
+ AcceptType = d.AcceptType,
|
|
|
|
+ HotspotName = d.HotspotName,
|
|
|
|
+ Type = "Waited",
|
|
|
|
+ Time = d.ExpiredTime,
|
|
|
|
+ Status = d.Status,
|
|
|
|
+ ActualHandleTime = d.ActualHandleTime,
|
|
|
|
+ CounterSignType = d.CounterSignType
|
|
|
|
+ })
|
|
|
|
+ .ToListAsync();
|
|
|
|
+ isHas = waitedDataList.Any();
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 已超期
|
|
|
|
+ //已超期
|
|
|
|
+ isHas = waitedDataList.Any(x => (x.Time < DateTime.Now && x.Status < EOrderStatus.Filed) ||
|
|
|
|
+ (x.Time < x.ActualHandleTime && x.Status >= EOrderStatus.Filed));
|
|
|
|
+ //超期是否有待办
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 会签待办
|
|
|
|
+ //会签待办
|
|
|
|
+ isHas = waitedDataList.Any(x => x.CounterSignType == ECounterSignType.Center || x.CounterSignType == ECounterSignType.Department);
|
|
|
|
+
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 甄别待审批
|
|
|
|
+ //甄别待审批
|
|
|
|
+ isHas = await _orderScreenRepository.Queryable(hasHandled: !true, isAdmin: isAdmin)
|
|
|
|
+ .Includes(d => d.Order)
|
|
|
|
+ .Includes(d => d.ScreenDetails.Where(sd => sd.AuditUserId == user.Id).OrderByDescending(sd => sd.AuditTime).Take(1).ToList())
|
|
|
|
+ .AnyAsync(d => (d.Status == EScreenStatus.Apply || d.Status == EScreenStatus.Approval || (d.Status == EScreenStatus.SendBack && d.SendBackApply == false)));
|
|
|
|
+
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 延期待审批
|
|
|
|
+ //延期待审批
|
|
|
|
+ isHas = await _orderDelayRepository.Queryable(canView: true, isAdmin: isAdmin)
|
|
|
|
+ .AnyAsync(d => d.DelayState == EDelayState.Examining);
|
|
|
|
+
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 甄别待申请
|
|
|
|
+ //甄别待申请
|
|
|
|
+ isHas = await _orderVisitedDetailRepository.Queryable(false, true)
|
|
|
|
+ .Includes(x => x.OrderVisit)
|
|
|
|
+ .Includes(x => x.OrderVisit, y => y.Order)
|
|
|
|
+ .Includes(x => x.OrderVisit, y => y.Employee)
|
|
|
|
+ .Includes(x => x.OrderScreens)
|
|
|
|
+ .Where(x => x.OrderScreens.Any(s => s.Status == EScreenStatus.SendBack && s.SendBackApply == true) || x.OrderScreens.Any(s => (s.Status != EScreenStatus.SendBack && s.SendBackApply != true)) == false)
|
|
|
|
+ .Where(x => x.OrderVisit.VisitState == EVisitState.Visited && x.OrderVisit.IsCanHandle)
|
|
|
|
+ .Where(x => x.VisitTarget == EVisitTarget.Org && x.VisitOrgCode == user.OrgId && (
|
|
|
|
+ SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "1" ||
|
|
|
|
+ SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "2" ||
|
|
|
|
+ SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "1" ||
|
|
|
|
+ SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "2"
|
|
|
|
+ ))
|
|
|
|
+ .AnyAsync();
|
|
|
|
+
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 退回待审批
|
|
|
|
+ //退回待审批
|
|
|
|
+ isHas = await _orderSendBackAuditRepository.Queryable()
|
|
|
|
+ .Where(d => d.State == ESendBackAuditState.Apply)
|
|
|
|
+ .WhereIF(Roles.Contains("role_sysadmin") == false, x => x.SendBackOrgId == user.OrgId) // 123 系统管理员;
|
|
|
|
+ .AnyAsync();
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 部门即将超期
|
|
|
|
+ //部门即将超期
|
|
|
|
+ isHas = await _orderRepository.Queryable(canView: !isCenter)
|
|
|
|
+ .Includes(d => d.OrderDelays)
|
|
|
|
+ .Where(d => SqlFunc.Subqueryable<WorkflowStep>()
|
|
|
|
+ .Where(step => step.ExternalId == d.Id && step.Status != EWorkflowStepStatus.Handled &&
|
|
|
|
+ ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == user.Id) ||
|
|
|
|
+ (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == user.OrgId) ||
|
|
|
|
+ (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && Roles.Contains(step.RoleId))))
|
|
|
|
+ .Any())
|
|
|
|
+ .Where(d => d.Status < EOrderStatus.Filed && DateTime.Now > d.NearlyExpiredTime && DateTime.Now < d.ExpiredTime)
|
|
|
|
+ .AnyAsync();
|
|
|
|
+ if (isHas)
|
|
|
|
+ {
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+ }
|
|
|
|
+ return isHas;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|