瀏覽代碼

长文增加表现-review1

luojunhui 2 天之前
父節點
當前提交
f41fefb586

+ 7 - 6
core/src/main/java/com/tzld/videoVector/job/ArticleQualitySyncJob.java

@@ -53,12 +53,14 @@ public class ArticleQualitySyncJob {
             return ReturnT.FAIL;
         }
 
+        String safeOdpsDt = odpsDt.replace("'", "''");
+
         String dt = LocalDate.now().format(DT_FMT);
         log.info("权重: r={} o={} f={}, 置信度阈值: {}, ODPS分区dt={}, 写入dt={}",
-                wRead, wOpen, wFission, confidenceThreshold, odpsDt, dt);
+                wRead, wOpen, wFission, confidenceThreshold, safeOdpsDt, dt);
 
         // 确认分区有数据
-        String probeSql = "SELECT COUNT(*) AS cnt FROM loghubods.article_title_his_cache WHERE dt = '" + odpsDt + "' AND type = '9'";
+        String probeSql = "SELECT COUNT(*) AS cnt FROM loghubods.article_title_his_cache WHERE dt = '" + safeOdpsDt + "' AND type = '9'";
         log.info("探针 SQL: {}", probeSql);
         try {
             long[] rowCount = {0};
@@ -85,13 +87,13 @@ public class ArticleQualitySyncJob {
         String sql = maxRows > 0
                 ? "SELECT source_id, his_publish_article_list "
                     + "FROM loghubods.article_title_his_cache "
-                    + "WHERE dt = '" + odpsDt + "' "
+                    + "WHERE dt = '" + safeOdpsDt + "' "
                     + "AND type = '9' "
                     + "AND his_publish_article_list IS NOT NULL "
                     + "LIMIT " + maxRows
                 : "SELECT source_id, his_publish_article_list "
                     + "FROM loghubods.article_title_his_cache "
-                    + "WHERE dt = '" + odpsDt + "' "
+                    + "WHERE dt = '" + safeOdpsDt + "' "
                     + "AND type = '9' "
                     + "AND his_publish_article_list IS NOT NULL";
 
@@ -323,7 +325,6 @@ public class ArticleQualitySyncJob {
     }
 
     private static double round2(Double v) {
-        if (v == null) return 0;
-        return Math.round(v * 100.0) / 100.0;
+        return ArticleQualityCalculator.round2(v);
     }
 }

+ 2 - 1
core/src/main/java/com/tzld/videoVector/util/ArticleQualityCalculator.java

@@ -113,7 +113,8 @@ public class ArticleQualityCalculator {
     private static double nullToZero(Long v) { return v == null ? 0 : (double) v; }
     private static double nullToZero(Double v) { return v == null ? 0 : v; }
 
-    private static double round2(double v) {
+    public static double round2(Double v) {
+        if (v == null) return 0;
         return Math.round(v * 100.0) / 100.0;
     }