parent
a1b50f82f2
commit
d790b9c214
@ -0,0 +1,28 @@
|
|||||||
|
package com.mashibing.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-27 0:29
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum CMPP2DeliverEnums {
|
||||||
|
|
||||||
|
DELIVRD("DELIVRD","Message is delivered to destination"),
|
||||||
|
EXPIRED("EXPIRED","Message validity period has expired"),
|
||||||
|
DELETED("DELETED","Message has been deleted"),
|
||||||
|
UNDELIV("UNDELIV","Message is undeliverable"),
|
||||||
|
ACCEPTD("ACCEPTD","Message is in accepted state"),
|
||||||
|
UNKNOWN("UNKNOWN","Message is in invalid state"),
|
||||||
|
REJECTD("REJECTD","Message is in a rejected state"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private String stat;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
CMPP2DeliverEnums(String stat, String description) {
|
||||||
|
this.stat = stat;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.mashibing.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-26 23:31
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum CMPP2ResultEnums {
|
||||||
|
|
||||||
|
OK(0, "正确"),
|
||||||
|
MESSAGE_BUILD_ERROR(1, "消息体结构错误"),
|
||||||
|
COMMAND_WORD_ERROR(2, "命令字错"),
|
||||||
|
MESSAGE_SEQUENCE_ERROR(3, "消息序号重复"),
|
||||||
|
MESSAGE_LENGTH_ERROR(4, "消息长度错误"),
|
||||||
|
INCORRECT_TARIFF_CODE(5, "资费代码错误"),
|
||||||
|
EXCEEDING_MAXIMUM_MESSAGE_LENGTH(6, "超过最大信息长"),
|
||||||
|
BUSINESS_CODE_ERROR(7, "业务代码错误"),
|
||||||
|
FLOW_CONTROL_ERROR(8, "流量控制错误"),
|
||||||
|
UNKNOWN(9, "其他错误"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private Integer result;
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
CMPP2ResultEnums(Integer result, String msg) {
|
||||||
|
this.result = result;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.mashibing.common.util;
|
||||||
|
|
||||||
|
import com.mashibing.common.enums.CMPP2DeliverEnums;
|
||||||
|
import com.mashibing.common.enums.CMPP2ResultEnums;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-26 23:40
|
||||||
|
*/
|
||||||
|
public class CMPP2DeliverUtil {
|
||||||
|
|
||||||
|
private static Map<String,String> states = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
CMPP2DeliverEnums[] cmpp2DeliverEnums = CMPP2DeliverEnums.values();
|
||||||
|
for (CMPP2DeliverEnums cmpp2ResultEnum : cmpp2DeliverEnums){
|
||||||
|
states.put(cmpp2ResultEnum.getStat(),cmpp2ResultEnum.getDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getResultMessage(String result){
|
||||||
|
return states.get(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.mashibing.common.util;
|
||||||
|
|
||||||
|
import com.mashibing.common.enums.CMPP2ResultEnums;
|
||||||
|
import com.mashibing.common.enums.MobileOperatorEnum;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-26 23:40
|
||||||
|
*/
|
||||||
|
public class CMPP2ResultUtil {
|
||||||
|
|
||||||
|
private static Map<Integer,String> results = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
CMPP2ResultEnums[] cmpp2ResultEnums = CMPP2ResultEnums.values();
|
||||||
|
for (CMPP2ResultEnums cmpp2ResultEnum : cmpp2ResultEnums){
|
||||||
|
results.put(cmpp2ResultEnum.getResult(),cmpp2ResultEnum.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getResultMessage(Integer result){
|
||||||
|
return results.get(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.mashibing.smsgateway.client;
|
||||||
|
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-21 10:14
|
||||||
|
*/
|
||||||
|
@FeignClient(value = "beacon-cache")
|
||||||
|
public interface BeaconCacheClient {
|
||||||
|
|
||||||
|
@GetMapping("/cache/hget/{key}/{field}")
|
||||||
|
Integer hgetInteger(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field);
|
||||||
|
|
||||||
|
@GetMapping("/cache/hget/{key}/{field}")
|
||||||
|
String hget(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.mashibing.smsgateway.config;
|
||||||
|
|
||||||
|
import cn.hippo4j.core.executor.DynamicThreadPool;
|
||||||
|
import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-26 23:13
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class ThreadPoolConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@DynamicThreadPool
|
||||||
|
public ThreadPoolExecutor cmppSubmitPool() {
|
||||||
|
String threadPoolId = "cmpp-submit";
|
||||||
|
ThreadPoolExecutor messageConsumeDynamicExecutor = ThreadPoolBuilder.builder()
|
||||||
|
// 指定线程名称的前缀
|
||||||
|
.threadFactory(threadPoolId)
|
||||||
|
// 线程池在Hippo4j中的唯一标识
|
||||||
|
.threadPoolId(threadPoolId)
|
||||||
|
// 代表动态线程池
|
||||||
|
.dynamicPool()
|
||||||
|
.build();
|
||||||
|
return messageConsumeDynamicExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@DynamicThreadPool
|
||||||
|
public ThreadPoolExecutor cmppDeliverPool() {
|
||||||
|
String threadPoolId = "cmpp-deliver";
|
||||||
|
ThreadPoolExecutor messageProduceDynamicExecutor = ThreadPoolBuilder.builder()
|
||||||
|
.threadFactory(threadPoolId)
|
||||||
|
.threadPoolId(threadPoolId)
|
||||||
|
.dynamicPool()
|
||||||
|
.build();
|
||||||
|
return messageProduceDynamicExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.mashibing.smsgateway.util;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-26 23:56
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class SpringUtil implements ApplicationContextAware {
|
||||||
|
|
||||||
|
private static ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
SpringUtil.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object getBeanByName(String beanName){
|
||||||
|
return SpringUtil.applicationContext.getBean(beanName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T>T getBeanByClass(Class<T> clazz){
|
||||||
|
return SpringUtil.applicationContext.getBean(clazz);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue