瀏覽代碼

补全数据处理,排序

zhaoxian 4 年之前
父節點
當前提交
45957102c0

+ 2 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouAudienceAccountDailyMapper.xml

@@ -120,10 +120,7 @@
                 IFNULL(ROUND(charge/ event_next_day_stay,2),0) as 'value',
             </if>
         </if>
-        CASE
-        WHEN ad_scene is null then '全部'
-        WHEN ad_scene = '' THEN '全部'
-        ELSE ad_scene END as 'type'
+        IFNULL(ad_scene,'全部') as 'type'
         FROM ctop_kuaishou_report_daily_account
         where stat_date = #{day}
         AND account_id = #{accountId}
@@ -166,10 +163,7 @@
                 IFNULL(ROUND(SUM(charge)/SUM(event_next_day_stay),2),0) as 'value',
             </if>
         </if>
-        CASE
-        WHEN ad_scene is null then '全部'
-        WHEN ad_scene = '' THEN '全部'
-        ELSE ad_scene END as 'type'
+        IFNULL(ad_scene,'全部')as 'type'
         FROM ctop_kuaishou_report_daily_account
         where stat_date &gt;= DATE_FORMAT(date_sub(now(), interval 8 day), '%Y-%m-%d')
         AND stat_date &lt;= DATE_FORMAT(date_sub(now(), interval 2 day), '%Y-%m-%d')

+ 24 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouAudienceAccountDailyServiceImpl.java

@@ -14,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
 
@@ -157,7 +159,12 @@ public class EtlKuaishouAudienceAccountDailyServiceImpl extends ServiceImpl<EtlK
     private void completeData(List<JSONObject> list, List<String> typeList) {
         List<String> newDayList = new ArrayList<>();
         for (JSONObject data : list) {
-            newDayList.add(data.getString("type"));
+            if (!newDayList.contains(data.getString("type"))) {
+                newDayList.add(data.getString("type"));
+            }
+        }
+        if (!newDayList.contains("全部")) {
+            typeList.remove("全部");
         }
         for (String type : typeList) {
             if (!newDayList.contains(type)) {
@@ -167,6 +174,22 @@ public class EtlKuaishouAudienceAccountDailyServiceImpl extends ServiceImpl<EtlK
                 list.add(obj);
             }
         }
+        userRechargeListSort(list);
     }
 
+    private static void userRechargeListSort(List<JSONObject> list) {
+        Collections.sort(list, new Comparator<JSONObject>() {
+            @Override
+            public int compare(JSONObject o1, JSONObject o2) {
+                try {
+                    String st1 = o1.getString("type");
+                    String st2 = o2.getString("type");
+                    return st1.compareTo(st2);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                return 0;
+            }
+        });
+    }
 }