From 8bb76e9bc36ff5504fd4aebbc2783aaa7fb4b9d3 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 6 Jun 2025 09:33:26 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E7=AB=9E=E8=B5=9B=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/competition/zip_work_file_service.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/services/competition/zip_work_file_service.rb b/app/services/competition/zip_work_file_service.rb index e5856829f..544bc3902 100644 --- a/app/services/competition/zip_work_file_service.rb +++ b/app/services/competition/zip_work_file_service.rb @@ -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