当前位置:网站首页>商品管统——采购需求合并到采购单
商品管统——采购需求合并到采购单
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
边栏推荐
- Error running app:Default Activity not found 解决方法
- lodash.js源码-flatten
- SQL case conversion, remove the space before and after
- Validation failed for one or more entities. See 'entityvalidationerrors' solution
- Notes on Python cookbook 3rd (2.2): String start or end match
- 编码风格:Mvc模式下SSM环境,代码分层管理
- YouTube subscription: solve the problem of incomplete height display of YouTube subscription button in pop-up window
- Functional guide for temporary users and novices of PL / SQL developer
- 《Python Cookbook 3rd》笔记(2.2):字符串开头或结尾匹配
- 痞子衡嵌入式:RT-UFL - 一个适用全平台i.MXRT的超级下载算法设计
猜你喜欢
![Usage of [:] and [::] in Python](/img/3b/00bc81122d330c9d59909994e61027.jpg)
Usage of [:] and [::] in Python

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

For programmers, those unfamiliar and familiar computer hardware

Exhibition cloud technology interpretation | in the face of emergencies, how does app do a good job in crash analysis and performance monitoring?

必看!RDS 数据库入门一本通(附网盘链接)

史上最全异常检测算法概述

z-index属性详解

推动中国制造升级,汽车装配车间生产流水线 3D 可视化

Unity使用transform.Rotate进行三维旋转角度出现偏差

Prometheus安装配置
随机推荐
CUDA_ Register and local memory
What is the SRM system? SRM supplier management system functions
史上最全异常检测算法概述
Difficulties in heterogeneous middleware implementation of Bifrost site management (1)
Algorithm template arrangement (1)
Baishan cloud technology is selected as the top 100 Internet enterprises in China in 2020
How much is the cost of CRM system?
jt-day10
【LeetCode】 92 整数反转
Python prompt attributeerror or depreciation warning: This module was degraded solution
完美日记母公司逸仙电商招股书:重营销、轻研发,前三季度亏11亿
Self writing performance testing tool (2)
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
Validation failed for one or more entities. See ‘EntityValidationErrors’解决方法
Error running app: default activity not found solution
SQL case conversion, remove the space before and after
2020-11-09:谈谈布隆过滤器和布谷鸟过滤器的相同点和不同点?
CUDA_主机内存
Thinking about competitive programming: myths and shocking facts
If you need a million objects