<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Api id="__WaCemGYIgYjwn2scoAR">
  <name>修改人员节信息</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <status>published</status>
  <apiGroup></apiGroup>
  <encode>UTF-8</encode>
  <requestType>post</requestType>
  <requestUrl>/lesson/sectionProgress</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 new_idcard = json["new_idcard"];
    var LEARNSTYLE = json["LEARNSTYLE"];
    var new_isEnd = json["new_isEnd"];
    var new_sectionId = json["new_sectionId"];//节ID
    Packages.java.lang.System.err.println("new_idcard "+new_idcard);//输出
    Packages.java.lang.System.err.println("new_sectionId "+new_sectionId);//输出
    if (isNotNull(new_sectionId) && isNotNull(new_idcard)) {
      var sql1 = "select '" + getDomainid() + "' as domainid,id from tlk_sectionInfo where ITEM_NEW_IDCARD='" + new_idcard + "' and ifnull(ITEM_ISSTUDY,'') != '1' and ITEM_NEW_SECTIONID='" + new_sectionId + "' ";
      var datas = queryByDSName("tms", sql1);
      //if (datas.size() > 0) {
      if(!"[]".equals(datas)){  
        for (var iterator = datas.iterator(); iterator.hasNext();) {
          var map1 = iterator.next();//取值
          var docids = map1.get("id");
        }
        //var sqlu = "update tlk_sectioninfo set item_isend = '"+new_isEnd+"' where id = '"+docids+"'"
        var process = getDocumentProcess();
        if(isNotNull(docids)){
          var Info = findDocument(docids);
          for (var key in json) {
            var value = json[key];
            if(!isNotNull(Info.findItem(key))){//如果为null就进入if
              Packages.java.lang.System.err.println("key "+key);//输出key
              result.put(key, Info.findItem(key));
               //continue;//跳过当前
            }else {
              Packages.java.lang.System.err.println("key2 "+key);//输出key
              Info.findItem(key).setValue(value);
            }

          }
          process.doUpdate(Info);
        }
        result.put("type", "update");
      } else {
        var fromid="__NIJTgebWnotllqo9ZS5";
        var process = getDocumentProcess();
        var formProcess = getFormProcess();
        var subform = formProcess.doView(fromid);
        var Info = process.doNew(subform, getWebUser(), createParamsTable());
        for (var key in json) {
          var value = json[key];
          if(!isNotNull(Info.findItem(key))){//如果为null就进入if
            Packages.java.lang.System.err.println("key "+key);//输出key
            result.put(key, Info.findItem(key));
            //continue;//跳过当前
          }else {
            Packages.java.lang.System.err.println("key2 "+key);//输出key          
            Info.findItem(key).setValue(value);
          }

        }
        result.put("type", "insert");
        process.doCreate(Info);
      }
      result.put("msg", "success");
      result.put("code", "0");
    } else {
      result.put("code", "-1");
      result.put("msg", "身份证和节id不能为空");
    }}else{
      result.put("code", "-1");
      result.put("msg", "请先包体传值再执行操作！");
    }
  return result;
})()]]></responseScript>
</Api>