<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Api id="__WhXSPzog6LXa6ceNL93">
  <name>行业考试管理-我管理的-列表数据</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <status>published</status>
  <apiGroup></apiGroup>
  <encode>UTF-8</encode>
  <requestType>post</requestType>
  <requestUrl>/train/select/teacher/train</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 class.item_train_teacher like '%"+userid+"%' "
  var jsonStr = getParameter("_content");
  if(isNotNull(jsonStr)){
    var json = JSON.parse(jsonStr);
    var plan = json["plan"]
    if(isNotNull(plan)){
      whereStr+=" and plan.item_plan like '%"+plan+"%' "
    }
    var status = json["status"]
    if(isNotNull(status)){
      if("未开始".equals(status)){
        whereStr+=" and DATE_FORMAT(now(), '%Y-%m-%d') < DATE_FORMAT(plan.item_train_start_time, '%Y-%m-%d') "
      }else if("进行中".equals(status)){
        whereStr+=" and DATE_FORMAT(now(), '%Y-%m-%d') >= DATE_FORMAT(plan.item_train_start_time, '%Y-%m-%d') and DATE_FORMAT(now(), '%Y-%m-%d') <= DATE_FORMAT(plan.item_train_end_time, '%Y-%m-%d') "
      }else if("已结束".equals(status)){
        whereStr+=" and DATE_FORMAT(now(), '%Y-%m-%d') > DATE_FORMAT(plan.item_train_end_time, '%Y-%m-%d') "
      }

    }
  }

  var sql="select '"+getDomainid()+"' as domainid,"+
      "class.id,DATE_FORMAT(class.created, '%Y-%m-%d') as created,"+
      "plan.item_plan,"+//培训计划
      "type.item_point_type,"+//培训类型
      "type.id as item_point_type_id,"+//培训类型id
      "class.item_classroom_type,"+//教室类型
      "class.item_class_name,"+//班级名称
      "classroom.item_longitude,"+//经度
      "classroom.item_latitude,"+//纬度
      "classroom.item_range,"+//有效范围
      "DATE_FORMAT(plan.item_train_start_time, '%Y-%m-%d') as item_train_start_time,"+//培训开始时间
      "DATE_FORMAT(plan.item_train_end_time, '%Y-%m-%d') as item_train_end_time,"+//培训结束时间
      "case when DATE_FORMAT(now(), '%Y-%m-%d') < DATE_FORMAT(plan.item_train_start_time, '%Y-%m-%d') then '未开始' when DATE_FORMAT(now(), '%Y-%m-%d') >= DATE_FORMAT(plan.item_train_start_time, '%Y-%m-%d') and DATE_FORMAT(now(), '%Y-%m-%d') <= DATE_FORMAT(plan.item_train_end_time, '%Y-%m-%d')  then '进行中' when DATE_FORMAT(now(), '%Y-%m-%d') > DATE_FORMAT(plan.item_train_end_time, '%Y-%m-%d') then '已结束' end as status, "+
  "plan.item_domain_name as item_train_domain_name,"+//培训单位
    "class.id as item_class_id,"+//教室id
    "plan.id as item_plan_id "+//计划id
    "from tlk_train_class_info class "+
    "inner join tlk_train_classroom classroom on classroom.id=class.item_classroom_id "+
    "inner join tlk_train_plan plan on plan.id=class.item_plan_id "+
    "left join tlk_train_point_type type on type.id = class.item_point_type " + whereStr+
    " order by class.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>