<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Api id="__dqwseKicZ6utZIfv9lk">
  <name>行业考试管理-我的考试-成绩录入</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <status>published</status>
  <apiGroup></apiGroup>
  <encode>UTF-8</encode>
  <requestType>post</requestType>
  <requestUrl>/train/insert/exam/score</requestUrl>
  <tags></tags>
  <responseType>json</responseType>
  <responseScript><![CDATA[(function () {
  var result = new Packages.java.util.HashMap(); //创建指定类对象
  var jsonStr = getParameter("_content");
  var domainid = getDomainid();
  var domainprocess = getDomainProcess();//获取企业域对象 
  var domainDao=domainprocess.doView(domainid);
  var domainName = domainDao.getName();
  var userName= getWebUser().getName();
  var userid = getWebUser().getId();
  var process = getDocumentProcess();
  if(isNotNull(jsonStr)){
    var json = JSON.parse(jsonStr);
    var person_id = json["id"];
    var written_score = json["written_score"];//分数
    var written_record = json["written_record"];//理论做题记录
    var process = getDocumentProcess();     
    var formService = getFormProcess();
    var subform = formService.doView("__FrXqhdaYJRdlagVRwcG");
    var logdoc = process.doNew(subform,getWebUser(),createParamsTable());
    logdoc.findItem("body_info").setValue(jsonStr)
    logdoc.findItem("user_name").setValue(userName)
    logdoc.findItem("user_id").setValue(userid)
    logdoc.findItem("exam_type").setValue(1)
    logdoc.findItem("remark").setValue("person_id="+person_id+";written_score="+written_score)
    process.doCreate(logdoc);
    var personDoc=findDocument(person_id);
    personDoc.findItem("written_score").setValue(written_score)
    personDoc.findItem("written_record").setValue(written_record)
    personDoc.findItem("has_written_score").setValue('1')
    var has_operate_score = personDoc.findItem("has_operate_score").getValue()
    var operate_score = personDoc.findItem("operate_score").getValue()
    if(parseDouble(written_score)>=60){
      if("1".equals(has_operate_score)&&parseDouble(operate_score)>=60){
        personDoc.findItem("exam_info").setValue('1')
      }
    }else{
      personDoc.findItem("exam_info").setValue('0')
    }


    process.doUpdate(personDoc);
    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>