瀏覽代碼

报表导出

xiao547607 4 年之前
父節點
當前提交
cd4d2842ef

+ 204 - 0
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApplicationMiddleController.java

@@ -1822,4 +1822,208 @@ public class ApplicationMiddleController {
 
         return msgResult;
     }
+
+    @ApiOperation(value = "导出录取信息")
+    @PostMapping("exportOverXls")
+    public MessageResult<String> exportOverXls(
+            String tabStatus,
+            String type,
+            String nameOrIdCard,
+            String status,
+            String cardType,
+            String schoolId,
+            String offerId,
+            @RequestParam(value="isSend",defaultValue="") String isSend,
+            @RequestParam(value="categoryId",defaultValue="") String categoryId,
+            @RequestParam(value="startStatus",defaultValue="") String startStatus,
+            @RequestParam(value="endStatus",defaultValue="") String endStatus,
+            @RequestParam(value="delFlag",defaultValue="false") Boolean delFlag,
+            @RequestAttribute String subject) {
+        MessageResult<String> msgResult = new MessageResult<>();
+        User user = userService.get(subject);
+
+
+        try {
+            HSSFWorkbook workbook = new HSSFWorkbook();
+            HSSFSheet sheet = workbook.createSheet();
+            //表头
+            HSSFRow rowTitle = sheet.createRow(0);
+            HSSFCell cellTitle1 = rowTitle.createCell(0);
+            cellTitle1.setCellValue("序号");
+            HSSFCell cellTitle2 = rowTitle.createCell(1);
+            cellTitle2.setCellValue("录取学校");
+            HSSFCell cellTitle3 = rowTitle.createCell(2);
+            cellTitle3.setCellValue("录取编号");
+            HSSFCell cellTitle4 = rowTitle.createCell(3);
+            cellTitle4.setCellValue("报名类型");
+            HSSFCell cellTitle5 = rowTitle.createCell(4);
+            cellTitle5.setCellValue("学生姓名");
+            HSSFCell cellTitle6 = rowTitle.createCell(5);
+            cellTitle6.setCellValue("证件号码");
+            HSSFCell cellTitle7 = rowTitle.createCell(6);
+            cellTitle7.setCellValue("申请时间");
+            HSSFCell cellTitle8 = rowTitle.createCell(7);
+            cellTitle8.setCellValue("登记人姓名");
+            HSSFCell cellTitle9 = rowTitle.createCell(8);
+            cellTitle9.setCellValue("联系电话");
+            HSSFCell cellTitle10 = rowTitle.createCell(9);
+            cellTitle10.setCellValue("学生地址");
+
+//            int maxColumn = sheet.getRow(0).getPhysicalNumberOfCells();
+//            for(int i = 1; i < maxColumn; i++) {
+//                //int columnWidth = sheet.getColumnWidth(i) / 256;
+//                sheet.setColumnWidth(i, 12 * 256);
+//            }
+
+            sheet.setColumnWidth(1, 20 * 256);
+            sheet.setColumnWidth(2, 20 * 256);
+            sheet.setColumnWidth(3, 10 * 256);
+            sheet.setColumnWidth(4, 15 * 256);
+            sheet.setColumnWidth(5, 25 * 256);
+            sheet.setColumnWidth(6, 20 * 256);
+            sheet.setColumnWidth(7, 15 * 256);
+            sheet.setColumnWidth(8, 20 * 256);
+            sheet.setColumnWidth(9, 40 * 256);
+
+            Map<String,Object> searchParams = new HashMap<>();
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("a.school_id","asc"));
+            sortList.add(new Sort("a.type_","asc"));
+            sortList.add(new Sort("a.category_id","desc"));
+            sortList.add(new Sort("a.offer_code","asc"));
+            sortList.add(new Sort("a.create_time","desc"));
+
+            if (StringUtils.isNotEmpty(tabStatus)) {
+                searchParams.put("tabStatus",tabStatus);
+            }
+            if (StringUtils.isNotEmpty(type)) {
+                if("A".equals(type) || "B".equals(type) ||"C".equals(type)) {
+                    searchParams.put("type", type);
+                }else{
+                    searchParams.put("type", "C");
+                    searchParams.put("categoryId", type);
+                }
+            }
+            if (StringUtils.isNotEmpty(status)) {
+                searchParams.put("status",status);
+            }
+            if (StringUtils.isNotEmpty(nameOrIdCard)) {
+                searchParams.put("nameOrIdCard","%" + nameOrIdCard + "%");
+            }
+
+            if (StringUtils.isNotEmpty(cardType)) {
+                searchParams.put("cardType",cardType);
+            }
+
+            searchParams.put("delFlag",delFlag);
+
+            if(StringUtils.isNotEmpty(schoolId)){
+                searchParams.put("code", "%" + schoolId + "%");
+            }else{
+                if (!userService.hasRole(subject,"SYSADMIN")) {
+                    searchParams.put("code", "%" + user.getSchoolId() + "%");
+                }
+            }
+
+            if(StringUtils.isNotEmpty(isSend)){
+                searchParams.put("isSend", isSend);
+            }
+
+            if(StringUtils.isNotEmpty(offerId)){
+                searchParams.put("offerId", offerId);
+            }
+
+            //查询范围
+            //开始
+            if (StringUtils.isNotEmpty(startStatus)) {
+                searchParams.put("startStatus",startStatus);
+            }
+            //结束
+            if (StringUtils.isNotEmpty(endStatus)) {
+                searchParams.put("endStatus",endStatus);
+            }
+
+            if (StringUtils.isNotEmpty(categoryId)) {
+                searchParams.put("categoryId",categoryId);
+            }
+
+            //根据用户和角色查询
+            int count1 = userRoleService.findCountByAIdAndRName(subject,"SYSADMIN");
+            int count2 = userRoleService.findCountByAIdAndRName(subject,"XFLD");
+            int count3 = userRoleService.findCountByAIdAndRName(subject,"XFGZRY");
+
+            if(count1 > 0){
+                //管理员查全部
+            }else if(count2 > 0){
+                //领导查全部
+            }else if(count3 > 0){
+                //工作人员只能查网上初审10和现场初审20
+                List statusList = new ArrayList();
+                statusList.add("10");
+                statusList.add("20");
+                searchParams.put("orStatus",statusList);
+            }
+
+            Page<ApplicationMiddleDTO> page = applicationMiddleService.pageSearchDTO(searchParams,0,10000000,false,sortList);
+
+            for (int i = 0; i < page.size(); i++) {
+                ApplicationMiddleDTO amDTO = page.get(i);
+
+                HSSFRow rowContent = sheet.createRow(i + 1);
+                //"序号"
+                HSSFCell cellContent1 = rowContent.createCell(0);
+                cellContent1.setCellValue(i + 1);
+//                "录取学校"
+                HSSFCell cellContent2 = rowContent.createCell(1);
+                cellContent2.setCellValue(amDTO.getOfferName());
+//                "录取编号"
+                HSSFCell cellContent3 = rowContent.createCell(2);
+                cellContent3.setCellValue(amDTO.getOfferCode());
+//                "报名类型"
+                HSSFCell cellContent4 = rowContent.createCell(3);
+                cellContent4.setCellValue(amDTO.getType());
+//                "学生姓名"
+                HSSFCell cellContent5 = rowContent.createCell(4);
+                cellContent5.setCellValue(amDTO.getName());
+//                "证件号码"
+                HSSFCell cellContent6 = rowContent.createCell(5);
+                cellContent6.setCellValue(amDTO.getIdCard());
+//                "申请时间"
+                HSSFCell cellContent7 = rowContent.createCell(6);
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+                cellContent7.setCellValue(sdf.format(amDTO.getCreateTime()));
+                //"登记人姓名"
+                HSSFCell cellContent8 = rowContent.createCell(7);
+                cellContent8.setCellValue(amDTO.getPersonName());
+                //联系电话
+                HSSFCell cellContent9 = rowContent.createCell(8);
+                cellContent9.setCellValue(amDTO.getPersonPhone());
+                //"学生地址"
+                HSSFCell cellContent10 = rowContent.createCell(9);
+                cellContent10.setCellValue(amDTO.getAddress());
+            }
+
+            //todo 将wb保存到oss
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            String downloadUrl = OSSUtil.upload(ossConfig, "import", "error.xls", input);
+
+            //todo 返回导入失败报表下载链接
+
+            msgResult.setData(downloadUrl);
+            msgResult.setResult(true);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 208 - 0
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApplicationPrimaryController.java

@@ -2143,4 +2143,212 @@ public class ApplicationPrimaryController {
 
         return msgResult;
     }
+
+    @ApiOperation(value = "导出录取信息")
+    @PostMapping("exportOverXls")
+    public MessageResult<String> exportOverXls(
+            String tabStatus,
+            String type,
+            String nameOrIdCard,
+            String status,
+            String cardType,
+            String schoolId,
+            String offerId,
+            @RequestParam(value="isSend",defaultValue="") String isSend,
+            @RequestParam(value="categoryId",defaultValue="") String categoryId,
+            @RequestParam(value="startStatus",defaultValue="") String startStatus,
+            @RequestParam(value="endStatus",defaultValue="") String endStatus,
+            @RequestParam(value="delFlag",defaultValue="false") Boolean delFlag,
+            @RequestAttribute String subject) {
+        MessageResult<String> msgResult = new MessageResult<>();
+        User user = userService.get(subject);
+
+
+        try {
+            HSSFWorkbook workbook = new HSSFWorkbook();
+            HSSFSheet sheet = workbook.createSheet();
+            //表头
+            HSSFRow rowTitle = sheet.createRow(0);
+            HSSFCell cellTitle1 = rowTitle.createCell(0);
+            cellTitle1.setCellValue("序号");
+            HSSFCell cellTitle2 = rowTitle.createCell(1);
+            cellTitle2.setCellValue("录取学校");
+            HSSFCell cellTitle3 = rowTitle.createCell(2);
+            cellTitle3.setCellValue("录取编号");
+            HSSFCell cellTitle4 = rowTitle.createCell(3);
+            cellTitle4.setCellValue("报名类型");
+            HSSFCell cellTitle5 = rowTitle.createCell(4);
+            cellTitle5.setCellValue("学生姓名");
+            HSSFCell cellTitle6 = rowTitle.createCell(5);
+            cellTitle6.setCellValue("证件号码");
+            HSSFCell cellTitle7 = rowTitle.createCell(6);
+            cellTitle7.setCellValue("申请时间");
+            HSSFCell cellTitle8 = rowTitle.createCell(7);
+            cellTitle8.setCellValue("登记人姓名");
+            HSSFCell cellTitle9 = rowTitle.createCell(8);
+            cellTitle9.setCellValue("联系电话");
+            HSSFCell cellTitle10 = rowTitle.createCell(9);
+            cellTitle10.setCellValue("学生地址");
+
+//            int maxColumn = sheet.getRow(0).getPhysicalNumberOfCells();
+//            for(int i = 1; i < maxColumn; i++) {
+//                //int columnWidth = sheet.getColumnWidth(i) / 256;
+//                sheet.setColumnWidth(i, 12 * 256);
+//            }
+
+            sheet.setColumnWidth(1, 20 * 256);
+            sheet.setColumnWidth(2, 20 * 256);
+            sheet.setColumnWidth(3, 10 * 256);
+            sheet.setColumnWidth(4, 15 * 256);
+            sheet.setColumnWidth(5, 25 * 256);
+            sheet.setColumnWidth(6, 20 * 256);
+            sheet.setColumnWidth(7, 15 * 256);
+            sheet.setColumnWidth(8, 20 * 256);
+            sheet.setColumnWidth(9, 40 * 256);
+
+            Map<String,Object> searchParams = new HashMap<>();
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("a.school_id","asc"));
+            sortList.add(new Sort("a.type_","asc"));
+            sortList.add(new Sort("a.category_id","desc"));
+            sortList.add(new Sort("a.offer_code","asc"));
+            sortList.add(new Sort("a.create_time","desc"));
+
+            if (StringUtils.isNotEmpty(tabStatus)) {
+                searchParams.put("tabStatus",tabStatus);
+            }
+            if (StringUtils.isNotEmpty(type)) {
+                if("A".equals(type) || "B".equals(type) ||"C".equals(type)) {
+                    searchParams.put("type", type);
+                }else{
+                    searchParams.put("type", "C");
+                    searchParams.put("categoryId", type);
+                }
+            }
+            if (StringUtils.isNotEmpty(status)) {
+                searchParams.put("status",status);
+            }
+            if (StringUtils.isNotEmpty(nameOrIdCard)) {
+                searchParams.put("nameOrIdCard","%" + nameOrIdCard + "%");
+            }
+
+            if (StringUtils.isNotEmpty(cardType)) {
+                searchParams.put("cardType",cardType);
+            }
+
+            searchParams.put("delFlag",delFlag);
+
+            if(StringUtils.isNotEmpty(schoolId)){
+                searchParams.put("code", "%" + schoolId + "%");
+            }else{
+                if (!userService.hasRole(subject,"SYSADMIN")) {
+                    searchParams.put("code", "%" + user.getSchoolId() + "%");
+                }
+            }
+
+            if(StringUtils.isNotEmpty(isSend)){
+                searchParams.put("isSend", isSend);
+            }
+
+            if(StringUtils.isNotEmpty(offerId)){
+                searchParams.put("offerId", offerId);
+            }
+
+            //查询范围
+            //开始
+            if (StringUtils.isNotEmpty(startStatus)) {
+                searchParams.put("startStatus",startStatus);
+            }
+            //结束
+            if (StringUtils.isNotEmpty(endStatus)) {
+                searchParams.put("endStatus",endStatus);
+            }
+
+            if (StringUtils.isNotEmpty(categoryId)) {
+                searchParams.put("categoryId",categoryId);
+            }
+
+            //根据用户和角色查询
+            int count1 = userRoleService.findCountByAIdAndRName(subject,"SYSADMIN");
+            int count2 = userRoleService.findCountByAIdAndRName(subject,"XFLD");
+            int count3 = userRoleService.findCountByAIdAndRName(subject,"XFGZRY");
+
+            if(count1 > 0){
+                //管理员查全部
+            }else if(count2 > 0){
+                //领导查全部
+            }else if(count3 > 0){
+                //工作人员只能查网上初审10和现场初审20
+                List statusList = new ArrayList();
+                statusList.add("10");
+                statusList.add("20");
+                searchParams.put("orStatus",statusList);
+            }
+
+            Page<ApplicationPrimaryDTO> page = applicationPrimaryService.pageSearchDTO(searchParams,0,10000000,false,sortList);
+            for (int i = 0; i < page.size(); i++) {
+                ApplicationPrimaryDTO apDTO = page.get(i);
+                HSSFRow rowContent = sheet.createRow(i + 1);
+                //"序号"
+                HSSFCell cellContent1 = rowContent.createCell(0);
+                cellContent1.setCellValue(i + 1);
+//                "录取学校"
+                HSSFCell cellContent2 = rowContent.createCell(1);
+                cellContent2.setCellValue(apDTO.getOfferName());
+//                "录取编号"
+                HSSFCell cellContent3 = rowContent.createCell(2);
+                cellContent3.setCellValue(apDTO.getOfferCode());
+//                "报名类型"
+                HSSFCell cellContent4 = rowContent.createCell(3);
+                String typeName = "";
+                if("C".equals(apDTO.getType())){
+                    typeName = apDTO.getType() + dataDictionaryService.getValue(apDTO.getCategoryId());
+                }else{
+                    typeName = apDTO.getType();
+                }
+                cellContent4.setCellValue(typeName);
+//                "学生姓名"
+                HSSFCell cellContent5 = rowContent.createCell(4);
+                cellContent5.setCellValue(apDTO.getName());
+//                "证件号码"
+                HSSFCell cellContent6 = rowContent.createCell(5);
+                cellContent6.setCellValue(apDTO.getIdCard());
+//                "申请时间"
+                HSSFCell cellContent7 = rowContent.createCell(6);
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+                cellContent7.setCellValue(sdf.format(apDTO.getCreateTime()));
+                //"登记人姓名"
+                HSSFCell cellContent8 = rowContent.createCell(7);
+                cellContent8.setCellValue(apDTO.getPersonName());
+                //联系电话
+                HSSFCell cellContent9 = rowContent.createCell(8);
+                cellContent9.setCellValue(apDTO.getPersonPhone());
+                //"学生地址"
+                HSSFCell cellContent10 = rowContent.createCell(9);
+                cellContent10.setCellValue(apDTO.getAddress());
+            }
+
+            //todo 将wb保存到oss
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            String downloadUrl = OSSUtil.upload(ossConfig, "import", "error.xls", input);
+
+            //todo 返回导入失败报表下载链接
+
+            msgResult.setData(downloadUrl);
+            msgResult.setResult(true);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }