<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Api id="__nfRDdxHWyrJ3G5pQDlT">
  <name>行业考试管理-我管理的-学员签到</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <status>published</status>
  <apiGroup></apiGroup>
  <encode>UTF-8</encode>
  <requestType>post</requestType>
  <requestUrl>/train/insert/teacher/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_class_id = json["class_id"]
    var resuilt=json["resuilt"]
    var personDoc=findDocument(person_id);
    var person_class_id=personDoc.findItem("class_id").getValue();
    if(!teacher_class_id.equals(person_class_id)){
      result.put("code","500");
      result.put("msg","当前班级与学员签到的班级不一致，请核对！");
      result.put("state", false);
      return result;
    }
    var process = getDocumentProcess();
    var formProcess = getFormProcess();
    var personSignInfo = formProcess.doView("__76KsQBpAITtCResDauk");
    var personSignInfoDoc = process.doNew(personSignInfo,getWebUser(),createParamsTable());
    var class_id = personDoc.findItem("class_id").getValue()//班级id
    personSignInfoDoc.addStringItem("class_id",class_id);
    var classDoc=findDocument(class_id);//获取班级信息
    var classroom_name=classDoc.findItem("classroom_name").getValue()//教室名称
    var classroom_id=classDoc.findItem("classroom_id").getValue()//教室id
    personSignInfoDoc.addStringItem("classroom_name",classroom_name);
    personSignInfoDoc.addStringItem("classroom_id",classroom_id);
    var point_type_id = personDoc.findItem("point_type").getValue()//培训类型id
    var pointTypeDoc=findDocument(point_type_id);//获取培训类型文档
    var point_type=pointTypeDoc.findItem("point_type").getValue()//培训类型名称
    personSignInfoDoc.addStringItem("point_type",point_type);
    personSignInfoDoc.addStringItem("point_type_id",point_type_id);
    var classroom_type = personDoc.findItem("classroom_type").getValue()//教室类型
    personSignInfoDoc.addStringItem("classroom_type",classroom_type);
    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);
    var person_sign_status=personDoc.findItem("sign_status").getValue()
    if("0".equals(person_sign_status)&&"1".equals(resuilt)){
    personDoc.findItem("sign_status").setValue('1')//签到状态
      process.doUpdate(personDoc); 
    }
    process.doCreate(personSignInfoDoc); 
    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;
  }
})()]]></responseScript>
</Api>