Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
innov | 9561b7b18f | |
innov | 3fdc1a59b4 |
|
@ -1,40 +0,0 @@
|
|||
require 'csv'
|
||||
require 'nkf'
|
||||
|
||||
csv_title = ["id", "用户名称", "用户电话","最后登录时间", "用户部门", "所属高校","课程数量", "高校省份", "高校城市", "高校地址", "实训总数"]
|
||||
|
||||
school_ids = School.select(:id, :province).where(province: ["安徽","江苏"]).pluck(:id)
|
||||
|
||||
user_items = []
|
||||
an_items = []
|
||||
j_items = []
|
||||
users = UserExtension.where(school_id: school_ids, identity: :teacher).includes(:user,:department, school: :courses)
|
||||
|
||||
users.each_with_index do |u, index|
|
||||
user = u.user
|
||||
school = u.school
|
||||
course_count = school.courses.size
|
||||
|
||||
shixun = SchoolReport.select(:school_id, :shixun_evaluate_count).find_by(school_id: u.school_id).try(:shixun_evaluate_count)
|
||||
item = [index+1, user.try(:show_real_name), user.try(:phone), user.try(:last_login_on), u&.department.try(:name),
|
||||
school.try(:name),course_count, school.try(:province), school.try(:city), school.try(:address), shixun]
|
||||
if u.school.try(:province) == "安徽"
|
||||
an_items.push(item)
|
||||
else
|
||||
j_items.push(item)
|
||||
end
|
||||
end
|
||||
|
||||
user_items = an_items + j_items
|
||||
|
||||
csv_string = CSV.generate(headers: true) do |csv|
|
||||
csv << csv_title
|
||||
user_items.each do |i|
|
||||
csv << i
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
fh = File.new("public/teachers.csv", "wb")
|
||||
fh.puts NKF.nkf("-wL",csv_string)
|
||||
fh.close
|
|
@ -1 +0,0 @@
|
|||
请输入内容dfasdasdfdfasdf
|
40
abcd/ttyy.rb
40
abcd/ttyy.rb
|
@ -1,40 +0,0 @@
|
|||
require 'csv'
|
||||
require 'nkf'
|
||||
|
||||
csv_title = ["id", "用户名称", "用户电话","最后登录时间", "用户部门", "所属高校","课程数量", "高校省份", "高校城市", "高校地址", "实训总数"]
|
||||
|
||||
school_ids = School.select(:id, :province).where(province: ["安徽","江苏"]).pluck(:id)
|
||||
|
||||
user_items = []
|
||||
an_items = []
|
||||
j_items = []
|
||||
users = UserExtension.where(school_id: school_ids, identity: :teacher).includes(:user,:department, school: :courses)
|
||||
|
||||
users.each_with_index do |u, index|
|
||||
user = u.user
|
||||
school = u.school
|
||||
course_count = school.courses.size
|
||||
|
||||
shixun = SchoolReport.select(:school_id, :shixun_evaluate_count).find_by(school_id: u.school_id).try(:shixun_evaluate_count)
|
||||
item = [index+1, user.try(:show_real_name), user.try(:phone), user.try(:last_login_on), u&.department.try(:name),
|
||||
school.try(:name),course_count, school.try(:province), school.try(:city), school.try(:address), shixun]
|
||||
if u.school.try(:province) == "安徽"
|
||||
an_items.push(item)
|
||||
else
|
||||
j_items.push(item)
|
||||
end
|
||||
end
|
||||
|
||||
user_items = an_items + j_items
|
||||
|
||||
csv_string = CSV.generate(headers: true) do |csv|
|
||||
csv << csv_title
|
||||
user_items.each do |i|
|
||||
csv << i
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
fh = File.new("public/teachers.csv", "wb")
|
||||
fh.puts NKF.nkf("-wL",csv_string)
|
||||
fh.close
|
|
@ -1,4 +0,0 @@
|
|||
请输入内容dfasdfa
|
||||
sd
|
||||
f
|
||||
asdf
|
|
@ -1,40 +0,0 @@
|
|||
require 'csv'
|
||||
require 'nkf'
|
||||
|
||||
csv_title = ["id", "用户名称", "用户电话","最后登录时间", "用户部门", "所属高校","课程数量", "高校省份", "高校城市", "高校地址", "实训总数"]
|
||||
|
||||
school_ids = School.select(:id, :province).where(province: ["安徽","江苏"]).pluck(:id)
|
||||
|
||||
user_items = []
|
||||
an_items = []
|
||||
j_items = []
|
||||
users = UserExtension.where(school_id: school_ids, identity: :teacher).includes(:user,:department, school: :courses)
|
||||
|
||||
users.each_with_index do |u, index|
|
||||
user = u.user
|
||||
school = u.school
|
||||
course_count = school.courses.size
|
||||
|
||||
shixun = SchoolReport.select(:school_id, :shixun_evaluate_count).find_by(school_id: u.school_id).try(:shixun_evaluate_count)
|
||||
item = [index+1, user.try(:show_real_name), user.try(:phone), user.try(:last_login_on), u&.department.try(:name),
|
||||
school.try(:name),course_count, school.try(:province), school.try(:city), school.try(:address), shixun]
|
||||
if u.school.try(:province) == "安徽"
|
||||
an_items.push(item)
|
||||
else
|
||||
j_items.push(item)
|
||||
end
|
||||
end
|
||||
|
||||
user_items = an_items + j_items
|
||||
|
||||
csv_string = CSV.generate(headers: true) do |csv|
|
||||
csv << csv_title
|
||||
user_items.each do |i|
|
||||
csv << i
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
fh = File.new("public/teachers.csv", "wb")
|
||||
fh.puts NKF.nkf("-wL",csv_string)
|
||||
fh.close
|
|
@ -1,40 +0,0 @@
|
|||
require 'csv'
|
||||
require 'nkf'
|
||||
|
||||
csv_title = ["id", "用户名称", "用户电话","最后登录时间", "用户部门", "所属高校","课程数量", "高校省份", "高校城市", "高校地址", "实训总数"]
|
||||
|
||||
school_ids = School.select(:id, :province).where(province: ["安徽","江苏"]).pluck(:id)
|
||||
|
||||
user_items = []
|
||||
an_items = []
|
||||
j_items = []
|
||||
users = UserExtension.where(school_id: school_ids, identity: :teacher).includes(:user,:department, school: :courses)
|
||||
|
||||
users.each_with_index do |u, index|
|
||||
user = u.user
|
||||
school = u.school
|
||||
course_count = school.courses.size
|
||||
|
||||
shixun = SchoolReport.select(:school_id, :shixun_evaluate_count).find_by(school_id: u.school_id).try(:shixun_evaluate_count)
|
||||
item = [index+1, user.try(:show_real_name), user.try(:phone), user.try(:last_login_on), u&.department.try(:name),
|
||||
school.try(:name),course_count, school.try(:province), school.try(:city), school.try(:address), shixun]
|
||||
if u.school.try(:province) == "安徽"
|
||||
an_items.push(item)
|
||||
else
|
||||
j_items.push(item)
|
||||
end
|
||||
end
|
||||
|
||||
user_items = an_items + j_items
|
||||
|
||||
csv_string = CSV.generate(headers: true) do |csv|
|
||||
csv << csv_title
|
||||
user_items.each do |i|
|
||||
csv << i
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
fh = File.new("public/teachers.csv", "wb")
|
||||
fh.puts NKF.nkf("-wL",csv_string)
|
||||
fh.close
|
|
@ -1,5 +0,0 @@
|
|||
请输入内容dfasdfa
|
||||
sd
|
||||
f
|
||||
asdf
|
||||
asdf
|
|
@ -0,0 +1,36 @@
|
|||
require 'csv'
|
||||
|
||||
schools = School.where(province: ["安徽","江苏"]).select(:id)
|
||||
|
||||
csv_title = ["id", "学校名称", "教师列表", "教师总数", "学生总数", "课堂总数", ]
|
||||
|
||||
schools.each do |s|
|
||||
name = school.name
|
||||
teacher_user = UserExtension.where(school_id: s.id, identity: :teacher)&.first.user
|
||||
teacher = "#{teacher_user.try(:show_real_name)-teacher_user.try(:phone)-teacher_user.try(:)}"
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
csv_title = ["id", "用户名称", "用户电话","最后登录时间", "用户部门", "所属高校", "高校省份", "高校城市", "高校地址"]
|
||||
school_ids = School.select(:id, :province).where(province: ["安徽","江苏"]).pluck(:id)
|
||||
user_items = ["users.firstname","users.lastname","users.phone","users.last_login_on","departments.name","schools.name","schools.province","schools.city", "schools.address"]
|
||||
|
||||
|
||||
|
||||
users = UserExtension.where(school_id: school_ids, identity: :teacher).joins(:user,:school,:department).pluck(user_items)
|
||||
|
||||
csv_string = CSV.generate(:col_sep => "\t", :row_sep => "\r\n") do |csv|
|
||||
csv << csv_title
|
||||
users.each_with_index do |index,user|
|
||||
csv << [index+1] + user
|
||||
end
|
||||
end
|
||||
|
||||
fh = File.new("/test.csv", "wb")
|
||||
fh.puts NKF.nkf("-wL",csv_string)
|
||||
fh.close
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
请输入内容dfasdf
|
||||
as
|
||||
df
|
||||
asd
|
||||
fasdf
|
Loading…
Reference in New Issue