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

网友投稿 332 2022-08-17


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

目录一、项目简述二、项目运行三、效果图四、核心代码品类信息控制层用户信息控制层商品信息控制层

一、项目简述

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

二、项目运行

环境配置: 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;

/**

* 类别模糊查询

* @param

* @return

*/

@SysLog("类别查询操作")

@RequestMapping("/crkCbcwlGategoryList")

public DataGridViewResult categoryList(CategoryVO categoryVO) {

//创建分页信息 参数1 当前页 参数2 每页显示条数

IPage page = new Page<>(categoryVO.getPage(), categoryVO.getLimit());

QueryWrapper queryWrapper = new QueryWrapper<>();

queryWrapper.like(!StringUtils.isEmpty(categoryVO.getCatename()),"catename", categoryVO.getCatename());

IPage categoryIPage = categoryService.page(page, queryWrapper);

/**

* logsIPage.getTotal() 总条数

* logsIPage.getRecords() 分页记录列表

*/

return new DataGridViewResult(categoryIPage.getTotal(),categoryIPage.getRecords());

}

/**

* 类别批量删除

* @param ids

* @return

*/

@SysLog("类别删除操作")

@RequestMapping("/deleteList")

public Result deleteList(String ids) {

//将字符串拆分成数组

String[] idsStr = ids.split(",");

List list = Arrays.asList(idsStr);

boolean bool = categoryService.removeByIds(list);

if(bool){

return Result.success(true,"200","删除成功!");

}

return Result.error(false,null,"删除失败!");

}

/**

* 添加类别信息

* @param category

* @return

*/

@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,"添加失败!");

}

/**

* 修改类别信息

* @param category

* @return

*/

@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,"修改失败!");

}

/**

* 删除单条数据

* @param id

* @return

*/

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

/**

* 客户模糊查询

* @param

* @return

*/

@SysLog("客户查询操作")

@RequestMapping("/customerList")

public DataGridViewResult customerList(CustomerVO customerVO) {

//创建分页信息 参数1 当前页 参数2 每页显示条数

IPage page = new Page<>(customerVO.getPage(), customerVO.getLimit());

QueryWrapper queryWrapper = new QueryWrapper<>();

queryWrapper.like(!StringUtils.isEmpty(customerVO.getCustvip()),"custvip", customerVO.getCustvip());

IPage customerIPage = customerService.page(page, queryWrapper);

/**

* logsIPage.getTotal() 总条数

* logsIPage.getRecords() 分页记录列表

*/

return new DataGridViewResult(customerIPage.getTotal(),customerIPage.getRecords());

}

/**

* 客户批量删除

* @param ids

* @return

*/

@SysLog("客户删除操作")

@RequestMapping("/deleteList")

public Result deleteList(String ids) {

//将字符串拆分成数组

String[] idsStr = ids.split(",");

List list = Arrays.asList(idsStr);

boolean bool = customerService.removeByIds(list);

if(bool){

return Result.success(true,"200","删除成功!");

}

return Result.error(false,null,"删除失败!");

}

/**

* 添加客户信息

* @param customer

* @return

*/

@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,"添加失败!");

}

/**

* 修改客户信息

* @param customer

* @return

*/

@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,"修改失败!");

}

/**

* 删除单条数据

* @param id

* @return

*/

@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,"删除失败!");

}

/**

*

* 加载下拉框

* @return

*/

@RequestMapping("/loadAllCustomer")

public DataGridViewResult loadAllCustomer(){

QueryWrapper queryWrapper = new QueryWrapper<>();

List 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;

/**

* 商品模糊查询

*

* @param

* @return

*/

@SysLog("商品查询操作")

@RequestMapping("/goodsList")

public DataGridViewResult goodsList(GoodsVO goodsVO) {

//创建分页信息 参数1 当前页 参数2 每页显示条数

IPage page = new Page<>(goodsVO.getPage(), goodsVO.getLimit());

QueryWrapper queryWrapper = new QueryWrapper<>();

queryWrapper.eq(goodsVO.getProviderid() != null && goodsVO.getProviderid() != 0, "providerid", goodsVO.getProviderid());

queryWrapper.like(!StringUtils.isEmpty(goodsVO.getGname()), "gname", goodsVO.getGname());

IPage goodsIPage = goodsService.page(page, queryWrapper);

List 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);

}

/**

* 添加商品信息

*

* @param goods

* @return

*/

@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, "添加失败!");

}

/**

* 修改商品信息

*

* @param goods

* @return

*/

@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, "修改失败!");

}

/**

* 删除单条数据

*

* @param id

* @return

*/

@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, "删除失败!");

}

/**

* 根据id查询当前商品拥有的类别

*

* @param id

* @return

*/

@RequestMapping("/initGoodsByCategoryId")

public DataGridViewResult initGoodsByCategoryId(int id) {

List> mapList = null;

try {

//查询所有类别列表

mapList = categoryService.listMaps();

//根据商品id查询商品拥有的类别

Set cateIdList = categoryService.findGoodsByCategoryId(id);

for (Map 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);

}

/**

* 根据商品id加载商品信息

* @param goodsid

* @return

*/

@GetMapping("/loadGoodsById")

public DataGridViewResult loadGoodsById(int goodsid) {

QueryWrapper goodsQueryWrapper = new QueryWrapper<>();

goodsQueryWrapper.eq(goodsid != 0, "gid", goodsid);

Goods goods = goodsService.getById(goodsid);

return new DataGridViewResult(goods);

}

/**

* 为商品分配类别

*

* @param categoryids

* @param goodsid

* @return

*/

@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, "分配失败");

}

/**

* 加载下拉框

*

* @return

*/

@RequestMapping("/loadAllGoods")

public DataGridViewResult loadAllGoods() {

QueryWrapper queryWrapper = new QueryWrapper<>();

List list = goodsService.list(queryWrapper);

return new DataGridViewResult(list);

}

/**

* 根据供应商查商品下拉框

*

* @param providerid

* @rehttp://turn

*/

@RequestMapping("/loadGoodsByProvidreId")

public DataGridViewResult loadGoodsByProvidreId(Integer providerid) {

QueryWrapper goodsQueryWrapper = new QueryWrapper<>();

goodsQueryWrapper.eq(providerid != null, "providerid", providerid);

List 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收银系统的资料请关注我们其它相关文章!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:使用@PropertySource读取配置文件通过@Value进行参数注入
下一篇:java实现五子棋大战
相关文章

 发表评论

暂时没有评论,来抢沙发吧~