|
@@ -1,18 +1,34 @@
|
|
package org.jeecg.modules.purCode.service.impl;
|
|
package org.jeecg.modules.purCode.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
import org.jeecg.modules.purCode.entity.PurOrderProduct;
|
|
import org.jeecg.modules.purCode.entity.PurOrderProduct;
|
|
|
|
+import org.jeecg.modules.purCode.entity.PurQuotationSelectionProduct;
|
|
import org.jeecg.modules.purCode.mapper.PurOrderProductMapper;
|
|
import org.jeecg.modules.purCode.mapper.PurOrderProductMapper;
|
|
|
|
+import org.jeecg.modules.purCode.mapper.PurQuotationSelectionProductMapper;
|
|
import org.jeecg.modules.purCode.service.IPurOrderProductService;
|
|
import org.jeecg.modules.purCode.service.IPurOrderProductService;
|
|
import org.jeecg.modules.purCode.vo.PurOrderAlert;
|
|
import org.jeecg.modules.purCode.vo.PurOrderAlert;
|
|
|
|
+import org.jeecg.modules.saleCode.entity.SaleOrderProduct;
|
|
|
|
+import org.jeecg.modules.saleCode.entity.SaleQuotation;
|
|
|
|
+import org.jeecg.modules.saleCode.entity.SaleQuotationProduct;
|
|
|
|
+import org.jeecg.modules.saleCode.entity.SaleQuotationProductHis;
|
|
|
|
+import org.jeecg.modules.saleCode.mapper.*;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
+
|
|
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 javax.annotation.Resource;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @Description: 采购订单子表 - 产品明细
|
|
* @Description: 采购订单子表 - 产品明细
|
|
* @Author: jeecg-boot
|
|
* @Author: jeecg-boot
|
|
@@ -22,8 +38,20 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
@Service
|
|
@Service
|
|
public class PurOrderProductServiceImpl extends ServiceImpl<PurOrderProductMapper, PurOrderProduct> implements IPurOrderProductService {
|
|
public class PurOrderProductServiceImpl extends ServiceImpl<PurOrderProductMapper, PurOrderProduct> implements IPurOrderProductService {
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
|
+ @Resource
|
|
private PurOrderProductMapper purOrderProductMapper;
|
|
private PurOrderProductMapper purOrderProductMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private SaleOrderProductMapper saleOrderProductMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SaleQuotationMapper saleQuotationMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private SaleQuotationProductMapper saleQuotationProductMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private SaleQuotationProductHisMapper saleQuotationProductHisMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private PurQuotationSelectionProductMapper purQuotationSelectionProductMapper;
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<PurOrderProduct> selectByMainId(String mainId) {
|
|
public List<PurOrderProduct> selectByMainId(String mainId) {
|
|
@@ -35,4 +63,92 @@ public class PurOrderProductServiceImpl extends ServiceImpl<PurOrderProductMappe
|
|
return purOrderProductMapper.selectPurOrderDetailAlert(page,queryWrapper);
|
|
return purOrderProductMapper.selectPurOrderDetailAlert(page,queryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 通过主表id查询子表,带采购折扣前单价和折扣
|
|
|
|
+ * @param mainId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<PurOrderProduct> selectByMainWithOrgPrice(String mainId){
|
|
|
|
+ LambdaQueryWrapper<PurOrderProduct> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(PurOrderProduct::getHeadId, mainId);
|
|
|
|
+ List<PurOrderProduct> productList = list(queryWrapper);
|
|
|
|
+ if (productList.size() == 0){
|
|
|
|
+ return productList;
|
|
|
|
+ }
|
|
|
|
+ List<PurOrderProduct> refOrderList = productList.stream().filter(e-> oConvertUtils.getString(e.getSourceType()).indexOf("Con")==0).collect(Collectors.toList());
|
|
|
|
+ List<PurOrderProduct> refQuotationList = productList.stream().filter(e-> oConvertUtils.getString(e.getSourceType()).indexOf("Quo")==0).collect(Collectors.toList());
|
|
|
|
+ List<PurOrderProduct> unRefList = productList.stream().filter(e-> oConvertUtils.isEmpty(e.getSourceType())).collect(Collectors.toList());
|
|
|
|
+ // 未参照的,设置折扣未空,折前单价等于当前单价
|
|
|
|
+ for (PurOrderProduct unRef : unRefList) {
|
|
|
|
+ unRef.setDiscountText("");
|
|
|
|
+ unRef.setTaxPriceOriginal(unRef.getTaxPrice());
|
|
|
|
+ }
|
|
|
|
+ /** 参照订单的,查询订单,查询报价单,查询采购报价选定,设置折扣和折前单价 **/
|
|
|
|
+ // 查询销售订单
|
|
|
|
+ LambdaQueryWrapper<SaleOrderProduct> saleOrderProductQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ saleOrderProductQueryWrapper.in(SaleOrderProduct::getId, refOrderList.stream().map(PurOrderProduct::getSourceId).collect(Collectors.toList()));
|
|
|
|
+ List<SaleOrderProduct> saleOrderProductList = saleOrderProductMapper.selectList(saleOrderProductQueryWrapper);
|
|
|
|
+ // 查询销售报价单,当前使用表和历史表
|
|
|
|
+ LambdaQueryWrapper<SaleQuotationProduct> saleQuotationProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ saleQuotationProductLambdaQueryWrapper.in(SaleQuotationProduct::getId, saleOrderProductList.stream().map(SaleOrderProduct::getSourceId).collect(Collectors.toList()));
|
|
|
|
+ List<SaleQuotationProduct> saleQuotationProductList = saleQuotationProductMapper.selectList(saleQuotationProductLambdaQueryWrapper);
|
|
|
|
+ LambdaQueryWrapper<SaleQuotationProductHis> saleQuotationProductHisLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ saleQuotationProductHisLambdaQueryWrapper.in(SaleQuotationProductHis::getId, saleOrderProductList.stream().map(SaleOrderProduct::getSourceId).collect(Collectors.toList()));
|
|
|
|
+ List<SaleQuotationProductHis> saleQuotationProductHisList = saleQuotationProductHisMapper.selectList(saleQuotationProductHisLambdaQueryWrapper);
|
|
|
|
+ List<String> purQuotationSelectionIdList = Stream.concat(
|
|
|
|
+ saleQuotationProductHisList.stream().map(SaleQuotationProductHis::getSourceId),
|
|
|
|
+ saleQuotationProductList.stream().map(SaleQuotationProduct::getSourceId)
|
|
|
|
+ ).distinct().collect(Collectors.toList());
|
|
|
|
+ // 查询采购报价选定
|
|
|
|
+ LambdaQueryWrapper<PurQuotationSelectionProduct> purQuotationSelectionProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ purQuotationSelectionProductLambdaQueryWrapper.in(PurQuotationSelectionProduct::getId, purQuotationSelectionIdList);
|
|
|
|
+ List<PurQuotationSelectionProduct> purQuotationSelectionProductList = purQuotationSelectionProductMapper.selectList(purQuotationSelectionProductLambdaQueryWrapper);
|
|
|
|
+ // 数据查找
|
|
|
|
+ refOrderList.forEach(po->{
|
|
|
|
+ // 查找销售订单
|
|
|
|
+ SaleOrderProduct findSaleOrderProduct = saleOrderProductList.stream().filter(e->e.getId().equals(po.getSourceId())).findFirst().orElse(null);
|
|
|
|
+ if (findSaleOrderProduct != null){
|
|
|
|
+ // 查找销售报价单
|
|
|
|
+ SaleQuotationProduct findSaleQuotationProduct = saleQuotationProductList.stream().filter(e->e.getId().equals(findSaleOrderProduct.getSourceId())).findFirst().orElse(null);
|
|
|
|
+ String sourceId = "";
|
|
|
|
+ if (findSaleQuotationProduct != null){
|
|
|
|
+ sourceId = findSaleQuotationProduct.getSourceId();
|
|
|
|
+ }else{
|
|
|
|
+ // 查找销售报价单历史
|
|
|
|
+ SaleQuotationProductHis findSaleQuotationProductHis = saleQuotationProductHisList.stream().filter(e->e.getId().equals(findSaleOrderProduct.getSourceId())).findFirst().orElse(null);
|
|
|
|
+ if (findSaleQuotationProductHis != null){
|
|
|
|
+ sourceId = findSaleQuotationProductHis.getSourceId();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 查找采购报价选定
|
|
|
|
+ String findSourceId = sourceId;
|
|
|
|
+ if (oConvertUtils.isNotEmpty(sourceId)){
|
|
|
|
+ PurQuotationSelectionProduct findPurQuotationSelectionProduct = purQuotationSelectionProductList.stream().filter(e->e.getId().equals(findSourceId)).findFirst().orElse(null);
|
|
|
|
+ if (findPurQuotationSelectionProduct != null){
|
|
|
|
+ po.setTaxPriceOriginal(findPurQuotationSelectionProduct.getTaxPriceOriginal());
|
|
|
|
+ BigDecimal discount = findPurQuotationSelectionProduct.getDiscount();
|
|
|
|
+ String discountText = discount == null ? "": new BigDecimal(100.0 - discount.doubleValue()).setScale(2).toString();
|
|
|
|
+ po.setDiscountText(discountText);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ /** 参照采购报价选定的,查询采购报价选定,设置折扣和折前单价 **/
|
|
|
|
+ LambdaQueryWrapper<PurQuotationSelectionProduct> purQuotationSelectionProductLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
+ purQuotationSelectionProductLambdaQueryWrapper2.in(PurQuotationSelectionProduct::getId, refQuotationList.stream().map(PurOrderProduct::getSourceId).collect(Collectors.toList()));
|
|
|
|
+ List<PurQuotationSelectionProduct> purQuotationSelectionProductList2 = purQuotationSelectionProductMapper.selectList(purQuotationSelectionProductLambdaQueryWrapper2);
|
|
|
|
+ refQuotationList.forEach(po-> {
|
|
|
|
+ PurQuotationSelectionProduct findPurQuotationSelectionProduct = purQuotationSelectionProductList2.stream().filter(e->e.getId().equals(po.getSourceId())).findFirst().orElse(null);
|
|
|
|
+ if (findPurQuotationSelectionProduct != null) {
|
|
|
|
+ po.setTaxPriceOriginal(findPurQuotationSelectionProduct.getTaxPriceOriginal());
|
|
|
|
+ BigDecimal discount = findPurQuotationSelectionProduct.getDiscount();
|
|
|
|
+ String discountText = discount == null ? "" : new BigDecimal(100.0 - discount.doubleValue()).setScale(2).toString();
|
|
|
|
+ po.setDiscountText(discountText);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return productList;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|