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

该项目是一个使用JavaWeb、SpringBoot、SSM(Spring、SpringMVC、MyBatis)和Shiro框架开发的物流管理系统。系统采用RBAC角色权限设计,支持不同角色查看和操作不同级别的数据。功能包括客户管理、订单管理、角色和权限管理等,具备完整的业务流程。系统还利用Bootstraptable、zTree等插件增强用户体验。
摘要由CSDN通过智能技术生成

基于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


@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();
    }
}
package cn.oza.logistic.ssm.controller;

@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";
            success += roleService.deleteByPrimaryKey(roleId);
        }
        map.put("status", "true");
        map.put("info", "成功删除选中 " + total + " 个角色中的 " + success + " 个角色");
        return map;
    }

    @RequestMapping("/add")
    @RequiresPermissions("role:insert")
    public String addRole() {
        return "role/add";
    }

    @ResponseBody
    @RequestMapping("/getTree")
    public List<Permission> getTree(){
        ArrayList<Permission> permissions = (ArrayList<Permission>) permissionService.selectByExample(new PermissionExample());
        return permissions;
    }

    @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) {
        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 {
        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));
    @ResponseBody
    @RequestMapping("/getTree")
    public List<Permission> getTree(){
        ArrayList<Permission> permissions = (ArrayList<Permission>) permissionService.selectByExample(new PermissionExample());
        return permissions;
    }

    @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 (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);
    }
}
package cn.oza.logistic.ssm.controller;

    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) {
        }
        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);

        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) {
        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);
        }
        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;
    }
}
package cn.oza.logistic.ssm.controller;

    @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 (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";
    }

        //获取常规数据
        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){
	 */
	public boolean validCallbackName ( String name ) {
		
		if ( name.matches( "^[a-zA-Z_]+[\\w0-9_]*$" ) ) {
			return true;
		}
		
		return false;
		
	}
	
}
package com.baidu.ueditor.upload;

public class BinaryUploader {

	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);
                                        @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")
        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("取件方式");
    }

    /*
    用 @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";
		return state.toJSONString();
		
	}
	
	public int getStartIndex () {
		
		String start = this.request.getParameter( "start" );
		
		try {
			return Integer.parseInt( start );
		} catch ( Exception e ) {
			return 0;
		}
		
	}
	
	/**
	 * callback参数验证
	 */
	public boolean validCallbackName ( String name ) {
		
		if ( name.matches( "^[a-zA-Z_]+[\\w0-9_]*$" ) ) {
			return true;
		}
		
		return false;
		
	}
	
}
package com.baidu.ueditor.upload;

package com.baidu.ueditor.upload;

public class BinaryUploader {

	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;
			}
    public String edit(Model m, Long basicDataId) {
        m.addAttribute("myBasicData", basicDataService.selectByPrimaryKey(basicDataId));

        BasicDataExample basicDataExample = new BasicDataExample();
        BasicDataExample.Criteria criteria = basicDataExample.createCriteria();
        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;
    }
}
package cn.oza.logistic.ssm.controller;

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

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

    @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";
        }

    @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;
    }
}
package com.baidu.ueditor;

        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("体积费率");

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

}
package cn.oza.logistic.ssm.controller;

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

    @Autowired
    private PermissionService permissionService;

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

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

请添加图片描述

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值