基于javaweb+mysql的springboot物流快递在线寄查快递系统(java+springboot+freemarker+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot物流快递在线寄查快递系统(java+springboot+freemarker+mysql)
超级管理员:系统管理、用户管理、网点管理、运输点管理、快递员管理、网点申请管理(审核)、报价管理(时效报价)等。
普通用户:注册登录、个人信息管理(个人资料、密码修改等)、地址管理、实名认证、在线寄件(单件寄件、批量导入寄件)、订单查询(物流信息查询)、在线申请网点、投诉建议等。
网点管理员:揽收负责区域的快递,进行快递快递运输,确认到达快递,快递到达后指派网点下快递员进行派送。
运输点管理员:负责运输至该运输点的快递再次运输。
运行环境:windows/Linux均可、jdk1.8、mysql5.7、idea/eclipse均可。
private OperaterLogService operaterLogService;
/**
* 快递员列表页面
* @param model
* @param user
* @param pageBean
* @return
*/
@RequestMapping(value="/list")
public String list(Model model, User user, PageBean<User> pageBean){
model.addAttribute("title", "快递员列表");
model.addAttribute("username", user.getUsername());
model.addAttribute("pageBean", userService.findList(pageBean,user.getUsername(), UserRoleTypeEnum.COURIER));
return "admin/courier/list";
}
/**
* 新增快递员页面
* @param model
* @return
*/
@RequestMapping(value="/add",method= RequestMethod.GET)
public String add(Model model){
model.addAttribute("roles", roleService.findAllByRoleType(UserRoleTypeEnum.COURIER));
return "admin/courier/add";
}
/**
* 快递员添加表单提交处理
* @param user
* @return
*/
@RequestMapping(value="/add",method= RequestMethod.POST)
@ResponseBody
public Result<Boolean> add(User user){
User loginedUser = SessionUtil.getLoginedUser();
if (loginedUser.getUserType().getCode() != UserRoleTypeEnum.BRANCHES.getCode()){
return Result.error(CodeMsg.COURIER_USER_ROLE_ERROR);
}
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.COURIER_USER_ROLE_EMPTY);
}
@RequestMapping("/orderManagement")
public String orderManagement(Model model){
model.addAttribute("index",3);
return "home/order_management/page";
}
@RequestMapping("/agingQuery")
public String agingQuery(Model model){
model.addAttribute("index",10);
return "home/aging_query/page";
}
@RequestMapping("/index")
public String index(Model model){
HomeUser homeUser = SessionUtil.getHomeUser();
HomeUserIdCard byHomeUserId = homeUserIdCardService.findByHomeUser_Id(homeUser.getId());
String percent = "30%";
if (homeUser.getName() != null || byHomeUserId != null) {
percent = "70%";
}
if (homeUser.getName() != null && byHomeUserId != null){
percent = "100%";
}
model.addAttribute("percent", percent);
model.addAttribute("homeUser", homeUser);
model.addAttribute("byHomeUserId", byHomeUserId);
model.addAttribute("index",1);
return "home/index/index";
}
}
package com.yuanlrc.base.controller.admin;
/**
* 网点申请控制层
*
*/
@RequestMapping("/home/branch")
@Controller
public class HomeBranchApplyForController {
@Autowired
private BranchApplyForService branchApplyForService;
@Autowired
private UserService userService;
/**
* 跳转到申请页面
* @param model
* @return
*/
@RequestMapping("/index")
public String index(Model model, PageBean<BranchApplyFor> pageBean) {
HomeUser homeUser = SessionUtil.getHomeUser();
model.addAttribute("pageBean", branchApplyForService.findList(pageBean, null, homeUser.getId()));
model.addAttribute("index", 6);
model.addAttribute("branchTypes", BranchTypeEnum.values());
return "home/branch/index";
}
/**
* 网点申请保存
* @param branchApplyFor
* @return
@Controller
@RequestMapping("/admin/buyOff")
public class BuyOffController {
@Autowired
private BuyOffService buyOffService;
@Autowired
private UserService userService;
/**
* 发货列表根据订单编号查询
* @param model
* @param waybillNumber
* @param pageBean
* @return
*/
@RequestMapping("/list")
public String list(Model model,String waybillNumber, PageBean<BuyOff> pageBean){
model.addAttribute("waybillNumber",waybillNumber);
model.addAttribute("users",userService.findByUserTypeNot());
model.addAttribute("title", "发货列表");
model.addAttribute("pageBean",buyOffService.findList(pageBean,waybillNumber));
return "admin/buy_off/list";
}
/**
* 指定派送列表根据订单编号查询
* @param model
* @param waybillNumber
* @param pageBean
* @return
*/
@RequestMapping("/deliveryList")
public String findDeliveryList(Model model,String waybillNumber, PageBean<BuyOff> pageBean){
User loginedUser = SessionUtil.getLoginedUser();
model.addAttribute("waybillNumber",waybillNumber);
model.addAttribute("users",userService.findByUserTypeAndBranchIdAndStatus(UserRoleTypeEnum.COURIER,loginedUser.getId(),User.ADMIN_USER_STATUS_ENABLE));
model.addAttribute("title", "指定派送列表");
model.addAttribute("pageBean",buyOffService.findDeliveryList(pageBean,waybillNumber));
return "admin/buy_off/delivery_list";
}
/**
* 快递员派送列表根据订单编号拆线呢
* @param model
* @param waybillNumber
* @param pageBean
* @return
*/
}
}
package com.yuanlrc.base.controller.admin;
/**
* 后台菜单管理控制器
*
*/
@RequestMapping("/admin/menu")
@Controller
public class MenuController {
@Autowired
private MenuService menuService;
@Autowired
private OperaterLogService operaterLogService;
/**
* 菜单列表展示页面
* @param model
* @return
*/
@RequestMapping(value="/list")
public String list(Model model){
List<Menu> findAll = menuService.findAll();
model.addAttribute("title","菜单列表");
model.addAttribute("topMenus",MenuUtil.getTopMenus(findAll));
}
//验证每一位数字都在1-9内
for(int x = 0;x < qq.length();x++) {
char ch = qq.charAt(x);
if(ch < '0' || ch > '9') {
return false;
}
}
return true;
}
/**
* 身份证验证
* @param card
* @return
*/
public static boolean isCard(String card)
{
String checkIdCard = "^(\\d{6})(\\d{4})(\\d{2})(\\d{2})(\\d{3})([0-9]|X)$";
Pattern c = Pattern.compile(checkIdCard);
Matcher m2 = c.matcher(card);
if (m2.matches()){
return true;
}
return false;
}
/**
* 获取编号
* @return
*/
public static String GenerateAUniqueNumber(){
LocalDate today = LocalDate.now();
String todayString = today.toString().replace("-","");
String strCurrentTimeMillis = String.valueOf(System.currentTimeMillis());
String subStrCurrentTimeMillisg = strCurrentTimeMillis.substring(strCurrentTimeMillis.length() - 3);
UUID uuid = UUID.randomUUID();
String uuidString = uuid.toString();
String uuidSubString = uuidString.replace("-", "").substring(26);
return StringUtils.join(todayString, subStrCurrentTimeMillisg, uuidSubString);
}
/**
* 生成唯一字符串
* @return
*/
public static String generateSn(){
return UUID.randomUUID().toString().toUpperCase().replace("-", "");
}
if (1 == buyOffService.signForComplete(id)) {
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER1_BUYOFF1_EDIT_ERROR);
}
return Result.success(true);
}
}
package com.yuanlrc.base.controller.home;
/**
* 网点申请控制层
*
*/
@RequestMapping("/home/branch")
@Controller
public class HomeBranchApplyForController {
* @param menu
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> add(Menu menu){
if(menu == null){
Result.error(CodeMsg.DATA_ERROR);
}
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(menu);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(menu.getParent() != null){
if(menu.getParent().getId() == null){
menu.setParent(null);
}
}
//表示验证都通过,开始添加数据库
if(menuService.save(menu) == null){
Result.error(CodeMsg.ADMIN_MENU_ADD_ERROR);
}
//数据库添加操作成功,记录日志
operaterLogService.add("添加菜单信息【" + menu + "】");
return Result.success(true);
}
/**
* 菜单编辑页面
* @param model
* @param id
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.GET)
public String eidt(Model model,@RequestParam(name="id",required=true)Long id){
List<Menu> findAll = menuService.findAll();
model.addAttribute("title","菜单列表");
model.addAttribute("topMenus",MenuUtil.getTopMenus(findAll));
model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
model.addAttribute("menu",menuService.find(id));
return "admin/menu/edit";
}
/**
*
* @param rsolutionId
* @return
*/
@RequestMapping(value = "/selOrderState", method = RequestMethod.POST)
public String selOrderState(String rsolutionId, String waybillNumberStr,
PageBean<ExpressMailOrder> pageBean, Model model) {
// rsolutionId 2已下单 3处理中 4已完成
pageBean.setPageSize(5);
model.addAttribute("pageBean", expressMailOrderService.selOrderState(pageBean, rsolutionId, waybillNumberStr));
model.addAttribute("rsolutionId", rsolutionId);
return "home/index/order_state_page";
}
/**
* 删除快递订单
*
* @param id
* @return
*/
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public Result<Boolean> delete(@RequestParam(name = "id", required = true) Long id) {
try {
expressMailOrderService.deleteById(id);
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_DELETE_ERROR);
}
return Result.success(true);
}
}
package com.yuanlrc.base.controller.admin;
private BuyOffService buyOffService;
@RequestMapping("/list")
public String list(Model model, ExpressMailOrder expressMailOrder, PageBean<ExpressMailOrder> pageBean){
model.addAttribute("waybillNumber",expressMailOrder.getWaybillNumber());
model.addAttribute("title", "揽收列表");
model.addAttribute("pageBean",expressMailOrderService.findAllByWaybillNumber(expressMailOrder,pageBean));
return "admin/express_mail_order/list";
}
/**
* 订单编辑页面
* @param model
* @return
*/
@RequestMapping(value="/edit",method= RequestMethod.GET)
public String edit(Model model,@RequestParam(name="id",required=true)Long id){
BuyOff buyOff = buyOffService.find(id);
model.addAttribute("expressMailOrder",buyOff.getBuyOffExpressMailOrder());
return "admin/buy_off/edit";
}
/**
* 编辑订单信息信息表单提交处理
* @param expressMailOrder
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> edit(ExpressMailOrder expressMailOrder){
//校验数据是否合法
if (!StringUtil.isMobile(expressMailOrder.getRecipientsMobile()) || null == expressMailOrder.getRecipientsMobile()
|| "".equals(expressMailOrder.getRecipientsMobile())){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_ISMOBILE_EDIT_ERROR);
}
if ("".equals(expressMailOrder.getRecipientsAddress()) || null == expressMailOrder.getRecipientsAddress()){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_ISADDRESS_EDIT_ERROR);
}
if (expressMailOrder.getRecipientsAddress().length() > 50){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_ISADDRESSLENGTH_EDIT_ERROR);
}
ExpressMailOrder expressMailOrderById = expressMailOrderService.find(expressMailOrder.getId());
user.setUserType(UserRoleTypeEnum.COURIER);
user.setBranchId(loginedUser.getId());
//到这说明一切符合条件,进行数据库新增
if(userService.save(user) == null){
return Result.error(CodeMsg.COURIER_USE_ADD_ERROR);
}
operaterLogService.add("添加快递员,快递员名:" + user.getUsername());
return Result.success(true);
}
/**
* 快递员编辑页面
* @param model
* @return
*/
@RequestMapping(value="/edit",method= RequestMethod.GET)
public String edit(Model model, @RequestParam(name="id")Long id){
model.addAttribute("roles", roleService.findAllByRoleType(UserRoleTypeEnum.COURIER));
model.addAttribute("user", userService.find(id));
return "admin/courier/edit";
}
/**
* 编辑快递员信息表单提交处理
* @param user
* @return
*/
@RequestMapping(value="/edit",method= RequestMethod.POST)
@ResponseBody
public Result<Boolean> edit(User user){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.COURIER_USER_ROLE_EMPTY);
}
if(user.getId() == null || user.getId().longValue() <= 0){
return Result.error(CodeMsg.COURIER_USE_NO_EXIST);
}
if(userService.isExistUsername(user.getUsername(), user.getId())){
return Result.error(CodeMsg.COURIER_USERNAME_EXIST);
}
//到这说明一切符合条件,进行数据库保存
User findById = userService.find(user.getId());
//讲提交的快递员信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
BeanUtils.copyProperties(user, findById, "id","createTime","updateTime","userType","branchId");
if(userService.save(findById) == null){
return Result.error(CodeMsg.COURIER_USE_EDIT_ERROR);
@RequestMapping(value="/update_pwd",method=RequestMethod.GET)
public String updatePwd(){
return "admin/system/update_pwd";
}
/**
* 修改密码表单提交
* @param oldPwd
* @param newPwd
* @return
*/
@RequestMapping(value="/update_pwd",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> updatePwd(@RequestParam(name="oldPwd",required=true)String oldPwd,
@RequestParam(name="newPwd",required=true)String newPwd
){
User loginedUser = SessionUtil.getLoginedUser();
if(!loginedUser.getPassword().equals(oldPwd)){
return Result.error(CodeMsg.ADMIN_USER_UPDATE_PWD_ERROR);
}
if(StringUtils.isEmpty(newPwd)){
return Result.error(CodeMsg.ADMIN_USER_UPDATE_PWD_EMPTY);
}
loginedUser.setPassword(newPwd);
//保存数据库
User save = userService.save(loginedUser);
//更新session
SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY, save);
return Result.success(true);
}
/**
* 日志管理列表
* @param model
* @param operaterLog
* @param pageBean
* @return
*/
@RequestMapping(value="/operator_log_list")
public String operatorLogList(Model model,OperaterLog operaterLog,PageBean<OperaterLog> pageBean){
model.addAttribute("pageBean", operaterLogService.findList(operaterLog, pageBean));
model.addAttribute("operator", operaterLog.getOperator());
model.addAttribute("title", "日志列表");
return "admin/system/operator_log_list";
}
/**
* 删除操作日志,可删除多个
* @param ids
* @return
*/
@RequestMapping(value="/delete_operator_log",method=RequestMethod.POST)
}
}
package com.yuanlrc.base.controller.home;
/**
* 网点申请控制层
*
*/
@RequestMapping("/home/branch")
@Controller
public class HomeBranchApplyForController {
@Autowired
private BranchApplyForService branchApplyForService;
@Autowired
private UserService userService;
private HomeUserIdCardService homeUserIdCardService;
/**
* 跳转到个人中心首页
* @param model
* @return
*/
@RequestMapping("/index")
public String index(Model model) {
HomeUser homeUser = SessionUtil.getHomeUser();
model.addAttribute("homeUser", homeUser);
model.addAttribute("index", 4);
model.addAttribute("active", 0);
return "home/user_manager/index";
}
/**
* 修改个人信息
* @param homeUser
* @return
*/
@RequestMapping("/update")
@ResponseBody
public Result<Boolean> update(HomeUser homeUser) {
CodeMsg validate = ValidateEntityUtil.validate(homeUser);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
return Result.error(validate);
}
if (homeUserService.isExistMobile(homeUser.getName(), homeUser.getId())) {
return Result.error(CodeMsg.HOMEUSER_MOBILE_EXIST);
}
HomeUser findById = homeUserService.find(homeUser.getId());
//讲提交的管理员信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
BeanUtils.copyProperties(homeUser, findById, "id", "createTime", "updateTime", "password", "email");
HomeUser save = homeUserService.save(findById);
if (save == null) {
return Result.error(CodeMsg.HOMEUSER_EDIT_ERROR);
}
SessionUtil.set(SessionConstant.SESSION_HOME_USER_LOGIN_KEY, save);
return Result.success(true);
* @param code
* @return
*/
@RequestMapping(value="/forget",method= RequestMethod.POST)
@ResponseBody
public Result<Boolean> forget(HomeUser homeUser, @RequestParam("reCode") String code) {
//正则验证输入的手机号是否合法
String checkPhone = "^1[3|4|5|7|8]\\d{9}$";
Pattern r = Pattern.compile(checkPhone);
Matcher m = r.matcher(homeUser.getMobile());
if (!m.matches()) {
return Result.error(CodeMsg.HOMEUSER_MOBILE_ERROR);
}
if (!StringUtil.emailFormat(homeUser.getEmail())) {
return Result.error(CodeMsg.COMMON_EMAIL_FORMAET_ERROR);
}
if (code == null) {
return Result.error(CodeMsg.HOMEUSER_CODE_ERROR);
}
if (code.length() != 4) {
return Result.error(CodeMsg.HOMEUSER_CODE_LENGTH_ERROR);
}
Object attr = SessionUtil.get(SessionConstant.HOME_USER_FORGET_PASSWORD_CODE);
if (attr == null) {
return Result.error(CodeMsg.CODE_NOT_EMPTY);
}
if (!code.equalsIgnoreCase(attr.toString())) {
return Result.error(CodeMsg.CPACHA_ERROR);
}
//判断手机号是否已注册
HomeUser byMobile = homeUserService.findByMobile(homeUser.getMobile());
if (byMobile == null) {
return Result.error(CodeMsg.HOMEUSER_NO_EXIST);
}
if (!byMobile.getEmail().equals(homeUser.getEmail())){
return Result.error(CodeMsg.CODE_NOT_ERROR);
}
byMobile.setPassword(homeUser.getPassword());
if (homeUserService.save(byMobile) == null) {
return Result.error(CodeMsg.HOMEUSER_FORGET_ERROR);
}
SessionUtil.set(SessionConstant.HOME_USER_FORGET_PASSWORD_CODE, null);
return Result.success(true);
}
if (expressMailOrder.getRecipientsAddress().length() > 50){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_ISADDRESSLENGTH_EDIT_ERROR);
}
ExpressMailOrder expressMailOrderById = expressMailOrderService.find(expressMailOrder.getId());
expressMailOrderById.setRecipientsMobile(expressMailOrder.getRecipientsMobile());
expressMailOrderById.setRecipientsAddress(expressMailOrder.getRecipientsAddress());
expressMailOrderById.setRecipientsFullAddress(expressMailOrder.getRecipientsFullAddress());
//一切合法进行保存
if(expressMailOrderService.save(expressMailOrderById) == null){
return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
}
return Result.success(true);
}
@RequestMapping("/takeDeliveryOfGoods")
@ResponseBody
public Result<Boolean> takeDeliveryOfGoods(@RequestParam(name="id",required=true)Long id){
if (null == id){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_USER_NULL);
}
if(1 == expressMailOrderService.saveExpressMailOrderAndBuyOff(id)){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_RECEIVING_EDIT_ERROR);
}
return Result.success(true);
}
@RequestMapping("/sendTheCargo")
@ResponseBody
public Result<Boolean> sendTheCargo(@RequestParam(name="id",required=true)Long id,
@RequestParam(name="userId",required=true)Long userId){
if (null == id){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_ID_NULL);
}
if (null == userId){
model.addAttribute("index",2);
return "home/online_sent_item/bulk_order_page";
}
@RequestMapping("/orderManagement")
public String orderManagement(Model model){
model.addAttribute("index",3);
return "home/order_management/page";
}
@RequestMapping("/agingQuery")
public String agingQuery(Model model){
model.addAttribute("index",10);
return "home/aging_query/page";
}
@RequestMapping("/index")
public String index(Model model){
HomeUser homeUser = SessionUtil.getHomeUser();
HomeUserIdCard byHomeUserId = homeUserIdCardService.findByHomeUser_Id(homeUser.getId());
String percent = "30%";
if (homeUser.getName() != null || byHomeUserId != null) {
percent = "70%";
}
if (homeUser.getName() != null && byHomeUserId != null){
percent = "100%";
}
model.addAttribute("percent", percent);
model.addAttribute("homeUser", homeUser);
model.addAttribute("byHomeUserId", byHomeUserId);
model.addAttribute("index",1);
return "home/index/index";
}
}
package com.yuanlrc.base.controller.admin;