基于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均可。
if (null == userId){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_USER_NULL);
}
Integer integer = processRecordsService.transportation(id,userId);
if(integer == 1){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_SENDTHECARGO_ADD_EDIT_ERROR);
}
return Result.success(true);
}
/**
* 指定快递员
* @param id
* @return
*/
@RequestMapping("/delivery")
@ResponseBody
public Result<Boolean> delivery(@RequestParam(name="id",required=true)Long id){
if (null == id){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_SENDTHECARGO_ADD_EDIT_ERROR);
}
Integer integer = processRecordsService.delivery(id);
if(integer == 1){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_SENDTHECARGO_ADD_EDIT_ERROR);
}
return Result.success(true);
}
}
* @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)
@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);
}
}
/**
* 后台角色管理控制器
*
*/
@RequestMapping("/admin/role")
@Controller
public class RoleController {
private Logger log = LoggerFactory.getLogger(RoleController.class);
@Autowired
private MenuService menuService;
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private RoleService roleService;
/**
* 分页搜索角色列表
* @param model
* @param role
* @param pageBean
}
/**
* 设置快递继续运输完成
* @param id
* @param userId
* @return
*/
@RequestMapping("/transportation")
@ResponseBody
public Result<Boolean> transportation(@RequestParam(name="id",required=true)Long id,
@RequestParam(name="userId",required=true)Long userId){
if (null == id){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_SENDTHECARGO_ADD_EDIT_ERROR);
}
if (null == userId){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_USER_NULL);
}
Integer integer = processRecordsService.transportation(id,userId);
if(integer == 1){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_SENDTHECARGO_ADD_EDIT_ERROR);
}
return Result.success(true);
}
/**
* 指定快递员
* @param id
* @return
*/
@RequestMapping("/delivery")
@ResponseBody
public Result<Boolean> delivery(@RequestParam(name="id",required=true)Long id){
if (null == id){
return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_SENDTHECARGO_ADD_EDIT_ERROR);
}
Integer integer = processRecordsService.delivery(id);
if(integer == 1){
/**
* 项目通用工具类
*
*/
public class StringUtil {
/**
* 返回指定格式的日期字符串
* @param date
* @param formatter
* @return
*/
public static String getFormatterDate(Date date,String formatter){
SimpleDateFormat sdf = new SimpleDateFormat(formatter);
return sdf.format(date);
}
/**
* 判断请求是否是ajax
* @param request
* @return
*/
public static boolean isAjax(HttpServletRequest request){
String header = request.getHeader("X-Requested-With");
if("XMLHttpRequest".equals(header))return true;
return false;
}
/**
* 从流读取字符串
/**
* 后台管理员管理控制器
*
*/
@RequestMapping("/admin/user")
@Controller
public class UserController {
@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 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.getAddress() == null){
return Result.error(CodeMsg.ADDRESS_ERROR);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.TRANSPORT_USER_ROLE_EMPTY);
}
//判断运输点名是否存在
if(userService.isExistUsername(user.getUsername(), 0L)){
return Result.error(CodeMsg.TRANSPORT_USERNAME_EXIST);
}
user.setUserType(UserRoleTypeEnum.TRANSPORT);
//到这说明一切符合条件,进行数据库新增
if(userService.save(user) == null){
return Result.error(CodeMsg.TRANSPORT_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.TRANSPORT));
model.addAttribute("user", userService.find(id));
return "admin/transport/edit";
}
/**
* 编辑运输点信息表单提交处理
* @param user
* @return
*/
@RequestMapping(value="/edit",method= RequestMethod.POST)
@ResponseBody
public Result<Boolean> edit(User user){
//用统一验证实体方法验证是否合法
* @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)
@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);
}
}
/**
* 前台登录注册控制层
*/
@Controller
@RequestMapping("/home/index")
public class HomeLoginController {
@Autowired
private HomeUserService homeUserService;
/**
* 跳转到登录页面
* @return
*/
@RequestMapping(value="/login",method= RequestMethod.GET)
public String login(){
return "home/login";
}
/**
* 用户登录
* @param mobile
* @param password
* @return
*/
@RequestMapping(value="/login",method= RequestMethod.POST)
@ResponseBody
public Result<Boolean> login(@RequestParam("mobile")String mobile,@RequestParam("password")String password) {
//正则验证输入的手机号是否合法
String checkPhone = "^1[3|4|5|7|8]\\d{9}$";
Pattern r = Pattern.compile(checkPhone);
Matcher m = r.matcher(mobile);
if (!m.matches()) {
return Result.error(CodeMsg.HOMEUSER_MOBILE_ERROR);
}
HomeUser byMobile = homeUserService.findByMobile(mobile);
model.addAttribute("roles", roleService.findAllByRoleType(UserRoleTypeEnum.TRANSPORT));
return "admin/transport/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.getAddress() == null){
return Result.error(CodeMsg.ADDRESS_ERROR);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.TRANSPORT_USER_ROLE_EMPTY);
}
//判断运输点名是否存在
if(userService.isExistUsername(user.getUsername(), 0L)){
return Result.error(CodeMsg.TRANSPORT_USERNAME_EXIST);
}
user.setUserType(UserRoleTypeEnum.TRANSPORT);
//到这说明一切符合条件,进行数据库新增
if(userService.save(user) == null){
return Result.error(CodeMsg.TRANSPORT_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.TRANSPORT));
return Result.error(CodeMsg.CPACHA_ERROR);
}
//验证通过,更新密码
HomeUser byId = homeUserService.findByMobile(homeUser.getMobile());
byId.setPassword(homeUser.getPassword());
if (homeUserService.save(byId) == null) {
return Result.error(CodeMsg.HOMEUSER_FORGET_ERROR);
}
SessionUtil.set(SessionConstant.HOME_USER_UPDATE_PASSWORD_CODE, null);
return Result.success(true);
}
/**
* 跳转到实名认证页面
*
* @param model
* @return
*/
@RequestMapping(value = "/realName")
public String realName(Model model) {
HomeUser homeUser = SessionUtil.getHomeUser();
HomeUserIdCard byHomeUserId = homeUserIdCardService.findByHomeUser_Id(homeUser.getId());
model.addAttribute("homeUser", homeUser);
model.addAttribute("byHomeUserId", byHomeUserId);
model.addAttribute("index", 4);
model.addAttribute("active", 2);
return "home/user_manager/real_name";
}
/**
* 用户进行实名认证
* @param homeUserIdCard
* @param code
* @return
*/
@RequestMapping(value = "/addRealName", method = RequestMethod.POST)
@ResponseBody
public Result<Boolean> addRealName(HomeUserIdCard homeUserIdCard, @RequestParam("code") String code) {
HomeUser homeUser = SessionUtil.getHomeUser();
HomeUserIdCard byHomeUser_id = homeUserIdCardService.findByHomeUser_Id(homeUser.getId());
if (byHomeUser_id != null) {
return Result.error(CodeMsg.HOMEUSERIDCARD_EXIST);
}
CodeMsg validate = ValidateEntityUtil.validate(homeUserIdCard);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
/**
* 运输点管理控制层
*/
@RequestMapping("/admin/transport")
@Controller
public class TransportController {
@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.TRANSPORT));
return "admin/transport/list";
}
/**
* 新增运输点页面
* @param model
@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);
return "home/order_management/order_details";
}
/**
* 进行表单验证进行保存
*
* @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);
}
/**
* @info : 前台用户地址控制层
*/
@RequestMapping("/home/address")
@Controller
public class HomeUserAddressController {
@Autowired
private HomeUserAddressService homeUserAddressService;
/**
* 跳转到地址中心页面
* @param model
* @return
*/
@RequestMapping("/list")
public String address(Model model, PageBean<HomeUserAddress> pageBean,String search,String searchCategory) {
HomeUser homeUser = SessionUtil.getHomeUser();
pageBean.setPageSize(5);
model.addAttribute("homeUser", homeUser);
model.addAttribute("search", search);
model.addAttribute("searchCategory", searchCategory);
model.addAttribute("pageBean", homeUserAddressService.findList(pageBean,search,searchCategory));
model.addAttribute("SENDER", HomeUserTypeEnum.SENDER);
model.addAttribute("RECIPIENT", HomeUserTypeEnum.RECIPIENT);
model.addAttribute("index", 4);
model.addAttribute("active", 1);
return "home/user_manager/address";
}
/**
* 新增用户地址
* @param homeUserAddress
/**
* 系统控制器
*
*/
@RequestMapping("/system")
@Controller
public class SystemController {
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private UserService userService;
@Autowired
private OrderAuthService orderAuthService;
@Autowired
private HomeUserService homeUserService;
@Autowired
private ExpressMailOrderService expressMailOrderService;
@Value("${show.tips.text}")
private String showTipsText;
@Value("${show.tips.url.text}")
private String showTipsUrlText;
@Value("${show.tips.btn.text}")
private String showTipsBtnText;
@Value("${show.tips.url}")
private String showTipsUtl;
private Logger log = LoggerFactory.getLogger(SystemController.class);
}
/**
* 运输点管理控制层
*/
@RequestMapping("/admin/transport")
@Controller
public class TransportController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private OperaterLogService operaterLogService;
/**
/**
* 运输点编辑页面
* @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.TRANSPORT));
model.addAttribute("user", userService.find(id));
return "admin/transport/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.getAddress() == null){
return Result.error(CodeMsg.ADDRESS_ERROR);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.TRANSPORT_USER_ROLE_EMPTY);
}
if(user.getId() == null || user.getId().longValue() <= 0){
return Result.error(CodeMsg.TRANSPORT_USE_NO_EXIST);
}
if(userService.isExistUsername(user.getUsername(), user.getId())){
return Result.error(CodeMsg.TRANSPORT_USERNAME_EXIST);
}
//到这说明一切符合条件,进行数据库保存
User findById = userService.find(user.getId());
//讲提交的运输点信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
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
private BuyOffService buyOffService;
@Autowired
private UserService userService;
/**
* 发货列表根据订单编号查询
* @param model