You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
727 B
26 lines
727 B
desc "导入职位类别"
|
|
|
|
namespace :job_classify do
|
|
|
|
task import: :environment do
|
|
jobs_xlsx =Roo::Spreadsheet.open(Rails.root.join("excel_template/jobs.xlsx").to_s)
|
|
|
|
job_data = jobs_xlsx.sheet(0)
|
|
last_row = job_data.last_row
|
|
|
|
job = nil
|
|
2.upto(last_row) do |r|
|
|
if job_data.cell(r, 1).present?
|
|
job = JobClassify.new(name: job_data.cell(r, 1), parent_id: 0, position: r)
|
|
job.save
|
|
p "导入职位一级---#{job_data.cell(r, 1)}"
|
|
end
|
|
if job_data.cell(r, 2).present?
|
|
children = JobClassify.new(name: job_data.cell(r, 2), parent_id: job.id, position: r)
|
|
children.save
|
|
p "导入职位二级---#{job_data.cell(r, 2)}"
|
|
end
|
|
end
|
|
end
|
|
end
|