diff --git a/campaign/src/main/java/com/pudonghot/yo/campaign/feign/response/RespCallingList.java b/campaign/src/main/java/com/pudonghot/yo/campaign/feign/response/RespCallingList.java index 4f1a33d7..f4184ccd 100644 --- a/campaign/src/main/java/com/pudonghot/yo/campaign/feign/response/RespCallingList.java +++ b/campaign/src/main/java/com/pudonghot/yo/campaign/feign/response/RespCallingList.java @@ -4,6 +4,7 @@ import lombok.Getter; import lombok.Setter; import lombok.ToString; import org.apache.commons.lang3.tuple.Pair; +import com.pudonghot.yo.util.PhoneNumberUtils; import com.fasterxml.jackson.annotation.JsonAlias; import com.fasterxml.jackson.annotation.JsonProperty; @@ -50,7 +51,7 @@ public class RespCallingList { * @return pair */ public Pair toPair() { - return Pair.of(phone, id); + return Pair.of(PhoneNumberUtils.cleanupMobile(phone), id); } } } diff --git a/fetch-event.sh b/fetch-event.sh index 9b764659..e4dd6f55 100755 --- a/fetch-event.sh +++ b/fetch-event.sh @@ -5,7 +5,7 @@ if [ -z "$1" ]; then exit 1 fi -url="http://localhost:8082/agent-event/fetch/$1" +url="http://localhost:8082/dev/agent-event/fetch/$1" echo "Listen URL: $url" count=0 diff --git a/fsagent/src/main/java/com/pudonghot/yo/fsagent/controller/DialController.java b/fsagent/src/main/java/com/pudonghot/yo/fsagent/controller/DialController.java index 82d6d4c1..7368670a 100644 --- a/fsagent/src/main/java/com/pudonghot/yo/fsagent/controller/DialController.java +++ b/fsagent/src/main/java/com/pudonghot/yo/fsagent/controller/DialController.java @@ -13,14 +13,18 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import com.pudonghot.yo.fsagent.api.request.ReqCampaignDial; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.beans.factory.annotation.Autowired; /** + * 仅供开发测试验证用 + * * @author Donghuang * @date Jun 12, 2020 10:04:20 */ @Slf4j @Controller +@RequestMapping("/dev") public class DialController { @Autowired private DialService dialService; diff --git a/fsagent/src/main/java/com/pudonghot/yo/fsagent/service/dialplan/impl/DialplanService20CampaignToIdAndType.java b/fsagent/src/main/java/com/pudonghot/yo/fsagent/service/dialplan/impl/DialplanService20CampaignToIdAndType.java index b2e927d5..9a0abd3f 100644 --- a/fsagent/src/main/java/com/pudonghot/yo/fsagent/service/dialplan/impl/DialplanService20CampaignToIdAndType.java +++ b/fsagent/src/main/java/com/pudonghot/yo/fsagent/service/dialplan/impl/DialplanService20CampaignToIdAndType.java @@ -57,7 +57,7 @@ public class DialplanService20CampaignToIdAndType extends BaseDialplanService { String otherDn = params.getCalledNumber(); if (StringUtils.isBlank(otherDn)) { - otherDn = PhoneNumberUtils.cleanupMobile( + otherDn = PhoneNumberUtils.extractMobile( call.getCallerChannel().getNumber()); } diff --git a/fsagent/src/main/java/com/pudonghot/yo/fsagent/service/impl/TrunkServiceImpl.java b/fsagent/src/main/java/com/pudonghot/yo/fsagent/service/impl/TrunkServiceImpl.java index a026ca35..bceaa742 100644 --- a/fsagent/src/main/java/com/pudonghot/yo/fsagent/service/impl/TrunkServiceImpl.java +++ b/fsagent/src/main/java/com/pudonghot/yo/fsagent/service/impl/TrunkServiceImpl.java @@ -131,7 +131,7 @@ public class TrunkServiceImpl if (trunk != null) { return Pair.of(trunk, - PhoneNumberUtils.cleanupMobile( + PhoneNumberUtils.extractMobile( calledNumber.substring(prefixLength))); } } diff --git a/lib/util/src/main/java/com/pudonghot/yo/util/PhoneNumberUtils.java b/lib/util/src/main/java/com/pudonghot/yo/util/PhoneNumberUtils.java index bcff8c7a..db29a302 100644 --- a/lib/util/src/main/java/com/pudonghot/yo/util/PhoneNumberUtils.java +++ b/lib/util/src/main/java/com/pudonghot/yo/util/PhoneNumberUtils.java @@ -28,12 +28,13 @@ public class PhoneNumberUtils { } /** - * cleanup mobile + * extract mobile + * * 01378888666 -> 1378888666 * @param mobile mobile number * @return mobile cleaned */ - public static String cleanupMobile(final String mobile) { + public static String extractMobile(final String mobile) { if (mobile.length() > MOBILE_LENGTH && PATTERN_CONTAINS_MOBILE.matcher(mobile).find()) { return mobile.substring( @@ -42,4 +43,16 @@ public class PhoneNumberUtils { 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]", "")); + } } diff --git a/lib/util/src/test/java/com/pudonghot/yo/util/PhoneNumberUtilsTest.java b/lib/util/src/test/java/com/pudonghot/yo/util/PhoneNumberUtilsTest.java index 0debd74c..123fd24f 100644 --- a/lib/util/src/test/java/com/pudonghot/yo/util/PhoneNumberUtilsTest.java +++ b/lib/util/src/test/java/com/pudonghot/yo/util/PhoneNumberUtilsTest.java @@ -18,7 +18,8 @@ public class PhoneNumberUtilsTest { log.info("val [{}].", PhoneNumberUtils.isMobile("13164268809")); log.info("val [{}].", PhoneNumberUtils.isMobile("14164268809")); log.info("val [{}].", PhoneNumberUtils.isMobile("12164268809")); - log.info("val [{}].", PhoneNumberUtils.cleanupMobile("013564268809")); - log.info("val [{}].", PhoneNumberUtils.cleanupMobile("9010013564268809")); + log.info("val [{}].", PhoneNumberUtils.extractMobile("013564268809")); + log.info("val [{}].", PhoneNumberUtils.extractMobile("9010013564268809")); + log.info("val clean up [{}].", PhoneNumberUtils.cleanupMobile("0100135642-688A9;")); } } diff --git a/openapi/src/main/java/com/pudonghot/yo/openapi/controller/AgentEventController.java b/openapi/src/main/java/com/pudonghot/yo/openapi/controller/AgentEventController.java index 53345d7e..b181236b 100644 --- a/openapi/src/main/java/com/pudonghot/yo/openapi/controller/AgentEventController.java +++ b/openapi/src/main/java/com/pudonghot/yo/openapi/controller/AgentEventController.java @@ -62,7 +62,7 @@ public class AgentEventController implements SessionAbility { * * @param agentId agent id */ - @PostMapping("/agent-event/publish/{agentId}") + @PostMapping("/dev/agent-event/publish/{agentId}") public void publish( @PathVariable("agentId") final Integer agentId, @@ -82,7 +82,7 @@ public class AgentEventController implements SessionAbility { * * @param agentId agent id */ - @GetMapping("/agent-event/fetch/{agentId}") + @GetMapping("/dev/agent-event/fetch/{agentId}") public DeferredResult fetch( @PathVariable("agentId") final Integer agentId) { diff --git a/openapi/src/main/java/com/pudonghot/yo/openapi/controller/CallController.java b/openapi/src/main/java/com/pudonghot/yo/openapi/controller/CallController.java index 145c76f9..7799a6a5 100644 --- a/openapi/src/main/java/com/pudonghot/yo/openapi/controller/CallController.java +++ b/openapi/src/main/java/com/pudonghot/yo/openapi/controller/CallController.java @@ -5,6 +5,7 @@ import com.wacai.tigon.mybatis.Search; import com.pudonghot.yo.model.domain.Agent; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.StringUtils; +import com.pudonghot.yo.util.PhoneNumberUtils; import com.pudonghot.yo.fs.model.domain.Channel; import com.pudonghot.yo.fsagent.api.DialService; import org.springframework.stereotype.Controller; @@ -73,6 +74,7 @@ public class CallController implements SessionAbility { @RequestBody final ReqAgentDialout args) { + log.info("Dial out [{}].", args); final Pair agentChannel = find(account); final Channel channel = agentChannel.getRight(); @@ -82,7 +84,8 @@ public class CallController implements SessionAbility { final ReqAgentDial reqAgentDial = new ReqAgentDial(); reqAgentDial.setTenantId(getTenantId()); reqAgentDial.setAccount(account); - reqAgentDial.setCalledNumber(args.getCalled()); + reqAgentDial.setCalledNumber( + PhoneNumberUtils.cleanupMobile(args.getCalled())); return new RespAgentDialout(dialService.agentDial(reqAgentDial).getUuid()); } diff --git a/push-event.sh b/push-event.sh index 2e8d3f81..5bcf079a 100755 --- a/push-event.sh +++ b/push-event.sh @@ -5,7 +5,7 @@ if [ -z "$1" ]; then exit 1 fi -url="http://localhost:8082/agent-event/publish/$1" +url="http://localhost:8082/dev/agent-event/publish/$1" echo "Publish URL: $url" count=0