forked from Trustie/forgeplus
fixed 竞赛导出作品编号
This commit is contained in:
parent
adb8954aec
commit
8bb76e9bc3
|
|
@ -18,18 +18,20 @@ class Competition::ZipWorkFileService
|
|||
|
||||
def zip
|
||||
zip_file = Rails.root.join(@path, filename)
|
||||
file_count =0
|
||||
Zip::File.open(zip_file, Zip::File::CREATE) do |attach_zip|
|
||||
if @competition_users.present?
|
||||
competition_info = @competition_users.last.competition_info
|
||||
@competition_users.each do |c_user|
|
||||
next if c_user.attachments.blank?
|
||||
c_user.attachments.each_with_index do |attach, index|
|
||||
Rails.logger.error("########—————@file_index==#{@file_index},#{index},#{@file_index.to_i != index + 1}")
|
||||
# Rails.logger.info("########—————@file_index==#{@file_index},#{index},#{@file_index.to_i != index + 1}")
|
||||
next if @file_index.present? && @file_index.to_i != index + 1
|
||||
file_count += 1
|
||||
# attach = c_user.attachments.last
|
||||
attach_local_path = "#{Rails.root}/files/#{attach.disk_directory}/#{attach.disk_filename}"
|
||||
attach_filename = "#{c_user.id}_#{c_user.leader}_#{attach.filename}"
|
||||
attach_filename = "#{c_user.ext1}_#{attach.filename}" if competition_info.identifier.to_s.downcase.include?("kxsysj-2024-2")
|
||||
attach_filename = "#{file_count}_#{attach.filename}" if competition_info.identifier.to_s.downcase.include?("kxsysj-2024-2")
|
||||
begin
|
||||
attach_zip.add(attach_filename, attach_local_path)
|
||||
rescue => ex
|
||||
|
|
@ -39,6 +41,7 @@ class Competition::ZipWorkFileService
|
|||
end
|
||||
end
|
||||
end
|
||||
Rails.logger.info("########—————Competition::ZipWorkFileService.file_count==#{file_count}")
|
||||
zip_file
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue