cy
2022-06-28 2ba5c891b24d4d0cd6ce7ef833592e4f576ee5e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package cn.ksource.test;
 
import java.util.ArrayList;
import java.util.List;
 
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
 
import cn.ksource.core.dao.BaseDao;
import cn.ksource.core.dao.SqlParameter;
import cn.ksource.core.util.StringUtil;
 
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/applicationContext_core.xml")
public class InPutData {
 
    @Autowired
    private BaseDao baseDao;
    
    @Test
    public void testInput() throws Exception {
        String sql = "insert into REPORT_DATE_CONFIG (ID,YEAR,MONTH,END_TIME) values(:ID,:YEAR,:MONTH,:END_TIME)";
        List<SqlParameter> paramList = new ArrayList<SqlParameter>();
        
        for (int year = 2014; year < 2025; year++) {
            for (int month = 1; month < 13; month++) {
                paramList.add(new SqlParameter("ID",StringUtil.getUUID()).addValue("YEAR", year).addValue("MONTH", month)
                        .addValue("END_TIME", 10));
            }
        }
        
        baseDao.executeBatch(sql, paramList);
    }
}