<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Api id="__I8U1nhwCnwLtIVNNQnS">
  <name>行业考试管理-我的监考-列表数据</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <status>published</status>
  <apiGroup></apiGroup>
  <encode>UTF-8</encode>
  <requestType>post</requestType>
  <requestUrl>/train/select/teacher/exam</requestUrl>
  <tags></tags>
  <responseType>json</responseType>
  <responseScript><![CDATA[(function(){
  var result = new Packages.java.util.HashMap();
  var domainid = getDomainid();
  var userName= getWebUser().getName();
  var userid = getWebUser().getId();
  var whereStr= " where exam.item_teacher like '%"+userid+"%' "
  var jsonStr = getParameter("_content");
  if(isNotNull(jsonStr)){
    var json = JSON.parse(jsonStr);
    var exam_name = json["exam_name"]
    if(isNotNull(exam_name)){
      whereStr+=" and exam.item_exam_name like '%"+exam_name+"%' "
    }
    var status = json["status"]
    if(isNotNull(status)){
      if("未开始".equals(status)){
        whereStr+=" and DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') < DATE_FORMAT(exam.item_computer_start_date, '%Y-%m-%d %H:%i:%s') "
      }else if("进行中".equals(status)){
        whereStr+=" and DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') >= DATE_FORMAT(exam.item_computer_start_date, '%Y-%m-%d %H:%i:%s') and DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') <= DATE_FORMAT(exam.item_computer_end_date, '%Y-%m-%d %H:%i:%s') "
      }else if("已结束".equals(status)){
        whereStr+=" and DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') > DATE_FORMAT(exam.item_computer_end_date, '%Y-%m-%d %H:%i:%s') "
      }

    }
  }

  var sql="select '"+getDomainid()+"' as domainid,"+
      "exam.id,DATE_FORMAT(exam.created, '%Y-%m-%d %H:%i:%s') as created,"+
      "exam.item_plan,"+//培训计划
      "exam.item_paper_id,"+//试卷id
     "exam.item_computer_address,"+//考试地址
      "exam.item_exam_name,"+//考试名称
       "CASE "+
        " exam.ITEM_exam_kind "+
        "  		WHEN '1' THEN"+
        "  '补考' "+
        "		  WHEN '0' THEN"+
        "		  '日常考试' "+
        "  END ITEM_exam_kind," + //考试类型
     "exam.item_attention,"+//注意事项
      "examination.item_longitude,"+//经度
      "examination.item_latitude,"+//纬度
      "examination.item_range,"+//有效范围
      "DATE_FORMAT(exam.item_computer_start_date, '%Y-%m-%d %H:%i:%s') as item_computer_start_date,"+//培训开始时间
      "DATE_FORMAT(exam.item_computer_end_date, '%Y-%m-%d %H:%i:%s') as item_computer_end_date,"+//培训结束时间
      "case when DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') < DATE_FORMAT(exam.item_computer_start_date, '%Y-%m-%d %H:%i:%s') then '未开始' when DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') >= DATE_FORMAT(exam.item_computer_start_date, '%Y-%m-%d %H:%i:%s') and DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') <= DATE_FORMAT(exam.item_computer_end_date, '%Y-%m-%d %H:%i:%s')  then '进行中' when DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') > DATE_FORMAT(exam.item_computer_end_date, '%Y-%m-%d %H:%i:%s') then '已结束' end as status, "+
    "exam.id as item_exam_id "+//考试id
    "from  tlk_train_exam exam "+
    "inner join tlk_train_examination_room examination on examination.id=exam.item_examination_id "+whereStr+
    " order by exam.created desc "
  var datas = queryByDSName("tms",sql); 
  result.put("data",datas);
  result.put("code","200");
  result.put("msg","OK");
  result.put("state", true);
  return result;

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