using DotNetCore.CAP;
using Hotline.Share.Dtos.Order;
using Hotline.Share.Enums.Order;
using MapsterMapper;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Sharing.Application;
using Sharing.Notifications.HuiJu;
using Sharing.Notifications.Knowledge;
using Sharing.Notifications.XieTong;
using Sharing.Province.Dtos.HuiJu.Send;
using Sharing.Province.Dtos.XieTong.Knowledge;
using Sharing.Province.Dtos.XieTong.Send;
using Sharing.Province.HuiJu.Send;
using Sharing.Province.XieTong.Knowledge;
using Sharing.Province.XieTong.Receive;
using Sharing.Province.XieTong.Send;
namespace Sharing.Api.Controllers
{
///
///
///
public class HotlineMessageReceiveController : Controller
{
#region 注入
private readonly IMediator _mediator;
private readonly ILogger _logger;
private readonly IMapper _mapper;
private readonly IGetCaseResultReceiveRepository _getCaseResultReceiveRepository;
private readonly IGetCaseProcessReceiveRepository _getCaseProcessReceiveRepository;
private readonly IGetVisitInfoReceiveRepository _getVisitInfoReceiveRepository;
private readonly IGetCaseBackApplyRepository _getCaseBackApplyRepository;
private readonly IDelayCaseInfoSendRepository _delayCaseInfoSendRepository;
private readonly ISendSuperviseProcessInfoRepository _sendSuperviseProcessInfoRepository;
private readonly ISendSuperviseResultInfoRepository _sendSuperviseResultInfoRepository;
private readonly ISubmitCaseInfoRepository _submitCaseInfoRepository;
private readonly ISubmitCaseResultRepository _submitCaseResultRepository;
private readonly ISubmitCaseProcessRepository _submitCaseProcessRepository;
private readonly ISubmitVisitInfoRepository _submitVisitInfoRepository;
private readonly ISubmitCaseRecordRepository _submitCaseRecordRepository;
private readonly ISubmitCaseTotalRepository _submitCaseTotalRepository;
private readonly ISendCaseInfoRepository _sendCaseInfoRepository;
private readonly ISupplyCaseInfoSendRepository _supplyCaseInfoSendRepository;
private readonly IRevokeCaseInfoRepository _revokeCaseInfoRepository;
private readonly IRemindCaseInfoRepository _remindCaseInfoRepository;
private readonly IGetKnowledgeInfoSendRepository _getKnowledgeInfoSendRepository;
private readonly IGetKnowledgeInfoUpdateRepository _getKnowledgeInfoUpdateRepository;
private readonly IGetKnowledgeInfoAbandonRepository _getKnowledgeInfoAbandonRepository;
private readonly ISendRealTimeStatusRepository _sendRealTimeStatusRepository;
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public HotlineMessageReceiveController(IMediator mediator, ILogger logger, IMapper mapper
, IGetCaseResultReceiveRepository getCaseResultReceiveRepository, IGetCaseProcessReceiveRepository getCaseProcessReceiveRepository
, IGetVisitInfoReceiveRepository getVisitInfoReceiveRepository, IGetCaseBackApplyRepository getCaseBackApplyRepository
, IDelayCaseInfoSendRepository delayCaseInfoSendRepository, ISendSuperviseProcessInfoRepository sendSuperviseProcessInfoRepository
, ISendSuperviseResultInfoRepository sendSuperviseResultInfoRepository, ISubmitCaseInfoRepository submitCaseInfoRepository
, ISubmitCaseResultRepository submitCaseResultRepository, ISubmitCaseProcessRepository submitCaseProcessRepository
, ISubmitVisitInfoRepository submitVisitInfoRepository, ISubmitCaseRecordRepository submitCaseRecordRepository
, ISubmitCaseTotalRepository submitCaseTotalRepository, ISendCaseInfoRepository sendCaseInfoRepository
, ISupplyCaseInfoSendRepository supplyCaseInfoSendRepository, IRevokeCaseInfoRepository revokeCaseInfoRepository
, IRemindCaseInfoRepository remindCaseInfoRepository, IGetKnowledgeInfoSendRepository getKnowledgeInfoSendRepository
, IGetKnowledgeInfoUpdateRepository getKnowledgeInfoUpdateRepository, IGetKnowledgeInfoAbandonRepository getKnowledgeInfoAbandonRepository
, ISendRealTimeStatusRepository sendRealTimeStatusRepository)
{
_mediator = mediator;
_logger = logger;
_mapper = mapper;
_getCaseResultReceiveRepository = getCaseResultReceiveRepository;
_getCaseProcessReceiveRepository = getCaseProcessReceiveRepository;
_getVisitInfoReceiveRepository = getVisitInfoReceiveRepository;
_getCaseBackApplyRepository = getCaseBackApplyRepository;
_delayCaseInfoSendRepository = delayCaseInfoSendRepository;
_sendSuperviseProcessInfoRepository = sendSuperviseProcessInfoRepository;
_sendSuperviseResultInfoRepository = sendSuperviseResultInfoRepository;
_submitCaseInfoRepository = submitCaseInfoRepository;
_submitCaseResultRepository = submitCaseResultRepository;
_submitCaseProcessRepository = submitCaseProcessRepository;
_submitVisitInfoRepository = submitVisitInfoRepository;
_submitCaseRecordRepository = submitCaseRecordRepository;
_submitCaseTotalRepository = submitCaseTotalRepository;
_sendCaseInfoRepository = sendCaseInfoRepository;
_supplyCaseInfoSendRepository = supplyCaseInfoSendRepository;
_revokeCaseInfoRepository = revokeCaseInfoRepository;
_remindCaseInfoRepository = remindCaseInfoRepository;
_getKnowledgeInfoSendRepository = getKnowledgeInfoSendRepository;
_getKnowledgeInfoUpdateRepository = getKnowledgeInfoUpdateRepository;
_getKnowledgeInfoAbandonRepository = getKnowledgeInfoAbandonRepository;
_sendRealTimeStatusRepository = sendRealTimeStatusRepository;
}
#endregion
#region 协同-第一批次
///
/// 服务工单交办处理
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderGetCaseResultReceive)]
public async Task GetCaseResultReceive(GetCaseResultReceiveInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _getCaseResultReceiveRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new GetCaseResultReceiveNotification(data));
}
///
/// 服务工单交办处理过程
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderGetCaseProcessReceive)]
public async Task GetCaseProcessReceive(GetCaseProcessReceiveInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _getCaseProcessReceiveRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new GetCaseProcessReceiveNotification(data));
}
///
/// 服务工单交办评价
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderGetVisitInfoReceive)]
public async Task GetVisitInfoReceive(GetVisitInfoReceiveInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _getVisitInfoReceiveRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new GetVisitInfoReceiveNotification(data));
}
///
/// 退回申请
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderGetCaseBackApply)]
public async Task GetCaseBackApply(GetCaseBackApplyInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _getCaseBackApplyRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new GetCaseBackApplyNotification(data));
}
///
/// 服务工单申请延时
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderDelayCaseInfoSend)]
public async Task DelayCaseInfoSend(DelayCaseInfoSendInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _delayCaseInfoSendRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new DelayCaseInfoSendNotification(data));
}
///
/// 服务工单督办过程
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderSendSuperviseProcessInfo)]
public async Task SendSuperviseProcessInfo(SendSuperviseProcessInfoInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _sendSuperviseProcessInfoRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SendSuperviseProcessInfoNotification(data));
}
///
/// 服务工单督办结果
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderSendSuperviseResultInfo)]
public async Task SendSuperviseResultInfo(SendSuperviseResultInfoInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _sendSuperviseResultInfoRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SendSuperviseResultInfoNotification(data));
}
#endregion
#region 汇聚-第二批次
///
/// 服务工单受理 --- 部分字段未赋值处理
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderCreated)]
public async Task ReceiveOrderCreated(OrderDto dto)
{
//处理数据
SubmitCaseInfo submitCaseInfo = new SubmitCaseInfo
{
OrderID = dto.Id,
No = dto.No,
CaseTitle = dto.Title,
CaseRegister = dto.EmployeeName,
CaseRegisterNo = dto.EmployeeStaffNo,
CaseDate = Convert.ToDateTime(dto.CreationTime),
PhoneNumber = dto.Contact,
AppLicantName = dto.FromName,
AppLicantAge = dto.AgeRangeCode,
AppLicantId = dto.LicenceNo,
CaseAccord = "",
CaseContent = dto.Content,
CaseProcessType = "",
CaseIsPublic = "",
CaseIsSecrect = "",
CaseIsVisit = "",
CaseValid = "",
TSigntTmeBf = null,
TfdBackTimeBf = null,
TBackTimeBf = null,
RelateSerial = "",
CaseLngLat = "",
CaseEmotion = "",
CaseAddress = "",
EventDate = null,
CaseGoal = "",
ThemeSerial = "",
AdviseType = "",
AdviseDept = "",
ComplainType = "",
ComplainDept = "",
PushType = "",
};
submitCaseInfo.CaseSerial = "";
//处理诉求渠道
switch (dto.Channel)
{
case EChannel.Phone:
submitCaseInfo.CaseSource = "RGDH";
break;
case EChannel.WxOfficial:
submitCaseInfo.CaseSource = "WX";
break;
case EChannel.Web:
submitCaseInfo.CaseSource = "WZ";
break;
case EChannel.App:
submitCaseInfo.CaseSource = "Ap";
break;
case EChannel.WxMiniProgram:
submitCaseInfo.CaseSource = "XCX";
break;
default:
break;
}
//处理性别
switch (dto.FromGender)
{
case EGender.Female:
submitCaseInfo.AppLicantSex = "0";
break;
case EGender.Male:
submitCaseInfo.AppLicantSex = "1";
break;
case EGender.Unknown:
submitCaseInfo.AppLicantSex = "2";
break;
default:
break;
}
//处理证件类型
switch (dto.LicenceTypeCode)
{
case "10":
submitCaseInfo.CertifiCateType = "10";
break;
case "40":
submitCaseInfo.CertifiCateType = "20";
break;
case "55":
submitCaseInfo.CertifiCateType = "30";
break;
case "57":
submitCaseInfo.CertifiCateType = "40";
break;
default:
submitCaseInfo.CertifiCateType = "50";
break;
}
//处理受理类型
switch (dto.AcceptType)
{
case EAcceptType.Consult:
submitCaseInfo.CaseType = "10";
break;
case EAcceptType.Suggest:
submitCaseInfo.CaseType = "15";
break;
case EAcceptType.SeekHelp:
submitCaseInfo.CaseType = "20";
break;
case EAcceptType.Praise:
submitCaseInfo.CaseType = "25";
break;
case EAcceptType.Report:
submitCaseInfo.CaseType = "30";
break;
case EAcceptType.Complain:
submitCaseInfo.CaseType = "35";
break;
case EAcceptType.Other:
submitCaseInfo.CaseType = "40";
break;
default:
break;
}
//处理紧急程度
switch (dto.EmergencyLevel)
{
case EEmergencyLevel.QuiteEmergency:
submitCaseInfo.CaseIsUrgent = "10";
break;
case EEmergencyLevel.Emergency:
submitCaseInfo.CaseIsUrgent = "20";
break;
default:
submitCaseInfo.CaseIsUrgent = "30";
break;
}
// submitCaseInfo.Id = await _submitCaseInfoRepository.AddAsync(submitCaseInfo, HttpContext.RequestAborted);
await _mediator.Publish(new OrderCreatedNotification(submitCaseInfo));
}
///
/// 服务工单处理结果
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderSubmitCaseResult)]
public async Task SubmitCaseResult(CaseResult dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _submitCaseResultRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SubmitCaseResultNotification(data));
}
///
/// 服务工单处理过程
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderSubmitCaseProcess)]
public async Task SubmitCaseProcess(CaseProcess dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _submitCaseProcessRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SubmitCaseProcessNotification(data));
}
///
/// 服务工单回访评价
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderSubmitVisitInfo)]
public async Task SubmitVisitInfo(VisitInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _submitVisitInfoRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SubmitVisitInfoNotification(data));
}
///
/// 电话记录
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderSubmitCaseRecord)]
public async Task SubmitCaseRecord(CaseRecord dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _submitCaseRecordRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SubmitCaseRecordNotification(data));
}
///
/// 统计数据
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderSubmitCaseTotal)]
public async Task SubmitCaseTotal(CaseTotal dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _submitCaseTotalRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SubmitCaseTotalNotification(data));
}
#endregion
#region 协同-第三批次
///
/// 服务工单上报 --- 部分字段未赋值处理
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.SendCaseInfo)]
public async Task SendCaseInfo(OrderDto dto)
{
//处理数据
SendCaseInfo sendCaseInfo = new SendCaseInfo
{
OrderID = dto.Id,
No = dto.No,
CaseTitle = dto.Title,
CaseRegister = dto.EmployeeName,
CaseRegisterNo = dto.EmployeeStaffNo,
CaseDate = Convert.ToDateTime(dto.CreationTime),
PhoneNumber = dto.Contact,
AppLicantName = dto.FromName,
AppLicantAge = dto.AgeRangeCode,
AppLicantId = dto.LicenceNo,
CaseAccord = "",
CaseContent = dto.Content,
CaseProcessType = "",
CaseIsPublic = "",
CaseIsSecrect = "",
CaseIsVisit = "",
CaseLngLat = "",
CaseEmotion = "",
CaseAddress = "",
EventDate = null,
ThemeSerial = "",
IsExtends = "",
};
//处理诉求渠道
switch (dto.Channel)
{
case EChannel.Phone:
sendCaseInfo.CaseSource = "RGDH";
break;
case EChannel.WxOfficial:
sendCaseInfo.CaseSource = "WX";
break;
case EChannel.Web:
sendCaseInfo.CaseSource = "WZ";
break;
case EChannel.App:
sendCaseInfo.CaseSource = "Ap";
break;
case EChannel.WxMiniProgram:
sendCaseInfo.CaseSource = "XCX";
break;
}
//处理性别
switch (dto.FromGender)
{
case EGender.Female:
sendCaseInfo.AppLicantSex = "0";
break;
case EGender.Male:
sendCaseInfo.AppLicantSex = "1";
break;
case EGender.Unknown:
sendCaseInfo.AppLicantSex = "2";
break;
}
//处理证件类型
sendCaseInfo.CertifiCateType = dto.LicenceTypeCode switch
{
"10" => "10",
"40" => "20",
"55" => "30",
"57" => "40",
_ => "50",
};
//处理受理类型
switch (dto.AcceptType)
{
case EAcceptType.Consult:
sendCaseInfo.CaseType = "10";
break;
case EAcceptType.Suggest:
sendCaseInfo.CaseType = "15";
break;
case EAcceptType.SeekHelp:
sendCaseInfo.CaseType = "20";
break;
case EAcceptType.Praise:
sendCaseInfo.CaseType = "25";
break;
case EAcceptType.Report:
sendCaseInfo.CaseType = "30";
break;
case EAcceptType.Complain:
sendCaseInfo.CaseType = "35";
break;
case EAcceptType.Other:
sendCaseInfo.CaseType = "40";
break;
}
//处理紧急程度
sendCaseInfo.CaseIsUrgent = dto.EmergencyLevel switch
{
EEmergencyLevel.QuiteEmergency => "10",
EEmergencyLevel.Emergency => "20",
_ => "30",
};
sendCaseInfo.Id = await _sendCaseInfoRepository.AddAsync(sendCaseInfo, HttpContext.RequestAborted);
await _mediator.Publish(new SendCaseInfoNotification(sendCaseInfo));
}
///
/// 上报补充诉求
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.SupplyCaseInfoSend)]
public async Task SupplyCaseInfoSend(SupplyCaseInfoSendInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _supplyCaseInfoSendRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SupplyCaseInfoSendNotification(data));
}
///
/// 服务工单撤单
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.SendRevokeCaseInfo)]
public async Task SendRevokeCaseInfo(RevokeCaseInfoInfo dto)
{
var data = _mapper.Map(dto);
data.Direction = "1";
//将上报信息写入本地库
var id = await _revokeCaseInfoRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SendRevokeCaseInfoNotification(data));
}
///
/// 服务工单催单
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.SendRemindCaseInfo)]
public async Task SendRemindCaseInfo(RemindCaseInfoInfo dto)
{
var data = _mapper.Map(dto);
data.Direction = "1";
//将上报信息写入本地库
var id = await _remindCaseInfoRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SendRemindCaseInfoNotification(data));
}
#endregion
#region 协同-第四批次
#region 知识库
///
/// 知识库上报
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineKnowledgeInfoSend)]
public async Task GetKnowledgeInfoSend(KnowledgeInfoSendInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _getKnowledgeInfoSendRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new GetKnowledgeInfoSendNotification(data));
}
///
/// 知识库变更
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineKnowledgeInfoUpdate)]
public async Task GetKnowledgeInfoUpdate(GetKnowledgeInfoUpdateInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _getKnowledgeInfoUpdateRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new GetKnowledgeInfoUpdateNotification(data));
}
///
/// 知识库下架
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineKnowledgeInfoAbandon)]
public async Task GetKnowledgeInfoAbandon(GetKnowledgeInfoAbandonInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _getKnowledgeInfoAbandonRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new GetKnowledgeInfoAbandonNotification(data));
}
#endregion
///
/// 实时服务上报
///
///
///
[NonAction]
[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineSendRealTimeStatus)]
public async Task SendRealTimeStatus(SendRealTimeStatusInfo dto)
{
var data = _mapper.Map(dto);
//将上报信息写入本地库
var id = await _sendRealTimeStatusRepository.AddAsync(data);
data.Id = id;
//信息上报
await _mediator.Publish(new SendRealTimeStatusNotification(data));
}
#endregion
}
}