<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<activity id="__smwM9jkqwwVFQ5zhYzs">
  <name>保存成绩</name>
  <parentId>__j878HaIQtHKiMk0tAn0</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <type>11</type>
  <onActionFlow></onActionFlow>
  <onActionPrint></onActionPrint>
  <colorType>default</colorType>
  <beforeActionScript><![CDATA[(function(){
  var id = ""
  id = getParameter("exampersonid");
  var examId = "";
  var applyid = "";
  println("id-------------"+id);
  var examPersonInfoDoc = findDocument(id);
  examId = examPersonInfoDoc.findItem("examId").getValue(); 
  println("examId1-------------"+examId);
  applyid = examPersonInfoDoc.findItem("applyid").getValue(); 
  println("applyid-------------"+applyid);
  println("进入成绩状态")
  var process = getDocumentProcess();
  println("examId2-------------"+examId);
  if(isNotNull(examId)){
    examId=getItemValueAsString("EXAMID");
    println("examId3-------------"+examId);
  }
  println("applyid2-------------"+applyid);
  if(isNotNull(applyid)){
    applyid=getItemValueAsString("applyid");
    println("applyid3-------------"+applyid);
  }
  println("applyid------------------------------"+applyid)
  var sumScore = "";
  var writtenScore=getItemValueAsDouble("writtenScore");
  var operateScore=getItemValueAsDouble("operateScore");
  var examInfoDoc = findDocument(examId);
  var remark = getItemValueAsString("remark");
  println("remark------------"+remark);
  var isComputerExam = examInfoDoc.findItem("isComputerExam").getValue(); 
  var isStamina = examInfoDoc.findItem("isStamina").getValue(); 
  var examRules = examInfoDoc.findItem("examRules").getValue(); 
  var writtenRatio = examInfoDoc.findItem("writtenRatio").getValue();
  var operateRatio= examInfoDoc.findItem("operateRatio").getValue();
  var examStandard= parseDouble(examInfoDoc.findItem("examStandard").getValue());
  var writtenPassScore = parseDouble(examInfoDoc.findItem("writtenPassScore").getValue());
  var operatePassScore= parseDouble(examInfoDoc.findItem("operatePassScore").getValue());
  var jieguo = ''
  if("1".equals(isComputerExam) && "0".equals(isStamina) ){
    println("是理论并且非实践------------------------------")
    sumScore = writtenScore;
    if("1".equals(examRules)){
      if(sumScore>=examStandard){
        jieguo = "1"//合格
      }else{
        jieguo = "0"//不合格
      }
    }else{
      println("不会进入此0规则因为那边已经默认只有理论的情况下默认1规则")
    }
  }else if("0".equals(isComputerExam) && "1".equals(isStamina) ){
    println("非理论是实践------------------------------")
    println("没有这种情况因为业务不会存在这种情况，强制处理了")
    //var sumScore = operateScore;
  } else if("1".equals(isComputerExam) && "1".equals(isStamina) ){
    println("两者都有------------------------------")
    if("0".equals(examRules)){
      sumScore = writtenScore * (writtenRatio / 100) + operateScore * (operateRatio / 100);   
      if(sumScore>=examStandard){
        jieguo = "1"//合格
      }else{
        jieguo = "0"//不合格
      }
    }else{//0规则,各自进行判断
      sumScore = writtenScore+operateScore;
      if(writtenScore>=writtenPassScore&&operateScore>=operatePassScore){
        jieguo = "1"//合格
      }else{
        jieguo = "0"//不合格
      }
    }
  }
  //根据考试规则来判断结果
  println("examRules考试规则"+examRules)
  println("sumScore总成绩"+sumScore)
  println("examStandard合格成绩"+examStandard)
  println("writtenPassScore比赛合格分数"+writtenPassScore)
  println("writtenScore比赛分数"+writtenScore)
  println("operateScore体测分数"+operateScore)
  println("operatePassScore体测合格分数"+operatePassScore)
  println("jieguo-------------"+jieguo);
  var doc=getCurrentDocument();
  println("doc--------------------"+doc)
  var idCardNo = getItemValue("idCardNo"); 
  var EXAMID = getItemValue("EXAMID"); 
  var signIn = getItemValue("signIn"); 
  var writtenRecordMore = getItemValue("writtenRecordMore"); 
  var sql11 = "select item_writtenscore from tlk_system_exam_person where item_idCardNo='"+idCardNo+"' and item_EXAMID='"+EXAMID+"'";
  println("sql111111111111111111"+sql11)
  var datas1 = queryByDSName("tms",sql11);
  if(datas1!=null){
    for(var iterator = datas1.iterator();iterator.hasNext();){
      var map1 = iterator.next();//取值
      var writtenscore = map1.get("item_writtenscore");
      println("writtenscore-----------------"+writtenscore);
      println("writtenScore-------------------"+writtenScore);
    }
  }
  if(writtenscore!=null){
    if(writtenscore!=writtenScore){
      var applyInfoDoc = findDocument(applyid);
      applyInfoDoc.findItem("apptype").setValue(1);
      var sqlqq="update tlk_system_exam_person set item_apptype = '1' where item_idCardNo='"+idCardNo+"' and item_EXAMID='"+EXAMID+"' ";
      updateByDSName("tms",sqlqq);
    }
  }
  var sql="update tlk_system_exam_person set item_writtenScore='"+writtenScore+"',item_remark = '"+remark+"',item_operateScore='"+operateScore+"',item_sumScore="+sumScore+",item_testState='"+jieguo+"',item_signIn='"+signIn+"',item_writtenRecordMore='"+writtenRecordMore+"' where item_idCardNo='"+idCardNo+"' and item_EXAMID='"+EXAMID+"' ";
  //将成绩更新到报名表（方便监管端查询）
  var applyInfoDoc = findDocument(applyid);
  applyInfoDoc.findItem("examId").setValue(examId);
  applyInfoDoc.findItem("operateScore").setValue(operateScore);
  applyInfoDoc.findItem("writtenScore").setValue(writtenScore);
  process.doUpdate(applyInfoDoc);   
  println("sql到这里11111111"+sql);
  updateByDSName("tms",sql);
  println(" 结束");
})()]]></beforeActionScript>
  <afterActionScript><![CDATA[]]></afterActionScript>
  <retractBeforeActionScript><![CDATA[]]></retractBeforeActionScript>
  <retractAfterActionScript><![CDATA[]]></retractAfterActionScript>
  <hiddenScript><![CDATA[(function(){
  var mark = getParameter("mark");
  println("mark2-------"+mark);
  if("1".equals(mark)){
    return true;
  }
  var scoreState = getItemValueAsString("scoreState");
  println("scoreState"+scoreState)
  if("1".equals(scoreState)){
    return true;
  }else{
    return false;
  }

})()]]></hiddenScript>
  <readonlyScript><![CDATA[]]></readonlyScript>
  <startFlowScript><![CDATA[]]></startFlowScript>
  <editMode>0</editMode>
  <fileNameScript><![CDATA[]]></fileNameScript>
  <iconurl></iconurl>
  <orderno>1</orderno>
  <stateToShow></stateToShow>
  <parentForm>__j878HaIQtHKiMk0tAn0</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>