当前位置:网站首页>商品管统——采购需求合并到采购单
商品管统——采购需求合并到采购单
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
边栏推荐
- Prometheus安装配置
- 实验2
- [elixir! #0073] beam 内置的内存数据库 —— ETS
- Incomplete Polyfill of proxy
- Validation failed for one or more entities. See 'entityvalidationerrors' solution
- YouTube subscription: solve the problem of incomplete height display of YouTube subscription button in pop-up window
- Oschina: my green plants are potatoes, ginger and garlic
- 极验无感验证破解
- Centos7 operating system security hardening series (2)
- The kth smallest node in the print binary search tree of offer
猜你喜欢
史上最全异常检测算法概述
[python学习手册-笔记]001.python前言
Must see! RDS database all in one
将Map中对应的key和value赋值到对象中
asp.net Using serilog in core and customizing enrich
编码风格:Mvc模式下SSM环境,代码分层管理
delete、truncate、drop 有什么区别,误删数据怎么办
接缝雕刻算法:一种看似不可能的图像大小调整方法
Python中[:]与[::]的用法
Validation failed for one or more entities. See ‘EntityValidationErrors’解决方法
随机推荐
Functional guide for temporary users and novices of PL / SQL developer
delete、truncate、drop 有什么区别,误删数据怎么办
C / C + + Programming Notes: C language development tank war! In memory of our lost little overlord game
Function calculation advanced IP query tool development
Notes on Python cookbook 3rd (2.2): String start or end match
编码风格:Mvc模式下SSM环境,代码分层管理
iNeuOS工业互联平台,WEB组态(iNeuView)增加工程视图导入、导出功能,及优化和修复,发布:v3.2.1版本
接缝雕刻算法:一种看似不可能的图像大小调整方法
Error running app:Default Activity not found 解决方法
Hand in hand to teach you to use container service tke cluster audit troubleshooting
使用call、apply和bind解决js中烦人的this,事件绑定时的this和传参问题
Oschina: my green plants are potatoes, ginger and garlic
jmeter接口测试--带有token的解决方法
Thinking about competitive programming: myths and shocking facts
Python中[:]与[::]的用法
C/C++编程笔记:C语言开发坦克大战!纪念我们逝去的小霸王游戏
关于centos启动报错:Failed to start Crash recovery kernel arming的解决方案
CUDA_全局内存及访问优化
大专学历的我工作六年了,还有机会进大厂吗?
Baishan cloud technology is selected as the top 100 Internet enterprises in China in 2020