From 44adbf8e8256489a4a978664e9fd1d83188e99f6 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 4 Apr 2019 22:11:39 +0800 Subject: [PATCH 1/4] 1 --- app/controllers/managements_controller.rb | 10 ++++++++-- app/views/managements/shixun_feedback_message.html.erb | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 13f408c2..3d126f3b 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -822,7 +822,7 @@ class ManagementsController < ApplicationController format.xls{ shixun_ids = @all_discusses.pluck(:dis_id).uniq filename = "#{Time.now.strftime("%Y%m%d")}-实训反馈.xls" - send_data(shixun_feedback_xls(shixun_ids), :type => "text/excel;charset=utf-8; header=present", :filename => filename_for_content_disposition(filename)) + send_data(shixun_feedback_xls(shixun_ids, @beginTime, @endTime), :type => "text/excel;charset=utf-8; header=present", :filename => filename_for_content_disposition(filename)) } end end @@ -4246,7 +4246,7 @@ end return sheet.rows end - def shixun_feedback_xls shixun_ids + def shixun_feedback_xls shixun_ids, beginTime, endTime xls_report = StringIO.new book = Spreadsheet::Workbook.new sheet1 = book.create_worksheet :name => "实训反馈" @@ -4258,6 +4258,12 @@ end "评论者单位", "评论时间", "社区导师是否已回复"]) shixuns.each_with_index do |shixun, i| discusses = shixun.discusses.where("user_id != ?", 1) + if beginTime.present? + discusses = discusses.where("created_at >= '#{beginTime}'") + end + if endTime.present? + discusses = discusses.where("created_at <= '#{endTime}'") + end sheet1[count_row, 0] = i + 1 sheet1[count_row, 1] = shixun.identifier sheet1[count_row, 2] = shixun.name diff --git a/app/views/managements/shixun_feedback_message.html.erb b/app/views/managements/shixun_feedback_message.html.erb index ff4ecebe..ba0eb05c 100644 --- a/app/views/managements/shixun_feedback_message.html.erb +++ b/app/views/managements/shixun_feedback_message.html.erb @@ -22,6 +22,8 @@ \ No newline at end of file From 30af40165d4074b399eb9f743b5f1c927e06372a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 8 Apr 2019 18:05:54 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 5a476440..e04c183b 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -3345,7 +3345,7 @@ end end @users = User.where(:id => user_id).where("#{sql}").includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on desc") - @xls_users = @users #导出excel用户 + @xls_users = @users.reorder("created_on desc").limit(1000) #导出excel用户 @page = (params['page'] || 1).to_i @users_count = @users.count @limit = 20