难读,易改 (java 代码)

            int a = 4;
int b = 7;
int c = 10;
String a_columns="substr(to_char(a.createTime,'yyyy-mm-dd'),1,";
String a_columns1 = ") as statisticsID, count(to_char(a.createTime,'yyyy-mm-dd')) as record,substr(to_char(a.createTime,'yyyy-mm-dd'), 1, 4) as statisticsName ";
String a_ctw = "a.createTimeWeek as statisticsID,count(a.createTimeWeek) as record ";
String a_ctw1 = a_ctw+",to_char(a.createTime,'yyyy-mm-dd')";
String b_ctw = "a.createTimeWeek as statisticsName";
String a_columnsA = a_columns + a + a_columns1;
String a_columnsB = a_columns + b + a_columns1;
String a_columnsC = a_columns + c + a_columns1;
// 录入时间
if("1".equals(statisticsMode)){
// 按照年分组
if("0".equals(statisticsModeType)){
sql.append(a_columnsA);
sql.append(b_columns);
// 按照月分组
}else if("1".equals(statisticsModeType)){
sql.append(a_columnsB);
sql.append(b_columns);
// 按照日分组
}else if("2".equals(statisticsModeType)){
sql.append(a_columnsC);
sql.append(b_columns);
// 按照周分组
}else if("3".equals(statisticsModeType)){
sql.append(a_ctw);
sql.append(b_ctw);
}
// 解决时间
}else if("2".equals(statisticsMode)){
// 按照年分组
if("0".equals(statisticsModeType)){
sql.append(a_columnsA);
sql.append(b_columns);
// 按照月分组
}else if("1".equals(statisticsModeType)){
sql.append(a_columnsB);
sql.append(b_columns);
// 按照日分组
}else if("2".equals(statisticsModeType)){
sql.append(a_columnsC);
sql.append(b_columns);
// 按照周分组
}else if("3".equals(statisticsModeType)){
sql.append(a_ctw1);
sql.append(b_ctw);
}

你可能感兴趣的:(java)