<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<activity id="__JpwJYcGlEcvjZgqUU1O">
  <name>保存</name>
  <parentId>__4yuDhHt2Tgj2NF8aTOX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <type>11</type>
  <onActionFlow></onActionFlow>
  <onActionPrint></onActionPrint>
  <colorType>default</colorType>
  <beforeActionScript><![CDATA[(function(){
  var exam_id = getItemValueAsString("exam_id");
  var select_person_id = getItemValueAsString("select_person_id");
  var exam_kind = getItemValueAsString("exam_kind");
  var max_number = getItemValueAsInt("max_number");
  var plan_id = getItemValueAsString("plan_id");
  var exam_kind = getItemValueAsString("exam_kind");
  var forSeat=1
  var arrto = splitText(select_person_id,";"); 
  var oldnumsql="select 1 from tlk_train_exam_person where item_exam_id='"+exam_id+"' "
  var oldnumdatas = queryByDSName("tms",oldnumsql);
  var sumnum=parseInt(oldnumdatas.size())+parseInt(arrto.length);
  println("sumnum-->"+sumnum)
  if(max_number<sumnum){
    return "人数大于当前班级最大人数！"
  }
  var checkClass="select 1 from tlk_train_exam_person where item_exam_id='"+exam_id+"'  "
  var checkClassdatas = queryByDSName("tms",checkClass);
  if(checkClassdatas.size()>0){
    var target=true //标记代表不是第一次添加人员
    }else{
      var target=false //标记代表是第一次添加人员
      }

  var process = getDocumentProcess();            
  var formProcess = getFormProcess();            
  var personInfo = formProcess.doView("__kYJzSUcq1iL0ltOWW69");
  for(var i=0;i<arrto.length;i++){
    var trainInfoDoc=findDocument(arrto[i]);
    var person_name=trainInfoDoc.findItem("person_name").getValue();
    var employee_id=trainInfoDoc.findItem("employee_id").getValue();
    var idcard_no=trainInfoDoc.findItem("idcard_no").getValue();
    var telephone=trainInfoDoc.findItem("telephone").getValue();
    var domain_name=trainInfoDoc.findItem("domain_name").getValue();
    var domain_id=trainInfoDoc.findItem("domain_id").getValue();
    var train_domain_name=trainInfoDoc.findItem("train_domain_name").getValue();
    var train_domain_id=trainInfoDoc.findItem("train_domain_id").getValue();
    var order_person_id=trainInfoDoc.findItem("order_person_id").getValue();
    var selectsql="select id from tlk_train_exam_person where item_idcard_no='"+idcard_no+"' and item_exam_id='"+exam_id+"'  "
    println(selectsql)
    var datas2 = queryByDSName("tms",selectsql);
    if(datas2.size()>0){
    }else{
      var personInfoDoc = process.doNew(personInfo,getWebUser(),createParamsTable());   
      if("1".equals(exam_kind)){
        trainInfoDoc.findItem("is_up").setValue('1');
        process.doUpdate(trainInfoDoc); 
        personInfoDoc.addStringItem("last_person_id",arrto[i]);
      }
      personInfoDoc.addStringItem("person_name",person_name);
      personInfoDoc.addStringItem("employee_id",employee_id);  
      personInfoDoc.addStringItem("idcard_no",idcard_no);
      personInfoDoc.addStringItem("telephone",telephone);  
      personInfoDoc.addStringItem("domain_name",domain_name); 
      personInfoDoc.addStringItem("domain_id",domain_id);  
      personInfoDoc.addStringItem("train_domain_name",train_domain_name); 
      personInfoDoc.addStringItem("train_domain_id",train_domain_id); 
      personInfoDoc.addStringItem("order_person_id",order_person_id); 
      personInfoDoc.addStringItem("exam_kind",exam_kind);  
      personInfoDoc.addStringItem("card_status",'0'); 
      personInfoDoc.addStringItem("exam_id",exam_id); 
      personInfoDoc.addStringItem("plan_id",plan_id); 
      personInfoDoc.addStringItem("card_status",'0'); 
      personInfoDoc.addStringItem("exam_info",'-'); 
      personInfoDoc.addStringItem("written_sign_status",'0'); 
      personInfoDoc.addStringItem("confirm_status",'0'); 
      personInfoDoc.addStringItem("is_up",'0'); 
      personInfoDoc.addStringItem("face_status",'0'); 
      personInfoDoc.addStringItem("has_operate_score",'0');
      personInfoDoc.addStringItem("has_written_score",'0');
      if(target){
        println("我进到非第一次添加")
        for(var s=1;s<=max_number;s++){
          println("seatdatas---》"+forSeat)
          var seatsql="select 1 from tlk_train_exam_person where item_seat="+forSeat+" and item_exam_id='"+exam_id+"' "
          println(seatsql)
          var seatdatas = queryByDSName("tms",seatsql);
          println("seatdatas---》"+seatdatas.size())
          if(seatdatas.size()>0){
            var  nowSeat=forSeat
            }else{
              nowSeat=forSeat
              forSeat=forSeat+1
              break;
            }
          forSeat=forSeat+1
        }
      }else {
        var nowSeat=i+1
        }
      println("最终座位---》"+nowSeat)
      personInfoDoc.addIntItem("seat",nowSeat);
      process.doCreate(personInfoDoc); 
      println("我已经新建---》"+personInfoDoc)
    }

  }
})()]]></beforeActionScript>
  <afterActionScript><![CDATA[]]></afterActionScript>
  <retractBeforeActionScript><![CDATA[]]></retractBeforeActionScript>
  <retractAfterActionScript><![CDATA[]]></retractAfterActionScript>
  <hiddenScript><![CDATA[]]></hiddenScript>
  <readonlyScript><![CDATA[]]></readonlyScript>
  <startFlowScript><![CDATA[]]></startFlowScript>
  <editMode>0</editMode>
  <fileNameScript><![CDATA[]]></fileNameScript>
  <iconurl></iconurl>
  <orderno>0</orderno>
  <stateToShow></stateToShow>
  <parentForm>__4yuDhHt2Tgj2NF8aTOX</parentForm>
  <jumpType>0</jumpType>
  <expSub>false</expSub>
  <icon></icon>
  <disableFlowNode>false</disableFlowNode>
  <changeFlowOperator>false</changeFlowOperator>
  <changeFlowCc>false</changeFlowCc>
  <multiLanguageLabel></multiLanguageLabel>
  <dispatcherMode>0</dispatcherMode>
  <dispatcherUrl><![CDATA[]]></dispatcherUrl>
  <dispatcherParams><![CDATA[[{"paramKey":"","paramValue":""}]]]></dispatcherParams>
  <jumpMode>0</jumpMode>
  <jumpActOpenType>0</jumpActOpenType>
  <withOld>false</withOld>
  <actionType>0</actionType>
  <actionDispatcherUrlScript><![CDATA[]]></actionDispatcherUrlScript>
  <actionSelection>0</actionSelection>
  <relatedFormId></relatedFormId>
  <actionScript><![CDATA[]]></actionScript>
  <workFlowType>0</workFlowType>
  <contextMenu>false</contextMenu>
  <showInToolbar>true</showInToolbar>
  <transpond></transpond>
  <targetList>|</targetList>
  <label><![CDATA[]]></label>
</activity>