Ver código fonte

导出注册老师列表

shenhao 3 anos atrás
pai
commit
0532d9fabe

+ 37 - 0
src/main/java/com/ssj/api/controller/ApiManagerTeacherController.java

@@ -530,6 +530,43 @@ public class ApiManagerTeacherController extends BaseController {
         return response;
     }
 
+    @RequestMapping(value = "/exportRegisterList", method = RequestMethod.GET)
+    @ApiOperation(value = "导出注册老师列表",  notes = "导出注册老师列表")
+    @ResponseBody
+    public void exportRegisterList(@RequestParam(name = "accessToken") String accessToken,String searchKey) {
+        ServletOutputStream os = null;
+        try {
+            String libName="注册老师";
+            //获得输出流
+            os = response.getOutputStream();
+            //清空输出流
+            response.reset();
+            exportExcelHead(response,libName);
+            Map<String,Object> params = new HashMap<>(2);
+            params.put("searchKey",searchKey);
+            List<Map<String,Object>> list = teacherEnrollment.findRegisterList(params);
+            String head = "姓名|name;电话|phone_number;类型|type;登记时间|create_time;";
+            List<ExcelExportEntity> entity = addEntity(head);
+            //把我们构造好的bean对象放到params就可以了
+            Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(libName, libName, ExcelType.XSSF), entity,
+                    list);
+            workbook.write(os);
+        }catch (IOException e) {
+            logger.error("异常", e);
+        } catch (Exception e) {
+            logger.error("导出注册老师列表异常", e);
+        }finally {
+            if(os != null){
+                try {
+                    os.flush();
+                    os.close();
+                } catch (IOException e) {
+                    logger.error("异常", e);
+                }
+            }
+        }
+    }
+
     /**
      * ----------------解析文档相关功能-----------------------
      */

+ 7 - 0
src/main/java/com/ssj/statistics/dao/IStatisticsQueryDao.java

@@ -43,4 +43,11 @@ public interface IStatisticsQueryDao {
      * @return
      */
     List<TeacherSalarysVO> findOnlineList(String month);
+
+    /**
+     * 查询导出老师列表
+     * @param params
+     * @return
+     */
+    List<Map<String, Object>> findRegisterList(Map<String, Object> params);
 }

+ 17 - 0
src/main/java/com/ssj/statistics/dao/impl/StatisticsQueryImpl.java

@@ -242,6 +242,23 @@ public class StatisticsQueryImpl implements IStatisticsQueryDao {
     }
 
     @Override
+    public List<Map<String, Object>> findRegisterList(Map<String, Object> params) {
+        StringBuffer sql = new StringBuffer();
+        List<Object> queryParams = new ArrayList<>();
+        sql.append("SELECT t.name,t.phone_number,\n");
+        sql.append("case when t.type = 1 then '常规兼职' when t.type=2 then '高校合作' else '远程实习' end as type, \n");
+        sql.append(" DATE_FORMAT(t.create_time,'%Y.%m.%d %H.%m') as create_time \n");
+        sql.append(" from tb_teacher_enrollment t \n");
+        if(params.get("searchKey")!=null && !"".equals(params.get("searchKey"))){
+            sql.append(" where t.name like concat('%',?,'%') \n");
+            sql.append(" or  t.phone_number like concat('%',?,'%') \n");
+            queryParams.add(params.get("searchKey"));
+            queryParams.add(params.get("searchKey"));
+        }
+        return dao.findMap(sql.toString(),queryParams.toArray());
+    }
+
+    @Override
     public List<CheckDetailVO> checkDetailList(String homeworkId) {
         StringBuffer sql = new StringBuffer();
         List<Object> queryParams = new ArrayList<>();

+ 7 - 0
src/main/java/com/ssj/statistics/service/ITeacherEnrollment.java

@@ -18,4 +18,11 @@ public interface ITeacherEnrollment extends BaseService<TeacherEnrollment,String
      * @param datas
      */
     void registerTeacherImport(List<Map<String, String>> datas);
+
+    /**
+     * 查询导出列表
+     * @param params
+     * @return
+     */
+    List<Map<String, Object>> findRegisterList(Map<String, Object> params);
 }

+ 9 - 0
src/main/java/com/ssj/statistics/service/impl/TeacherEnrollmentServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ssj.statistics.service.impl;
 
 import com.ssj.framework.core.common.service.BaseServiceImpl;
+import com.ssj.statistics.dao.IStatisticsQueryDao;
 import com.ssj.statistics.dao.ITeacherEnrollmentDao;
 import com.ssj.statistics.entity.TeacherEnrollment;
 import com.ssj.statistics.service.ITeacherEnrollment;
@@ -25,6 +26,9 @@ public class TeacherEnrollmentServiceImpl extends BaseServiceImpl<TeacherEnrollm
     @Autowired
     private ITeacherEnrollmentDao dao;
 
+    @Autowired
+    private IStatisticsQueryDao queryDao;
+
     @Override
     public PagingAndSortingRepository<TeacherEnrollment, String> getDao() {
         return dao;
@@ -48,4 +52,9 @@ public class TeacherEnrollmentServiceImpl extends BaseServiceImpl<TeacherEnrollm
             dao.save(vo);
         }
     }
+
+    @Override
+    public List<Map<String, Object>> findRegisterList(Map<String, Object> params) {
+        return queryDao.findRegisterList(params);
+    }
 }