package com.sckw.report;

import com.sckw.mongo.model.SckwTradeOrder;
import com.sckw.report.dao.SckwTradeOrderRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zk
 * @desc 贸易订单测试
 * @date 2023/7/8 0008
 */
@SpringBootTest
public class SckwTradeOrderTest {
    @Autowired
    SckwTradeOrderRepository tradeOrderRepository;

    /**
     * 插入单条数据
     */
    @Test
    public void insertOne() {
        SckwTradeOrder order = new SckwTradeOrder();
        order.setTOrderId(System.currentTimeMillis());
        order.setTOrderNo("O" + order.getTOrderId());
        tradeOrderRepository.insert(order);
    }

    /**
     * 插入多条数据
     */
    @Test
    public void insertMany() {
        List<SckwTradeOrder> list = new ArrayList<SckwTradeOrder>();
        Long begtime = System.currentTimeMillis();
        for (int i=0; i<10000; i++) {
            SckwTradeOrder order = new SckwTradeOrder();
            order.setTOrderId(System.currentTimeMillis() + i);
            order.setTOrderNo("O" + order.getTOrderId());
            list.add(order);
        }
        tradeOrderRepository.insert(list);
        Long enttime = System.currentTimeMillis();
        System.out.println("------------------"+(enttime - begtime));
    }


}
