Parcourir la source

Merge branch 'master' of http://110.188.24.182:10023/Fengwo/hotline

田爽 il y a 1 an
Parent
commit
c6edb787be

+ 27 - 4
src/Hotline.Api/Controllers/OrderController.cs

@@ -240,6 +240,7 @@ public class OrderController : BaseController
         orderVisit.OrderId = order.Id;
         orderVisit.VisitState = EVisitState.WaitForVisit;
         orderVisit.PublishTime = DateTime.Now;
+        orderVisit.IsCanHandle = true;
         string visitId = await _orderVisitRepository.AddAsync(orderVisit);
 
         //新增回访信息
@@ -629,18 +630,18 @@ public class OrderController : BaseController
     [HttpGet("visitapply/visitagainlist")]
     public async Task<PagedDto<OrderCanVisitAgainDto>> OrderVisitAgainList([FromQuery]OrderVisitAgainListDto dto)
     {
-        var (total, items) =  await _orderVisitedDetailRepository.Queryable()
+        var (total, items) = await _orderVisitedDetailRepository.Queryable()
             .Includes(x => x.OrderVisit, x => x.Order)
             .WhereIF(!string.IsNullOrEmpty(dto.Keyword), x => x.OrderVisit.Order.No.Contains(dto.Keyword))
             .Where(x => x.OrderVisit.VisitState == EVisitState.Visited && (x.OrderVisit.VisitType == EVisitType.SmsVisit || x.OrderVisit.VisitType == EVisitType.ChipVoiceVisit))
-            .Where(x => SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "1" || SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "2" )
+            .Where(x => SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "1" || SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "2")
+            .Where(x => x.OrderVisit.IsCanHandle)
             .Where(x => x.VisitTarget == EVisitTarget.Org)
             .OrderByDescending(x => x.OrderVisit.VisitTime)
             .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
         return new PagedDto<OrderCanVisitAgainDto>(total, _mapper.Map<IReadOnlyList<OrderCanVisitAgainDto>>(items));
     }
 
-
     /// <summary>
     /// 二次回访申请
     /// </summary>
@@ -662,6 +663,14 @@ public class OrderController : BaseController
         if (orderModel?.CounterSignType != null)
             throw UserFriendlyException.SameMessage("会签件不能申请二次回访");
 
+        var orderVisitModel = await _orderVisitRepository.GetAsync(x => x.Id == dto.OrderVisitId && x.IsCanHandle, HttpContext.RequestAborted);
+        if (orderVisitModel == null)
+            throw UserFriendlyException.SameMessage("当前状态不能进行二次回访");
+
+
+        orderVisitModel.IsCanHandle = false;
+        await _orderVisitRepository.UpdateAsync(orderVisitModel, HttpContext.RequestAborted);
+
         orderVisitApply.EmployeeId = _sessionContext.RequiredUserId;
         orderVisitApply.VisitApplyState = EVisitApplyState.Examining;
         await _orderVisitApplyRepository.AddAsync(orderVisitApply, HttpContext.RequestAborted);
@@ -715,6 +724,7 @@ public class OrderController : BaseController
                 visitModelNew.CreatorOrgLevel = 0;
                 visitModelNew.AreaId = string.Empty;
                 visitModelNew.VisitState = EVisitState.WaitForVisit;
+                visitModelNew.IsCanHandle = false;
 
                 var id = await _orderVisitRepository.AddAsync(visitModelNew, HttpContext.RequestAborted);
                 var visitModelDetail = await _orderVisitedDetailRepository.Queryable().Where(x => x.VisitId == visitModel.Id).ToListAsync(HttpContext.RequestAborted);
@@ -741,6 +751,12 @@ public class OrderController : BaseController
             visitApplyModel.ExaminOpinion = dto.ExaminOpinion;
             visitApplyModel.ExaminTime = DateTime.Now;
             await _orderVisitApplyRepository.UpdateAsync(visitApplyModel, HttpContext.RequestAborted);
+            var visitModel = await _orderVisitRepository.GetAsync(visitApplyModel.OrderVisitId, HttpContext.RequestAborted);
+            if (visitModel!=null)
+            {
+                visitModel.IsCanHandle = true;
+                await _orderVisitRepository.UpdateAsync(visitModel, HttpContext.RequestAborted);
+            }
         }
 
     }
@@ -919,7 +935,11 @@ public class OrderController : BaseController
     [HttpPost("delay")]
     public async Task ApplyDelay([FromBody] DelayStartFlowDto dto)
     {
-        var delaydto = _mapper.Map<ApplyDelayDto>(dto.Data);
+        var delaydto = dto.Data;
+
+        if (string.IsNullOrEmpty(dto.Workflow.Opinion))
+            throw UserFriendlyException.SameMessage("办理意见不能为空!");
+
         //验证工单是否可以申请
         var order = await _orderRepository.GetAsync(delaydto.OrderId, HttpContext.RequestAborted);
         if (order is null)
@@ -943,6 +963,9 @@ public class OrderController : BaseController
         model.ApplyOrgCode = _sessionContext.OrgId;
         model.BeforeDelay = order.ExpiredTime;
         model.DelayState = EDelayState.Examining;
+        model.DelayReason = dto.Workflow.Opinion;
+        model.FileIds = dto.Workflow.Additions;
+
         if (model.BeforeDelay != null)
         {
             model.AfterDelay = _timeLimitDomainService.CalcEndTime(model.BeforeDelay.Value, delaydto.DelayUnit, delaydto.DelayNum, false)?.EndTime;//todo

+ 1 - 1
src/Hotline.Api/config/appsettings.Development.json

@@ -60,7 +60,7 @@
     }
   },
   "DatabaseConfiguration": {
-    "ApplyDbMigrations": false,
+    "ApplyDbMigrations": true,
     "ApplySeed": false
   },
   "MqConfiguration": {

+ 22 - 11
src/Hotline.Application/FlowEngine/WorkflowApplication.cs

@@ -438,7 +438,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         //        .ToList();
         return new NextStepsDto
         {
-            Steps = await GetConfigStepsAsync(startStepDefine.StepType, startStepDefine.BusinessType, firstStepDefines, cancellationToken)
+            Steps = await GetConfigStepsAsync(definition.FlowType, startStepDefine.StepType, startStepDefine.BusinessType, firstStepDefines, cancellationToken)
         };
         //dto.Steps = steps;
         //return dto;
@@ -508,7 +508,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         if (!nextDefines.Any())
             throw new UserFriendlyException("未正确配置下一节点");
 
-        dto.Steps = await GetConfigStepsAsync(currentStep.StepType, currentStep.BusinessType, nextDefines, cancellationToken);
+        dto.Steps = await GetConfigStepsAsync(workflow.FlowType, currentStep.StepType, currentStep.BusinessType, nextDefines, cancellationToken);
 
         if (currentStep.IsInCountersign() && currentStep.IsTopCountersignEndStep(workflow.TopCountersignStepId))
         {
@@ -542,16 +542,22 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
             throw new UserFriendlyException("无效当前节点编号");
         return new NextStepsDto
         {
-            Steps = await GetRecallConfigStepsAsync(workflow.Status is EWorkflowStatus.Completed, currentStep.BusinessType, stepDefines, cancellationToken)
+            Steps = await GetRecallConfigStepsAsync(workflow.Status is EWorkflowStatus.Completed,
+                workflow.FlowType, currentStep.BusinessType, stepDefines, cancellationToken)
         };
     }
 
-    private async Task<IReadOnlyList<NextStepOption>> GetRecallConfigStepsAsync(bool isWorkflowFiled, EBusinessType currentBusinessType, List<StepDefine> stepDefines, CancellationToken cancellationToken)
+    private async Task<IReadOnlyList<NextStepOption>> GetRecallConfigStepsAsync(
+        bool isWorkflowFiled,
+        EFlowType flowType,
+        EBusinessType currentBusinessType,
+        List<StepDefine> stepDefines,
+        CancellationToken cancellationToken)
     {
         var stepOptions = new List<NextStepOption>();
         foreach (var stepDefine in stepDefines)
         {
-            var nextStepOption = await GetConfigStepAsync(stepDefine, cancellationToken);
+            var nextStepOption = await GetConfigStepAsync(flowType, stepDefine, cancellationToken);
             if (stepDefine.StepType is EStepType.End)
             {
                 stepOptions.Add(nextStepOption);
@@ -614,13 +620,17 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         await _workflowDomainService.RejectAsync(workflow, basicDto, cancellationToken);
     }
 
-    private async Task<List<NextStepOption>> GetConfigStepsAsync(EStepType currentStepType,
-        EBusinessType currentBusinessType, List<StepDefine> stepDefines, CancellationToken cancellationToken)
+    private async Task<List<NextStepOption>> GetConfigStepsAsync(
+        EFlowType flowType,
+        EStepType currentStepType,
+        EBusinessType currentBusinessType,
+        List<StepDefine> stepDefines,
+        CancellationToken cancellationToken)
     {
         var stepOptions = new List<NextStepOption>();
         foreach (var stepDefine in stepDefines)
         {
-            var nextStepOption = await GetConfigStepAsync(stepDefine, cancellationToken);
+            var nextStepOption = await GetConfigStepAsync(flowType, stepDefine, cancellationToken);
             if (stepDefine.StepType is EStepType.End)
             {
                 stepOptions.Add(nextStepOption);
@@ -635,7 +645,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         return stepOptions;
     }
 
-    public async Task<NextStepOption> GetConfigStepAsync(StepDefine stepDefine, CancellationToken cancellationToken)
+    public async Task<NextStepOption> GetConfigStepAsync(EFlowType flowType, StepDefine stepDefine, CancellationToken cancellationToken)
     {
         var handlers = new List<Kv>();
         if (stepDefine.StepType is EStepType.End)
@@ -668,8 +678,9 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                     .ToListAsync(cancellationToken);
                 var users1 = roles.SelectMany(d => d.Accounts).Select(d => d.User);
 
-                //解决当前为一级部门选择中心汇总
-                if (stepDefine.StepType != EStepType.Summary || stepDefine.BusinessType != EBusinessType.Center)
+                //工单办理:除当前为一级部门选择中心汇总,其余只能选下级部门
+                if (flowType is EFlowType.Handle
+                    && (stepDefine.StepType != EStepType.Summary || stepDefine.BusinessType != EBusinessType.Center))
                     users1 = users1.Where(d => d.OrgId.StartsWith(levelOneOrgCode));
 
                 handlers = users1.Select(d => new Kv(d.Id, d.Name)).ToList();