TslDataApplicationTest.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package com.nokia.tsl_data;
  2. import java.util.List;
  3. import org.junit.jupiter.api.Test;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.boot.test.context.SpringBootTest;
  6. import com.nokia.tsl_data.dao.TargetTsRatioMapper;
  7. import com.nokia.tsl_data.service.TaskService;
  8. import com.nokia.tsl_data.service.UserCountService;
  9. import com.nokia.tsl_data.util.TextUtil;
  10. @SpringBootTest
  11. class TslDataApplicationTest {
  12. @Autowired
  13. private TaskService taskService;
  14. @Test
  15. void test() {
  16. taskService.generateReportV3("20241202");
  17. }
  18. @Test
  19. void test1() {
  20. taskService.runTaskForDay("20241205");
  21. }
  22. @Autowired
  23. private UserCountService userCountService;
  24. @Test
  25. void test2() {
  26. String path = "/data/abc.txt";
  27. List<String> lines = TextUtil.readLines(path, "utf8");
  28. lines.forEach(line -> {
  29. String[] split = line.split("\t");
  30. System.out.println(split[0] + "==" + split[2]);
  31. userCountService.updateManagementUserCount("202506", split[0], Double.parseDouble(split[2]));
  32. });
  33. }
  34. @Autowired
  35. private TargetTsRatioMapper targetTsRatioMapper;
  36. @Test
  37. void test3() {
  38. String path = "/data/abc.txt";
  39. List<String> lines = TextUtil.readLines(path, "utf8");
  40. lines.forEach(line -> {
  41. String[] split = line.split("\t");
  42. for (int i = 1; i < split.length; i++) {
  43. String city = split[0];
  44. String month = i < 10 ? "20250" + i : "2025" + i;
  45. Double target = Double.parseDouble(split[i]);
  46. System.out.println("地市: " + city + " 月分: " + month + " 率值: " + target);
  47. int r = targetTsRatioMapper.updateManagementTargetRatio(month, city, target);
  48. if (r == 1) {
  49. System.out.println("更新成功");
  50. } else {
  51. targetTsRatioMapper.insertManagementTargetRatio(month, city, target);
  52. }
  53. }
  54. });
  55. }
  56. @Test
  57. void test4() {
  58. String path = "/data/abc.txt";
  59. List<String> lines = TextUtil.readLines(path, "utf8");
  60. lines.forEach(line -> {
  61. String[] split = line.split("\t");
  62. for (int i = 1; i < split.length; i++) {
  63. String city = split[0];
  64. String month = i < 10 ? "20250" + i : "2025" + i;
  65. Double target = Double.parseDouble(split[i]);
  66. System.out.println("地市: " + city + " 月分: " + month + " 率值: " + target);
  67. targetTsRatioMapper.updateServiceRequestTargetRatio(month, city, target);
  68. }
  69. });
  70. }
  71. }