当前位置:网站首页>商品管统——采购需求合并到采购单
商品管统——采购需求合并到采购单
2020-11-10 07:37:00 【osc_y8ifc29r】
一 采购简要流程

二 查询未领取的采购单
1 请求
GET /ware/purchase/unreceive/list
2 响应数据
{
"msg": "success",
"code": 0,
"page": {
"totalCount": 0,
"pageSize": 10,
"totalPage": 0,
"currPage": 1,
"list": [{
"id": 1,
"assigneeId": 1,
"assigneeName": "aa",
"phone": "123",
"priority": 1,
"status": 1,
"wareId": 1,
"amount": 22.0000,
"createTime": "2019-12-12",
"updateTime": "2019-12-12"
}]
}
}
三 合并采购需求
1 请求
POST /ware/purchase/merge
2 请求参数
{
purchaseId: 1, //整单id
items: [1, 2, 3, 4] //合并项集合
}
3 响应数据
{
"msg": "success",
"code": 0
}
四 控制器
/**
* 功能描述:合并采购需求
*
* @param mergeVo 待合并的采购单
* @return R 返回给前端的数据
* @author cakin
* @date 2020/11/9
*/
@PostMapping("/merge")
public R merge(@RequestBody MergeVo mergeVo) {
purchaseService.mergePurchase(mergeVo);
return R.ok();
}
/**
* 功能描述:查询未领取的采购单
*
* @param params 过滤条件
* @return R 返回给前端的数据
* @author cakin
* @date 2020/11/9
*/
@RequestMapping("/unreceive/list")
public R unreceivelist(@RequestParam Map<String, Object> params) {
PageUtils page = purchaseService.queryPageUnreceivePurchase(params);
return R.ok().put("page", page);
}
五 服务层
/**
* 功能描述:查询未领取的采购单
*
* @param params 过滤条件
* @return PageUtils 分页结果
* @author cakin
* @date 2020/11/9
*/
@Override
public PageUtils queryPageUnreceivePurchase(Map<String, Object> params) {
IPage<PurchaseEntity> page = this.page(
new Query<PurchaseEntity>().getPage(params),
// 0-刚新建 1-刚分配
new QueryWrapper<PurchaseEntity>().eq("status", 0).or().eq("status", 1)
);
return new PageUtils(page);
}
/**
* 功能描述:合并采购需求
*
* @param mergeVo 待合并的采购单
* @author cakin
* @date 2020/11/9
*/
@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());
this.save(purchaseEntity);
purchaseId = purchaseEntity.getId();
}
// TODO 确认采购单状态是0,1才可以合并
List<Long> items = mergeVo.getItems();
Long finalPurchaseId = purchaseId;
List<PurchaseDetailEntity> collect = items.stream().map(i -> {
PurchaseDetailEntity detailEntity = new PurchaseDetailEntity();
detailEntity.setId(i);
detailEntity.setPurchaseId(finalPurchaseId);
detailEntity.setStatus(WareConstant.PurchaseDetailStatusEnum.ASSIGNED.getCode());
return detailEntity;
}).collect(Collectors.toList());
// 更新采购需求
detailService.updateBatchById(collect);
// 更新采购单的时间字段
PurchaseEntity purchaseEntity = new PurchaseEntity();
purchaseEntity.setId(purchaseId);
purchaseEntity.setUpdateTime(new Date());
this.updateById(purchaseEntity);
}
六 VO
/**
* @className: MergeVo
* @description: 采购单
* @date: 2020/11/9
* @author: cakin
*/
@Data
public class MergeVo {
/**
* 整单id
*/
private Long purchaseId;
/**
* 合并项集合
*/
private List<Long> items;
}
七 枚举类
/**
* @className: WareConstant
* @description: 仓库枚举类
* @date: 2020/11/9
* @author: cakin
*/
public class WareConstant {
/**
* @className: PurchaseStatusEnum
* @description: 采购单状态枚举
* @date: 2020/11/9
* @author: cakin
*/
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;
}
}
/**
* @className: PurchaseDetailStatusEnum
* @description: 采购需求枚举
* @date: 2020/11/9
* @author: cakin
*/
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;
}
}
}
八 测试

版权声明
本文为[osc_y8ifc29r]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4313107/blog/4710449
边栏推荐
- [Python learning manual notes] 001. Preface to Python
- CUDA_ Host memory
- 分布式文档存储数据库之MongoDB索引管理
- CUDA_寄存器和局部存储器
- 一个名为不安全的类Unsafe
- CUDA_ Global memory and access optimization
- Using tail as time series to identify whales
- [python学习手册-笔记]001.python前言
- Prometheus安装配置
- What is the SRM system? SRM supplier management system functions
猜你喜欢

Functional guide for temporary users and novices of PL / SQL developer

Fear of reconstruction? I'm too late to tell you how to refactor. Now I'm here

Raspberry pie drum set WiFi

delete、truncate、drop 有什么区别,误删数据怎么办

Must see! RDS database all in one

JS label syntax jumps out of multiple loops

jt-day10

CUDA_存储器模型

Three ways to solve coursera video unable to watch

An unsafe class named unsafe
随机推荐
Ineuos industrial interconnection platform, web configuration (ineuview) increases the function of importing and exporting engineering views, as well as optimization and repair. Release: v3.2.1
对于程序员,那些既陌生又熟悉的计算机硬件
一幅图像能顶16x16字!——用于大规模图像缩放识别的变压器(对ICLR 2021年论文的简要回顾)
异常:Invalid or unexpected token
Algorithm template arrangement (1)
必看!RDS 数据库入门一本通(附网盘链接)
《Python Cookbook 3rd》笔记(2.2):字符串开头或结尾匹配
Hengxun Technology: the way to deal with server downtime
Common settings of PLSQL developer
delete、truncate、drop 有什么区别,误删数据怎么办
Yixian e-commerce prospectus of perfect diary parent company: focusing on marketing and ignoring R & D, with a loss of 1.1 billion in the first three quarters
表单验证,为避免全局污染,少定义全局变量写法
[elixir! 0073] beam built-in memory database ETS
实验2
史上最全异常检测算法概述
关于centos启动报错:Failed to start Crash recovery kernel arming的解决方案
Using tail as time series to identify whales
CUDA_ Register and local memory
CUDA_ constant memory
Coding style: SSM environment in MVC mode, code hierarchical management