mirror of https://github.com/elunez/eladmin
新增产品采购单
parent
3d5ba8be3a
commit
74ddeb451e
|
@ -1,12 +1,29 @@
|
||||||
package me.zhengjie.modules.wms.purchase.repository;
|
package me.zhengjie.modules.wms.purchase.repository;
|
||||||
|
|
||||||
|
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceProcessSheetProduct;
|
||||||
import me.zhengjie.modules.wms.purchase.domain.ProductPurchaseOrderProduct;
|
import me.zhengjie.modules.wms.purchase.domain.ProductPurchaseOrderProduct;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author jie
|
||||||
* @date 2019-10-06
|
* @date 2019-10-06
|
||||||
*/
|
*/
|
||||||
public interface ProductPurchaseOrderProductRepository extends JpaRepository<ProductPurchaseOrderProduct, Long>, JpaSpecificationExecutor {
|
public interface ProductPurchaseOrderProductRepository extends JpaRepository<ProductPurchaseOrderProduct, Long>, JpaSpecificationExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指定产品采购单下所有的产品信息(状态为true)
|
||||||
|
* @param productPurchaseOrderId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Query(value ="select * from product_purchase_order_product where product_purchase_order_id = ?1 and status =1", nativeQuery = true)
|
||||||
|
List<ProductPurchaseOrderProduct> queryByProductPurchaseOrderIdAndStatusTrue(Long productPurchaseOrderId);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query(value = "delete product_purchase_order_product where product_code = ?1 and product_purchase_order_id = ?2", nativeQuery = true)
|
||||||
|
void deleteByProductCodeAndProductPurchaseOrderId(String productCode, Long productPurchaseOrderId);
|
||||||
}
|
}
|
|
@ -1,12 +1,22 @@
|
||||||
package me.zhengjie.modules.wms.purchase.repository;
|
package me.zhengjie.modules.wms.purchase.repository;
|
||||||
|
|
||||||
|
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceProcessSheet;
|
||||||
import me.zhengjie.modules.wms.purchase.domain.ProductPurchaseOrder;
|
import me.zhengjie.modules.wms.purchase.domain.ProductPurchaseOrder;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author jie
|
||||||
* @date 2019-10-06
|
* @date 2019-10-06
|
||||||
*/
|
*/
|
||||||
public interface ProductPurchaseOrderRepository extends JpaRepository<ProductPurchaseOrder, Long>, JpaSpecificationExecutor {
|
public interface ProductPurchaseOrderRepository extends JpaRepository<ProductPurchaseOrder, Long>, JpaSpecificationExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据产品采购单单据编号查询产品采购单单信息
|
||||||
|
* @param productPurchaseOrderCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Query(value ="select * from product_purchase_order where product_purchase_order_code = ?1 and status = 1", nativeQuery = true)
|
||||||
|
ProductPurchaseOrder findByProductPurchaseOrderCode(String productPurchaseOrderCode);
|
||||||
}
|
}
|
|
@ -29,13 +29,22 @@ public class ConsumablesPurchaseOrderController {
|
||||||
private ConsumablesPurchaseOrderService consumablesPurchaseOrderService;
|
private ConsumablesPurchaseOrderService consumablesPurchaseOrderService;
|
||||||
|
|
||||||
@Log("分页查询耗材采购单")
|
@Log("分页查询耗材采购单")
|
||||||
@ApiOperation(value = "查询ConsumablesPurchaseOrder")
|
@ApiOperation(value = "分页查询耗材采购单")
|
||||||
@GetMapping(value = "/consumablesPurchaseOrder")
|
@GetMapping(value = "/queryConsumablesPurchaseOrderPageList")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','CONSUMABLESPURCHASEORDER_ALL','CONSUMABLESPURCHASEORDER_SELECT')")
|
@PreAuthorize("hasAnyRole('ADMIN','CONSUMABLESPURCHASEORDER_ALL','CONSUMABLESPURCHASEORDER_SELECT')")
|
||||||
public ResponseEntity getConsumablesPurchaseOrders(ConsumablesPurchaseOrderQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity queryConsumablesPurchaseOrderPageList(ConsumablesPurchaseOrderQueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity(consumablesPurchaseOrderService.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity(consumablesPurchaseOrderService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Log("查询耗材采购单列表")
|
||||||
|
@ApiOperation(value = "查询耗材采购单列表")
|
||||||
|
@GetMapping(value = "/queryConsumablesPurchaseOrderList")
|
||||||
|
@PreAuthorize("hasAnyRole('ADMIN','CONSUMABLESPURCHASEORDER_ALL','CONSUMABLESPURCHASEORDER_SELECT')")
|
||||||
|
public ResponseEntity queryConsumablesPurchaseOrderList(ConsumablesPurchaseOrderQueryCriteria criteria){
|
||||||
|
return new ResponseEntity(consumablesPurchaseOrderService.queryAll(criteria),HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@Log("新增耗材采购单")
|
@Log("新增耗材采购单")
|
||||||
@ApiOperation(value = "新增耗材采购单")
|
@ApiOperation(value = "新增耗材采购单")
|
||||||
@PostMapping(value = "/consumablesPurchaseOrder")
|
@PostMapping(value = "/consumablesPurchaseOrder")
|
||||||
|
|
|
@ -1,14 +1,26 @@
|
||||||
package me.zhengjie.modules.wms.purchase.service.impl;
|
package me.zhengjie.modules.wms.purchase.service.impl;
|
||||||
|
|
||||||
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
|
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
|
||||||
|
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceProcessSheet;
|
||||||
|
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceProcessSheetProduct;
|
||||||
|
import me.zhengjie.modules.wms.outSourceProductSheet.request.OutSourceProcessSheetProductRequest;
|
||||||
|
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceProcessSheetDTO;
|
||||||
|
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceProcessSheetProductDTO;
|
||||||
import me.zhengjie.modules.wms.purchase.domain.ProductPurchaseOrder;
|
import me.zhengjie.modules.wms.purchase.domain.ProductPurchaseOrder;
|
||||||
|
import me.zhengjie.modules.wms.purchase.domain.ProductPurchaseOrderProduct;
|
||||||
|
import me.zhengjie.modules.wms.purchase.repository.ProductPurchaseOrderProductRepository;
|
||||||
import me.zhengjie.modules.wms.purchase.request.CreateProductPurchaseOrderRequest;
|
import me.zhengjie.modules.wms.purchase.request.CreateProductPurchaseOrderRequest;
|
||||||
|
import me.zhengjie.modules.wms.purchase.request.ProductPurchaseOrderProductRequest;
|
||||||
|
import me.zhengjie.modules.wms.purchase.service.dto.ProductPurchaseOrderProductDTO;
|
||||||
|
import me.zhengjie.modules.wms.purchase.service.mapper.ProductPurchaseOrderProductMapper;
|
||||||
import me.zhengjie.utils.ValidationUtil;
|
import me.zhengjie.utils.ValidationUtil;
|
||||||
import me.zhengjie.modules.wms.purchase.repository.ProductPurchaseOrderRepository;
|
import me.zhengjie.modules.wms.purchase.repository.ProductPurchaseOrderRepository;
|
||||||
import me.zhengjie.modules.wms.purchase.service.ProductPurchaseOrderService;
|
import me.zhengjie.modules.wms.purchase.service.ProductPurchaseOrderService;
|
||||||
import me.zhengjie.modules.wms.purchase.service.dto.ProductPurchaseOrderDTO;
|
import me.zhengjie.modules.wms.purchase.service.dto.ProductPurchaseOrderDTO;
|
||||||
import me.zhengjie.modules.wms.purchase.service.dto.ProductPurchaseOrderQueryCriteria;
|
import me.zhengjie.modules.wms.purchase.service.dto.ProductPurchaseOrderQueryCriteria;
|
||||||
import me.zhengjie.modules.wms.purchase.service.mapper.ProductPurchaseOrderMapper;
|
import me.zhengjie.modules.wms.purchase.service.mapper.ProductPurchaseOrderMapper;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -23,6 +35,7 @@ import org.springframework.data.domain.Pageable;
|
||||||
import me.zhengjie.utils.PageUtil;
|
import me.zhengjie.utils.PageUtil;
|
||||||
import me.zhengjie.utils.QueryHelp;
|
import me.zhengjie.utils.QueryHelp;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
@ -43,6 +56,12 @@ public class ProductPurchaseOrderServiceImpl implements ProductPurchaseOrderServ
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductPurchaseOrderMapper productPurchaseOrderMapper;
|
private ProductPurchaseOrderMapper productPurchaseOrderMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProductPurchaseOrderProductRepository productPurchaseOrderProductRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProductPurchaseOrderProductMapper productPurchaseOrderProductMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(ProductPurchaseOrderQueryCriteria criteria, Pageable pageable){
|
public Object queryAll(ProductPurchaseOrderQueryCriteria criteria, Pageable pageable){
|
||||||
Specification<ProductPurchaseOrder> specification = new Specification<ProductPurchaseOrder>() {
|
Specification<ProductPurchaseOrder> specification = new Specification<ProductPurchaseOrder>() {
|
||||||
|
@ -101,8 +120,49 @@ public class ProductPurchaseOrderServiceImpl implements ProductPurchaseOrderServ
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ProductPurchaseOrderDTO create(CreateProductPurchaseOrderRequest createProductPurchaseOrderRequest) {
|
public ProductPurchaseOrderDTO create(CreateProductPurchaseOrderRequest createProductPurchaseOrderRequest) {
|
||||||
|
ProductPurchaseOrder productPurchaseOrder = new ProductPurchaseOrder();
|
||||||
|
BeanUtils.copyProperties(createProductPurchaseOrderRequest, productPurchaseOrder);
|
||||||
|
|
||||||
return null;
|
String productPurchaseOrderCode = productPurchaseOrder.getProductPurchaseOrderCode();
|
||||||
|
if(!StringUtils.hasLength(productPurchaseOrderCode)){
|
||||||
|
throw new BadRequestException("产品采购单单据编号不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
productPurchaseOrder.setStatus(true);
|
||||||
|
// 新增产品采购单
|
||||||
|
productPurchaseOrderRepository.save(productPurchaseOrder);
|
||||||
|
|
||||||
|
productPurchaseOrder = productPurchaseOrderRepository.findByProductPurchaseOrderCode(productPurchaseOrder.getProductPurchaseOrderCode());
|
||||||
|
|
||||||
|
// 新增产品采购单产品信息
|
||||||
|
List<ProductPurchaseOrderProductRequest> productPurchaseOrderProductRequestRequestList = createProductPurchaseOrderRequest.getProductPurchaseOrderProductList();
|
||||||
|
if(CollectionUtils.isEmpty(productPurchaseOrderProductRequestRequestList)){
|
||||||
|
throw new BadRequestException("产品采购单产品信息不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
for(ProductPurchaseOrderProductRequest productPurchaseOrderProductRequest : productPurchaseOrderProductRequestRequestList){
|
||||||
|
ProductPurchaseOrderProduct productPurchaseOrderProduct = new ProductPurchaseOrderProduct();
|
||||||
|
BeanUtils.copyProperties(productPurchaseOrderProductRequest, productPurchaseOrderProduct);
|
||||||
|
productPurchaseOrderProduct.setStatus(true);
|
||||||
|
productPurchaseOrderProduct.setProductPurchaseOrderId(productPurchaseOrder.getId());
|
||||||
|
productPurchaseOrderProductRepository.save(productPurchaseOrderProduct);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ProductPurchaseOrderDTO productPurchaseOrderDTO = productPurchaseOrderMapper.toDto(productPurchaseOrder);
|
||||||
|
|
||||||
|
List<ProductPurchaseOrderProduct> productPurchaseOrderProductList = productPurchaseOrderProductRepository.queryByProductPurchaseOrderIdAndStatusTrue(productPurchaseOrder.getId());
|
||||||
|
if(!CollectionUtils.isEmpty(productPurchaseOrderProductList)){
|
||||||
|
List<ProductPurchaseOrderProductDTO> productPurchaseOrderProductDTOList = new ArrayList<>();
|
||||||
|
for(ProductPurchaseOrderProduct productPurchaseOrderProduct : productPurchaseOrderProductList){
|
||||||
|
ProductPurchaseOrderProductDTO productPurchaseOrderProductDTO = new ProductPurchaseOrderProductDTO();
|
||||||
|
BeanUtils.copyProperties(productPurchaseOrderProduct, productPurchaseOrderProductDTO);
|
||||||
|
productPurchaseOrderProductDTOList.add(productPurchaseOrderProductDTO);
|
||||||
|
}
|
||||||
|
productPurchaseOrderDTO.setProductPurchaseOrderProductList(productPurchaseOrderProductDTOList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return productPurchaseOrderDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue