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());
}
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;
}
Aggregations