diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/repository/ProductInfoRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/repository/ProductInfoRepository.java index a50a0938..0046fc10 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/repository/ProductInfoRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/repository/ProductInfoRepository.java @@ -19,6 +19,10 @@ public interface ProductInfoRepository extends JpaRepository, */ ProductInfo findByIdAndStatusTrue(long id); + + ProductInfo findByProductCode(String productCode); + + /** * 删除产品资料 * @param id diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/customerOrder/domain/CustomerOrderProduct.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/customerOrder/domain/CustomerOrderProduct.java index 4a6788b8..7d0eb03a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/customerOrder/domain/CustomerOrderProduct.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/customerOrder/domain/CustomerOrderProduct.java @@ -3,6 +3,8 @@ package me.zhengjie.modules.wms.customerOrder.domain; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import org.hibernate.annotations.CreationTimestamp; + import javax.persistence.*; import java.sql.Timestamp; import java.io.Serializable; @@ -17,6 +19,7 @@ import java.io.Serializable; public class CustomerOrderProduct implements Serializable { @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Long id; @@ -54,10 +57,12 @@ public class CustomerOrderProduct implements Serializable { // 创建时间 @Column(name = "create_time") + @CreationTimestamp private Timestamp createTime; // 更新时间 @Column(name = "update_time") + @CreationTimestamp private Timestamp updateTime; // 状态 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/customerOrder/service/impl/CustomerOrderServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/customerOrder/service/impl/CustomerOrderServiceImpl.java index 01ade7ea..10be2738 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/customerOrder/service/impl/CustomerOrderServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/customerOrder/service/impl/CustomerOrderServiceImpl.java @@ -2,7 +2,11 @@ package me.zhengjie.modules.wms.customerOrder.service.impl; import me.zhengjie.exception.BadRequestException; 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.ProductInfoRepository; +import me.zhengjie.modules.wms.bd.service.dto.SupplierInfoDTO; import me.zhengjie.modules.wms.bd.service.mapper.CustomerInfoMapper; import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct; 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 org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -37,6 +42,11 @@ import me.zhengjie.utils.PageUtil; import me.zhengjie.utils.QueryHelp; 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 * @date 2019-08-03 @@ -63,10 +73,42 @@ public class CustomerOrderServiceImpl implements CustomerOrderService { @Autowired private CustomerInfoRepository customerInfoRepository; + @Autowired + private ProductInfoRepository productInfoRepository; + @Override public Object queryAll(CustomerOrderQueryCriteria criteria, Pageable pageable){ - Page page = customerOrderRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(customerOrderMapper::toDto)); + + Specification specification = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + + List 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 page = customerOrderRepository.findAll(specification, pageable); + Page customerOrderDTOPage = page.map(customerOrderMapper::toDto); + if(null != customerOrderDTOPage){ + List customerOrderDTOList = customerOrderDTOPage.getContent(); + if(!CollectionUtils.isEmpty(customerOrderDTOList)){ + for(CustomerOrderDTO customerOrderDTO : customerOrderDTOList){ + List customerOrderProductList = customerOrderProductRepository.findByCustomerOrderIdAndStatusTrue(customerOrderDTO.getId()); + List customerOrderProductDTOList = customerOrderProductMapper.toDto(customerOrderProductList); + customerOrderDTO.setCustomerOrderProductList(customerOrderProductDTOList); + } + } + } + + return PageUtil.toPage(customerOrderDTOPage); } @Override @@ -127,6 +169,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService { BeanUtils.copyProperties(customerOrderProductRequest, customerOrderProduct); customerOrderProduct.setCustomerOrderId(customerOrder.getId()); customerOrderProduct.setStatus(true); + ProductInfo productInfo = productInfoRepository.findByProductCode(customerOrderProductRequest.getProductCode()); + customerOrderProduct.setProductId(productInfo.getId()); + customerOrderProductList.add(customerOrderProduct); } customerOrderProductRepository.saveAll(customerOrderProductList); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/invoice/domain/InvoiceProduct.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/invoice/domain/InvoiceProduct.java index f809feb0..c3918905 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/invoice/domain/InvoiceProduct.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/invoice/domain/InvoiceProduct.java @@ -3,6 +3,8 @@ package me.zhengjie.modules.wms.invoice.domain; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import org.hibernate.annotations.CreationTimestamp; + import javax.persistence.*; import java.sql.Timestamp; import java.io.Serializable; @@ -23,10 +25,12 @@ public class InvoiceProduct implements Serializable { // 创建时间 @Column(name = "create_status") + @CreationTimestamp private Timestamp createStatus; // 更新时间 @Column(name = "update_status") + @CreationTimestamp private Timestamp updateStatus; // 状态 @@ -54,8 +58,8 @@ public class InvoiceProduct implements Serializable { private Long customerOrderNumber; // 实际发货单数量 - @Column(name = "acutal_invoice_number",nullable = false) - private Long acutalInvoiceNumber; + @Column(name = "actual_invoice_number",nullable = false) + private Long actualInvoiceNumber; // 瘦瘦金额 @Column(name = "sale_price") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/invoice/service/dto/InvoiceProductDTO.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/invoice/service/dto/InvoiceProductDTO.java index 22b11225..4f39d195 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/invoice/service/dto/InvoiceProductDTO.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/invoice/service/dto/InvoiceProductDTO.java @@ -39,7 +39,7 @@ public class InvoiceProductDTO implements Serializable { private Long customerOrderNumber; // 实际发货单数量 - private Long acutalInvoiceNumber; + private Long actualInvoiceNumber; // 瘦瘦金额 private Long salePrice; diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index 33e004d7..a52de8aa 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -3,7 +3,7 @@ server: spring: profiles: - active: dev + active: prod jackson: time-zone: GMT+8 data: