|
@@ -1,20 +1,167 @@
|
|
|
package com.nokia.domainb.capability;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
+import com.nokia.domainb.util.AESUtil;
|
|
|
+import de.siegmar.fastcsv.reader.CsvReader;
|
|
|
+import de.siegmar.fastcsv.reader.CsvRow;
|
|
|
+import de.siegmar.fastcsv.writer.CsvWriter;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
+import org.springframework.util.StopWatch;
|
|
|
|
|
|
-import cn.chinaunicom.open.nlgxptconnection.COMPConnectionContext;
|
|
|
+import java.io.OutputStreamWriter;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+class UsercomplaintQuerysTest {
|
|
|
+ public static final String TEST_DIR = "z:/";
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void test() {
|
|
|
+ String d1 = TEST_DIR + "103.csv";
|
|
|
+ String d2 = TEST_DIR + "101.csv";
|
|
|
+ String result1 = TEST_DIR + "无法发送测试结果.csv";
|
|
|
+ String result2 = TEST_DIR + "无法接收测试结果.csv";
|
|
|
+ try (CsvReader r1 = CsvReader.builder().build(Paths.get(d1), StandardCharsets.UTF_8);
|
|
|
+ CsvReader r2 = CsvReader.builder().build(Paths.get(d2), StandardCharsets.UTF_8);
|
|
|
+ OutputStreamWriter osw1 = new OutputStreamWriter(Files.newOutputStream(Paths.get(result1)),
|
|
|
+ StandardCharsets.UTF_8);
|
|
|
+ CsvWriter w1 = CsvWriter.builder().build(osw1);
|
|
|
+ OutputStreamWriter osw2 = new OutputStreamWriter(Files.newOutputStream(Paths.get(result2)),
|
|
|
+ StandardCharsets.UTF_8);
|
|
|
+ CsvWriter w2 = CsvWriter.builder().build(osw2);) {
|
|
|
+ w1.writeRow("入参", "时间", "调用时长", "结果");
|
|
|
+ for (CsvRow row : r1) {
|
|
|
+ if (row.getOriginalLineNumber() == 1) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String mobile = row.getField(1);
|
|
|
+ LocalDateTime beginTimeLocalDateTime = getLocalDateTime(row.getField(2));
|
|
|
+ String beginTime = getTimeString(beginTimeLocalDateTime);
|
|
|
+// String endTime = "";
|
|
|
+ String endTime = getTimeString(beginTimeLocalDateTime.plusDays(3));
|
|
|
+ String cKey = "qg4uY8nV7fPhvUXt";
|
|
|
+ String cSrc = getTimeString() + "_" + "test";
|
|
|
+ String token = AESUtil.Encrypt(cSrc, cKey);
|
|
|
+ String complaintType = "1";
|
|
|
+ String isMobile = "";
|
|
|
+ String flowNo = "103";
|
|
|
+ String destAddr = "";
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("mobile", mobile);
|
|
|
+ map.put("destAddr", destAddr);
|
|
|
+ map.put("complaintType", complaintType);
|
|
|
+ map.put("isMobile", isMobile);
|
|
|
+ map.put("flowNo", flowNo);
|
|
|
+ map.put("beginTime", beginTime);
|
|
|
+ map.put("endTime", endTime);
|
|
|
+ map.put("token", token);
|
|
|
+ UsercomplaintQuerys usercomplaintQuerys = new UsercomplaintQuerys();
|
|
|
+ String result;
|
|
|
+ String now = LocalDateTime.now().toString();
|
|
|
+ StopWatch stopWatch = new StopWatch();
|
|
|
+ stopWatch.start();
|
|
|
+ try {
|
|
|
+ result = usercomplaintQuerys.query(mobile, destAddr, complaintType, isMobile, flowNo, beginTime,
|
|
|
+ endTime, token, false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ result = e.getMessage();
|
|
|
+ }
|
|
|
+ stopWatch.stop();
|
|
|
+ log.info("{} | {} ms | {}", mobile, stopWatch.getTotalTimeMillis(), result);
|
|
|
+ w1.writeRow(JSON.toJSONString(map), now, String.valueOf(stopWatch.getTotalTimeMillis()),
|
|
|
+ JSON.toJSONString(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ w2.writeRow("入参", "时间", "调用时长", "结果");
|
|
|
+ for (CsvRow row : r2) {
|
|
|
+ if (row.getOriginalLineNumber() == 1) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String mobile = row.getField(1);
|
|
|
+ LocalDateTime beginTimeLocalDateTime = getLocalDateTime(row.getField(2));
|
|
|
+ String beginTime = getTimeString(beginTimeLocalDateTime);
|
|
|
+// String endTime = "";
|
|
|
+ String endTime = getTimeString(beginTimeLocalDateTime.plusDays(3));
|
|
|
+ String cKey = "qg4uY8nV7fPhvUXt";
|
|
|
+ String cSrc = getTimeString() + "_" + "test";
|
|
|
+ String token = AESUtil.Encrypt(cSrc, cKey);
|
|
|
+ String complaintType = "2";
|
|
|
+ String isMobile = "";
|
|
|
+ String flowNo = "101";
|
|
|
+ String destAddr = "";
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("mobile", mobile);
|
|
|
+ map.put("destAddr", destAddr);
|
|
|
+ map.put("complaintType", complaintType);
|
|
|
+ map.put("isMobile", isMobile);
|
|
|
+ map.put("flowNo", flowNo);
|
|
|
+ map.put("beginTime", beginTime);
|
|
|
+ map.put("endTime", endTime);
|
|
|
+ map.put("token", token);
|
|
|
+ UsercomplaintQuerys usercomplaintQuerys = new UsercomplaintQuerys();
|
|
|
+ String result;
|
|
|
+ String now = LocalDateTime.now().toString();
|
|
|
+ StopWatch stopWatch = new StopWatch();
|
|
|
+ stopWatch.start();
|
|
|
+ try {
|
|
|
+ result = usercomplaintQuerys.query(mobile, destAddr, complaintType, isMobile, flowNo, beginTime,
|
|
|
+ endTime, token, false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ result = e.getMessage();
|
|
|
+ }
|
|
|
+ stopWatch.stop();
|
|
|
+ log.info("{} | {} ms | {}", mobile, stopWatch.getTotalTimeMillis(), result);
|
|
|
+ w2.writeRow(JSON.toJSONString(map), now, String.valueOf(stopWatch.getTotalTimeMillis()),
|
|
|
+ JSON.toJSONString(result));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-public class UsercomplaintQuerysTest {
|
|
|
- /*
|
|
|
- * 测试环境
|
|
|
- */
|
|
|
@Test
|
|
|
- void testQuery() {
|
|
|
+ void testQuery() throws Exception {
|
|
|
+ String cKey = "qg4uY8nV7fPhvUXt";
|
|
|
+ String cSrc = getTimeString() + "_" + "test";
|
|
|
+ String token = AESUtil.Encrypt(cSrc, cKey);
|
|
|
+ String mobile = "15633026835";
|
|
|
+ String complaintType = "1";
|
|
|
+ String isMobile = "";
|
|
|
+// String isMobile = "1";
|
|
|
+ String flowNo = "103";
|
|
|
+ String beginTime = "20220824203620";
|
|
|
+// String beginTime = getTimeString("2022-08-23 18:43:56");
|
|
|
+// String endTime = getTimeString(LocalDateTime.parse(beginTime, DateTimeFormatter.ofPattern("yyyyMMddHHmmss")).plusDays(1));
|
|
|
+// String endTime = "";
|
|
|
+ String endTime = "20220825203620";
|
|
|
+ String destAddr = "";
|
|
|
UsercomplaintQuerys usercomplaintQuerys = new UsercomplaintQuerys();
|
|
|
- COMPConnectionContext result = usercomplaintQuerys.query("13231899751", "", "1", "2", "101", "20220709000000",
|
|
|
- "20220710235959",
|
|
|
- "A4ZWiyWpfJmeqFIRUTz6whuCJWcgRNuAiTI0SSIwehc=", true);
|
|
|
- System.out.println(result.getRequestContext());
|
|
|
- System.out.println(result.getResponseContext());
|
|
|
+ StopWatch stopWatch = new StopWatch();
|
|
|
+ stopWatch.start();
|
|
|
+ String result = usercomplaintQuerys.query(mobile, destAddr, complaintType, isMobile, flowNo, beginTime,
|
|
|
+ endTime, token, false);
|
|
|
+ stopWatch.stop();
|
|
|
+ log.info("{} | {} ms | {}", mobile, stopWatch.getTotalTimeMillis(), result);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getTimeString(LocalDateTime time) {
|
|
|
+ return time.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getTimeString() {
|
|
|
+ return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
|
|
+ }
|
|
|
+
|
|
|
+ private LocalDateTime getLocalDateTime(String time) {
|
|
|
+ return LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
}
|
|
|
}
|