商城项目15_采购需求合并采购单领取采购单完成采购仓库流程图
Posted 所得皆惊喜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了商城项目15_采购需求合并采购单领取采购单完成采购仓库流程图相关的知识,希望对你有一定的参考价值。
文章目录
- ①. 整合ware服务
- ②. 仓库维护 - info
- ③. 库存 - ware_sku
- ④. 查询采购需求
- ⑤. 合并采购单 - merge
- ⑥. 领取采购单 - received
- ⑦. 完成采购 - done
- ⑧. 采购整体流程图
①. 整合ware服务
- ①. 创建项目后nacos注册中心、配置中心、重写网关、配置日志等级为debug模式
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://192.168.56.11:3306/gulimall_wms?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
username: root
password: root
application:
name: gulimall-ware
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
jackson:
date-format: yyyy-MM-dd HH:mm:ss
mybatis-plus:
# classpath*:/mapper/**/*.xml 表示不止扫描自己类路径下的mapper,其他引入的mapper也会进行扫描
# classpath*:/mapper/**/*.xml 只扫描自己的路径下
mapper-locations: classpath:/mapper/**/*.xml
# 如下代码是mybatisplus中配置自增主键
global-config:
db-config:
id-type: auto
server:
port: 11000
# 打印日志级别
logging:
level:
com.atguigu.gulimall: debug
spring.application.name=gulimall-ware
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.namespace=957e05c7-6c16-4a55-8d8e-ff21e842e530
spring.cloud.nacos.config.file-extension=yaml
spring:
cloud:
gateway:
routes:
- id: ware_route
uri: lb://gulimall-ware
predicates:
- Path=/api/ware/**
filters:
- RewritePath=/api/(?<segment>/?.*), /$\\segment
- ②. 主启动类加上对应的注解、整合mybatis-plus
@EnableTransactionManagement
@SpringBootApplication
@MapperScan("com.atguigu.gulimall.ware.dao")
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "com.atguigu.gulimall.ware.feign")
public class GulimallWareApplication
public static void main(String[] args)
SpringApplication.run(GulimallWareApplication.class, args);
- ③. 配置仓库服务的jvm参数
②. 仓库维护 - info
- ①. 查看表结构
CREATE TABLE `wms_ware_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(255) DEFAULT NULL COMMENT '仓库名',
`address` varchar(255) DEFAULT NULL COMMENT '仓库地址',
`areacode` varchar(20) DEFAULT NULL COMMENT '区域编码',
PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='仓库信息';
- ②. 可以根据id精准匹配、仓库名和仓库地址模糊查询
@Override
public PageUtils queryPage(Map<String, Object> params)
QueryWrapper<WareInfoEntity> wrapper = new QueryWrapper<>();
String key=(String)params.get("key");
if(!StringUtils.isEmpty(key))
wrapper.eq("id",key)
.or().like("name",key)
.or().like("address",key);
IPage<WareInfoEntity> page = this.page(
new Query<WareInfoEntity>().getPage(params),
wrapper
);
return new PageUtils(page);
③. 库存 - ware_sku
- ①. 查看表结构
CREATE TABLE `wms_ware_sku` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`sku_id` bigint(20) DEFAULT NULL COMMENT 'sku_id',
`ware_id` bigint(20) DEFAULT NULL COMMENT '仓库id',
`stock` int(11) DEFAULT NULL COMMENT '库存数',
`sku_name` varchar(200) DEFAULT NULL COMMENT 'sku_name',
`stock_locked` int(11) DEFAULT NULL COMMENT '锁定库存',
PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='商品库存';
- ②. 接口请求参数、响应参数
- ③. 后台快速操作数据库页面,一般我们不这样去新增库存,需要用到采购需求和采购单,这里只是一个数据库层面的操作
@Override
public PageUtils queryPage(Map<String, Object> params)
QueryWrapper<WareSkuEntity> wrapper = new QueryWrapper<>();
String wareId = (String)params.get("wareId");
String skuId = (String)params.get("skuId");
if(StringUtils.isNotEmpty(wareId))
wrapper.eq("ware_id",wareId);
if(StringUtils.isNotEmpty(skuId))
wrapper.eq("sku_id",skuId);
IPage<WareSkuEntity> page = this.page(
new Query<WareSkuEntity>().getPage(params),
wrapper
);
return new PageUtils(page);
④. 查询采购需求
- ①. 查看表结构
CREATE TABLE `wms_purchase_detail` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`purchase_id` bigint(20) DEFAULT NULL COMMENT '采购单id',
`sku_id` bigint(20) DEFAULT NULL COMMENT '采购商品id',
`sku_num` int(11) DEFAULT NULL COMMENT '采购数量',
`sku_price` decimal(18,4) DEFAULT NULL COMMENT '采购金额',
`ware_id` bigint(20) DEFAULT NULL COMMENT '仓库id',
`status` int(11) DEFAULT NULL COMMENT '状态[0新建,1已分配,2正在采购,3已完成,4采购失败]',
PRIMARY KEY (`id`)
) ENGINE=InnoDB comment='采购需求';
- ②. 接口请求参数、响应参数
// 请求参数
page: 1,//当前页码
limit: 10,//每页记录数
sidx: 'id',//排序字段
order: 'asc/desc',//排序方式
key: '华为',//检索关键字
status: 0,//状态
wareId: 1,//仓库id
//响应数据
"msg": "success",
"code": 0,
"page":
"totalCount": 0,
"pageSize": 10,
"totalPage": 0,
"currPage": 1,
"list": [
"id": 2,
"purchaseId": 1,
"skuId": 1,
"skuNum": 2,
"skuPrice": 22.0000,
"wareId": 1,
"status": 1
]
- ③. 代码实现
@Override
public PageUtils queryPage(Map<String, Object> params)
QueryWrapper<PurchaseDetailEntity> wrapper = new QueryWrapper<>();
String key=(String)params.get("key");
if(!StringUtils.isEmpty(key))
wrapper.and(w->
w.eq("purchase_id",key).or().eq("sku_id",key);
);
//状态
String status = (String) params.get("status");
wrapper.eq(StringUtils.isNotBlank(status),"status",status);
//仓库id
String wareId = (String) params.get("wareId");
wrapper.eq(StringUtils.isNotBlank(wareId),"ware_id",wareId);
IPage<PurchaseDetailEntity> page = this.page(
new Query<PurchaseDetailEntity>().getPage(params),
wrapper
);
return new PageUtils(page);
⑤. 合并采购单 - merge
- ①. 先要有一个采购单
- ②. 合并到整单列表的时候,需要将采购单状态是新建(0)、已分配(1)的查询出来
@Override
public PageUtils queryPageUnreceive(Map<String, Object> params)
QueryWrapper<PurchaseEntity> wrapper = new QueryWrapper<>();
//采购单刚刚创建、或者还没有被领取
wrapper.in("status",0,1);
IPage<PurchaseEntity> page = this.page(
new Query<PurchaseEntity>().getPage(params),
wrapper
);
return new PageUtils(page);
- ③. 采购单表以及流程
CREATE TABLE `wms_purchase` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '采购单id',
`assignee_id` bigint(20) DEFAULT NULL COMMEacNT '采购人id',
`assignee_name` varchar(255) DEFAULT NULL COMMENT '采购人名',
`phone` char(13) DEFAULT NULL COMMENT '联系方式',
`priority` int(4) DEFAULT NULL COMMENT '优先级',
`status` int(4) DEFAULT NULL COMMENT '状态',
`ware_id` bigint(20) DEFAULT NULL COMMENT '仓库id',
`amount` decimal(18,4) DEFAULT NULL COMMENT '总金额',
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
`update_time` datetime DEFAULT NULL COMMENT '更新日期',
PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='采购信息';
- ④. 接口文档请求参数、响应参数(/ware/purchase/merge)
//请求参数
purchaseId: 1, //整单id
items:[1,2,3,4] //合并项集合
//响应参数
"msg": "success",
"code": 0
- ⑤. 新建枚举类
public class WareConstant
public enum PurchaseStatusEnum
CREATED(0,"新建"),ASSIGNED(1,"已分配"),
RECEIVE(2,"已领取"),FINISH(3,"已完成"),
HASERROR(4,"有异常");
private int code;
private String msg;
PurchaseStatusEnum(int code,String msg)
this.code = code;
this.msg = msg;
public int getCode()
return code;
public String getMsg()
return msg;
public enum PurchaseDetailStatusEnum
CREATED(0,"新建"),ASSIGNED(1,"已分配"),
BUYING(2,"正在采购"),FINISH(3,"已完成"),
HASERROR(4,"采购失败");
private int code;
private String msg;
PurchaseDetailStatusEnum(int code,String msg)
this.code = code;
this.msg = msg;
public int getCode()
return code;
public String getMsg()
return msg;
- ⑥. 完整代码展示
/**
* 合并采购需求
* @param mergeVo
*/
@Transactional
@Override
public void mergePurchase(MergeVo mergeVo)
Long purchaseId = mergeVo.getPurchaseId();
// 如果没有采购单,可以自动生成一个采购单
if(purchaseId==null)
PurchaseEntity purchaseEntity=new PurchaseEntity();
purchaseEntity.setStatus(WareConstant.PurchaseStatusEnum.CREATED.getCode());
purchaseEntity.setCreateTime(new Date());
purchaseEntity.setUpdateTime(new Date());
以上是关于商城项目15_采购需求合并采购单领取采购单完成采购仓库流程图的主要内容,如果未能解决你的问题,请参考以下文章
商城项目15_采购需求合并采购单领取采购单完成采购仓库流程图
048医疗项目-模块四:采购单模块—采购单受理(Dao,Service,Action三层)