OutboundCallController.java 17.5 KB
package cn.com.glsx.entmicro.controller;

import cn.com.glsx.entmicro.dto.TaskExecuteStatus;
import cn.com.glsx.entmicro.model.response.outbound.OutBoundTaskCustomerExportResponse;
import cn.com.glsx.entmicro.model.response.outbound.OutBoundTaskCustomerRpcResponse;
import cn.com.glsx.entmicro.request.outbound.*;
import cn.com.glsx.entmicro.response.outbound.*;
import cn.com.glsx.entmicro.service.outbound.OutboundCallService;
import cn.com.glsx.entmicro.utils.Pagination;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Author yelq
 * @Version 1.0
 * @Description: 智能外呼
 * @Date 2022/8/4 17:11
 */
@Slf4j
@Api("智能机器人外呼任务")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
public class OutboundCallController {

    @Autowired
    private OutboundCallService outboundCallService;

    @ServiceMethod(method = "entmicro.api.outbound.call.phone.check")
    @ApiOperation("创建外呼任务校验客户手机号接口")
    public RopResponse<PhoneCheckRopResponse> checkOutboundCallPhone(PhoneCheckRopRequest request) {
        try {
            return RopResponse.success(outboundCallService.checkOutboundCallPhone(request));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_checkOutboundCallPhone_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.merchant.check.task.name")
    @ApiOperation("校验外呼任务名称重复(true-已存在,false-不存在)")
    public RopResponse<Boolean> merchantCheckOutboundCallTaskName(MerchantCheckTaskNameRopRequest request) {
        try {
            return RopResponse.success(outboundCallService.merchantCheckOutboundCallTaskName(request));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_merchantCheckOutboundCallTaskName_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.merchant.create.task")
    @ApiOperation("门店创建外呼任务")
    public RopResponse<Boolean> merchantCreateOutboundCallTask(MerchantCreateTaskRopRequest request) {
        try {
            return RopResponse.success(outboundCallService.merchantCreateOutboundCallTask(request));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_merchantCreateOutboundCallTask_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.merchant.task.delete")
    @ApiOperation("门店删除外呼任务")
    public RopResponse<Boolean> merchantDeleteOutboundCallTask(MerchantDeleteTaskRopRequest request) {
        try {
            return RopResponse.success(outboundCallService.merchantDeleteOutboundCallTask(request));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_merchantDeleteOutboundCallTask_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.merchant.task.page")
    @ApiOperation("门店外呼任务分页")
    public RopResponse<Pagination<OutboundCallTaskRopResponse>> merchantOutboundCallTaskPage(MerchantTaskPageRopRequest request) {
        try {
            return RopResponse.success(outboundCallService.merchantOutboundCallTaskPage(request));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_merchantOutboundCallTaskPage_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.caller.numbers.query")
    @ApiOperation("获取呼叫电话列表")
    public RopResponse<List<String>> getOutboundCallDidList(DidListRopRequest request) {
        try {
            return RopResponse.success(outboundCallService.getOutboundCallDidList(request));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_getOutboundCallDidList_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.robot.list.query")
    @ApiOperation("获取机器人列表")
    public RopResponse<List<RobotDetailRopResponse>> getOutboundCallRobotList(RobotListRopRequest request) {
        try {
            return RopResponse.success(outboundCallService.getOutboundCallRobotList(request));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_getOutboundCallRobotList_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.execute.task.status.update")
    @ApiOperation("执行任务状态变更")
    public RopResponse<String> outboundExecuteTaskStatusUpdate(ExecuteTaskStatusUpdateRopRequest request) {
        try {
            return RopResponse.success(outboundCallService.outboundExecuteTaskStatusUpdate(request));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_outboundExecuteTaskStatusUpdate_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.create.execute.task")
    @ApiOperation("创建外呼执行任务")
    public RopResponse<Boolean> outboundCallCreateExecuteTask(CreateTaskRopReuqst request) {
        try {
            return RopResponse.success(outboundCallService.outboundCallCreateExecuteTask(request));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_outbountCallCreateExecuteTask_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.import.update.phone.status")
    @ApiOperation("导入手机号更新添加状态接口")
    public RopResponse<Boolean> importPhoneAddStatus(ImportRopRequest request) {
        try {
            return RopResponse.success(outboundCallService.importPhoneAddStatus(request));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_importPhoneAddStatus_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.task.page")
    @ApiOperation("智能外呼任务分页")
    public RopResponse<Pagination<OutBoundTaskRopResponse>> findOutBoundTaskListPageByCondition(OutBoundTaskRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.findOutBoundTaskListByCondition(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_findOutBoundTaskListPageByCondition_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.task.detail")
    @ApiOperation("智能外呼任务详情-基本信息")
    public RopResponse<OutBoundTaskDetailRopResponse> findOutBoundTaskDetail(TaskDetailRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.findOutBoundTaskDetail(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_findOutBoundTaskDetail_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.task.phoneStatus.page")
    @ApiOperation("智能外呼任务详情-手机号状态列表分页")
    public RopResponse<Pagination<OutBoundTaskCustomerRpcResponse>> findCustomersPageByTaskId(OutBoundTaskRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.findCustomersPageByTaskId(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_findCustomersPageByTaskId_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.task.phoneStatus.download")
    @ApiOperation("下载手机号状态列表")
    public RopResponse<String> downLoadPhoneStatusByTaskId(PhoneStatusDownLoadRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.downLoadPhoneStatusByTaskId(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_downLoadPhoneStatusByTaskId_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.task.status")
    @ApiOperation("统计:所有任务的执行状态")
    public RopResponse<TaskExecuteStatus> findTaskExecuteStatus(OutBoundTaskRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.findTaskExecuteStatus(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_findTaskExecuteStatus_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }


    @ServiceMethod(method = "entmicro.api.outbound.task.getOutBoundNum")
    @ApiOperation("获取外呼数量")
    public RopResponse<Integer> getOutBoundNum(FindOutBoundTaskNumRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.getOutBoundNum(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_getOutBoundNum_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.task.outBoundNum")
    @ApiOperation("设置外呼数量")
    public RopResponse<Boolean> setOutBoundNum(OutBoundConfigureRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.setOutBoundNum(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_outBoundNum_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.task.message.detail.query")
    @ApiOperation("查看外呼任务短信内容")
    public RopResponse<TaskMessageDetailRopResponse> queryTaskMessageDetail(QueryTaskMessageDetailRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.queryTaskMessageDetail(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_queryTaskMessageDetail_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.task.message.detail.update")
    @ApiOperation("修改外呼任务短信内容")
    public RopResponse<Boolean> updateTaskMessageDetail(UpdateTaskMessageDetailRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.updateTaskMessageDetail(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_updateTaskMessageDetail_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.merchant.task.create.content.echo")
    @ApiOperation("门店任务创建内容回显")
    public RopResponse<OutboundCallTaskEchoRopResponse> echoMerchantTask(TaskDetailRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.echoMerchantTask(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_echoMerchantTask_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.call.merchant.task.create.content.update")
    @ApiOperation("更改门店外呼任务")
    public RopResponse<Boolean> updateMerchantTask(MerchantTaskUpdateRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.updateMerchantTask(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_updateMerchantTask_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.task.customer.condition.page")
    @ApiOperation("AI外呼任务详情-客户列表多条件分页")
    public RopResponse<Pagination<OutBoundTaskCustomerRopResponse>> findCustomersPageByCondition(TaskCustomerPageRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.findCustomersPageByCondition(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_findCustomersPageByCondition_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "entmicro.api.outbound.task.customer.condition.export")
    @ApiOperation("AI外呼任务详情-客户列表多条件分页导出")
    public RopResponse<String> exportCustomersPageByCondition(TaskCustomerPageRopRequest ropRequest) {
        try {
            return RopResponse.success(outboundCallService.exportCustomersPageByCondition(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OutboundCallController_exportCustomersPageByCondition_invoke__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
            return RopResponse.error(e.getMessage());
        }
    }

}