KwpIocApplicationTests.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.pavis.ai.kwp.ioc;
  2. import com.alibaba.fastjson.JSON;
  3. import com.pavis.ai.kwp.ioc.common.utils.DateTimeUtils;
  4. import com.pavis.ai.kwp.ioc.common.utils.ImageUtils;
  5. import com.pavis.ai.kwp.ioc.dto.meta.IrRes;
  6. import com.pavis.ai.kwp.ioc.service.CtrService;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.apache.commons.lang3.StringUtils;
  9. import org.junit.Test;
  10. import org.junit.runner.RunWith;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.boot.test.context.SpringBootTest;
  13. import org.springframework.test.context.junit4.SpringRunner;
  14. @Slf4j
  15. @RunWith(SpringRunner.class)
  16. @SpringBootTest
  17. public class KwpIocApplicationTests {
  18. @Autowired
  19. private CtrService ctrService;
  20. @Test
  21. public void testCtrService() {
  22. try {
  23. IrRes res = ctrService.startRequest("6733699117742653440",
  24. "https://chilun.bj.bcebos.com/ddp1f196028b3b94c1abd50464b057a557d.png");
  25. log.info("res:{}", JSON.toJSONString(res));
  26. } catch (Exception e) {
  27. e.printStackTrace();
  28. }
  29. }
  30. @Test
  31. public void testBase64() throws Exception {
  32. String base64 = ImageUtils.imgUrl2Base64("http://ocrproducts.bj.bcebos.com/161234901701820190608140412201");
  33. log.info("base64:{}", base64);
  34. }
  35. @Test
  36. public void testSubstring() {
  37. String str = "102:小票类型不匹配,当前小票类型为:other";
  38. log.info("str:{}", str);
  39. log.info("str before:{}", StringUtils.substringBefore(str, ":"));
  40. log.info("str after:{}", StringUtils.substringAfter(str, ":"));
  41. }
  42. @Test
  43. public void testNonEtTime() {
  44. log.info(DateTimeUtils.nonEtDatetime("2020-11-20 10:23:34"));
  45. }
  46. }