基于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均可。
}
/**
* 菜单添加提交表单处理
* @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 expressMailOrder
* @return
*/
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Result<Boolean> add(ExpressMailOrder expressMailOrder) {
expressMailOrder.setWaybillNumber(StringUtil.GenerateAUniqueNumber());
//进行实体类验证
CodeMsg validate = ValidateEntityUtil.validate(expressMailOrder);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
return Result.error(validate);
}
//验证成功进行保存
if (expressMailOrderService.save(expressMailOrder) == null) {
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_ADD_ERROR);
}
//保存成功返回成功消息
return Result.success(true);
}
/**
* 进行设置上门送件时间
*
* @param expressMailOrderId
* @return
*/
@RequestMapping(value = "/setPickUpTime", method = RequestMethod.POST)
@ResponseBody
public Result<Boolean> setPickUpTime(String pickUpTime, Long expressMailOrderId) {
ExpressMailOrder expressMailOrder = expressMailOrderService.find(expressMailOrderId);
if (expressMailOrder.getOrderStatus().equals(ExpressMailOrderStatus.SIGNFOR)){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_SETPICKUPTIME_ERROR1);
}
SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition parseposition = new ParsePosition(0);
Date date = simpledateformat.parse(pickUpTime, parseposition);
expressMailOrder.setPickUpTime(date);
//验证成功进行保存
if (expressMailOrderService.save(expressMailOrder) == null) {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
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.ADMIN));
return "admin/user/list";
}
/**
* 新增管理员页面
* @param model
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.GET)
public String add(Model model){
model.addAttribute("roles", roleService.findAllByRoleType(UserRoleTypeEnum.ADMIN));
return "admin/user/add";
}
/**
* 管理员添加表单提交处理
* @param user
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> add(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.ADMIN_USER_ROLE_EMPTY);
}
//判断管理员名是否存在
if(userService.isExistUsername(user.getUsername(), 0L)){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
}
user.setUserType(UserRoleTypeEnum.ADMIN);
@ResponseBody
public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
try {
userService.delete(id);
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_USE_DELETE_ERROR);
}
operaterLogService.add("删除管理员,管理员ID:" + id);
return Result.success(true);
}
}
@Controller
@RequestMapping("/admin/expressMailOrder")
public class AdminExpressMailOrderController {
@Autowired
private ExpressMailOrderService expressMailOrderService;
@Autowired
private ProcessRecordsService processRecordsService;
@Autowired
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";
}
BuyOff save = buyOffService.save(buyOff);
if (null == save) {
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER1_BUYOFF_EDIT_ERROR);
}
return Result.success(true);
}
/**
* 快递员签收
* @param id
* @return
*/
@RequestMapping("/signFor")
@ResponseBody
public Result<Boolean> signFor(@RequestParam("id") Long id){
if (null == id){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER1_BUYOFF1_EDIT_ERROR);
}
if (1 == buyOffService.signForComplete(id)) {
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER1_BUYOFF1_EDIT_ERROR);
}
return Result.success(true);
}
}
/**
* 删除网点申请
* @param id
* @return
*/
@RequestMapping(value = "/deleteApplyFor", method = RequestMethod.POST)
@ResponseBody
public Result<Boolean> deleteApplyFor(@RequestParam(name = "id", required = false) Long id) {
BranchApplyFor branchApplyFor = branchApplyForService.find(id);
if (branchApplyFor.getBranchApplyForStatus().getCode() == 0) {
return Result.error(CodeMsg.BRANCHAPPLYFOR_STATUS_ERROR);
}
if (branchApplyFor.getBranchApplyForStatus().getCode() == 1) {
return Result.error(CodeMsg.BRANCHAPPLYFOR_STATUSNOT_ERROR);
}
try {
branchApplyForService.delete(id);
} catch (Exception e) {
return Result.error(CodeMsg.BRANCHAPPLYFOR_DELETE_ERROR);
}
return Result.success(true);
}
}
@Configuration
@RequestMapping("/home/entryPage")
/**
* @info 快递员控制层
*/
@RequestMapping("/admin/courier")
@Controller
public class CourierController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
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)
@Controller
@RequestMapping("/admin/expressMailOrder")
public class AdminExpressMailOrderController {
@Autowired
private ExpressMailOrderService expressMailOrderService;
@Autowired
private ProcessRecordsService processRecordsService;
@Autowired
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());
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
}
return Result.success(true);
}
/**
* 点击修改时弹出层要回显数据
*
* @param id
* @return
*/
@RequestMapping("/initializeForm")
@ResponseBody
public Result<HomeUserAddress> initializeForm(@RequestParam("id") Long id) {
HomeUserAddress homeUserAddress = homeUserAddressService.find(id);
return Result.success(homeUserAddress);
}
/**
* 用户修改地址
* @param homeUserAddress
* @return
*/
@RequestMapping("/update")
@ResponseBody
public Result<Boolean> update(HomeUserAddress homeUserAddress) {
HomeUser homeUser = SessionUtil.getHomeUser();
CodeMsg validate = ValidateEntityUtil.validate(homeUserAddress);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
return Result.error(validate);
}
if (homeUserAddress.getMobile() == null && homeUserAddress.getPhone() == null) {
return Result.error(CodeMsg.HOMEUSERADDRESS_MOBILE_PHONE_ERROR);
}
if ("".equals(homeUserAddress.getMobile()) && "".equals(homeUserAddress.getPhone())) {
return Result.error(CodeMsg.HOMEUSERADDRESS_MOBILE_PHONE_ERROR);
}
if (homeUserAddress.getIsDefault() == 0) {
HomeUserAddress byIsDefault = homeUserAddressService.findByIsDefaultAndHomeUserTypeAndHomeUser_Id(
HomeUserAddress.DEFAULT,homeUserAddress.getHomeUserType(),homeUser.getId());
if (byIsDefault != null) {
byIsDefault.setIsDefault(1);
if (homeUserAddressService.save(byIsDefault) == null) {
return Result.error(CodeMsg.HOMEUSERADDRESS_ADD_ERROR);
}
}
}
HomeUserAddress byId = homeUserAddressService.find(homeUserAddress.getId());
//讲提交的管理员信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
BeanUtils.copyProperties(homeUserAddress, byId, "id", "createTime", "updateTime", "homeUser");
@Configuration
@RequestMapping("/home/entryPage")
public class EntryPageController {
@Autowired
private HomeUserAddressService homeUserAddressService;
@Autowired
private HomeUserIdCardService homeUserIdCardService;
@RequestMapping("/singletonPage")
public String singletonPage(Model model) {
HomeUser homeUser = SessionUtil.getHomeUser();
HomeUserAddress defaultRecipientsInfo = homeUserAddressService.findByIsDefaultAndHomeUserTypeAndHomeUser_Id(HomeUserAddress.DEFAULT, HomeUserTypeEnum.RECIPIENT,homeUser.getId());
HomeUserAddress defaultSenderInfo = homeUserAddressService.findByIsDefaultAndHomeUserTypeAndHomeUser_Id(HomeUserAddress.DEFAULT, HomeUserTypeEnum.SENDER,homeUser.getId());
List<HomeUserAddress> senderInfoList = homeUserAddressService.findByHomeUserTypeAndHomeUser_Id(HomeUserTypeEnum.SENDER, homeUser.getId());
List<HomeUserAddress> recipientsInfoList = homeUserAddressService.findByHomeUserTypeAndHomeUser_Id(HomeUserTypeEnum.RECIPIENT, homeUser.getId());
model.addAttribute("senderInfoList",senderInfoList);
model.addAttribute("recipientsInfoList",recipientsInfoList);
model.addAttribute("defaultSenderInfo",defaultSenderInfo);
model.addAttribute("defaultRecipientsInfo",defaultRecipientsInfo);
model.addAttribute("paymentMethodEnum", PaymentMethodEnum.values());
model.addAttribute("homeUser",SessionUtil.getHomeUser());
model.addAttribute("index",2);
return "home/online_sent_item/singleton_page";
}
@RequestMapping("/bulkOrderPage")
public String bulkOrderPage(Model model) {
HomeUser homeUser = SessionUtil.getHomeUser();
HomeUserAddress defaultSenderInfo = homeUserAddressService.findByIsDefaultAndHomeUserTypeAndHomeUser_Id(HomeUserAddress.DEFAULT, HomeUserTypeEnum.SENDER,homeUser.getId());
List<HomeUserAddress> senderInfoList = homeUserAddressService.findByHomeUserTypeAndHomeUser_Id(HomeUserTypeEnum.SENDER, homeUser.getId());
model.addAttribute("senderInfoList",senderInfoList);
model.addAttribute("defaultSenderInfo",defaultSenderInfo);
model.addAttribute("paymentMethodEnum", PaymentMethodEnum.values());
model.addAttribute("homeUser",SessionUtil.getHomeUser());
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")
@RequestParam(name="userId",required=true)Long userId){
if (null == id){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_ID_NULL);
}
if (null == userId){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_USER_NULL);
}
Integer integer = processRecordsService.ChangeStatusSaveProcess(id, userId,
ExpressMailOrderStatus.THEGOODS, ExpressMailOrderStatus.COMPLETED);
if(integer == 1){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_SENDTHECARGO_ADD_EDIT_ERROR);
}
return Result.success(true);
}
}
@Controller
@RequestMapping("/admin/buyOff")
public class BuyOffController {
@Autowired
return Result.success(true);
}
}
@Configuration
@RequestMapping("/home/entryPage")
public class EntryPageController {
@Autowired
private HomeUserAddressService homeUserAddressService;
@Autowired
private HomeUserIdCardService homeUserIdCardService;
@RequestMapping("/singletonPage")
public String singletonPage(Model model) {
HomeUser homeUser = SessionUtil.getHomeUser();
HomeUserAddress defaultRecipientsInfo = homeUserAddressService.findByIsDefaultAndHomeUserTypeAndHomeUser_Id(HomeUserAddress.DEFAULT, HomeUserTypeEnum.RECIPIENT,homeUser.getId());
HomeUserAddress defaultSenderInfo = homeUserAddressService.findByIsDefaultAndHomeUserTypeAndHomeUser_Id(HomeUserAddress.DEFAULT, HomeUserTypeEnum.SENDER,homeUser.getId());
List<HomeUserAddress> senderInfoList = homeUserAddressService.findByHomeUserTypeAndHomeUser_Id(HomeUserTypeEnum.SENDER, homeUser.getId());
List<HomeUserAddress> recipientsInfoList = homeUserAddressService.findByHomeUserTypeAndHomeUser_Id(HomeUserTypeEnum.RECIPIENT, homeUser.getId());
model.addAttribute("senderInfoList",senderInfoList);
model.addAttribute("recipientsInfoList",recipientsInfoList);
model.addAttribute("defaultSenderInfo",defaultSenderInfo);
model.addAttribute("defaultRecipientsInfo",defaultRecipientsInfo);
model.addAttribute("paymentMethodEnum", PaymentMethodEnum.values());
model.addAttribute("homeUser",SessionUtil.getHomeUser());
model.addAttribute("index",2);
}
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 model
* @return
*/
@RequestMapping("/updatePassword")
public String updatePassword(Model model) {
HomeUser homeUser = SessionUtil.getHomeUser();
model.addAttribute("homeUser", homeUser);
model.addAttribute("index", 4);
return "home/user_manager/update_password";
}
/**
* 修改密码
* @param homeUser
* @param code
* @return
*/
@RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
@ResponseBody
public Result<Boolean> updatePassword(HomeUser homeUser, @RequestParam("code") 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);
* @info 快递员控制层
*/
@RequestMapping("/admin/courier")
@Controller
public class CourierController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
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 ids
* @return
*/
@RequestMapping(value="/delete_operator_log",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> delete(String ids){
if(!StringUtils.isEmpty(ids)){
String[] splitIds = ids.split(",");
for(String id : splitIds){
operaterLogService.delete(Long.valueOf(id));
}
}
return Result.success(true);
}
/**
* 清空整个日志
* @return
*/
@RequestMapping(value="/delete_all_operator_log",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> deleteAll(){
operaterLogService.deleteAll();
return Result.success(true);
}
}
operaterLogService.add("删除快递员,快递员ID:" + id);
return Result.success(true);
}
}
@Controller
@RequestMapping("/home/expressMailOrder")
public class HomeExpressMailOrderController {
@Autowired
private ExpressMailOrderService expressMailOrderService;
@Autowired
private BuyOffService buyOffService;
@Autowired
private ProcessRecordsService processRecordsService;
@RequestMapping("/orderDetails")
public String orderManagement(Model model,@RequestParam(name="expressMailOrderId",required=true) Long expressMailOrderId){
model.addAttribute("processRecordsList",processRecordsService.findByExpressMailOrder_Id(expressMailOrderId));
model.addAttribute("expressMailOrder",expressMailOrderService.find(expressMailOrderId));
model.addAttribute("buyOffList",buyOffService.findByBuyOffExpressMailOrder_IdOrderByCreateTime(expressMailOrderId));
model.addAttribute("index",10);