|
@@ -31,6 +31,7 @@ using DocumentFormat.OpenXml.Office2010.Excel;
|
|
|
using Hotline.Share.Dtos.FlowEngine.Workflow;
|
|
|
using Hotline.Validators.FlowEngine;
|
|
|
using FluentValidation;
|
|
|
+using Hotline.Authentications;
|
|
|
|
|
|
namespace Hotline.Application.Orders
|
|
|
{
|
|
@@ -53,9 +54,9 @@ namespace Hotline.Application.Orders
|
|
|
private readonly IOrderDomainService _orderDomainService;
|
|
|
private readonly IOrderScreenRepository _orderScreenRepository;
|
|
|
private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
|
|
|
- private readonly IOrderApplication _orderApplication;
|
|
|
+ private readonly IOrderApplication _orderApplication;
|
|
|
|
|
|
- public OrderSecondaryHandlingApplication(
|
|
|
+ public OrderSecondaryHandlingApplication(
|
|
|
IMapper mapper,
|
|
|
IRepository<OrderSecondaryHandling> orderSecondaryHandlingRepository,
|
|
|
IFileRepository fileRepository,
|
|
@@ -72,8 +73,8 @@ namespace Hotline.Application.Orders
|
|
|
IOrderDomainService orderDomainService,
|
|
|
IOrderScreenRepository orderScreenRepository,
|
|
|
IOptionsSnapshot<AppConfiguration> appOptions,
|
|
|
- ICalcExpireTime expireTime,
|
|
|
- IOrderApplication orderApplication)
|
|
|
+ ICalcExpireTime expireTime,
|
|
|
+ IOrderApplication orderApplication)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_orderSecondaryHandlingRepository = orderSecondaryHandlingRepository;
|
|
@@ -92,8 +93,8 @@ namespace Hotline.Application.Orders
|
|
|
_expireTime = expireTime;
|
|
|
_orderScreenRepository = orderScreenRepository;
|
|
|
_appOptions = appOptions;
|
|
|
- _orderApplication = orderApplication;
|
|
|
- }
|
|
|
+ _orderApplication = orderApplication;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 二次办理新增
|
|
@@ -149,9 +150,9 @@ namespace Hotline.Application.Orders
|
|
|
var visit = await _orderVisitRepository.GetAsync(x => x.Id == model.VisitId, cancellationToken);
|
|
|
if (visit != null)
|
|
|
{
|
|
|
- //visit.VisitState = model.VisitState;
|
|
|
- visit.IsCanHandle = true;
|
|
|
- await _orderVisitRepository.UpdateAsync(visit, cancellationToken);
|
|
|
+ //visit.VisitState = model.VisitState;
|
|
|
+ visit.IsCanHandle = true;
|
|
|
+ await _orderVisitRepository.UpdateAsync(visit, cancellationToken);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -168,14 +169,14 @@ namespace Hotline.Application.Orders
|
|
|
model.AuditUser = _sessionContext.UserName;
|
|
|
model.AuditTime = DateTime.Now;
|
|
|
var visit = await _orderVisitRepository.GetAsync(x => x.OrderId == model.OrderId, cancellationToken);
|
|
|
- if (model.State == ESecondaryHandlingState.End)
|
|
|
+ if (model.State == ESecondaryHandlingState.End)
|
|
|
{
|
|
|
var order = await _orderRepository.GetAsync(x => x.Id == model.OrderId, cancellationToken);
|
|
|
if (string.IsNullOrEmpty(order.WorkflowId))
|
|
|
throw UserFriendlyException.SameMessage("无效二次办理审批信息,没有找到对应流程信息!");
|
|
|
string orgId = order.CounterSignType == ECounterSignType.Department ? model.ApplyOrgId.Substring(0, 6) : model.ApplyOrgId;
|
|
|
- var step = await _workflowDomainService.FindLastHandleStepAsync(order.WorkflowId, orgId, cancellationToken);
|
|
|
- if (step == null)
|
|
|
+ var step = await _workflowDomainService.FindLastHandleStepAsync(order.WorkflowId, orgId, cancellationToken);
|
|
|
+ if (step == null)
|
|
|
throw UserFriendlyException.SameMessage("无效二次办理审批信息,没有找到对应流程节点!");
|
|
|
var recall = new RecallDto
|
|
|
{
|
|
@@ -190,18 +191,18 @@ namespace Hotline.Application.Orders
|
|
|
};
|
|
|
var reTransactNum = order.ReTransactNum is null ? 1 : order.ReTransactNum + 1;
|
|
|
//var expiredTime = _timeLimitDomainService.CalcEndTime(DateTime.Now, order.AcceptTypeCode);
|
|
|
-
|
|
|
- var expiredTime = await _expireTime.CalcEndTime(DateTime.Now,DateTime.Now, order.AcceptTypeCode);
|
|
|
+
|
|
|
+ var expiredTime = await _expireTime.CalcEndTime(DateTime.Now, DateTime.Now, order.AcceptTypeCode);
|
|
|
var processType = step.FlowDirection == EFlowDirection.OrgToCenter || step.FlowDirection == EFlowDirection.CenterToCenter ? EProcessType.Zhiban : EProcessType.Jiaoban;
|
|
|
var isOrderFiled = order.Status >= EOrderStatus.Filed;
|
|
|
order.ExpiredTime = expiredTime.ExpiredTime;
|
|
|
- order.NearlyExpiredTime = expiredTime.NearlyExpiredTime;
|
|
|
- order.NearlyExpiredTimeOne = expiredTime.NearlyExpiredTimeOne;
|
|
|
- order.ReTransactNum = reTransactNum;
|
|
|
- order.ProcessType = processType;
|
|
|
- order.Status = EOrderStatus.Special;
|
|
|
+ order.NearlyExpiredTime = expiredTime.NearlyExpiredTime;
|
|
|
+ order.NearlyExpiredTimeOne = expiredTime.NearlyExpiredTimeOne;
|
|
|
+ order.ReTransactNum = reTransactNum;
|
|
|
+ order.ProcessType = processType;
|
|
|
+ order.Status = EOrderStatus.Special;
|
|
|
|
|
|
- await _orderRepository.Updateable().SetColumns(o => new Order() { ExpiredTime = expiredTime.ExpiredTime, NearlyExpiredTime = expiredTime.NearlyExpiredTime, NearlyExpiredTimeOne = expiredTime.NearlyExpiredTimeOne, ReTransactNum = reTransactNum, ProcessType = processType, Status = EOrderStatus.Handling })
|
|
|
+ await _orderRepository.Updateable().SetColumns(o => new Order() { ExpiredTime = expiredTime.ExpiredTime, NearlyExpiredTime = expiredTime.NearlyExpiredTime, NearlyExpiredTimeOne = expiredTime.NearlyExpiredTimeOne, ReTransactNum = reTransactNum, ProcessType = processType, Status = EOrderStatus.Handling })
|
|
|
.Where(o => o.Id == order.Id).ExecuteCommandAsync(cancellationToken);
|
|
|
var orderDto = _mapper.Map<OrderDto>(order);
|
|
|
await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderExpiredTimeUpdate, orderDto, cancellationToken: cancellationToken);
|
|
@@ -224,40 +225,40 @@ namespace Hotline.Application.Orders
|
|
|
if (_appOptions.Value.IsYiBin)
|
|
|
{
|
|
|
var screen = await _orderScreenRepository.Queryable().FirstAsync(
|
|
|
- x => x.OrderId == model.OrderId &&
|
|
|
- (x.Status != EScreenStatus.End && x.Status != EScreenStatus.Refuse), cancellationToken);
|
|
|
- if (screen != null)
|
|
|
- {
|
|
|
- await _orderScreenRepository.RemoveAsync(screen, false, cancellationToken);
|
|
|
- }
|
|
|
+ x => x.OrderId == model.OrderId &&
|
|
|
+ (x.Status != EScreenStatus.End && x.Status != EScreenStatus.Refuse), cancellationToken);
|
|
|
+ if (screen != null)
|
|
|
+ {
|
|
|
+ await _orderScreenRepository.RemoveAsync(screen, false, cancellationToken);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- var (workflow, targetStepDefine, currentStep, targetStep, newStep, isOrgToCenter) = await _workflowDomainService.RecallAsync(recall,
|
|
|
- recall.NextHandlers.FirstOrDefault(), EWorkflowTraceType.SecondHandle,
|
|
|
- order.ExpiredTime, order.Status >= EOrderStatus.Filed, EHandleMode.SecondaryHandle,
|
|
|
- async (workflow, currentStep, targetStepDefine, targetStep, targetStepNew) =>
|
|
|
- {
|
|
|
- var basicWorkflowDto = _mapper.Map<BasicWorkflowDto>(dto);
|
|
|
- var stepAssignInfo = await _orderApplication.GetOrderRecallAssignInfoAsync(workflow, targetStepDefine, targetStep,
|
|
|
- basicWorkflowDto, cancellationToken);
|
|
|
- if (stepAssignInfo is null) return;
|
|
|
- var validator = new StepAssignInfoValidator();
|
|
|
- await validator.ValidateAndThrowAsync(stepAssignInfo, cancellationToken);
|
|
|
-
|
|
|
- targetStepNew.Assign(stepAssignInfo);
|
|
|
- },
|
|
|
- cancellationToken);
|
|
|
+ var (workflow, targetStepDefine, currentStep, targetStep, newStep, isOrgToCenter) = await _workflowDomainService.RecallAsync(recall,
|
|
|
+ recall.NextHandlers.FirstOrDefault(), EWorkflowTraceType.SecondHandle,
|
|
|
+ order.ExpiredTime, order.Status >= EOrderStatus.Filed, EHandleMode.SecondaryHandle,
|
|
|
+ async (workflow, currentStep, targetStepDefine, targetStep, targetStepNew) =>
|
|
|
+ {
|
|
|
+ var basicWorkflowDto = _mapper.Map<BasicWorkflowDto>(dto);
|
|
|
+ var stepAssignInfo = await _orderApplication.GetOrderRecallAssignInfoAsync(workflow, targetStepDefine, targetStep,
|
|
|
+ basicWorkflowDto, cancellationToken);
|
|
|
+ if (stepAssignInfo is null) return;
|
|
|
+ var validator = new StepAssignInfoValidator();
|
|
|
+ await validator.ValidateAndThrowAsync(stepAssignInfo, cancellationToken);
|
|
|
+
|
|
|
+ targetStepNew.Assign(stepAssignInfo);
|
|
|
+ },
|
|
|
+ cancellationToken);
|
|
|
_mapper.Map(workflow, order);
|
|
|
order.FileEmpty();
|
|
|
await _orderRepository.UpdateAsync(order, false, cancellationToken);
|
|
|
|
|
|
visit.VisitState = EVisitState.None;
|
|
|
await _orderVisitRepository.UpdateAsync(visit, cancellationToken);
|
|
|
- }
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
visit.IsCanHandle = true;
|
|
|
- await _orderVisitRepository.UpdateAsync(visit, cancellationToken);
|
|
|
+ await _orderVisitRepository.UpdateAsync(visit, cancellationToken);
|
|
|
}
|
|
|
await _orderSecondaryHandlingRepository.UpdateAsync(model, cancellationToken);
|
|
|
}
|
|
@@ -281,7 +282,7 @@ namespace Hotline.Application.Orders
|
|
|
.Where(x => x.OrderVisit.Order.IsProvince == false)
|
|
|
.LeftJoin<OrderScreen>((x, s) => x.Id == s.VisitDetailId && s.Status < EScreenStatus.End && s.IsDeleted == false)
|
|
|
//.Where((x, s) => s.Id == null && (x.SecondaryHandling.State == ESecondaryHandlingState.NotApply || x.SecondaryHandling.Id == null))
|
|
|
- .Where(x=> SqlFunc.Subqueryable<OrderSecondaryHandling>().Where(osh => osh.VisitDetailId == x.Id && osh.State != ESecondaryHandlingState.NotApply).NotAny())
|
|
|
+ .Where(x => SqlFunc.Subqueryable<OrderSecondaryHandling>().Where(osh => osh.VisitDetailId == x.Id && osh.State != ESecondaryHandlingState.NotApply).NotAny())
|
|
|
//.Where(x => x.OrderVisit.VisitTime < dto.CreationTimeEnd && x.OrderVisit.VisitTime > dto.CreationTimeStart)
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.No), x => x.OrderVisit.Order!.No!.Contains(dto.No!))
|
|
|
.WhereIF(dto.IsProvince.HasValue, x => x.OrderVisit.Order!.IsProvince == dto.IsProvince)
|
|
@@ -301,7 +302,7 @@ namespace Hotline.Application.Orders
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.OrgNoSatisfiedReason), x => SqlFunc.JsonField(x.OrgNoSatisfiedReason, "Key") == dto.OrgNoSatisfiedReason)
|
|
|
//.Where(x => SqlFunc.Subqueryable<OrderVisit>().Where(ov => ov.Id == x.VisitId && ov.VisitState == EVisitState.Visited && ov.IsCanHandle).Any())
|
|
|
.Where((x, s) => x.OrderVisit.VisitState == EVisitState.Visited && x.OrderVisit.IsCanHandle)
|
|
|
- .WhereIF(!isAdmin, (x, s) => (x.OrderVisit.Order.CounterSignType == ECounterSignType.Department || x.OrderVisit.Order.CounterSignType == null) && x.VisitOrgCode.StartsWith(_sessionContext.OrgId))
|
|
|
+ .WhereIF(!isAdmin, (x, s) => (x.OrderVisit.Order.CounterSignType == ECounterSignType.Department || x.OrderVisit.Order.CounterSignType == null) && x.VisitOrgCode.StartsWith(_sessionContext.OrgId))
|
|
|
;
|
|
|
if (_sessionContext.OrgId != null && !_sessionContext.OrgIsCenter)
|
|
|
{
|
|
@@ -328,14 +329,14 @@ namespace Hotline.Application.Orders
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- return query.OrderByDescending((x, s) => x.CreationTime);
|
|
|
- }
|
|
|
+ return query.OrderByDescending((x, s) => x.CreationTime);
|
|
|
+ }
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 二次办理列表查询
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- public ISugarQueryable<OrderSecondaryHandling> Query(SecondaryHandlingListDto dto, CancellationToken cancellationToken)
|
|
|
+ /// <summary>
|
|
|
+ /// 二次办理列表查询
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public ISugarQueryable<OrderSecondaryHandling> Query(SecondaryHandlingListDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (dto.CreationTimeEnd.HasValue)
|
|
|
dto.CreationTimeEnd = dto.CreationTimeEnd.Value.AddDays(1).AddSeconds(-1);
|
|
@@ -345,7 +346,7 @@ namespace Hotline.Application.Orders
|
|
|
.Includes(x => x.Visit, d => d.Order)
|
|
|
.Where(x => x.State > ESecondaryHandlingState.NotApply)
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => x.Visit.Order.Title.Contains(dto.Keyword!) || x.Visit.Order.No.Contains(dto.Keyword!))
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.Title), x => x.Visit.Order.Title.Contains(dto.Title!))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Title), x => x.Visit.Order.Title.Contains(dto.Title!))
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.No), x => x.Visit.Order.No.Contains(dto.No!))
|
|
|
.WhereIF(dto.Status is ESecondaryHandlingState.Apply, x => x.State == ESecondaryHandlingState.Apply)
|
|
|
.WhereIF(dto.Status is ESecondaryHandlingState.Handled, x => x.State != ESecondaryHandlingState.Apply)
|
|
@@ -377,20 +378,27 @@ namespace Hotline.Application.Orders
|
|
|
/// <returns></returns>
|
|
|
public ISugarQueryable<SecondaryHandlingVo> SecondaryHandlingReport(QuerySecondaryHandlingRequest dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- return _orderSecondaryHandlingRepository.Queryable()
|
|
|
- .WhereIF(dto.StartTime.HasValue, x => x.CreationTime >= dto.StartTime)
|
|
|
- .WhereIF(dto.EndTime.HasValue, x => x.CreationTime <= dto.EndTime)
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.OrgName), x => x.ApplyOrgName.Equals(dto.OrgName))
|
|
|
- .Where(x => x.State == ESecondaryHandlingState.End)
|
|
|
- .GroupBy(x => new { x.ApplyOrgId, x.ApplyOrgName })
|
|
|
- .Select(x => new SecondaryHandlingVo
|
|
|
- {
|
|
|
- OrgId = x.ApplyOrgId,
|
|
|
- OrgName = x.ApplyOrgName,
|
|
|
- Num = SqlFunc.AggregateCount(x.Id)
|
|
|
- })
|
|
|
- .OrderByIF(dto.SortRule is 0, x => x.Num, OrderByType.Asc)
|
|
|
- .OrderByIF(dto.SortRule is 1, x => x.Num, OrderByType.Desc);
|
|
|
+ var query = _orderSecondaryHandlingRepository.Queryable();
|
|
|
+
|
|
|
+ var isCenter = _sessionContext.OrgIsCenter;
|
|
|
+ if (!isCenter)
|
|
|
+ {
|
|
|
+ query.Where(x => x.ApplyOrgId.StartsWith(_sessionContext.OrgId));
|
|
|
+ }
|
|
|
+
|
|
|
+ return query.WhereIF(dto.StartTime.HasValue, x => x.CreationTime >= dto.StartTime)
|
|
|
+ .WhereIF(dto.EndTime.HasValue, x => x.CreationTime <= dto.EndTime)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.OrgName), x => x.ApplyOrgName.Equals(dto.OrgName))
|
|
|
+ .Where(x => x.State == ESecondaryHandlingState.End)
|
|
|
+ .GroupBy(x => new { x.ApplyOrgId, x.ApplyOrgName })
|
|
|
+ .Select(x => new SecondaryHandlingVo
|
|
|
+ {
|
|
|
+ OrgId = x.ApplyOrgId,
|
|
|
+ OrgName = x.ApplyOrgName,
|
|
|
+ Num = SqlFunc.AggregateCount(x.Id)
|
|
|
+ })
|
|
|
+ .OrderByIF(dto.SortRule is 0, x => x.Num, OrderByType.Asc)
|
|
|
+ .OrderByIF(dto.SortRule is 1, x => x.Num, OrderByType.Desc);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -419,7 +427,15 @@ namespace Hotline.Application.Orders
|
|
|
/// <returns></returns>
|
|
|
public ISugarQueryable<SecondaryHandlingSatisfactionVo> SecondaryHandlingSatisfactionReport(QuerySecondaryHandlingRequest dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- return _orderSecondaryHandlingRepository.Queryable()
|
|
|
+ var query = _orderSecondaryHandlingRepository.Queryable();
|
|
|
+
|
|
|
+ var isCenter = _sessionContext.OrgIsCenter;
|
|
|
+ if (!isCenter)
|
|
|
+ {
|
|
|
+ query.Where(x => x.ApplyOrgId.StartsWith(_sessionContext.OrgId));
|
|
|
+ }
|
|
|
+
|
|
|
+ return query
|
|
|
.Includes(x => x.Order)
|
|
|
.Includes(x => x.Visit)
|
|
|
.Includes(x => x.VisitDetail)
|