fixed 竞赛增加字段,打分限制,导出保密文件,搜索队长信息

This commit is contained in:
xxq250 2024-11-07 10:58:35 +08:00
parent 86df55d43b
commit 513cf10a09
7 changed files with 49 additions and 12 deletions

View File

@ -149,6 +149,7 @@ class CompetitionInfosController < ApplicationController
@table_columns = enroll_fields.keys
@table_columns = @table_columns + %w(作品下载链接) if params[:upload].to_s == "true" && !enroll_fields.values.include?("works_url")
@table_columns = @table_columns + %w(申请表下载链接) if params[:apply_status].present?
@table_columns = @table_columns + %w(bm审查下载链接) if @competition_info.identifier == "KXSYSJ-2024"
# 重排成员放最后
enroll_fields_values = enroll_fields.values - ["members_to_string"] + ["members_to_string"]
@export_infos = []
@ -172,6 +173,10 @@ class CompetitionInfosController < ApplicationController
file = Attachment.where_id_or_uuid(u.ext2).first
info_array = info_array + [file.blank? ? "" : "#{EduSetting.get('host_name')}/#{download_url(file)}"]
end
if @competition_info.identifier == "KXSYSJ-2024"
file = Attachment.where_id_or_uuid(u.bm_file_id).first
info_array = info_array + [file.blank? ? "" : "#{EduSetting.get('host_name')}/#{download_url(file)}"]
end
@export_infos.push(info_array)
end
Rails.logger.info("######_______________1111########@export_infos: #{@export_infos}")
@ -330,8 +335,13 @@ class CompetitionInfosController < ApplicationController
# 第一轮赛合格人员
first_round_ids = [541, 543, 544, 545, 546, 548, 550, 551, 552, 554, 555, 556, 558, 560, 563, 565, 567, 576, 579, 581]
@second_round = first_round_ids.include?(@competition_user&.id)
cache_key = "limit_forbid_control:#{@competition_info.identifier}:competition_api_score:#{@competition_user&.id}-#{@stage}"
@count_control = Rails.cache.read(cache_key)
if @competition_info.identifier.to_s == "dmsc" || @competition_info.identifier.to_s == "zswd"
cache_key = "limit_forbid_control:#{@competition_info.identifier}:competition_api_score:#{@competition_user&.id}-#{@stage}"
@count_control = Rails.cache.read(cache_key)
else
api_score_control = LimitForbidControl::CompetitionApiScore.new(@competition_user.id)
@count_control = api_score_control.forbid?
end
end
def upload
@ -431,7 +441,7 @@ class CompetitionInfosController < ApplicationController
.order("competition_user_scores.score desc, competition_user_scores.created_at asc")
@rank_num = competition_users.pluck(:id)
if params[:keyword].present?
competition_users = competition_users.where("competition_users.org_name LIKE :keyword OR competition_users.leader LIKE :keyword ", keyword: "%#{params[:keyword].to_s}%")
competition_users = competition_users.where("competition_users.org_name LIKE :keyword OR competition_users.leader LIKE :keyword OR competition_users.ext4 LIKE :keyword ", keyword: "%#{params[:keyword].to_s}%")
end
@competition_users_count = competition_users.count
@competition_users = paginate(competition_users)
@ -439,7 +449,7 @@ class CompetitionInfosController < ApplicationController
competition_users = @competition_info.competition_users.where("competition_users.status = 3").where("score > 0").order("score desc, created_at asc")
@rank_num = competition_users.pluck(:id)
if params[:keyword].present?
competition_users = competition_users.where("competition_users.org_name LIKE :keyword OR competition_users.leader LIKE :keyword ", keyword: "%#{params[:keyword].to_s}%")
competition_users = competition_users.where("competition_users.org_name LIKE :keyword OR competition_users.leader LIKE :keyword OR competition_users.ext4 LIKE :keyword ", keyword: "%#{params[:keyword].to_s}%")
end
@competition_users_count = competition_users.count
@competition_users = paginate(competition_users)
@ -460,7 +470,7 @@ class CompetitionInfosController < ApplicationController
def enroll_params
params.permit(:org_name, :org_job, :org_rank, :leader, :zone, :sub_competition, :phone,
:subject_source_type, :subject_source_name, :enroll_template_id, :mail, :ext1, :ext2, :ext3, :ext4, :ext5,
:bm_file_id)
:bm_file_id, :teacher_name, :teacher_dept, :teacher_email, :teacher_phone, :teacher_professional)
end
def competition_info_params

View File

@ -12,7 +12,7 @@ class LimitForbidControl::CompetitionApiScore < LimitForbidControl::Base
def forbid_expires
num = EduSetting.get('daily_api_score_forbid_time').presence.to_i
num.zero? ? 1.hours : num.to_i.hours
num.zero? ? 1.hours : num.to_i.minutes
end
def cumulative_expires

View File

@ -93,11 +93,11 @@ class CompetitionInfo < ApplicationRecord
hash={}
hash.merge!({ "ID" => "id" })
hash.merge!({ "用户名" => "user_login" })
hash.merge!({ "参赛单位" => "org_name" })
hash.merge!({ "参赛负责人" => "leader" })
hash.merge!({ "职务" => "org_job" }) if self.is_local?
hash.merge!({ "队长姓名" => "leader" })
hash.merge!({ "队长单位" => "org_name" })
hash.merge!({ "队长职称" => "org_job" })
hash.merge!({ "军衔" => "org_rank" }) if self.is_local?
hash.merge!({ "电话" => "phone" })
hash.merge!({ "队长电话" => "phone" })
hash.merge!({ "赛区" => "zone" })
hash.merge!({ "赛项" => "sub_competition" })
hash.merge!({ "课题来源" => "subject_source_from" }) if self.is_local?
@ -105,6 +105,11 @@ class CompetitionInfo < ApplicationRecord
hash.merge!({ "参赛作品名称" => "works_name" })
hash.merge!({ "参赛作品链接" => "works_url" })
hash.merge!({ "成员" => "members_to_string" })
hash.merge!({ "指导老师姓名" => "teacher_name" })
hash.merge!({ "指导老师单位" => "teacher_dept" })
hash.merge!({ "指导老师邮箱" => "teacher_email" })
hash.merge!({ "指导老师电话" => "teacher_phone" })
hash.merge!({ "指导老师职称" => "teacher_professional" })
self.enroll_columns.present? && self.enroll_columns.is_a?(String) ? JSON.parse(self.enroll_columns) : hash
rescue => err

View File

@ -42,6 +42,13 @@ class CompetitionUser < ApplicationRecord
validates :user_id, uniqueness: { scope: :competition_info_id}
# 报名扩展字段应用记录
# ext5:竞赛阶段
# ext1:指导老师
# ext2:申请模板文件
# ext3:申请模板状态
# ext4:参赛队伍名称
serialize :members, JSON
# %i[real_name org_name org_job org_rank].each do |method_name|

View File

@ -4,7 +4,8 @@ json.count @competition_users_count
json.data do
json.array! @competition_users.to_a do |c_user|
json.extract! c_user, :id, :org_name, :org_job, :org_rank, :leader, :zone, :sub_competition, :subject_source_type,
:subject_source_name, :phone, :status, :mail, :ext1, :ext2, :ext3, :ext4, :ext5, :sub_item, :works_name, :works_url,:bm_file_id
:subject_source_name, :phone, :status, :mail, :ext1, :ext2, :ext3, :ext4, :ext5, :sub_item, :works_name, :works_url,
:bm_file_id, :teacher_name, :teacher_dept, :teacher_email, :teacher_phone, :teacher_professional
json.user_id c_user.user_id
json.user_real_name c_user.user&.real_name
json.members c_user.members
@ -17,6 +18,10 @@ json.data do
file = Attachment.where_id_or_uuid(c_user.ext2).first
json.partial! 'attachments/attachment_simple', attachment: file if file.present?
end
json.bm_file do
file = Attachment.where_id_or_uuid(c_user.bm_file_id).first
json.partial! 'attachments/attachment_simple', attachment: file if file.present?
end
json.attachments c_user.attachments do |attachment|
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
end

View File

@ -8,7 +8,8 @@ json.data do
if @competition_user.present?
json.enroll_info do
json.extract! @competition_user, :org_name, :org_job, :org_rank, :leader, :zone, :sub_competition, :subject_source_type,
:subject_source_name, :phone, :status, :mail, :ext1, :ext2, :ext3, :ext4, :ext5, :sub_item, :works_name, :works_url,:bm_file_id
:subject_source_name, :phone, :status, :mail, :ext1, :ext2, :ext3, :ext4, :ext5, :sub_item, :works_name, :works_url,
:bm_file_id, :teacher_name, :teacher_dept, :teacher_email, :teacher_phone, :teacher_professional
json.user_id @competition_user.user_id
json.user_real_name @competition_user.user&.real_name
json.members @competition_user.members

View File

@ -0,0 +1,9 @@
class AddCompetitionUserAddTeacher < ActiveRecord::Migration[5.2]
def change
add_column :competition_users, :teacher_name, :string
add_column :competition_users, :teacher_dept, :string
add_column :competition_users, :teacher_email, :string
add_column :competition_users, :teacher_phone, :string
add_column :competition_users, :teacher_professional, :string
end
end