<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Api id="__s2Uwg4qfkIdXpczBxzb">
  <name>第三方完成学习</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <status>published</status>
  <apiGroup></apiGroup>
  <encode>UTF-8</encode>
  <requestType>post</requestType>
  <requestUrl>/train/over</requestUrl>
  <tags></tags>
  <responseType>json</responseType>
  <responseScript><![CDATA[(function () {
  var result = new Packages.java.util.HashMap(); //创建指定类对象
  var jsonStr = getParameter("_content");
  if(isNotNull(jsonStr)){
    var json = JSON.parse(jsonStr);
    var idCard = json["idCard"];
    if(isNotNull(idCard)){
      var selectByIdcard="select id,item_securityId from tlk_qualify_person_apply where item_idCardNo ='"+idCard+"' and item_applyStatus='0' and ITEM_organizationId='"+getDomainid()+"' "
      var datasByIdcard = queryByDSName("tms",selectByIdcard);
      if(datasByIdcard.size()>0){
        for(var iterator = datasByIdcard.iterator();iterator.hasNext();){
          var map1 = iterator.next();//取值
          var applyId= map1.get("id");
          var person_id= map1.get("item_securityId");
        }
        var checksql="select 1 from tlk_orther_over_record where item_apply_id='"+applyId+"'"
        var datasBycheck = queryByDSName("tms",checksql);
        if(datasBycheck.size()>0){
          result.put("msg", "请勿重复提交！");
          result.put("code", "-1");
          result.put("type", "update");
          return result;
        }
        var process = getDocumentProcess();
        var formProcess = getFormProcess();            
        var personInfo = formProcess.doView("__3jlpgtc2kfejdiqfyl8");
        var personDoc = process.doNew(personInfo,getWebUser(),createParamsTable()); 
        personDoc.addStringItem("idcard_number",idCard);
        personDoc.addStringItem("apply_id",applyId);
        process.doCreate(personDoc); 
        result.put("msg", "记录保存成功");
        result.put("code", "1");
        result.put("type", "update");
        return result;
      }else{
        result.put("msg", "未找到该人员身份证的报名记录！");
        result.put("code", "-1");
        result.put("type", "update");
        return result;
      }
    }else{
      result.put("msg", "身份证为必传字段！");
      result.put("code", "-1");
      result.put("type", "update");
      return result;
    }
  }
  result.put("msg", "参数不能是空");
  result.put("code", "-1");
  result.put("type", "update");
  return result;

})()]]></responseScript>
</Api>