这是原代码,从数据库提取24个月(一次只能提取24个月的)的数据,现在需要提取(2010年-2020年)10年的数据,要怎么用循环实现呢,求大佬指教。
public static void main(String[] args) {
/* 1. 定义client对象 */
DataQueryClient client = new DataQueryClient() ;
/* 2. 调用方法的参数定义,并赋值 */
/* 2.1 用户名&密码 */
String userId = "XXX" ;
String pwd = "XXX";
/* 2.2 接口ID */
String interfaceId = "XXX" ;
/* 2.3 接口参数,多个参数间无顺序 */
HashMap<String, String> params = new HashMap<String, String>();
//必选参数
params.put("dataCode", "XXX"); //资料代码,中国地面
params.put("timeRange", "(20190101000000,20201231000000]"); //统计时间段,时间范围,前开后闭
//可选参数
params.put("adminCodes", "530000");
params.put("elements", "Station_ID_C,Station_Name,City,Cnty,Town,Lat,Lon,Alti,Year,Mon,Day,PRE_Time_2020"); //统计分组要素:站号,站名
params.put("staLevels", "011,012,013") ;
params.put("orderBy", "Station_ID_C:desc,Mon:asc,Day:asc");
params.put("limitCnt", "100000000") ; //返回最多记录数:
String dataFormat="html";
String savePath="F:/temp/test.html";
RetFilesInfo retFilesInfo = new RetFilesInfo() ;
for(long timeRange=20200101000000L;timeRange<20210101010000L;timeRange=timeRange+20000000000L){
try {
//初始化接口服务连接资源
client.initResources() ;
//调用接口
int rst = client.callAPI_to_saveAsFile(userId, pwd, interfaceId, params,dataFormat,savePath ,retFilesInfo) ;
//输出结果
if(rst == 0) { //正常返回
ClibUtil clibUtil = new ClibUtil() ;
clibUtil.outputRst( retFilesInfo ) ;
} else { //异常返回
System.out.println( "[error] StaElemStatAPI_CLIB_callAPI_to_array2D." ) ;
System.out.printf( "\treturn code: %d. \n", rst ) ;
System.out.printf( "\terror message: %s.\n", retFilesInfo.request.errorMessage ) ;
}
} catch (Exception e) {
//异常输出
e.printStackTrace() ;
} finally {
//释放接口服务连接资源
client.destroyResources() ;
}
}
}
}
/* 3. 调用接口 */