mirror of https://github.com/elunez/eladmin
客户订单分页查询
parent
6f46a259f4
commit
e66523c346
|
@ -19,6 +19,10 @@ public interface ProductInfoRepository extends JpaRepository<ProductInfo, Long>,
|
||||||
*/
|
*/
|
||||||
ProductInfo findByIdAndStatusTrue(long id);
|
ProductInfo findByIdAndStatusTrue(long id);
|
||||||
|
|
||||||
|
|
||||||
|
ProductInfo findByProductCode(String productCode);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除产品资料
|
* 删除产品资料
|
||||||
* @param id
|
* @param id
|
||||||
|
|
|
@ -3,6 +3,8 @@ package me.zhengjie.modules.wms.customerOrder.domain;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import org.hibernate.annotations.CreationTimestamp;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -17,6 +19,7 @@ import java.io.Serializable;
|
||||||
public class CustomerOrderProduct implements Serializable {
|
public class CustomerOrderProduct implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id")
|
@Column(name = "id")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@ -54,10 +57,12 @@ public class CustomerOrderProduct implements Serializable {
|
||||||
|
|
||||||
// 创建时间
|
// 创建时间
|
||||||
@Column(name = "create_time")
|
@Column(name = "create_time")
|
||||||
|
@CreationTimestamp
|
||||||
private Timestamp createTime;
|
private Timestamp createTime;
|
||||||
|
|
||||||
// 更新时间
|
// 更新时间
|
||||||
@Column(name = "update_time")
|
@Column(name = "update_time")
|
||||||
|
@CreationTimestamp
|
||||||
private Timestamp updateTime;
|
private Timestamp updateTime;
|
||||||
|
|
||||||
// 状态
|
// 状态
|
||||||
|
|
|
@ -2,7 +2,11 @@ package me.zhengjie.modules.wms.customerOrder.service.impl;
|
||||||
|
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.wms.bd.domain.CustomerInfo;
|
import me.zhengjie.modules.wms.bd.domain.CustomerInfo;
|
||||||
|
import me.zhengjie.modules.wms.bd.domain.ProductInfo;
|
||||||
|
import me.zhengjie.modules.wms.bd.domain.SupplierInfo;
|
||||||
import me.zhengjie.modules.wms.bd.repository.CustomerInfoRepository;
|
import me.zhengjie.modules.wms.bd.repository.CustomerInfoRepository;
|
||||||
|
import me.zhengjie.modules.wms.bd.repository.ProductInfoRepository;
|
||||||
|
import me.zhengjie.modules.wms.bd.service.dto.SupplierInfoDTO;
|
||||||
import me.zhengjie.modules.wms.bd.service.mapper.CustomerInfoMapper;
|
import me.zhengjie.modules.wms.bd.service.mapper.CustomerInfoMapper;
|
||||||
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct;
|
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct;
|
||||||
import me.zhengjie.modules.wms.customerOrder.repository.CustomerOrderRepository;
|
import me.zhengjie.modules.wms.customerOrder.repository.CustomerOrderRepository;
|
||||||
|
@ -20,6 +24,7 @@ import me.zhengjie.modules.wms.customerOrder.service.mapper.CustomerOrderMapper;
|
||||||
import me.zhengjie.utils.ValidationUtil;
|
import me.zhengjie.utils.ValidationUtil;
|
||||||
import org.springframework.beans.BeanUtils;
|
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.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -37,6 +42,11 @@ 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 javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
import javax.persistence.criteria.Predicate;
|
||||||
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author jie
|
||||||
* @date 2019-08-03
|
* @date 2019-08-03
|
||||||
|
@ -63,10 +73,42 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CustomerInfoRepository customerInfoRepository;
|
private CustomerInfoRepository customerInfoRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProductInfoRepository productInfoRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(CustomerOrderQueryCriteria criteria, Pageable pageable){
|
public Object queryAll(CustomerOrderQueryCriteria criteria, Pageable pageable){
|
||||||
Page<CustomerOrder> page = customerOrderRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
|
||||||
return PageUtil.toPage(page.map(customerOrderMapper::toDto));
|
Specification<CustomerOrder> specification = new Specification<CustomerOrder>() {
|
||||||
|
@Override
|
||||||
|
public Predicate toPredicate(Root<CustomerOrder> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
||||||
|
|
||||||
|
List<Predicate> targetPredicateList = new ArrayList<>();
|
||||||
|
|
||||||
|
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
|
||||||
|
targetPredicateList.add(statusPredicate);
|
||||||
|
|
||||||
|
if(CollectionUtils.isEmpty(targetPredicateList)){
|
||||||
|
return null;
|
||||||
|
}else{
|
||||||
|
return criteriaBuilder.and(targetPredicateList.toArray(new Predicate[targetPredicateList.size()]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Page<CustomerOrder> page = customerOrderRepository.findAll(specification, pageable);
|
||||||
|
Page<CustomerOrderDTO> customerOrderDTOPage = page.map(customerOrderMapper::toDto);
|
||||||
|
if(null != customerOrderDTOPage){
|
||||||
|
List<CustomerOrderDTO> customerOrderDTOList = customerOrderDTOPage.getContent();
|
||||||
|
if(!CollectionUtils.isEmpty(customerOrderDTOList)){
|
||||||
|
for(CustomerOrderDTO customerOrderDTO : customerOrderDTOList){
|
||||||
|
List<CustomerOrderProduct> customerOrderProductList = customerOrderProductRepository.findByCustomerOrderIdAndStatusTrue(customerOrderDTO.getId());
|
||||||
|
List<CustomerOrderProductDTO> customerOrderProductDTOList = customerOrderProductMapper.toDto(customerOrderProductList);
|
||||||
|
customerOrderDTO.setCustomerOrderProductList(customerOrderProductDTOList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PageUtil.toPage(customerOrderDTOPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,6 +169,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
|
||||||
BeanUtils.copyProperties(customerOrderProductRequest, customerOrderProduct);
|
BeanUtils.copyProperties(customerOrderProductRequest, customerOrderProduct);
|
||||||
customerOrderProduct.setCustomerOrderId(customerOrder.getId());
|
customerOrderProduct.setCustomerOrderId(customerOrder.getId());
|
||||||
customerOrderProduct.setStatus(true);
|
customerOrderProduct.setStatus(true);
|
||||||
|
ProductInfo productInfo = productInfoRepository.findByProductCode(customerOrderProductRequest.getProductCode());
|
||||||
|
customerOrderProduct.setProductId(productInfo.getId());
|
||||||
|
customerOrderProductList.add(customerOrderProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
customerOrderProductRepository.saveAll(customerOrderProductList);
|
customerOrderProductRepository.saveAll(customerOrderProductList);
|
||||||
|
|
|
@ -3,6 +3,8 @@ package me.zhengjie.modules.wms.invoice.domain;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import org.hibernate.annotations.CreationTimestamp;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -23,10 +25,12 @@ public class InvoiceProduct implements Serializable {
|
||||||
|
|
||||||
// 创建时间
|
// 创建时间
|
||||||
@Column(name = "create_status")
|
@Column(name = "create_status")
|
||||||
|
@CreationTimestamp
|
||||||
private Timestamp createStatus;
|
private Timestamp createStatus;
|
||||||
|
|
||||||
// 更新时间
|
// 更新时间
|
||||||
@Column(name = "update_status")
|
@Column(name = "update_status")
|
||||||
|
@CreationTimestamp
|
||||||
private Timestamp updateStatus;
|
private Timestamp updateStatus;
|
||||||
|
|
||||||
// 状态
|
// 状态
|
||||||
|
@ -54,8 +58,8 @@ public class InvoiceProduct implements Serializable {
|
||||||
private Long customerOrderNumber;
|
private Long customerOrderNumber;
|
||||||
|
|
||||||
// 实际发货单数量
|
// 实际发货单数量
|
||||||
@Column(name = "acutal_invoice_number",nullable = false)
|
@Column(name = "actual_invoice_number",nullable = false)
|
||||||
private Long acutalInvoiceNumber;
|
private Long actualInvoiceNumber;
|
||||||
|
|
||||||
// 瘦瘦金额
|
// 瘦瘦金额
|
||||||
@Column(name = "sale_price")
|
@Column(name = "sale_price")
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class InvoiceProductDTO implements Serializable {
|
||||||
private Long customerOrderNumber;
|
private Long customerOrderNumber;
|
||||||
|
|
||||||
// 实际发货单数量
|
// 实际发货单数量
|
||||||
private Long acutalInvoiceNumber;
|
private Long actualInvoiceNumber;
|
||||||
|
|
||||||
// 瘦瘦金额
|
// 瘦瘦金额
|
||||||
private Long salePrice;
|
private Long salePrice;
|
||||||
|
|
|
@ -3,7 +3,7 @@ server:
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: prod
|
||||||
jackson:
|
jackson:
|
||||||
time-zone: GMT+8
|
time-zone: GMT+8
|
||||||
data:
|
data:
|
||||||
|
|
Loading…
Reference in New Issue