<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<activity id="__FrscjEajk2Jc6axaY4J">
  <name>保存</name>
  <parentId>__WwIYAARbbN4LE3598ci</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <type>11</type>
  <onActionFlow></onActionFlow>
  <onActionPrint></onActionPrint>
  <colorType>default</colorType>
  <beforeActionScript><![CDATA[(function(){
  var doc=getCurrentDocument().getItemMap();//当前文档
  var batch_id = getItemValueAsString("batch_id");
  var examKind = getItemValueAsString("examKind");
  var computerStartDate = getItemValueAsDate("computerStartDate");
  var computerEndDate = getItemValueAsDate("computerEndDate");
  var entries = doc.entrySet().iterator(); 
  var process = getDocumentProcess();
  var formProcess = getFormProcess();
  var examInfo = formProcess.doView("__TguP7KZtUDBVC1gHr6k");
  var examInfoDoc = process.doNew(examInfo,getWebUser(),createParamsTable());        
  while( entries.hasNext() ){                           
    var entry = entries.next();
    var key = entry.getKey();
    var value = entry.getValue(); 
    var doc1key=examInfoDoc.findItem(key);
    if(isNotNull(doc1key)){
      doc1key.setValue(value);
    }
  }
  process.doCreate(examInfoDoc);
  var batchProcess = getDocProcess('__Qlqia54jXSOKQxX0rof');
  var batchDoc = batchProcess.doView(batch_id);
  var examId= examInfoDoc.getId()
  if('1'.equals(examKind)){
    batchDoc.findItem("up_id").setValue(examId)
  }else{
    batchDoc.findItem("exam_id").setValue(examId)
  }
  batchDoc.findItem("send_start_time").setValue(computerStartDate)
  batchDoc.findItem("send_end_time").setValue(computerEndDate)
  batchProcess.doUpdate(batchDoc);
  //安排人员进去
  var process = getDocumentProcess();
  var formProcess = getFormProcess();
  var examPersonInfo = formProcess.doView("__2i8jAJxf4DjUsB0szBf");
  var sql="select item_apply_id from tlk_batch_person where item_batch_id='"+batch_id+"' "
  var datas = queryByDSName("tms",sql);
  var seat=0
  for(var iterator = datas.iterator();iterator.hasNext();){
    var map1 = iterator.next();//取值
    var apply_id= map1.get("item_apply_id");
    var applyInfoDoc = batchProcess.doView(apply_id);
    var examPersonInfoDoc = process.doNew(examPersonInfo,getWebUser(),createParamsTable()); 
    if('1'.equals(examKind)){
      var sqlExam="select 1 from tlk_system_exam_person where item_applyId='"+apply_id+"' and item_testState='0' "
      var Examdatas = queryByDSName("tms",sqlExam);
      if(Examdatas.size()>0){
        var sqlUp="update tlk_system_exam_person set item_isDelete='1' where item_applyId='"+apply_id+"'";
        updateByDSName("tms",sqlUp);
        var examNum = applyInfoDoc.findItem("examNum").getValue();
        var value=parseDouble(examNum)+1;
        applyInfoDoc.findItem("examNum").setValue(value);
        examPersonInfoDoc.addStringItem("securityId",applyInfoDoc.findItem("securityId").getValue());  
        examPersonInfoDoc.addStringItem("examId",examId);     
        examPersonInfoDoc.addStringItem("idCardNo",applyInfoDoc.findItem("idCardNo").getValue());     
        examPersonInfoDoc.addStringItem("name",applyInfoDoc.findItem("name").getValue()); 
        examPersonInfoDoc.addStringItem("company",applyInfoDoc.findItem("learnName").getValue()); 
        examPersonInfoDoc.addStringItem("mobile",applyInfoDoc.findItem("phone").getValue()); 
        examPersonInfoDoc.addStringItem("zw",seat+1); 
        applyInfoDoc.findItem("examId").setValue(examId);
        applyInfoDoc.findItem("writtenScore").setValue("0");
        applyInfoDoc.findItem("operateScore").setValue("0");
        examPersonInfoDoc.addIntItem("writtenScore",0); 
        examPersonInfoDoc.addIntItem("operateScore",0); 
        examPersonInfoDoc.addIntItem("sumScore",0); 
        examPersonInfoDoc.addStringItem("testState","-"); 
        examPersonInfoDoc.addStringItem("noticeState","0"); 
        examPersonInfoDoc.addStringItem("scoreState","0"); 
        examPersonInfoDoc.addStringItem("cardState","0"); 
        examPersonInfoDoc.addStringItem("applyId",applyInfoDoc.getId()); 
        examPersonInfoDoc.addStringItem("writtenRecord","");  
        examPersonInfoDoc.addStringItem("writtenState","0");     
        examPersonInfoDoc.addStringItem("isMakeUp","2");     
        examPersonInfoDoc.addStringItem("signIn","0");     
        examPersonInfoDoc.addStringItem("confirmDate","");     
        process.doCreate(examPersonInfoDoc); 
      }
    }else{
      examPersonInfoDoc.addStringItem("securityId",applyInfoDoc.findItem("securityId").getValue());  
      examPersonInfoDoc.addStringItem("examId",examId);     
      examPersonInfoDoc.addStringItem("idCardNo",applyInfoDoc.findItem("idCardNo").getValue());     
      examPersonInfoDoc.addStringItem("name",applyInfoDoc.findItem("name").getValue()); 
      examPersonInfoDoc.addStringItem("company",applyInfoDoc.findItem("learnName").getValue()); 
      examPersonInfoDoc.addStringItem("mobile",applyInfoDoc.findItem("phone").getValue()); 
      applyInfoDoc.findItem("examId").setValue(examId);
      applyInfoDoc.findItem("writtenScore").setValue("0");
      applyInfoDoc.findItem("operateScore").setValue("0");
      examPersonInfoDoc.addStringItem("zw",seat+1); 
      examPersonInfoDoc.addIntItem("writtenScore",0); 
      examPersonInfoDoc.addIntItem("operateScore",0); 
      examPersonInfoDoc.addIntItem("sumScore",0); 
      examPersonInfoDoc.addStringItem("testState","-"); 
      examPersonInfoDoc.addStringItem("noticeState","0"); 
      examPersonInfoDoc.addStringItem("scoreState","0"); 
      examPersonInfoDoc.addStringItem("cardState","0"); 
      examPersonInfoDoc.addStringItem("applyId",applyInfoDoc.getId()); 
      examPersonInfoDoc.addStringItem("writtenRecord","");  
      examPersonInfoDoc.addStringItem("writtenState","0");     
      examPersonInfoDoc.addStringItem("isMakeUp","0");     
      examPersonInfoDoc.addStringItem("signIn","0");     
      examPersonInfoDoc.addStringItem("confirmDate","");     
      process.doCreate(examPersonInfoDoc); 
      process.doUpdate(applyInfoDoc);
    }
  }
})() 

]]></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>__WwIYAARbbN4LE3598ci</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>