|
|
|
@ -35,6 +35,15 @@ class ManagementsController < ApplicationController
|
|
|
|
|
@agents_pages = Paginator.new @agents_count, limit, params['page'] || 1
|
|
|
|
|
@offset ||= @agents_pages.offset
|
|
|
|
|
@user_agents = paginateHelper @user_agents, limit
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html
|
|
|
|
|
format.xls{
|
|
|
|
|
time = Time.now.strftime("%Y%m%d")
|
|
|
|
|
filename = "实训课程体系#{time}.xls"
|
|
|
|
|
send_data(user_agents_export(), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 实训课程等级体系
|
|
|
|
@ -4369,6 +4378,38 @@ end
|
|
|
|
|
return sheet.rows
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def user_agents_export
|
|
|
|
|
xls_report = StringIO.new
|
|
|
|
|
book = Spreadsheet::Workbook.new
|
|
|
|
|
sheet1 = book.create_worksheet :name => "引流名单"
|
|
|
|
|
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
|
|
|
|
sheet1.row(0).default_format = blue
|
|
|
|
|
count_row = 1
|
|
|
|
|
sheet1.row(0).concat(["序号", "LoginId", "姓名", "学校名称", "手机号", "邮箱", "参赛人数", "参赛队伍", "访问量"])
|
|
|
|
|
user_agents = UserAgent.where("user_agents.key is not null").pluck(:key).uniq
|
|
|
|
|
user_agents.each_with_index do |agent, index|
|
|
|
|
|
user = User.find_by_login(agent)
|
|
|
|
|
# 代理用户
|
|
|
|
|
agents = UserAgent.where(key: agent)
|
|
|
|
|
agents_count = agents.count
|
|
|
|
|
competion_users = agents.where(agent_type: UserAgent::USER_COMPETITION).pluck(:ip)
|
|
|
|
|
rank_user_id = UserActions.where(ip: competion_users).pluck(:user_id).uniq
|
|
|
|
|
team_ids = TeamMember.where(user_id: rank_user_id).pluck(:competition_team_id).uniq
|
|
|
|
|
sheet1[count_row, 0] = index + 1
|
|
|
|
|
sheet1[count_row, 1] = agent
|
|
|
|
|
sheet1[count_row, 2] = user.show_real_name
|
|
|
|
|
sheet1[count_row, 3] = user.school_name
|
|
|
|
|
sheet1[count_row, 4] = user.phone
|
|
|
|
|
sheet1[count_row, 5] = user.mail
|
|
|
|
|
sheet1[count_row, 6] = competion_users.count
|
|
|
|
|
sheet1[count_row, 7] = team_ids.count
|
|
|
|
|
sheet1[count_row, 8] = agents_count
|
|
|
|
|
count_row += 1
|
|
|
|
|
end
|
|
|
|
|
book.write xls_report
|
|
|
|
|
xls_report.string
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def export_subject_level_system
|
|
|
|
|
xls_report = StringIO.new
|
|
|
|
|
book = Spreadsheet::Workbook.new
|
|
|
|
|