java项目-基于SSM实现物流信息管理系统

简介: 基于SSM框架的物流管理系统主要分为三种用户角色,分别是管理员、员工以及客户用户,其具体功能如下:管理员:管理员登录后主要功能模块有个人信息,客户管理,反馈信息,基础信息,货物信息以及货物运输。员工用户:员工用户登录后主要模块有个人信息,配送范围,货物信息,货物运输以及反馈信息。客户用户:客户用户登录后主要模块有个人信息,配送范围,货物信息,货物运输以及反馈信息。

作者主页:编程指南针

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

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

文末获取源码

一,项目简介

基于SSM框架的物流管理系统主要分为三种用户角色,分别是管理员、员工以及客户用户,其具体功能如下:

管理员:管理员登录后主要功能模块有个人信息,客户管理,反馈信息,基础信息,货物信息以及货物运输。

员工用户:员工用户登录后主要模块有个人信息,配送范围,货物信息,货物运输以及反馈信息。

客户用户:客户用户登录后主要模块有个人信息,配送范围,货物信息,货物运输以及反馈信息。

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发:SSM框架

前端开发:Bootstrap+Jquery+Echart

三,系统展示

展示一下部分系统的功能:

用户登陆

image.gif编辑

管理员主功能界面:

image.gif编辑

员工管理

image.gif编辑

客户管理

image.gif编辑

反馈信息

image.gif编辑

基础信息管理

image.gif编辑

货物信息审核

image.gif编辑

货物运输

image.gif编辑

客户角色的管理主界面

image.gif编辑

普通管理用户的管理主界面

四,核心代码展示

package com.action;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import com.model.*;
import com.service.*;
import com.util.*;
@Controller
public class GgtypeAction {
  @Autowired
  private GgtypeService ggtypeService;
  @RequestMapping("/getGgtypes")
  public void getGgtypes(HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    String page = (String) request.getParameter("page");
    String rows = (String) request.getParameter("rows");
    String ggtypeName = (String) request.getParameter("ggtypeName");
    String ggtypeId = (String) request.getParameter("ggtypeId");
    PageBean pageBean = new PageBean(Integer.parseInt(page), Integer.parseInt(rows));
    Ggtype ggtype = new Ggtype();
    try {
      if (StringUtil.isNotEmpty(ggtypeName)) {
        ggtype.setGgtypeName(ggtypeName);
      }
      if (StringUtil.isNotEmpty(ggtypeId)) {
        ggtype.setGgtypeId(Integer.parseInt(ggtypeId));
      }
      JSONArray jsonArray = JSONArray.fromObject(ggtypeService.queryGgtypes(ggtype, pageBean.getStart(), pageBean.getRows()));
      JSONObject result = new JSONObject();
      int total = ggtypeService.queryGgtypes(ggtype, 0, 0).size();
      result.put("rows", jsonArray);
      result.put("total", total);
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/addGgtype")
  public void addGgtype(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    try {
      JSONObject result = new JSONObject();
      String ggtypeName = (String) request.getParameter("ggtypeName");
      String ggtypeMark = (String) request.getParameter("ggtypeMark");
      String ggtypeId = (String) request.getParameter("ggtypeId");
      Ggtype ggtype = new Ggtype();
      if (StringUtil.isNotEmpty(ggtypeId)) {
        ggtype = ggtypeService.getGgtype(Integer.parseInt(ggtypeId));
      }
      if (StringUtil.isNotEmpty(ggtypeName)) {
        ggtype.setGgtypeName(ggtypeName);
      }
      if (StringUtil.isNotEmpty(ggtypeMark)) {
        ggtype.setGgtypeMark(ggtypeMark);
      }
      if (StringUtil.isNotEmpty(ggtypeId)) {
        ggtypeService.modifyGgtype(ggtype);
      } else {
        ggtypeService.save(ggtype);
      }
      result.put("success", "true");
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/deleteGgtype")
  public void deleteGgtype(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    try {
      String delIds = (String) request.getParameter("delIds");
      System.out.println("delIds = " + delIds);
      JSONObject result = new JSONObject();
      String str[] = delIds.split(",");
      for (int i = 0; i < str.length; i++) {
        ggtypeService.deleteGgtype(Integer.parseInt(str[i]));
      }
      result.put("success", "true");
      result.put("delNums", str.length);
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/ggtypeComboList")
  public void ggtypeComboList(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    try {
      JSONArray jsonArray = new JSONArray();
      JSONObject jsonObject = new JSONObject();
      jsonObject.put("id", "");
      jsonObject.put("ggtypeName", "请选择...");
      jsonArray.add(jsonObject);
      jsonArray.addAll(JSONArray.fromObject(ggtypeService.queryGgtypes(null, 0, 0)));
      ResponseUtil.write(response, jsonArray);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

image.gif

package com.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.model.*;
import com.service.*;
@Controller
public class AdminAction {
  @Autowired
  private AdminService adminService;
  @RequestMapping("/mimaAdmin")
  public void mimaAdmin(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    try {
      JSONObject result = new JSONObject();
      String adminPassword = (String) request.getParameter("adminPassword");
      String adminPassword1 = (String) request.getParameter("adminPassword1");
      Admin admin = new Admin();
      admin.setAdminName("admin");
      admin.setAdminPassword(adminPassword);
      if (adminService.queryAdmins(admin, 0, 0).size()==1) {
        admin = (Admin)(adminService.queryAdmins(admin, 0, 0)).get(0);
        admin.setAdminPassword(adminPassword1);
        adminService.modifyAdmin(admin);
        request.setAttribute("error", "密码修改成功!");
        request.getRequestDispatcher("adminmima.jsp").forward(request,
            response);
      }else{
        result.put("success", "true");
        request.setAttribute("error", "原密码错误,请重新输入!");
        request.getRequestDispatcher("adminmima.jsp").forward(request,
            response);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

image.gif

package com.action;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import com.model.*;
import com.service.*;
import com.util.*;
@Controller
public class RoleAction {
  @Autowired
  private RoleService roleService;
  @RequestMapping("/getRoles")
  public void getRoles(HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    String page = (String) request.getParameter("page");
    String rows = (String) request.getParameter("rows");
    String roleName = (String) request.getParameter("roleName");
    String roleId = (String) request.getParameter("roleId");
    String roleMark2 = (String) request.getParameter("roleMark2");
    PageBean pageBean = new PageBean(Integer.parseInt(page), Integer.parseInt(rows));
    Role role = new Role();
    try {
      if (StringUtil.isNotEmpty(roleName)) {
        role.setRoleName(roleName);
      }
      if (StringUtil.isNotEmpty(roleId)) {
        role.setRoleId(Integer.parseInt(roleId));
      }
      if (StringUtil.isNotEmpty(roleMark2)) {
        role.setRoleMark2(Integer.parseInt(roleMark2));
      }
      JSONArray jsonArray = JSONArray.fromObject(roleService.queryRoles(role, pageBean.getStart(), pageBean.getRows()));
      JSONObject result = new JSONObject();
      int total = roleService.queryRoles(role, 0, 0).size();
      result.put("rows", jsonArray);
      result.put("total", total);
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/addRole")
  public void addRole(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    try {
      JSONObject result = new JSONObject();
      String roleName = (String) request.getParameter("roleName");
      String roleMark = (String) request.getParameter("roleMark");
      String roleMark1 = (String) request.getParameter("roleMark1");
      String roleMark2 = (String) request.getParameter("roleMark2");
      String roleId = (String) request.getParameter("roleId");
      Role role = new Role();
      if (StringUtil.isNotEmpty(roleId)) {
        role = roleService.getRole(Integer.parseInt(roleId));
      }
      if (StringUtil.isNotEmpty(roleName)) {
        role.setRoleName(roleName);
      }
      if (StringUtil.isNotEmpty(roleMark)) {
        role.setRoleMark(roleMark);
      }
      if (StringUtil.isNotEmpty(roleMark1)) {
        role.setRoleMark1(roleMark1);
      }
      if (StringUtil.isNotEmpty(roleMark2)) {
        role.setRoleMark2(Integer.parseInt(roleMark2));
      }
      if (StringUtil.isNotEmpty(roleId)) {
        roleService.modifyRole(role);
      } else {
        roleService.save(role);
      }
      result.put("success", "true");
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/deleteRole")
  public void deleteRole(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    try {
      String delIds = (String) request.getParameter("delIds");
      System.out.println("delIds = " + delIds);
      JSONObject result = new JSONObject();
      String str[] = delIds.split(",");
      for (int i = 0; i < str.length; i++) {
        roleService.deleteRole(Integer.parseInt(str[i]));
      }
      result.put("success", "true");
      result.put("delNums", str.length);
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/roleComboList")
  public void roleComboList(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    String roleMark2 = (String) request.getParameter("roleMark2");
    Role role = new Role();
    if (StringUtil.isNotEmpty(roleMark2)) {
      role.setRoleMark2(Integer.parseInt(roleMark2));
    }
    try {
      JSONArray jsonArray = new JSONArray();
      JSONObject jsonObject = new JSONObject();
      jsonObject.put("id", "");
      jsonObject.put("roleName", "请选择...");
      jsonArray.add(jsonObject);
      //jsonArray.addAll(JSONArray.fromObject(roleService.queryRoles(role, 0, 0)));
      ResponseUtil.write(response, jsonArray);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

image.gif

package com.action;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import com.model.*;
import com.service.*;
import com.util.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
//导入导出
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
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.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
@Controller
public class GonggaoAction {
  @Autowired
  private GonggaoService gonggaoService;
  @Autowired
  private GgtypeService ggtypeService;
  /***上传导入开始***/
  private InputStream excelFile;
  public InputStream getExcelFile() {
    return excelFile;
  }
  /***上传导入结束***/
  @RequestMapping("/getGonggaos")
  public void getGonggaos(HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    String page = (String) request.getParameter("page");
    String rows = (String) request.getParameter("rows");
    String gonggaoName = (String) request.getParameter("gonggaoName");
    String gonggaoId = (String) request.getParameter("gonggaoId");
    String ggtypeId = (String) request.getParameter("ggtypeId");
    String sdate = (String) request.getParameter("sdate");
    String edate = (String) request.getParameter("edate");
    PageBean pageBean = new PageBean(Integer.parseInt(page), Integer.parseInt(rows));
    Gonggao gonggao = new Gonggao();
    try {
      if (StringUtil.isNotEmpty(gonggaoName)) {
        gonggao.setGonggaoName(gonggaoName);
      }
      if (StringUtil.isNotEmpty(gonggaoId)) {
        gonggao.setGonggaoId(Integer.parseInt(gonggaoId));
      }
      if (StringUtil.isNotEmpty(ggtypeId)) {
        gonggao.setGgtypeId(Integer.parseInt(ggtypeId));
      }
      JSONArray jsonArray = JSONArray.fromObject(gonggaoService.queryGonggaos(
          gonggao, pageBean.getStart(), pageBean.getRows(), sdate, edate));
      JSONObject result = new JSONObject();
      int total = gonggaoService.queryGonggaos(gonggao, 0, 0, sdate, edate).size();
      result.put("rows", jsonArray);
      result.put("total", total);
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/addGonggao")
  public void addGonggao(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    JSONObject result = new JSONObject();
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    String gonggaoName = (String) request.getParameter("gonggaoName");
    String gonggaoMark = (String) request.getParameter("gonggaoMark");
    String gonggaoDate = (String) request.getParameter("gonggaoDate");
    String ggtypeId = (String) request.getParameter("ggtypeId");
    String gonggaoId = (String) request.getParameter("gonggaoId");
    Gonggao gonggao = new Gonggao();
    if (StringUtil.isNotEmpty(gonggaoId)) {
      gonggao = gonggaoService.getGonggao(Integer.parseInt(gonggaoId));
    }
    if (StringUtil.isNotEmpty(gonggaoName)) {
      gonggao.setGonggaoName(gonggaoName);
    }
    if (StringUtil.isNotEmpty(gonggaoMark)) {
      gonggao.setGonggaoMark(gonggaoMark);
    }
    if (StringUtil.isNotEmpty(gonggaoDate)) {
      gonggao.setGonggaoDate(DateUtil.formatString(gonggaoDate,
          "yyyy-MM-dd hh:mm:ss"));
    }
    if (StringUtil.isNotEmpty(ggtypeId)) {
      gonggao.setGgtypeId(Integer.parseInt(ggtypeId));
      Ggtype ggtype = new Ggtype();
      ggtype = ggtypeService.getGgtype(Integer.parseInt(ggtypeId));
      gonggao.setGgtypeName(ggtype.getGgtypeName());
    }
    try {
      if (StringUtil.isNotEmpty(gonggaoId)) {
        gonggaoService.modifyGonggao(gonggao);
        result.put("success", "true");
        ResponseUtil.write(response, result);
      } else {
        Date date = new Date();
        gonggao.setGonggaoDate(date);
        gonggaoService.save(gonggao);
        result.put("success", "true");
        ResponseUtil.write(response, result);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/deleteGonggao")
  public void deleteGonggao(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    JSONObject result = new JSONObject();
    String delIds = (String) request.getParameter("delIds");
    try {
      String str[] = delIds.split(",");
      for (int i = 0; i < str.length; i++) {
        gonggaoService.deleteGonggao(Integer.parseInt(str[i]));
      }
      result.put("success", "true");
      result.put("delNums", str.length);
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/gonggaoComboList")
  public void gonggaoComboList(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    String ggtypeId = (String) request.getParameter("ggtypeId");
    Gonggao gonggao = new Gonggao();
    if (StringUtil.isNotEmpty(ggtypeId)) {
      gonggao.setGgtypeId(Integer.parseInt(ggtypeId));
    }
    try {
      JSONArray jsonArray = new JSONArray();
      JSONObject jsonObject = new JSONObject();
      jsonObject.put("id", "");
      jsonObject.put("gonggaoName", "请选择...");
      jsonArray.add(jsonObject);
      jsonArray.addAll(JSONArray.fromObject(gonggaoService.queryGonggaos(gonggao, 0, 0, null, null)));
      ResponseUtil.write(response, jsonArray);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/gonggaoTongji")
  public void gonggaoTongji(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    String sdate=request.getParameter("sdate");
    String edate=request.getParameter("edate");
    List<Integer> ggtypeIds = new ArrayList<Integer>();
    List<String> ggtypeNames = new ArrayList<String>();
    List<Integer> gonggaoZongshus = new ArrayList<Integer>();
    List<Ggtype> ggtypes = new ArrayList<Ggtype>();
    List<Gonggao> gonggaos = new ArrayList<Gonggao>();
    Gonggao gonggao = new Gonggao();
    Integer zongshu = 0;
    try {
      ggtypes = ggtypeService.queryGgtypes(null, 0,0);
      for(int i=0;i<ggtypes.size();i++){
        ggtypeIds.add(ggtypes.get(i).getGgtypeId());
        ggtypeNames.add(ggtypes.get(i).getGgtypeName());
      }
      for(int i=0;i<ggtypeIds.size();i++){
        Integer gonggaoZongshu = 0;
        gonggao.setGgtypeId(ggtypeIds.get(i));
        gonggaos = gonggaoService.queryGonggaos(gonggao, 0, 0, sdate, edate);
        for(int j=0;j<gonggaos.size();j++){
          gonggaoZongshu = gonggaoZongshu + gonggaos.size();
        }
        zongshu = zongshu + gonggaoZongshu;
        gonggaoZongshus.add(gonggaoZongshu);
      }
      HttpSession session = request.getSession();
      session.setAttribute("ggtypeNames", ggtypeNames);
      session.setAttribute("gonggaoZongshus", gonggaoZongshus);
      session.setAttribute("zongshu", zongshu);
      response.sendRedirect("admin/gonggaotongji.jsp");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/shangchuanGonggao")
  public void shangchuanGonggao(HttpServletRequest request, HttpServletResponse response,MultipartFile uploadFile)
      throws Exception {
    try {
      String gonggaoId = (String) request.getParameter("gonggaoId");
      String directory = "/file";
      String targetDirectory = request.getSession().getServletContext().getRealPath(directory);
          String fileName = uploadFile.getOriginalFilename();
      File dir = new File(targetDirectory,fileName);
          if(!dir.exists()){
              dir.mkdirs();
          }
          //MultipartFile自带的解析方法
          uploadFile.transferTo(dir);
      String shangchuandizhi = "/file" + "/" + fileName;
      String shangchuanname = fileName;
      Gonggao gonggao = gonggaoService.getGonggao(Integer.parseInt(gonggaoId));
      gonggao.setGonggaoImg(shangchuandizhi);
      gonggao.setGonggaoImgName(shangchuanname);
      gonggaoService.modifyGonggao(gonggao);
      JSONObject result = new JSONObject();
      result.put("success", "true");
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/xiazaiGonggao")
  public void xiazaiGonggao(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    String filename = (String) request.getParameter("filename");
        //模拟文件,myfile.txt为需要下载的文件
        String path = request.getSession().getServletContext().getRealPath("file")+"\\"+filename;
        //获取输入流
        InputStream bis = new BufferedInputStream(new FileInputStream(new File(path)));
        //转码,免得文件名中文乱码
        filename = URLEncoder.encode(filename,"UTF-8");
        //设置文件下载头
        response.addHeader("Content-Disposition", "attachment;filename=" + filename);
        //1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
        response.setContentType("multipart/form-data");
        BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
        int len = 0;
        while((len = bis.read()) != -1){
            out.write(len);
            out.flush();
        }
        out.close();
  }
  @RequestMapping("/daoruGonggao")
  public void daoruGonggao(HttpServletRequest request, HttpServletResponse response,MultipartFile uploadFile)
      throws Exception {
    try {
      String directory = "/file";
      String targetDirectory = request.getSession().getServletContext().getRealPath(directory);
          String fileName = uploadFile.getOriginalFilename();
      File dir = new File(targetDirectory,fileName);
          if(!dir.exists()){
              dir.mkdirs();
          }
          //MultipartFile自带的解析方法
          uploadFile.transferTo(dir);
      excelFile = new FileInputStream(dir);
      Workbook wb = new HSSFWorkbook(excelFile);
      Sheet sheet = wb.getSheetAt(0);
      int rowNum = sheet.getLastRowNum() + 1;
      for (int i = 1; i < rowNum; i++) {
        Gonggao gonggao = new Gonggao();
        Row row = sheet.getRow(i);
        int cellNum = row.getLastCellNum();
        for (int j = 0; j < cellNum; j++) {
          Cell cell = row.getCell(j);
          String cellValue = null;
          switch (cell.getCellType()) { // 判断excel单元格内容的格式,并对其进行转换,以便插入数据库
          case 0:
            cellValue = String.valueOf((int) cell
                .getNumericCellValue());
            break;
          case 1:
            cellValue = cell.getStringCellValue();
            break;
          case 2:
            cellValue = cell.getStringCellValue();
            break;
          }
          switch (j) {// 通过列数来判断对应插如的字段
          case 1:
            gonggao.setGonggaoName(cellValue);
            break;
          case 2:
            gonggao.setGonggaoMark(cellValue);
            break;
          }
        }
        gonggaoService.save(gonggao);
      }
      JSONObject result = new JSONObject();
      result.put("success", "true");
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @RequestMapping("/daochuGonggao")
  public void daochuGonggao(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    String delIds = (String) request.getParameter("delIds");
    JSONObject result = new JSONObject();
    String str[] = delIds.split(",");
    // 创建一个Excel文件
    HSSFWorkbook workbook = new HSSFWorkbook();
    // 创建一个工作表
    HSSFSheet sheet = workbook.createSheet("gonggaos记录");
    // 添加表头行
    HSSFRow hssfRow = sheet.createRow(0);
    // 设置单元格格式居中
    HSSFCellStyle cellStyle = workbook.createCellStyle();
    cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    // 添加表头内容
    HSSFCell headCell = hssfRow.createCell(0);
    headCell.setCellValue("编号");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(1);
    headCell.setCellValue("用户名");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(2);
    headCell.setCellValue("密码");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(3);
    headCell.setCellValue("姓名");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(4);
    headCell.setCellValue("性别");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(5);
    headCell.setCellValue("年龄");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(6);
    headCell.setCellValue("电话");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(7);
    headCell.setCellValue("备注1");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(8);
    headCell.setCellValue("备注2");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(9);
    headCell.setCellValue("备注3");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(10);
    headCell.setCellValue("备注4");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(13);
    headCell.setCellValue("标志1");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(14);
    headCell.setCellValue("备注2");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(15);
    headCell.setCellValue("权限");
    headCell.setCellStyle(cellStyle);
    headCell = hssfRow.createCell(16);
    headCell.setCellValue("部门");
    headCell.setCellStyle(cellStyle);
    // 添加数据内容
    for (int i = 0; i < str.length; i++) {
      hssfRow = sheet.createRow((int) i + 1);
      Gonggao gonggao = gonggaoService.getGonggao(Integer.parseInt(str[i]));
      // 创建单元格,并设置值
      HSSFCell cell = hssfRow.createCell(0);
      cell.setCellValue(gonggao.getGonggaoId());
      cell.setCellStyle(cellStyle);
      cell = hssfRow.createCell(1);
      cell.setCellValue(gonggao.getGonggaoName());
      cell.setCellStyle(cellStyle);
      cell = hssfRow.createCell(7);
      cell.setCellValue(gonggao.getGonggaoMark());
      cell.setCellStyle(cellStyle);
      cell = hssfRow.createCell(16);
      cell.setCellValue(gonggao.getGgtypeName());
      cell.setCellStyle(cellStyle);
    }
    // 保存Excel文件
    try {
      Date date = new Date();
      String strdate = DateUtil.formatDate(date, "yyyyMMddhhmmss");
      OutputStream outputStream = new FileOutputStream("D:/gonggao"
          + strdate + ".xls");
      workbook.write(outputStream);
      outputStream.close();
      result.put("success", "true");
      ResponseUtil.write(response, result);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

image.gif

五,项目总结

  本项目主要基于物流信息的基本管理功能实现的一个信息化管理系统,客户登陆系统后可以添加货物并进行运输信息的选择和添加,普通用户进入系统可以对用户的发货信息进行审核,并根据运输情况改变运输状态,客户在货物运达后可以进行验收操作。整个业务流程十分完整。管理员主要进行基础信息的基本管理,也可以进行相关的业务操作。

相关文章
|
4月前
|
Java API Spring
打造未来电商新引擎:揭秘Java可扩展API设计,让支付与物流灵活如丝,引领电商时代潮流!
【8月更文挑战第30天】本文通过电商平台案例,探讨了如何设计可扩展的Java API。首先定义支付和物流服务的接口与抽象类,然后实现具体服务,接着引入工厂模式或依赖注入管理服务实例,最后通过配置实现灵活扩展。这种设计确保了应用架构的灵活性和长期稳定性。
63 3
|
2月前
|
Java 关系型数据库 MySQL
基于Java的学生成绩管理系统/学生信息管理系统
基于Java的学生成绩管理系统/学生信息管理系统
66 2
|
3月前
|
Java 应用服务中间件 数据库连接
ssm项目整合,简单的用户管理系统
文章介绍了一个使用SSM框架(Spring、SpringMVC、MyBatis)构建的简单用户管理系统的整合过程,包括项目搭建、数据库配置、各层代码实现以及视图展示。
ssm项目整合,简单的用户管理系统
|
2月前
|
SQL Java 数据库连接
快速搭建SSM项目【最全教程】~令狐小哥版
快速搭建SSM项目【最全教程】~令狐小哥版
43 1
|
2月前
|
前端开发 Java 关系型数据库
【保姆级SSM教程】高并发朋友圈点赞项目设计
【保姆级SSM教程】高并发朋友圈点赞项目设计
40 0
|
4月前
|
Java 数据库连接 Maven
SSM框架整合图书管理项目
这篇文章是关于SSM框架整合到图书管理项目的详细教程,涵盖了从Maven项目构建、依赖导入、数据库连接、配置文件编写、实体类和接口实现到SpringMVC整合的完整步骤。
SSM框架整合图书管理项目
|
4月前
|
Java 应用服务中间件 Maven
Mac使用Idea配置传统SSM项目(非maven项目)
Mac使用Idea配置传统SSM项目(非maven项目)
58 1
|
4月前
|
Java 数据库连接 缓存
Hibernate性能调优:五大秘籍,让应用效能飙升,告别慢如蜗牛的加载,体验丝滑般流畅!
【8月更文挑战第31天】本文深入探讨了提升Hibernate应用性能的五大技巧,包括选择合适的缓存策略、优化查询语句、合理使用Eager与Lazy加载、批量操作与事务管理以及利用索引和数据库优化。通过正确配置多级缓存、分页查询、延迟加载、批量处理及合理创建索引,能够显著提高应用响应速度与吞吐量,改善用户体验。这些技巧需根据具体应用场景灵活调整,以实现最佳性能优化效果。
210 0
|
5月前
|
JavaScript Java 测试技术
基于Java的人事管理系统设计和实现(源码+LW+部署讲解)
基于Java的人事管理系统设计和实现(源码+LW+部署讲解)
106 7
|
5月前
|
JavaScript Java 测试技术
基于Java的儿童福利院管理系统设计和实现(源码+LW+部署讲解)
基于Java的儿童福利院管理系统设计和实现(源码+LW+部署讲解)
105 7