Explorar o código

广告账号BUG

cola %!s(int64=2) %!d(string=hai) anos
pai
achega
df7fa709e0

+ 5 - 5
src/main/java/com/qucheng/game/data/oldsystem/ods/AdAccountCDC.java

@@ -67,7 +67,7 @@ public class AdAccountCDC {
         props.load(AdAccountCDC.class.getResourceAsStream(Env.isTest ? "/application.test.properties" : "/application.properties"));
 
         // 设置默认并行度
-        env.setParallelism(1);
+        env.setParallelism(16);
 
         // 任务失败后的重启策略
         // env.setRestartStrategy(RestartStrategies.noRestart());// 失败不重启
@@ -103,9 +103,9 @@ public class AdAccountCDC {
                 .password(props.getProperty("cdc.mysql.zx.password"))
                 .databaseList("zx-advertising-oceanengine", "zx-advertising-tencent")
                 .tableList((StringUtils.join(new String[]{
-                        "zx-advertising-oceanengine.t_clue_wechat_game",
-                        "zx-advertising-oceanengine.t_ad_account",
-                        "zx-advertising-tencent.t_ad_account",
+//                        "zx-advertising-oceanengine.t_clue_wechat_game",
+//                        "zx-advertising-oceanengine.t_ad_account",
+//                        "zx-advertising-tencent.t_ad_account",
                         "zx-advertising-tencent.t_adcreative",
                 }, ",")))
                 .deserializer(new MapDebeziumDeserializationSchema())
@@ -433,7 +433,7 @@ public class AdAccountCDC {
                 }
                 Map<String, Object> result = new HashMap<>();
                 result.put("account_id", accountId);
-                result.put("type", "BYTE");
+                result.put("type", "MP");
                 result.put("create_time", createTime);
                 result.put("update_time", createTime);
                 result.put("start_date", createTime.toLocalDate());

+ 26 - 31
src/main/java/com/qucheng/game/data/oldsystem/ods/PitcherAgentCDC.java

@@ -66,7 +66,7 @@ public class PitcherAgentCDC {
         props.load(PitcherAgentCDC.class.getResourceAsStream(Env.isTest ? "/application.test.properties" : "/application.properties"));
 
         // 设置默认并行度
-        env.setParallelism(1);
+        env.setParallelism(16);
 
         // 任务失败后的重启策略
         // env.setRestartStrategy(RestartStrategies.noRestart());// 失败不重启
@@ -176,16 +176,13 @@ public class PitcherAgentCDC {
 
         private void pitcherAgentToMpConfigAgent(Envelope.Operation operation, Map<String, Object> data, Collector<Tuple3<String, String, TransportMap>> out) {
             Long accountId = ObjectUtil.objToLong(data.get("account_id"));
-            String sourceSystem = ObjectUtil.objToString(data.get("sourceSystem"));
-            if (sourceSystem.contains("ZX")) {
-                return;
-            }
-            if (accountId == null) {
-                return;
-            }
+            String sourceSystem = ObjectUtil.objToString(data.get("source_system"));
             String accountType = ObjectUtil.objToString(data.get("account_type"));
             Long pitcherId = ObjectUtil.objToLong(data.get("pitcher_id"));
             Long gameId = ObjectUtil.objToLong(data.get("game_id"));
+            if (sourceSystem.contains("ZX") || accountId == null || gameId == null) {
+                return;
+            }
 
             Map<String, Object> result = new HashMap<>(16);
             result.put("advertiser_conf_id", accountId);
@@ -204,20 +201,19 @@ public class PitcherAgentCDC {
                     queryParam.put("source_system", sourceSystem);
                     queryParam.put("zx_pitcher_id", pitcherId);
                     Map<String, Object> putUserMap = mapper.queryOne("t_pitcher_map", queryParam);
+                    queryParam.clear();
                     if (putUserMap != null) {
                         result.put("bugu_put_user_id", putUserMap.get("bugu_pitcher_id"));
                         result.put("bugu_put_user_name", putUserMap.get("bugu_pitcher_name"));
                         result.put("sys_put_user_name", putUserMap.get("zx_pitcher_name"));
                     }
                 }
-                if (gameId != null) {
-                    queryParam.put("source_system", sourceSystem);
-                    queryParam.put("id", gameId);
-                    queryParam.clear();
-                    Map<String, Object> gameInfo = mapper.queryOne("t_game", queryParam);
-                    if (gameInfo != null) {
-                        result.put("app_name", gameInfo.get("game_name"));
-                    }
+                queryParam.put("source_system", sourceSystem);
+                queryParam.put("id", gameId);
+                Map<String, Object> gameInfo = mapper.queryOne("t_game", queryParam);
+                queryParam.clear();
+                if (gameInfo != null) {
+                    result.put("app_name", gameInfo.get("game_name"));
                 }
             }
 
@@ -231,16 +227,13 @@ public class PitcherAgentCDC {
 
         private void pitcherAgentToAdAccount(Envelope.Operation operation, Map<String, Object> data, Collector<Tuple3<String, String, TransportMap>> out) {
             Long accountId = ObjectUtil.objToLong(data.get("account_id"));
-            String sourceSystem = ObjectUtil.objToString(data.get("sourceSystem"));
-            if (sourceSystem.contains("ZX")) {
-                return;
-            }
-            if (accountId == null) {
-                return;
-            }
+            String sourceSystem = ObjectUtil.objToString(data.get("source_system"));
             String accountType = ObjectUtil.objToString(data.get("account_type"));
             Long pitcherId = ObjectUtil.objToLong(data.get("pitcher_id"));
             Long gameId = ObjectUtil.objToLong(data.get("game_id"));
+            if (sourceSystem.contains("ZX") || accountId == null || gameId == null) {
+                return;
+            }
 
             Map<String, Object> result = new HashMap<>();
             result.put("account_id", accountId);
@@ -253,25 +246,27 @@ public class PitcherAgentCDC {
             try (SqlSession session = odsSqlSessionFactory.openSession(true)) {
                 BaseMapper mapper = session.getMapper(BaseMapper.class);
 
-                Map<String, Object> queryParams = new HashMap<>(6);
+                Map<String, Object> queryParam = new HashMap<>(6);
                 if (pitcherId != null) {
-                    queryParams.put("source_system", sourceSystem);
-                    queryParams.put("zx_pitcher_id", pitcherId);
-                    Map<String, Object> putUserMap = mapper.queryOne("t_pitcher_map", queryParams);
+                    queryParam.put("source_system", sourceSystem);
+                    queryParam.put("zx_pitcher_id", pitcherId);
+                    Map<String, Object> putUserMap = mapper.queryOne("t_pitcher_map", queryParam);
+                    queryParam.clear();
                     if (putUserMap != null) {
                         result.put("sys_put_user_name", putUserMap.get("zx_pitcher_name"));
                     }
                 }
                 if (gameId != null) {
-                    queryParams.put("source_system", sourceSystem);
-                    queryParams.put("id", gameId);
-                    queryParams.clear();
-                    Map<String, Object> gameInfo = mapper.queryOne("t_game", queryParams);
+                    queryParam.put("source_system", sourceSystem);
+                    queryParam.put("id", gameId);
+                    Map<String, Object> gameInfo = mapper.queryOne("t_game", queryParam);
+                    queryParam.clear();
                     if (gameInfo != null) {
                         result.put("app_name", gameInfo.get("game_name"));
                     }
                 }
             }
+
             out.collect(new Tuple3<>("ad_account", sourceSystem, TransportMap.builder()
                     .tableName("ad_account")
                     .primaryKeys(Collections.singletonList("account_id"))

+ 11 - 5
src/main/java/com/qucheng/game/data/oldsystem/util/ObjectUtil.java

@@ -50,6 +50,7 @@ public class ObjectUtil {
                 if ("false".equalsIgnoreCase((String) value)) {
                     return false;
                 }
+                return null;
             }
         } catch (Exception e) {
             log.error(e.getMessage(), e);
@@ -106,7 +107,8 @@ public class ObjectUtil {
                 return (Double) value;
             }
             if (value instanceof String) {
-                return Double.parseDouble((String) value);
+                String tmp = (String)value;
+                return StringUtils.isBlank(tmp) ? null : Double.parseDouble(tmp);
             }
             if (value instanceof Long) {
                 return Double.valueOf((Long) value);
@@ -145,7 +147,8 @@ public class ObjectUtil {
                 return ((Double) value).intValue();
             }
             if (value instanceof String) {
-                return Integer.parseInt((String) value);
+                String tmp = (String)value;
+                return StringUtils.isBlank(tmp) ? null : Integer.parseInt(tmp);
             }
             if (value instanceof Long) {
                 return ((Long) value).intValue();
@@ -185,7 +188,8 @@ public class ObjectUtil {
                 return ((Double) value).longValue();
             }
             if (value instanceof String) {
-                return Long.parseLong((String) value);
+                String tmp = (String)value;
+                return StringUtils.isBlank(tmp) ? null : Long.parseLong(tmp);
             }
             if (value instanceof Long) {
                 return (Long) value;
@@ -221,7 +225,8 @@ public class ObjectUtil {
                 return ((Double) value).floatValue();
             }
             if (value instanceof String) {
-                return Float.parseFloat((String) value);
+                String tmp = (String)value;
+                return StringUtils.isBlank(tmp) ? null : Float.parseFloat(tmp);
             }
             if (value instanceof Long) {
                 return ((Long) value).floatValue();
@@ -254,7 +259,8 @@ public class ObjectUtil {
                 return BigDecimal.valueOf((Double) value);
             }
             if (value instanceof String) {
-                return new BigDecimal((String) value);
+                String tmp = (String)value;
+                return StringUtils.isBlank(tmp) ? null : new BigDecimal(tmp);
             }
             if (value instanceof Long) {
                 return BigDecimal.valueOf((Long) value);