diff --git a/project_manager/src/main/java/com/ossean/projectmanager/lasttabledao/RelativeMemoToOpenSourceProjectDao.java b/project_manager/src/main/java/com/ossean/projectmanager/lasttabledao/RelativeMemoToOpenSourceProjectDao.java index 247e285c0..d1a610064 100644 --- a/project_manager/src/main/java/com/ossean/projectmanager/lasttabledao/RelativeMemoToOpenSourceProjectDao.java +++ b/project_manager/src/main/java/com/ossean/projectmanager/lasttabledao/RelativeMemoToOpenSourceProjectDao.java @@ -17,13 +17,8 @@ public interface RelativeMemoToOpenSourceProjectDao { @Param("osp_id") int osp_id, @Param("targetTableName") String targetTableName); - // 读取项目id对应的所有关联的帖子 - @Select("select * from relative_memo_to_open_source_projects_new where osp_id=#{osp_id}") - public List getRelativeMemosByspId( - @Param("osp_id") int osp_id); - // 批量读取匹配结果 - @Select("select * from ${targetTableName} where has_synchronized = 0 limit ${batch} ") + @Select("select * from ${targetTableName} where has_synchronized = 0 limit #{batch} ") public List getMatchResultsByHassync(@Param("targetTableName") String targetTableName, @Param("batch") int batch); @@ -34,9 +29,9 @@ public interface RelativeMemoToOpenSourceProjectDao { @Param("ospId") int ospId); //同步匹配结果表冗余 - @Update("update ${targetTableName} set (replies_num, view_num_crawled, memo_type, has_synchronized, created_time) " - + "values (#{rmtosp.replies_num}, #{rmtosp.view_num_crawled}, #{rmtosp.memo_type}, 1, #{rmtosp.created_time} where id = #{rmtosp.id})") - public void syncMatchResult(RelativeMemoToOpenSourceProject rmtosp); + @Update("update ${targetTableName} set replies_num = #{rmtosp.replies_num}, view_num_crawled = #{rmtosp.view_num_crawled}, " + + "memo_type = #{rmtosp.memo_type}, has_synchronized = 1, created_time = #{rmtosp.created_time} where id = #{rmtosp.id}") + public void syncMatchResult(@Param("targetTableName") String targetTableName, @Param("rmtosp") RelativeMemoToOpenSourceProject rmtosp); // 读取项目id对应的匹配权重较大的所有关联的帖子 @Select("select count(*) from ${targetTableName} where has_synchronized = 0") diff --git a/project_manager/src/main/java/com/ossean/projectmanager/model/RelativeMemo.java b/project_manager/src/main/java/com/ossean/projectmanager/model/RelativeMemo.java index c86eb3be8..d20259b28 100644 --- a/project_manager/src/main/java/com/ossean/projectmanager/model/RelativeMemo.java +++ b/project_manager/src/main/java/com/ossean/projectmanager/model/RelativeMemo.java @@ -13,7 +13,7 @@ public class RelativeMemo { private String created_time; private String updated_time; private String url; - private int view_num_crawled; + private int view_num; private int vote_up_num; private int collection_num; private String abstractText; @@ -97,11 +97,11 @@ public class RelativeMemo { public void setUrl(String url) { this.url = url; } - public int getView_num_crawled() { - return view_num_crawled; + public int getView_num() { + return view_num; } - public void setView_num_crawled(int view_num_crawled) { - this.view_num_crawled = view_num_crawled; + public void setView_num(int view_num) { + this.view_num = view_num; } public int getVote_up_num() { return vote_up_num; diff --git a/project_manager/src/main/java/com/ossean/projectmanager/syncmatchresult/SyncMatchResult.java b/project_manager/src/main/java/com/ossean/projectmanager/syncmatchresult/SyncMatchResult.java index ce82991bc..aec91c2fd 100644 --- a/project_manager/src/main/java/com/ossean/projectmanager/syncmatchresult/SyncMatchResult.java +++ b/project_manager/src/main/java/com/ossean/projectmanager/syncmatchresult/SyncMatchResult.java @@ -29,8 +29,17 @@ public class SyncMatchResult { */ public void syncMatchResult() { while (true) { + int notSyncNum = matchResultDao.getNotSyncCount("relative_memo_to_open_source_projects_1"); + if (notSyncNum < 1) { + try { + logger.info("sleeping 10s......"); + Thread.sleep(10000); + } catch (InterruptedException e) { + logger.error(e); + } + } logger.info("starting syncMatchResult......"); - for (int i = 1; i < 70; i++) { + for (int i = 1; i <= 70; i++) { String matchResultTableName = "relative_memo_to_open_source_projects_" + String.valueOf(i); logger.info("starting sync " + matchResultTableName + "......"); List rmtospList = matchResultDao.getMatchResultsByHassync(matchResultTableName, 50000); @@ -41,8 +50,8 @@ public class SyncMatchResult { rmtosp.setCreated_time(curMemo.getCreated_time()); rmtosp.setMemo_type(curMemo.getMemo_type()); rmtosp.setReplies_num(curMemo.getReplies_num()); - rmtosp.setView_num_crawled(curMemo.getView_num_crawled()); - matchResultDao.syncMatchResult(rmtosp); + rmtosp.setView_num_crawled(curMemo.getView_num()); + matchResultDao.syncMatchResult(matchResultTableName, rmtosp); } } } diff --git a/project_manager/src/main/resource/applicationContext-myBatis.xml b/project_manager/src/main/resource/applicationContext-myBatis.xml index d75abb8e7..992a3e477 100644 --- a/project_manager/src/main/resource/applicationContext-myBatis.xml +++ b/project_manager/src/main/resource/applicationContext-myBatis.xml @@ -39,9 +39,9 @@ destroy-method="close"> + value="jdbc:mysql://localhost:3306/ossean_new?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true" /> - +