|
@@ -29,6 +29,7 @@ using Hotline.Share.Dtos.Enterprise;
|
|
|
using Hotline.Share.Dtos.FlowEngine;
|
|
|
using Hotline.Share.Dtos.FlowEngine.Workflow;
|
|
|
using Hotline.Share.Dtos.Order;
|
|
|
+using Hotline.Share.Dtos.Order.Migration;
|
|
|
using Hotline.Share.Dtos.Settings;
|
|
|
using Hotline.Share.Enums.CallCenter;
|
|
|
using Hotline.Share.Enums.FlowEngine;
|
|
@@ -46,6 +47,7 @@ using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.OpenApi.Writers;
|
|
|
using MiniExcelLibs;
|
|
|
+using MongoDB.Driver;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
using NPOI.SS.Util;
|
|
|
using Org.BouncyCastle.Utilities;
|
|
@@ -594,6 +596,46 @@ public class OrderController : BaseController
|
|
|
.OrderByDescending(x => x.CreationTime).ToListAsync(HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 查询发布平移待办理人
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ /// <exception cref="UserFriendlyException"></exception>
|
|
|
+ [HttpGet("published/migration/{id}")]
|
|
|
+ public async Task<GetOrderMigrationDto> PublishMigration(string id)
|
|
|
+ {
|
|
|
+ var steps = await _workflowStepRepository.Queryable()
|
|
|
+ .Where(d => d.ExternalId == id && d.Status != EWorkflowStepStatus.Handled)
|
|
|
+ .ToListAsync(HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ if (!steps.Any())
|
|
|
+ throw new UserFriendlyException("未查询到待办理节点");
|
|
|
+ if (steps.Count > 1)
|
|
|
+ throw new UserFriendlyException("多个待办理节点暂不支持平移");
|
|
|
+ var step = steps.First();
|
|
|
+ if (step.BusinessType is not EBusinessType.Center and EBusinessType.Send)
|
|
|
+ throw new UserFriendlyException("非中心节点暂不支持平移");
|
|
|
+
|
|
|
+ var setting = _systemSettingCacheManager.GetSetting(SettingConstants.RolePaiDan);
|
|
|
+ var roles = setting?.SettingValue.ToList();
|
|
|
+ var users = await _userRepository.Queryable()
|
|
|
+ .Includes(d => d.Organization)
|
|
|
+ .Where(d => d.Roles.Any(x => roles.Contains(x.Name)))
|
|
|
+ .ToListAsync(HttpContext.RequestAborted);
|
|
|
+ return new GetOrderMigrationDto
|
|
|
+ {
|
|
|
+ StepId = step.Id,
|
|
|
+ Handlers = users.Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ UserId = d.Id,
|
|
|
+ Username = d.Name,
|
|
|
+ OrgId = d.OrgId,
|
|
|
+ OrgName = d.Organization.Name
|
|
|
+ }).ToList()
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 工单回访
|
|
@@ -671,7 +713,7 @@ public class OrderController : BaseController
|
|
|
var dissatisfiedReason = _sysDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.DissatisfiedReason);
|
|
|
var visitManner = _sysDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.VisitManner).Where(x => x.DicDataValue != "-1");
|
|
|
//var callRecord = await _trCallRecordRepository.GetAsync(x => x.CallAccept == orderVisit.CallId); //由CallAccept改为OtherAccept
|
|
|
- var callRecord = await _trCallRecordRepository.GetAsync(x => x.OtherAccept == orderVisit.CallId && string.IsNullOrEmpty(x.OtherAccept)==false,HttpContext.RequestAborted);
|
|
|
+ var callRecord = await _trCallRecordRepository.GetAsync(x => x.OtherAccept == orderVisit.CallId && string.IsNullOrEmpty(x.OtherAccept) == false, HttpContext.RequestAborted);
|
|
|
var recordingFileUrl = "";
|
|
|
var recordingBaseAddress = "";
|
|
|
var recordingAbsolutePath = "";
|
|
@@ -789,7 +831,7 @@ public class OrderController : BaseController
|
|
|
_mapper.Map(detaildto, visit.OrderVisitDetails[i]);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
await _orderVisitRepository.UpdateAsync(visit, HttpContext.RequestAborted);
|
|
|
await _orderVisitedDetailRepository.UpdateRangeAsync(visit.OrderVisitDetails, HttpContext.RequestAborted);
|
|
|
await _orderRepository.UpdateAsync(visit.Order, HttpContext.RequestAborted);
|
|
@@ -1461,10 +1503,12 @@ public class OrderController : BaseController
|
|
|
{
|
|
|
var model = await _orderDelayRepository.Queryable()
|
|
|
.Includes(d => d.Order)
|
|
|
- .Includes(d => d.Workflow)
|
|
|
+ .Includes(d => d.Workflow, x => x.Steps)
|
|
|
.FirstAsync(d => d.Id == id);
|
|
|
var rspModel = _mapper.Map<OrderDelayDto>(model);
|
|
|
- rspModel.IsCanHandle = model.CanHandle(_sessionContext.RequiredUserId, _sessionContext.RequiredOrgId);
|
|
|
+ //rspModel.IsCanHandle = model.CanHandle(_sessionContext.RequiredUserId, _sessionContext.RequiredOrgId);
|
|
|
+ rspModel.IsCanHandle = model.Workflow?.IsCanHandle(
|
|
|
+ _sessionContext.RequiredUserId, _sessionContext.RequiredOrgId, _sessionContext.Roles) ?? false;
|
|
|
rspModel.Handle = false;
|
|
|
if (!string.IsNullOrEmpty(rspModel.WorkflowId))
|
|
|
{
|
|
@@ -1802,11 +1846,13 @@ public class OrderController : BaseController
|
|
|
{
|
|
|
var model = await _orderScreenRepository.Queryable(canView: false)
|
|
|
.Includes(x => x.Order)
|
|
|
- .Includes(x => x.Workflow)
|
|
|
+ .Includes(x => x.Workflow, d => d.Steps)
|
|
|
.Includes(x => x.Visit, d => d.Order)
|
|
|
.FirstAsync(x => x.Id == id);
|
|
|
var rspModel = _mapper.Map<OrderScreenListDto>(model);
|
|
|
- rspModel.IsCanHandle = model.CanHandle(_sessionContext.RequiredUserId, _sessionContext.RequiredOrgId);
|
|
|
+ //rspModel.IsCanHandle = model.CanHandle(_sessionContext.RequiredUserId, _sessionContext.RequiredOrgId);
|
|
|
+ rspModel.IsCanHandle = model.Workflow?.IsCanHandle(
|
|
|
+ _sessionContext.RequiredUserId, _sessionContext.RequiredOrgId, _sessionContext.Roles) ?? false;
|
|
|
rspModel.Handle = false;
|
|
|
if (!string.IsNullOrEmpty(rspModel.WorkflowId))
|
|
|
{
|
|
@@ -2462,7 +2508,7 @@ public class OrderController : BaseController
|
|
|
|
|
|
//工单ID跟通话记录相关联
|
|
|
//var callRecord = await _trCallRecordRepository.GetAsync(p => p.CallAccept == order.CallId, HttpContext.RequestAborted);//由CallAccept改为OtherAccept
|
|
|
- var callRecord = await _trCallRecordRepository.GetAsync(p => p.OtherAccept== order.CallId && string.IsNullOrEmpty(p.OtherAccept) ==false, HttpContext.RequestAborted);
|
|
|
+ var callRecord = await _trCallRecordRepository.GetAsync(p => p.OtherAccept == order.CallId && string.IsNullOrEmpty(p.OtherAccept) == false, HttpContext.RequestAborted);
|
|
|
if (callRecord != null && string.IsNullOrEmpty(callRecord.ExternalId))
|
|
|
{
|
|
|
callRecord.ExternalId = order.Id;
|
|
@@ -3103,7 +3149,7 @@ public class OrderController : BaseController
|
|
|
.WhereIF(dto.StartTime.HasValue, d => d.CreationTime >= dto.StartTime)
|
|
|
.WhereIF(dto.EndTime.HasValue, d => d.CreationTime <= dto.EndTime)
|
|
|
.Where(d => d.Source < ESource.MLSQ || d.Source > ESource.WZSC)
|
|
|
- .Where(d => d.Status != EOrderStatus.BackToProvince && d.Status < EOrderStatus.Filed)
|
|
|
+ .Where(d => d.Status != EOrderStatus.BackToProvince && d.Status < EOrderStatus.Filed)
|
|
|
//.Where(d => SqlFunc.Subqueryable<OrderSpecial>().Where(os => os.OrderId == d.Id).NotAny())
|
|
|
.Where(d => d.OrderSpecials.Any() == false || d.OrderSpecials.Any(s => s.State == 0) == false)
|
|
|
.OrderByDescending(d => d.StartTime)
|
|
@@ -3113,7 +3159,7 @@ public class OrderController : BaseController
|
|
|
|
|
|
dto.IsHandled = false;
|
|
|
isHandled = dto.IsHandled.HasValue && dto.IsHandled.Value;
|
|
|
- EOrderStatus[] handleStatuses = EnumExts.GetFields<EOrderStatus>().Select(d => (EOrderStatus)d.Key).ToArray();
|
|
|
+ EOrderStatus[] handleStatuses = EnumExts.GetFields<EOrderStatus>().Select(d => (EOrderStatus)d.Key).ToArray();
|
|
|
handleStatuses = handleStatuses.WhereIF(dto.IsHandled.HasValue,
|
|
|
d => dto.IsHandled!.Value
|
|
|
? d is not EOrderStatus.WaitForAccept and not EOrderStatus.BackToUnAccept and not EOrderStatus.SpecialToUnAccept
|
|
@@ -3136,7 +3182,7 @@ public class OrderController : BaseController
|
|
|
.OrderByIF(dto.IsHandled == false, d => d.CreationTime, OrderByType.Desc)
|
|
|
.ToPagedListAsync(dto, HttpContext.RequestAborted);
|
|
|
|
|
|
- var page2 = new PagedDto<OrderDto>(total2, _mapper.Map<IReadOnlyList<OrderDto>>(items2));
|
|
|
+ var page2 = new PagedDto<OrderDto>(total2, _mapper.Map<IReadOnlyList<OrderDto>>(items2));
|
|
|
|
|
|
return new { Waited = page1, Sign = page2 };
|
|
|
}
|
|
@@ -4840,7 +4886,7 @@ public class OrderController : BaseController
|
|
|
try
|
|
|
{
|
|
|
|
|
|
- if(item.Source!= "麻辣社区"|| item.Source!= "人民网" || item.Source!= "省长信箱" || item.Source!= "问政四川")
|
|
|
+ if (item.Source != "麻辣社区" || item.Source != "人民网" || item.Source != "省长信箱" || item.Source != "问政四川")
|
|
|
//if (item.Source < ESource.MLSQ || item.Source > ESource.WZSC)
|
|
|
{
|
|
|
errorCount++;
|
|
@@ -4866,78 +4912,78 @@ public class OrderController : BaseController
|
|
|
break;
|
|
|
}
|
|
|
var order = await _orderRepository.GetAsync(x => x.ExternalId == item.ExternalId && x.Source == (ESource)SourceCode, HttpContext.RequestAborted);
|
|
|
-
|
|
|
- order = _mapper.Map<Orders.Order>(item);
|
|
|
- #region 处理数据开始
|
|
|
- order.Source = (ESource)SourceCode; //来源
|
|
|
-
|
|
|
- //处理热点
|
|
|
- //处理一级热点
|
|
|
- string hotspotId = "";
|
|
|
- string hotspotName = "";
|
|
|
- string hotspotFullName = "";
|
|
|
- var hotspotOne = await _hotspotTypeRepository.Queryable().FirstAsync(x => x.HotSpotName == item.HotspotNameOne, HttpContext.RequestAborted);
|
|
|
- if (hotspotOne!=null)
|
|
|
+
|
|
|
+ order = _mapper.Map<Orders.Order>(item);
|
|
|
+ #region 处理数据开始
|
|
|
+ order.Source = (ESource)SourceCode; //来源
|
|
|
+
|
|
|
+ //处理热点
|
|
|
+ //处理一级热点
|
|
|
+ string hotspotId = "";
|
|
|
+ string hotspotName = "";
|
|
|
+ string hotspotFullName = "";
|
|
|
+ var hotspotOne = await _hotspotTypeRepository.Queryable().FirstAsync(x => x.HotSpotName == item.HotspotNameOne, HttpContext.RequestAborted);
|
|
|
+ if (hotspotOne != null)
|
|
|
+ {
|
|
|
+ hotspotId = hotspotOne.Id;
|
|
|
+ hotspotName = hotspotOne.HotSpotName;
|
|
|
+ hotspotFullName = hotspotOne.HotSpotFullName;
|
|
|
+ var hotspotTwo = await _hotspotTypeRepository.Queryable().FirstAsync(x => x.HotSpotName == item.HotspotNameTwo && x.ParentId == hotspotId, HttpContext.RequestAborted);
|
|
|
+ if (hotspotTwo != null)
|
|
|
{
|
|
|
- hotspotId = hotspotOne.Id;
|
|
|
- hotspotName = hotspotOne.HotSpotName;
|
|
|
- hotspotFullName = hotspotOne.HotSpotFullName;
|
|
|
- var hotspotTwo = await _hotspotTypeRepository.Queryable().FirstAsync(x => x.HotSpotName == item.HotspotNameTwo && x.ParentId == hotspotId,HttpContext.RequestAborted);
|
|
|
- if (hotspotTwo!=null)
|
|
|
+ hotspotId = hotspotTwo.Id;
|
|
|
+ hotspotName = hotspotTwo.HotSpotName;
|
|
|
+ hotspotFullName = hotspotTwo.HotSpotFullName;
|
|
|
+ var hotspotThree = await _hotspotTypeRepository.Queryable().FirstAsync(x => x.HotSpotName == item.HotspotNameThree && x.ParentId == hotspotId, HttpContext.RequestAborted);
|
|
|
+ if (hotspotThree != null)
|
|
|
{
|
|
|
- hotspotId = hotspotTwo.Id;
|
|
|
- hotspotName = hotspotTwo.HotSpotName;
|
|
|
- hotspotFullName = hotspotTwo.HotSpotFullName;
|
|
|
- var hotspotThree = await _hotspotTypeRepository.Queryable().FirstAsync(x => x.HotSpotName == item.HotspotNameThree && x.ParentId == hotspotId, HttpContext.RequestAborted);
|
|
|
- if (hotspotThree!=null)
|
|
|
+ hotspotId = hotspotThree.Id;
|
|
|
+ hotspotName = hotspotThree.HotSpotName;
|
|
|
+ hotspotFullName = hotspotThree.HotSpotFullName;
|
|
|
+ var hotspotFour = await _hotspotTypeRepository.Queryable().FirstAsync(x => x.HotSpotName == item.HotspotNameFour && x.ParentId == hotspotId, HttpContext.RequestAborted);
|
|
|
+ if (hotspotFour != null)
|
|
|
{
|
|
|
- hotspotId = hotspotThree.Id;
|
|
|
- hotspotName = hotspotThree.HotSpotName;
|
|
|
- hotspotFullName = hotspotThree.HotSpotFullName;
|
|
|
- var hotspotFour = await _hotspotTypeRepository.Queryable().FirstAsync(x => x.HotSpotName == item.HotspotNameFour && x.ParentId == hotspotId, HttpContext.RequestAborted);
|
|
|
- if (hotspotFour!=null)
|
|
|
+ hotspotId = hotspotFour.Id;
|
|
|
+ hotspotName = hotspotFour.HotSpotName;
|
|
|
+ hotspotFullName = hotspotFour.HotSpotFullName;
|
|
|
+ var hotspotFive = await _hotspotTypeRepository.Queryable().FirstAsync(x => x.HotSpotName == item.HotspotNameFive && x.ParentId == hotspotId, HttpContext.RequestAborted);
|
|
|
+ if (hotspotFive != null)
|
|
|
{
|
|
|
- hotspotId = hotspotFour.Id;
|
|
|
- hotspotName = hotspotFour.HotSpotName;
|
|
|
- hotspotFullName = hotspotFour.HotSpotFullName;
|
|
|
- var hotspotFive = await _hotspotTypeRepository.Queryable().FirstAsync(x => x.HotSpotName == item.HotspotNameFive && x.ParentId == hotspotId, HttpContext.RequestAborted);
|
|
|
- if (hotspotFive!=null)
|
|
|
- {
|
|
|
- hotspotId = hotspotFive.Id;
|
|
|
- hotspotName = hotspotFive.HotSpotName;
|
|
|
- hotspotFullName = hotspotFive.HotSpotFullName;
|
|
|
- }
|
|
|
+ hotspotId = hotspotFive.Id;
|
|
|
+ hotspotName = hotspotFive.HotSpotName;
|
|
|
+ hotspotFullName = hotspotFive.HotSpotFullName;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- order.HotspotId = hotspotId;
|
|
|
- order.HotspotName = hotspotName;
|
|
|
- order.HotspotSpliceName = hotspotFullName;
|
|
|
+ }
|
|
|
+ order.HotspotId = hotspotId;
|
|
|
+ order.HotspotName = hotspotName;
|
|
|
+ order.HotspotSpliceName = hotspotFullName;
|
|
|
|
|
|
- //处理部门
|
|
|
- var orgOne = await _organizeRepository.Queryable().FirstAsync(x => x.Name == item.OrgLevelOneName, HttpContext.RequestAborted);
|
|
|
- if (orgOne!=null)
|
|
|
- {
|
|
|
- order.OrgLevelOneCode = orgOne.Id;
|
|
|
- order.OrgLevelOneName = orgOne.Name;
|
|
|
- var orgTwo = await _organizeRepository.Queryable().FirstAsync(x => x.Name == item.OrgLevelTwoName && x.ParentId == order.OrgLevelOneCode, HttpContext.RequestAborted);
|
|
|
- if (orgTwo!=null)
|
|
|
- {
|
|
|
- order.OrgLevelTwoCode = orgTwo.Id;
|
|
|
- order.OrgLevelTwoName = orgTwo.Name;
|
|
|
- }
|
|
|
- }
|
|
|
- //承办部门
|
|
|
- var ActualHandleOrg = await _organizeRepository.Queryable().FirstAsync(x => x.Name == item.ActualHandleOrgName, HttpContext.RequestAborted);
|
|
|
- if (ActualHandleOrg!=null)
|
|
|
+ //处理部门
|
|
|
+ var orgOne = await _organizeRepository.Queryable().FirstAsync(x => x.Name == item.OrgLevelOneName, HttpContext.RequestAborted);
|
|
|
+ if (orgOne != null)
|
|
|
+ {
|
|
|
+ order.OrgLevelOneCode = orgOne.Id;
|
|
|
+ order.OrgLevelOneName = orgOne.Name;
|
|
|
+ var orgTwo = await _organizeRepository.Queryable().FirstAsync(x => x.Name == item.OrgLevelTwoName && x.ParentId == order.OrgLevelOneCode, HttpContext.RequestAborted);
|
|
|
+ if (orgTwo != null)
|
|
|
{
|
|
|
- order.ActualHandleOrgCode = ActualHandleOrg.Id;
|
|
|
+ order.OrgLevelTwoCode = orgTwo.Id;
|
|
|
+ order.OrgLevelTwoName = orgTwo.Name;
|
|
|
}
|
|
|
+ }
|
|
|
+ //承办部门
|
|
|
+ var ActualHandleOrg = await _organizeRepository.Queryable().FirstAsync(x => x.Name == item.ActualHandleOrgName, HttpContext.RequestAborted);
|
|
|
+ if (ActualHandleOrg != null)
|
|
|
+ {
|
|
|
+ order.ActualHandleOrgCode = ActualHandleOrg.Id;
|
|
|
+ }
|
|
|
|
|
|
- //处理地址
|
|
|
- order.Address = $"{order.Province}{order.City}{order.County}{order.Town}";
|
|
|
- order.FullAddress = $"{order.Address}{order.Street}";
|
|
|
+ //处理地址
|
|
|
+ order.Address = $"{order.Province}{order.City}{order.County}{order.Town}";
|
|
|
+ order.FullAddress = $"{order.Address}{order.Street}";
|
|
|
|
|
|
#endregion
|
|
|
if (order is null)
|
|
@@ -5386,4 +5432,48 @@ public class OrderController : BaseController
|
|
|
return _mapper.Map<IReadOnlyList<OrderModifyingRecordsDto>>(list);
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
+ #region 工单平移
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询工单平移待办理人
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("migration/{orderId}")]
|
|
|
+ public async Task<GetOrderMigrationDto> Migration(string orderId)
|
|
|
+ {
|
|
|
+ var steps = await _workflowStepRepository.Queryable()
|
|
|
+ .Where(d => d.ExternalId == orderId && d.Status != EWorkflowStepStatus.Handled)
|
|
|
+ .ToListAsync(HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ if (!steps.Any())
|
|
|
+ throw new UserFriendlyException("未查询到待办理节点");
|
|
|
+ if (steps.Count > 1)
|
|
|
+ throw new UserFriendlyException("多个待办理节点暂不支持平移");
|
|
|
+ var step = steps.First();
|
|
|
+ if (step.BusinessType is not EBusinessType.Center and EBusinessType.Send)
|
|
|
+ throw new UserFriendlyException("非中心节点暂不支持平移");
|
|
|
+
|
|
|
+ var setting = step.BusinessType is EBusinessType.Center
|
|
|
+ ? _systemSettingCacheManager.GetSetting(SettingConstants.RoleZuoXi)
|
|
|
+ : _systemSettingCacheManager.GetSetting(SettingConstants.RolePaiDan);
|
|
|
+ var roles = setting?.SettingValue.ToList();
|
|
|
+ var users = await _userRepository.Queryable()
|
|
|
+ .Includes(d => d.Organization)
|
|
|
+ .Where(d => d.Roles.Any(x => roles.Contains(x.Name)))
|
|
|
+ .ToListAsync(HttpContext.RequestAborted);
|
|
|
+ return new GetOrderMigrationDto
|
|
|
+ {
|
|
|
+ StepId = step.Id,
|
|
|
+ Handlers = users.Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ UserId = d.Id,
|
|
|
+ Username = d.Name,
|
|
|
+ OrgId = d.OrgId,
|
|
|
+ OrgName = d.Organization.Name
|
|
|
+ }).ToList()
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|