Search in sources :

Example 6 with Area

use of com.bc.pmpheep.back.po.Area in project pmph by BCSquad.

the class AreaSeviceTest method testGetAreaById.

@Test
public void testGetAreaById() {
    Area area = addArea();
    Area area2 = areaService.getAreaById(area.getId());
    Assert.assertNotNull("是否存在", area2);
    Assert.assertEquals("查询结果是否相等", "测试区域", area2.getAreaName());
}
Also used : Area(com.bc.pmpheep.back.po.Area) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 7 with Area

use of com.bc.pmpheep.back.po.Area in project pmph by BCSquad.

the class DataTransfer method area.

/**
 * authoer:lyc 区域表迁移
 */
public int area() {
    String sql = "SELECT AreaID,ParentCode,AreaName FROM ba_areacode";
    ConnectionManager cm;
    ResultSet rs;
    try {
        cm = new ConnectionManager(url, username, password);
        rs = cm.getResultSet(sql);
    } catch (ClassNotFoundException | SQLException ex) {
        logger.error("JDBC初始化发生错误", ex);
        return 0;
    }
    areaService.deleteAllArea();
    int count = 0;
    try {
        while (rs.next()) {
            Area area = new Area();
            area.setId(new Long(rs.getInt(1)));
            area.setParentId(new Long(rs.getInt(2)));
            area.setAreaName(rs.getString(3));
            areaService.addArea(area);
            count++;
            if (count % 100 == 0) {
                logger.info("已迁移 {} 条数据", count);
            }
        }
        logger.info("总共迁移 {} 条数据", count);
        cm.close();
    } catch (SQLException ex) {
        logger.error("JDBC SQL语句运行时发生错误", ex);
        return count;
    }
    return count;
}
Also used : Area(com.bc.pmpheep.back.po.Area) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet)

Aggregations

Area (com.bc.pmpheep.back.po.Area)7 BaseTest (com.bc.pmpheep.test.BaseTest)5 Test (org.junit.Test)5 WriterPoint (com.bc.pmpheep.back.po.WriterPoint)1 AreaTreeVO (com.bc.pmpheep.back.vo.AreaTreeVO)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1