项目介绍

仓库管理员角色包含以下功能:
仓库管理员操作,入库操作,员工查看,揽收快件,新建员工等功能。

快递员角色包含以下功能:
员工操作,员工登录,操作成功等功能。

用户角色包含以下功能:
发快递成功,发送快递,查看快递等功能。

管理员角色包含以下功能:
管理员查看全局快递信息等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
5.数据库:MySql 5.7版本;

技术栈

1. 后端:Spring+SpringMVC+Mybatis
2. 前端:HTML+CSS+JavaScript+jsp

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录

java 开源 物流 java物流管理_ssm

 

java 开源 物流 java物流管理_java_02

 

java 开源 物流 java物流管理_java 开源 物流_03

 

java 开源 物流 java物流管理_java_04

 

java 开源 物流 java物流管理_java 开源 物流_05

java 开源 物流 java物流管理_mysql_06

订单管理控制层:

@Controller
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderViewService orderViewService;

    @Autowired
    private OrderService orderService;

    @Autowired
    private UserService userService;

    @Autowired
    private CustomerService customerService;

    @Autowired
    private BasicDataService basicDataService;

    @Autowired
    private OrderDetailService orderDetailService;

    //工具方法
    public PageInfo<OrderView> getOrdersUtil(String keyWord, Integer pageNum, Integer pageSize) {
        //开始分页,这里启动并设置页码,和每页结果数量后,后续结果会自动为分页后结果
        PageHelper.startPage(pageNum, pageSize);

        OrderViewExample orderViewExample = new OrderViewExample();
        OrderViewExample.Criteria criteria = orderViewExample.createCriteria();
        /**
         * StringUtils.isNotBlank 可以判断 ""/" "/null 为 false
         */
        if (StringUtils.isNotBlank(keyWord)) {
            //客户名条件
            criteria.andCustomerNameLike("%" + keyWord + "%");
        }

        //判断当前登录用户是否为业务员,业务员只能查看自己的订单
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        if (user.getRoleId() == ConstantDataField.SALESMAN_ROLE_ID) {
            //客户的业务员用户名等于登录用户的用户名
            criteria.andUsernameEqualTo(user.getUsername());
        }

        List<OrderView> orders = orderViewService.selectByExample(orderViewExample);
        //获得分页对象
        PageInfo<OrderView> pageInfo = new PageInfo<>(orders);

        return pageInfo;
    }

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

    @ResponseBody
    @RequestMapping("/getOrders")
    @RequiresPermissions("order:list")
    public PageInfo<OrderView> getOrders(String keyWord,
                                        @RequestParam(defaultValue = "1") Integer pageNum,
                                        @RequestParam(defaultValue = "10") Integer pageSize) {
        return getOrdersUtil(keyWord, pageNum, pageSize);
    }

    @ResponseBody
    @RequestMapping("/delete")
    @RequiresPermissions("order:delete")
    public Map<String, String> delete(Long[] orderIds) {
        HashMap<String, String> map = new HashMap<>();
        //单个删除
        if (orderIds.length == 1) {
            int res = orderService.deleteByPrimaryKey(orderIds[0]);
            if (res == 1) {
                map.put("status", "true");
                map.put("info", "删除成功!");
                return map;
            }
            map.put("status", "false");
            map.put("info", "删除失败!订单已经不存在");
            return map;
        }
        //批量删除
        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);
        List<OrderDetail> orderDetails = orderDetailService.selectByExample(orderDetailExample);
        m.addAttribute("orderDetails", orderDetails);

        return "order/edit";
    }

    @RequiresPermissions("order:update")
    @RequestMapping("/update")
    @ResponseBody
    public Boolean update(@RequestBody Order order) {
        OrderDetailExample orderDetailExample = new OrderDetailExample();
        orderDetailExample.createCriteria().andOrderIdEqualTo(order.getOrderId());
        List<OrderDetail> dbOrderDetails = orderDetailService.selectByExample(orderDetailExample); //数据库中的orderDetails
        List<OrderDetail> formOrderDetails = order.getorderDetails(); //表单数据中的orderDetails

        //循环比较数据库数据和表单新数据,删除数据库中在修改中删除的数据
        dbOrderDetails.forEach(dbOrderDetail -> {
            if (!formOrderDetails.contains(dbOrderDetail)) {
                orderDetailService.deleteByPrimaryKey(dbOrderDetail.getOrderDetailId());
            }
        });

        //循环比较表单新数据和数据库数据,若存在则修改,不存在则新增
        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);
        List<BasicData> areas = basicDataService.selectByExample(areaExample);
        m.addAttribute("areas", areas);

        //查找付款方式
        BasicDataExample paymentExample = new BasicDataExample();
        paymentExample.createCriteria().andParentIdEqualTo(ConstantDataField.PAYMENT_BASICDATA_ID);
        List<BasicData> payments = basicDataService.selectByExample(paymentExample);
        m.addAttribute("payments", payments);

        //查找运送方式
        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);
    }
}

用户管理控制层:

@Controller
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    private CustomerViewService customerViewService;
    @Autowired
    private CustomerService customerService;
    @Autowired
    private BasicDataService basicDataService;
    @Autowired
    private UserService userService;

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

    @ResponseBody
    @RequestMapping("/getCustomers")
    @RequiresPermissions("customer:list")
    public PageInfo<CustomerView> getCustomers(String keyWord,
                                                 @RequestParam(defaultValue = "1") Integer pageNum,
                                                 @RequestParam(defaultValue = "10") Integer pageSize) {
        //开始分页,这里启动并设置页码,和每页结果数量后,后续结果会自动为分页后结果
        PageHelper.startPage(pageNum, pageSize);

        CustomerViewExample customerViewExample = new CustomerViewExample();
        CustomerViewExample.Criteria criteria = customerViewExample.createCriteria();
        /**
         * StringUtils.isNotBlank 可以判断 ""/" "/null 为 false
         */
        if (StringUtils.isNotBlank(keyWord)) {
            //权限名条件
            criteria.andCustomerNameLike("%" + keyWord + "%");
        }

        //判断当前登录用户是否为业务员,业务员只能查看自己的客户
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        if (user.getRoleId() == ConstantDataField.SALESMAN_ROLE_ID) {
            //客户的业务员id等于登录用户的id
            criteria.andUserIdEqualTo(user.getUserId());
        }

        List<CustomerView> customers = customerViewService.selectByExample(customerViewExample);
        //获得分页对象
        PageInfo<CustomerView> pageInfo = new PageInfo<>(customers);

        return pageInfo;
    }

    @ResponseBody
    @RequestMapping("/delete")
    @RequiresPermissions("customer:delete")
    public Map<String, String> delete(Long[] customerIds) {
        HashMap<String, String> map = new HashMap<>();
        if (customerIds.length == 1) {
            int res = customerService.deleteByPrimaryKey(customerIds[0]);
            if (res == 1) {
                map.put("status", "true");
                map.put("info", "删除成功!");
                return map;
            }
            map.put("status", "false");
            map.put("info", "删除失败!客户已经不存在");
            return map;
        }
        //批量删除
        int success = 0;
        int total = customerIds.length;
        for(Long customerId : customerIds) {
            success += customerService.deleteByPrimaryKey(customerId);
        }
        map.put("status", "true");
        map.put("info", "成功删除选中 " + total + " 个客户中的 " + success + " 个客户");
        return map;
    }


    @RequestMapping("/add")
    @RequiresPermissions("customer:insert")
    public String add(Model m) {
        //查出地区列表
        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);
        m.addAttribute("users", users);

        //查出当前客户
        Customer customer = customerService.selectByPrimaryKey(customerId);
        m.addAttribute("customer", customer);
        return "customer/edit";
    }

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

业务管理控制层: 

@RequestMapping("/transaction")
@Controller
public class TransactionController {
    @Autowired
    private OrderController orderController;

    @Autowired
    private OrderViewService orderViewService;

    @Autowired
    private OrderService orderService;

    @Autowired
    private BasicDataService basicDataService;

    @Autowired
    private OrderDetailService orderDetailService;

    @Autowired
    private UserService userService;

    @Autowired
    private TransactionService transactionService;

    @Autowired
    private TransactionDetailService transactionDetailService;

    @Autowired
    private InfoService infoService;

    @Autowired
    private ExportService exportService;

    @Autowired
    private ExportDetailService exportDetailService;

    @RequestMapping("/list")
    @RequiresPermissions("transaction:deal")
    public String list() {
        return "transaction/list";
    }

    @RequestMapping("/getOrders")
    @RequiresPermissions("transaction:deal")
    @ResponseBody
    public PageInfo<OrderView> getOrders(String keyWord,
                                        @RequestParam(defaultValue = "1") Integer pageNum,
                                        @RequestParam(defaultValue = "10") Integer pageSize) {
        return orderController.getOrdersUtil(keyWord, pageNum, pageSize);
    }

    @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){
                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);
        m.addAttribute("allowedStorage", allowedStorage);

        return "transaction/deal";
    }

    @RequestMapping("/update")
    @RequiresPermissions("transaction:deal")
    @ResponseBody
    public Boolean update(@RequestBody Transaction transaction){
        //判断是否存在
        TransactionExample transactionExample = new TransactionExample();
        transactionExample.createCriteria().andOrderIdEqualTo(transaction.getOrderId());
        int res;
        if (transactionService.selectByExample(transactionExample).size() == 0 ) {
            res = transactionService.insert(transaction);
        } else {
            res = transactionService.updateByPrimaryKeySelective(transaction);
        }
        List<TransactionDetail> transactionDetails = transaction.getTransactionDetails();
        transactionDetails.forEach(transactionDetail -> {
            if (transactionDetail.getTransactionDetailId() == null){
                transactionDetailService.insert(transactionDetail);
            } else {
                transactionDetailService.updateByPrimaryKeySelective(transactionDetail);
            }
        });

        //修改为入库
        Order order = orderService.selectByPrimaryKey(transaction.getOrderId());
        order.setOrderStatus(1);
        orderService.updateByPrimaryKeySelective(order);

        if (res == 1) {
            return true;
        }
        return false;
    }

    @RequestMapping("/export")
    @RequiresPermissions("transaction:export")
    public String export(Model m, Long orderId) {
        //判定是否入库了,若否,返回错误页面
        Order order = orderService.selectByPrimaryKey(orderId);
        if (order.getOrderStatus() == 0) {
            m.addAttribute("errorMsg","该订单还未报价入库!");
            return "transaction/error";
        }

        Info info = null;
        try {
            info = resolveInfo(orderId);
        } catch (Exception e) {
            m.addAttribute("errorMsg", "出现异常,请检查是否完成报价入库!");
            return "transaction/error";
        }

        Info dbInfo = infoService.selectByPrimaryKey(orderId);
        if (dbInfo == null) {
            infoService.insert(info);
        } else {
            infoService.updateByPrimaryKeySelective(info);
        }

        ExportExample exportExample = new ExportExample();
        exportExample.createCriteria().andOrderIdEqualTo(orderId);
        Export export = exportService.selectByExample(exportExample).get(0);
        m.addAttribute("export", export);

        ExportDetailExample exportDetailExample = new ExportDetailExample();
        exportDetailExample.createCriteria().andOrderIdEqualTo(orderId);
        List<ExportDetail> exportDetails = exportDetailService.selectByExample(exportDetailExample);
        m.addAttribute("exportDetails", exportDetails);

        TransactionExample transactionExample = new TransactionExample();
        transactionExample.createCriteria().andOrderIdEqualTo(orderId);
        Transaction transaction = transactionService.selectByExample(transactionExample).get(0);
        m.addAttribute("transaction", transaction);

        m.addAttribute("info", info);

        return "transaction/export";
    }

    @RequiresPermissions("transaction:export")
    @RequestMapping("/print")
    public void print(HttpServletResponse response, Long orderId){
        //查找处需要的信息
        Info info = infoService.selectByPrimaryKey(orderId);

        ExportExample exportExample = new ExportExample();
        exportExample.createCriteria().andOrderIdEqualTo(orderId);
        Export export = exportService.selectByExample(exportExample).get(0);

        ExportDetailExample exportDetailExample = new ExportDetailExample();
        exportDetailExample.createCriteria().andOrderIdEqualTo(orderId);
        List<ExportDetail> exportDetails = exportDetailService.selectByExample(exportDetailExample);

        TransactionExample transactionExample = new TransactionExample();
        transactionExample.createCriteria().andOrderIdEqualTo(orderId);
        Transaction transaction = transactionService.selectByExample(transactionExample).get(0);

        //excel 制作
        HSSFWorkbook book = new HSSFWorkbook();
        HSSFSheet sheet = book.createSheet();


        HSSFRow row_0 = sheet.createRow(0);
        sheet.addMergedRegion(new CellRangeAddress(0,0,1,3));
        sheet.addMergedRegion(new CellRangeAddress(0,0,5,7));
        sheet.addMergedRegion(new CellRangeAddress(0,0,9,11));
        row_0.createCell(0).setCellValue("订单编号");
        row_0.createCell(1).setCellValue(export.getOrderId());
        row_0.createCell(4).setCellValue("业务员");
        row_0.createCell(5).setCellValue(export.getStaff());
        row_0.createCell(8).setCellValue("客户");
        row_0.createCell(9).setCellValue(export.getCustomerName());

        HSSFRow row_1 = sheet.createRow(1);
        sheet.addMergedRegion(new CellRangeAddress(1,1,1,3));
        sheet.addMergedRegion(new CellRangeAddress(1,1,5,7));
        sheet.addMergedRegion(new CellRangeAddress(1,1,9,11));
        row_1.createCell(0).setCellValue("到达国家");
        row_1.createCell(1).setCellValue(export.getArea());
        row_1.createCell(4).setCellValue("收货地址");
        row_1.createCell(5).setCellValue(export.getShippingAddress());
        row_1.createCell(8).setCellValue("收件人");
        row_1.createCell(9).setCellValue(export.getShippingName());

        HSSFRow row_2 = sheet.createRow(2);
        sheet.addMergedRegion(new CellRangeAddress(2,2,1,3));
        sheet.addMergedRegion(new CellRangeAddress(2,2,5,7));
        sheet.addMergedRegion(new CellRangeAddress(2,2,9,11));
        row_2.createCell(0).setCellValue("联系电话");
        row_2.createCell(1).setCellValue(export.getShippingPhone());
        row_2.createCell(4).setCellValue("付款方式");
        row_2.createCell(5).setCellValue(export.getPayment());
        row_2.createCell(8).setCellValue("货运方式");
        row_2.createCell(9).setCellValue(export.getShippingMethod());

        HSSFRow row_3 = sheet.createRow(3);
        sheet.addMergedRegion(new CellRangeAddress(3,3,1,3));
        sheet.addMergedRegion(new CellRangeAddress(3,3,5,7));
        sheet.addMergedRegion(new CellRangeAddress(3,3,9,11));
        row_3.createCell(0).setCellValue("取件方式");
        row_3.createCell(1).setCellValue(export.getPickupMehtod());
        row_3.createCell(4).setCellValue("入库人");
        row_3.createCell(5).setCellValue(export.getStorageStaff());
        row_3.createCell(8).setCellValue("入库选择");
        row_3.createCell(9).setCellValue(export.getStorage());

        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("取件费用");
        row_8.createCell(1).setCellValue(export.getPickUpFee());

        HSSFRow row_9 = sheet.createRow(9);
        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;
        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();
                totalWeight += transactionDetail.getWeight();
            }
        }

        //重量价格
        if (totalWeight / totalVolume < 200) {
            weightFee = totalVolume * 200 * transaction.getWeightRate();
        } else {
            weightFee = totalWeight * transaction.getWeightRate();
        }

        //体积价格
        volumeFee = totalVolume * transaction.getVolumeRate();

        taxFee = totalValue * taxRate;

        totalFee = weightFee + taxFee + volumeFee + transaction.getPickUpFee();

        info.setTaxFee(taxFee);
        info.setTaxRate(taxRate);
        info.setTotalFee(totalFee);
        info.setTotalValue(totalValue);
        info.setTotalWeight(totalWeight);
        info.setTotalVolume(totalVolume);
        info.setVolumeFee(volumeFee);
        info.setWeightFee(weightFee);
        return info;
    }
}