赞
踩
集成开发环境:IntelliJ IDEA(2021)
数据库:MySQL 8.0
技术栈:Springboot、mybatisPlus、jquery、echarts
适用于结课大作业,课程设计、项目练习、学习演示等;
目录
仓库管理系统是一款标准化、智能化过程导向管理的仓库管理软件,它结合了众多知名企业的实际情况和管理经验,能够准确、高效地管理跟踪客户订单、采购订单、以及仓库的综合管理。使用后,仓库管理模式发生了彻底的转变。从传统的“结果导向”转变成“过程导向”;从“数据录入”转变成“数据采集”,同时兼容原有的“数据录入”方式;从“人工找货”转变成了“导向定位取货”;同时引入了“监控平台”让管理更加高效、快捷。条码管理实质是过程管理,过程精细可控,结果自然正确无误。
1. 用户登录:
用户登录模块用于管理员、老师、学生三种用户的登录。登录时需要验证用户的账号、工号、学号及其密码,此时需要与数据库中的用户登录信息进行比较,如果与数据库表中数据一致,则进入对应的系统中,否则,提示用户名或密码错误。
2. 员工信息管理:
员工信息管理模块主要是管理员对于员工信息的管理,管理员可以增加员工信息,其中学生的用户名是唯一,不可重复。还可以通过员工用户名、昵称进行查询。
3. 入库信息查询:
入库信息查询模块是针对管理员和员工对入库信息的查询,管理员和员工可以根据自己的查询的需要,根据入库商品的商品名称、型号、存放位置来进行对需要商品信息的查询。
4. 出库信息查询:
出库信息查询模块是针对管理员和员工对入库信息的查询,管理员和员工可以根据自己的查询的需要,根据出库商品的商品名称、型号、存放位置来进行对需要商品信息的查询。
1. 系统总流图,主要权限为查看入库信息、打印入库单据、查看出库信息、打印出库单据。数据流图如图2-1所示:
图2-1 系统总数据流图
2. 出库信息流图,主要权限为商品出货、打印出货单据。数据流图如图2-2所示:
图2-2 出库信息数据流图
图2-3 入库信息数据流图
1. 用户登录
用户登录模块是用户进入系统的入口,用户在登录时需要通过验证用户登录的账号和密码,在验证成功后才能够进入系统,否则向用户提示账号或密码错误,需要重新登录。用户登录用例图如图4-1所示:
图2-1 用户登录用例图
2. 入库信息管理
学生信息管理模块主要管理员对于入库商品信息的管理,管理员可以增加、编辑、删除信息,其入库信息管理用例图如4-2所示:
图2-2 入库信息管理用例图
3. 入库信息查询
入库信息查询模块主要是管理员和员工对入库商品的信息进行管理,管理员和员工可以查询入库的具体信息。入库信息查询用例图如图4-3所示:
图2-3 入库商品信息查询用例图
4. 出库信息管理
班级成绩统计模块主要是管理员对出库商品的管理,管理员可以添加、删除、编辑出库商品信息,用例图如图2-4所示:
图2-4 出库信息用例图
5. 出库信息查询
出库信息查询出要是管理员和员工对出库商品信息的管理,可以根据名称、型号、规格等信息对出库商品信息进行查询,出库信息查询用例图如图4-5所示:
图2-5 出库信息查询用例图
6. 员工信息管理
员工信息管理主要是管理员对需要员工信息进行添加、编辑、删除等工作。可以通过用户名、昵称、性别、联系方式、职位、家庭住址等信息对员工信息进行查看,员工信息管理用例图如图4-6所示:
图2-6 员工信息管理用例图
图3-1 系统功能模块图
1.逻辑设计:E-R图
如图所示:
图3-2 管理员E-R图
图3-3 入库单据E-R图
图3-4 出库单据E-R图
2.数据表
如表3-1所示:
表3-1 管理员表
数据项名 | 数据项含义 | 类型 | 长度 | 备注 | |
Id | 编号 | BIGINT | 0 | 主键1 | |
username | 管理员账号名 | VARCHAR | 255 | 主键2 | |
password | 管理员账号密码 | VARCHAR | 255 | ||
name | 管理员姓名 | VARCHAR | 255 | ||
sex | 性别 | VARCHAR | 255 | ||
classify | 种类 | VARCHAR | 255 | ||
phone | 电话 | VARCHAR | 255 | ||
address | 进货量 | VARCHAR | 255 |
入库单据表
用于存放入库单据的详细信息。
表3-2 入库单据表
数据项名 | 数据项含义 | 类型 | 长度 | 备注 |
id | 商品编号 | BIGINT | 0 | 主键1 |
name | 商品名 | VARCHAR | 255 | |
vendor | 生产厂商 | VARCHAR | 255 | |
model | 型号 | VARCHAR | 255 | |
specification | 规格 | VARCHAR | 255 | |
number | 入库数量 | BIGINT | 0 | |
time | 入库时间 | DATETIME | 0 | |
unit | 入库单位 | VARCHAR | 255 | |
location | 存放位置 | VARCHAR | 255 |
出库单据表
用于存放出库商品的详细信息。
表3-3 出库单据表
数据项名 | 数据项含义 | 类型 | 长度 | 备注 | |
id | 商品编号 | BIGINT | 0 | 主键1 | |
name | 商品名 | VARCHAR | 255 | ||
vendor | 生产厂商 | VARCHAR | 255 | ||
model | 型号 | VARCHAR | 255 | ||
specification | 规格 | VARCHAR | 255 | ||
out_number | 出库数量 | BIGINT | 255 | ||
out_time | 出库时间 | DATETIME | 0 | ||
out_unit | 出库单位 | VARCHAR | 255 | ||
deliveryman | 送货员 | VARCHAR | 255 |
用户在进入系统前必须先登录系统,登录时,员工输入用户名和密码,管理员输入用户名和密码,验证成功后进入主页面,否则提示用户名和密码错误。登录界面展示如图4-1所示:
图4-1 登录
新增功能:出仓和入仓的图标分析
添加员工
管理员在员工信息管理页面可以点击“添加”进行员工的添加,添加时需要输入员工的用户名、昵称、性别、联系方式、职位、家庭住址等基本信息。添加员工界面展示如图4-2所示:
图4-2 添加员工
查询员工信息
管理员可以通过输入员工用户名,昵称,查询员工信息(支持模糊查询)界面展示如图4-3所示:
图4-3 查询学生信息
修改员工信息
管理员可以选择需要修改的员工,同时为他们修改信息。为员工修改信息界面展示如图所示:
图4-4为员工修改信息
3入库管理
用户进入系统后显示入库商品界面,可以查看入库商品的信息,入库商品信息界面展示如图所示:
图4-5 入库商品信息公告
添加入库商品信息
管理员可以添加入库商品信息,需要填写添加商品的名称、型号、规格、生产厂商、入库数量、存放位置。添加入库商品界面展示,如图4-6所示:
图4-6 入库商品信息管理
删除入库商品信息
删除商品信息时,服务器会提示是否删除,避免用户误删。删除公告界面展示如图4-7所示:
图4-7 删除信息
修改入库信息
管理员可以对入库商品的信息进行修改。修改信息界面展示如图4-8所示:
图4-8 修改公告
入库商品信息查询
通过输入商品名称、型号、存放位置来找到相应的入库商品信息。入库商品信息查询页面展示如图4-9所示:
图4-9 入库商品信息查询
商品出库
管理员可以出库需要出库的商品,输入它的商品名称、型号、规格、出库数量、出库单位、配送员,即可出库需要出库的商品如图4-10所示:
图4-10 商品出库
商品出库信息查询
管理员在商品出库信息界面可以通过商品名称、型号、配送员进行已经出库商品的查询如图4-11所示:
图4-11 商品出库信息查询
修改密码
用户可以修改自己的密码,如图4-12所示:
图4-12 修改密码
员工实体类
- package com.aliyev.domain;
-
- import lombok.Data;
-
- @Data
- public class Employee {
- private Integer id;
- private String username;
- private String password;
- private String name;
- private String sex;
- private String classify;
- private String address;
- private String phone;
- }
入库表实体类
- package com.aliyev.domain;
-
- import com.baomidou.mybatisplus.annotation.TableField;
- import com.baomidou.mybatisplus.annotation.TableName;
- import lombok.Data;
-
- import java.sql.Time;
- import java.time.LocalDateTime;
-
- @Data
- @TableName("goods_in")
- public class GoodsIn {
- private Integer id;
- private String name;
- private String model;
- private String vendor;
- private String specification;
- private Integer number;
- private LocalDateTime time;
- private String unit;//入库单位
- private String location;
- }
出库表实体类
- package com.aliyev.domain;
-
- import com.baomidou.mybatisplus.annotation.TableName;
- import lombok.Data;
-
- import java.time.LocalDateTime;
-
- @Data
- @TableName("goods_out")
- public class GoodsOut {
- private Integer id;
- private String name;
- private String vendor;
- private String model;
- private String specification;
- private Integer outNumber;
- private LocalDateTime outTime;
- private String outUnit;//入库单位
- private String deliveryman;//配松员
- }
- package com.aliyev.domain;
-
- import lombok.Data;
-
- @Data
- public class PasswordSetting {
- private Integer id;
- private String newPassword;
- private String oldPassword;
- }
mybatisPlus配置类
- package com.aliyev.config;
-
- import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
- import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
-
- @Configuration
- public class MpConfig {
- @Bean
- public MybatisPlusInterceptor mybatisPlusInterceptor(){
- MybatisPlusInterceptor mp=new MybatisPlusInterceptor();
- mp.addInnerInterceptor(new PaginationInnerInterceptor());
- return mp;
- }
- }
SpringMvc配置类
- package com.aliyev.config;
-
- import com.aliyev.filter.LoginCheckFilter;
- import com.aliyev.utils.JacksonObjectMapper;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.core.Ordered;
- import org.springframework.http.converter.HttpMessageConverter;
- import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
- import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
- import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
- import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
-
- import java.util.List;
-
- @Slf4j
- @Configuration
- public class SpringMvcConfig extends WebMvcConfigurationSupport {
- @Override
- protected void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.addResourceHandler("/layuimini/**").addResourceLocations("classpath:/layuimini/");
- }
-
- @Override
- protected void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
- MappingJackson2HttpMessageConverter messageConverter=new MappingJackson2HttpMessageConverter();
- messageConverter.setObjectMapper(new JacksonObjectMapper());
- converters.add(0,messageConverter);
- super.extendMessageConverters(converters);
- }
-
- }
- package com.aliyev.dao;
-
- import com.aliyev.domain.Employee;
- import com.baomidou.mybatisplus.core.mapper.BaseMapper;
- import org.apache.ibatis.annotations.Mapper;
-
- @Mapper
- public interface EmployeeDao extends BaseMapper<Employee> {
- }
- package com.aliyev.dao;
-
- import com.aliyev.domain.GoodsIn;
- import com.baomidou.mybatisplus.core.mapper.BaseMapper;
- import org.apache.ibatis.annotations.Mapper;
-
- @Mapper
- public interface GoodsInDao extends BaseMapper<GoodsIn> {
- }
- package com.aliyev.dao;
-
- import com.aliyev.domain.GoodsOut;
- import com.baomidou.mybatisplus.core.mapper.BaseMapper;
- import org.apache.ibatis.annotations.Mapper;
-
- @Mapper
- public interface GoodsOutDao extends BaseMapper<GoodsOut> {
- }
业务层接口
- package com.aliyev.service;
-
-
- import com.aliyev.dao.EmployeeDao;
- import com.aliyev.domain.Employee;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.service.IService;
-
- public interface EmployeeService extends IService<Employee> {
- IPage<Employee> getPage(int currentPage,int pageSize);
- }
- package com.aliyev.service;
-
-
- import com.aliyev.domain.Employee;
- import com.aliyev.domain.GoodsIn;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.service.IService;
-
- public interface GoodsInService extends IService<GoodsIn> {
- IPage getPage(int currentPage,int pageSize,GoodsIn goodsIn);
-
- }
- package com.aliyev.service;
-
-
- import com.aliyev.domain.Employee;
- import com.aliyev.domain.GoodsIn;
- import com.aliyev.domain.GoodsOut;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.service.IService;
-
- public interface GoodsOutService extends IService<GoodsOut> {
- IPage getPage(int currentPage, int pageSize, GoodsOut goodsOut);
- }
接口实现类
- package com.aliyev.service.impl;
-
- import com.aliyev.dao.EmployeeDao;
- import com.aliyev.domain.Employee;
- import com.aliyev.service.EmployeeService;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
-
- @Service
- public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, Employee> implements EmployeeService {
-
- @Autowired
- private EmployeeDao employeeDao;
- @Override
- public IPage<Employee> getPage(int currentPage, int pageSize) {
- IPage<Employee> page=new Page<>(currentPage,pageSize);
- employeeDao.selectPage(page,null);
- return page;
- }
- }
- package com.aliyev.service.impl;
-
- import com.aliyev.dao.EmployeeDao;
- import com.aliyev.dao.GoodsInDao;
- import com.aliyev.domain.Employee;
- import com.aliyev.domain.GoodsIn;
- import com.aliyev.service.EmployeeService;
- import com.aliyev.service.GoodsInService;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import org.apache.logging.log4j.util.Strings;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
-
- @Service
- public class GoodsInServiceImpl extends ServiceImpl<GoodsInDao, GoodsIn> implements GoodsInService {
-
- @Autowired
- private GoodsInDao goodsInDao;
- @Override
- public IPage getPage(int currentPage, int pageSize,GoodsIn goodsIn) {
-
- LambdaQueryWrapper<GoodsIn> lqw=new LambdaQueryWrapper<>();
- lqw.like(Strings.isNotEmpty(goodsIn.getName()),GoodsIn::getName,goodsIn.getName())
- .like(Strings.isNotEmpty(goodsIn.getModel()),GoodsIn::getModel,goodsIn.getModel())
- .like(Strings.isNotEmpty(goodsIn.getLocation()),GoodsIn::getLocation,goodsIn.getLocation());
- IPage page=new Page(currentPage,pageSize);
- goodsInDao.selectPage(page,lqw);
- return page;
- }
- }
- package com.aliyev.service.impl;
-
- import com.aliyev.dao.EmployeeDao;
- import com.aliyev.dao.GoodsOutDao;
- import com.aliyev.domain.Employee;
- import com.aliyev.domain.GoodsIn;
- import com.aliyev.domain.GoodsOut;
- import com.aliyev.service.EmployeeService;
- import com.aliyev.service.GoodsOutService;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import org.apache.logging.log4j.util.Strings;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
-
- @Service
- public class GoodsOutServiceImpl extends ServiceImpl<GoodsOutDao, GoodsOut> implements GoodsOutService {
-
- @Autowired
- private GoodsOutDao goodsOutDao;
- @Override
- public IPage getPage(int currentPage, int pageSize, GoodsOut goodsIn) {
- LambdaQueryWrapper<GoodsOut> lqw=new LambdaQueryWrapper<>();
- lqw.like(Strings.isNotEmpty(goodsIn.getName()),GoodsOut::getName,goodsIn.getName())
- .like(Strings.isNotEmpty(goodsIn.getModel()),GoodsOut::getModel,goodsIn.getModel())
- .like(Strings.isNotEmpty(goodsIn.getDeliveryman()),GoodsOut::getDeliveryman,goodsIn.getDeliveryman());
- IPage page=new Page(currentPage,pageSize);
- goodsOutDao.selectPage(page,lqw);
- return page;
- }
- }
员工控制层
- package com.aliyev.controller;
-
- import com.aliyev.domain.Employee;
- import com.aliyev.domain.PasswordSetting;
- import com.aliyev.service.EmployeeService;
- import com.aliyev.utils.Result;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.logging.log4j.util.Strings;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
-
- import javax.servlet.http.HttpServletRequest;
-
-
- @RestController
- @RequestMapping(value = "/employee")
- @Slf4j
- public class EmployeeController {
- @Autowired
- private EmployeeService employeeService;
-
- /**
- * 获取登录对象数据
- *
- * @param id
- * @return
- */
- @GetMapping("{id}")
- public Result<Employee> user(@PathVariable Integer id) {
- System.out.println("ada" + id);
- Employee emp = employeeService.getById(id);
- return Result.success(emp, "查询成功");
- }
-
- /**
- * 登录
- *
- * @param employee
- * @param request
- * @return
- */
- @RequestMapping(value = "/login", method = RequestMethod.POST)
- public Result<String> login(Employee employee, HttpServletRequest request) {
- String username = employee.getUsername();
- String password = employee.getPassword();
-
- LambdaQueryWrapper<Employee> lqw = new LambdaQueryWrapper<>();
- lqw.eq(Strings.isNotEmpty(username), Employee::getUsername, username);
- Employee emp = employeeService.getOne(lqw);
- if (emp == null) {
- return Result.error("用户名不存在!");
- }
- if (!emp.getPassword().equals(password)) {
- return Result.error("用户名或密码错误");
- }
-
- request.getSession().setAttribute("employee", emp.getId());
- return Result.success(emp.getId().toString(), "登录成功~~");
- }
-
- /**
- * 退出登录
- *
- * @param request
- * @return
- */
- @RequestMapping("/logout")
- public Result<String> logout(HttpServletRequest request) {
- request.getSession().removeAttribute("employee");
- return Result.success("退出登录成功~~");
- }
-
- /**
- * 分页多田间查询
- *
- * @param currentPage
- * @param pageSize
- * @return
- */
- @RequestMapping()
- public Result<IPage> getEmployssPage(Integer currentPage, Integer pageSize, Employee employee) {
- log.info(employee.toString());
- IPage<Employee> page = employeeService.getPage(currentPage, pageSize);
- LambdaQueryWrapper<Employee> lqw = new LambdaQueryWrapper<>();
- lqw.like(Strings.isNotEmpty(employee.getUsername()), Employee::getUsername, employee.getUsername())
- .like(Strings.isNotEmpty(employee.getClassify()), Employee::getClassify, employee.getClassify())
- .like(Strings.isNotEmpty(employee.getName()), Employee::getName, employee.getName())
- .like(Strings.isNotEmpty(employee.getSex()), Employee::getSex, employee.getSex())
- .like(Strings.isNotEmpty(employee.getAddress()), Employee::getAddress, employee.getAddress());
- employeeService.page(page, lqw);
- //当前页大于无数据时,挑至最大页码
- if (currentPage > page.getPages()) {
- currentPage = (int) page.getPages();
- IPage<Employee> pages = employeeService.getPage(currentPage, pageSize);
- employeeService.page(pages, lqw);
- return Result.success(pages);
- }
- return Result.success(page);
- }
-
- @RequestMapping(value = "/updataPassword", method = RequestMethod.POST)
- public Result<String> updatePassword(PasswordSetting passwordSetting, HttpServletRequest request) {
- LambdaQueryWrapper<Employee> lqw = new LambdaQueryWrapper<>();
- lqw.eq(Strings.isNotEmpty(passwordSetting.getId().toString()), Employee::getId, passwordSetting.getId())
- .eq(Strings.isNotEmpty(passwordSetting.getOldPassword()), Employee::getPassword, passwordSetting.getOldPassword());
- Employee emp = employeeService.getOne(lqw);
- // log.info(emp.toString());
- if (emp == null) {
- return Result.error("旧密码错误,请重新填写!!!");
- }
- emp.setPassword(passwordSetting.getNewPassword());
- employeeService.updateById(emp);
-
- //更改成功后重新登录
- request.getSession().removeAttribute("employee");
- return Result.success("修改成功");
- }
-
- /**
- * 添加员工
- *
- * @param employee
- * @return
- */
- @RequestMapping(method = RequestMethod.POST)
- public Result<String> addEmployee(Employee employee) {
- LambdaQueryWrapper<Employee> lqw = new LambdaQueryWrapper<>();
- lqw.eq(Strings.isNotEmpty(employee.getUsername()), Employee::getUsername, employee.getUsername());
- Employee emp = employeeService.getOne(lqw);
- if (emp != null) {
- return Result.error("该用户名已存在,请重新填写用户名~~");
- }
- employeeService.save(employee);
- return Result.success("添加成功");
- }
-
- /**
- * 根据id删除
- *
- * @param id
- * @return
- */
- @RequestMapping("/deleteById")
- public Result<String> removeById(Integer id) {
-
- LambdaQueryWrapper<Employee> lqw = new LambdaQueryWrapper<>();
- lqw.eq(Strings.isNotEmpty(id.toString()), Employee::getId, id);
- Employee emp = employeeService.getOne(lqw);
- if (emp == null) {
- return Result.error("该数据在服务器已不存在,请重新刷新试试~~");
- }
-
- if (employeeService.removeById(id)) {
- return Result.success("删除成功!");
- }
- return Result.error("删除失败");
- }
-
- @RequestMapping(value = "updateById", method = RequestMethod.POST)
- public Result<String> updateById(Employee employee) {
- System.out.println(employee);
-
- return employeeService.updateById(employee) ? Result.success("修改成功~~") : Result.error("修改失败~~");
- }
- }
入库控制层
- package com.aliyev.controller;
-
- import com.aliyev.domain.GoodsIn;
- import com.aliyev.service.GoodsInService;
- import com.aliyev.utils.Result;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.logging.log4j.util.Strings;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import java.time.LocalDateTime;
-
- @RestController
- @RequestMapping("/goodsIn")
- @Slf4j
- public class GoodsInController {
-
- @Autowired
- private GoodsInService goodsInService;
-
- /**
- * 分页查询
- * @param currentPage
- * @param pageSize
- * @param goodsIn
- * @return
- */
- @RequestMapping()
- public Result<IPage> getAll(Integer currentPage, Integer pageSize, GoodsIn goodsIn) {
- IPage page = goodsInService.getPage(currentPage, pageSize, goodsIn);
- if(currentPage>page.getPages()){
- IPage newPage = goodsInService.getPage((int) page.getPages(), pageSize, goodsIn);
- return Result.success(newPage,"查询成功!");
- }
- if ((page.getPages() == 0 && (goodsIn.getName() != null || goodsIn.getModel() != null))
- && (page.getPages() == 0 && goodsIn.getName() != null && goodsIn.getModel() != null)) {
- Result.success(page, "查无此数据!!");
- } else if (page.getPages() == 0 && goodsIn.getName() == null && goodsIn.getModel() == null) {
- return Result.error("服务器故障,请联系管理员~~");
- }
- return Result.success(page,"查询成功");
- }
-
- /**
- * 商品入库
- * @param goodsIn
- * @return
- */
- @RequestMapping(method = RequestMethod.POST)
- public Result<String> saveGoods(GoodsIn goodsIn){
- goodsIn.setTime(LocalDateTime.now());
- LambdaQueryWrapper<GoodsIn> lqw=new LambdaQueryWrapper<>();
- lqw.eq(Strings.isNotEmpty(goodsIn.getName()),GoodsIn::getName,goodsIn.getName())
- .eq(Strings.isNotEmpty(goodsIn.getModel()),GoodsIn::getModel,goodsIn.getModel())
- .eq(Strings.isNotEmpty(goodsIn.getVendor()),GoodsIn::getVendor,goodsIn.getVendor())
- .eq(Strings.isNotEmpty(goodsIn.getSpecification()),GoodsIn::getSpecification,goodsIn.getSpecification())
- .eq(Strings.isNotEmpty(goodsIn.getUnit()),GoodsIn::getUnit,goodsIn.getUnit());
- GoodsIn goodIn = goodsInService.getOne(lqw);
- if(goodIn!=null){
- goodIn.setTime(LocalDateTime.now());
- goodIn.setNumber(goodIn.getNumber()+goodsIn.getNumber());
- goodsInService.updateById(goodIn);
- return Result.success("入库成功~~");
- }else if(goodIn==null){
- goodsInService.save(goodsIn);
- return Result.success("入库成功~~");
- }else{
- return Result.error("入库失败,系统发生故障,请联系管理员~~");
- }
- }
-
- /**
- * 删除商品
- * @param id
- * @return
- */
- @RequestMapping("deleteGoods")
- public Result<String> deleteByIdGoods(Integer id){
- LambdaQueryWrapper<GoodsIn> lqw=new LambdaQueryWrapper<>();
- lqw.eq(Strings.isNotEmpty(id.toString()),GoodsIn::getId,id);
- GoodsIn good = goodsInService.getOne(lqw);
- if(good==null){
- return Result.error("数据库中无该数据,请重新刷新看看~~");
- }
- return goodsInService.removeById(id)?Result.success("删除成功!"):Result.error("服务器故障,删除失败,请联系管理员!");
-
- }
-
- /**
- * 修改商品信息
- * @param goodsIn
- * @return
- */
- @RequestMapping("updateGoods")
- public Result<String> UpdateById(GoodsIn goodsIn){
- goodsIn.setTime(LocalDateTime.now());
- LambdaQueryWrapper<GoodsIn> lqw=new LambdaQueryWrapper<>();
- lqw.eq(Strings.isNotEmpty(goodsIn.getId().toString()),GoodsIn::getId,goodsIn.getId());
- GoodsIn good = goodsInService.getOne(lqw);
- if(good==null){
- return Result.error("数据库中无该数据,请重新刷新看看~~");
- }
- return goodsInService.updateById(goodsIn)?Result.success("修改成功!"):Result.error("修改失败!");
- }
- }
出库控制层
- package com.aliyev.controller;
-
- import com.aliyev.domain.GoodsIn;
- import com.aliyev.domain.GoodsOut;
- import com.aliyev.service.GoodsInService;
- import com.aliyev.service.GoodsOutService;
- import com.aliyev.utils.Result;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.logging.log4j.util.Strings;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
-
- import java.time.LocalDateTime;
-
- @RestController
- @RequestMapping("/goodsOut")
- @Slf4j
- public class GoodsOutController {
- @Autowired
- private GoodsOutService goodsOutService;
-
- @Autowired
- private GoodsInService goodsInService;
-
- /**
- * 商品出库
- * @param goodsOut
- * @return
- */
- @RequestMapping(method = RequestMethod.POST)
- public Result<String> saveGoodsOut(GoodsOut goodsOut){
- log.info("接收的数据"+goodsOut);
- LambdaQueryWrapper<GoodsIn> law=new LambdaQueryWrapper<>();
- law.eq(Strings.isNotEmpty(goodsOut.getName()),GoodsIn::getName,goodsOut.getName())
- .eq(Strings.isNotEmpty(goodsOut.getVendor()),GoodsIn::getVendor,goodsOut.getVendor())
- .eq(Strings.isNotEmpty(goodsOut.getModel()),GoodsIn::getModel,goodsOut.getModel())
- .eq(Strings.isNotEmpty(goodsOut.getSpecification()),GoodsIn::getSpecification,goodsOut.getSpecification())
- .eq(Strings.isNotEmpty(goodsOut.getId().toString()),GoodsIn::getId,goodsOut.getId());
- GoodsIn goodsIn = goodsInService.getOne(law);
- System.out.println("查询到的数据"+goodsIn);
- if(goodsIn==null){
- return Result.error("服务器故障,请刷新!");
- }
- if(goodsOut.getOutNumber()>goodsIn.getNumber()){
- return Result.error("当前货存量只有"+goodsIn.getNumber());
- }
- int number=goodsIn.getNumber()-goodsOut.getOutNumber();
- if(number==0){
- goodsInService.removeById(goodsIn.getId());
- goodsOut.setOutTime(LocalDateTime.now());
- goodsOut.setId(null);
- goodsOutService.save(goodsOut);
- return Result.success("出库成功");
- }else{
- goodsOut.setOutTime(LocalDateTime.now());
- goodsOut.setId(null);
- goodsOutService.save(goodsOut);
- goodsIn.setNumber(number);
- goodsInService.updateById(goodsIn);
- return Result.success("出库成功~~~");
- }
- }
-
- /**
- * 获取全部数据
- * @param currentPage
- * @param pageSize
- * @param goodsOut
- * @return
- */
- @RequestMapping()
- public Result<IPage> getAll(Integer currentPage, Integer pageSize, GoodsOut goodsOut) {
- IPage page = goodsOutService.getPage(currentPage, pageSize, goodsOut);
- if(currentPage>page.getPages()){
- IPage newPage = goodsOutService.getPage((int) page.getPages(), pageSize, goodsOut);
- return Result.success(newPage,"查询成功!");
- }
- if ((page.getPages() == 0 && (goodsOut.getName() != null || goodsOut.getModel() != null))
- && (page.getPages() == 0 && goodsOut.getName() != null && goodsOut.getModel() != null)) {
- Result.success(page, "查无此数据!!");
- } else if (page.getPages() == 0 && goodsOut.getName() == null && goodsOut.getModel() == null) {
- return Result.error("服务器故障,请联系管理员~~");
- }
- return Result.success(page,"查询成功");
- }
- @RequestMapping("deleteGoods")
- public Result<String> deleteByIdGoods(Integer id){
- LambdaQueryWrapper<GoodsOut> lqw=new LambdaQueryWrapper<>();
- lqw.eq(Strings.isNotEmpty(id.toString()),GoodsOut::getId,id);
- GoodsOut good = goodsOutService.getOne(lqw);
- if(good==null){
- return Result.error("数据库中无该数据,请重新刷新看看~~");
- }
- return goodsOutService.removeById(id)?Result.success("删除成功!"):Result.error("服务器故障,删除失败,请联系管理员!");
-
- }
- }
- package com.aliyev.utils;
-
- import com.fasterxml.jackson.databind.DeserializationFeature;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.fasterxml.jackson.databind.module.SimpleModule;
- import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
- import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
- import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
- import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
- import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
- import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
- import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
-
- import java.math.BigInteger;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.time.LocalTime;
- import java.time.format.DateTimeFormatter;
-
- import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
-
- /**
- * 对象映射器:基于jackson将Java对象转为json,或者将json转为Java对象
- * 将JSON解析为Java对象的过程称为 [从JSON反序列化Java对象]
- * 从Java对象生成JSON的过程称为 [序列化Java对象到JSON]
- */
- public class JacksonObjectMapper extends ObjectMapper {
-
- public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
- public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
- public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
-
- public JacksonObjectMapper() {
- super();
- //收到未知属性时不报异常
- this.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- //反序列化时,属性不存在的兼容处理
- this.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
-
-
- SimpleModule simpleModule = new SimpleModule()
- .addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)))
- .addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)))
- .addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)))
-
- .addSerializer(BigInteger.class, ToStringSerializer.instance)
- .addSerializer(Long.class, ToStringSerializer.instance)
- .addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)))
- .addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)))
- .addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
-
- //注册功能模块 例如,可以添加自定义序列化器和反序列化器
- this.registerModule(simpleModule);
- }
- }
- package com.aliyev.utils;
-
- import lombok.Data;
-
- import java.util.HashMap;
- import java.util.Map;
-
- @Data
- public class Result<T> {
- private Integer code;//0失败,1成功
- private String msg;
- private T Data;
- private Map map=new HashMap();//动态数据
-
- //成功数据封装
- public static <T> Result<T> success(T obj){
- Result<T> r = new Result<>();
- r.code=1;
- r.Data=obj;
- return r;
- }
- public static <T> Result<T> success(T obj,String msg){
- Result<T> r = new Result<>();
- r.code=1;
- r.Data=obj;
- r.msg=msg;
- return r;
- }
-
- //失败数据封装
- public static <T> Result<T> error(String msg){
- Result<T> r = new Result<>();
- r.code=0;
- r.msg=msg;
- return r;
- }
-
- //
- public Result<T> add(String key, String value){
- this.map.put(key,value);
- return this;
- }
-
- }
- package com.aliyev.filter;
-
-
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.util.AntPathMatcher;
-
- import javax.servlet.*;
- import javax.servlet.annotation.WebFilter;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
-
- @WebFilter(filterName = "loginCheckFilter",urlPatterns = "/*")
- @Slf4j
- public class LoginCheckFilter implements Filter {
- private static final AntPathMatcher PATH_MATCHER=new AntPathMatcher();//通配符比较器
- @Override
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
- HttpServletRequest request = (HttpServletRequest) servletRequest;
- HttpServletResponse response = (HttpServletResponse) servletResponse;
- String requestURI = request.getRequestURI();
- String[] urls=new String[]{
- "/employee/login",
- "/employee/logout",
- "/layuimini/css/**",
- "/layuimini/images/**",
- "/layuimini/js/**",
- "/layuimini/lib/**",
- "/layuimini/pages/user/login.html",
- };
- for (String url : urls) {
- if(PATH_MATCHER.match(url,requestURI)){
- filterChain.doFilter(request,response);
- log.info("释放的资源{}",requestURI);
- return;
- }
- }
- //检查是否登录
- if(request.getSession().getAttribute("employee")!=null){
- filterChain.doFilter(request,response);
- return;
- }
-
- response.sendRedirect("/layuimini/pages/user/login.html");
- return;
- }
-
-
- }
由于页面代码涉及太多,需要者留下邮箱,博主看到私发~~~
创作不易,需要者自取,留下一个小赞在走吧~~~~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。