当前位置:   article > 正文

基于javaweb+mysql的springboot超市进销存系统设计和实现(java+springboot+ssm+mysql+html+maven)_基于springboot的小型超市进销存管理系统的设计与实现

基于springboot的小型超市进销存管理系统的设计与实现

基于javaweb+mysql的springboot超市进销存系统设计和实现(java+springboot+ssm+mysql+html+maven)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SpringBoot超市进销存系统设计和实现(java+springboot+ssm+mysql+html+maven)

一、项目简述

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

二、项目运行

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

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


/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/outsale")
public class OutsaleController {

    @Autowired
    private OutsaleService outsaleService;

    @Autowired
    private GoodsService goodsService;

    @Autowired
    private SaleService saleService;

    @Autowired
    private ProviderService providerService;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
        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,"删除失败!");
    }

    /**
     * 添加客户信息
     * @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,"修改失败!");
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
            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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
                outport.setGnumbering(goods.getGnumbering());
            }
        }
        return new DataGridViewResult(outportIPage.getTotal(), records);

    }

}
package com.it.controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/outsale")
public class OutsaleController {
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
 */
@RestController
@RequestMapping("/logs")
public class LogsController {

    @Autowired
    private LogsService logsService;

    /**
     * 日志模糊查询
     * @param logVO
     * @return
     */
    @SysLog("日志查询操作")
    @RequestMapping("/logList")
    public DataGridViewResult logList(LogVO logVO) {
        //创建分页信息    参数1 当前页  参数2 每页显示条数
        IPage<Logs> page = new Page<>(logVO.getPage(), logVO.getLimit());
        QueryWrapper<Logs> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(!StringUtils.isEmpty(logVO.getType()),"type", logVO.getType());
        queryWrapper.like(!StringUtils.isEmpty(logVO.getUname()),"uname", logVO.getUname());
        queryWrapper.ge(logVO.getStartTime()!=null,"ltime", logVO.getStartTime());
        queryWrapper.le(logVO.getEndTime()!=null,"ltime", logVO.getEndTime());
        IPage<Logs> logsIPage = logsService.page(page, queryWrapper);

        /**
         * logsIPage.getTotal() 总条数
         * logsIPage.getRecords() 分页记录列表
         */
        return new DataGridViewResult(logsIPage.getTotal(),logsIPage.getRecords());
    }

    /**
     * 日志批量删除
     * @param ids
     * @return
     */
    @SysLog("日志删除操作")
    @RequestMapping("/delete")
    public Result logList(String ids) {
        //将字符串拆分成数组
        String[] idsStr = ids.split(",");
        List<String> list = Arrays.asList(idsStr);
        boolean bool = logsService.removeByIds(list);
        if(bool){
            return Result.success(true,"200","删除成功!");
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
            e.printStackTrace();
        }
    }

    /**
     * 查询所有用户信息
     *
     * @param userVO
     * @return
     */
    @SysLog("用户查询操作")
    @RequestMapping("/userList")
    public DataGridViewResult userList(UserVO userVO) {
        //分页构造函数
        IPage<User> page = new Page<>(userVO.getPage(), userVO.getLimit());
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(!StringUtils.isEmpty(userVO.getUsername()), "username", userVO.getUsername());
        queryWrapper.like(!StringUtils.isEmpty(userVO.getUname()), "uname", userVO.getUname());
        /**
         * 翻页查询
         * @param page         翻页对象
         * @param queryWrapper 实体对象封装操作类
         */
        IPage<User> userIPage = userService.page(page, queryWrapper);
        return new DataGridViewResult(userIPage.getTotal(), userIPage.getRecords());
    }

    /**
     * 添加用户信息
     *
     * @param user
     * @return
     */
    @SysLog("用户添加操作")
    @PostMapping("/adduser")
    public Result addRole(User user) {

        user.setUcreatetime(new Date());
        String salt = UUIDUtil.randomUUID();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
        return Result.success(false,null,"修改失败");
    }

    /**
     * 删除权限
     * @param id
     * @return
     */
    @SysLog("权限删除操作")
    @RequestMapping("/deleteById")
    public Result deleteById(int id){
        //删除成功
        if(permissionService.removeById(id)){
            return Result.success(true,null,"删除成功");
        }
        //删除失败
        return Result.success(false,null,"删除失败");
    }

}
package com.it.controller;

/**
 * <p>
 * 前端控制器
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

/**
 * <p>
 * 前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/outport")
public class OutportController {

    @Autowired
    private OutportService outportService;

    @Autowired
    private GoodsService goodsService;

    @Autowired
    private InportService inportService;

    @Autowired
    private ProviderService providerService;

    /**
     * 添加退货信息
     *
     * @param id
     * @param number
     * @param remark
     * @return
     */
    @SysLog("退货添加操作")
    @RequestMapping("addOutport")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
    public DataGridViewResult roleList(RoleVO roleVO) {
        //分页构造函数
        IPage<Role> page = new Page<>(roleVO.getPage(), roleVO.getLimit());
        QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(!StringUtils.isEmpty(roleVO.getRolename()), "rolename", roleVO.getRolename());
        /**
         * 翻页查询
         *
         * @param page         翻页对象
         * @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
         */
        IPage<Role> roleIPage = roleService.page(page, queryWrapper);
        return new DataGridViewResult(roleIPage.getTotal(), roleIPage.getRecords());
    }

    /**
     * 添加角色信息
     *
     * @param role
     * @return
     */
    @SysLog("角色添加操作")
    @PostMapping("/addrole")
    public Result addRole(Role role) {
        boolean bool = roleService.save(role);
        try {
            if (bool) {
                return Result.success(true, "200", "添加成功!");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.error(false, null, "添加失败!");
    }

    /**
     * 修改角色信息
     *
     * @param role
     * @return
     */
    @SysLog("角色修改操作")
    @PostMapping("/updaterole")
    public Result updateRole(Role role) {
        boolean bool = roleService.updateById(role);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
 * 前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private PermissionService permissionService;

    @Autowired
    private UserService userService;

    @Autowired
    private RoleService roleService;

    /**
     * 加载首页左侧菜单
     *
     * @param session
     * @return
     */
    @RequestMapping("/loadIndexLeftMenuTree")
    public DataGridViewResult loadIndexLeftMenuTree(HttpSession session) {
        //调用查询权限菜单列表
        QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("type", "menu");
        User username = (User) session.getAttribute("username");
        List<Permission> permissionList = new ArrayList<>();

        if (username.getType() == 0) {
            permissionList = permissionService.list(queryWrapper);
        }
        try {
            //1.根据当前登录用户ID查询该用户拥有的角色列表
            Set<Integer> currentUserRoleIds = userService.findRoleByUserId(username.getUid());
            //2.创建集合保存每个角色下拥有的权限菜单ID
            Set<Integer> pids = new HashSet<Integer>();
            //3.循环遍历当前用户拥有的角色列表
            for (Integer roleId : currentUserRoleIds) {
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41

/**
 * <p>
 * 前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/sale")
public class SaleController {
    @Autowired
    private SaleService saleService;

    @Autowired
    private GoodsService goodsService;

    @Autowired
    private CustomerService customerService;

    /**
     * 销售查询
     *
     * @param
     * @return
     */
    @SysLog("销售查询操作")
    @RequestMapping("/saleList")
    public DataGridViewResult saleList(SaleVO saleVO) {

        //创建分页信息    参数1 当前页  参数2 每页显示条数
        IPage<Sale> page = new Page<>(saleVO.getPage(), saleVO.getLimit());
        QueryWrapper<Sale> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(!StringUtils.isEmpty(saleVO.getNumbering()), "numbering", saleVO.getNumbering());
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
            return Result.error(false, "400", "登录失败,账户禁用");
        }
    }

    /**
     * 得到登陆验证码
     * @param response
     * @param session
     * @throws IOException
     */
    @RequestMapping("/getCode")
    public void getCode(HttpServletResponse response, HttpSession session) throws IOException {
        //定义图形验证码的长和宽
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(116, 36,4,5);
        session.setAttribute("code",lineCaptcha.getCode());
        try {
            ServletOutputStream outputStream = response.getOutputStream();
            lineCaptcha.write(outputStream);
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询所有用户信息
     *
     * @param userVO
     * @return
     */
    @SysLog("用户查询操作")
    @RequestMapping("/userList")
    public DataGridViewResult userList(UserVO userVO) {
        //分页构造函数
        IPage<User> page = new Page<>(userVO.getPage(), userVO.getLimit());
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(!StringUtils.isEmpty(userVO.getUsername()), "username", userVO.getUsername());
        queryWrapper.like(!StringUtils.isEmpty(userVO.getUname()), "uname", userVO.getUname());
        /**
         * 翻页查询
         * @param page         翻页对象
         * @param queryWrapper 实体对象封装操作类
         */
        IPage<User> userIPage = userService.page(page, queryWrapper);
        return new DataGridViewResult(userIPage.getTotal(), userIPage.getRecords());
    }

    /**
     * 添加用户信息
     *
     * @param user
     * @return
     */
    @SysLog("用户添加操作")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54

/**
 * <p>
 * 前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private RoleService roleService;

    /**
     * 登录
     *
     * @param username 用户名
     * @param password 密码
     * @param request
     * @return
     */

    @SysLog("登录操作")
    @PostMapping("/login")
    public Result login(String username, String password, String code,HttpServletRequest request) {
        try {

            if (!(request.getSession().getAttribute("code")+"").equalsIgnoreCase(code+"")) {
                return Result.error(false, "400", "登录失败,验证码错误");
            }

            //获取当前登录主体对象
            Subject subject = SecurityUtils.getSubject();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37

/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/provider")
public class ProviderController {

    @Autowired
    private ProviderService providerService;

    /**
     * 供应商模糊查询
     * @param
     * @return
     */
    @SysLog("供应商查询操作")
    @RequestMapping("/providerList")
    public DataGridViewResult providerList(ProviderVO providerVO) {

        //创建分页信息    参数1 当前页  参数2 每页显示条数
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

@RestController
@RequestMapping("file")
public class FileController {

    /**
     * 文件上传
     * @param mf
     * @return
     */
    @RequestMapping("uploadFile")
    public Map<String,Object> uploadFile(MultipartFile mf) {
        //1.得到文件名
        String oldName = mf.getOriginalFilename();
        //2.根据旧的文件名生成新的文件名
        String newName= AppFileUtils.createNewFileName(oldName);
        //3.得到当前日期的字符串
        String dirName= DateUtil.format(new Date(), "yyyy-MM-dd");
        //4.构造文件夹
        File dirFile=new File(AppFileUtils.UPLOAD_PATH,dirName);
        //5.判断当前文件夹是否存在
        if(!dirFile.exists()) {
            //如果不存在则创建新文件夹
            dirFile.mkdirs();
        }
        //6.构造文件对象
        File file=new File(dirFile, newName+"_temp");
        //7.把mf里面的图片信息写入file
        try {
            mf.transferTo(file);
        } catch (IllegalStateException | IOException e) {
            e.printStackTrace();
        }
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("path",dirName+"/"+newName+"_temp");
        return map;
    }

    /**
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
        IPage<Role> page = new Page<>(roleVO.getPage(), roleVO.getLimit());
        QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(!StringUtils.isEmpty(roleVO.getRolename()), "rolename", roleVO.getRolename());
        /**
         * 翻页查询
         *
         * @param page         翻页对象
         * @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
         */
        IPage<Role> roleIPage = roleService.page(page, queryWrapper);
        return new DataGridViewResult(roleIPage.getTotal(), roleIPage.getRecords());
    }

    /**
     * 添加角色信息
     *
     * @param role
     * @return
     */
    @SysLog("角色添加操作")
    @PostMapping("/addrole")
    public Result addRole(Role role) {
        boolean bool = roleService.save(role);
        try {
            if (bool) {
                return Result.success(true, "200", "添加成功!");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.error(false, null, "添加失败!");
    }

    /**
     * 修改角色信息
     *
     * @param role
     * @return
     */
    @SysLog("角色修改操作")
    @PostMapping("/updaterole")
    public Result updateRole(Role role) {
        boolean bool = roleService.updateById(role);
        try {
            if (bool) {
                return Result.success(true, "200", "修改成功!");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.error(false, null, "修改失败!");
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
        return Result.error(false,null,"修改失败!");
    }

    /**
     * 删除单条数据
     * @param id
     * @return
     */
    @SysLog("供应商删除操作")
    @RequestMapping("/deleteOne")
    public Result deleteOne(int id) {

        boolean bool = providerService.removeById(id);
        if(bool){
            return Result.success(true,"200","删除成功!");
        }
        return Result.error(false,null,"删除失败!");
    }

    /**
     *
     * 加载下拉框
     * @return
     */
    @RequestMapping("/loadAllProvider")
    public DataGridViewResult loadAllProvider(){
        QueryWrapper<Provider> queryWrapper = new QueryWrapper<>();
        List<Provider> list = providerService.list(queryWrapper);
        return new DataGridViewResult(list);

    }

}
package com.it.controller;

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
     * @param ids
     * @return
     */
    @SysLog("供应商删除操作")
    @RequestMapping("/deleteList")
    public Result deleteList(String ids) {
        //将字符串拆分成数组
        String[] idsStr = ids.split(",");
        List<String> list = Arrays.asList(idsStr);
        boolean bool = providerService.removeByIds(list);
        if(bool){
            return Result.success(true,"200","删除成功!");
        }
        return Result.error(false,null,"删除失败!");
    }

    /**
     * 添加供应商信息
     * @param provider
     * @param session
     * @return
     */
    @SysLog("供应商添加操作")
    @PostMapping("/addprovider")
    public Result addProvider(Provider provider, HttpSession session){
        User user = (User) session.getAttribute("username");
        provider.setOpername(user.getUname());
        boolean bool = providerService.save(provider);
        if(bool){
            return Result.success(true,"200","添加成功!");
        }
        return Result.error(false,null,"添加失败!");
    }

    /**
     * 修改供应商信息
     * @param provider
     * @return
     */
    @SysLog("供应商修改操作")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40

/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    /**
     * 客户模糊查询
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
        }

        return new DataGridViewResult(saleIPage.getTotal(), records);

    }

    /**
     * 添加销售单信息
     *
     * @param sale
     * @return
     */
    @SysLog("销售添加操作")
    @PostMapping("/addsale")
    public Result addsale(Sale sale, HttpSession session) {
        if (sale.getGid() == 0) {
            return Result.error(false, null, "添加失败!未选商品");
        }
        Goods goods = goodsService.getById(sale.getGid());
        Integer gquantity = goods.getGquantity();
        if (gquantity < sale.getBuyquantity()) {
            return Result.error(false, null, "添加失败!库存不足,库存为:" + gquantity);
        }
        User user = (User) session.getAttribute("username");
        String num = RandomStringUtils.randomAlphanumeric(7);
        sale.setNumbering(num);
        sale.setPerson(user.getUsername());
        sale.setBuytime(new Date());
        sale.setRealnumber(sale.getBuyquantity());
        boolean bool = saleService.save(sale);
        if (bool) {
            return Result.success(true, "200", "添加成功!");
        }
        return Result.error(false, null, "添加失败!库存不足");
    }

    /**
     * 修改销售单信息
     *
     * @param sale
     * @return
     */
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

    /**
     * 删除单条数据
     *
     * @param id
     * @return
     */
    @SysLog("角色删除操作")
    @RequestMapping("/deleteOne")
    public Result deleteOne(int id) {
        boolean bool = roleService.removeById(id);
        try {
            if (bool) {
                return Result.success(true, "200", "删除成功!");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.error(false, null, "删除失败!");
    }

    /**
     * 初始化权限菜单树
     *
     * @param roleId
     * @return
     */
    @RequestMapping("/initPermissionByRoleId")
    public DataGridViewResult initPermissionByRoleId(int roleId) {
        //创建条件构造器对象
        QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
        List<Permission> permissionList = permissionService.list();
        List<Integer> currentPermissionIds = permissionService.findRolePermissionIdByRoleId(roleId);
        //保存角色拥有的菜单
        List<Permission> currentPermissions = new ArrayList<>();
        if (currentPermissionIds != null && currentPermissionIds.size() > 0) {
            queryWrapper.in("id", currentPermissionIds);
            currentPermissions = permissionService.list(queryWrapper);
        }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
    @Resource
    private OutportService outportService;

    @Autowired
    private GoodsService goodsService;

    @SysLog("查询统计销售报表")
    @RequestMapping("/statisticsSales")
    public DataGridViewResult statisticsSales(){
        QueryWrapper<Sale> queryWrapper = new QueryWrapper<>();
        queryWrapper
                .select("gid","sum(buyquantity) total,sum(realnumber) actualtotal")
                .groupBy("gid")
                .orderByAsc("total")
                .last("limit 5");
        List<Sale> salesList = saleService.list(queryWrapper);
        Map<String, Object> map = new HashMap<>();
        List<String> list1 = new ArrayList<>();
        List<Integer> list2 = new ArrayList<>();
        List<Integer> list3 = new ArrayList<>();

        for (Sale sale : salesList) {
            Goods goods = goodsService.getById(sale.getGid());
            if (null != goods) {
                list1.add(goods.getGname()+goods.getGnumbering());
                list2.add(sale.getTotal());
                list3.add(sale.getActualtotal());
            }
        }
        map.put("data1",list1);
        map.put("data2",list2);
        map.put("data3",list3);
        return new DataGridViewResult(map);

    }

    @SysLog("查询统计退货报表")
    @RequestMapping("/statisticsinGoods")
    public DataGridViewResult statisticsinGoods(){
        QueryWrapper<Inport> queryWrapper = new QueryWrapper<>();
        queryWrapper
                .select("sum( number ) as countnumbers,DATE_FORMAT( inptime, '%Y-%m' ) AS counttime")
                .between("inptime",DateUtils.stepMonth(5),new Date())
                .groupBy("counttime")
                .orderByAsc("counttime");
        List<Inport> inportsList = inportService.list(queryWrapper);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
                    list3.add(sales.getMoneys()-outsale.getMoneys());
                    list4.add(-outsale.getMoneys());
                }else{
                    list3.add(sales.getMoneys());
                    list4.add(null);
                }
            }else {
                list1.add(new SimpleDateFormat("yyyy-MM").format(DateUtils.getMonth(i)));
                list2.add(null);
                if(outsale!=null){
                    list3.add(-outsale.getMoneys());
                    list4.add(-outsale.getMoneys());
                }else{
                    list3.add(null);
                    list4.add(null);
                }
            }
        }

        map.put("data1",list1);
        map.put("data2",list2);
        map.put("data3",list3);
        map.put("data4",list4);
        return new DataGridViewResult(map);
    }

}
package com.it.controller;

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
        try {
            //查询所有角色列表
            mapList = roleService.listMaps();
            //根据用户id查询用户拥有的角色
            Set<Integer> roleIdList = userService.findRoleByUserId(id);
            for (Map<String, Object> map : mapList) {
                //定义标记 默认不选中
                boolean flag = false;
                int roleId = (int) map.get("roleid");
                for (Integer rid : roleIdList) {
                    if (rid == roleId) {
                        flag = true;
                        break;
                    }
                }
                map.put("LAY_CHECKED", flag);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new DataGridViewResult(Long.valueOf(mapList.size()), mapList);

    }

    /**
     * 为用户分配角色
     *
     * @param roleids
     * @param userid
     * @return
     */
    @SysLog("用户添加操作")
    @RequestMapping("/saveUserRole")
    public Result saveUserRole(String roleids, int userid) {

        try {
            if (userService.saveUserRole(userid, roleids)) {
                return Result.success(true, null, "分配成功");
            }

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
    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<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);

    }

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
    /**
     * 进货查询
     *
     * @param
     * @return
     */
    @SysLog("进货查询操作")
    @RequestMapping("/inportList")
    public DataGridViewResult inportList(InportVO inportVO) {

        //创建分页信息    参数1 当前页  参数2 每页显示条数
        IPage<Inport> page = new Page<>(inportVO.getPage(), inportVO.getLimit());
        QueryWrapper<Inport> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(inportVO.getProviderid() != null && inportVO.getProviderid() != 0, "providerid", inportVO.getProviderid());
        queryWrapper.eq(inportVO.getGoodsid() != null && inportVO.getGoodsid() != 0, "goodsid", inportVO.getGoodsid());
        queryWrapper.ge(inportVO.getStartTime() != null, "inptime", inportVO.getStartTime());
        queryWrapper.le(inportVO.getEndTime() != null, "inptime", inportVO.getEndTime());
        queryWrapper.orderByDesc("inptime");
        IPage<Inport> inportIPage = inportService.page(page, queryWrapper);
        List<Inport> records = inportIPage.getRecords();
        for (Inport inport : records) {
            inport.setAllinpprice(inport.getInpprice()*inport.getNumber());
            Provider provider = providerService.getById(inport.getProviderid());
            if (null != provider) {
                inport.setProvidername(provider.getProvidername());
            }
            Goods goods = goodsService.getById(inport.getGoodsid());
            if (null != goods) {
                inport.setGoodsname(goods.getGname());
            }
        }
        return new DataGridViewResult(inportIPage.getTotal(), records);

    }

    /**
     * 添加进货信息
     *
     * @param inport
     * @return
     */
    @SysLog("进货添加操作")
    @PostMapping("/addinport")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
                    .select("sum( money*buyquantity ) AS moneys,DATE_FORMAT( buytime, '%Y-%m' ) AS counttime")
                    .between("buytime",DateUtils.stepMonth(i),DateUtils.getMonth(i))
                    .groupBy("counttime")
                    .orderByDesc("counttime");

            queryWrapper2
                    .select("sum( outprice ) AS moneys,DATE_FORMAT( outtime, '%Y-%m' ) AS counttime")
                    .between("outtime",DateUtils.stepMonth(i),DateUtils.getMonth(i))
                    .groupBy("counttime")
                    .orderByDesc("counttime");

            Sale sales = saleService.getOne(queryWrapper);

            Outsale outsale = outsaleService.getOne(queryWrapper2);

            if(null!= sales){
                list1.add(sales.getCounttime());
                list2.add(sales.getMoneys());
                if(outsale!=null){
                    list3.add(sales.getMoneys()-outsale.getMoneys());
                    list4.add(-outsale.getMoneys());
                }else{
                    list3.add(sales.getMoneys());
                    list4.add(null);
                }
            }else {
                list1.add(new SimpleDateFormat("yyyy-MM").format(DateUtils.getMonth(i)));
                list2.add(null);
                if(outsale!=null){
                    list3.add(-outsale.getMoneys());
                    list4.add(-outsale.getMoneys());
                }else{
                    list3.add(null);
                    list4.add(null);
                }
            }
        }

        map.put("data1",list1);
        map.put("data2",list2);
        map.put("data3",list3);
        map.put("data4",list4);
        return new DataGridViewResult(map);
    }

}
package com.it.controller;

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

请添加图片描述

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/702467
推荐阅读
相关标签
  

闽ICP备14008679号