diff --git a/lib/tasks/sync_fgu_personal_data_tasks.rake b/lib/tasks/sync_fgu_personal_data_tasks.rake index 97ed328..b80b607 100644 --- a/lib/tasks/sync_fgu_personal_data_tasks.rake +++ b/lib/tasks/sync_fgu_personal_data_tasks.rake @@ -578,6 +578,162 @@ module FguSyncPlugin puts "*********************************************" end + def self.filter_not_blank(table_name) + key_mapping = { + 'v_rul_research_01' => { + "紀錄編號" => "journal_id", + "結束日" => "publication_date", + "填報系所" => "department", + "合著者1姓名" => "author1", + "合著者2姓名" => "author2", + "合著者3姓名" => "author3", + "合著者4以上" => "author4", + "期刊_學報之論文名稱" => "paper_title", + "期刊_學報名稱" => "journal_title", + "期刊_學報卷數" => "vol_no", + "期刊_學報期數" => "issue_no", + "論文發表型式" => "paper_type", + "國別地區代號" => "country", + "期刊_學報頁碼" => "from_to", + "期刊資料庫" => "paper_level", + "備註" => "note" + }, + 'v_rul_research_02' => { + "紀錄編號" => "conf_id", + "開始日" => "start_date", + "結束日" => "end_date", + "填報系所" => "department", + "合著者1姓名" => "author1", + "合著者2姓名" => "author2", + "合著者3姓名" => "author3", + "合著者4以上" => "author4", + "論文名稱" => "paper_title", + "會議名稱" => "conference_name", + "出版_發表地區" => "location", + "備註" => "note" + }, + 'v_rul_research_03' => { + "紀錄編號" => "book_id", + "結束日" => "date_of_publication", + "填報部門" => "department", + "作者類型" => "author_type", + "專書類別" => "book_type", + "合著者1姓名" => "author1", + "合著者2姓名" => "author2", + "合著者3姓名" => "author3", + "合著者4以上" => "author4", + "專書名稱" => "book_title", + "使用語文" => "language", + "出版社_發表處所名稱" => "publisher", + "專書ISBN編號或無" => "isbn", + "出版_發表地區" => "location", + "備註" => "note" + }, + 'vrul_sch' => { + "f_start" => "start_date", + "f_end" => "end_date", + "f_school" => "school_name", + "f_dep" => "department", + "f_degree" => "degree" + }, + 'vrul_exp' => { + "f_start" => "start_date", + "f_end" => "end_date", + "f_comp" => "organization_title", + "f_empname" => "job_title" + }, + 'vrul_inemp' => { + "f_start" => "start_date", + "f_end" => "end_date", + "f_unit" => "organization_title", + "f_empname" => "job_title", + "f_emptype" => "emp_type" + }, + 'dbo.v_rul_research_credential' => { + "紀錄編號" => "rss2_id", + "核發日期" => "issue_date", + "證照名稱" => "title", + "發照機關" => "issued_by", + "證照類別" => "certificate_type", + "有效期限" => "expiration_date" + }, + 'dbo.v_rul_research_award' => { + "紀錄編號" => "rss2_id", + "獲獎日期" => "award_date", + "獎項名稱" => "award_name", + "國別/地區" => "country", + "名次" => "ranking", + "區域" => "honor_type", + "頒發機構名稱" => "awarding_body", + "頒獎單位名稱"=> "awarding_unit" + }, + 'dbo.v_rul_research_patent' => { + "紀錄編號" => "rss2_id", + "專利名稱" => "patent_title", + "申請國別" => "patent_country", + "生效日期"=> "publication_date", + "有效期限" => "expiration_date", + "專利類型" => "patent_type" + }, + 'dbo.v_rul_research_create' => { + "紀錄編號" => "rss2_id", + "首次發表時間" => "publish_date", + "更新日期" => "updated_at", + "展演舉行起日" => "start_date", + "展演舉行迄日" => "end_date", + "展演活動名稱" => "activity_name", + "展演作品名稱" => "work_title", + "展演主辦單位全銜" => "activity_organizer", + "展演協辦單位全銜" => "activity_co_organizer", + "展演活動辦理國別/地區" => "region", + "是否為巡演" => "road_show", + "巡演明細" => "tour_details", + "獎名" => "award_name", + "頒獎單位" => "awarding_unit", + "作者別" => "authors_type", + "所有作者群" => "authors" + }, + 'dbo.v_rul_research_plan' => { + "紀錄編號" => "rss2_id", + "計畫名稱" => "project_title", + "校外計畫編號" => "project_number", + "計畫起日期" => "period_start_date", + "計畫迄日期" => "period_end_date", + "經費補助單位(補助單位)" => "unit", + "填報者類型(職稱/擔任之工作)" => "jobs", + "所有參與者" => "participants" + }, + 'vrul_base' => { + "f_email" => "email", + "f_phone" => "office_tel", + "f_office" => "address", + "f_name" => "name", + "f_teachwork" => "role", + "f_empname" => "job_title", + "f_emptype" => "job_status" + }, + 'vrul_profession' => { + 'f_profession_list' => 'profession_list' + }, + 'vrul_nowteachcour' => { + "f_ayear" => "year", + "f_asem" => "sem", + "f_cour_id" => "course_id", + "f_cour_name" => "course_name", + "f_cour_url" => "course_url" + } + } + fields = key_mapping[table_name].keys + sql = "SELECT * FROM #{table_name} WHERE " + fields.each_with_index do |f, i| + if i != 0 + sql += " AND " + end + sql += "[#{f}] <> \"\"" + end + result = @client.execute(sql).to_a[-1] + end + def self.get_sql(table_name, filter_params={}, order_fields=nil) key_mapping = { 'v_rul_research_01' => {