毕业设计-基于Springboot实现公租房申请管理系统

作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助

文末获取源码 

项目编号:BS-XX-120

一,项目简介

本项目基于Springboot开发实现了一个公租房申请管理系统平台,系统分为管理员用户和公租房申请用户。管理员用户又分为三种:超级管理员,基础数据管理员,审核管理员。超级管理员主要用来管理管理员和普通用户信息,资讯信息等,基础数据管理员主要用来管理小区,房屋等相关信息,审核管理员主要用来审核用户的申请信息,给用户进行配租等。前端用户在前台界面可以查看公租房申请的相关政策信息,相关流程,实现在线注册和登陆,并可以在线申请公租房。

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发技术:springboot+mybatis

前台开发技术:layui+jquery

特点技术:短信发送,GoEasy通信技术等

三,系统展示

前端用户功能展示

用户注册

用户登陆

首页

申请指南

新闻动态

审核结果公示

在线申请

申请结果查询

管理员功能展示

超级管理员登陆

后台主界面

管理员管理:可以停用和删除

前台用户管理

资讯管理

审核人员管理功能

办公地点管理

公告管理

审核结果发布

基础数据管理员

房屋管理

给通过人员配租

四,核心代码展示

package org.wy.gzf_boot.controller;



import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.wy.gzf_boot.model.Admin;
import org.wy.gzf_boot.model.Community;
import org.wy.gzf_boot.service.AdminService;
import org.wy.gzf_boot.service.ApartmentService;
import org.wy.gzf_boot.service.CommunityService;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 管理员表 前端控制器
 * </p>
 *
 * @since 2020-03-08
 */
@Controller
@RequestMapping("/admin")
public class AdminController {

    @Resource
    private AdminService adminService;
    @Resource
    private CommunityService communityService;
    @Resource
    private ApartmentService apartmentService;

    @RequestMapping("/toWelcome")
    public String toWelcome(){
        return "xianadmin/welcome";
    }

    /**
     * 登录页面入口
     * @return
     */
    @RequestMapping("/toLogin")
    public String toLogin(){
        return "xianadmin/login";
    }

    /**
     * 管理员登录验证账号密码
     */
    @ResponseBody
    @RequestMapping("/toCheck")
    public Map toCheck(Admin admin,HttpSession session){
        Map map=new HashMap();
        Admin a=adminService.login(admin);
        if(a!=null){
            session.setAttribute("admin",a);
            map.put("admin",a);
        }
        return map;
    }

    @RequestMapping("/toIndex")
    public String toIndex(int adminState){
        if(adminState==0){
            return "superadmin/index";
        }else if (adminState==1){
            return "xianadmin/index";
        }else{
            return "shiadmin/index";
        }
    }

    @RequestMapping("/toRole")
    public String toRole(){
        return "superadmin/admin-role";
    }

    @RequestMapping("/toAdminList")
    public String toAdminList(){
        return "superadmin/admin-list";
    }

    @RequestMapping("/toCommunityList")
    public String toCommunityList(){
        return "superadmin/community-list";
    }

    @RequestMapping("/toAddCommunity")
    public String toAddCommunity(){
        return "superadmin/community-add";
    }

    @RequestMapping("/toApartmentList")
    public ModelAndView toApartmentList(ModelAndView mv){
        List<Community> allCommunity=communityService.getCommunityList();
        mv.addObject("allCommunity",allCommunity);
        mv.setViewName("superadmin/apartment-list");
        return mv;
    }

    @RequestMapping("/toAddApartment")
    public ModelAndView toAddApartment(ModelAndView mv){
        List<Community> allCommunity=communityService.getCommunityList();
        mv.addObject("allCommunity",allCommunity);
        mv.setViewName("superadmin/apartment-add");
        return mv;
    }

    @RequestMapping("/toApplicant")
    public String toApplicant(){
        return "xianadmin/applicant-list";
    }


    @RequestMapping("/toAddApplicant")
    public String toAddApplicant(){
        return "xianadmin/applicant-add";
    }

    @RequestMapping("/toApplyCheck")
    public String toApplyCheck(){
        return "shiadmin/shi-apply-list";
    }

    @RequestMapping("/toNotice")
    public String toNotice(){
        return "superadmin/notice-write";
    }

    @ResponseBody
    @RequestMapping("/adminExit")
    public ModelAndView adminExit(HttpSession session,ModelAndView mv){
     session.invalidate();
     mv.setViewName("xianadmin/login");
     return mv;
    }

    @RequestMapping("/toNoticeBox")
    public ModelAndView toNoticeBox(ModelAndView mv){
        mv.setViewName("shiadmin/notice-box");
        return mv;
    }

    @RequestMapping("/toAdmin")
    public String toAdmin(){
        return "superadmin/admin-list";
    }

    @ResponseBody
    @RequestMapping("/getAdminList")
    public Map toAdminList(Admin admin){
        Map map=new HashMap();
        List adminList=adminService.getAdminList(admin);
        int adminCount=adminService.getAdminCount(admin);
        map.put("adminList",adminList);
        map.put("adminCount",adminCount);
        return map;
    }

    @ResponseBody
    @RequestMapping("/addAdmin")
    public int addAdmin(Admin admin){
        return adminService.addAdmin(admin);
    }

    @RequestMapping("/toAddAdmin")
    public String toAddAdmin(){
        return "superadmin/admin-add";
    }

    @ResponseBody
    @RequestMapping("/banAdminById")
    public int banAdminById(Admin admin){
        return adminService.banAdminById(admin);
    }
    @ResponseBody
    @RequestMapping("delAdmin")
    public int delAdmin(Admin admin){
        return adminService.delAdmin(admin);
    }

    @RequestMapping("/toApplyHelp")
    public String toApplyHelp(){
        return "user/apply-help";
    }
}

package org.wy.gzf_boot.controller;




import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.wy.gzf_boot.mapper.ApartmentMapper;
import org.wy.gzf_boot.model.Apartment;

import org.wy.gzf_boot.model.Community;
import org.wy.gzf_boot.service.ApartmentService;
import org.wy.gzf_boot.service.CommunityService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.websocket.server.PathParam;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 房源表 前端控制器
 * </p>
 *

 * @since 2020-03-08
 */
@Controller
@RequestMapping("/apartment")
public class ApartmentController {

    @Resource
    private ApartmentService apartmentService;

    @Resource
    private CommunityService communityService;

    //获取符合条件的所有房源
    @ResponseBody
    @RequestMapping("/getApartmentList")
    public Map getApartmentList(Community community, Apartment apartment,int pageNum, int pageSize){
        apartment.setCommunity(community);
        System.out.println("单元号:"+apartment.getUnitId());
        Map map=new HashMap();
        map.put("apartment",apartment);
        int apartmentCount=apartmentService.getApartmentCount(map);
        map.put("pageNum",pageNum);
        map.put("pageSize",pageSize);
        PageInfo page=apartmentService.getApartmentList(map);
        map.put("apartmentCount",apartmentCount);
        map.put("page",page);

        return map;
    }

    //获取符合条件的所有空闲房源
    @ResponseBody
    @RequestMapping("/getFreeApartmentList")
    public Map getFreeApartmentList(Community community, Apartment apartment,int pageNum, int pageSize){
        apartment.setCommunity(community);
        System.out.println("单元号:"+apartment.getUnitId());
        Map map=new HashMap();
        map.put("apartment",apartment);
        int apartmentCount=apartmentService.getFreeApartmentCount(map);
        map.put("pageNum",pageNum);
        map.put("pageSize",pageSize);
        PageInfo page=apartmentService.getFreeApartmentList(map);
        map.put("apartmentCount",apartmentCount);
        map.put("page",page);
        return map;
    }
    /**
     * 添加房源
     * @param apartment
     * @return
     */
    @ResponseBody
    @RequestMapping("/addApartment")
    public int addApartment(Apartment apartment,Community community){
        apartment.setCommunity(community);
        int result=apartmentService.addApartment(apartment);
        return result;
    }

    @ResponseBody
    @RequestMapping("/delApartment")
    public int delApartment(int apartmentId){
        return apartmentService.delApartment(apartmentId);
    }

    @RequestMapping("/toApartmentEdit")
    public ModelAndView toEditApartment(Apartment apartment, ModelAndView mv){
        Apartment apartment1=apartmentService.getApartmentById(apartment);
        mv.addObject("apartment",apartment1);
        mv.setViewName("superadmin/apartment-edit");
        return mv;
    }

    @ResponseBody
    @RequestMapping("/editApartment")
    public int editApartment(Apartment apartment){
        return apartmentService.editApartment(apartment);
    }

    /**
     * excel导出
     * @param request
     * @param response
     * @throws Exception
     */
    @RequestMapping("/apartment_excel_down")
    public void exportPermMatrix(HttpServletRequest request, HttpServletResponse response) throws Exception {
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("xxx信息表");

        List<Apartment> apartmentList = apartmentService.getAllApartment();
        //此处添加数据
        HSSFRow headerRow1 = sheet.createRow(0);
        headerRow1.createCell(0).setCellValue("位置");
        headerRow1.createCell(1).setCellValue("房源");
        headerRow1.createCell(2).setCellValue("房源面积");
        headerRow1.createCell(3).setCellValue("计租面积");
        headerRow1.createCell(4).setCellValue("户型");
        headerRow1.createCell(5).setCellValue("建筑结构");
        headerRow1.createCell(6).setCellValue("状态");
        //headerRow1.createCell(6).setCellValue("总层数");
        for (int i = 0; i < apartmentList.size(); i++) {
            HSSFRow headerRow = sheet.createRow(i + 1);
            headerRow.createCell(0).setCellValue(apartmentList.get(i).getCommunity().getLocation());
            headerRow.createCell(1).setCellValue(apartmentList.get(i).getCommunity().getCommunityName()+apartmentList.get(i).getUnitId()+"号楼"+apartmentList.get(i).getFloorId()+"-"+apartmentList.get(i).getRoomId());
            headerRow.createCell(2).setCellValue(apartmentList.get(i).getRoomArea()+"㎡");
            headerRow.createCell(3).setCellValue(apartmentList.get(i).getRentArea()+"㎡");
            headerRow.createCell(4).setCellValue(apartmentList.get(i).getHouseType());
            headerRow.createCell(5).setCellValue(apartmentList.get(i).getCommunity().getStructure());
            headerRow.createCell(6).setCellValue(apartmentList.get(i).getRoomState());
        }

        //清空response
        response.reset();
        response.setContentType("multipart/form-data");
        response.setHeader("Content-Disposition",
                "attachment; filename=" + new String("房源信息列表".getBytes(), "iso8859-1") + ".xls");
        OutputStream os = new BufferedOutputStream(response.getOutputStream());
        workbook.write(os);
        os.flush();
        os.close();
        //workbook.close();
    }

    /**
     * excel导入数据
     */
    @ResponseBody
    @RequestMapping("/apartment_input_excel")
    @Transactional(rollbackFor = Exception.class)
    public Map importWatchExcel(@RequestParam("file") MultipartFile xlsFile) {
        Map result = new HashMap<>();
        // contentType
        // String contentType = file.getContentType();
        // excel文件名
        // String fileName = file.getOriginalFilename();
        if (xlsFile.isEmpty()) {
            result.put("code", 500);
            result.put("message", "导入文件为空!");
            return result;
        }
        // 根据不同excel创建不同对象,Excel2003版本-->HSSFWorkbook,Excel2007版本-->XSSFWorkbook
        Workbook wb = null;
        InputStream im = null;
        try {
            im = xlsFile.getInputStream();
            wb = WorkbookFactory.create(im);
            // 根据页面index 获取sheet页
            Sheet sheet = wb.getSheetAt(0);
            Row row = null;
            // 循环sheet页中数据从第x行开始,例:第3行开始为导入数据
            for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {

               Apartment apartment=new Apartment();

                // 获取每一行数据
                row = sheet.getRow(i);
                // 输出表格内容,此处可替换为数据插入操作
                String communityName=row.getCell(1).getStringCellValue();
                List communityList=communityService.getCommunityByName(communityName);
                Community community= (Community) communityList.get(0);

                apartment.setCommunity(community);

                if (null != row.getCell(2) && "" != row.getCell(2).toString()) {
                    row.getCell(2).setCellType(CellType.STRING);
                    apartment.setUnitId(Integer.parseInt(row.getCell(2).getStringCellValue()));
                }
                if (null != row.getCell(3) && "" != row.getCell(3).toString()) {
                    row.getCell(3).setCellType(CellType.STRING);
                   apartment.setFloorId(Integer.parseInt(row.getCell(3).getStringCellValue()));
                }
                if (null != row.getCell(4) && "" != row.getCell(4).toString()) {
                    row.getCell(4).setCellType(CellType.STRING);
                    apartment.setRoomId(Integer.parseInt(row.getCell(4).getStringCellValue()));
                }
                if (null != row.getCell(5) && "" != row.getCell(5).toString()) {
                    String roomArea=row.getCell(5).getStringCellValue();
                    apartment.setRoomArea(Float.parseFloat(roomArea));
                }
                if (null != row.getCell(6) && "" != row.getCell(6).toString()) {
                    String rentArea=row.getCell(6).getStringCellValue();
                    apartment.setRentArea(Float.parseFloat(rentArea));
                }
                if (null != row.getCell(7) && "" != row.getCell(7).toString()) {
                    apartment.setHouseType(row.getCell(7).getStringCellValue());
                }
                if (null != row.getCell(9) && "" != row.getCell(9).toString()) {
                    apartment.setRoomState(row.getCell(9).getStringCellValue());
                }

                apartmentService.addApartment(apartment);
            }
            result.put("code", 200);
            result.put("message", "导入成功!");
        } catch (Exception e1) {
            // 回滚数据
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            e1.printStackTrace();
        } finally {
            try {
                im.close();
                wb.close();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
        }
        return result;
    }

    @RequestMapping("/toSelectExcel")
    public String toSelectExcel(){
        return "superadmin/apartment-excel-select";
    }

    @ResponseBody
    @RequestMapping("/getAllApartment")
    public List getAllApartment(){
        return apartmentService.getAllApartment();
    }
}

package org.wy.gzf_boot.controller;


import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import org.wy.gzf_boot.model.*;
import org.wy.gzf_boot.service.ApplicantService;
import org.wy.gzf_boot.service.SecondTrialService;
import org.wy.gzf_boot.service.UserInformService;
import org.wy.gzf_boot.util.FileUtils;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;

/**
 * <p>
 * 申请人表 前端控制器
 * </p>
 *
 * @since 2020-03-08
 */
@Controller
@RequestMapping("/applicant")
public class ApplicantController {

    @Resource
    private ApplicantService applicantService;

    @Resource
    private SecondTrialService secondTrialService;

    @Resource
    private UserInformService userInformService;

    @Value("${uploadPath}")
    private String uploadPath;
    @ResponseBody
    @RequestMapping("/getApplicantList")
    public Map getApplicantList(int pageSize, int pageNum, String applicantName, String adminState) {
        Map map = new HashMap();

        map.put("adminState", adminState);
        int applicantCount = applicantService.getApplicantCount(map);
        map.put("applicantCount", applicantCount);
        System.out.println("申请人总条数:" + applicantCount);
        map.put("pageNum", pageNum);
        map.put("pageSize", pageSize);
        map.put("applicantName", applicantName);
        PageInfo page = applicantService.getApplicantList(map);

        map.put("page", page);

        return map;
    }

    /**
     * 申请人信息提交,多文件上传
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("/addApplicant")
    public int addApply(HttpServletRequest request) {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        List<MultipartFile> file1 = multipartRequest.getFiles("file1");
        List<MultipartFile> file2 = multipartRequest.getFiles("file2");
        List<MultipartFile> file3 = multipartRequest.getFiles("file3");
        List<MultipartFile> file4 = multipartRequest.getFiles("file4");
        List<MultipartFile> file5 = multipartRequest.getFiles("file5");

        Applicant applicant = new Applicant();
        User user = new User();
        user.setUserId(Integer.parseInt(multipartRequest.getParameter("userId")));
        applicant.setUser(user);
        applicant.setApplicantName(multipartRequest.getParameter("applicantName"));
        applicant.setSex(Integer.parseInt(multipartRequest.getParameter("sex")));
        applicant.setIdNumber(multipartRequest.getParameter("idNumber"));
        applicant.setBirthday(multipartRequest.getParameter("birthday"));
        applicant.setEducation(multipartRequest.getParameter("education"));
        applicant.setWorkUnit(multipartRequest.getParameter("workUnit"));
        applicant.setPhone(multipartRequest.getParameter("phone"));
        applicant.setAddress(multipartRequest.getParameter("address"));
        Community community = new Community();
        community.setCommunityId(Integer.parseInt(multipartRequest.getParameter("communityId")));
        applicant.setCommunity(community);
        applicant.setDemandArea(Integer.parseInt(multipartRequest.getParameter("demandArea")));
        applicant.setDemandFloor(Integer.parseInt(multipartRequest.getParameter("demandFloor")));
        applicant.setDemandRoom(multipartRequest.getParameter("demandRoom"));


        List<MultipartFile> allFiles = new ArrayList<>();
        allFiles.add(file1.get(0));
        allFiles.add(file2.get(0));
        allFiles.add(file3.get(0));
        allFiles.add(file4.get(0));
        allFiles.add(file5.get(0));
        for (int i = 0; i < allFiles.size(); i++) {
            String fileName = allFiles.get(i).getOriginalFilename();
            if (!"".equals(fileName)) {
                String suffixName = fileName.substring(fileName.lastIndexOf("."));
                fileName = UUID.randomUUID() + suffixName;  //新文件名
                if (i == 0) {
                    applicant.setIdentityCard(fileName);
                } else if (i == 1) {
                    applicant.setMarriageProof(fileName);
                } else if (i == 2) {
                    applicant.setHouseProof(fileName);
                } else if (i == 3) {
                    applicant.setWorkProof(fileName);
                } else if (i == 4) {
                    applicant.setApplyDoc(fileName);
                }
            }
            String path = uploadPath;
            FileUtils.upload(allFiles.get(i), path, fileName);
        }
        int result = applicantService.addApplicant(applicant);
        if (result > 0) {
            UserInform userInform = new UserInform();
            userInform.setTitle("申请提交通知");
            userInform.setContent(applicant.getApplicantName() + "(先生/女士),您的公租房申请材料已经提交,请您耐心等待。您可在首页的查询办理进度,也可等待审核公告发布");
            userInform.setUser(user);
            userInformService.addUserInform(userInform);
            return result;
        }
        return 0;
    }

    @RequestMapping("/getApplicantById")
    public ModelAndView getApplicantById(int applicantId, ModelAndView mv) {
        Applicant applicant = applicantService.getApplicantById(applicantId);
        mv.addObject("applicant", applicant);
        mv.setViewName("xianadmin/applicant-edit");
        return mv;
    }

    @ResponseBody
    @RequestMapping("/editApplicant")
    public int editApplicant(Applicant applicant) {
        return applicantService.editApplicant(applicant);
    }

    @RequestMapping("/getIdentityCard")
    public ModelAndView getIdentityCard(int applicantId, ModelAndView mv) {
        Applicant applicant = applicantService.getIdentityCard(applicantId);
        mv.setViewName("xianadmin/identitycard-img");
        mv.addObject("applicant", applicant);
        return mv;
    }

    @ResponseBody
    @RequestMapping("/editIdentityCard")
    public int editIdentityCard(@RequestParam("file") MultipartFile file, Applicant applicant) {
        String fileName = file.getOriginalFilename();
        if (!"".equals(fileName)) {
            String suffixName = fileName.substring(fileName.lastIndexOf("."));
            fileName = UUID.randomUUID() + suffixName;  //新文件名
        }
        String path = "D:\\gzf_boot\\src\\main\\resources\\static\\upload";
        FileUtils.upload(file, path, fileName);
        applicant.setIdentityCard(fileName);
        int result = applicantService.editIdentityCard(applicant);

        return result;
    }

    @RequestMapping("/shiCheckApplicant")
    public ModelAndView shiCheckApplicant(int applicantId, ModelAndView mv) {
        Applicant applicant = applicantService.getApplicantById(applicantId);
        mv.addObject("applicant", applicant);
        mv.setViewName("shiadmin/shi-apply-details");
        return mv;
    }

    @RequestMapping("/xianCheckApplicant")
    public ModelAndView xianCheckApplicant(int applicantId, ModelAndView mv) {
        Applicant applicant = applicantService.getApplicantById(applicantId);
        mv.addObject("applicant", applicant);
        mv.setViewName("xianadmin/xian-apply-details");
        return mv;
    }

    @RequestMapping("/checkIdentityCard")
    public ModelAndView checkIdentityCard(int applicantId, ModelAndView mv) {
        Applicant applicant = applicantService.getIdentityCard(applicantId);
        mv.setViewName("shiadmin/identitycard-check");
        mv.addObject("applicant", applicant);
        return mv;
    }

    @RequestMapping("/checkMarriageProof")
    public ModelAndView checkMarriageProof(Applicant applicant, ModelAndView mv) {
        mv.setViewName("shiadmin/marriageProof-check");
        mv.addObject("applicant", applicant);
        return mv;
    }

    @RequestMapping("/checkWorkProof")
    public ModelAndView checkWorkProof(Applicant applicant, ModelAndView mv) {
        mv.setViewName("shiadmin/workProof-check");
        mv.addObject("applicant", applicant);
        return mv;
    }

    @RequestMapping("/checkHouseProof")
    public ModelAndView checkHouseProof(Applicant applicant, ModelAndView mv) {
        mv.setViewName("shiadmin/houseProof-check");
        mv.addObject("applicant", applicant);
        return mv;
    }

    @RequestMapping("/checkApplyDoc")
    public ModelAndView checkApplyDoc(Applicant applicant, ModelAndView mv) {
        mv.setViewName("shiadmin/applyDoc-check");
        mv.addObject("applicant", applicant);
        return mv;
    }

    @ResponseBody
    @RequestMapping("/checkSuccess")
    public int checkSuccess(int applicantId) {
        Applicant applicant = new Applicant();
        applicant.setShiState(1);
        applicant.setApplicantId(applicantId);
        int result = applicantService.checkApply(applicant);
        SecondTrial secondTrial = new SecondTrial();
        secondTrial.setApplicant(applicant);
        int result2 = secondTrialService.addTrial(secondTrial);
        if (result > 0 && result2 > 0) {
            return 1;
        } else {
            return 0;
        }
    }


    @RequestMapping("/toWriteRefuse")
    public ModelAndView toWriteRefuse(int applicantId, int userId, ModelAndView mv) {
        mv.setViewName("shiadmin/refuse-write");
        mv.addObject("applicantId", applicantId);
        mv.addObject("userId", userId);
        return mv;
    }

    /**
     * 下载小区信息    导出 excel 使用我们的模板导出
     * /excel_down
     */
    @RequestMapping("/applicant_excel_down")
    public void exportPermMatrix(int shiState, HttpServletRequest request, HttpServletResponse response) throws Exception {
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("xxx信息表");
        List<Applicant> list = new ArrayList<>();
        System.out.println("________________" + shiState + "_________________________");
        if (shiState == 0) {
            list = applicantService.getAllApplicant();
        } else {
            list = applicantService.getOkApplicant();
        }

        //此处添加数据
        HSSFRow headerRow1 = sheet.createRow(0);
        headerRow1.createCell(0).setCellValue("申请人姓名");
        headerRow1.createCell(1).setCellValue("性别");
        headerRow1.createCell(2).setCellValue("身份证号");
        headerRow1.createCell(3).setCellValue("出生日期");
        headerRow1.createCell(4).setCellValue("学历");
        headerRow1.createCell(5).setCellValue("工作单位");
        headerRow1.createCell(6).setCellValue("联系电话");
        headerRow1.createCell(7).setCellValue("联系地址");
        headerRow1.createCell(8).setCellValue("需求面积");
        headerRow1.createCell(9).setCellValue("需求楼层");
        headerRow1.createCell(10).setCellValue("需求房型");
        headerRow1.createCell(11).setCellValue("状态");

        for (int i = 0; i < list.size(); i++) {
            HSSFRow headerRow = sheet.createRow(i + 1);
            headerRow.createCell(0).setCellValue(list.get(i).getApplicantName());
            if (list.get(i).getSex() == 0) {
                headerRow.createCell(1).setCellValue("男");
            } else {
                headerRow.createCell(1).setCellValue("女");
            }
            headerRow.createCell(2).setCellValue(list.get(i).getIdNumber());
            headerRow.createCell(3).setCellValue(list.get(i).getBirthday());
            headerRow.createCell(4).setCellValue(list.get(i).getEducation());
            headerRow.createCell(5).setCellValue(list.get(i).getWorkUnit());
            headerRow.createCell(6).setCellValue(list.get(i).getPhone());
            headerRow.createCell(7).setCellValue(list.get(i).getAddress());
            headerRow.createCell(8).setCellValue(list.get(i).getDemandArea() + "㎡");
            headerRow.createCell(9).setCellValue(list.get(i).getDemandFloor() + "层");
            headerRow.createCell(10).setCellValue(list.get(i).getDemandRoom());
            if (list.get(i).getShiState() == 0) {
                headerRow.createCell(11).setCellValue("未审核");
            } else if (list.get(i).getShiState() == 1) {
                headerRow.createCell(11).setCellValue("审核通过");
            } else {
                headerRow.createCell(11).setCellValue("审核未通过");
            }
        }

        //清空response
        response.reset();
        response.setContentType("multipart/form-data");
        if (shiState == 0) {
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("申请人信息列表(全部)".getBytes(), "iso8859-1") + ".xls");
        } else {
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("申请人信息列表(已通过)".getBytes(), "iso8859-1") + ".xls");
        }

        OutputStream os = new BufferedOutputStream(response.getOutputStream());
        workbook.write(os);
        os.flush();
        os.close();
        workbook.close();
    }

    /**
     * excel导入数据
     */
    @ResponseBody
    @RequestMapping("applicant_input_excel")
    @Transactional(rollbackFor = Exception.class)
    public Map importWatchExcel(@RequestParam("file") MultipartFile xlsFile) {
        Map result = new HashMap<>();
        // contentType
        // String contentType = file.getContentType();
        // excel文件名
        // String fileName = file.getOriginalFilename();
        if (xlsFile.isEmpty()) {
            result.put("code", 500);
            result.put("message", "导入文件为空!");
            return result;
        }
        // 根据不同excel创建不同对象,Excel2003版本-->HSSFWorkbook,Excel2007版本-->XSSFWorkbook
        Workbook wb = null;
        InputStream im = null;
        try {
            im = xlsFile.getInputStream();
            wb = WorkbookFactory.create(im);
            // 根据页面index 获取sheet页
            Sheet sheet = wb.getSheetAt(0);
            Row row = null;
            // 循环sheet页中数据从第x行开始,例:第2行开始为导入数据
            for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {

                Applicant applicant = new Applicant();

                // 获取每一行数据
                row = sheet.getRow(i);
                // 输出表格内容,此处可替换为数据插入操作
                if (null != row.getCell(0) && "" != row.getCell(0).toString()) {
                    applicant.setApplicantName(row.getCell(0).getStringCellValue());
                }
                // 内容,表格数字格式为常规
                if (null != row.getCell(1) && "" != row.getCell(1).toString()) {
                    String sex = row.getCell(1).getStringCellValue();
                    if ("男".equals(sex)) {
                        applicant.setSex(0);
                    } else {
                        applicant.setSex(1);
                    }
                }
                if (null != row.getCell(2) && "" != row.getCell(2).toString()) {
                    applicant.setIdNumber(row.getCell(2).getStringCellValue());
                }
                if (null != row.getCell(3) && "" != row.getCell(3).toString()) {
                    applicant.setBirthday(row.getCell(3).getStringCellValue());
                }
                if (null != row.getCell(4) && "" != row.getCell(4).toString()) {
                    applicant.setEducation(row.getCell(4).getStringCellValue());
                }
                if (null != row.getCell(5) && "" != row.getCell(5).toString()) {
                    applicant.setWorkUnit(row.getCell(5).getStringCellValue());
                }
                if (null != row.getCell(6) && "" != row.getCell(6).toString()) {
                    applicant.setPhone(row.getCell(6).getStringCellValue());
                }
                if (null != row.getCell(7) && "" != row.getCell(7).toString()) {
                    applicant.setAddress(row.getCell(7).getStringCellValue());
                }
                if (null != row.getCell(8) && "" != row.getCell(8).toString()) {
                    row.getCell(8).setCellType(CellType.STRING);
                    applicant.setDemandArea(Integer.parseInt(row.getCell(8).getStringCellValue()));
                }
                if (null != row.getCell(9) && "" != row.getCell(9).toString()) {
                    row.getCell(9).setCellType(CellType.STRING);
                    applicant.setDemandFloor(Integer.parseInt(row.getCell(9).getStringCellValue()));
                }
                if (null != row.getCell(10) && "" != row.getCell(10).toString()) {
                    applicant.setDemandRoom(row.getCell(10).getStringCellValue());
                }
                if (null != row.getCell(11) && "" != row.getCell(11).toString()) {
                    String state = row.getCell(11).getStringCellValue();
                    if ("未审核".equals(state)) {
                        applicant.setShiState(0);
                    } else if ("审核通过".equals(state)) {
                        applicant.setShiState(1);
                    } else {
                        applicant.setShiState(2);
                    }
                }

                applicantService.addApplicant(applicant);
            }
            result.put("code", 200);
            result.put("message", "导入成功!");
        } catch (Exception e1) {
            // 回滚数据
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            e1.printStackTrace();
        } finally {
            try {
                im.close();
                wb.close();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
        }
        return result;
    }

    @RequestMapping("/toSelectExcel")
    public String toSelectExcel() {
        return "xianadmin/applicant-excel-select";
    }

    @ResponseBody
    @RequestMapping("/toCheckApply")
    public Map toCheckApply(String applicantName, String idNumber) {
        Map map = new HashMap();
        map.put("applicantName", applicantName);
        map.put("idNumber", idNumber);
        Applicant applicant = applicantService.toCheckApply(map);
        map.put("applicant", applicant);
        return map;
    }

    @ResponseBody
    @RequestMapping("/getApplicantListByTime")
    public Map getApplicantListByTime(String startDate, String endDate, int pageNum, int pageSize) {
        Map map = new HashMap();
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        int applicantCount = applicantService.getApplicantListByTimeCount(map);
        map.put("applicantCount", applicantCount);
        System.out.println("申请人总条数:" + applicantCount);
        map.put("pageNum", pageNum);
        map.put("pageSize", pageSize);
        PageInfo page = applicantService.getApplicantListByTime(map);
        map.put("page", page);
        return map;
    }

    @ResponseBody
    @RequestMapping("/getApplicantForUser")
    public Map getApplicantForUser(String startDate, String endDate, int times, int pageNum, int pageSize) {
        Map map = new HashMap();
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        map.put("times", times);
        if (times == 1) {
            int applicantCount = applicantService.getApplicantListByTimeCount(map);
            map.put("applicantCount", applicantCount);
            map.put("pageNum", pageNum);
            map.put("pageSize", pageSize);
            PageInfo page = applicantService.getApplicantListByTime(map);
            map.put("applicantPage", page);
        } else {
            int trialCount = secondTrialService.getAllTrialCount(map);
            map.put("trialCount", trialCount);
            map.put("pageNum", pageNum);
            map.put("pageSize", pageSize);
            PageInfo page = secondTrialService.getAllTrial(map);
            map.put("trialPage", page);
        }
        return map;
    }
}

五,项目总结

本项目基于springboot框架来进行开发实现,符合现在开发的主流趋势,项目结构清晰明了,层次分明,采用MVC设计模式和三层架构来进行整体设计。界面布局简洁大方,操作符合用户使用习惯,人机交互处理的比较人性化,适合做毕业设计使用,也可以做课程设计或期未作业使用。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编程千纸鹤

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值