Sfoglia il codice sorgente

人员企业招聘信息导出功能

yanliming 1 anno fa
parent
commit
fa7c378a19

+ 97 - 11
web/src/main/java/com/jpsoft/employment/modules/base/controller/EnterpriseInfoController.java

@@ -14,6 +14,8 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.mapping.ResultMap;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -205,38 +207,122 @@ public class EnterpriseInfoController {
 
     @ApiOperation(value = "列表")
     @RequestMapping(value = "pageList", method = RequestMethod.POST)
-    public MessageResult<Map> pageList(
+    public MessageResult<Object> pageList(
             String name,
             @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
             @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+            @RequestParam(value = "exportFlag", defaultValue = "false") Boolean exportFlag,
             HttpServletRequest request) {
         String subject = (String) request.getAttribute("subject");
 
         //当前用户ID
         System.out.println(subject);
 
-        MessageResult<Map> msgResult = new MessageResult<>();
+        MessageResult<Object> msgResult = new MessageResult<>();
 
-        Map<String, Object> searchParams = new HashMap<>();
+        try {
 
-        List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("create_time", "desc"));
+            Map<String, Object> searchParams = new HashMap<>();
 
-        if (StringUtils.isNotEmpty(name)) {
-            searchParams.put("name", "%" + name + "%");
-        }
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time", "desc"));
 
+            if (StringUtils.isNotEmpty(name)) {
+                searchParams.put("name", "%" + name + "%");
+            }
 
-        Page<EnterpriseInfo> page = enterpriseInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
 
+            Page<EnterpriseInfo> page = enterpriseInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
 
-        msgResult.setResult(true);
-        msgResult.setData(PojoUtils.pageWrapper(page));
+            List<Map> mapList = new ArrayList<>();
+
+            for (EnterpriseInfo enterpriseInfo : page) {
+                Map map = new HashMap();
+                map.put("id", enterpriseInfo.getId());
+                map.put("name", enterpriseInfo.getName());
+                map.put("address", enterpriseInfo.getAddress());
+                map.put("licenseImage", enterpriseInfo.getLicenseImage());
+                map.put("contactsPersonId", enterpriseInfo.getContactsPersonId());
+
+                String statusN;
+                if ("1".equals(enterpriseInfo.getStatus())) {
+                    statusN = "已认证";
+                } else {
+                    statusN = "未认证";
+                }
+
+                map.put("status", enterpriseInfo.getStatus());
+                map.put("statusN", statusN);
+
+                mapList.add(map);
+            }
+
+            if (exportFlag) {
+                String filePath = exportXls(mapList);
+                msgResult.setData(filePath);
+            } else {
+                Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
+                dataMap.put("data", mapList);
+                msgResult.setData(dataMap);
+            }
+
+            msgResult.setResult(true);
+        }
+        catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+            msgResult.setResult(false);
+        }
 
         return msgResult;
     }
 
 
+    private String exportXls(List<Map> mapList) {
+        String downloadUrl = "";
+
+        Workbook workbook = new HSSFWorkbook();
+        Sheet sheet = workbook.createSheet();
+
+        //表头
+        Row rowTitle = sheet.createRow(0);
+
+        String[] titles = new String[]{"序号", "企业名称", "企业地址", "企业联系人", "认证状态"};
+
+        for (int i = 0; i < titles.length; i++) {
+            Cell cell = rowTitle.createCell(i);
+            cell.setCellValue(titles[i]);
+        }
+
+        for (int i = 0; i < mapList.size(); i++) {
+            Map<String, Object> map = mapList.get(i);
+
+            Row row = sheet.createRow(i + 1);
+
+            int colIndex = 0;
+            row.createCell(colIndex++).setCellValue(i + 1);
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("name"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("address"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("contactsPersonId"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("statusN"), ""));
+        }
+
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+
+        try {
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            downloadUrl = OSSUtil.upload(ossConfig, "EnterpriseList", "企业列表.xls", input);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+        }
+
+        return downloadUrl;
+    }
+
+
     @ApiOperation(value = "列表")
     @RequestMapping(value = "list", method = RequestMethod.POST)
     public MessageResult<List<EnterpriseInfo>> list(

+ 185 - 98
web/src/main/java/com/jpsoft/employment/modules/base/controller/PersonInfoController.java

@@ -18,6 +18,8 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -50,11 +52,11 @@ public class PersonInfoController {
 
     @Autowired
     private OSSConfig ossConfig;
-	
-	
-	@ApiOperation(value="创建空记录")
+
+
+    @ApiOperation(value = "创建空记录")
     @GetMapping("create")
-    public MessageResult<PersonInfo> create(){
+    public MessageResult<PersonInfo> create() {
         MessageResult<PersonInfo> msgResult = new MessageResult<>();
 
         PersonInfo personInfo = new PersonInfo();
@@ -65,18 +67,18 @@ public class PersonInfoController {
         return msgResult;
     }
 
-    @ApiOperation(value="添加信息")
+    @ApiOperation(value = "添加信息")
     @PostMapping("add")
-    public MessageResult<PersonInfo> add(@RequestBody PersonInfo personInfo,@RequestAttribute String subject){
+    public MessageResult<PersonInfo> add(@RequestBody PersonInfo personInfo, @RequestAttribute String subject) {
         MessageResult<PersonInfo> msgResult = new MessageResult<>();
 
         try {
             personInfo.setId(UUID.randomUUID().toString());
-			personInfo.setDelFlag(false);
+            personInfo.setDelFlag(false);
             personInfo.setCreateBy(subject);
             personInfo.setCreateTime(new Date());
             DES3 des3 = new DES3();
-            personInfo.setPassword(des3.encrypt(jwtSecret,"123456"));
+            personInfo.setPassword(des3.encrypt(jwtSecret, "123456"));
             personInfo.setStatus("0");
 
             int affectCount = personInfoService.insert(personInfo);
@@ -88,9 +90,8 @@ public class PersonInfoController {
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库添加失败");
             }
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -99,9 +100,9 @@ public class PersonInfoController {
         return msgResult;
     }
 
-    @ApiOperation(value="获取信息")
+    @ApiOperation(value = "获取信息")
     @GetMapping("edit/{id}")
-    public MessageResult<PersonInfo> edit(@PathVariable("id") String id){
+    public MessageResult<PersonInfo> edit(@PathVariable("id") String id) {
         MessageResult<PersonInfo> msgResult = new MessageResult<>();
 
         try {
@@ -114,9 +115,8 @@ public class PersonInfoController {
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库不存在该记录!");
             }
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -125,15 +125,15 @@ public class PersonInfoController {
         return msgResult;
     }
 
-    @ApiOperation(value="更新用户")
+    @ApiOperation(value = "更新用户")
     @PostMapping("update")
-    public MessageResult<PersonInfo> update(@RequestBody PersonInfo personInfo,@RequestAttribute String subject){
+    public MessageResult<PersonInfo> update(@RequestBody PersonInfo personInfo, @RequestAttribute String subject) {
         MessageResult<PersonInfo> msgResult = new MessageResult<>();
 
         try {
-		    personInfo.setUpdateBy(subject);
+            personInfo.setUpdateBy(subject);
             personInfo.setUpdateTime(new Date());
-		
+
             int affectCount = personInfoService.update(personInfo);
 
             if (affectCount > 0) {
@@ -143,9 +143,8 @@ public class PersonInfoController {
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库更新失败");
             }
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -154,19 +153,19 @@ public class PersonInfoController {
         return msgResult;
     }
 
-    @ApiOperation(value="删除用户")
+    @ApiOperation(value = "删除用户")
     @PostMapping("delete/{id}")
-    public MessageResult<PersonInfo> delete(@PathVariable("id") String id,@RequestAttribute String subject){
+    public MessageResult<PersonInfo> delete(@PathVariable("id") String id, @RequestAttribute String subject) {
         MessageResult<PersonInfo> msgResult = new MessageResult<>();
 
         try {
-			
-			PersonInfo personInfo = personInfoService.get(id);
+
+            PersonInfo personInfo = personInfoService.get(id);
             personInfo.setDelFlag(true);
             personInfo.setUpdateBy(subject);
             personInfo.setUpdateTime(new Date());
-			
-			int affectCount = personInfoService.update(personInfo);
+
+            int affectCount = personInfoService.update(personInfo);
 
             if (affectCount > 0) {
                 msgResult.setResult(true);
@@ -174,9 +173,8 @@ public class PersonInfoController {
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库删除失败");
             }
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -186,9 +184,9 @@ public class PersonInfoController {
     }
 
 
-    @ApiOperation(value="批量删除")
+    @ApiOperation(value = "批量删除")
     @PostMapping("batchDelete")
-    public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
+    public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject) {
         MessageResult<Integer> msgResult = new MessageResult<>();
 
         try {
@@ -210,9 +208,8 @@ public class PersonInfoController {
                 msgResult.setResult(false);
                 msgResult.setMessage("删除失败");
             }
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -221,56 +218,105 @@ public class PersonInfoController {
         return msgResult;
     }
 
-    @ApiOperation(value="列表")
-    @RequestMapping(value = "pageList",method = RequestMethod.POST)
-    public MessageResult<Map> pageList(
-            String realName,String phone,String idCard,String status,
-            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
-            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
-            HttpServletRequest request){
-        String subject = (String)request.getAttribute("subject");
+    @ApiOperation(value = "列表")
+    @RequestMapping(value = "pageList", method = RequestMethod.POST)
+    public MessageResult<Object> pageList(
+            String realName, String phone, String idCard, String status,
+            @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
+            @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+            @RequestParam(value = "exportFlag", defaultValue = "false") Boolean exportFlag,
+            HttpServletRequest request) {
+        String subject = (String) request.getAttribute("subject");
 
         //当前用户ID
         System.out.println(subject);
 
-        MessageResult<Map> msgResult = new MessageResult<>();
+        MessageResult<Object> msgResult = new MessageResult<>();
 
-        Map<String,Object> searchParams = new HashMap<>();
+        try {
 
-        List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("create_time","desc"));
+            Map<String, Object> searchParams = new HashMap<>();
 
-        if (StringUtils.isNotEmpty(realName)) {
-            searchParams.put("realName",realName + "%");
-        }
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time", "desc"));
 
-        if (StringUtils.isNotEmpty(phone)) {
-            searchParams.put("phone",phone + "%");
-        }
-        if (StringUtils.isNotEmpty(idCard)) {
-            searchParams.put("idCard",idCard + "%");
-        }
-        if (StringUtils.isNotEmpty(status)) {
-            searchParams.put("status",status);
-        }
+            if (StringUtils.isNotEmpty(realName)) {
+                searchParams.put("realName", realName + "%");
+            }
+
+            if (StringUtils.isNotEmpty(phone)) {
+                searchParams.put("phone", phone + "%");
+            }
+            if (StringUtils.isNotEmpty(idCard)) {
+                searchParams.put("idCard", idCard + "%");
+            }
+            if (StringUtils.isNotEmpty(status)) {
+                searchParams.put("status", status);
+            }
+
+            Page<PersonInfo> page = personInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
+
+            List<Map> mapList = new ArrayList<>();
+
+            for (PersonInfo personInfo : page) {
+                Map map = new HashMap();
+                map.put("id", personInfo.getId());
+                map.put("phone", personInfo.getPhone());
+                map.put("realName", personInfo.getRealName());
+                map.put("idCard", personInfo.getIdCard());
+                map.put("gender", personInfo.getGender());
+                String genderN = "";
+                if (StringUtils.isNotEmpty(personInfo.getGender())) {
+                    if (personInfo.getGender().equals("0")) {
+                        genderN = "女";
+                    } else {
+                        genderN = "男";
+                    }
+                }
+                map.put("genderN", genderN);
+                map.put("age", personInfo.getAge());
+
+                String statusN;
+                if ("1".equals(personInfo.getStatus())) {
+                    statusN = "已认证";
+                } else {
+                    statusN = "未认证";
+                }
 
-        Page<PersonInfo> page = personInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+                map.put("status", personInfo.getStatus());
+                map.put("statusN", statusN);
 
+                mapList.add(map);
+            }
 
-        msgResult.setResult(true);
-        msgResult.setData(PojoUtils.pageWrapper(page));
+
+            if (exportFlag) {
+                String filePath = exportXls(mapList);
+                msgResult.setData(filePath);
+            } else {
+                Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
+                dataMap.put("data", mapList);
+                msgResult.setData(dataMap);
+            }
+
+            msgResult.setResult(true);
+
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+            msgResult.setResult(false);
+        }
 
         return msgResult;
-    }
 
+    }
 
 
-    @ApiOperation(value="导入人员")
+    @ApiOperation(value = "导入人员")
     @PostMapping("importXls")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "uploadFile",value = "上传文件", required = true,paramType="form", dataType = "__file")
+            @ApiImplicitParam(name = "uploadFile", value = "上传文件", required = true, paramType = "form", dataType = "__file")
     })
-    public MessageResult<String> importXls(MultipartFile uploadFile, @RequestAttribute String subject){
+    public MessageResult<String> importXls(MultipartFile uploadFile, @RequestAttribute String subject) {
         MessageResult<String> msgResult = new MessageResult<>();
 
         try {
@@ -284,7 +330,7 @@ public class PersonInfoController {
 
             int count = sheet1.getLastRowNum();
 
-            for(int rowIndex=1 ; rowIndex<=count; rowIndex++){
+            for (int rowIndex = 1; rowIndex <= count; rowIndex++) {
                 try {
 
                     String userName = poiUtils.getCellValue(sheetIndex, rowIndex, 0).toString().replace(" ", "");
@@ -293,31 +339,31 @@ public class PersonInfoController {
 
                     String phone = poiUtils.getCellValue(sheetIndex, rowIndex, 2).toString().replace(" ", "");
 
-                    String idCard = poiUtils.getCellValue(sheetIndex,rowIndex,3).toString().replace(" ","");
+                    String idCard = poiUtils.getCellValue(sheetIndex, rowIndex, 3).toString().replace(" ", "");
 
-                    String enterpriseName = poiUtils.getCellValue(sheetIndex,rowIndex,4).toString().replace(" ","");
+                    String enterpriseName = poiUtils.getCellValue(sheetIndex, rowIndex, 4).toString().replace(" ", "");
 
-                    if(StringUtils.isEmpty(userName)){
+                    if (StringUtils.isEmpty(userName)) {
                         sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("未填写用户名!");
                         failCount++;
                         continue;
                     }
 
 
-                    if(StringUtils.isEmpty(realName)){
+                    if (StringUtils.isEmpty(realName)) {
                         sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("未填写真实姓名!");
                         failCount++;
                         continue;
                     }
 
 
-                    if(StringUtils.isEmpty(phone)){
+                    if (StringUtils.isEmpty(phone)) {
                         sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("未填写联系电话!");
                         failCount++;
                         continue;
                     }
 
-                    if(StringUtils.isEmpty(idCard)){
+                    if (StringUtils.isEmpty(idCard)) {
                         sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("未填写身份证号!");
                         failCount++;
                         continue;
@@ -337,12 +383,11 @@ public class PersonInfoController {
 
 
                     //是否填写关联企业
-                    if(StringUtils.isNotEmpty(enterpriseName)){
+                    if (StringUtils.isNotEmpty(enterpriseName)) {
                         EnterpriseInfo enterpriseInfo = enterpriseInfoService.findByName(enterpriseName);
-                        if(enterpriseInfo!=null){
+                        if (enterpriseInfo != null) {
                             personInfo.setEnterpriseId(enterpriseInfo.getId());
-                        }
-                        else{
+                        } else {
                             sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("填写的企业名称在系统中不存在,请检查企业名称!");
                             failCount++;
                             continue;
@@ -359,19 +404,18 @@ public class PersonInfoController {
                     //保存新用户
                     personInfoService.insert(personInfo);
                     affectCount++;
-                }
-                catch(Exception innerEx){
-                    logger.error(innerEx.getMessage(),innerEx);
+                } catch (Exception innerEx) {
+                    logger.error(innerEx.getMessage(), innerEx);
                 }
             }
 
-            if (failCount>0){
+            if (failCount > 0) {
                 //有导入失败的记录
                 msgResult.setResult(false);
                 msgResult.setMessage("数据成功导入" + affectCount + "条,有" + failCount + "条数据未导入成功,错误原因请查看报表。");
 
                 //todo 只保留错误数据的sheet
-                Workbook wb = poiUtils.exportErrorXls(sheetIndex,validateColIndex,1 + affectCount + failCount);
+                Workbook wb = poiUtils.exportErrorXls(sheetIndex, validateColIndex, 1 + affectCount + failCount);
 
                 //todo 将wb保存到oss
                 ByteArrayOutputStream output = new ByteArrayOutputStream();
@@ -380,18 +424,16 @@ public class PersonInfoController {
                 byte[] buffer = output.toByteArray();
                 ByteArrayInputStream input = new ByteArrayInputStream(buffer);
 
-                String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
+                String downloadUrl = OSSUtil.upload(ossConfig, "import", "error.xls", input);
 
                 //todo 返回导入失败报表下载链接
                 msgResult.setData(downloadUrl);
-            }
-            else{
+            } else {
                 msgResult.setResult(true);
                 msgResult.setMessage("数据成功导入" + affectCount + "条");
             }
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -401,11 +443,9 @@ public class PersonInfoController {
     }
 
 
-
-
-    @ApiOperation(value="审核信息")
+    @ApiOperation(value = "审核信息")
     @PostMapping("check/{id}")
-    public MessageResult<PersonInfo> check(@PathVariable("id") String id,@RequestAttribute String subject){
+    public MessageResult<PersonInfo> check(@PathVariable("id") String id, @RequestAttribute String subject) {
         MessageResult<PersonInfo> msgResult = new MessageResult<>();
 
         try {
@@ -415,7 +455,7 @@ public class PersonInfoController {
             personInfo.setUpdateBy(subject);
             personInfo.setUpdateTime(new Date());
 
-            if(StringUtils.isNotEmpty(personInfo.getIdCard())){
+            if (StringUtils.isNotEmpty(personInfo.getIdCard())) {
                 int gender = IdcardUtil.getGenderByIdCard(personInfo.getIdCard());
                 int age = IdcardUtil.getAgeByIdCard(personInfo.getIdCard());
 
@@ -432,9 +472,8 @@ public class PersonInfoController {
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库审核失败");
             }
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -442,4 +481,52 @@ public class PersonInfoController {
 
         return msgResult;
     }
+
+
+    private String exportXls(List<Map> mapList) {
+        String downloadUrl = "";
+
+        Workbook workbook = new HSSFWorkbook();
+        Sheet sheet = workbook.createSheet();
+
+        //表头
+        Row rowTitle = sheet.createRow(0);
+
+        String[] titles = new String[]{"序号", "姓名", "联系电话", "身份证号", "性别", "年龄", "认证状态"};
+
+        for (int i = 0; i < titles.length; i++) {
+            Cell cell = rowTitle.createCell(i);
+            cell.setCellValue(titles[i]);
+        }
+
+        for (int i = 0; i < mapList.size(); i++) {
+            Map<String, Object> map = mapList.get(i);
+
+            Row row = sheet.createRow(i + 1);
+
+            int colIndex = 0;
+            row.createCell(colIndex++).setCellValue(i + 1);
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("realName"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("phone"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("idCard"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("genderN"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("age"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("statusN"), ""));
+        }
+
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+
+        try {
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            downloadUrl = OSSUtil.upload(ossConfig, "personList", "人员列表.xls", input);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+        }
+
+        return downloadUrl;
+    }
 }

+ 154 - 40
web/src/main/java/com/jpsoft/employment/modules/base/controller/RecruitInformationInfoController.java

@@ -17,6 +17,9 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.slf4j.Logger;
@@ -224,79 +227,190 @@ public class RecruitInformationInfoController {
 
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
-    public MessageResult<Map> pageList(
+    public MessageResult<Object> pageList(
             String name,String positionName,String intendedIndustries,String method,
             String status,String workArea,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestParam(value = "exportFlag", defaultValue = "false") Boolean exportFlag,
             HttpServletRequest request){
         String subject = (String)request.getAttribute("subject");
 
         //当前用户ID
         System.out.println(subject);
 
-        MessageResult<Map> msgResult = new MessageResult<>();
+        MessageResult<Object> msgResult = new MessageResult<>();
 
-        Map<String,Object> searchParams = new HashMap<>();
+        try {
 
-        List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("a.create_time","desc"));
+            Map<String, Object> searchParams = new HashMap<>();
 
-        if (StringUtils.isNotEmpty(name)) {
-            searchParams.put("name","%" + name + "%");
-        }
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("a.create_time", "desc"));
 
-        if (StringUtils.isNotEmpty(positionName)) {
-            searchParams.put("positionName",positionName+ "%");
-        }
+            if (StringUtils.isNotEmpty(name)) {
+                searchParams.put("name", "%" + name + "%");
+            }
 
-        if (StringUtils.isNotEmpty(workArea)) {
-            searchParams.put("workArea",workArea+ "%");
-        }
+            if (StringUtils.isNotEmpty(positionName)) {
+                searchParams.put("positionName", positionName + "%");
+            }
 
-        if (StringUtils.isNotEmpty(intendedIndustries)) {
-            searchParams.put("intendedIndustries",intendedIndustries);
-        }
+            if (StringUtils.isNotEmpty(workArea)) {
+                searchParams.put("workArea", workArea + "%");
+            }
 
-        if (StringUtils.isNotEmpty(method)) {
-            searchParams.put("method",method);
-        }
+            if (StringUtils.isNotEmpty(intendedIndustries)) {
+                searchParams.put("intendedIndustries", intendedIndustries);
+            }
 
-        if (StringUtils.isNotEmpty(status)) {
-            searchParams.put("status",status);
-        }
+            if (StringUtils.isNotEmpty(method)) {
+                searchParams.put("method", method);
+            }
 
+            if (StringUtils.isNotEmpty(status)) {
+                searchParams.put("status", status);
+            }
 
-        Page<RecruitInformationInfo> page = recruitInformationInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
 
+            Page<RecruitInformationInfo> page = recruitInformationInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
 
-        for (RecruitInformationInfo recruitInformationInfo:page) {
-            EnterpriseInfo enterpriseInfo = enterpriseInfoService.get(recruitInformationInfo.getEnterpriseId());
-            if(enterpriseInfo!=null){
-                recruitInformationInfo.setEnterpriseName(enterpriseInfo.getName());
-            }
+            List<Map> mapList = new ArrayList<>();
+
+            for (RecruitInformationInfo recruitInformationInfo : page) {
+                Map map = new HashMap();
+
+                String enterpriseName="";
+                EnterpriseInfo enterpriseInfo = enterpriseInfoService.get(recruitInformationInfo.getEnterpriseId());
+                if (enterpriseInfo != null) {
+                    enterpriseName = enterpriseInfo.getName();
+                }
+
+                String industryN = dataDictionaryService.findNameByCatalogNameAndValue("意向行业", recruitInformationInfo.getIndustry());
+                if (StringUtils.isNotEmpty(industryN)) {
+                    recruitInformationInfo.setIndustryN(industryN);
+                }
+
+                String settlementMethodN = dataDictionaryService.findNameByCatalogNameAndValue("结算方式", recruitInformationInfo.getSettlementMethod());
+                if (StringUtils.isNotEmpty(settlementMethodN)) {
+                    recruitInformationInfo.setSettlementMethodN(settlementMethodN);
+                }
+
+                Integer isReadNumber = recruitPersonRelationService.isReadCountByRecruit(recruitInformationInfo.getId());
+
+                recruitInformationInfo.setIsReadNumber(isReadNumber);
+
+
+                map.put("id",recruitInformationInfo.getId());
+                map.put("enterpriseName",enterpriseName);
+                map.put("industryN",industryN);
+                map.put("settlementMethodN",settlementMethodN);
+                map.put("positionName",recruitInformationInfo.getPositionName());
+                map.put("salary",recruitInformationInfo.getSalary());
+                map.put("recruitingNumbers",recruitInformationInfo.getRecruitingNumbers());
+                map.put("contacts",recruitInformationInfo.getContacts());
+                map.put("contactsPhone",recruitInformationInfo.getContactsPhone());
+                map.put("workArea",recruitInformationInfo.getWorkArea());
+                map.put("address",recruitInformationInfo.getAddress());
+                map.put("browseNumber",recruitInformationInfo.getBrowseNumber());
+
+                String statusN;
+                if ("1".equals(recruitInformationInfo.getStatus())) {
+                    statusN = "已审核";
+                } else {
+                    statusN = "未审核";
+                }
+                map.put("status",recruitInformationInfo.getStatus());
+                map.put("statusN",statusN);
+
+                String isOnlineN;
+                if (recruitInformationInfo.getIsOnline()) {
+                    isOnlineN = "上架";
+                } else {
+                    isOnlineN = "下架";
+                }
+                map.put("isOnline",recruitInformationInfo.getIsOnline());
+                map.put("isOnlineN",isOnlineN);
+                mapList.add(map);
 
-            String industryN = dataDictionaryService.findNameByCatalogNameAndValue("意向行业",recruitInformationInfo.getIndustry());
-            if(StringUtils.isNotEmpty(industryN)){
-                recruitInformationInfo.setIndustryN(industryN);
             }
 
-            String settlementMethodN = dataDictionaryService.findNameByCatalogNameAndValue("结算方式",recruitInformationInfo.getSettlementMethod());
-            if(StringUtils.isNotEmpty(settlementMethodN)){
-                recruitInformationInfo.setSettlementMethodN(settlementMethodN);
+
+            if (exportFlag) {
+                String filePath = exportXls(mapList);
+                msgResult.setData(filePath);
+            } else {
+                Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
+                dataMap.put("data", mapList);
+                msgResult.setData(dataMap);
             }
 
-            Integer isReadNumber = recruitPersonRelationService.isReadCountByRecruit(recruitInformationInfo.getId());
+            msgResult.setResult(true);
+        }
+        catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+            msgResult.setResult(false);
+        }
+
+        return msgResult;
+    }
+
+
+    private String exportXls(List<Map> mapList) {
+        String downloadUrl = "";
+
+        Workbook workbook = new HSSFWorkbook();
+        Sheet sheet = workbook.createSheet();
 
-            recruitInformationInfo.setIsReadNumber(isReadNumber);
+        //表头
+        Row rowTitle = sheet.createRow(0);
 
+        String[] titles = new String[]{"序号", "企业名称", "行业",
+                "职位名称", "薪资待遇","结算方式","招聘人数",
+                "联系人","联系电话","工作地区","详细地址","浏览次数","审核状态","是否上架"};
+
+        for (int i = 0; i < titles.length; i++) {
+            Cell cell = rowTitle.createCell(i);
+            cell.setCellValue(titles[i]);
         }
 
+        for (int i = 0; i < mapList.size(); i++) {
+            Map<String, Object> map = mapList.get(i);
+
+            Row row = sheet.createRow(i + 1);
+
+            int colIndex = 0;
+            row.createCell(colIndex++).setCellValue(i + 1);
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("enterpriseName"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("industryN"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("positionName"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("salary"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("settlementMethodN"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("recruitingNumbers"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("contacts"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("contactsPhone"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("workArea"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("address"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("browseNumber"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("statusN"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("isOnlineN"), ""));
 
-        msgResult.setResult(true);
-        msgResult.setData(PojoUtils.pageWrapper(page));
+        }
 
-        return msgResult;
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+
+        try {
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            downloadUrl = OSSUtil.upload(ossConfig, "RecruitInfoList", "招聘信息列表.xls", input);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+        }
+
+        return downloadUrl;
     }