增加axb代码

master
bynt 3 years ago
parent 0b2f840263
commit f9c008d81f

@ -0,0 +1,22 @@
package com.baiye.http;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Enzo
* @date : 2022/2/10
*/
@Data
@NoArgsConstructor
public class AxbCallResponse {
private String reason;
private String bindingId;
private String gateway;
private String requestId;
private String prefixA;
private String prefixX;
private String telX;
private String xtypeID;
private String result;
}

@ -0,0 +1,27 @@
package com.baiye.config.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author Enzo
* @date : 2022/2/10
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "axb.call")
public class AxbProperties {
private String appid;
private String cdrUrl;
private String bingUrl;
private String statusUrl;
private String unBingUrl;
}

@ -19,6 +19,8 @@ import com.baiye.util.PageUtil;
import com.baiye.util.QueryHelp;
import com.baiye.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@ -84,6 +86,7 @@ public class CompanyServiceImpl implements CompanyService {
}
@Override
@Cacheable(cacheNames = "companyCache",key = "#companyId")
public Company findById(Long companyId) {
return companyRepository.findById(companyId).orElseGet(Company::new);
}

@ -4,8 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baiye.http.CommonResponse;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.RollCallBackDTO;
import com.baiye.modules.telemarkting.service.RollCallService;
import io.swagger.annotations.Api;
@ -35,11 +34,11 @@ public class RollCallController {
@PostMapping("/roll/req")
@ApiOperation("请求接入点呼")
public CommonResponse<Object> rollCallReq(@Validated @RequestBody DoubleCallReqDTO doubleCallReq) {
if (ObjectUtil.isEmpty(doubleCallReq)) {
public CommonResponse<Object> rollCallReq(@Validated @RequestBody TelephoneCallReqDTO telephoneCallReqDTO) {
if (ObjectUtil.isEmpty(telephoneCallReqDTO)) {
return CommonResponse.createByError();
}
return rollCallService.rollCallReq(doubleCallReq);
return rollCallService.rollCallReq(telephoneCallReqDTO);
}
@PostMapping("/roll/cdrUrl")

@ -3,12 +3,17 @@ package com.baiye.modules.telemarkting.api;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.http.CommonResponse;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackStatusDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallStopDTO;
import com.baiye.modules.telemarkting.service.DoubleCallService;
import com.baiye.modules.system.domain.Company;
import com.baiye.modules.system.service.CompanyService;
import com.baiye.modules.system.service.OrganizeService;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackStatusDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO;
import com.baiye.modules.telemarkting.service.TelephoneCallService;
import com.baiye.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
@ -16,8 +21,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author wjt
* @date 2021/12/14
@ -25,35 +28,43 @@ import javax.annotation.Resource;
@Slf4j
@RestController
@RequestMapping("/api")
@Api(tags = "对接双呼")
@Api(tags = "拨打电话")
@RequiredArgsConstructor
public class DoubleCallController {
public class TelephoneCallController {
private final DoubleCallService doubleCallService;
private final TelephoneCallService telephoneCallService;
private final CompanyService companyService;
@PostMapping("/double/req")
@ApiOperation("请求接入双呼")
public CommonResponse<Object> doubleCallReq(@Validated @RequestBody DoubleCallReqDTO doubleCallReq) {
if (ObjectUtil.isEmpty(doubleCallReq)) {
@PostMapping("/telephone/req")
@ApiOperation("拨打电话")
public CommonResponse<String> doubleCallReq(@Validated @RequestBody TelephoneCallReqDTO telephoneCallReqDTO) {
if (ObjectUtil.isEmpty(telephoneCallReqDTO)) {
return CommonResponse.createByError();
}
Long teamId = doubleCallReq.getTeamId();
return doubleCallService.doubleCallReq(doubleCallReq);
Long companyId = SecurityUtils.getCompanyId();
if (companyId != null) {
Company byId = companyService.findById(SecurityUtils.getCompanyId());
telephoneCallReqDTO.setCompanyName(byId.getCompanyName());
return telephoneCallReqDTO.getCallMode() != null
&& telephoneCallReqDTO.getCallMode() > DefaultNumberConstants.ONE_NUMBER
? telephoneCallService.doubleCallReq(telephoneCallReqDTO)
: telephoneCallService.axbDialNumber(telephoneCallReqDTO);
}
return CommonResponse.createByError();
}
@PostMapping("/back/cdrUrl")
@ApiOperation("双呼系统回调话单")
public CommonResponse<String> doubleCallBack(@RequestBody String json) {
try {
DoubleCallBackDTO doubleCallReq = JSONUtil.toBean(json, DoubleCallBackDTO.class);
TelephoneCallBackDTO doubleCallReq = JSONUtil.toBean(json, TelephoneCallBackDTO.class);
if (ObjectUtil.isEmpty(doubleCallReq) || StrUtil.isEmpty(doubleCallReq.getSessionId())) {
return CommonResponse.createByErrorMessage("参数为空");
}
log.info("=======双呼回调话单: {}", doubleCallReq);
doubleCallService.doubleCallBack(doubleCallReq);
telephoneCallService.doubleCallBack(doubleCallReq);
} catch (Exception e) {
log.error("双呼回调话单错误 参数 {}", json);
log.error("双呼回调话单错误,数据解析错误 {}", e.getMessage());
@ -66,12 +77,12 @@ public class DoubleCallController {
@ApiOperation("双呼系统回调状态")
public CommonResponse<String> doubleCallBackStatus(@RequestBody String json) {
try {
DoubleCallBackStatusDTO doubleCallBack = JSONUtil.toBean(json, DoubleCallBackStatusDTO.class);
TelephoneCallBackStatusDTO doubleCallBack = JSONUtil.toBean(json, TelephoneCallBackStatusDTO.class);
if (ObjectUtil.isEmpty(doubleCallBack) || StrUtil.isEmpty(doubleCallBack.getSessionId())) {
return CommonResponse.createByErrorMessage("参数为空");
}
log.info("=====双呼状态话单 {}", doubleCallBack);
doubleCallService.doubleCallBackStatus(doubleCallBack);
telephoneCallService.doubleCallBackStatus(doubleCallBack);
} catch (Exception e) {
log.error("双呼回调状态错误 参数 {}", json);
log.error("双呼回调状态错误,数据解析错误 {}", e.getMessage());
@ -82,13 +93,13 @@ public class DoubleCallController {
@PostMapping("/double/stop")
@ApiOperation("挂断呼叫")
public CommonResponse<Object> doubleCallStop(@RequestBody DoubleCallStopDTO doubleCallStopDTO) {
return doubleCallService.doubleCallStop(doubleCallStopDTO);
public CommonResponse<Object> doubleCallStop(@RequestBody TelephoneCallStopDTO telephoneCallStopDTO) {
return telephoneCallService.doubleCallStop(telephoneCallStopDTO);
}
@GetMapping("/call/record")
@ApiOperation("获取通话记录和录音地址")
public CommonResponse<Object> getCallRecord(@RequestParam(value = "clueId") Long clueId, @RequestParam(value = "memberId") Long memberId) {
return doubleCallService.getCallRecord(clueId, memberId);
return telephoneCallService.getCallRecord(clueId, memberId);
}
}

@ -0,0 +1,45 @@
package com.baiye.modules.telemarkting.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author Enzo
* @date : 2022/2/10
*/
@Data
public class AxbCallRequestDTO implements Serializable {
private static final long serialVersionUID = 215726963974324463L;
@ApiModelProperty("appid")
private String appid;
@ApiModelProperty("请求唯一 id")
private String requestId;
@ApiModelProperty("真实主叫号码")
private String telA;
@ApiModelProperty("真实被叫号码")
private String telB;
@ApiModelProperty("AB呼叫的虚拟中间X号")
private String telX;
@ApiModelProperty("X号码的群组")
private String xGroup;
@ApiModelProperty("自动解绑周期,不带由 系统指定")
private Integer expires;
@ApiModelProperty("话单回推地址")
private String cdrUrl;
@ApiModelProperty("状态回推地址")
private String statusUrl;
@ApiModelProperty("用户附属信息")
private String userData;
}

@ -8,7 +8,7 @@ import lombok.Data;
*
*/
@Data
public class DoubleCallBackDTO {
public class TelephoneCallBackDTO {
private Integer direction;
private String spId;
private String appKey;

@ -8,7 +8,7 @@ import lombok.Data;
*
*/
@Data
public class DoubleCallBackStatusDTO {
public class TelephoneCallBackStatusDTO {
private String status;
private String callId;
private String sessionId;

@ -12,7 +12,7 @@ import java.io.Serializable;
*
*/
@Data
public class DoubleCallReqDTO implements Serializable {
public class TelephoneCallReqDTO implements Serializable {
private static final long serialVersionUID = 8037829549747968861L;
@ -41,4 +41,13 @@ public class DoubleCallReqDTO implements Serializable {
@ApiModelProperty("主任务id")
@NotNull
private Long taskId;
@ApiModelProperty("公司名称")
private String companyName;
@ApiModelProperty(value = "组呼叫方式0:双呼 1:点呼 2:AXB")
private Integer callMode;
}

@ -7,7 +7,7 @@ import lombok.Data;
* @date 2022/01/18
*/
@Data
public class DoubleCallStopDTO {
public class TelephoneCallStopDTO {
private String sessionid;
private String callId;
}

@ -7,7 +7,7 @@ import lombok.Data;
* @date 2021/12/14
*/
@Data
public class DoubleCallSystemDTO {
public class TelephoneCallSystemDTO {
private String appid;
private String requestId;
private String telA;

@ -0,0 +1,57 @@
package com.baiye.modules.telemarkting.httpRequest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.baiye.config.properties.AxbProperties;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException;
import com.baiye.http.AxbCallResponse;
import com.baiye.model.enums.ResponseCode;
import com.baiye.modules.telemarkting.entity.dto.AxbCallRequestDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
/**
* @author Enzo
* @date : 2022/2/10
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class AxbRequest {
private final AxbProperties axbProperties;
public String call(TelephoneCallReqDTO telephoneCallReqDTO) {
AxbCallRequestDTO axbCallRequestDTO = new AxbCallRequestDTO();
BeanUtil.copyProperties(telephoneCallReqDTO, axbCallRequestDTO);
axbCallRequestDTO.setAppid(axbProperties.getAppid());
axbCallRequestDTO.setXGroup(telephoneCallReqDTO.getCompanyName());
axbCallRequestDTO.setCdrUrl(axbProperties.getCdrUrl());
axbCallRequestDTO.setStatusUrl(axbProperties.getStatusUrl());
HttpResponse response =
HttpRequest.post
(axbProperties.getBingUrl())
.body(JSONUtil.toJsonPrettyStr
(axbCallRequestDTO)).execute();
if (response.isOk()) {
AxbCallResponse axbCallResponse = JSONUtil
.toBean(response.body(), AxbCallResponse.class);
if (String.valueOf
(DefaultNumberConstants.ZERO_NUMBER)
.equals(axbCallResponse.getResult())) {
return axbCallResponse.getBindingId();
}
throw new BadRequestException
(StringUtils.isNotBlank(axbCallResponse.getReason()) ?
axbCallResponse.getReason()
: ResponseCode.CALL_ERROR.getDesc());
}
throw new BadRequestException(ResponseCode.CALL_ERROR.getDesc());
}
}

@ -9,9 +9,9 @@ import cn.hutool.json.JSONUtil;
import com.baiye.exception.BadRequestException;
import com.baiye.http.DoubleCallResponse;
import com.baiye.model.enums.ResponseCode;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallStopDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallSystemDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallSystemDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
@ -30,23 +30,21 @@ public class CallReq {
private String stopUrl;
@Value("${double.call.appid}")
private String appid;
@Value("${double.call.companyName}")
private String companyName;
@Value("${double.call.cdrUrl}")
private String cdrUrl;
@Value("${double.call.statusUrl}")
private String statusUrl;
public String startReq(DoubleCallReqDTO doubleCallReq) {
public String startReq(TelephoneCallReqDTO doubleCallReq) {
log.info("=======================doubleCallReq start in {}", DateUtil.date());
return reqTask(doubleCallReq);
}
private String reqTask(DoubleCallReqDTO doubleCallReq) {
DoubleCallSystemDTO doubleCallSystemDTO = new DoubleCallSystemDTO();
BeanUtil.copyProperties(doubleCallReq, doubleCallSystemDTO);
private String reqTask(TelephoneCallReqDTO telephoneCallReqDTO) {
TelephoneCallSystemDTO doubleCallSystemDTO = new TelephoneCallSystemDTO();
BeanUtil.copyProperties(telephoneCallReqDTO, doubleCallSystemDTO);
doubleCallSystemDTO.setAppid(appid);
doubleCallSystemDTO.setCompanyName(companyName);
doubleCallSystemDTO.setCompanyName(telephoneCallReqDTO.getCompanyName());
doubleCallSystemDTO.setCdrUrl(cdrUrl);
doubleCallSystemDTO.setStatusUrl(statusUrl);
int count = 0;
@ -70,16 +68,16 @@ public class CallReq {
return null;
}
public Boolean stopReq(DoubleCallStopDTO doubleCallStopDTO) {
public Boolean stopReq(TelephoneCallStopDTO telephoneCallStopDTO) {
log.info("=======================stopReq start in {}", DateUtil.date());
return stopTask(doubleCallStopDTO);
return stopTask(telephoneCallStopDTO);
}
private Boolean stopTask(DoubleCallStopDTO doubleCallStopDTO) {
private Boolean stopTask(TelephoneCallStopDTO telephoneCallStopDTO) {
int count = 0;
int flag = 3;
while (count <= flag) {
HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(doubleCallStopDTO), stopUrl);
HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(telephoneCallStopDTO), stopUrl);
if (httpResponse.isOk()) {
log.info("请求挂断成功,返回值:{}", httpResponse.body());
return Boolean.TRUE;

@ -9,9 +9,9 @@ import cn.hutool.json.JSONUtil;
import com.baiye.exception.BadRequestException;
import com.baiye.http.DoubleCallResponse;
import com.baiye.model.enums.ResponseCode;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallStopDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallSystemDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallSystemDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
@ -30,56 +30,49 @@ public class DoubleCallReq {
private String stopUrl;
@Value("${double.call.appid}")
private String appid;
@Value("${double.call.companyName}")
private String companyName;
@Value("${double.call.cdrUrl}")
private String cdrUrl;
@Value("${double.call.statusUrl}")
private String statusUrl;
public String startReq(DoubleCallReqDTO doubleCallReq) {
public String startReq(TelephoneCallReqDTO doubleCallReq) {
log.info("=======================doubleCallReq start in {}", DateUtil.date());
return reqTask(doubleCallReq);
}
private String reqTask(DoubleCallReqDTO doubleCallReq) {
DoubleCallSystemDTO doubleCallSystemDTO = new DoubleCallSystemDTO();
BeanUtil.copyProperties(doubleCallReq, doubleCallSystemDTO);
private String reqTask(TelephoneCallReqDTO telephoneCallReqDTO) {
TelephoneCallSystemDTO doubleCallSystemDTO = new TelephoneCallSystemDTO();
BeanUtil.copyProperties(telephoneCallReqDTO, doubleCallSystemDTO);
doubleCallSystemDTO.setAppid(appid);
doubleCallSystemDTO.setCompanyName(companyName);
doubleCallSystemDTO.setCompanyName(telephoneCallReqDTO.getCompanyName());
doubleCallSystemDTO.setCdrUrl(cdrUrl);
doubleCallSystemDTO.setStatusUrl(statusUrl);
int count = 0;
int flag = 3;
log.info("请求对象:{}", JSONUtil.toJsonPrettyStr(doubleCallSystemDTO));
while (count <= flag) {
HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(doubleCallSystemDTO), reqUrl);
if (httpResponse.isOk() && httpResponse.body().contains("success")) {
log.info("请求呼叫成功,返回值:{}", httpResponse.body());
JSONObject result = JSONUtil.parseObj(httpResponse.body());
return result.get("sessionId").toString();
} else {
count++;
String body = httpResponse.body();
log.error("请求失败,response==={}", body);
throw new BadRequestException(StringUtils.isNotBlank(body) ?
JSONUtil.toBean(body, DoubleCallResponse.class).getReason() : ResponseCode.CALL_ERROR.getDesc());
}
HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(doubleCallSystemDTO), reqUrl);
if (httpResponse.isOk() && httpResponse.body().contains("success")) {
log.info("请求呼叫成功,返回值:{}", httpResponse.body());
JSONObject result = JSONUtil.parseObj(httpResponse.body());
return result.get("sessionId").toString();
} else {
String body = httpResponse.body();
log.error("请求失败,response==={}", body);
throw new BadRequestException(StringUtils.isNotBlank(body) ?
JSONUtil.toBean(body, DoubleCallResponse.class).getReason() : ResponseCode.CALL_ERROR.getDesc());
}
log.info("=======================doubleCallReq end in {}", DateUtil.date());
return null;
}
public Boolean stopReq(DoubleCallStopDTO doubleCallStopDTO) {
public Boolean stopReq(TelephoneCallStopDTO telephoneCallStopDTO) {
log.info("=======================stopReq start in {}", DateUtil.date());
return stopTask(doubleCallStopDTO);
return stopTask(telephoneCallStopDTO);
}
private Boolean stopTask(DoubleCallStopDTO doubleCallStopDTO) {
private Boolean stopTask(TelephoneCallStopDTO telephoneCallStopDTO) {
int count = 0;
int flag = 3;
while (count <= flag) {
HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(doubleCallStopDTO), stopUrl);
HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(telephoneCallStopDTO), stopUrl);
if (httpResponse.isOk()) {
log.info("请求挂断成功,返回值:{}", httpResponse.body());
return Boolean.TRUE;

@ -1,3 +1,4 @@
/*
package com.baiye.modules.telemarkting.httpRequest;
import cn.hutool.core.codec.Base64;
@ -14,10 +15,12 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
*/
/**
* @author wujingtao
* @date 2022/02/10
*/
*//*
@Slf4j
@Component
public class RollCallReq {
@ -72,3 +75,4 @@ public class RollCallReq {
return HttpRequest.post(url).header("Authorization", authorization).body(json).execute();
}
}
*/

@ -1,53 +0,0 @@
package com.baiye.modules.telemarkting.service;
import com.baiye.http.CommonResponse;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackStatusDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallStopDTO;
/**
* @author wjt
* @date 2021/12/14
*/
public interface DoubleCallService {
/**
*
*
* @param doubleCallReq
* @return
*/
CommonResponse<Object> doubleCallReq(DoubleCallReqDTO doubleCallReq);
/**
*
*
* @param doubleCallBack
*/
void doubleCallBack(DoubleCallBackDTO doubleCallBack);
/**
*
*
* @param doubleCallBackStatus
*/
void doubleCallBackStatus(DoubleCallBackStatusDTO doubleCallBackStatus);
/**
*
*
* @param doubleCallStopDTO
* @return
*/
CommonResponse<Object> doubleCallStop(DoubleCallStopDTO doubleCallStopDTO);
/**
* h
*
* @param clueId
* @param memberId
* @return
*/
CommonResponse<Object> getCallRecord(Long clueId, Long memberId);
}

@ -1,7 +1,7 @@
package com.baiye.modules.telemarkting.service;
import com.baiye.http.CommonResponse;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.RollCallBackDTO;
/**
@ -13,10 +13,10 @@ public interface RollCallService {
/**
*
*
* @param doubleCallReq
* @param telephoneCallReqDTO
* @return
*/
CommonResponse<Object> rollCallReq(DoubleCallReqDTO doubleCallReq);
CommonResponse<Object> rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO);
/**
*

@ -0,0 +1,60 @@
package com.baiye.modules.telemarkting.service;
import com.baiye.http.CommonResponse;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackStatusDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO;
/**
* @author wjt
* @date 2021/12/14
*/
public interface TelephoneCallService {
/**
*
*
* @param telephoneCallReqDTO
* @return
*/
CommonResponse<String> doubleCallReq(TelephoneCallReqDTO telephoneCallReqDTO);
/**
*
*
* @param telephoneCallBackDTO
*/
void doubleCallBack(TelephoneCallBackDTO telephoneCallBackDTO);
/**
*
*
* @param telephoneCallBackStatusDTO
*/
void doubleCallBackStatus(TelephoneCallBackStatusDTO telephoneCallBackStatusDTO);
/**
*
*
* @param telephoneCallStopDTO
* @return
*/
CommonResponse<Object> doubleCallStop(TelephoneCallStopDTO telephoneCallStopDTO);
/**
* h
*
* @param clueId
* @param memberId
* @return
*/
CommonResponse<Object> getCallRecord(Long clueId, Long memberId);
/**
* axb
* @param telephoneCallReqDTO
* @return
*/
CommonResponse<String> axbDialNumber(TelephoneCallReqDTO telephoneCallReqDTO);
}

@ -6,14 +6,12 @@ import cn.hutool.core.util.StrUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.feign.SourceClueClient;
import com.baiye.http.CommonResponse;
import com.baiye.modules.system.domain.Clue;
import com.baiye.modules.telemarkting.dao.AllCallInfoRepository;
import com.baiye.modules.telemarkting.dao.CallClueRepository;
import com.baiye.modules.telemarkting.entity.AllCallInfo;
import com.baiye.modules.telemarkting.entity.CallClueInfo;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.RollCallBackDTO;
import com.baiye.modules.telemarkting.httpRequest.RollCallReq;
import com.baiye.modules.telemarkting.service.RollCallService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -34,37 +32,38 @@ public class RollCallServiceImpl implements RollCallService {
private CallClueRepository callClueRepository;
@Resource
private SourceClueClient sourceClueClient;
@Resource
private RollCallReq rollCallReq;
/* @Resource
private RollCallReq rollCallReq;*/
@Override
public CommonResponse<Object> rollCallReq(DoubleCallReqDTO doubleCallReq) {
public CommonResponse<Object> rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO) {
String requestId = RandomUtil.randomString(10);
doubleCallReq.setRequestId(requestId);
telephoneCallReqDTO.setRequestId(requestId);
// Clue body = sourceClueClient.queryDetails(Long.parseLong(doubleCallReq.getUserData())).getBody();
// if (ObjectUtil.isNull(body) || StrUtil.isEmpty(body.getNid())) {
// return CommonResponse.createByErrorMessage("未获取到号码");
// }
// doubleCallReq.setTelB(body.getNid());
doubleCallReq.setTelB("13003658692");
String sessionId = rollCallReq.startReq(doubleCallReq);
telephoneCallReqDTO.setTelB("13003658692");
// TODO sessionId not setting
String sessionId = "";
log.info("=============================sessionId {}", sessionId);
if (StrUtil.isNotBlank(sessionId)) {
AllCallInfo allCallInfo = new AllCallInfo();
allCallInfo.setSessionId(sessionId);
allCallInfo.setRequestId(requestId);
allCallInfo.setClueId(Long.parseLong(doubleCallReq.getUserData()));
allCallInfo.setMemberId(doubleCallReq.getMemberId());
allCallInfo.setClueId(Long.parseLong(telephoneCallReqDTO.getUserData()));
allCallInfo.setMemberId(telephoneCallReqDTO.getMemberId());
allCallInfo.setStatus(DefaultNumberConstants.ONE_NUMBER);
allCallInfo.setType(DefaultNumberConstants.ONE_NUMBER);
allCallInfo.setRecordFlag(DefaultNumberConstants.ZERO_NUMBER);
CallClueInfo clueInfo = new CallClueInfo();
clueInfo.setClueId(Long.parseLong(doubleCallReq.getUserData()));
clueInfo.setTeamId(doubleCallReq.getTeamId());
clueInfo.setMemberId(doubleCallReq.getMemberId());
clueInfo.setClueId(Long.parseLong(telephoneCallReqDTO.getUserData()));
clueInfo.setTeamId(telephoneCallReqDTO.getTeamId());
clueInfo.setMemberId(telephoneCallReqDTO.getMemberId());
clueInfo.setStatus(DefaultNumberConstants.ONE_NUMBER);
clueInfo.setTaskId(doubleCallReq.getTaskId());
clueInfo.setTaskId(telephoneCallReqDTO.getTaskId());
allCallInfoRepository.save(allCallInfo);
callClueRepository.save(clueInfo);

@ -2,6 +2,7 @@ package com.baiye.modules.telemarkting.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
@ -14,14 +15,16 @@ import com.baiye.modules.telemarkting.dao.AllCallInfoRepository;
import com.baiye.modules.telemarkting.dao.CallClueRepository;
import com.baiye.modules.telemarkting.entity.AllCallInfo;
import com.baiye.modules.telemarkting.entity.CallClueInfo;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackStatusDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.DoubleCallStopDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackStatusDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO;
import com.baiye.modules.telemarkting.entity.vo.CallRecordsVO;
import com.baiye.modules.telemarkting.httpRequest.AxbRequest;
import com.baiye.modules.telemarkting.httpRequest.DoubleCallReq;
import com.baiye.modules.telemarkting.service.DoubleCallService;
import com.baiye.modules.telemarkting.service.TelephoneCallService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -37,9 +40,14 @@ import java.util.Objects;
*/
@Service
@Slf4j
public class DoubleCallServiceImpl implements DoubleCallService {
public class TelephoneCallServiceImpl implements TelephoneCallService {
@Resource
private AxbRequest axbRequest;
@Resource
private DoubleCallReq doubleCallReq;
@Resource
private AllCallInfoRepository allCallInfoRepository;
@Resource
@ -48,7 +56,7 @@ public class DoubleCallServiceImpl implements DoubleCallService {
private SourceClueClient sourceClueClient;
@Override
public CommonResponse<Object> doubleCallReq(DoubleCallReqDTO doubleCallReq) {
public CommonResponse<String> doubleCallReq(TelephoneCallReqDTO doubleCallReq) {
String requestId = RandomUtil.randomString(10);
doubleCallReq.setRequestId(requestId);
Clue body = sourceClueClient.queryDetails(Long.parseLong(doubleCallReq.getUserData())).getBody();
@ -90,7 +98,7 @@ public class DoubleCallServiceImpl implements DoubleCallService {
}
@Override
public void doubleCallBack(DoubleCallBackDTO doubleCallBack) {
public void doubleCallBack(TelephoneCallBackDTO doubleCallBack) {
String sessionId = doubleCallBack.getSessionId();
AllCallInfo allCallInfo = allCallInfoRepository.findBySessionId(sessionId);
if (ObjectUtil.isNotEmpty(allCallInfo)) {
@ -105,7 +113,7 @@ public class DoubleCallServiceImpl implements DoubleCallService {
@Override
@Transactional(rollbackFor = Exception.class)
public void doubleCallBackStatus(DoubleCallBackStatusDTO doubleCallBackStatus) {
public void doubleCallBackStatus(TelephoneCallBackStatusDTO doubleCallBackStatus) {
String sessionId = doubleCallBackStatus.getSessionId();
long userDate = Long.parseLong(doubleCallBackStatus.getUserData());
@ -118,8 +126,8 @@ public class DoubleCallServiceImpl implements DoubleCallService {
}
@Override
public CommonResponse<Object> doubleCallStop(DoubleCallStopDTO doubleCallStopDTO) {
if (doubleCallReq.stopReq(doubleCallStopDTO)) {
public CommonResponse<Object> doubleCallStop(TelephoneCallStopDTO telephoneCallStopDTO) {
if (doubleCallReq.stopReq(telephoneCallStopDTO)) {
return CommonResponse.createBySuccess();
}
return CommonResponse.createByError();
@ -143,4 +151,35 @@ public class DoubleCallServiceImpl implements DoubleCallService {
list.sort(Comparator.comparing(CallRecordsVO::getCreateTime));
return CommonResponse.createBySuccess(list);
}
@Override
public CommonResponse<String> axbDialNumber(TelephoneCallReqDTO doubleCallReq) {
long originalNumber = Long.parseLong(doubleCallReq.getUserData());
ResponseEntity<Clue> body = sourceClueClient.queryDetails(originalNumber);
if (ObjectUtil.isNotNull(body) && ObjectUtil.isNotNull(body.getBody())) {
String nid = Objects.requireNonNull(body.getBody()).getNid();
String randomString = RandomUtil.randomString(DefaultNumberConstants.TEN_NUMBER);
doubleCallReq.setRequestId(randomString);
doubleCallReq.setTelB(nid);
String sessionId = axbRequest.call(doubleCallReq);
if (CharSequenceUtil.isNotBlank(sessionId)) {
AllCallInfo allCallInfo = new AllCallInfo();
allCallInfo.setSessionId(sessionId);
allCallInfo.setRequestId(randomString);
allCallInfo.setClueId(originalNumber);
allCallInfo.setMemberId(doubleCallReq.getMemberId());
allCallInfo.setStatus(DefaultNumberConstants.ONE_NUMBER);
CallClueInfo clueInfo = new CallClueInfo();
clueInfo.setClueId(originalNumber);
clueInfo.setTeamId(doubleCallReq.getTeamId());
clueInfo.setMemberId(doubleCallReq.getMemberId());
clueInfo.setStatus(DefaultNumberConstants.ONE_NUMBER);
clueInfo.setTaskId(doubleCallReq.getTaskId());
allCallInfoRepository.save(allCallInfo);
callClueRepository.save(clueInfo);
return CommonResponse.createBySuccess(sessionId);
}
}
return CommonResponse.createByError();
}
}

@ -110,6 +110,26 @@ file:
avatarMaxSize: 5
#配置双呼参数
double:
call:
reqUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBack
appid: app1
cdrUrl: http://118.178.137.129:8866/api/back/cdrUrl
statusUrl: http://118.178.137.129:8866/api/back/status
stopUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBackStop
#axb地址
axb:
call:
appid: app1
cdrUrl: http://118.178.137.129:8866/api/back/cdrUrl
statusUrl: http://118.178.137.129:8866/api/back/status
bingUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Calls/AxbBinding
unBingUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Calls/AxbUnBinding
#ribbon:
# #建立连接超时时间
# ConnectTimeout: 50000

@ -115,3 +115,23 @@ file:
# ConnectTimeout: 50000
# #建立连接之后,读取响应资源超时时间
# ReadTimeout: 50000
#配置呼出参数
double:
call:
reqUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBack
appid: app1
cdrUrl: https://mm.tuoz.net/api/back/cdrUrl
statusUrl: https://mm.tuoz.net/api/back/status
stopUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBackStop
#axb地址
axb:
call:
appid: app1
cdrUrl: https://mm.tuoz.net/api/back/cdrUrl
statusUrl: https://mm.tuoz.net/api/back/status
bingUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Calls/AxbBinding
unBingUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Calls/AxbUnBinding

@ -59,15 +59,7 @@ code:
rsa:
private_key: MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKLhn7fPqFSK9z3Ao4yFFisDO8YV1dOn1I3wpwj1IIu3Z7vkaHyynBf7eF8fo86EQRvnJIo3jVO2jUw5Lor2OYcZVK72oxD5LIULVYI/eXJogzd1C+tJ5IHC7dmTJ37qfjP9VV3mDWlsRusdCoVPE2xUI13H4bPOCE4DyyeldXlFAgMBAAECgYBakWx3D5+AyvipPKl0JDhsWFLvVQrdss+M0Uh/wZWEOsoSfvHejI4hA7It6nDyDzYI5uC5fiQ2bSZqQM1xdXIMmq4F0WM2+ni4Q/bYbaLt9UDGs6GXwHcg3gOTBJoSJq0SZxBpflxbfVOj63ITehTl51q0FvaedxWl63hf6bikQQJBANT3s1usMZmubYxQPLrBeK1mcXG1JxwKDK6n7bJnlBeZy1GCUZ7bwBgr32gRvUXtgqrzT3IyZlld5cUScX601TUCQQDDyxVAPExwbpxD0Ao7CZE9LRYC8YaMQ46NENqaIhnmhMa4vqoTky8t2nLZITmk0EqecTBt/Io+37+X/KCHD+XRAkAraGmIb+qUNndhuCEIt9KPFWheEtxr3KiFGPlb+by3qsNEU9mrFYNr6dVZcvQvQp/1lC5HSnqOEJN6va2gc99ZAkEAnYtF+EAMydNXDgHSmZqjMXSb55Zsy2R4ye2r2KZj7Ocd9/4DYGjoZ58FFs3zUjkAMemmLHouy1TDGAsBKGyUYQJBAJ1io1DxuejCE+sN/bu4Y2S7oQ2Mpfjh7jRYGruDzhdqVnnLxf0spaqJZ5HekQz3uMpkQQGkcN1MZZcRpoWJ7XU=
#配置双呼参数
double:
call:
reqUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBack
appid: app1
companyName: 杭州百业互联科技有限公司
cdrUrl: http://118.178.137.129:8866/api/back/cdrUrl
statusUrl: http://118.178.137.129:8866/api/back/status
stopUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBackStop
#配置短信参数
sms:

@ -169,11 +169,11 @@ public class ClueServiceImpl implements ClueService {
if (clueQueryCriteria.getId() != null) {
for (ClueDto clueDto : clueDtoList) {
//循环查库ID查询只一次循环
// String organizeStr = organizeClient.query(clueDto.getOrganizeId()).getBody().toString();
// String str = organizeStr.replaceAll("=", ":");
// JSONArray jsonArray = JSONUtil.parseArray(str);
// JSONObject jsonObject = JSONUtil.parseObj(jsonArray.get(0));
// clueDto.setCallMode((Integer)jsonObject.get("callMode"));
String organizeStr = organizeClient.query(clueDto.getOrganizeId()).getBody().toString();
String str = organizeStr.replaceAll("=", ":");
JSONArray jsonArray = JSONUtil.parseArray(str);
JSONObject jsonObject = JSONUtil.parseObj(jsonArray.get(0));
clueDto.setCallMode((Integer)jsonObject.get("callMode"));
Map<String, List<String>> mapList = organizeClient.getLabel(clueDto.getTaskId(), clueDto.getOrganizeId()).getBody();
clueDto.setBaseLabel(mapList.get("baseLabel"));
clueDto.setOrganizeLabel(mapList.get("organizeLabel"));

Loading…
Cancel
Save