<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<activity id="__kp08G5rz5pudjLlJ7fY">
  <name>确认取消</name>
  <parentId>__3tEBpOpEisePUNfVuQY</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <type>13</type>
  <onActionFlow></onActionFlow>
  <onActionPrint></onActionPrint>
  <colorType>default</colorType>
  <beforeActionScript><![CDATA[//判断表单某字段不能为空
#include "sysfunction";
(function(){
  var examId = getId(); 
  var cancelReason = getItemValueAsString("cancelReason");
  if("".equals(cancelReason)) {
    return "考试取消原因必须填写！";
  }

  var computerStartDate = getItemValueAsDate("computerStartDate");
  if(isNotNull(computerStartDate)){
    var computerStartDate1=format(computerStartDate,"yyyy-MM-dd HH:mm:ss")
    var todta= format(getToday(),"yyyy-MM-dd HH:mm:ss")
   // println(computerStartDate1-todta);
   /* if(computerStartDate1<todta){
    }*/
    println("sssssssssssssssssss"+computerStartDate1)
    println("sssssssssssssssssss"+todta)
    var dateDiff = diffHours(todta,computerStartDate1);   //时间差的毫秒数   .getTime()
    println("sssssssssssssssssss"+dateDiff)
    if(dateDiff <= 0){  
      println("sssssssssssssssssss"+dateDiff)
      return "考试已过期！"; 
    }   
  }


  var sql = "select '"+getDomainid()+"' as domainid, ID, ID as ITEM_ID from tlk_system_exam_person where ITEM_EXAMID = '"+examId+"' and ITEM_SCORESTATE = '1'";
  println("sql==>" + sql);
  var t_count = countBySQL(sql);
  if(t_count > 0) {
    return "已存在确认成绩的学员，无法取消!"
  }
})()]]></beforeActionScript>
  <afterActionScript><![CDATA[]]></afterActionScript>
  <retractBeforeActionScript><![CDATA[]]></retractBeforeActionScript>
  <retractAfterActionScript><![CDATA[]]></retractAfterActionScript>
  <hiddenScript><![CDATA[(function(){
var examine = getItemValueAsString("examine"); 
  println("sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"+examine)
  if("0".equals(examine)||"1".equals(examine)){//待提交和审核通过
    return false
  
  }else{
     return true
  }
   


})()]]></hiddenScript>
  <readonlyScript><![CDATA[
//判断表单某字段不能为空
(function(){
var examState = getItemValueAsString("examState"); 
if("0".equals(examState)) {
    return false;
}else{
  return true;
}
})()
]]></readonlyScript>
  <startFlowScript><![CDATA[							]]></startFlowScript>
  <editMode>0</editMode>
  <fileNameScript><![CDATA[]]></fileNameScript>
  <iconurl></iconurl>
  <orderno>1</orderno>
  <stateToShow></stateToShow>
  <parentForm>__3tEBpOpEisePUNfVuQY</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>1</actionType>
  <actionDispatcherUrlScript><![CDATA[]]></actionDispatcherUrlScript>
  <actionSelection>0</actionSelection>
  <relatedFormId>选择</relatedFormId>
  <actionScript><![CDATA[//判断表单某字段不能为空
#include "sysfunction";
(function(){
  var aid="";
  var usid  =getWebUser().getId();
  var examId = getId();
  var subject="您参加的《国家保安员证》考试已取消！";
  var appId=getApplication();
  var appName = "考试管理";
  var cancelReason = getItemValueAsString("cancelReason"); 
  var process = getDocumentProcess();    
  var examInfoDoc=findDocument(examId); 
  println("原始examInfoDoc=============================>"+examInfoDoc);
  examInfoDoc.findItem("examState").setValue("1");
  examInfoDoc.findItem("cancelReason").setValue(cancelReason);
  var examName= examInfoDoc.findItem("examName").getValue();
  println("examName---------->"+examName);
   println("修改后examInfoDoc=============================>"+examInfoDoc);
  process.doUpdate(examInfoDoc);
 println("过去了=============================>");
  //通知这场考试下的人 考试已经被取消
  var sql1 = "select * from tlk_system_exam_person where ITEM_EXAMID = '"+examId+"'";
  var datas = queryByDSName("tms",sql1);
  if(datas!=null){
    for(var iterator = datas.iterator();iterator.hasNext();){
      var map1 = iterator.next();//取值
      var idCardNo= map1.get("ITEM_IDCARDNO");
      var sql2 = "select * from tlk_qualify_person_apply where ITEM_IDCARDNO = '"+idCardNo+"'";
      var datass = queryByDSName("tms",sql2);
      if(datass!=null){
        for(var iterators = datass.iterator();iterators.hasNext();){
          var map2 = iterators.next();//取值
          var name= map2.get("ITEM_NAME");
          var learnId= map2.get("ITEM_LEARNID");//本企业id
          var trainName= map2.get("ITEM_TRAINNAME");
          var trainId= map2.get("ITEM_TRAINID");
          var sql13 = "select ITEM_userID,ITEM_phone from baibaodunflow.vw_employee where ITEM_documentID='"+idCardNo+"'and DOMAINID='"+learnId+"'";
          var datasss = queryByDSName("obpm2",sql13);
          if(datas!="[]"){
            println("进来？？？1.4")
            var iteratora = datasss.iterator();
            if(iteratora.hasNext()){
              var map1 = iteratora.next();//取值  
              aid=map1.get("ITEM_userID")
              var content = "";
              var texts ="";
              texts += "" + name + "，您参与的由" ;
              texts += "" + trainName + "组织的《国家保安员证》考试已取消，考试名称：" ;
              texts += "" + examName + "，请等待培训学校重新安排，有任何问题可直接咨询所属保安公司或培训学校。" ;
              var appAvatar = "https://bcxin-saas-prod.obs.cn-north-1.myhuaweicloud.com:443/upload%2F2021-11-01%2F1635755240828768236.png";
              var title = "";
              var titleImg = "";
              var actionName = "";
              var actionUrl = "";
              content += "appName=" + appName + "&&;" ; //应用名称
              content += "appId=" + appId + "&&;" ;  //应用id
              content += "appAvatar=" + appAvatar + "&&;" ;  //应用图标
              content += "title=" + title + "&&;" ; //标题
              content += "titleImg=" + titleImg + "&&;" ;  //标题图标
              content += "actionName=" + actionName + "&&;" ;   //操作名称
              content += "actionUrl=" + actionUrl + "&&;" ;   //操作链接
              content += "content=" + texts + ""; 
              println("usid=====>" + usid);
              println("ids====>" + aid);
              println("subject==>" + subject);
              sendMessage(usid,aid,subject,content);
              println("考试取消站内信发送结束");
            }
          }
        }
      }
    }
  }
  var sql = "delete from tlk_system_exam_person where ITEM_EXAMID = '"+examId+"' ";
  deleteByDSName("tms",sql);
})()]]></actionScript>
  <workFlowType>0</workFlowType>
  <contextMenu>false</contextMenu>
  <showInToolbar>true</showInToolbar>
  <transpond>选择</transpond>
  <targetList>ism1EiHqAkpLpSd2Zr7|</targetList>
  <label><![CDATA[]]></label>
</activity>