yumeng 4 lat temu
rodzic
commit
7412af2c18

+ 11 - 10
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/JsonResourceUtil.java

@@ -3,17 +3,17 @@ package org.jeecg.common.util;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
-import org.jeecg.common.constant.AccountReportConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.io.ClassPathResource;
 
-import java.io.File;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Created by JQ.bi on 2020.06.03
@@ -79,13 +79,14 @@ public class JsonResourceUtil {
         return mapMap;
     }
 
+
     /**
      * 拼接字段
      */
-    public static String joinFiled(Map<String, Map<String,Object>> mapMap,JSONArray array) {
+    public static String joinFiled(Map<String, Map<String, Object>> mapMap, JSONArray array) {
         StringBuilder sb = new StringBuilder();
         array.forEach(it -> {
-            if (mapMap.get(it.toString()).isEmpty()) {
+            if (mapMap.get(it) == null) {
                 sb.append(it).append(",");
             } else {
                 sb.append(mapMap.get(it.toString()).get("filed")).append(",");
@@ -97,11 +98,11 @@ public class JsonResourceUtil {
     /**
      * 拼接title
      */
-    public static List<String> joinTitle(Map<String, Map<String,Object>> mapMap,JSONArray array) {
+    public static List<String> joinTitle(Map<String, Map<String, Object>> mapMap, JSONArray array) {
         List<String> titles = new ArrayList<>(20);
         array.forEach(it -> {
-            if (mapMap.get(it.toString()).isEmpty()) {
-                titles.add(it.toString());
+            if (mapMap.get(it) == null) {
+                titles.add("");
             } else {
                 titles.add(mapMap.get(it.toString()).get("comment").toString());
             }
@@ -112,7 +113,7 @@ public class JsonResourceUtil {
     /**
      * 拼接字段
      */
-    public static String joinAllFiled(Map<String, Map<String,Object>> mapMap) {
+    public static String joinAllFiled(Map<String, Map<String, Object>> mapMap) {
         StringBuilder sb = new StringBuilder();
         mapMap.forEach((k, v) -> sb.append(v.get("filed")).append(","));
         return sb.deleteCharAt(sb.length() - 1).toString();

+ 16 - 6
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCreateCreativeJob.java

@@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 @Component
 public class KuaishouCreateCreativeJob {
@@ -20,6 +22,7 @@ public class KuaishouCreateCreativeJob {
     private IKuaiShouGroupTemplateService groupTemplateService;
     @Autowired
     private ICtopOauthTokenService tokenService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
 
     @XxlJob("kuaihouCreateCreative")
     public void execute() {
@@ -27,17 +30,24 @@ public class KuaishouCreateCreativeJob {
         templateQueryWrapper.eq("task_status", 2);
         templateQueryWrapper.eq("creative_status", 0);
         templateQueryWrapper.orderByAsc("create_time");
-        templateQueryWrapper.last("limit 20");
+        templateQueryWrapper.last("limit 200");
         List<KuaiShouGroupTemplate> list = groupTemplateService.list(templateQueryWrapper);
         if (Check.isNull(list)) {
             return;
         }
         for (KuaiShouGroupTemplate template : list) {
-            CtopOauthToken token = tokenService.getTokenByAccountId(template.getAccountId());
-            if (Check.isNull(token)) {
-                continue;
-            }
-            groupTemplateService.createCreative(token.getAccessToken(), template.getUnitId(), template);
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    CtopOauthToken token = tokenService.getTokenByAccountId(template.getAccountId());
+                    if (Check.isNull(token)) {
+                        return;
+                    }
+                    groupTemplateService.createCreative(token.getAccessToken(), template.getUnitId(), template);
+                }
+            });
+
+
         }
     }
 }

+ 2 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouYiCheReportController.java

@@ -187,9 +187,7 @@ public class KuaiShouYiCheReportController {
             directApplication.add(directApplicationJson.getString("agent"));
             directApplication.add(directApplicationJson.getString("media"));
             directApplication.add(directApplicationJson.getString("systemType"));
-            if (!Check.isNull(directApplicationJson.getString("statDate"))) {
-                directApplication.add(directApplicationJson.getString("statDate").replace("-", "/"));
-            }
+            directApplication.add(directApplicationJson.getString("statDate"));
             directApplication.add(directApplicationJson.getBigDecimal("charge"));
             directApplication.add(directApplicationJson.getBigDecimal("cashCost"));
             directApplication.add(directApplicationJson.getLong("photoShow"));
@@ -222,9 +220,7 @@ public class KuaiShouYiCheReportController {
                 List<Object> channelSubcontracting = new ArrayList();
                 channelSubcontracting.add(channelSubcontractingJson.getString("agent"));
                 channelSubcontracting.add(channelSubcontractingJson.getString("systemType"));
-                if (!Check.isNull(channelSubcontractingJson.getString("statDate"))) {
-                    channelSubcontracting.add(channelSubcontractingJson.getString("statDate").replace("-", "/"));
-                }
+                channelSubcontracting.add(channelSubcontractingJson.getString("statDate"));
                 channelSubcontracting.add(channelSubcontractingJson.getString("campaignName"));
                 channelSubcontracting.add(channelSubcontractingJson.getBigDecimal("charge"));
                 channelSubcontracting.add(channelSubcontractingJson.getBigDecimal("cashCost"));

+ 49 - 19
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouYiCheReportMapper.xml

@@ -15,7 +15,13 @@
 
     <select id="selectReportByMap" parameterType="java.util.Map" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-        t1.system_type systemType,
+        (case when t1.system_type = 'android'
+         then '安卓'
+         when t1.system_type = 'ios'
+         then 'ios'
+         else '-'
+         end
+        ) as systemType,
         t1.auth_name authName,
         ROUND(sum(t2.charge) / #{disCount},3) charge,
         sum(t2.activation) activation,
@@ -64,7 +70,13 @@
 
     <select id="selectSumReportByMap" parameterType="java.util.Map" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-        t1.system_type systemType,
+        (case when t1.system_type = 'android'
+        then '安卓'
+        when t1.system_type = 'ios'
+        then 'ios'
+        else '-'
+        end
+        ) as systemType,
         #{dateDesc} authName,
         ROUND(sum(t2.charge) / #{disCount},3) charge,
         sum(t2.activation) activation,
@@ -121,19 +133,25 @@
         '未知'
         END
         ) media,
-        t1.system_type systemType,
-        t2.stat_date statDate,
+        (case when t1.system_type = 'android'
+        then '安卓'
+        when t1.system_type = 'ios'
+        then 'ios'
+        else '-'
+        end
+        ) as systemType,
+        DATE_FORMAT(t2.stat_date,'%Y/%c/%d')  statDate,
         sum(t2.charge) charge,
         ROUND(sum(t2.charge) / #{disCount}, 3) cashCost,
-        sum(t2.photo_show) photoShow,
-        sum(t2.photo_click) photoClick,
+        sum(t2.aclick + t2.photo_show) photoShow,
+        sum(t2.photo_click + t2.bclick) photoClick,
         (
         CASE
         WHEN sum(t2.photo_show) != 0 THEN
         CONCAT(
         CAST(ROUND(
         (
-        sum(t2.photo_click) / sum(t2.photo_show)
+        sum(t2.photo_click + t2.bclick) / sum(t2.photo_show + t2.aclick)
         ) * 100,
         3
         ) AS CHAR)
@@ -281,19 +299,25 @@
         '未知'
         END
         ) media,
-        t2.system_type systemType,
-        t2.stat_date statDate,
+        (case when t2.system_type = 'android'
+        then '安卓'
+        when t2.system_type = 'ios'
+        then 'ios'
+        else '-'
+        end
+        ) as systemType,
+        DATE_FORMAT(t2.stat_date,'%Y/%c/%d') statDate,
         sum(t2.charge) charge,
         ROUND(sum(t2.charge) / #{disCount}, 3) cashCost,
-        sum(t2.photo_show) photoShow,
-        sum(t2.photo_click) photoClick,
+        sum(t2.aclick + t2.photo_show) photoShow,
+        sum(t2.photo_click + t2.bclick) photoClick,
         (
         CASE
         WHEN sum(t2.photo_show) != 0 THEN
         CONCAT(
         CAST( ROUND(
         (
-        sum(t2.photo_click) / sum(t2.photo_show)
+        sum(t2.photo_click + t2.bclick) / sum(t2.photo_show + t2.aclick)
         ) * 100,
         3
         ) AS CHAR)
@@ -446,7 +470,7 @@
         <if test="projectId != null">
             and t.project_id = #{projectId}
         </if>
-        <if test="systemType != null">
+        <if test="statDate != null">
             and t1.stat_date = #{statDate}
         </if>
         ) t2
@@ -471,20 +495,26 @@
         '未知'
         END
         ) media,
-        t2.system_type systemType,
-        t2.stat_date statDate,
+        (case when t2.system_type = 'android'
+        then '安卓'
+        when t2.system_type = 'ios'
+        then 'ios'
+        else '-'
+        end
+        ) as systemType,
+        DATE_FORMAT(t2.stat_date,'%Y/%c/%d') statDate,
         t2.campaignName campaignName ,
         sum(t2.charge) charge,
         ROUND(sum(t2.charge) / #{disCount}, 3) cashCost,
-        sum(t2.photo_show) photoShow,
-        sum(t2.photo_click) photoClick,
+        sum(t2.aclick + t2.photo_show) photoShow,
+        sum(t2.photo_click + t2.bclick) photoClick,
         (
         CASE
         WHEN sum(t2.photo_show) != 0 THEN
         CONCAT(
         CAST( ROUND(
         (
-        sum(t2.photo_click) / sum(t2.photo_show)
+        sum(t2.photo_click + t2.bclick) / sum(t2.photo_show + t2.aclick)
         ) * 100,
         3
         ) AS CHAR)
@@ -626,7 +656,7 @@
         <if test="projectId != null">
             and t.project_id = #{projectId}
         </if>
-        <if test="systemType != null">
+        <if test="statDate != null">
             and t1.stat_date = #{statDate}
         </if>
         ) t2