|
@@ -23,9 +23,11 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|