|
@@ -1,9 +1,21 @@
|
|
|
package com.fjhx.sale.service.sale.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.fjhx.sale.entity.quotation.po.QuotationPay;
|
|
|
+import com.fjhx.sale.entity.quotation.po.QuotationProduct;
|
|
|
import com.fjhx.sale.entity.sale.po.SaleQuotation;
|
|
|
import com.fjhx.sale.mapper.sale.SaleQuotationMapper;
|
|
|
+import com.fjhx.sale.service.quotation.QuotationPayService;
|
|
|
+import com.fjhx.sale.service.quotation.QuotationProductService;
|
|
|
import com.fjhx.sale.service.sale.SaleQuotationService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.sale.util.code.CodeEnum;
|
|
|
+import com.obs.services.internal.ServiceException;
|
|
|
+import com.ruoyi.common.core.domain.BasePo;
|
|
|
+import com.ruoyi.system.utils.UserUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fjhx.sale.entity.sale.vo.SaleQuotationVo;
|
|
@@ -12,6 +24,8 @@ import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.fjhx.sale.entity.sale.dto.SaleQuotationDto;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -23,19 +37,50 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
*/
|
|
|
@Service
|
|
|
public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, SaleQuotation> implements SaleQuotationService {
|
|
|
+ @Autowired
|
|
|
+ private QuotationProductService quotationProductService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QuotationPayService quotationPayService;
|
|
|
|
|
|
+ /**
|
|
|
+ * 报价表分页
|
|
|
+ */
|
|
|
@Override
|
|
|
public Page<SaleQuotationVo> getPage(SaleQuotationSelectDto dto) {
|
|
|
- IWrapper<SaleQuotation> wrapper = getWrapper();
|
|
|
- wrapper.orderByDesc("sq", SaleQuotation::getId);
|
|
|
+ LambdaQueryWrapper<SaleQuotation> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(ObjectUtil.isNotEmpty(dto.getSellCorporationId()),
|
|
|
+ SaleQuotation::getSellCorporationId, dto.getSellCorporationId());
|
|
|
+ wrapper.eq(ObjectUtil.isNotEmpty(dto.getStatus()), SaleQuotation::getStatus, dto.getStatus());
|
|
|
+ wrapper.orderByDesc(SaleQuotation::getCreateTime);
|
|
|
Page<SaleQuotationVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ List<SaleQuotationVo> saleQuotationVoList = page.getRecords();
|
|
|
+
|
|
|
+ //赋值用户名称
|
|
|
+ UserUtil.assignmentNickName(saleQuotationVoList, BasePo::getCreateUser, SaleQuotationVo::setUserName);
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 报价表明细
|
|
|
+ */
|
|
|
@Override
|
|
|
public SaleQuotationVo detail(Long id) {
|
|
|
+ //查询报价表详情
|
|
|
SaleQuotation SaleQuotation = this.getById(id);
|
|
|
SaleQuotationVo result = BeanUtil.toBean(SaleQuotation, SaleQuotationVo.class);
|
|
|
+ if (ObjectUtil.isNotEmpty(result)) {
|
|
|
+ //查询报价-商品表的详情
|
|
|
+ List<QuotationProduct> quotationProductList = quotationProductService.list(Wrappers.<QuotationProduct>lambdaQuery()
|
|
|
+ .eq(QuotationProduct::getSaleQuotationId, result.getId()));
|
|
|
+ result.setQuotationProductList(quotationProductList);
|
|
|
+
|
|
|
+ //查询报价-收费项目表的详情
|
|
|
+ List<QuotationPay> quotationPayList = quotationPayService.list(Wrappers.<QuotationPay>lambdaQuery()
|
|
|
+ .eq(QuotationPay::getSaleQuotationId, result.getId()));
|
|
|
+ result.setQuotationPayList(quotationPayList);
|
|
|
+ }
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -54,4 +99,42 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 报价单的复制功能(报价单,报价-商品表的 ,报价-收费项目表,根据报价表的ID相关数据复制一份)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void copy(SaleQuotationDto saleQuotationDto) {
|
|
|
+ if (ObjectUtil.isEmpty(saleQuotationDto.getId())) {
|
|
|
+ throw new ServiceException("参数缺失:报价单ID不能为null");
|
|
|
+ }
|
|
|
+ //查询商品-报价表的数据
|
|
|
+ SaleQuotation saleQuotation = this.getById(saleQuotationDto.getId());
|
|
|
+ if (ObjectUtil.isNotEmpty(saleQuotation)){
|
|
|
+ throw new ServiceException("报价表的数据不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询报价-商品表的数据
|
|
|
+ List<QuotationProduct> quotationProductList = quotationProductService.list(Wrappers.<QuotationProduct>lambdaQuery()
|
|
|
+ .eq(QuotationProduct::getSaleQuotationId, saleQuotationDto.getId()));
|
|
|
+
|
|
|
+ //查询报价-收费项目表
|
|
|
+ List<QuotationPay> quotationPays = quotationPayService.list(Wrappers.<QuotationPay>lambdaQuery()
|
|
|
+ .eq(QuotationPay::getSaleQuotationId, saleQuotationDto.getId()));
|
|
|
+
|
|
|
+ //添加商品-报价表
|
|
|
+ quotationProductList.forEach(quotationProduct -> quotationProduct.setId(null));
|
|
|
+ quotationProductService.saveBatch(quotationProductList);
|
|
|
+
|
|
|
+ //添加报价-收费项目表
|
|
|
+ quotationPays.forEach(quotationPay -> quotationPay.setId(null));
|
|
|
+ quotationPayService.saveBatch(quotationPays);
|
|
|
+
|
|
|
+
|
|
|
+ //添加报价表的信息
|
|
|
+ saleQuotation.setId(null);
|
|
|
+ saleQuotation.setCode(CodeEnum.SALE_QUOTATION.getCode());
|
|
|
+ baseMapper.insert(saleQuotation);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|