添加点呼挂断接口

master
wujingtao 2 years ago
parent bcb3158567
commit b68722bb7d

@ -62,6 +62,9 @@ public class TaskServiceImpl implements TaskService {
private int datacenterId;
private final RedisUtils redisUtils;
public static void main(String[] args) {
System.out.println(IdUtil.getSnowflake(9, 9).nextId());
}
@Override
@Transactional(rollbackOn = Exception.class)
public void saveTask(Task task) {

@ -43,7 +43,7 @@ public class TelephoneCallController {
@PostMapping("/telephone/req")
@ApiOperation("拨打电话")
public CommonResponse<String> doubleCallReq(@Validated @RequestBody TelephoneCallReqDTO telephoneCallReqDTO) {
public CommonResponse<TelephoneCallStopDTO> doubleCallReq(@Validated @RequestBody TelephoneCallReqDTO telephoneCallReqDTO) {
if (ObjectUtil.isEmpty(telephoneCallReqDTO)) {
return CommonResponse.createByError();
}
@ -132,7 +132,11 @@ public class TelephoneCallController {
public CommonResponse<Object> doubleCallStop(@RequestBody TelephoneCallStopDTO telephoneCallStopDTO) {
return telephoneCallService.doubleCallStop(telephoneCallStopDTO);
}
@PostMapping("/roll/stop")
@ApiOperation("点呼挂断呼叫")
public CommonResponse<Object> rollCallStop(@RequestBody TelephoneCallStopDTO telephoneCallStopDTO) {
return telephoneCallService.rollCallStop(telephoneCallStopDTO);
}
@PostMapping("/roll/cdrUrl")
@ApiOperation("点呼系统回调话单")

@ -6,6 +6,8 @@ import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException;
@ -13,6 +15,7 @@ import com.baiye.http.RollCallResponse;
import com.baiye.model.enums.ResponseCode;
import com.baiye.modules.telemarkting.entity.dto.RollCallSystemDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO;
import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@ -36,6 +39,8 @@ public class RollCallReq {
private String appId;
@Value("${roll.call.accountSid}")
private String accountSid;
@Value("${roll.call.stopUrl}")
private String stopUrl;
public String startReq(TelephoneCallReqDTO doubleCallReq) {
log.info("=======================RollCallReq start in {}", DateUtil.date());
@ -66,7 +71,7 @@ public class RollCallReq {
log.info("点呼返回值为 {}", httpResponse);
RollCallResponse doubleCallResponse = JSONUtil.toBean(httpResponse, RollCallResponse.class);
if (String.valueOf
(DefaultNumberConstants.ZERO_NUMBER)
(DefaultNumberConstants.ZERO_NUMBER)
.equals(doubleCallResponse.getResult())) {
return doubleCallResponse.getReqid();
} else {
@ -82,6 +87,33 @@ public class RollCallReq {
throw new BadRequestException(ResponseCode.CALL_ERROR.getDesc());
}
public Boolean stopReq(TelephoneCallStopDTO telephoneCallStopDTO) {
return stopTask(telephoneCallStopDTO);
}
private Boolean stopTask(TelephoneCallStopDTO telephoneCallStopDTO) {
int count = 0;
int flag = 3;
while (count <= flag) {
JSONObject json = new JSONObject();
json.putOpt("callid", telephoneCallStopDTO.getSessionid());
JSONObject jsonObject = new JSONObject();
jsonObject.putOpt("req_id",telephoneCallStopDTO.getCallId());
jsonObject.putOpt("type", "hangup");
jsonObject.putOpt("bsname", "aibot");
jsonObject.putOpt("body", json);
HttpResponse httpResponse = HttpRequest.post(stopUrl).body(JSONUtil.toJsonPrettyStr(jsonObject)).execute();
if (httpResponse.isOk()) {
log.info("请求挂断成功,返回值:{}", httpResponse.body());
return Boolean.TRUE;
} else {
count++;
log.error("请求失败,response==={}", httpResponse.body());
}
}
return Boolean.FALSE;
}
private String sendCallReq(Map<String, Object> json, String url, String authorization) {
return HttpRequest.post(url).
header(Header.AUTHORIZATION, authorization).

@ -11,53 +11,41 @@ public interface TelephoneCallService {
/**
*
*
* @param telephoneCallReqDTO
* @return
*/
CommonResponse<String> doubleCallReq(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId);
CommonResponse<TelephoneCallStopDTO> doubleCallReq(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId);
/**
*
* @param telephoneCallBackDTO
*/
void doubleCallBack(TelephoneCallBackDTO telephoneCallBackDTO);
/**
*
*
* @param telephoneCallBackStatusDTO
*/
void doubleCallBackStatus(TelephoneCallBackStatusDTO telephoneCallBackStatusDTO);
/**
*
*
* @param telephoneCallStopDTO
* @return
*
*/
CommonResponse<Object> doubleCallStop(TelephoneCallStopDTO telephoneCallStopDTO);
/**
*
*/
CommonResponse<Object> rollCallStop(TelephoneCallStopDTO telephoneCallStopDTO);
/**
* axb
*
* @param telephoneCallReqDTO
* @return
*/
CommonResponse<String> axbDialNumber(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId);
CommonResponse<TelephoneCallStopDTO> axbDialNumber(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId);
/**
*
*
* @param telephoneCallReqDTO
* @return
*/
CommonResponse<String> rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId);
CommonResponse<TelephoneCallStopDTO> rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId);
/**
*
*
* @param rollCallBackDTO
*/
void rollCallBack(RollCallBackDTO rollCallBackDTO);
}

@ -67,7 +67,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
private UserService userService;
@Override
public CommonResponse<String> doubleCallReq(TelephoneCallReqDTO doubleCallReq, Long companyId) {
public CommonResponse<TelephoneCallStopDTO> doubleCallReq(TelephoneCallReqDTO doubleCallReq, Long companyId) {
String requestId = RandomUtil.randomString(10);
doubleCallReq.setRequestId(requestId);
Clue body;
@ -106,7 +106,10 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
} else {
return CommonResponse.createByError();
}
return CommonResponse.createBySuccess(sessionId);
TelephoneCallStopDTO telephoneCallStopDTO = new TelephoneCallStopDTO();
telephoneCallStopDTO.setSessionid(sessionId);
telephoneCallStopDTO.setCallId(requestId);
return CommonResponse.createBySuccess(telephoneCallStopDTO);
}
@Override
@ -153,7 +156,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
}
@Override
public CommonResponse<String> axbDialNumber(TelephoneCallReqDTO doubleCallReq, Long companyId) {
public CommonResponse<TelephoneCallStopDTO> axbDialNumber(TelephoneCallReqDTO doubleCallReq, Long companyId) {
long originalNumber = Long.parseLong(doubleCallReq.getUserData());
ResponseEntity<Clue> body;
try {
@ -188,14 +191,17 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
clueInfo.setCompanyId(companyId);
allCallInfoRepository.save(allCallInfo);
callClueRepository.save(clueInfo);
return CommonResponse.createBySuccess(sessionId);
TelephoneCallStopDTO telephoneCallStopDTO = new TelephoneCallStopDTO();
telephoneCallStopDTO.setSessionid(sessionId);
telephoneCallStopDTO.setCallId(randomString);
return CommonResponse.createBySuccess(telephoneCallStopDTO);
}
}
return CommonResponse.createByError();
}
@Override
public CommonResponse<String> rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId) {
public CommonResponse<TelephoneCallStopDTO> rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId) {
String requestId = RandomUtil.randomString(10);
telephoneCallReqDTO.setRequestId(requestId);
if (telephoneCallReqDTO.getDisplay() == null || telephoneCallReqDTO.getTelA() == null) {
@ -251,8 +257,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
}
telephoneCallReqDTO.setTelB(body.getNid());
String reqId = rollCallReq.startReq(telephoneCallReqDTO);
log.info("=============================reqId {}", reqId);
// if (StrUtil.isNotBlank(reqId)) {
AllCallInfo allCallInfo = new AllCallInfo();
allCallInfo.setSessionId(requestId);
allCallInfo.setRequestId(requestId);
@ -272,9 +277,18 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
clueInfo.setCompanyId(companyId);
allCallInfoRepository.save(allCallInfo);
callClueRepository.save(clueInfo);
return CommonResponse.createBySuccess(requestId);
TelephoneCallStopDTO telephoneCallStopDTO = new TelephoneCallStopDTO();
telephoneCallStopDTO.setSessionid(reqId);
telephoneCallStopDTO.setCallId(requestId);
return CommonResponse.createBySuccess(telephoneCallStopDTO);
}
@Override
public CommonResponse<Object> rollCallStop(TelephoneCallStopDTO telephoneCallStopDTO) {
if (rollCallReq.stopReq(telephoneCallStopDTO)) {
return CommonResponse.createBySuccess();
}
return CommonResponse.createByError();
}
/**
* ()
*

@ -3,8 +3,8 @@ spring:
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:8.130.96.163}:${NACOS_PORT:8848}
# server-addr: localhost:8848
# server-addr: ${NACOS_HOST:8.130.96.163}:${NACOS_PORT:8848}
server-addr: localhost:8848
redis:
database: 2
host: 8.130.96.163
@ -83,8 +83,8 @@ login:
font-size: 25
business:
ids:
- 8
- 10
- 8
- 10
#是否允许生成代码生产环境设置为false
@ -141,7 +141,7 @@ roll:
cdrUrl: http://8.130.96.163:8866/api/roll/cdrUrl
#cdrUrl: https://baiyee.vip/api/roll/cdrUrl
#cdrUrl: http://localhost:8866/api/roll/cdrUrl
stopUrl: http://api.hzdaba.cn/v3/Accounts/default/Esl/Process
alipay:
protocol: https
# 不需要加/gateway.do这是新旧SDK的区别切记

@ -145,7 +145,7 @@ roll:
accountSid: dbby_hangzhoubaiyehl
appId: app1
cdrUrl: https://baiyee.vip/api/roll/cdrUrl
stopUrl: http://api.hzdaba.cn/v3/Accounts/default/Esl/Process
alipay:
protocol: https

@ -1,6 +1,5 @@
package com.baiye.module.dao;
import com.baiye.module.entity.ClueMiddle;
import com.baiye.module.entity.ClueTalk;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

@ -840,8 +840,8 @@ public class ClueServiceImpl implements ClueService {
if (clueTalk.getMemberStatus() == DefaultNumberConstants.FOUR_NUMBER) {
throw new BadRequestException("已经转为crm,请勿重复操作");
}
if (clueTalk.getClueCallStatus() == null || clueTalk.getClueCallStatus() == DefaultNumberConstants.ZERO_NUMBER) {
throw new BadRequestException("未拨打电话,不能转crm");
if (clueTalk.getClueCallStatus() == null || clueTalk.getClueCallStatus() != DefaultNumberConstants.TWO_NUMBER) {
throw new BadRequestException("未拨打有效电话,不能转crm");
}
int userCount = turnCrmLogRepository.findByUserIdCount(clueTalk.getMemberId()) + DefaultNumberConstants.ONE_NUMBER;
UserDto userInfo = userClient.findUserInfo(clueTalk.getMemberId());

Loading…
Cancel
Save