<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Api id="__1VooOCFTf07benlGYuT">
  <name>行业考试管理-我的监考-学员签到</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <status>published</status>
  <apiGroup></apiGroup>
  <encode>UTF-8</encode>
  <requestType>post</requestType>
  <requestUrl>/train/insert/exam/sign</requestUrl>
  <tags></tags>
  <responseType>json</responseType>
  <responseScript><![CDATA[(function(){
  var result = new Packages.java.util.HashMap();
  var domainid = getDomainid();
  var domainprocess = getDomainProcess();//获取企业域对象 
  var domainDao=domainprocess.doView(domainid);
  var domainName = domainDao.getName();
  var userName= getWebUser().getName();
  var userid = getWebUser().getId();
  var jsonStr = getParameter("_content");
  if(isNotNull(jsonStr)){
    var json = JSON.parse(jsonStr);
    var person_id = json["person_id"]
    var teacher_exam_id = json["exam_id"]
    var resuilt=json["resuilt"]
    var personDoc=findDocument(person_id);
    var person_exam_id=personDoc.findItem("exam_id").getValue();
    if(!teacher_exam_id.equals(person_exam_id)){
      result.put("code","500");
      result.put("msg","当前考试与学员签到的考试不一致，请核对！");
      result.put("state", false);
      return result;
    }
    var process = getDocumentProcess();
    var formProcess = getFormProcess();
    var personSignInfo = formProcess.doView("__hSBmYpM2yBrECc2U0lG");
    var personSignInfoDoc = process.doNew(personSignInfo,getWebUser(),createParamsTable());
    var exam_id = personDoc.findItem("exam_id").getValue()//考试id
    personSignInfoDoc.addStringItem("exam_id",exam_id);
    var person_name = personDoc.findItem("person_name").getValue()//人员姓名
    var employee_id = personDoc.findItem("employee_id").getValue()//人员职员id
    var idcard_no = personDoc.findItem("idcard_no").getValue()//人员身份证
    var telephone = personDoc.findItem("telephone").getValue()//人员手机号
    personSignInfoDoc.addStringItem("person_name",person_name);
    personSignInfoDoc.addStringItem("person_id",person_id);
    personSignInfoDoc.addStringItem("employee_id",employee_id);
    personSignInfoDoc.addStringItem("idcard_no",idcard_no);
    personSignInfoDoc.addStringItem("telephone",telephone);
    personSignInfoDoc.addStringItem("resuilt",resuilt);
    personSignInfoDoc.addDateItem("sign_date",getToday());
    personSignInfoDoc.addStringItem("sign_teacher",userName);
    personSignInfoDoc.addStringItem("sign_teacher_id",userid);
    personSignInfoDoc.addStringItem("domain_name",domainName);
    personSignInfoDoc.addStringItem("domain_id",domainid);
    personDoc.findItem("written_sign_status").setValue(resuilt)
    process.doUpdate(personDoc);
    process.doCreate(personSignInfoDoc); 
    if("1".equals(resuilt)){
    result.put("code","200");
    result.put("msg","签到成功！");
    result.put("state", true);
    return result;
    }else{
    result.put("code","500");
    result.put("msg","签到失败！");
    result.put("state", false);
    return result;
    }
    
  }else{
    result.put("code","500");
    result.put("msg","请求体不能为空！");
    result.put("state", false);
    return result;
  }
})()]]></responseScript>
</Api>