From 7d6c48e86c8bfb2364bf2d3a4d4528724762e47c Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Tue, 12 Mar 2019 20:24:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=AE=A4=E8=AF=81=E3=80=91=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E8=AE=A4=E8=AF=81=E7=9A=84=E7=95=8C=E5=88=AB=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=EF=BC=8C=E6=B2=A1=E6=9C=89=E5=A4=8D=E5=88=B6=E6=AF=95?= =?UTF-8?q?=E4=B8=9A=E8=A6=81=E6=B1=82=20vs=20=E5=9F=B9=E5=85=BB=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E5=92=8C=20=E6=AF=95=E4=B8=9A=E8=A6=81=E6=B1=82=20vs?= =?UTF-8?q?=20=E9=80=9A=E7=94=A8=E6=A0=87=E5=87=86=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E7=9F=A9=E9=98=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ec_years_controller.rb | 41 ++++++++++++++++---------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/app/controllers/ec_years_controller.rb b/app/controllers/ec_years_controller.rb index 12ad6212..1e77f089 100644 --- a/app/controllers/ec_years_controller.rb +++ b/app/controllers/ec_years_controller.rb @@ -387,6 +387,14 @@ class EcYearsController < ApplicationController new_egs.save! # 记录新旧对应关系,为之后的中间表做记录 egs_record << [pre_egs.id, new_egs.id] + prev_ersvss = EcRequireSubVsStandard.where(:ec_graduation_subitem_id => pre_egs.id) + prev_ersvss.each do |prev_ersvs| + new_ersvss = EcRequireSubVsStandard.new + new_ersvss.attributes = prev_ersvs.attributes.dup.except("id", "ec_graduation_subitem_id") + new_ersvss.ec_graduation_subitem_id = new_egs.id + new_ersvss.save! + end + end end @@ -398,28 +406,29 @@ class EcYearsController < ApplicationController new_eto.ec_year_id = ec_year.id new_eto.save! - # 复制 "毕业要去 vs 培养目标" - pre_ervsos = EcRequirementVsObjective.where(:ec_training_objective_id => pre_eto.id) - pre_ervsos.each do |ervso| - new_ervso = EcRequirementVsObjective.new - new_ervso.attributes = ervso.attributes.dup.except("id", "ec_training_objective_id", "ec_graduation_requirement_id") - new_ervso.ec_training_objective_id = new_eto.id - new_egr_id = -1 - egr_record.each do |egr_id| - if egr_id[0] == ervso.id - new_egr_id = egr_id[1] - end - end - raise("找不对应的毕业要求") if new_egr_id == -1 - new_ervso.ec_graduation_requirement_id = new_egr_id - end - # 复制 "培养目标分项" pre_eto.ec_training_subitems.try(:each) do |pre_ets| new_ets = EcTrainingSubitem.new new_ets.attributes = pre_ets.attributes.dup.except("id", "ec_training_objective_id") new_ets.ec_training_objective_id = new_eto.id new_ets.save! + + # 复制 "毕业要去 vs 培养目标" + pre_ervsos = EcRequirementVsObjective.where(:ec_training_objective_id => pre_ets.id) + pre_ervsos.each do |ervso| + new_ervso = EcRequirementVsObjective.new + new_ervso.attributes = ervso.attributes.dup.except("id", "ec_training_objective_id", "ec_graduation_requirement_id") + new_ervso.ec_training_objective_id = new_ets.id + new_egr_id = -1 + egr_record.each do |egr_id| + if egr_id[0] == ervso.ec_graduation_requirement_id + new_egr_id = egr_id[1] + end + end + raise("找不对应的毕业要求") if new_egr_id == -1 + new_ervso.ec_graduation_requirement_id = new_egr_id + new_ervso.save! + end end end