基于javaweb+mysql的springboot快递物流管理系统(java+springboot+shiro+bootstrap+ssm+maven+mysql+jsp)

基于javaweb+mysql的springboot快递物流管理系统(java+springboot+shiro+bootstrap+ssm+maven+mysql+jsp)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot快递物流管理系统(java+springboot+shiro+bootstrap+ssm+maven+mysql+jsp)

项目技术:

使用 spring boot,基于 ssm 框架和 shiro 安全框架,开发的一个物流管理系统。前端使用的是 H-ui 开源框架,运用了 Bootstrap table、zTree、PageHelper、jQuery validate 等插件。

特点

  1. 基于 spring boot、maven 构建; 2. 运用了 spring、spring mvc、mybatis 和 shiro 框架; 3. 采用了 RBAC 的思路设计系统,采用了 Mysql 作为数据库支持; 4. 不同的角色登录系统会有不同的菜单列表,且会根据角色返回特定的数据; 5. 拥有基础数据管理模块,管理员管理模块,角色管理模块,权限管理模块,客户管理模块,订单管理模块和业务处理模块;

  2. 能够实现完整的业务流程:添加客户、添加订单、订单处理、财务报表。

细节介绍

  1. 业务员访问时,只能访问客户管理、订单管理、业务处理菜单,且只有添加的权力,没有修改和删除的权力; 2. 业务员添加订单时,只能基于自己拥有的客户添加; 3. 业务经理拥有客户管理、订单管理、业务处理的所有功能,可以查看所有业务员的客户和订单; 4. 总经理角色可以查看所有数据,但是没有修改的权力; 5. 仓管员只有业务处理中,测量物品信息和入库的功能,其他数据不可修改;

  2. 财务可以查看审核订单价格详情并导出为 excel 表格。

运行环境:

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

使用前修改 application.properties 里的数据库的连接信息即可。可以通过 dataBase 目录下的 sql 文件创建所需要的表,数据库名字为 logistic_system。

测试账号

username:admin

password:123456

    @ResponseBody
    @RequestMapping("/insert")
    @RequiresPermissions("role:insert")
    public Boolean insert(Role role){
        int res = roleService.insert(role);
        if (res == 1)
            return true;
        return false;
    }

    @ResponseBody
    @RequestMapping("/checkRole")
    @RequiresPermissions("role:list")
    public Boolean checkRole(String name, String curName) {
        if (curName != null && name.equals(curName)) {
            return true;
        }
        RoleExample roleExample = new RoleExample();
        RoleExample.Criteria criteria = roleExample.createCriteria();
        criteria.andRolenameEqualTo(name);
        if (roleService.selectByExample(roleExample).size() != 0) {
            return false;
        }
        return true;
    }

    @RequestMapping("/edit")
    @RequiresPermissions("role:update")
    public String edit(Model m, Long roleId) {
        m.addAttribute("role", roleService.selectByPrimaryKey(roleId));
        return "role/edit";
    }

    @ResponseBody
    @RequestMapping("/update")
    @RequiresPermissions("role:update")
    public Boolean update(Role role) {
        int res = roleService.updateByPrimaryKeySelective(role);
        if (res == 1) {
            return true;
        }
        return false;
    }
        //查出地区列表
        BasicDataExample basicDataExample = new BasicDataExample();
        basicDataExample.createCriteria().andParentIdEqualTo(ConstantDataField.AREA_BASICDATA_ID);
        List<BasicData> basicDatas= basicDataService.selectByExample(basicDataExample);
        m.addAttribute("areas",basicDatas);

        //获取当前登录用户
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();

        //如果是业务员进行操作,只能选择自己作为业务员
        List<User> users = new ArrayList<>();
        if (user.getRoleId() == ConstantDataField.SALESMAN_ROLE_ID) {
            users.add(user);
        } else {
            UserExample userExample = new UserExample();
            userExample.createCriteria().andRoleIdEqualTo(ConstantDataField.SALESMAN_ROLE_ID);
            users = userService.selectByExample(userExample);
        }
        m.addAttribute("users", users);

        return "customer/add";
    }

    @ResponseBody
    @RequestMapping("/insert")
    @RequiresPermissions("customer:insert")
    public Boolean insert(Customer customer){
        int res = customerService.insert(customer);
        if (res == 1) {
            return true;
        }
        return false;
    }

    @RequestMapping("/edit")
    @RequiresPermissions("customer:update")
    public String edit(Model m, Long customerId) {
        //查出地区列表
        BasicDataExample basicDataExample = new BasicDataExample();
        basicDataExample.createCriteria().andParentIdEqualTo(ConstantDataField.AREA_BASICDATA_ID);
        List<BasicData> basicDatas= basicDataService.selectByExample(basicDataExample);
        m.addAttribute("areas",basicDatas);

        //查出业务员
        UserExample userExample = new UserExample();
        userExample.createCriteria().andRoleIdEqualTo(ConstantDataField.SALESMAN_ROLE_ID);
        List<User> users = userService.selectByExample(userExample);

@Controller
@RequestMapping("/permission")
public class PermissionController {
    @Autowired
    private PermissionService permissionService;

    @RequestMapping("/list")
    @RequiresPermissions("permission:list")
    public String permissionList() {
        return "permission/list";
    }

    /**
     * 该方法返回 admin 集合的 JSON 字符串,使用 PageHelper 工具进行分页
     * @param keyWord 搜索关键字
     * @param pageNum 页数,默认为 1
     * @param pageSize 每个页面用户容量,默认为 10/页
     * @return
     */
    @ResponseBody
    @RequestMapping("/getPermissions")
    @RequiresPermissions("permission:list")
    public PageInfo<Permission> getPermissions(String keyWord,
                                               @RequestParam(defaultValue = "1") Integer pageNum,
                                               @RequestParam(defaultValue = "10") Integer pageSize) {
        //开始分页,这里启动并设置页码,和每页结果数量后,后续结果会自动为分页后结果
        PageHelper.startPage(pageNum, pageSize);

        PermissionExample permissionExample = new PermissionExample();

        /**
         * StringUtils.isNotBlank 可以判断 ""/" "/null 为 false
         */
        if (StringUtils.isNotBlank(keyWord)) {
    @RequestMapping("/list")
    @RequiresPermissions("admin:list")
    public String adminList() {
        return "admin/list";
    }

    /**
     * 该方法返回 admin 集合的 JSON 字符串,使用 PageHelper 工具进行分页
     * @param keyWord 搜索关键字
     * @param pageNum 页数,默认为 1
     * @param pageSize 每个页面用户容量,默认为 10/页
     * @return
     */
    @ResponseBody
    @RequestMapping("/getAdmins")
    @RequiresPermissions("admin:list")
    public PageInfo<User> getAdmins(String keyWord,
                                @RequestParam(defaultValue = "1") Integer pageNum,
                                @RequestParam(defaultValue = "10") Integer pageSize) {
        //开始分页,这里启动并设置页码,和每页结果数量后,后续结果会自动为分页后结果
        PageHelper.startPage(pageNum, pageSize);

        UserExample userExample = new UserExample();

        /**
         * StringUtils.isNotBlank 可以判断 ""/" "/null 为 false
         */
        if (StringUtils.isNotBlank(keyWord)) {
            //用户名条件
            UserExample.Criteria criteriaUserName = userExample.createCriteria();
            criteriaUserName.andUsernameLike("%" + keyWord + "%");

            //真实名字条件
            UserExample.Criteria criteriaRealName = userExample.createCriteria();
            criteriaRealName.andRealnameLike("%" + keyWord + "%");

            //将两个条件用 or 组合
            userExample.or(criteriaRealName);
        }

        //批量删除
        int success = 0;
        int total = orderIds.length;
        for(Long orderId : orderIds) {
            success += orderService.deleteByPrimaryKey(orderId);
        }
        map.put("status", "true");
        map.put("info", "成功删除选中 " + total + " 个订单中的 " + success + " 个订单");
        return map;
    }

    @RequestMapping("/add")
    @RequiresPermissions("order:insert")
    public String add(Model m) {
        this.getOrderGeneralData(m);
        return "order/add";
    }

    /*
    用 @RequestBody 注解,将前台传入的 JSON 字符串解析成对象
     */
    @RequestMapping("/insert")
    @RequiresPermissions("order:insert")
    @ResponseBody
    @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED, timeout = 5)
    public Boolean insert(@RequestBody Order order) {
        //插入 order,在此之后,order 获得了 orderId
        int res = orderService.insert(order);
        //获取订单详情集合
        List<OrderDetail> orderDetails = order.getorderDetails();
        orderDetails.forEach(orderDetail -> {
            orderDetail.setOrderId(order.getOrderId());
            orderDetailService.insert(orderDetail);
        });
        if (res == 1) {
            return true;
        }
        return false;
    }

    @RequestMapping("/edit")
    @RequiresPermissions("order:update")
    public String edit(Long orderId, Model m) {
        //获取常规数据
        getOrderGeneralData(m);

        //添加选中的订单
        Order selectedOrder = orderService.selectByPrimaryKey(orderId);
        m.addAttribute("selectedOrder", selectedOrder);

        //添加订单详情
        OrderDetailExample orderDetailExample = new OrderDetailExample();
        orderDetailExample.createCriteria().andOrderIdEqualTo(orderId);
}

@Controller
public class IndexController {
    @RequiresPermissions("system:index")
    @RequestMapping(value = {"/index", ""})
    public String index() {
        return "index";
    }

    @RequestMapping("/welcome")
    @RequiresPermissions("system:index")
    public String welcome() {
        return "welcome";
    }

    @RequestMapping("/login")
    public String login(HttpServletRequest request, Model m) {
        //获取认证失败的错误信息,在Shiro框架的 FormAuthenticationFilter 过滤器中共享
        //共享的属性名称  shiroLoginFailure , 通过 request 获取共享的 shiro 异常的字节码
        String shiroLoginFailure = String.valueOf(request.getAttribute("shiroLoginFailure"));

        if (UnknownAccountException.class.getName().equals(shiroLoginFailure)) {
            m.addAttribute("errorMsg", "账户不存在");
        } else if (IncorrectCredentialsException.class.getName().equals(shiroLoginFailure)) {
            m.addAttribute("errorMsg", "密码错误");
        }

        return "login";
    }

    @RequestMapping("/checkVerifyCode")
    @ResponseBody
    public Boolean checkVerifyCode(String verifyCode, HttpSession session) {
        String randCode = String.valueOf(session.getAttribute("rand"));
        if (randCode.compareToIgnoreCase(verifyCode) == 0) {
            return true;
        }
        return false;

	public static final State save(HttpServletRequest request,
			Map<String, Object> conf) {
		FileItemStream fileStream = null;
		boolean isAjaxUpload = request.getHeader( "X_Requested_With" ) != null;

		if (!ServletFileUpload.isMultipartContent(request)) {
			return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT);
		}

		ServletFileUpload upload = new ServletFileUpload(
				new DiskFileItemFactory());

        if ( isAjaxUpload ) {
            upload.setHeaderEncoding( "UTF-8" );
        }

		try {
			FileItemIterator iterator = upload.getItemIterator(request);

			while (iterator.hasNext()) {
				fileStream = iterator.next();

				if (!fileStream.isFormField())
					break;
				fileStream = null;
			}

			if (fileStream == null) {
				return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
			}

			String savePath = (String) conf.get("savePath");
			String originFileName = fileStream.getName();
			String suffix = FileType.getSuffixByFilename(originFileName);

			originFileName = originFileName.substring(0,
					originFileName.length() - suffix.length());
			savePath = savePath + suffix;

			long maxSize = ((Long) conf.get("maxSize")).longValue();

			if (!validType(suffix, (String[]) conf.get("allowFiles"))) {
				return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
        criteria.andParentIdIsNull();
        m.addAttribute("basicDatas", basicDataService.selectByExample(basicDataExample));
        return "basicData/edit";
    }

    @ResponseBody
    @RequestMapping("/update")
    @RequiresPermissions("basicData:update")
    public Boolean update(BasicData basicData) {
        int res = basicDataService.updateByPrimaryKey(basicData);
        if (res == 1) {
            return true;
        }
        return false;
    }
}

@Controller
@RequestMapping("/permission")
public class PermissionController {
    @Autowired
    private PermissionService permissionService;

    @RequestMapping("/list")
    @RequiresPermissions("permission:list")
    public String permissionList() {
        return "permission/list";
    }

    /**
    }

    @RequestMapping("/deal")
    public String deal(Model m, Long orderId) {
        Order order = orderService.selectByPrimaryKey(orderId);

        OrderViewExample orderViewExample = new OrderViewExample();
        orderViewExample.createCriteria().andOrderIdEqualTo(orderId);
        OrderView orderView = orderViewService.selectByExample(orderViewExample).get(0);

        String area = basicDataService.selectByPrimaryKey(order.getIntervalId()).getBaseName();

        String payment = basicDataService.selectByPrimaryKey(order.getPaymentMethodId()).getBaseName();

        String shippingMethod = basicDataService.selectByPrimaryKey(order.getFreightMethodId()).getBaseName();

        String pickUpMethod = basicDataService.selectByPrimaryKey(order.getTakeMethodId()).getBaseName();

        BasicDataExample basicDataExample = new BasicDataExample();
        basicDataExample.createCriteria().andParentIdEqualTo(ConstantDataField.STORAGE_BASICDATA_ID);
        List<BasicData> storages = basicDataService.selectByExample(basicDataExample);

        OrderDetailExample orderDetailExample = new OrderDetailExample();
        orderDetailExample.createCriteria().andOrderIdEqualTo(orderId);
        List<OrderDetail> orderDetails = orderDetailService.selectByExample(orderDetailExample);

        BasicDataExample basicDataExample1 = new BasicDataExample();
        basicDataExample.createCriteria().andParentIdEqualTo(ConstantDataField.UNIT_BASICDATA_ID);
        List<BasicData> units = basicDataService.selectByExample(basicDataExample1);

        UserExample userExample = new UserExample();
        userExample.createCriteria().andRoleIdEqualTo(ConstantDataField.STORAGE_ROLE_ID);
        List<User> users = userService.selectByExample(userExample);

        TransactionExample transactionExample = new TransactionExample();
        transactionExample.createCriteria().andOrderIdEqualTo(orderId);
        List<Transaction> transactions = transactionService.selectByExample(transactionExample);

        List<TransactionDetail> transactionDetails = new ArrayList<>();
        orderDetails.forEach(orderDetail -> {
            TransactionDetailExample transactionDetailExample = new TransactionDetailExample();
            transactionDetailExample.createCriteria().andOrderDetailIdEqualTo(orderDetail.getOrderDetailId());
            List<TransactionDetail> details = transactionDetailService.selectByExample(transactionDetailExample);
            if (details.size() == 0){
        sheet.addMergedRegion(new CellRangeAddress(9,9,1,11));
        row_9.createCell(0).setCellValue("总费用");
        row_9.createCell(1).setCellValue(export.getTotalFee());

        HSSFRow row_10 = sheet.createRow(10);
        sheet.addMergedRegion(new CellRangeAddress(10,10,0,11));
        row_10.createCell(0).setCellValue("货物清单");

        HSSFRow row_11 = sheet.createRow(11);
        sheet.addMergedRegion(new CellRangeAddress(11,11,0,1));
        sheet.addMergedRegion(new CellRangeAddress(11,11,7,8));
        sheet.addMergedRegion(new CellRangeAddress(11,11,9,10));
        row_11.createCell(0).setCellValue("货物名称");
        row_11.createCell(2).setCellValue("数量");
        row_11.createCell(3).setCellValue("单位");
        row_11.createCell(4).setCellValue("长");
        row_11.createCell(5).setCellValue("宽");
        row_11.createCell(6).setCellValue("高");
        row_11.createCell(7).setCellValue("核算体积");
        row_11.createCell(9).setCellValue("核算重量");
        row_11.createCell(11).setCellValue("总价值");

        for(int i = 0; i < exportDetails.size(); i++) {
            HSSFRow row = sheet.createRow(i + 12);
            sheet.addMergedRegion(new CellRangeAddress(i+12,i+12,0,1));
            sheet.addMergedRegion(new CellRangeAddress(i+12,i+12,7,8));
            sheet.addMergedRegion(new CellRangeAddress(i+12,i+12,9,10));
            row.createCell(0).setCellValue(exportDetails.get(i).getGoodsName());
            row.createCell(2).setCellValue(exportDetails.get(i).getGoodsNumber());
            row.createCell(3).setCellValue(exportDetails.get(i).getGoodsUnit());
            row.createCell(4).setCellValue(exportDetails.get(i).getLength());
            row.createCell(5).setCellValue(exportDetails.get(i).getWidth());
            row.createCell(6).setCellValue(exportDetails.get(i).getHeight());
            row.createCell(7).setCellValue(exportDetails.get(i).getVolume());
            row.createCell(9).setCellValue(exportDetails.get(i).getWeight());
            row.createCell(11).setCellValue(exportDetails.get(i).getGoodsTotal());
        }

        try {
            response.addHeader("Content-Disposition",
                    "attachment;filename=" + new String("财务审核表.xls".getBytes(), "ISO-8859-1"));
            book.write(response.getOutputStream());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //添加info 方法
    private Info resolveInfo(Long orderId) {
        Info info = new Info();
        info.setOrderId(orderId);

        Double totalVolume = 0.0;
        Double totalWeight = 0.0;

        HSSFRow row_4 = sheet.createRow(4);
        sheet.addMergedRegion(new CellRangeAddress(4,4,0,11));
        row_4.createCell(0).setCellValue("费用明细");

        HSSFRow row_5 = sheet.createRow(5);
        sheet.addMergedRegion(new CellRangeAddress(5,5,1,3));
        sheet.addMergedRegion(new CellRangeAddress(5,5,5,7));
        sheet.addMergedRegion(new CellRangeAddress(5,5,9,11));
        row_5.createCell(0).setCellValue("体积收费");
        row_5.createCell(1).setCellValue(export.getVolumeFee());
        row_5.createCell(4).setCellValue("总体积");
        row_5.createCell(5).setCellValue(export.getTotalVolume());
        row_5.createCell(8).setCellValue("体积费率");
        row_5.createCell(9).setCellValue(transaction.getVolumeRate());

        HSSFRow row_6 = sheet.createRow(6);
        sheet.addMergedRegion(new CellRangeAddress(6,6,1,3));
        sheet.addMergedRegion(new CellRangeAddress(6,6,5,7));
        sheet.addMergedRegion(new CellRangeAddress(6,6,9,11));
        row_6.createCell(0).setCellValue("重量收费");
        row_6.createCell(1).setCellValue(export.getWeightFee());
        row_6.createCell(4).setCellValue("总重量");
        row_6.createCell(5).setCellValue(export.getTotalWeight());
        row_6.createCell(8).setCellValue("重量费率");
        row_6.createCell(9).setCellValue(transaction.getWeightRate());

        HSSFRow row_7 = sheet.createRow(7);
        sheet.addMergedRegion(new CellRangeAddress(7,7,1,3));
        sheet.addMergedRegion(new CellRangeAddress(7,7,5,7));
        sheet.addMergedRegion(new CellRangeAddress(7,7,9,11));
        row_7.createCell(0).setCellValue("过关税费");
        row_7.createCell(1).setCellValue(export.getTaxFee());
        row_7.createCell(4).setCellValue("总价值");
        row_7.createCell(5).setCellValue(export.getTotalValue());
        row_7.createCell(8).setCellValue("税率");
        row_7.createCell(9).setCellValue(info.getTaxRate());

        HSSFRow row_8 = sheet.createRow(8);
        sheet.addMergedRegion(new CellRangeAddress(8,8,1,11));
        row_8.createCell(0).setCellValue("取件费用");
    public String edit(Model m, Long userId) {
        m.addAttribute("user", userService.selectByPrimaryKey(userId));
        m.addAttribute("roles", roleService.selectByExample(new RoleExample()));
        return "admin/edit";
    }

    @ResponseBody
    @RequestMapping("/update")
    @RequiresPermissions("admin:update")
    public Boolean update(User user) {
        if (StringUtils.isBlank(user.getPassword())) {
            user.setPassword(null);
        } else {
            String salt = UUID.randomUUID().toString().substring(0, 4);
            //String hashedPassword = new SimpleHash("md5", user.getPassword(), salt, 3).toString();
            //user.setPassword(hashedPassword);
            user.setSalt(salt);
        }
        int res = userService.updateByPrimaryKeySelective(user);
        if (res == 1) {
            return true;
        }
        return false;
    }
}

@Controller

        UserExample userExample = new UserExample();
        userExample.createCriteria().andRoleIdEqualTo(ConstantDataField.STORAGE_ROLE_ID);
        List<User> users = userService.selectByExample(userExample);

        TransactionExample transactionExample = new TransactionExample();
        transactionExample.createCriteria().andOrderIdEqualTo(orderId);
        List<Transaction> transactions = transactionService.selectByExample(transactionExample);

        List<TransactionDetail> transactionDetails = new ArrayList<>();
        orderDetails.forEach(orderDetail -> {
            TransactionDetailExample transactionDetailExample = new TransactionDetailExample();
            transactionDetailExample.createCriteria().andOrderDetailIdEqualTo(orderDetail.getOrderDetailId());
            List<TransactionDetail> details = transactionDetailService.selectByExample(transactionDetailExample);
            if (details.size() == 0){
                transactionDetails.add(null);
            } else {
                transactionDetails.add(details.get(0));
            }

        });

        Subject subject = SecurityUtils.getSubject();
        Boolean allowedQuote = subject.isPermitted("transaction:quote");
        Boolean allowedStorage = subject.isPermitted("transaction:storage");

        m.addAttribute("order", order);
        m.addAttribute("orderView", orderView);
        m.addAttribute("area", area);
        m.addAttribute("payment", payment);
        m.addAttribute("shippingMethod", shippingMethod);
        m.addAttribute("pickUpMethod", pickUpMethod);
        m.addAttribute("storages", storages);
        m.addAttribute("orderDetails", orderDetails);
        m.addAttribute("units", units);
        m.addAttribute("users", users);
        if (transactions.size() > 0) {
            m.addAttribute("transaction", transactions.get(0));
        } else {
            m.addAttribute("transaction", null);
        }
        m.addAttribute("transactionDetails",transactionDetails);
        m.addAttribute("allowedQuote", allowedQuote);
        });

        //循环比较表单新数据和数据库数据,若存在则修改,不存在则新增
        formOrderDetails.forEach(formOrderDetail -> {
            if (dbOrderDetails.contains(formOrderDetail)) {
                orderDetailService.updateByPrimaryKeySelective(formOrderDetail);
            } else {
                formOrderDetail.setOrderId(order.getOrderId());
                orderDetailService.insert(formOrderDetail);
            }
        });

        //修改Order
        int res = orderService.updateByPrimaryKey(order);
        if (res == 1){
            return true;
        }
        return false;
    }

    //抽取的工具方法
    private void getOrderGeneralData(Model m){
        User user = (User)SecurityUtils.getSubject().getPrincipal(); //获取当前用户
        Long userRoleId = user.getRoleId(); //当前用户角色ID
        Long userId = user.getUserId(); //当前用户ID

        //查找业务员
        UserExample userExample = new UserExample();
        List<User> users = new ArrayList<>();
        //如果当前用户是业务员只能用自己用户添加
        if (userRoleId == ConstantDataField.SALESMAN_ROLE_ID) {
            users.add(userService.selectByPrimaryKey(userId));
        } else {
            userExample.createCriteria().andRoleIdEqualTo(ConstantDataField.SALESMAN_ROLE_ID);
            users = userService.selectByExample(userExample);
        }
        m.addAttribute("users", users);

        //查找客户
        CustomerExample customerExample = new CustomerExample();
        List<Customer> customers;
        //如果当前用户是业务员只能获得自己的客户
        if (userRoleId == ConstantDataField.SALESMAN_ROLE_ID) {
            customerExample.createCriteria().andUserIdEqualTo(userId);
            customers = customerService.selectByExample(customerExample);
        } else {
            customers = customerService.selectByExample(customerExample);
        }
        m.addAttribute("customers", customers);

        //查找地区
        BasicDataExample areaExample = new BasicDataExample();
        areaExample.createCriteria().andParentIdEqualTo(ConstantDataField.AREA_BASICDATA_ID);

        //查找运送方式
        BasicDataExample transportExample = new BasicDataExample();
        transportExample.createCriteria().andParentIdEqualTo(ConstantDataField.TRANSPORT_BASICDATA_ID);
        List<BasicData> transports = basicDataService.selectByExample(transportExample);
        m.addAttribute("transports", transports);

        //查找取件方式
        BasicDataExample pickupExample = new BasicDataExample();
        pickupExample.createCriteria().andParentIdEqualTo(ConstantDataField.PICKUP_BASICDATA_ID);
        List<BasicData> pickups = basicDataService.selectByExample(pickupExample);
        m.addAttribute("pickups", pickups);

        //查找单位
        BasicDataExample unitExample = new BasicDataExample();
        unitExample.createCriteria().andParentIdEqualTo(ConstantDataField.UNIT_BASICDATA_ID);
        List<BasicData> units = basicDataService.selectByExample(unitExample);
        m.addAttribute("units", units);
    }
}

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //添加info 方法
    private Info resolveInfo(Long orderId) {
        Info info = new Info();
        info.setOrderId(orderId);

        Double totalVolume = 0.0;
        Double totalWeight = 0.0;
        Double totalValue =0.0;
        Double taxRate = 0.0;
        Double weightFee = 0.0;
        Double volumeFee = 0.0;
        Double taxFee = 0.0;
        Double totalFee = 0.0;

        //获取订单
        Order order = orderService.selectByPrimaryKey(orderId);

        //获得税率
        if (order.getFreightMethodId() == ConstantDataField.SEA_BASICDATA_ID){
            if (order.getIntervalId() == ConstantDataField.SINGAPORE_BASICDATA_ID || order.getIntervalId() == ConstantDataField.AUSTRALIA_BASICDATA_ID) {
                taxRate = 0.07;
            }
        }

        //获取业务
        TransactionExample transactionExample = new TransactionExample();
        transactionExample.createCriteria().andOrderIdEqualTo(orderId);
        Transaction transaction = transactionService.selectByExample(transactionExample).get(0);

        //获取订单详情
        OrderDetailExample orderDetailExample = new OrderDetailExample();
        orderDetailExample.createCriteria().andOrderIdEqualTo(orderId);
        List<OrderDetail> orderDetails = orderDetailService.selectByExample(orderDetailExample);

        //获取业务详情,同时计算出总重量、总体积、总价值
        for (OrderDetail orderDetail : orderDetails) {
            TransactionDetailExample transactionDetailExample = new TransactionDetailExample();
            transactionDetailExample.createCriteria().andOrderDetailIdEqualTo(orderDetail.getOrderDetailId());
            List<TransactionDetail> transactionDetails = transactionDetailService.selectByExample(transactionDetailExample);
            //计算
            totalValue += orderDetail.getGoodsTotal();
            for (TransactionDetail transactionDetail : transactionDetails) {
                totalVolume += transactionDetail.getVolume();
    }

    /**
     * setUsePrefix(true)用于解决一个奇怪的bug。在引入spring aop的情况下。
     * 在@Controller注解的类的方法中加入@RequiresRole等shiro注解,会导致该方法无法映射请求,导致返回404。
     * 加入这项配置能解决这个bug
     */
    @Bean
    public static DefaultAdvisorAutoProxyCreator getDefaultAdvisorAutoProxyCreator(){
        DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator=new DefaultAdvisorAutoProxyCreator();
        defaultAdvisorAutoProxyCreator.setUsePrefix(true);
        return defaultAdvisorAutoProxyCreator;
    }

}

@Controller
@RequestMapping("role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    @Autowired

        //查找取件方式
        BasicDataExample pickupExample = new BasicDataExample();
        pickupExample.createCriteria().andParentIdEqualTo(ConstantDataField.PICKUP_BASICDATA_ID);
        List<BasicData> pickups = basicDataService.selectByExample(pickupExample);
        m.addAttribute("pickups", pickups);

        //查找单位
        BasicDataExample unitExample = new BasicDataExample();
        unitExample.createCriteria().andParentIdEqualTo(ConstantDataField.UNIT_BASICDATA_ID);
        List<BasicData> units = basicDataService.selectByExample(unitExample);
        m.addAttribute("units", units);
    }
}

@Controller
@RequestMapping("/customer")
public class CustomerController {
    @Autowired

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值