文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Java实战之超市收银管理系统的实现

2024-04-02 19:55

关注

一、项目简述

本系统主要实现的功能有:收银、报表、用户管理、商品管理、销售管理、进货退货管理、仓库管 理等等功能。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: Spring+ SpringMVC + MyBatis + ThymeLeaf + JavaScript + JQuery + Ajax + maven等等

三、效果图

四、核心代码

品类信息控制层


@RestController
@RequestMapping("/category")
public class CategoryController {
 
    @Autowired
    private CategoryService categoryService;
 
 
    
    @SysLog("类别查询操作")
    @RequestMapping("/categoryList")
    public DataGridViewResult categoryList(CategoryVO categoryVO) {
 
        //创建分页信息    参数1 当前页  参数2 每页显示条数
        IPage<Category> page = new Page<>(categoryVO.getPage(), categoryVO.getLimit());
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(!StringUtils.isEmpty(categoryVO.getCatename()),"catename", categoryVO.getCatename());
        IPage<Category> categoryIPage = categoryService.page(page, queryWrapper);
        
        return new DataGridViewResult(categoryIPage.getTotal(),categoryIPage.getRecords());
 
    }
 
    
    @SysLog("类别删除操作")
    @RequestMapping("/deleteList")
    public Result deleteList(String ids) {
        //将字符串拆分成数组
        String[] idsStr = ids.split(",");
        List<String> list = Arrays.asList(idsStr);
        boolean bool = categoryService.removeByIds(list);
        if(bool){
            return Result.success(true,"200","删除成功!");
        }
        return Result.error(false,null,"删除失败!");
    }
 
    
    @SysLog("类别添加操作")
    @PostMapping("/addcategory")
    public Result addCategory(Category category){
        boolean bool = categoryService.save(category);
        if(bool){
            return Result.success(true,"200","添加成功!");
        }
        return Result.error(false,null,"添加失败!");
    }
 
    
    @SysLog("类别修改操作")
    @PostMapping("/updatecategory")
    public Result updateCategory(Category category){
 
        boolean bool = categoryService.updateById(category);
        if(bool){
            return Result.success(true,"200","修改成功!");
        }
        return Result.error(false,null,"修改失败!");
    }
 
    
    @SysLog("类别删除操作")
    @RequestMapping("/deleteOne")
    public Result deleteOne(int id) {
 
        boolean bool = categoryService.removeById(id);
        if(bool){
            return Result.success(true,"200","删除成功!");
        }
        return Result.error(false,null,"删除失败!");
    }
}

用户信息控制层


@RestController
@RequestMapping("/customer")
public class CustomerController {
 
    @Autowired
    private CustomerService customerService;
 
 
    
    @SysLog("客户查询操作")
    @RequestMapping("/customerList")
    public DataGridViewResult customerList(CustomerVO customerVO) {
 
        //创建分页信息    参数1 当前页  参数2 每页显示条数
        IPage<Customer> page = new Page<>(customerVO.getPage(), customerVO.getLimit());
        QueryWrapper<Customer> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(!StringUtils.isEmpty(customerVO.getCustvip()),"custvip", customerVO.getCustvip());
        IPage<Customer> customerIPage = customerService.page(page, queryWrapper);
        
        return new DataGridViewResult(customerIPage.getTotal(),customerIPage.getRecords());
 
    }
 
    
    @SysLog("客户删除操作")
    @RequestMapping("/deleteList")
    public Result deleteList(String ids) {
        //将字符串拆分成数组
        String[] idsStr = ids.split(",");
        List<String> list = Arrays.asList(idsStr);
        boolean bool = customerService.removeByIds(list);
        if(bool){
            return Result.success(true,"200","删除成功!");
        }
        return Result.error(false,null,"删除失败!");
    }
 
    
    @SysLog("客户添加操作")
    @PostMapping("/addcustomer")
    public Result addCustomer(Customer customer){
        String id = RandomStringUtils.randomAlphanumeric(10);
 
        customer.setCustvip(id);
        boolean bool = customerService.save(customer);
        if(bool){
            return Result.success(true,"200","添加成功!");
        }
        return Result.error(false,null,"添加失败!");
    }
 
    
    @SysLog("客户修改操作")
    @PostMapping("/updatecustomer")
    public Result updateCustomer(Customer customer){
 
        boolean bool = customerService.updateById(customer);
        if(bool){
            return Result.success(true,"200","修改成功!");
        }
        return Result.error(false,null,"修改失败!");
    }
 
    
    @SysLog("客户删除操作")
    @RequestMapping("/deleteOne")
    public Result deleteOne(int id) {
 
        boolean bool = customerService.removeById(id);
        if(bool){
            return Result.success(true,"200","删除成功!");
        }
        return Result.error(false,null,"删除失败!");
    }
 
 
 
    
    @RequestMapping("/loadAllCustomer")
    public DataGridViewResult loadAllCustomer(){
        QueryWrapper<Customer> queryWrapper = new QueryWrapper<>();
        List<Customer> list = customerService.list(queryWrapper);
        return new DataGridViewResult(list);
 
    }
 
}

商品信息控制层


@RestController
@RequestMapping("/goods")
public class GoodsController {
 
 
    @Autowired
    private GoodsService goodsService;
 
    @Autowired
    private ProviderService providerService;
 
    @Autowired
    private CategoryService categoryService;
 
    
    @SysLog("商品查询操作")
    @RequestMapping("/goodsList")
    public DataGridViewResult goodsList(GoodsVO goodsVO) {
        //创建分页信息    参数1 当前页  参数2 每页显示条数
        IPage<Goods> page = new Page<>(goodsVO.getPage(), goodsVO.getLimit());
        QueryWrapper<Goods> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(goodsVO.getProviderid() != null && goodsVO.getProviderid() != 0, "providerid", goodsVO.getProviderid());
        queryWrapper.like(!StringUtils.isEmpty(goodsVO.getGname()), "gname", goodsVO.getGname());
        IPage<Goods> goodsIPage = goodsService.page(page, queryWrapper);
        List<Goods> records = goodsIPage.getRecords();
        for (Goods goods : records) {
            Provider provider = providerService.getById(goods.getProviderid());
            if (null != provider) {
                goods.setProvidername(provider.getProvidername());
            }
        }
        return new DataGridViewResult(goodsIPage.getTotal(), records);
    }
 
 
    
    @SysLog("商品添加操作")
    @PostMapping("/addgoods")
    public Result addGoods(Goods goods) {
        String id = RandomStringUtils.randomAlphanumeric(8);
        if (goods.getGoodsimg()!=null&&goods.getGoodsimg().endsWith("_temp")){
            String newName = AppFileUtils.renameFile(goods.getGoodsimg());
            goods.setGoodsimg(newName);
        }
        goods.setGnumbering(id);
        boolean bool = goodsService.save(goods);
        if (bool) {
            return Result.success(true, "200", "添加成功!");
        }
        return Result.error(false, null, "添加失败!");
    }
 
    
    @SysLog("商品修改操作")
    @PostMapping("/updategoods")
    public Result updateGoods(Goods goods) {
        //商品图片不是默认图片
        if (!(goods.getGoodsimg()!=null&&goods.getGoodsimg().equals(Constast.DEFAULT_IMG))){
            if (goods.getGoodsimg().endsWith("_temp")){
                String newName = AppFileUtils.renameFile(goods.getGoodsimg());
                goods.setGoodsimg(newName);
                //删除原先的图片
                String oldPath = goodsService.getById(goods.getGid()).getGoodsimg();
                AppFileUtils.removeFileByPath(oldPath);
            }
        }
        boolean bool = goodsService.updateById(goods);
        if (bool) {
            return Result.success(true, "200", "修改成功!");
        }
        return Result.error(false, null, "修改失败!");
    }
 
 
    
    @SysLog("商品删除操作")
    @RequestMapping("/deleteOne")
    public Result deleteOne(int id) {
 
        boolean bool = goodsService.removeById(id);
        if (bool) {
            return Result.success(true, "200", "删除成功!");
        }
        return Result.error(false, null, "删除失败!");
    }
 
    
    @RequestMapping("/initGoodsByCategoryId")
    public DataGridViewResult initGoodsByCategoryId(int id) {
        List<Map<String, Object>> mapList = null;
        try {
            //查询所有类别列表
            mapList = categoryService.listMaps();
            //根据商品id查询商品拥有的类别
            Set<Integer> cateIdList = categoryService.findGoodsByCategoryId(id);
            for (Map<String, Object> map : mapList) {
                //定义标记 默认不选中
                boolean flag = false;
                int cateId = (int) map.get("cateid");
                for (Integer cid : cateIdList) {
                    if (cid == cateId) {
                        flag = true;
                        break;
                    }
                }
                map.put("LAY_CHECKED", flag);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new DataGridViewResult(Long.valueOf(mapList.size()), mapList);
 
    }
 
    
    @GetMapping("/loadGoodsById")
    public DataGridViewResult loadGoodsById(int goodsid) {
 
 
        QueryWrapper<Goods> goodsQueryWrapper = new QueryWrapper<>();
        goodsQueryWrapper.eq(goodsid != 0, "gid", goodsid);
        Goods goods = goodsService.getById(goodsid);
 
        return new DataGridViewResult(goods);
 
    }
 
    
    @SysLog("类别添加操作")
    @RequestMapping("/saveGoodsCategory")
    public Result saveGoodsCategory(String categoryids, int goodsid) {
 
        try {
            if (goodsService.saveGoodsCategory(goodsid, categoryids)) {
                return Result.success(true, null, "分配成功");
            }
 
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.error(false, null, "分配失败");
 
    }
 
    
    @RequestMapping("/loadAllGoods")
    public DataGridViewResult loadAllGoods() {
        QueryWrapper<Goods> queryWrapper = new QueryWrapper<>();
        List<Goods> list = goodsService.list(queryWrapper);
        return new DataGridViewResult(list);
 
    }
 
 
    
    @RequestMapping("/loadGoodsByProvidreId")
    public DataGridViewResult loadGoodsByProvidreId(Integer providerid) {
        QueryWrapper<Goods> goodsQueryWrapper = new QueryWrapper<>();
        goodsQueryWrapper.eq(providerid != null, "providerid", providerid);
        List<Goods> list = goodsService.list(goodsQueryWrapper);
        for (Goods goods : list) {
            Provider provider = providerService.getById(goods.getProviderid());
            if (null != provider) {
                goods.setProvidername(provider.getProvidername());
            }
 
        }
        return new DataGridViewResult(list);
 
    }
}

以上就是Java实战之超市收银管理系统的实现的详细内容,更多关于Java收银系统的资料请关注编程网其它相关文章!

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯