当前位置:网站首页>商品管统——采购需求合并到采购单
商品管统——采购需求合并到采购单
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
边栏推荐
- 将Map中对应的key和value赋值到对象中
- Error running app:Default Activity not found 解决方法
- 消防知识线上答题活动小程序复盘
- Seam engraving algorithm: a seemingly impossible image size adjustment method
- Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
- Incomplete Polyfill of proxy
- CUDA_存储器模型
- CUDA_ Global memory and access optimization
- The length of the last word in leetcode
- Aikang Guobin denounced Guoxin Securities report as untrue and sent a lawyer's letter
猜你喜欢
Validation failed for one or more entities. See 'entityvalidationerrors' solution
Python prompt attributeerror or depreciation warning: This module was degraded solution
Exception: invalid or unexpected token
jt-day10
“wget: 无法解析主机地址”的解决方法
【LeetCode】 92 整数反转
一个名为不安全的类Unsafe
If you need a million objects
SQL case conversion, remove the space before and after
【LeetCode】 93 平衡二叉树
随机推荐
自己上手写性能测试工具(二)
CUDA_ Global memory and access optimization
Algorithm template arrangement (1)
大专学历的我工作六年了,还有机会进大厂吗?
CUDA_全局内存及访问优化
Assign the corresponding key and value in the map to the object
The length of the last word in leetcode
Come and learn! Development Guide for personalized recommendation system (with internet disk link)
【LeetCode】 93 平衡二叉树
Centos7 operating system security hardening series (2)
假如需要一百万个对象
Promote China manufacturing upgrade, 3D visualization of production line in automobile assembly workshop
Self writing performance testing tool (2)
初级工程师如何在职场生存
Difficulties in heterogeneous middleware implementation of Bifrost site management (1)
Error running app: default activity not found solution
CUDA常用概念及注意点
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
爱康国宾怒斥国信证券报告失实,已发律师函
So what should investors do with the current market? Now a new investment outlet is coming!