畢業(yè)設(shè)計-基于Springboot實(shí)現(xiàn)公租房申請管理系統(tǒng)
?作者主頁:
作者簡介:Java領(lǐng)域優(yōu)質(zhì)創(chuàng)作者、CSDN博客專家 、掘金特邀作者、多年架構(gòu)師設(shè)計經(jīng)驗、騰訊課堂常駐講師
主要內(nèi)容:Java項目、畢業(yè)設(shè)計、簡歷模板、學(xué)習(xí)資料、面試題庫、技術(shù)互助
文末獲取源碼?
項目編號:BS-XX-120
一,項目簡介
本項目基于Springboot開發(fā)實(shí)現(xiàn)了一個公租房申請管理系統(tǒng)平臺,系統(tǒng)分為管理員用戶和公租房申請用戶。管理員用戶又分為三種:超級管理員,基礎(chǔ)數(shù)據(jù)管理員,審核管理員。超級管理員主要用來管理管理員和普通用戶信息,資訊信息等,基礎(chǔ)數(shù)據(jù)管理員主要用來管理小區(qū),房屋等相關(guān)信息,審核管理員主要用來審核用戶的申請信息,給用戶進(jìn)行配租等。前端用戶在前臺界面可以查看公租房申請的相關(guān)政策信息,相關(guān)流程,實(shí)現(xiàn)在線注冊和登陸,并可以在線申請公租房。
二,環(huán)境介紹
語言環(huán)境:Java:? jdk1.8
數(shù)據(jù)庫:Mysql: mysql5.7
應(yīng)用服務(wù)器:Tomcat:? tomcat8.5.31
開發(fā)工具:IDEA或eclipse
后臺開發(fā)技術(shù):springboot+mybatis
前臺開發(fā)技術(shù):layui+jquery
特點(diǎn)技術(shù):短信發(fā)送,GoEasy通信技術(shù)等
三,系統(tǒng)展示
前端用戶功能展示
用戶注冊
用戶登陸
首頁
申請指南
新聞動態(tài)
審核結(jié)果公示
在線申請
申請結(jié)果查詢
管理員功能展示
超級管理員登陸
后臺主界面
管理員管理:可以停用和刪除
前臺用戶管理
資訊管理
審核人員管理功能
辦公地點(diǎn)管理
公告管理
審核結(jié)果發(fā)布
基礎(chǔ)數(shù)據(jù)管理員
房屋管理
給通過人員配租
四,核心代碼展示
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
*/public class AdminController { ? ?
? ?private AdminService adminService; ? ?
? ?private CommunityService communityService; ? ?
? ?private ApartmentService apartmentService; ? ?
? ?public String toWelcome(){ ? ? ? ?return "xianadmin/welcome";
? ?} ? ?/**
? ? * 登錄頁面入口
? ? * @return
? ? */
? ?
? ?public String toLogin(){ ? ? ? ?return "xianadmin/login";
? ?} ? ?/**
? ? * 管理員登錄驗證賬號密碼
? ? */
? ?
? ?
? ?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;
? ?} ? ?
? ?public String toIndex(int adminState){ ? ? ? ?if(adminState==0){ ? ? ? ? ? ?return "superadmin/index";
? ? ? ?}else if (adminState==1){ ? ? ? ? ? ?return "xianadmin/index";
? ? ? ?}else{ ? ? ? ? ? ?return "shiadmin/index";
? ? ? ?}
? ?} ? ?
? ?public String toRole(){ ? ? ? ?return "superadmin/admin-role";
? ?} ? ?
? ?public String toAdminList(){ ? ? ? ?return "superadmin/admin-list";
? ?} ? ?
? ?public String toCommunityList(){ ? ? ? ?return "superadmin/community-list";
? ?} ? ?
? ?public String toAddCommunity(){ ? ? ? ?return "superadmin/community-add";
? ?} ? ?
? ?public ModelAndView toApartmentList(ModelAndView mv){
? ? ? ?List<Community> allCommunity=communityService.getCommunityList();
? ? ? ?mv.addObject("allCommunity",allCommunity);
? ? ? ?mv.setViewName("superadmin/apartment-list"); ? ? ? ?return mv;
? ?} ? ?
? ?public ModelAndView toAddApartment(ModelAndView mv){
? ? ? ?List<Community> allCommunity=communityService.getCommunityList();
? ? ? ?mv.addObject("allCommunity",allCommunity);
? ? ? ?mv.setViewName("superadmin/apartment-add"); ? ? ? ?return mv;
? ?} ? ?
? ?public String toApplicant(){ ? ? ? ?return "xianadmin/applicant-list";
? ?} ? ?
? ?public String toAddApplicant(){ ? ? ? ?return "xianadmin/applicant-add";
? ?} ? ?
? ?public String toApplyCheck(){ ? ? ? ?return "shiadmin/shi-apply-list";
? ?} ? ?
? ?public String toNotice(){ ? ? ? ?return "superadmin/notice-write";
? ?} ? ?
? ?
? ?public ModelAndView adminExit(HttpSession session,ModelAndView mv){
? ? session.invalidate();
? ? mv.setViewName("xianadmin/login"); ? ? return mv;
? ?} ? ?
? ?public ModelAndView toNoticeBox(ModelAndView mv){
? ? ? ?mv.setViewName("shiadmin/notice-box"); ? ? ? ?return mv;
? ?} ? ?
? ?public String toAdmin(){ ? ? ? ?return "superadmin/admin-list";
? ?} ? ?
? ?
? ?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;
? ?} ? ?
? ?
? ?public int addAdmin(Admin admin){ ? ? ? ?return adminService.addAdmin(admin);
? ?} ? ?
? ?public String toAddAdmin(){ ? ? ? ?return "superadmin/admin-add";
? ?} ? ?
? ?
? ?public int banAdminById(Admin admin){ ? ? ? ?return adminService.banAdminById(admin);
? ?} ? ?
? ?
? ?public int delAdmin(Admin admin){ ? ? ? ?return adminService.delAdmin(admin);
? ?} ? ?
? ?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
*/public class ApartmentController { ? ?
? ?private ApartmentService apartmentService; ? ?
? ?private CommunityService communityService; ? ?//獲取符合條件的所有房源
? ?
? ?
? ?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;
? ?} ? ?//獲取符合條件的所有空閑房源
? ?
? ?
? ?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
? ? */
? ?
? ?
? ?public int addApartment(Apartment apartment,Community community){
? ? ? ?apartment.setCommunity(community); ? ? ? ?int result=apartmentService.addApartment(apartment); ? ? ? ?return result;
? ?} ? ?
? ?
? ?public int delApartment(int apartmentId){ ? ? ? ?return apartmentService.delApartment(apartmentId);
? ?} ? ?
? ?public ModelAndView toEditApartment(Apartment apartment, ModelAndView mv){
? ? ? ?Apartment apartment1=apartmentService.getApartmentById(apartment);
? ? ? ?mv.addObject("apartment",apartment1);
? ? ? ?mv.setViewName("superadmin/apartment-edit"); ? ? ? ?return mv;
? ?} ? ?
? ?
? ?public int editApartment(Apartment apartment){ ? ? ? ?return apartmentService.editApartment(apartment);
? ?} ? ?/**
? ? * excel導(dǎo)出
? ? * @param request
? ? * @param response
? ? * @throws Exception
? ? */
? ?
? ?public void exportPermMatrix(HttpServletRequest request, HttpServletResponse response) throws Exception { ? ? ? ?HSSFWorkbook workbook = new HSSFWorkbook(); ? ? ? ?HSSFSheet sheet = workbook.createSheet("xxx信息表");
? ? ? ?List<Apartment> apartmentList = apartmentService.getAllApartment(); ? ? ? ?//此處添加數(shù)據(jù)
? ? ? ?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("建筑結(jié)構(gòu)");
? ? ? ?headerRow1.createCell(6).setCellValue("狀態(tài)"); ? ? ? ?//headerRow1.createCell(6).setCellValue("總層數(shù)");
? ? ? ?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導(dǎo)入數(shù)據(jù)
? ? */
? ?
? ?
? ?
? ?public Map importWatchExcel( { ? ? ? ? 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", "導(dǎo)入文件為空!"); ? ? ? ? ? ?return result;
? ? ? ?} ? ? ? ?// 根據(jù)不同excel創(chuàng)建不同對象,Excel2003版本-->HSSFWorkbook,Excel2007版本-->XSSFWorkbook
? ? ? ?Workbook wb = null; ? ? ? ?InputStream im = null; ? ? ? ?try {
? ? ? ? ? ?im = xlsFile.getInputStream();
? ? ? ? ? ?wb = WorkbookFactory.create(im); ? ? ? ? ? ?// 根據(jù)頁面index 獲取sheet頁
? ? ? ? ? ?Sheet sheet = wb.getSheetAt(0); ? ? ? ? ? ?Row row = null; ? ? ? ? ? ?// 循環(huán)sheet頁中數(shù)據(jù)從第x行開始,例:第3行開始為導(dǎo)入數(shù)據(jù)
? ? ? ? ? ?for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
? ? ? ? ? ? ? Apartment apartment=new Apartment(); ? ? ? ? ? ? ? ?// 獲取每一行數(shù)據(jù)
? ? ? ? ? ? ? ?row = sheet.getRow(i); ? ? ? ? ? ? ? ?// 輸出表格內(nèi)容,此處可替換為數(shù)據(jù)插入操作
? ? ? ? ? ? ? ?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", "導(dǎo)入成功!");
? ? ? ?} catch (Exception e1) { ? ? ? ? ? ?// 回滾數(shù)據(jù)
? ? ? ? ? ?TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
? ? ? ? ? ?e1.printStackTrace();
? ? ? ?} finally { ? ? ? ? ? ?try {
? ? ? ? ? ? ? ?im.close();
? ? ? ? ? ? ? ?wb.close();
? ? ? ? ? ?} catch (IOException e2) {
? ? ? ? ? ? ? ?e2.printStackTrace();
? ? ? ? ? ?}
? ? ? ?} ? ? ? ?return result;
? ?} ? ?
? ?public String toSelectExcel(){ ? ? ? ?return "superadmin/apartment-excel-select";
? ?} ? ?
? ?
? ?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
*/public class ApplicantController { ? ?
? ?private ApplicantService applicantService; ? ?
? ?private SecondTrialService secondTrialService; ? ?
? ?private UserInformService userInformService; ? ?
? ?private String uploadPath; ? ?
? ?
? ?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("申請人總條數(shù):" + 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
? ? */
? ?
? ?
? ?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("申請?zhí)峤煌ㄖ?#34;);
? ? ? ? ? ?userInform.setContent(applicant.getApplicantName() + "(先生/女士),您的公租房申請材料已經(jīng)提交,請您耐心等待。您可在首頁的查詢辦理進(jìn)度,也可等待審核公告發(fā)布");
? ? ? ? ? ?userInform.setUser(user);
? ? ? ? ? ?userInformService.addUserInform(userInform); ? ? ? ? ? ?return result;
? ? ? ?} ? ? ? ?return 0;
? ?} ? ?
? ?public ModelAndView getApplicantById(int applicantId, ModelAndView mv) { ? ? ? ?Applicant applicant = applicantService.getApplicantById(applicantId);
? ? ? ?mv.addObject("applicant", applicant);
? ? ? ?mv.setViewName("xianadmin/applicant-edit"); ? ? ? ?return mv;
? ?} ? ?
? ?
? ?public int editApplicant(Applicant applicant) { ? ? ? ?return applicantService.editApplicant(applicant);
? ?} ? ?
? ?public ModelAndView getIdentityCard(int applicantId, ModelAndView mv) { ? ? ? ?Applicant applicant = applicantService.getIdentityCard(applicantId);
? ? ? ?mv.setViewName("xianadmin/identitycard-img");
? ? ? ?mv.addObject("applicant", applicant); ? ? ? ?return mv;
? ?} ? ?
? ?
? ?public int editIdentityCard( { ? ? ? ? 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;
? ?} ? ?
? ?public ModelAndView shiCheckApplicant(int applicantId, ModelAndView mv) { ? ? ? ?Applicant applicant = applicantService.getApplicantById(applicantId);
? ? ? ?mv.addObject("applicant", applicant);
? ? ? ?mv.setViewName("shiadmin/shi-apply-details"); ? ? ? ?return mv;
? ?} ? ?
? ?public ModelAndView xianCheckApplicant(int applicantId, ModelAndView mv) { ? ? ? ?Applicant applicant = applicantService.getApplicantById(applicantId);
? ? ? ?mv.addObject("applicant", applicant);
? ? ? ?mv.setViewName("xianadmin/xian-apply-details"); ? ? ? ?return mv;
? ?} ? ?
? ?public ModelAndView checkIdentityCard(int applicantId, ModelAndView mv) { ? ? ? ?Applicant applicant = applicantService.getIdentityCard(applicantId);
? ? ? ?mv.setViewName("shiadmin/identitycard-check");
? ? ? ?mv.addObject("applicant", applicant); ? ? ? ?return mv;
? ?} ? ?
? ?public ModelAndView checkMarriageProof(Applicant applicant, ModelAndView mv) {
? ? ? ?mv.setViewName("shiadmin/marriageProof-check");
? ? ? ?mv.addObject("applicant", applicant); ? ? ? ?return mv;
? ?} ? ?
? ?public ModelAndView checkWorkProof(Applicant applicant, ModelAndView mv) {
? ? ? ?mv.setViewName("shiadmin/workProof-check");
? ? ? ?mv.addObject("applicant", applicant); ? ? ? ?return mv;
? ?} ? ?
? ?public ModelAndView checkHouseProof(Applicant applicant, ModelAndView mv) {
? ? ? ?mv.setViewName("shiadmin/houseProof-check");
? ? ? ?mv.addObject("applicant", applicant); ? ? ? ?return mv;
? ?} ? ?
? ?public ModelAndView checkApplyDoc(Applicant applicant, ModelAndView mv) {
? ? ? ?mv.setViewName("shiadmin/applyDoc-check");
? ? ? ?mv.addObject("applicant", applicant); ? ? ? ?return mv;
? ?} ? ?
? ?
? ?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;
? ? ? ?}
? ?} ? ?
? ?public ModelAndView toWriteRefuse(int applicantId, int userId, ModelAndView mv) {
? ? ? ?mv.setViewName("shiadmin/refuse-write");
? ? ? ?mv.addObject("applicantId", applicantId);
? ? ? ?mv.addObject("userId", userId); ? ? ? ?return mv;
? ?} ? ?/**
? ? * 下載小區(qū)信息 ? ?導(dǎo)出 excel 使用我們的模板導(dǎo)出
? ? * /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();
? ? ? ?} ? ? ? ?//此處添加數(shù)據(jù)
? ? ? ?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("學(xué)歷");
? ? ? ?headerRow1.createCell(5).setCellValue("工作單位");
? ? ? ?headerRow1.createCell(6).setCellValue("聯(lián)系電話");
? ? ? ?headerRow1.createCell(7).setCellValue("聯(lián)系地址");
? ? ? ?headerRow1.createCell(8).setCellValue("需求面積");
? ? ? ?headerRow1.createCell(9).setCellValue("需求樓層");
? ? ? ?headerRow1.createCell(10).setCellValue("需求房型");
? ? ? ?headerRow1.createCell(11).setCellValue("狀態(tài)"); ? ? ? ?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導(dǎo)入數(shù)據(jù)
? ? */
? ?
? ?
? ?
? ?public Map importWatchExcel( { ? ? ? ? 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", "導(dǎo)入文件為空!"); ? ? ? ? ? ?return result;
? ? ? ?} ? ? ? ?// 根據(jù)不同excel創(chuàng)建不同對象,Excel2003版本-->HSSFWorkbook,Excel2007版本-->XSSFWorkbook
? ? ? ?Workbook wb = null; ? ? ? ?InputStream im = null; ? ? ? ?try {
? ? ? ? ? ?im = xlsFile.getInputStream();
? ? ? ? ? ?wb = WorkbookFactory.create(im); ? ? ? ? ? ?// 根據(jù)頁面index 獲取sheet頁
? ? ? ? ? ?Sheet sheet = wb.getSheetAt(0); ? ? ? ? ? ?Row row = null; ? ? ? ? ? ?// 循環(huán)sheet頁中數(shù)據(jù)從第x行開始,例:第2行開始為導(dǎo)入數(shù)據(jù)
? ? ? ? ? ?for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) { ? ? ? ? ? ? ? ?Applicant applicant = new Applicant(); ? ? ? ? ? ? ? ?// 獲取每一行數(shù)據(jù)
? ? ? ? ? ? ? ?row = sheet.getRow(i); ? ? ? ? ? ? ? ?// 輸出表格內(nèi)容,此處可替換為數(shù)據(jù)插入操作
? ? ? ? ? ? ? ?if (null != row.getCell(0) && "" != row.getCell(0).toString()) {
? ? ? ? ? ? ? ? ? ?applicant.setApplicantName(row.getCell(0).getStringCellValue());
? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ?// 內(nèi)容,表格數(shù)字格式為常規(guī)
? ? ? ? ? ? ? ?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", "導(dǎo)入成功!");
? ? ? ?} catch (Exception e1) { ? ? ? ? ? ?// 回滾數(shù)據(jù)
? ? ? ? ? ?TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
? ? ? ? ? ?e1.printStackTrace();
? ? ? ?} finally { ? ? ? ? ? ?try {
? ? ? ? ? ? ? ?im.close();
? ? ? ? ? ? ? ?wb.close();
? ? ? ? ? ?} catch (IOException e2) {
? ? ? ? ? ? ? ?e2.printStackTrace();
? ? ? ? ? ?}
? ? ? ?} ? ? ? ?return result;
? ?} ? ?
? ?public String toSelectExcel() { ? ? ? ?return "xianadmin/applicant-excel-select";
? ?} ? ?
? ?
? ?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;
? ?} ? ?
? ?
? ?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("申請人總條數(shù):" + applicantCount);
? ? ? ?map.put("pageNum", pageNum);
? ? ? ?map.put("pageSize", pageSize); ? ? ? ?PageInfo page = applicantService.getApplicantListByTime(map);
? ? ? ?map.put("page", page); ? ? ? ?return map;
? ?} ? ?
? ?
? ?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;
? ?}
}
五,項目總結(jié)
本項目基于springboot框架來進(jìn)行開發(fā)實(shí)現(xiàn),符合現(xiàn)在開發(fā)的主流趨勢,項目結(jié)構(gòu)清晰明了,層次分明,采用MVC設(shè)計模式和三層架構(gòu)來進(jìn)行整體設(shè)計。界面布局簡潔大方,操作符合用戶使用習(xí)慣,人機(jī)交互處理的比較人性化,適合做畢業(yè)設(shè)計使用,也可以做課程設(shè)計或期未作業(yè)使用。