<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<activity id="__XteBkmUjAF5JgxUAdse">
  <name>保存</name>
  <parentId>__uNwXxWDjKLVu6QuQWUg</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <type>11</type>
  <onActionFlow></onActionFlow>
  <onActionPrint></onActionPrint>
  <colorType>default</colorType>
  <beforeActionScript><![CDATA[(function(){
  var point_type = getItemValueAsString("point_type");
  var class_id = getItemValueAsString("class_id");
  var classroom_type = getItemValueAsString("classroom_type");
  var select_person_id = getItemValueAsString("select_person_id");
  var max_number = getItemValueAsInt("max_number");
  var plan_id = getItemValueAsString("plan_id");
  var forSeat=1
  var arrto = splitText(select_person_id,";"); 
  var oldnumsql="select 1 from tlk_train_person where item_class_id='"+class_id+"' and item_classroom_type='"+classroom_type+"' "
  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_person where item_class_id='"+class_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("__Wgz1dukcCuAmA1lXi9u");
  for(var i=0;i<arrto.length;i++){
    var payInfoDoc=findDocument(arrto[i]);
    var person_name=payInfoDoc.findItem("person_name").getValue();
    var employee_id=payInfoDoc.findItem("employee_id").getValue();
    var idcard_no=payInfoDoc.findItem("idcard_no").getValue();
    var telephone=payInfoDoc.findItem("telephone").getValue();
    var domain_name=payInfoDoc.findItem("domain_name").getValue();
    var domain_id=payInfoDoc.findItem("domain_id").getValue();
    var train_domain_name=payInfoDoc.findItem("trian_name").getValue();
    var train_domain_id=payInfoDoc.findItem("trian_id").getValue();
    var selectsql="select id from tlk_train_person where item_idcard_no='"+idcard_no+"' and item_plan_id='"+plan_id+"' and item_classroom_type='"+classroom_type+"' "
    println(selectsql)
    var datas2 = queryByDSName("tms",selectsql);
    if(datas2.size()>0){
    }else{
      var personInfoDoc = process.doNew(personInfo,getWebUser(),createParamsTable());   
      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",arrto[i]); 
      personInfoDoc.addStringItem("point_type",point_type);  
      personInfoDoc.addStringItem("classroom_type",classroom_type); 
      personInfoDoc.addStringItem("class_id",class_id); 
      personInfoDoc.addStringItem("plan_id",plan_id); 
      personInfoDoc.addStringItem("sign_status",0); 
      if(target){
        println("我进到非第一次添加")
        for(var s=1;s<=max_number;s++){
          println("seatdatas---》"+forSeat)
          var seatsql="select 1 from tlk_train_person where item_seat="+forSeat+" and item_class_id='"+class_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>__uNwXxWDjKLVu6QuQWUg</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>