Преглед изворни кода

20221021--新增了智能客服的新接口测试

lifuquan пре 2 година
родитељ
комит
9b74c1b655

+ 19 - 8
src/main/java/com/nokia/domainb/DomainBApplication.java

@@ -3,19 +3,30 @@ package com.nokia.domainb;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.core.env.Environment;
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
 
-import java.net.InetAddress;
-import java.net.UnknownHostException;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 
 @Slf4j
 @SpringBootApplication
 public class DomainBApplication {
 
-    public static void main(String[] args) throws UnknownHostException {
-        SpringApplication app = new SpringApplication(DomainBApplication.class);
-        Environment env = app.run(args).getEnvironment();
-        log.info("╭( ′• o •′ )╭☞ run on http://{}:{}", InetAddress.getLocalHost().getHostAddress(),
-                env.getProperty("server.port"));
+    public static void main(String[] args) {
+        SpringApplication.run(DomainBApplication.class, args);
+    }
+
+    /**
+     * 欠费接口整合线程池配置
+     */
+    @Bean
+    public ThreadPoolExecutor qryowefeeExecutor() {
+        ThreadPoolExecutor executor = new ThreadPoolExecutor(100, 200, 0L, TimeUnit.MILLISECONDS,
+                new ArrayBlockingQueue<>(10000), new CustomizableThreadFactory("qryowefee-"));
+        executor.prestartAllCoreThreads();
+        log.info("qryowefee poolSize: {}", executor.getPoolSize());
+        return executor;
     }
 }

+ 47 - 0
src/main/java/com/nokia/domainb/capability/NorthFirstLine.java

@@ -0,0 +1,47 @@
+package com.nokia.domainb.capability;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import com.nokia.domainb.util.AESUtil;
+
+import cn.chinaunicom.open.common.Const;
+import cn.chinaunicom.open.nlgxptconnection.COMPConnection;
+import cn.chinaunicom.open.nlgxptconnection.COMPConnectionContext;
+import cn.chinaunicom.open.nlgxptconnection.impl.COMPJsonConnection;
+
+/**
+ * 智能客服一线定界结果查询接口
+ * json_chinaUnicom_hb18_complaintManagement_northFirstLine
+ * 智能客服支撑北一接口的v2版本
+ */
+public class NorthFirstLine extends AbstractQuery {
+    // 上线后记得找一下正式url
+    private static final String url = "";
+    private static final String urlTest = "http://10.124.150.230:8000/api/chinaUnicom/hb18/complaintManagement/northFirstLine/v1";
+
+    public COMPConnectionContext query(String phoneNumber, boolean test) throws Exception {
+        String realAppSecret = test ? appSecretTest : appSecret;
+        String realUrl = test ? urlTest : url;
+        COMPConnection compConnection = new COMPJsonConnection(appId, realAppSecret);
+
+        // REQ
+        Map<String, Object> req = new HashMap<>();
+
+        Map<String, Object> insideReq = new HashMap<>();
+        req.put("NORTH_FIRST_LINE_REQ", insideReq);
+
+        insideReq.put("phone", phoneNumber);
+        insideReq.put("reqid", UUID.randomUUID().toString());
+
+        String str = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + "_test";
+        String key = "qg4uY8byXoC5UXtB";
+        String loginid = AESUtil.Encrypt(str, key);
+        insideReq.put("loginid", loginid);
+
+        return compConnection.excute(Const.HttpMethodType.POST, realUrl, req, false);
+    }
+}

+ 0 - 26
src/main/java/com/nokia/domainb/config/ThreadPoolConfig.java

@@ -1,26 +0,0 @@
-package com.nokia.domainb.config;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
-
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-@Slf4j
-@Configuration
-public class ThreadPoolConfig {
-    /**
-     * 欠费接口整合线程池配置
-     */
-    @Bean
-    public ThreadPoolExecutor qryowefeeExecutor() {
-        ThreadPoolExecutor executor = new ThreadPoolExecutor(100, 200, 0L, TimeUnit.MILLISECONDS,
-                new ArrayBlockingQueue<>(10000), new CustomizableThreadFactory("qryowefee-"));
-        executor.prestartAllCoreThreads();
-        log.info("qryowefee poolSize: {}", executor.getPoolSize());
-        return executor;
-    }
-}

+ 3 - 6
src/main/resources/logback-spring.xml

@@ -3,8 +3,7 @@
     <property name="PATH" value="./log"/>
     <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
         <encoder>
-            <Pattern>%d{HH:mm:ss.SSS} %highlight(%-5level) %yellow(%X{traceId}) %magenta([%thread]) %cyan(%logger:%line) %msg%n</Pattern>
-            <charset>UTF-8</charset>
+            <Pattern>%d{HH:mm:ss.SSS} %highlight(%-5level) %yellow(%X{traceId}) %cyan(%logger:%line) %msg%n</Pattern>
         </encoder>
     </appender>
     <appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
@@ -18,8 +17,7 @@
             <totalSizeCap>20GB</totalSizeCap>
         </rollingPolicy>
         <encoder>
-            <Pattern>%d %highlight(%-5level) %yellow(%X{traceId}) %magenta([%thread]) %cyan(%logger:%line) %msg%n</Pattern>
-            <charset>UTF-8</charset>
+            <Pattern>%d %highlight(%-5level) %yellow(%X{traceId}) %cyan(%logger:%line) %msg%n</Pattern>
         </encoder>
     </appender>
     <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
@@ -33,8 +31,7 @@
             <totalSizeCap>20GB</totalSizeCap>
         </rollingPolicy>
         <encoder>
-            <Pattern>%d %highlight(%-5level) %yellow(%X{traceId}) %magenta([%thread]) %cyan(%logger:%line) %msg%n</Pattern>
-            <charset>UTF-8</charset>
+            <Pattern>%d %highlight(%-5level) %yellow(%X{traceId}) %cyan(%logger:%line) %msg%n</Pattern>
         </encoder>
         <filter class="ch.qos.logback.classic.filter.LevelFilter">
             <level>ERROR</level>

+ 16 - 0
src/test/java/com/nokia/domainb/capability/NorthFirstLineTest.java

@@ -0,0 +1,16 @@
+package com.nokia.domainb.capability;
+
+import org.junit.jupiter.api.Test;
+
+import cn.chinaunicom.open.nlgxptconnection.COMPConnectionContext;
+
+public class NorthFirstLineTest {
+
+    @Test
+    void testQuery() throws Exception {
+        NorthFirstLine northFirstLine = new NorthFirstLine();
+        COMPConnectionContext context = northFirstLine.query("13231899751", true);
+        System.out.println(context.getRequestContext());
+        System.out.println(context.getResponseContext());
+    }
+}