Java Project: Express Logistics Management System (java+SpringBoot+shiro+Bootstrap+ssm+maven+mysql)

Get the source code: Download it from "Resources" on the homepage of the blog!

Project technology:

Using spring boot, a logistics management system developed based on the ssm framework and the shiro security framework. The front end uses the H-ui open source framework, and uses plugins such as Bootstrap table, zTree, PageHelper, and jQuery validate.

Features

1. Based on spring boot and maven;
2. Using spring, spring mvc, mybatis and shiro frameworks;
3. Using RBAC to design the system and using Mysql as database support;
4. Different roles will have different login systems , and will return specific data according to the role;
5. Have basic data management module, administrator management module, role management module, authority management module, customer management module, order management module and business processing module;

6. Able to realize complete business process: add customers, add orders, order processing, financial statements.

illustrate in detail

1. When a salesman accesses, he can only access the customer management, order management, and business processing menus, and only has the right to add, not to modify and delete;
2. When a salesperson adds an order, he can only add it based on the customers he owns;
3. The business manager has all the functions of customer management, order management, and business processing, and can view the customers and orders of all salesmen;
4. The general manager role can view all data, but has no right to modify;
5. The warehouse clerk only has business During processing, the function of measuring item information and warehousing, other data cannot be modified;

6. Finance can view the price details of the review order and export it to an excel sheet.

Operating environment:

1. JDK 1.8;
2. Maven;
3. Tomcat 8;
4. Mysql 8.0/Mysql 5.7.
 

Modify the connection information of the database in application.properties before use. The required tables can be created through the sql file in the dataBase directory, and the database name is logistic_system.

test account

> username:admin

> password:123456

 

 

 

 

 

 

Backend administrator management controller:

/**
 * 后台管理员管理控制器
 * @author yy
 *
 */
@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 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);
		//到这说明一切符合条件,进行数据库新增
		if(userService.save(user) == null){
			return Result.error(CodeMsg.ADMIN_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",required=true)Long id){
		model.addAttribute("roles", roleService.findAllByRoleType(UserRoleTypeEnum.ADMIN));
		model.addAttribute("user", userService.find(id));
		return "admin/user/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.ADMIN_USER_ROLE_EMPTY);
		}
		if(user.getId() == null || user.getId().longValue() <= 0){
			return Result.error(CodeMsg.ADMIN_USE_NO_EXIST);
		}
		if(userService.isExistUsername(user.getUsername(), user.getId())){
			return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
		}
		//到这说明一切符合条件,进行数据库保存
		User findById = userService.find(user.getId());
		//讲提交的管理员信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
		BeanUtils.copyProperties(user, findById, "id","createTime","updateTime","userType");
		if(userService.save(findById) == null){
			return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
		}
		operaterLogService.add("编辑管理员,管理员名:" + user.getUsername());
		return Result.success(true);
	}
	
	/**
	 * 删除管理员
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	@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);
	}
}

Background role management controller:

/**
 * 后台角色管理控制器
 * @author yy
 *
 */
@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
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model,Role role,PageBean<Role> pageBean){
		model.addAttribute("title", "角色列表");
		model.addAttribute("name", role.getName());
		model.addAttribute("pageBean", roleService.findByName(role, pageBean));
		return "admin/role/list";
	}
	
	/**
	 * 角色添加页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		List<Menu> findAll = menuService.findAll();
		model.addAttribute("roleTypes", UserRoleTypeEnum.values());
		model.addAttribute("topMenus",MenuUtil.getTopMenus(findAll));
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		model.addAttribute("thirdMenus",MenuUtil.getThirdMenus(findAll));
		return "admin/role/add";
	}
	
	/**
	 * 角色添加表单提交处理
	 * @param role
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> add(Role role){
		Role top1ByRoleType = roleService.findTop1ByRoleTypeAndRoleTypeNot(role.getRoleType());
		if (top1ByRoleType != null){
			return Result.error(CodeMsg.ADMIN_ROLE_EXIST);
		}
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(role);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(roleService.save(role) == null){
			return Result.error(CodeMsg.ADMIN_ROLE_ADD_ERROR);
		}
		log.info("添加角色【"+role+"】");
		operaterLogService.add("添加角色【"+role.getName()+"】");
		return Result.success(true);
	}
	
	/**
	 * 角色编辑页面
	 * @param id
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public String edit(@RequestParam(name="id",required=true)Long id,Model model){
		List<Menu> findAll = menuService.findAll();
		model.addAttribute("topMenus",MenuUtil.getTopMenus(findAll));
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		model.addAttribute("thirdMenus",MenuUtil.getThirdMenus(findAll));
		Role role = roleService.find(id);
		model.addAttribute("role", role);
		model.addAttribute("authorities",JSONArray.toJSON(role.getAuthorities()).toString());
		model.addAttribute("roleTypes", UserRoleTypeEnum.values());
		return "admin/role/edit";
	}
	
	/**
	 * 角色修改表单提交处理
	 * @param request
	 * @param role
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> edit(Role role){
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(role);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		Role existRole = roleService.find(role.getId());
		if(existRole == null){
			return Result.error(CodeMsg.ADMIN_ROLE_NO_EXIST);
		}
		existRole.setName(role.getName());
		existRole.setRemark(role.getRemark());
		existRole.setStatus(role.getStatus());
		existRole.setAuthorities(role.getAuthorities());
		if(roleService.save(existRole) == null){
			return Result.error(CodeMsg.ADMIN_ROLE_EDIT_ERROR);
		}
		log.info("编辑角色【"+role+"】");
		operaterLogService.add("编辑角色【"+role.getName()+"】");
		return Result.success(true);
	}
	
	/**
	 * 删除角色
	 * @param request
	 * @param id
	 * @return
	 */
	@RequestMapping(value="delete",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
		try {
			roleService.delete(id);
		} catch (Exception e) {
			// TODO: handle exception
			return Result.error(CodeMsg.ADMIN_ROLE_DELETE_ERROR);
		}
		log.info("编辑角色ID【"+id+"】");
		operaterLogService.add("删除角色ID【"+id+"】");
		return Result.success(true);
	}
}

Record control layer:

@Controller
@RequestMapping("/admin/processRecords")
public class ProcessRecordsController {

    @Autowired
    private ProcessRecordsService processRecordsService;


    @Autowired
    private UserService userService;

    /**
     * 进入运输收货列表根据订单编号查询
     * @param pageBean
     * @param waybillNumber
     * @param model
     * @return
     */
    @RequestMapping("/list")
    public String list(PageBean<ProcessRecords> pageBean, String waybillNumber, Model model) {
        User loginedUser = SessionUtil.getLoginedUser();
        model.addAttribute("title", "运输收货列表");
        model.addAttribute("waybillNumber", waybillNumber);
        model.addAttribute("UserRoleTypeEnum",loginedUser.getUserType().getCode());
        model.addAttribute("pageBean", processRecordsService.findList(pageBean, waybillNumber));
        return "admin/process_records/list";
    }

    /**
     * 进入执行运输列表根据订单编号查询
     * @param pageBean
     * @param waybillNumber
     * @param model
     * @return
     */
    @RequestMapping("/receiveList")
    public String receiveList(PageBean<ProcessRecords> pageBean, String waybillNumber, Model model) {
        model.addAttribute("title", "运输列表");
        model.addAttribute("waybillNumber", waybillNumber);
        model.addAttribute("users",userService.findByUserTypeNot());
        model.addAttribute("pageBean", processRecordsService.findListByWaybillNumber(pageBean, waybillNumber));
        return "admin/process_records/receive_list";
    }

    /**
     * 网点拾取快递并添加流程记录
     * @param id
     * @return
     */
    @RequestMapping("/takeDeliveryOfGoods")
    @ResponseBody
    public Result<Boolean> takeDeliveryOfGoods(@RequestParam(name="id",required=true)Long id){

        if (null == id){
            return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER1_RECEIVING_EDIT_ERROR);
        }

        ProcessRecords processRecords = processRecordsService.find(id);
        processRecords.setOperation(ProcessRecords.HAVE_HANDLED);

        //讲提交的管理员信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
        ProcessRecords newProcessRecords = new ProcessRecords();
        BeanUtils.copyProperties(processRecords, newProcessRecords,"id","createTime","updateTime");
        newProcessRecords.setTravelPosition(ExpressMailOrderStatus.INTRANSIT);
        newProcessRecords.setId(null);
        newProcessRecords.setOperation(ProcessRecords.NO_OPERATIONS);
        ProcessRecords saveNew = processRecordsService.save(newProcessRecords);
        if (null == saveNew){
            return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER1_RECEIVING_EDIT_ERROR);
        }
        ProcessRecords save = processRecordsService.save(processRecords);
        if (null == save){
            return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER1_RECEIVING_EDIT_ERROR);
        }
        return Result.success(true);
    }

    /**
     * 设置快递继续运输完成
     * @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){
            return Result.error(CodeMsg.ADMIN_EXPRESSMAILORDER_SENDTHECARGO_ADD_EDIT_ERROR);
        }
        return Result.success(true);
    }




}

Get the source code: Download it from "Resources" on the homepage of the blog!

Guess you like

Origin blog.csdn.net/yuyecsdn/article/details/124145940