|
@ -274,13 +274,19 @@ public class DatacollectService implements IDatacollectService {
|
|
|
for(int i=0; i< colList.length();i++)
|
|
|
{
|
|
|
JSONObject col = colList.getJSONObject(i);
|
|
|
strSql+= ","+col.optString("adapterMetadataCode") +" as " + col.optString("stdMetadataCode") ;
|
|
|
String adapterMetadataCode = col.optString("adapterMetadataCode");
|
|
|
if(adapterMetadataCode.length()>0)
|
|
|
{
|
|
|
strSql+= ","+adapterMetadataCode +" as " + col.optString("stdMetadataCode") ;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
strSql += " from " +adapterTableName +" where 1=1 ";
|
|
|
strSql += " from " +adapterTableName;
|
|
|
String strWhere = " where 1=1";
|
|
|
//采集范围
|
|
|
if(condition!=null && condition.length()>0)
|
|
|
{
|
|
|
strSql += getCondition(dbType,condition);
|
|
|
strWhere += getCondition(dbType,condition);
|
|
|
}
|
|
|
//增量采集
|
|
|
String maxKey = "0";
|
|
@ -296,25 +302,38 @@ public class DatacollectService implements IDatacollectService {
|
|
|
keyDate = DateConvert.toDate(keyvalue);
|
|
|
}
|
|
|
//根据数据库类型获取时间sql
|
|
|
strSql += " and "+ key + ">'"+getDateSqlByDBType(dbType,keyDate)+"'";
|
|
|
strSql += " order by "+ key;
|
|
|
strWhere += " and "+ key + ">'"+getDateSqlByDBType(dbType,keyDate)+"'";
|
|
|
strWhere += " order by "+ key;
|
|
|
}
|
|
|
else if(keytype.toUpperCase().equals("VARCHAR")) //字符串类型
|
|
|
{
|
|
|
maxKey = getToNumberSqlByDBType(dbType,key);
|
|
|
if(keyvalue!=null && keyvalue.length()>0) {
|
|
|
strSql += " and "+ maxKey + ">'" + keyvalue + "'";
|
|
|
strWhere += " and "+ maxKey + ">'" + keyvalue + "'";
|
|
|
}
|
|
|
strSql += " order by "+ maxKey;
|
|
|
strWhere += " order by "+ maxKey;
|
|
|
}
|
|
|
else{
|
|
|
if(keyvalue!=null && keyvalue.length()>0) {
|
|
|
strSql += " and "+ key + ">'" + keyvalue + "'";
|
|
|
strWhere += " and "+ key + ">'" + keyvalue + "'";
|
|
|
}
|
|
|
strSql += " order by "+ key;
|
|
|
strWhere += " order by "+ key;
|
|
|
}
|
|
|
}
|
|
|
JSONObject obj = db.load("select count(1) as count,max(" + maxKey + ") as max_num from (" + strSql + ")");
|
|
|
strSql += strWhere;
|
|
|
String sqlCount = "select count(1) as count,max(" + maxKey + ") as max_num from " + adapterTableName + strWhere;
|
|
|
JSONObject obj = db.load(sqlCount);
|
|
|
if(obj==null)
|
|
|
{
|
|
|
if(db.errorMessage.length()>0)
|
|
|
{
|
|
|
return db.errorMessage;
|
|
|
}
|
|
|
else{
|
|
|
return "查询异常:"+sqlCount;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
int count = obj.getInt("COUNT");
|
|
|
if(count==0) //0条记录,无需采集
|
|
|
{
|
|
@ -349,14 +368,6 @@ public class DatacollectService implements IDatacollectService {
|
|
|
detail.setJobDatasetRows(rows);
|
|
|
detail.setSchemeVersion(schemeVersion);
|
|
|
|
|
|
//最大值
|
|
|
if(i==countPage-1)
|
|
|
{
|
|
|
Object max = db.scalar("select max("+getToNumberSqlByDBType(dbType,key)+") from (" + sql + ")");
|
|
|
if(max!=null)
|
|
|
maxKeyvalue = String.valueOf(max);
|
|
|
}
|
|
|
|
|
|
List<JSONObject> list = db.query(sql);
|
|
|
String message = intoMongodb(list,schemeVersion,stdTableName,colList); //错误信息
|
|
|
|