Ver Fonte

清洗数据

lqc há 5 anos atrás
pai
commit
cc9b565ffe
2 ficheiros alterados com 46 adições e 6 exclusões
  1. 5 6
      pom.xml
  2. 41 0
      src/test/java/com/mokamrp/WebTest.java

+ 5 - 6
pom.xml

@@ -88,12 +88,6 @@
             <version>1.18.8</version>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.11</version>
-            <scope>test</scope>
-        </dependency>
         <!-- xxl-sso-core -->
         <dependency>
             <groupId>com.xuxueli</groupId>
@@ -176,6 +170,11 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-pool2</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <profiles>
         <!--        <profile>-->

+ 41 - 0
src/test/java/com/mokamrp/WebTest.java

@@ -0,0 +1,41 @@
+package com.mokamrp;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.mokamrp.privates.PrivateServerStart;
+import com.mokamrp.privates.mapper.pojo.Corp;
+import com.mokamrp.privates.service.CorpService;
+import com.mokamrp.privates.service.pangu.FosterwxMobileService;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@Slf4j
+@SpringBootTest(classes = PrivateServerStart.class)
+@RunWith(SpringRunner.class)
+public class WebTest {
+    @Autowired
+    private FosterwxMobileService fosterwxMobileService;
+
+    @Autowired
+    private CorpService corpService;
+
+    @Test
+    public void test1() {
+        // 清洗数据
+        fosterwxMobileService.list().forEach(fosterwxMobile -> {
+            if (corpService.count(new LambdaQueryWrapper<Corp>().eq(Corp::getName, fosterwxMobile.getWorkWxCorp())) > 1) {
+                log.warn("{}名字有两个主体", fosterwxMobile.getWorkWxCorp());
+            }
+            Corp corp = corpService.getOne(new LambdaQueryWrapper<Corp>().eq(Corp::getName, fosterwxMobile.getWorkWxCorp()).last("Limit 1"));
+            if (null != corp) {
+                fosterwxMobile.setWorkWxCorpId(corp.getId());
+                fosterwxMobile.setWxAppid(corp.getWxCorpid());
+                fosterwxMobileService.updateById(fosterwxMobile);
+            }
+        });
+    }
+}