cleanup dial number
This commit is contained in:
parent
dc956c5ff1
commit
5801bb591b
@ -4,6 +4,7 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import com.pudonghot.yo.util.PhoneNumberUtils;
|
||||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ public class RespCallingList {
|
|||||||
* @return pair
|
* @return pair
|
||||||
*/
|
*/
|
||||||
public Pair<String, String> toPair() {
|
public Pair<String, String> toPair() {
|
||||||
return Pair.of(phone, id);
|
return Pair.of(PhoneNumberUtils.cleanupMobile(phone), id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ if [ -z "$1" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
url="http://localhost:8082/agent-event/fetch/$1"
|
url="http://localhost:8082/dev/agent-event/fetch/$1"
|
||||||
echo "Listen URL: $url"
|
echo "Listen URL: $url"
|
||||||
count=0
|
count=0
|
||||||
|
|
||||||
|
@ -13,14 +13,18 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import com.pudonghot.yo.fsagent.api.request.ReqCampaignDial;
|
import com.pudonghot.yo.fsagent.api.request.ReqCampaignDial;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 仅供开发测试验证用
|
||||||
|
*
|
||||||
* @author Donghuang
|
* @author Donghuang
|
||||||
* @date Jun 12, 2020 10:04:20
|
* @date Jun 12, 2020 10:04:20
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
|
@RequestMapping("/dev")
|
||||||
public class DialController {
|
public class DialController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DialService dialService;
|
private DialService dialService;
|
||||||
|
@ -57,7 +57,7 @@ public class DialplanService20CampaignToIdAndType extends BaseDialplanService {
|
|||||||
|
|
||||||
String otherDn = params.getCalledNumber();
|
String otherDn = params.getCalledNumber();
|
||||||
if (StringUtils.isBlank(otherDn)) {
|
if (StringUtils.isBlank(otherDn)) {
|
||||||
otherDn = PhoneNumberUtils.cleanupMobile(
|
otherDn = PhoneNumberUtils.extractMobile(
|
||||||
call.getCallerChannel().getNumber());
|
call.getCallerChannel().getNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class TrunkServiceImpl
|
|||||||
|
|
||||||
if (trunk != null) {
|
if (trunk != null) {
|
||||||
return Pair.of(trunk,
|
return Pair.of(trunk,
|
||||||
PhoneNumberUtils.cleanupMobile(
|
PhoneNumberUtils.extractMobile(
|
||||||
calledNumber.substring(prefixLength)));
|
calledNumber.substring(prefixLength)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,13 @@ public class PhoneNumberUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cleanup mobile
|
* extract mobile
|
||||||
|
*
|
||||||
* 01378888666 -> 1378888666
|
* 01378888666 -> 1378888666
|
||||||
* @param mobile mobile number
|
* @param mobile mobile number
|
||||||
* @return mobile cleaned
|
* @return mobile cleaned
|
||||||
*/
|
*/
|
||||||
public static String cleanupMobile(final String mobile) {
|
public static String extractMobile(final String mobile) {
|
||||||
if (mobile.length() > MOBILE_LENGTH
|
if (mobile.length() > MOBILE_LENGTH
|
||||||
&& PATTERN_CONTAINS_MOBILE.matcher(mobile).find()) {
|
&& PATTERN_CONTAINS_MOBILE.matcher(mobile).find()) {
|
||||||
return mobile.substring(
|
return mobile.substring(
|
||||||
@ -42,4 +43,16 @@ public class PhoneNumberUtils {
|
|||||||
|
|
||||||
return mobile;
|
return mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clean mobile, remove none-number chars then extract mobile
|
||||||
|
*
|
||||||
|
* 01378888666; -> 1378888666
|
||||||
|
* 901378888666; -> 1378888666
|
||||||
|
* @param mobile mobile number
|
||||||
|
* @return mobile cleaned
|
||||||
|
*/
|
||||||
|
public static String cleanupMobile(final String mobile) {
|
||||||
|
return extractMobile(mobile.replaceAll("[^\\d]", ""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,8 @@ public class PhoneNumberUtilsTest {
|
|||||||
log.info("val [{}].", PhoneNumberUtils.isMobile("13164268809"));
|
log.info("val [{}].", PhoneNumberUtils.isMobile("13164268809"));
|
||||||
log.info("val [{}].", PhoneNumberUtils.isMobile("14164268809"));
|
log.info("val [{}].", PhoneNumberUtils.isMobile("14164268809"));
|
||||||
log.info("val [{}].", PhoneNumberUtils.isMobile("12164268809"));
|
log.info("val [{}].", PhoneNumberUtils.isMobile("12164268809"));
|
||||||
log.info("val [{}].", PhoneNumberUtils.cleanupMobile("013564268809"));
|
log.info("val [{}].", PhoneNumberUtils.extractMobile("013564268809"));
|
||||||
log.info("val [{}].", PhoneNumberUtils.cleanupMobile("9010013564268809"));
|
log.info("val [{}].", PhoneNumberUtils.extractMobile("9010013564268809"));
|
||||||
|
log.info("val clean up [{}].", PhoneNumberUtils.cleanupMobile("0100135642-688A9;"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class AgentEventController implements SessionAbility {
|
|||||||
*
|
*
|
||||||
* @param agentId agent id
|
* @param agentId agent id
|
||||||
*/
|
*/
|
||||||
@PostMapping("/agent-event/publish/{agentId}")
|
@PostMapping("/dev/agent-event/publish/{agentId}")
|
||||||
public void publish(
|
public void publish(
|
||||||
@PathVariable("agentId")
|
@PathVariable("agentId")
|
||||||
final Integer agentId,
|
final Integer agentId,
|
||||||
@ -82,7 +82,7 @@ public class AgentEventController implements SessionAbility {
|
|||||||
*
|
*
|
||||||
* @param agentId agent id
|
* @param agentId agent id
|
||||||
*/
|
*/
|
||||||
@GetMapping("/agent-event/fetch/{agentId}")
|
@GetMapping("/dev/agent-event/fetch/{agentId}")
|
||||||
public DeferredResult<RespAgentEvent> fetch(
|
public DeferredResult<RespAgentEvent> fetch(
|
||||||
@PathVariable("agentId")
|
@PathVariable("agentId")
|
||||||
final Integer agentId) {
|
final Integer agentId) {
|
||||||
|
@ -5,6 +5,7 @@ import com.wacai.tigon.mybatis.Search;
|
|||||||
import com.pudonghot.yo.model.domain.Agent;
|
import com.pudonghot.yo.model.domain.Agent;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import com.pudonghot.yo.util.PhoneNumberUtils;
|
||||||
import com.pudonghot.yo.fs.model.domain.Channel;
|
import com.pudonghot.yo.fs.model.domain.Channel;
|
||||||
import com.pudonghot.yo.fsagent.api.DialService;
|
import com.pudonghot.yo.fsagent.api.DialService;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
@ -73,6 +74,7 @@ public class CallController implements SessionAbility {
|
|||||||
@RequestBody
|
@RequestBody
|
||||||
final ReqAgentDialout args) {
|
final ReqAgentDialout args) {
|
||||||
|
|
||||||
|
log.info("Dial out [{}].", args);
|
||||||
final Pair<Agent, Channel> agentChannel = find(account);
|
final Pair<Agent, Channel> agentChannel = find(account);
|
||||||
final Channel channel = agentChannel.getRight();
|
final Channel channel = agentChannel.getRight();
|
||||||
|
|
||||||
@ -82,7 +84,8 @@ public class CallController implements SessionAbility {
|
|||||||
final ReqAgentDial reqAgentDial = new ReqAgentDial();
|
final ReqAgentDial reqAgentDial = new ReqAgentDial();
|
||||||
reqAgentDial.setTenantId(getTenantId());
|
reqAgentDial.setTenantId(getTenantId());
|
||||||
reqAgentDial.setAccount(account);
|
reqAgentDial.setAccount(account);
|
||||||
reqAgentDial.setCalledNumber(args.getCalled());
|
reqAgentDial.setCalledNumber(
|
||||||
|
PhoneNumberUtils.cleanupMobile(args.getCalled()));
|
||||||
return new RespAgentDialout(dialService.agentDial(reqAgentDial).getUuid());
|
return new RespAgentDialout(dialService.agentDial(reqAgentDial).getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ if [ -z "$1" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
url="http://localhost:8082/agent-event/publish/$1"
|
url="http://localhost:8082/dev/agent-event/publish/$1"
|
||||||
echo "Publish URL: $url"
|
echo "Publish URL: $url"
|
||||||
count=0
|
count=0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user