wangmiaomiao 11 月之前
父节点
当前提交
16cac2d8da
共有 3 个文件被更改,包括 27 次插入8 次删除
  1. 0 7
      slibra-admin/pom.xml
  2. 25 0
      slibra-admin/src/test/java/com/slibra/MyTest.java
  3. 2 1
      slibra-quartz/pom.xml

+ 0 - 7
slibra-admin/pom.xml

@@ -88,13 +88,6 @@
             <version>0.7.5</version>
             <version>0.7.5</version>
         </dependency>
         </dependency>
 
 
-        <!-- SQL Server Driver -->
-        <dependency>
-            <groupId>com.microsoft.sqlserver</groupId>
-            <artifactId>mssql-jdbc</artifactId>
-            <scope>runtime</scope>
-        </dependency>
-
 
 
 
 
 
 

+ 25 - 0
slibra-admin/src/test/java/com/slibra/MyTest.java

@@ -23,9 +23,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.util.CollectionUtils;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -134,4 +136,27 @@ public class MyTest {
     }
     }
 
 
 
 
+    @Test
+    public void testSqlserverGet(){
+        log.info("进入了定时同步SqlServer的任务");
+        //主库获取上次最新的同步日期
+        String lastTime = this.xinyiRobotMapper.selectLastTime();
+        log.info("上次同步的日期是{}", lastTime);
+        //从
+        DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
+        List<TXinyiRobot> tXinyiRobots = xinyiRobotMapper.selectTXinyiRobotListByTime(lastTime);
+        DynamicDataSourceContextHolder.clearDataSourceType();
+//        System.out.println(JSON.toJSONString(tXinyiRobots));
+//        System.out.println("-------------");
+        //主
+        if(!CollectionUtils.isEmpty(tXinyiRobots)){
+            for (TXinyiRobot tXinyiRobot : tXinyiRobots) {
+                tXinyiRobot.setvDateTime(tXinyiRobot.getvDate() + tXinyiRobot.getvTime());
+                tXinyiRobot.setCreatedTime(new Date());
+                this.xinyiRobotMapper.insertTXinyiRobot(tXinyiRobot);
+            }
+        }
+    }
+
+
 }
 }

+ 2 - 1
slibra-quartz/pom.xml

@@ -43,7 +43,8 @@
         <dependency>
         <dependency>
             <groupId>com.microsoft.sqlserver</groupId>
             <groupId>com.microsoft.sqlserver</groupId>
             <artifactId>mssql-jdbc</artifactId>
             <artifactId>mssql-jdbc</artifactId>
-            <scope>runtime</scope>
+            <!--<scope>runtime</scope>-->
+            <version>8.1.0.jre8-preview</version>
         </dependency>
         </dependency>
         <dependency>
         <dependency>
             <groupId>com.slibra</groupId>
             <groupId>com.slibra</groupId>