From 856d69ce678173e0a8e165bcb0135037d20b48ee Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 15 十月 2024 11:51:22 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java
index 7e20f14..c20dadd 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java
@@ -97,11 +97,13 @@
         if (StringUtils.isNotBlank(indItem.getDimension())){
             selectSql.append(indItem.getDimension());
             selectSql.append(", ");
+            selectSql.append(result.getSelectSql());
+        }else{
+            selectSql.append(result.getSelectSql());
+            selectSql.append(", ");
+            selectSql.append(indItem.getTimeLabel());
+            selectSql.append(" data_time");
         }
-        selectSql.append(result.getSelectSql());
-        selectSql.append(", ");
-        selectSql.append(indItem.getTimeLabel());
-        selectSql.append(" data_time");
         result.setSelectSql(selectSql.toString());
 
         // 拼接WHERE
@@ -153,7 +155,9 @@
                 whereSql.append(indItem.getTimeLabel());
                 whereSql.append(" <= '");
                 whereSql.append(DateUtils.format(calendar.getTime(), PATTERN_MON));
-                whereSql.append("' AND >= '");
+                whereSql.append("' AND '");
+                whereSql.append(indItem.getTimeLabel());
+                whereSql.append("' >= '");
                 calendar.add(Calendar.MONTH, -12);
                 whereSql.append(DateUtils.format(calendar.getTime(), PATTERN_MON));
                 whereSql.append("'");
@@ -197,14 +201,17 @@
 
         // 拼接GROUP
         StringBuilder groupSql = new StringBuilder();
-        groupSql.append(" GROUP BY ");
-        groupSql.append(indItem.getDimension());
+        if (StringUtils.isNotBlank(indItem.getDimension())){
+            groupSql.append(indItem.getDimension());
+        }
         result.setGroupSql(groupSql.toString());
 
         // 拼接ORDER
         StringBuilder orderBySql = new StringBuilder();
-        orderBySql.append(indItem.getTimeLabel());
-        result.setOrderBySql(orderBySql.toString());
+        if (StringUtils.isNotBlank(indItem.getDimension()) && indItem.getDimension().equals(indItem.getTimeLabel())){
+            orderBySql.append(indItem.getTimeLabel());
+            result.setOrderBySql(orderBySql.toString());
+        }
         return result;
     }
 

--
Gitblit v1.9.3