采购单初期版本
This commit is contained in:
parent
b91927bfde
commit
c8ac7159cf
@ -1,12 +1,17 @@
|
|||||||
package cn.lili.controller.purchase;
|
package cn.lili.controller.other.purchase;
|
||||||
|
|
||||||
|
import cn.lili.common.enums.ResultCode;
|
||||||
import cn.lili.common.enums.ResultUtil;
|
import cn.lili.common.enums.ResultUtil;
|
||||||
import cn.lili.common.security.context.UserContext;
|
import cn.lili.common.security.context.UserContext;
|
||||||
|
import cn.lili.common.vo.PageVO;
|
||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
||||||
|
import cn.lili.modules.goods.entity.dos.GoodsUnit;
|
||||||
|
import cn.lili.modules.goods.service.GoodsUnitService;
|
||||||
import cn.lili.modules.purchase.entity.dos.PurchaseOrder;
|
import cn.lili.modules.purchase.entity.dos.PurchaseOrder;
|
||||||
import cn.lili.modules.purchase.entity.params.PurchaseOrderSearchParams;
|
import cn.lili.modules.purchase.entity.params.PurchaseOrderSearchParams;
|
||||||
import cn.lili.modules.purchase.entity.vos.PurchaseOrderVO;
|
import cn.lili.modules.purchase.entity.vos.PurchaseOrderVO;
|
||||||
import cn.lili.modules.purchase.service.PurchaseOrderService;
|
import cn.lili.modules.purchase.service.PurchaseOrderService;
|
||||||
|
import cn.lili.mybatis.util.PageUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
@ -33,9 +38,19 @@ public class PurchaseBuyerController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PurchaseOrderService purchaseOrderService;
|
private PurchaseOrderService purchaseOrderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GoodsUnitService goodsUnitService;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "分页获取商品计量单位")
|
||||||
|
@GetMapping("/goodsUnit")
|
||||||
|
public ResultMessage<IPage<GoodsUnit>> goodsUnitPage(PageVO pageVO) {
|
||||||
|
return ResultUtil.data(goodsUnitService.page(PageUtil.initPage(pageVO)));
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "添加采购单")
|
@ApiOperation(value = "添加采购单")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ResultMessage<PurchaseOrderVO> addPurchaseOrderVO(PurchaseOrderVO purchaseOrderVO) {
|
public ResultMessage<PurchaseOrderVO> addPurchaseOrderVO(@RequestBody PurchaseOrderVO purchaseOrderVO) {
|
||||||
return ResultUtil.data(purchaseOrderService.addPurchaseOrder(purchaseOrderVO));
|
return ResultUtil.data(purchaseOrderService.addPurchaseOrder(purchaseOrderVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +79,7 @@ public class PurchaseBuyerController {
|
|||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public ResultMessage<Object> close(@NotNull @PathVariable String id) {
|
public ResultMessage<Object> close(@NotNull @PathVariable String id) {
|
||||||
purchaseOrderService.close(id);
|
purchaseOrderService.close(id);
|
||||||
return ResultUtil.success();
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,9 +1,14 @@
|
|||||||
package cn.lili.controller.purchase;
|
package cn.lili.controller.other.purchase;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.lili.common.enums.ResultCode;
|
||||||
import cn.lili.common.enums.ResultUtil;
|
import cn.lili.common.enums.ResultUtil;
|
||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
||||||
|
import cn.lili.modules.purchase.entity.dos.PurchaseOrder;
|
||||||
import cn.lili.modules.purchase.entity.dos.PurchaseQuoted;
|
import cn.lili.modules.purchase.entity.dos.PurchaseQuoted;
|
||||||
import cn.lili.modules.purchase.entity.vos.PurchaseQuotedVO;
|
import cn.lili.modules.purchase.entity.vos.PurchaseQuotedVO;
|
||||||
|
import cn.lili.modules.purchase.service.PurchaseOrderService;
|
||||||
import cn.lili.modules.purchase.service.PurchaseQuotedService;
|
import cn.lili.modules.purchase.service.PurchaseQuotedService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
@ -30,10 +35,19 @@ public class PurchaseQuotedController {
|
|||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private PurchaseQuotedService purchaseQuotedService;
|
private PurchaseQuotedService purchaseQuotedService;
|
||||||
|
/**
|
||||||
|
* 采购单
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private PurchaseOrderService purchaseOrderService;
|
||||||
|
|
||||||
@ApiOperation(value = "添加采购单报价")
|
@ApiOperation(value = "添加采购单报价")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ResultMessage<PurchaseQuoted> addPurchaseOrderVO(PurchaseQuotedVO purchaseQuotedVO) {
|
public ResultMessage<PurchaseQuoted> addPurchaseOrderVO(@RequestBody PurchaseQuotedVO purchaseQuotedVO) {
|
||||||
|
PurchaseOrder purchaseOrder=purchaseOrderService.getById(purchaseQuotedVO.getPurchaseOrderId());
|
||||||
|
if(DateUtil.compare(purchaseOrder.getDeadline(),new DateTime())< 0){
|
||||||
|
ResultUtil.error(ResultCode.PURCHASE_ORDER_DEADLINE_ERROR);
|
||||||
|
}
|
||||||
return ResultUtil.data(purchaseQuotedService.addPurchaseQuoted(purchaseQuotedVO));
|
return ResultUtil.data(purchaseQuotedService.addPurchaseQuoted(purchaseQuotedVO));
|
||||||
}
|
}
|
||||||
|
|
@ -449,6 +449,8 @@ public enum ResultCode {
|
|||||||
CUSTOM_WORDS_SECRET_KEY_ERROR(90002, "秘钥验证失败!"),
|
CUSTOM_WORDS_SECRET_KEY_ERROR(90002, "秘钥验证失败!"),
|
||||||
CONNECT_NOT_EXIST(90000, "登录方式不存在!"),
|
CONNECT_NOT_EXIST(90000, "登录方式不存在!"),
|
||||||
ELASTICSEARCH_INDEX_INIT_ERROR(90003, "索引初始化失败!"),
|
ELASTICSEARCH_INDEX_INIT_ERROR(90003, "索引初始化失败!"),
|
||||||
|
PURCHASE_ORDER_DEADLINE_ERROR(90004,"供求单,已超过报名截止时间")
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final Integer code;
|
private final Integer code;
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
package cn.lili.modules.purchase.serviceimpl;
|
package cn.lili.modules.purchase.serviceimpl;
|
||||||
|
|
||||||
|
import cn.lili.common.security.context.UserContext;
|
||||||
import cn.lili.common.utils.BeanUtil;
|
import cn.lili.common.utils.BeanUtil;
|
||||||
import cn.lili.modules.purchase.entity.dos.PurchaseOrder;
|
import cn.lili.modules.purchase.entity.dos.PurchaseOrder;
|
||||||
|
import cn.lili.modules.purchase.entity.dos.PurchaseOrderItem;
|
||||||
import cn.lili.modules.purchase.entity.params.PurchaseOrderSearchParams;
|
import cn.lili.modules.purchase.entity.params.PurchaseOrderSearchParams;
|
||||||
import cn.lili.modules.purchase.entity.vos.PurchaseOrderVO;
|
import cn.lili.modules.purchase.entity.vos.PurchaseOrderVO;
|
||||||
import cn.lili.modules.purchase.mapper.PurchaseOrderMapper;
|
import cn.lili.modules.purchase.mapper.PurchaseOrderMapper;
|
||||||
import cn.lili.modules.purchase.service.PurchaseOrderItemService;
|
import cn.lili.modules.purchase.service.PurchaseOrderItemService;
|
||||||
import cn.lili.modules.purchase.service.PurchaseOrderService;
|
import cn.lili.modules.purchase.service.PurchaseOrderService;
|
||||||
|
import cn.lili.mybatis.util.PageUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购单业务层实现
|
* 采购单业务层实现
|
||||||
@ -37,6 +36,7 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
|
|||||||
BeanUtil.copyProperties(purchaseOrderVO, purchaseOrder);
|
BeanUtil.copyProperties(purchaseOrderVO, purchaseOrder);
|
||||||
//添加采购单
|
//添加采购单
|
||||||
purchaseOrder.setStatus("OPEN");
|
purchaseOrder.setStatus("OPEN");
|
||||||
|
purchaseOrder.setMemberId(UserContext.getCurrentUser().getId());
|
||||||
this.save(purchaseOrder);
|
this.save(purchaseOrder);
|
||||||
//添加采购单子内容
|
//添加采购单子内容
|
||||||
purchaseOrderItemService.addPurchaseOrderItem(purchaseOrder.getId(), purchaseOrderVO.getPurchaseOrderItems());
|
purchaseOrderItemService.addPurchaseOrderItem(purchaseOrder.getId(), purchaseOrderVO.getPurchaseOrderItems());
|
||||||
@ -51,9 +51,8 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
|
|||||||
BeanUtil.copyProperties(purchaseOrder, purchaseOrderVO);
|
BeanUtil.copyProperties(purchaseOrder, purchaseOrderVO);
|
||||||
|
|
||||||
//获取采购单子内容
|
//获取采购单子内容
|
||||||
Map<String, Object> map = new HashMap<>(2);
|
purchaseOrderVO.setPurchaseOrderItems(purchaseOrderItemService.list(
|
||||||
map.put("purchaseOrderId", id);
|
new LambdaQueryWrapper<PurchaseOrderItem>().eq(PurchaseOrderItem::getPurchaseOrderId,id)));
|
||||||
purchaseOrderVO.setPurchaseOrderItems(purchaseOrderItemService.listByMap(map));
|
|
||||||
return purchaseOrderVO;
|
return purchaseOrderVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,21 +60,15 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
|
|||||||
public IPage<PurchaseOrder> page(PurchaseOrderSearchParams purchaseOrderSearchParams) {
|
public IPage<PurchaseOrder> page(PurchaseOrderSearchParams purchaseOrderSearchParams) {
|
||||||
|
|
||||||
LambdaQueryWrapper<PurchaseOrder> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<PurchaseOrder> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
if (purchaseOrderSearchParams.getMemberId() != null) {
|
|
||||||
lambdaQueryWrapper.eq(PurchaseOrder::getMemberId, purchaseOrderSearchParams.getMemberId());
|
|
||||||
}
|
|
||||||
if (purchaseOrderSearchParams.getCategoryId() != null) {
|
|
||||||
lambdaQueryWrapper.eq(PurchaseOrder::getCategoryId, purchaseOrderSearchParams.getCategoryId());
|
|
||||||
}
|
|
||||||
if (purchaseOrderSearchParams.getStatus() != null) {
|
|
||||||
lambdaQueryWrapper.eq(PurchaseOrder::getStatus, purchaseOrderSearchParams.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
Page page = new Page();
|
lambdaQueryWrapper.eq(purchaseOrderSearchParams.getMemberId() != null,
|
||||||
page.setSize(purchaseOrderSearchParams.getPageSize());
|
PurchaseOrder::getMemberId, purchaseOrderSearchParams.getMemberId());
|
||||||
page.setPages(purchaseOrderSearchParams.getPageNumber());
|
lambdaQueryWrapper.eq(purchaseOrderSearchParams.getCategoryId() != null,
|
||||||
IPage<PurchaseOrder> purchaseOrders = this.page(page, lambdaQueryWrapper);
|
PurchaseOrder::getCategoryId, purchaseOrderSearchParams.getCategoryId());
|
||||||
return purchaseOrders;
|
lambdaQueryWrapper.eq(purchaseOrderSearchParams.getStatus() != null,
|
||||||
|
PurchaseOrder::getStatus, purchaseOrderSearchParams.getStatus());
|
||||||
|
lambdaQueryWrapper.orderByDesc(PurchaseOrder::getCreateTime);
|
||||||
|
return this.page(PageUtil.initPage(purchaseOrderSearchParams), lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,7 @@ import cn.lili.common.utils.BeanUtil;
|
|||||||
import cn.lili.modules.purchase.entity.dos.PurchaseQuoted;
|
import cn.lili.modules.purchase.entity.dos.PurchaseQuoted;
|
||||||
import cn.lili.modules.purchase.entity.vos.PurchaseQuotedVO;
|
import cn.lili.modules.purchase.entity.vos.PurchaseQuotedVO;
|
||||||
import cn.lili.modules.purchase.mapper.PurchaseQuotedMapper;
|
import cn.lili.modules.purchase.mapper.PurchaseQuotedMapper;
|
||||||
|
import cn.lili.modules.purchase.service.PurchaseOrderService;
|
||||||
import cn.lili.modules.purchase.service.PurchaseQuotedItemService;
|
import cn.lili.modules.purchase.service.PurchaseQuotedItemService;
|
||||||
import cn.lili.modules.purchase.service.PurchaseQuotedService;
|
import cn.lili.modules.purchase.service.PurchaseQuotedService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@ -11,7 +12,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -26,9 +26,10 @@ import java.util.List;
|
|||||||
public class PurchaseQuotedServiceImpl extends ServiceImpl<PurchaseQuotedMapper, PurchaseQuoted> implements PurchaseQuotedService {
|
public class PurchaseQuotedServiceImpl extends ServiceImpl<PurchaseQuotedMapper, PurchaseQuoted> implements PurchaseQuotedService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PurchaseQuotedItemService purchaseQuotedItemService;
|
private PurchaseQuotedItemService purchaseQuotedItemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PurchaseQuotedVO addPurchaseQuoted(PurchaseQuotedVO purchaseQuotedVO) {
|
public PurchaseQuotedVO addPurchaseQuoted(PurchaseQuotedVO purchaseQuotedVO) {
|
||||||
|
|
||||||
|
|
||||||
PurchaseQuoted purchaseQuoted = new PurchaseQuoted();
|
PurchaseQuoted purchaseQuoted = new PurchaseQuoted();
|
||||||
BeanUtil.copyProperties(purchaseQuotedVO, purchaseQuoted);
|
BeanUtil.copyProperties(purchaseQuotedVO, purchaseQuoted);
|
||||||
//添加报价单
|
//添加报价单
|
||||||
@ -42,6 +43,7 @@ public class PurchaseQuotedServiceImpl extends ServiceImpl<PurchaseQuotedMapper,
|
|||||||
public List<PurchaseQuoted> getByPurchaseOrderId(String purchaseOrderId) {
|
public List<PurchaseQuoted> getByPurchaseOrderId(String purchaseOrderId) {
|
||||||
LambdaQueryWrapper<PurchaseQuoted> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<PurchaseQuoted> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
lambdaQueryWrapper.eq(PurchaseQuoted::getPurchaseOrderId, purchaseOrderId);
|
lambdaQueryWrapper.eq(PurchaseQuoted::getPurchaseOrderId, purchaseOrderId);
|
||||||
|
lambdaQueryWrapper.orderByDesc(PurchaseQuoted::getCreateTime);
|
||||||
return this.list(lambdaQueryWrapper);
|
return this.list(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package cn.lili.controller.purchase;
|
package cn.lili.controller.other.purchase;
|
||||||
|
|
||||||
import cn.lili.common.enums.ResultUtil;
|
import cn.lili.common.enums.ResultUtil;
|
||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
Loading…
x
Reference in New Issue
Block a user