mirror of https://github.com/elunez/eladmin
客户订单状态
parent
dc8ca410e9
commit
4302930fce
|
@ -113,6 +113,10 @@ public class CustomerOrder implements Serializable {
|
||||||
@Column(name = "complete_status")
|
@Column(name = "complete_status")
|
||||||
private Boolean completeStatus;
|
private Boolean completeStatus;
|
||||||
|
|
||||||
|
// 订单进展状态
|
||||||
|
@Column(name = "proc_status")
|
||||||
|
private String procStatus;
|
||||||
|
|
||||||
public void copy(CustomerOrder source){
|
public void copy(CustomerOrder source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,10 @@ public class CustomerOrderProduct implements Serializable {
|
||||||
@Column(name = "customer_order_id")
|
@Column(name = "customer_order_id")
|
||||||
private Long customerOrderId;
|
private Long customerOrderId;
|
||||||
|
|
||||||
|
// 所属客户订单
|
||||||
|
@Column(name = "customer_order_code")
|
||||||
|
private Long customerOrderCode;
|
||||||
|
|
||||||
// 产品主键
|
// 产品主键
|
||||||
@Column(name = "product_id")
|
@Column(name = "product_id")
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
|
@ -14,8 +14,20 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface CustomerOrderProductRepository extends JpaRepository<CustomerOrderProduct, Long>, JpaSpecificationExecutor {
|
public interface CustomerOrderProductRepository extends JpaRepository<CustomerOrderProduct, Long>, JpaSpecificationExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据客户订单id查看客户订单对应的所有产品
|
||||||
|
* @param customerOrderId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
List<CustomerOrderProduct> findByCustomerOrderIdAndStatusTrue(Long customerOrderId);
|
List<CustomerOrderProduct> findByCustomerOrderIdAndStatusTrue(Long customerOrderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据客户订单编号查询客户订单对应的所有产品信息
|
||||||
|
* @param customerOrderCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CustomerOrderProduct> findByCustomerOrderCodeAndStatusTrue(String customerOrderCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据产品code以及客户订单id删除订单中对应的产品信息
|
* 根据产品code以及客户订单id删除订单中对应的产品信息
|
||||||
* @param productCode
|
* @param productCode
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package me.zhengjie.modules.wms.customerOrder.repository;
|
package me.zhengjie.modules.wms.customerOrder.repository;
|
||||||
|
|
||||||
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrder;
|
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrder;
|
||||||
|
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct;
|
||||||
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.Modifying;
|
||||||
|
@ -29,4 +30,15 @@ public interface CustomerOrderRepository extends JpaRepository<CustomerOrder, Lo
|
||||||
*/
|
*/
|
||||||
@Query(value = "select * from s_customer_order where customer_order_code = ?1 and status = 1", nativeQuery = true)
|
@Query(value = "select * from s_customer_order where customer_order_code = ?1 and status = 1", nativeQuery = true)
|
||||||
CustomerOrder findByCustomerOrderCodeAndStatusTrue(String customerOrderCode);
|
CustomerOrder findByCustomerOrderCodeAndStatusTrue(String customerOrderCode);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新客户订单状态
|
||||||
|
* @param procStatus
|
||||||
|
*/
|
||||||
|
@Modifying
|
||||||
|
@Query(value = "update s_customer_order set proc_status = 0 where id = ?1", nativeQuery = true)
|
||||||
|
void updateProcStatus(String procStatus);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,9 @@ public class CustomerOrderDTO implements Serializable {
|
||||||
// 订单产品
|
// 订单产品
|
||||||
private List<CustomerOrderProductDTO> customerOrderProductList;
|
private List<CustomerOrderProductDTO> customerOrderProductList;
|
||||||
|
|
||||||
|
// 订单紧张状态
|
||||||
|
private String procStatus;
|
||||||
|
|
||||||
public void copy(CustomerOrderDTO source){
|
public void copy(CustomerOrderDTO source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
|
||||||
}
|
}
|
||||||
|
|
||||||
customerOrder.setTotalMoney(totalMoney);
|
customerOrder.setTotalMoney(totalMoney);
|
||||||
|
customerOrder.setCompleteStatus(false);
|
||||||
|
// 录入订单的时候是等待发货
|
||||||
|
customerOrder.setProcStatus(ProcStatusEnum.WAIT_SEND_GOOD.getCode());
|
||||||
customerOrderRepository.save(customerOrder);
|
customerOrderRepository.save(customerOrder);
|
||||||
customerOrderProductRepository.saveAll(customerOrderProductList);
|
customerOrderProductRepository.saveAll(customerOrderProductList);
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,9 @@ public class Invoice implements Serializable {
|
||||||
@Column(name = "customer_name")
|
@Column(name = "customer_name")
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
|
@Column(name = "pi_ci")
|
||||||
|
private String pici;
|
||||||
|
|
||||||
public void copy(Invoice source){
|
public void copy(Invoice source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,10 @@ public class InvoiceProduct implements Serializable {
|
||||||
@Column(name = "invoice_id")
|
@Column(name = "invoice_id")
|
||||||
private Long invoiceId;
|
private Long invoiceId;
|
||||||
|
|
||||||
|
// 客户订单编号
|
||||||
|
@Column(name = "customer_order_code")
|
||||||
|
private String customerOrderCode;
|
||||||
|
|
||||||
public void copy(InvoiceProduct source){
|
public void copy(InvoiceProduct source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,21 @@ public interface InvoiceProductRepository extends JpaRepository<InvoiceProduct,
|
||||||
|
|
||||||
List<InvoiceProduct> findByInvoiceIdAndStatusTrue(Long invoiceId);
|
List<InvoiceProduct> findByInvoiceIdAndStatusTrue(Long invoiceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据销售发货单编号编号查询所有产品
|
||||||
|
* @param invoicCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<InvoiceProduct> findByInvoiceCodeAndStatusTrue(String invoicCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据客户订单编号查询所有销售发货单对应的产品
|
||||||
|
* @param customerOrderCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<InvoiceProduct> findByCustomerOrderCodeAndStatusTrue(String customerOrderCode);
|
||||||
|
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query(value = "update s_invoice_product set status = 0 where invoice_id = ?1", nativeQuery = true)
|
@Query(value = "update s_invoice_product set status = 0 where invoice_id = ?1", nativeQuery = true)
|
||||||
void deleteInvoiceProduct(long invoiceId);
|
void deleteInvoiceProduct(long invoiceId);
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package me.zhengjie.modules.wms.invoice.repository;
|
package me.zhengjie.modules.wms.invoice.repository;
|
||||||
|
|
||||||
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
||||||
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDetailDTO;
|
||||||
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.Modifying;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author jie
|
||||||
* @date 2019-08-27
|
* @date 2019-08-27
|
||||||
|
@ -14,6 +17,13 @@ public interface InvoiceRepository extends JpaRepository<Invoice, Long>, JpaSpec
|
||||||
|
|
||||||
Invoice findBySaleInvoiceCode(String saleInvoiceCode);
|
Invoice findBySaleInvoiceCode(String saleInvoiceCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据客户订单编号查看客户订单
|
||||||
|
* @param customerOrderCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Invoice> findByCustomerOrderCodeAndStatusTrue(String customerOrderCode);
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query(value = "update s_invoice set status = 0 where id = ?1", nativeQuery = true)
|
@Query(value = "update s_invoice set status = 0 where id = ?1", nativeQuery = true)
|
||||||
void deleteInvoice(long invoiceId);
|
void deleteInvoice(long invoiceId);
|
||||||
|
|
|
@ -38,6 +38,9 @@ public class InvoiceProductDTO implements Serializable {
|
||||||
// 订单数量
|
// 订单数量
|
||||||
private Long customerOrderNumber;
|
private Long customerOrderNumber;
|
||||||
|
|
||||||
|
// 备注:为了前端方便,特意加上这个字段,因为客户订单里面的产品数量用的这个,销售发货单里面改了字段名字叫customerOrderNumber 所以 customerOrderNumber = productNumber
|
||||||
|
private Long productNumber;
|
||||||
|
|
||||||
// 实际发货单数量
|
// 实际发货单数量
|
||||||
private Long actualInvoiceNumber;
|
private Long actualInvoiceNumber;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package me.zhengjie.modules.wms.invoice.service.impl;
|
package me.zhengjie.modules.wms.invoice.service.impl;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.system.cons.MessageModulePath;
|
import me.zhengjie.modules.system.cons.MessageModulePath;
|
||||||
|
@ -18,6 +19,8 @@ import me.zhengjie.modules.wms.bd.repository.CustomerInfoRepository;
|
||||||
import me.zhengjie.modules.wms.bd.repository.ProductInfoRepository;
|
import me.zhengjie.modules.wms.bd.repository.ProductInfoRepository;
|
||||||
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrder;
|
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrder;
|
||||||
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct;
|
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct;
|
||||||
|
import me.zhengjie.modules.wms.customerOrder.repository.CustomerOrderProductRepository;
|
||||||
|
import me.zhengjie.modules.wms.customerOrder.repository.CustomerOrderRepository;
|
||||||
import me.zhengjie.modules.wms.customerOrder.request.CustomerOrderProductRequest;
|
import me.zhengjie.modules.wms.customerOrder.request.CustomerOrderProductRequest;
|
||||||
import me.zhengjie.modules.wms.customerOrder.service.dto.CustomerOrderDTO;
|
import me.zhengjie.modules.wms.customerOrder.service.dto.CustomerOrderDTO;
|
||||||
import me.zhengjie.modules.wms.customerOrder.service.dto.CustomerOrderProductDTO;
|
import me.zhengjie.modules.wms.customerOrder.service.dto.CustomerOrderProductDTO;
|
||||||
|
@ -29,8 +32,7 @@ import me.zhengjie.modules.wms.invoice.request.UpdateInvoiceRequest;
|
||||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDetailDTO;
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDetailDTO;
|
||||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductDTO;
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductDTO;
|
||||||
import me.zhengjie.modules.wms.invoice.service.mapper.InvoiceProductMapper;
|
import me.zhengjie.modules.wms.invoice.service.mapper.InvoiceProductMapper;
|
||||||
import me.zhengjie.utils.SecurityUtils;
|
import me.zhengjie.utils.*;
|
||||||
import me.zhengjie.utils.ValidationUtil;
|
|
||||||
import me.zhengjie.modules.wms.invoice.repository.InvoiceRepository;
|
import me.zhengjie.modules.wms.invoice.repository.InvoiceRepository;
|
||||||
import me.zhengjie.modules.wms.invoice.service.InvoiceService;
|
import me.zhengjie.modules.wms.invoice.service.InvoiceService;
|
||||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDTO;
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDTO;
|
||||||
|
@ -48,11 +50,10 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.LongStream;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import me.zhengjie.utils.PageUtil;
|
|
||||||
import me.zhengjie.utils.QueryHelp;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
@ -79,6 +80,12 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CustomerInfoRepository customerInfoRepository;
|
private CustomerInfoRepository customerInfoRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomerOrderRepository customerOrderRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomerOrderProductRepository customerOrderProductRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private InvoiceProductMapper invoiceProductMapper;
|
private InvoiceProductMapper invoiceProductMapper;
|
||||||
|
|
||||||
|
@ -166,6 +173,9 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||||
List<InvoiceProduct> invoiceProductList = invoiceProductRepository.findByInvoiceIdAndStatusTrue(id);
|
List<InvoiceProduct> invoiceProductList = invoiceProductRepository.findByInvoiceIdAndStatusTrue(id);
|
||||||
if(!CollectionUtils.isEmpty(invoiceProductList)){
|
if(!CollectionUtils.isEmpty(invoiceProductList)){
|
||||||
List<InvoiceProductDTO> invoiceProductDTOList = invoiceProductMapper.toDto(invoiceProductList);
|
List<InvoiceProductDTO> invoiceProductDTOList = invoiceProductMapper.toDto(invoiceProductList);
|
||||||
|
for(InvoiceProductDTO invoiceProductDTO : invoiceProductDTOList){
|
||||||
|
invoiceProductDTO.setProductNumber(invoiceProductDTO.getCustomerOrderNumber());
|
||||||
|
}
|
||||||
invoiceDetailDTO.setInvoiceProductDTOList(invoiceProductDTOList);
|
invoiceDetailDTO.setInvoiceProductDTOList(invoiceProductDTOList);
|
||||||
}
|
}
|
||||||
return invoiceDetailDTO;
|
return invoiceDetailDTO;
|
||||||
|
@ -257,6 +267,7 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||||
|
|
||||||
BeanUtils.copyProperties(createInvoiceRequest, invoice);
|
BeanUtils.copyProperties(createInvoiceRequest, invoice);
|
||||||
invoice.setStatus(true);
|
invoice.setStatus(true);
|
||||||
|
invoice.setPici(PiciUtil.initPici(customerOrderCode));
|
||||||
invoiceRepository.save(invoice);
|
invoiceRepository.save(invoice);
|
||||||
invoice = invoiceRepository.findBySaleInvoiceCode(saleInvoiceCode);
|
invoice = invoiceRepository.findBySaleInvoiceCode(saleInvoiceCode);
|
||||||
InvoiceDTO invoiceDTO = invoiceMapper.toDto(invoice);
|
InvoiceDTO invoiceDTO = invoiceMapper.toDto(invoice);
|
||||||
|
@ -272,17 +283,30 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||||
if(null == productInfo){
|
if(null == productInfo){
|
||||||
throw new BadRequestException("产品编号" + productInfo.getProductCode() + "对应的产品不存在!");
|
throw new BadRequestException("产品编号" + productInfo.getProductCode() + "对应的产品不存在!");
|
||||||
}
|
}
|
||||||
|
invoiceProduct.setCustomerOrderCode(customerOrderCode);
|
||||||
invoiceProduct.setProductId(productInfo.getId());
|
invoiceProduct.setProductId(productInfo.getId());
|
||||||
invoiceProductRepository.save(invoiceProduct);
|
invoiceProductRepository.save(invoiceProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<InvoiceProduct> invoiceProductList = invoiceProductRepository.findByInvoiceIdAndStatusTrue(invoice.getId());
|
List<InvoiceProduct> invoiceProductList = invoiceProductRepository.findByInvoiceIdAndStatusTrue(invoice.getId());
|
||||||
List<InvoiceProductDTO> invoiceProductDTOList = invoiceProductMapper.toDto(invoiceProductList);
|
List<InvoiceProductDTO> invoiceProductDTOList = invoiceProductMapper.toDto(invoiceProductList);
|
||||||
|
for(InvoiceProductDTO invoiceProductDTO : invoiceProductDTOList){
|
||||||
|
invoiceProductDTO.setProductNumber(invoiceProductDTO.getCustomerOrderNumber());
|
||||||
|
}
|
||||||
|
|
||||||
InvoiceDetailDTO invoiceDetailDTO = new InvoiceDetailDTO();
|
InvoiceDetailDTO invoiceDetailDTO = new InvoiceDetailDTO();
|
||||||
BeanUtils.copyProperties(invoiceDTO, invoiceDetailDTO);
|
BeanUtils.copyProperties(invoiceDTO, invoiceDetailDTO);
|
||||||
invoiceDetailDTO.setInvoiceProductDTOList(invoiceProductDTOList);
|
invoiceDetailDTO.setInvoiceProductDTOList(invoiceProductDTOList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断客户订单是否完成
|
||||||
|
* 查看客户订单所有的商品以及数量
|
||||||
|
* 查看该订单的所有发货单数量,
|
||||||
|
* 比较是否完成
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增消息通知
|
* 新增消息通知
|
||||||
*/
|
*/
|
||||||
|
@ -309,6 +333,47 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||||
}
|
}
|
||||||
messageRepository.saveAll(messageList);
|
messageRepository.saveAll(messageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查看发货单的数量是否根订单数量一致,如果一致则订单已发货,如果
|
||||||
|
Map<String, Long> existProduct = new HashMap<>();
|
||||||
|
List<InvoiceProduct> existProductList = invoiceProductRepository.findByCustomerOrderCodeAndStatusTrue(customerOrderCode);
|
||||||
|
if(!CollectionUtils.isEmpty(existProductList)){
|
||||||
|
Map<String, List<InvoiceProduct>> existProductMap = existProductList.stream().collect(Collectors.groupingBy(InvoiceProduct::getProductCode));
|
||||||
|
for(Map.Entry<String, List<InvoiceProduct>> entry : existProductMap.entrySet()){
|
||||||
|
String productCode = entry.getKey();
|
||||||
|
List<InvoiceProduct> invoiceProductListTemp = entry.getValue();
|
||||||
|
if(!CollectionUtils.isEmpty(invoiceProductListTemp)){
|
||||||
|
Long productNumberTotal = invoiceProductListTemp.stream().mapToLong(InvoiceProduct::getActualInvoiceNumber).sum();
|
||||||
|
existProduct.put(productCode, productNumberTotal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, Long> sourceProduct = new HashMap<>();
|
||||||
|
List<CustomerOrderProduct> sourceProductList = customerOrderProductRepository.findByCustomerOrderCodeAndStatusTrue(customerOrderCode);
|
||||||
|
if(!CollectionUtils.isEmpty(sourceProductList)){
|
||||||
|
Map<String, List<CustomerOrderProduct>> sourceProductMap = sourceProductList.stream().collect(Collectors.groupingBy(CustomerOrderProduct::getProductCode));
|
||||||
|
for(Map.Entry<String, List<CustomerOrderProduct>> entry : sourceProductMap.entrySet()){
|
||||||
|
String productCode = entry.getKey();
|
||||||
|
List<CustomerOrderProduct> customerOrderProductListTemp = entry.getValue();
|
||||||
|
if(!CollectionUtils.isEmpty(customerOrderProductListTemp)){
|
||||||
|
Long productNumberTotal = customerOrderProductListTemp.stream().mapToLong(CustomerOrderProduct::getProductNumber).sum();
|
||||||
|
sourceProduct.put(productCode, productNumberTotal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!CollectionUtils.isEmpty(sourceProduct)){
|
||||||
|
for(Map.Entry<String, Long> entry : sourceProduct.entrySet()){
|
||||||
|
String productCodeTemp = entry.getKey();
|
||||||
|
long productNumberTemp = entry.getValue();
|
||||||
|
long productNumberTempExist = existProduct.get(productCodeTemp);
|
||||||
|
if(productNumberTemp == productNumberTempExist || productNumberTemp > productNumberTempExist){
|
||||||
|
customerOrderRepository.updateProcStatus(ProcStatusEnum.COMPLETED.getCode());
|
||||||
|
}else{
|
||||||
|
customerOrderRepository.updateProcStatus(ProcStatusEnum.SENDING_GOOD.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("单据编号:插入消息失败!");
|
log.error("单据编号:插入消息失败!");
|
||||||
}
|
}
|
||||||
|
@ -403,4 +468,64 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||||
invoiceRepository.deleteInvoice(id);
|
invoiceRepository.deleteInvoice(id);
|
||||||
invoiceProductRepository.deleteInvoiceProduct(id);
|
invoiceProductRepository.deleteInvoiceProduct(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理当前客户订单的完成状态
|
||||||
|
* @param customerOrderCode
|
||||||
|
*/
|
||||||
|
public void dealCustomerOrderCompleteStatus(String customerOrderCode){
|
||||||
|
if(!StringUtils.isEmpty(customerOrderCode)){
|
||||||
|
List<CustomerOrderProduct> customerOrderProductList = customerOrderProductRepository.findByCustomerOrderCodeAndStatusTrue(customerOrderCode);
|
||||||
|
if(!CollectionUtils.isEmpty(customerOrderProductList)){
|
||||||
|
Map<String, CustomerOrderProduct> customerOrderProductMap = customerOrderProductList.stream().collect(Collectors.toMap(CustomerOrderProduct::getProductCode, a -> a, (k1, k2) -> k1));
|
||||||
|
|
||||||
|
// 查看客户订单对应销售发货单所有产品
|
||||||
|
List<InvoiceProduct> invoiceProductList = invoiceProductRepository.findByCustomerOrderCodeAndStatusTrue(customerOrderCode);
|
||||||
|
if(!CollectionUtils.isEmpty(invoiceProductList)){
|
||||||
|
// 销售发货单产品集合,key为产品,value为产品集合
|
||||||
|
// Map<String, List<InvoiceProduct>> invoiceProductMap = invoiceProductList.stream().collect(Collectors.groupingBy(InvoiceProduct::getProductCode));
|
||||||
|
Map<String,Integer> existProductNumnerMap = new HashMap<>();
|
||||||
|
// invoiceProductList.forEach(invoiceProduct -> existProductNumnerMap.computeIfPresent(invoiceProduct.getCustomerOrderCode(), invoiceProduct.getCustomerOrderNumber()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<InvoiceProduct> invoiceProductList = new ArrayList<>();
|
||||||
|
|
||||||
|
InvoiceProduct invoiceProduct = new InvoiceProduct();
|
||||||
|
invoiceProduct.setProductCode("01001");
|
||||||
|
invoiceProduct.setCustomerOrderNumber(10L);
|
||||||
|
invoiceProductList.add(invoiceProduct);
|
||||||
|
|
||||||
|
|
||||||
|
InvoiceProduct invoiceProduct2 = new InvoiceProduct();
|
||||||
|
invoiceProduct2.setProductCode("01001");
|
||||||
|
invoiceProduct2.setCustomerOrderNumber(10L);
|
||||||
|
invoiceProductList.add(invoiceProduct2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, Long> targetMap = new HashMap<>();
|
||||||
|
|
||||||
|
invoiceProductList.forEach(item->{
|
||||||
|
System.out.println(item.getProductCode() + ":" + item.getCustomerOrderNumber());
|
||||||
|
|
||||||
|
Long tempNum = targetMap.computeIfAbsent(item.getProductCode(), (k) ->{
|
||||||
|
Long tempNumber = null == targetMap.get(k)?0L:targetMap.get(k);
|
||||||
|
tempNumber += item.getCustomerOrderNumber();
|
||||||
|
return tempNumber;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
targetMap.put(item.getProductCode(), tempNum);
|
||||||
|
System.out.println(tempNum);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(new Gson().toJson(targetMap));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package me.zhengjie.utils;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 黄星星
|
||||||
|
* @date 2020-03-27
|
||||||
|
*/
|
||||||
|
public class DateUtil {
|
||||||
|
public static String format_yyyyMMddHHmmss = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
|
public static String parseToStr(Date date, String format){
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||||
|
return sdf.format(date);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.zhengjie.utils;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 黄星星
|
||||||
|
* @date 2020-03-27
|
||||||
|
*/
|
||||||
|
public class PiciUtil {
|
||||||
|
|
||||||
|
public static String initPici(String code){
|
||||||
|
return code + "_" + DateUtil.parseToStr(new Date(), DateUtil.format_yyyyMMddHHmmss);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package me.zhengjie.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 黄星星
|
||||||
|
* @date 2020-05-05
|
||||||
|
*/
|
||||||
|
public enum ProcStatusEnum {
|
||||||
|
WAIT_SEND_GOOD("等待发货", "WAIT_SEND_GOOD"),
|
||||||
|
SENDING_GOOD("发货中", "SENDING_GOOD"),
|
||||||
|
COMPLETED("已完结", "COMPLETED"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
ProcStatusEnum(String name, String code) {
|
||||||
|
this.name = name;
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue