|
@@ -19,6 +19,7 @@ import com.fjhx.common.enums.FlowStatusEnum1;
|
|
|
import com.fjhx.common.enums.PushBusinessTypeEnum;
|
|
|
import com.fjhx.common.service.coding.CodingRuleService;
|
|
|
import com.fjhx.common.service.corporation.CorporationService;
|
|
|
+import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.common.utils.Utils;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerDto;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
|
|
@@ -299,19 +300,95 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
if (ObjectUtil.isEmpty(result)) {
|
|
|
throw new ServiceException("查询不到明细信息请检查");
|
|
|
}
|
|
|
- //赋值买方公司名称(客户)
|
|
|
- Customer customer = customerService.getById(result.getBuyCorporationId());
|
|
|
- if (ObjectUtil.isNotEmpty(customer)) {
|
|
|
- result.setBuyCorporationName(customer.getName());
|
|
|
- }
|
|
|
|
|
|
- //赋值买方公司地址
|
|
|
- setArea(result);
|
|
|
- //查询报价-商品表的详情
|
|
|
- List<QuotationProduct> quotationProductList = quotationProductService.list(Wrappers.<QuotationProduct>lambdaQuery()
|
|
|
- .eq(QuotationProduct::getSaleQuotationId, result.getId()));
|
|
|
+ return setDetailInfo(Arrays.asList(result)).get(0);
|
|
|
+//
|
|
|
+// //赋值买方公司名称(客户)
|
|
|
+// Customer customer = customerService.getById(result.getBuyCorporationId());
|
|
|
+// if (ObjectUtil.isNotEmpty(customer)) {
|
|
|
+// result.setBuyCorporationName(customer.getName());
|
|
|
+// }
|
|
|
+//
|
|
|
+// //赋值买方公司地址
|
|
|
+// setArea(result);
|
|
|
+// //查询报价-商品表的详情
|
|
|
+// List<QuotationProduct> quotationProductList = quotationProductService.list(Wrappers.<QuotationProduct>lambdaQuery()
|
|
|
+// .eq(QuotationProduct::getSaleQuotationId, result.getId()));
|
|
|
+//
|
|
|
+// List<QuotationProductVo> quotationProductVos = BeanUtil.copyToList(quotationProductList, QuotationProductVo.class);
|
|
|
+// //赋值产品信息
|
|
|
+// productInfoService.attributeAssign(quotationProductVos, QuotationProductVo::getProductId, (item, productInfo) -> {
|
|
|
+// item.setProductCode(productInfo.getCustomCode());
|
|
|
+// item.setProductName(productInfo.getName());
|
|
|
+// item.setProductLength(productInfo.getLength());
|
|
|
+// item.setProductWidth(productInfo.getWidth());
|
|
|
+// item.setProductHeight(productInfo.getHeight());
|
|
|
+// });
|
|
|
+//
|
|
|
+// //获取配件列表
|
|
|
+// Map<Long, List<QuotationProductBomVo>> qpbMap = new HashMap<>();
|
|
|
+// List<Long> ids = quotationProductVos.stream().map(QuotationProduct::getId).collect(Collectors.toList());
|
|
|
+// if (ObjectUtil.isNotEmpty(ids)) {
|
|
|
+// List<QuotationProductBom> list = quotationProductBomService.list(q -> q.in(QuotationProductBom::getQuotationProductId, ids));
|
|
|
+//
|
|
|
+// List<QuotationProductBomVo> quotationProductBomVos = BeanUtil.copyToList(list, QuotationProductBomVo.class);
|
|
|
+// //赋值产品信息
|
|
|
+// productInfoService.attributeAssign(quotationProductBomVos, QuotationProductBom::getMaterialId, (item, productInfo) -> {
|
|
|
+// item.setProductCode(productInfo.getCustomCode());
|
|
|
+// item.setProductName(productInfo.getName());
|
|
|
+// item.setProductLength(productInfo.getLength());
|
|
|
+// item.setProductWidth(productInfo.getWidth());
|
|
|
+// item.setProductHeight(productInfo.getHeight());
|
|
|
+// });
|
|
|
+//
|
|
|
+// qpbMap = quotationProductBomVos.stream().collect(Collectors.groupingBy(QuotationProductBom::getQuotationProductId));
|
|
|
+// }
|
|
|
+// for (QuotationProductVo quotationProductVo : quotationProductVos) {
|
|
|
+// quotationProductVo.setQuotationProductBomList(qpbMap.get(quotationProductVo.getId()));
|
|
|
+// }
|
|
|
+// result.setQuotationProductList(quotationProductVos);
|
|
|
+//
|
|
|
+// //赋值报价金额趋势
|
|
|
+// List<SaleQuotation> quotationTrendList = this.list(q -> q
|
|
|
+// .eq(SaleQuotation::getGroupId, result.getGroupId())
|
|
|
+// .ne(SaleQuotation::getStatus, FlowStatusEnum1.CANCELLATION.getKey())
|
|
|
+// .orderByAsc(SaleQuotation::getCreateTime)
|
|
|
+// );
|
|
|
+// result.setQuotationTrendList(quotationTrendList);
|
|
|
+//
|
|
|
+// return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取报价单历史版本
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<SaleQuotationVo> getVersionList(Long saleQuotationId) {
|
|
|
+ SaleQuotation saleQuotation = this.getById(saleQuotationId);
|
|
|
+ Assert.notEmpty(saleQuotation, "查询不到报价单信息!");
|
|
|
+ Long groupId = saleQuotation.getGroupId();
|
|
|
+ List<SaleQuotation> saleQuotationList = this.list(q -> q.eq(SaleQuotation::getGroupId, groupId).orderByDesc(SaleQuotation::getCreateTime));
|
|
|
+ List<SaleQuotationVo> saleQuotationVos = BeanUtil.copyToList(saleQuotationList, SaleQuotationVo.class);
|
|
|
+ return setDetailInfo(saleQuotationVos);
|
|
|
+ }
|
|
|
|
|
|
- List<QuotationProductVo> quotationProductVos = BeanUtil.copyToList(quotationProductList, QuotationProductVo.class);
|
|
|
+ /**
|
|
|
+ * 赋值明细信息
|
|
|
+ */
|
|
|
+ private List<SaleQuotationVo> setDetailInfo(List<SaleQuotationVo> saleQuotationVos) {
|
|
|
+ Long groupId = saleQuotationVos.get(0).getGroupId();
|
|
|
+
|
|
|
+ //获取id列表
|
|
|
+ List<Long> ids = saleQuotationVos.stream().map(SaleQuotation::getId).collect(Collectors.toList());
|
|
|
+ //获取子产品列表
|
|
|
+ List<QuotationProduct> productList = quotationProductService.list(q -> q.in(QuotationProduct::getSaleQuotationId, ids));
|
|
|
+ List<QuotationProductVo> quotationProductVos = BeanUtil.copyToList(productList, QuotationProductVo.class);
|
|
|
+ Map<Long, List<QuotationProductVo>> productMap = quotationProductVos.stream().collect(Collectors.groupingBy(QuotationProductVo::getSaleQuotationId));
|
|
|
//赋值产品信息
|
|
|
productInfoService.attributeAssign(quotationProductVos, QuotationProductVo::getProductId, (item, productInfo) -> {
|
|
|
item.setProductCode(productInfo.getCustomCode());
|
|
@@ -320,46 +397,71 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
item.setProductWidth(productInfo.getWidth());
|
|
|
item.setProductHeight(productInfo.getHeight());
|
|
|
});
|
|
|
-
|
|
|
//获取配件列表
|
|
|
+ List<Long> qpIds = productList.stream().map(QuotationProduct::getId).collect(Collectors.toList());
|
|
|
Map<Long, List<QuotationProductBomVo>> qpbMap = new HashMap<>();
|
|
|
- List<Long> ids = quotationProductVos.stream().map(QuotationProduct::getId).collect(Collectors.toList());
|
|
|
- if (ObjectUtil.isNotEmpty(ids)) {
|
|
|
- List<QuotationProductBom> list = quotationProductBomService.list(q -> q.in(QuotationProductBom::getQuotationProductId, ids));
|
|
|
-
|
|
|
- List<QuotationProductBomVo> quotationProductBomVos = BeanUtil.copyToList(list, QuotationProductBomVo.class);
|
|
|
+ if (ObjectUtil.isNotEmpty(qpIds)) {
|
|
|
+ List<QuotationProductBom> bomList = quotationProductBomService.list(q -> q.in(QuotationProductBom::getQuotationProductId, qpIds));
|
|
|
+ List<QuotationProductBomVo> quotationProductBomVos = BeanUtil.copyToList(bomList, QuotationProductBomVo.class);
|
|
|
//赋值产品信息
|
|
|
- productInfoService.attributeAssign(quotationProductBomVos, QuotationProductBom::getProductId, (item, productInfo) -> {
|
|
|
+ productInfoService.attributeAssign(quotationProductBomVos, QuotationProductBom::getMaterialId, (item, productInfo) -> {
|
|
|
item.setProductCode(productInfo.getCustomCode());
|
|
|
item.setProductName(productInfo.getName());
|
|
|
item.setProductLength(productInfo.getLength());
|
|
|
item.setProductWidth(productInfo.getWidth());
|
|
|
item.setProductHeight(productInfo.getHeight());
|
|
|
});
|
|
|
-
|
|
|
qpbMap = quotationProductBomVos.stream().collect(Collectors.groupingBy(QuotationProductBom::getQuotationProductId));
|
|
|
}
|
|
|
- for (QuotationProductVo quotationProductVo : quotationProductVos) {
|
|
|
- quotationProductVo.setQuotationProductBomList(qpbMap.get(quotationProductVo.getId()));
|
|
|
+
|
|
|
+ //赋值客户信息
|
|
|
+ customerService.attributeAssign(saleQuotationVos, SaleQuotation::getBuyCorporationId, (item, customer) -> {
|
|
|
+ item.setBuyCorporationName(customer.getName());
|
|
|
+ });
|
|
|
+
|
|
|
+ //获取地址信息
|
|
|
+ List<Long> areaIdList = new ArrayList<>();
|
|
|
+ for (SaleQuotation quotation : saleQuotationVos) {
|
|
|
+ areaIdList.add(quotation.getBuyCountryId());
|
|
|
+ areaIdList.add(quotation.getBuyProvinceId());
|
|
|
+ areaIdList.add(quotation.getBuyCityId());
|
|
|
}
|
|
|
- result.setQuotationProductList(quotationProductVos);
|
|
|
+ areaIdList = areaIdList.stream().distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, String> areaMap = CustomizeAreaUtil.getAreaMapByIds(areaIdList);
|
|
|
|
|
|
- //赋值报价金额趋势
|
|
|
+ //获取报价金额趋势
|
|
|
List<SaleQuotation> quotationTrendList = this.list(q -> q
|
|
|
- .eq(SaleQuotation::getGroupId, result.getGroupId())
|
|
|
+ .eq(SaleQuotation::getGroupId, groupId)
|
|
|
.ne(SaleQuotation::getStatus, FlowStatusEnum1.CANCELLATION.getKey())
|
|
|
.orderByAsc(SaleQuotation::getCreateTime)
|
|
|
);
|
|
|
- result.setQuotationTrendList(quotationTrendList);
|
|
|
|
|
|
- return result;
|
|
|
- }
|
|
|
+ //赋值信息
|
|
|
+ for (SaleQuotationVo quotation : saleQuotationVos) {
|
|
|
+ //赋值买方地址
|
|
|
+ quotation.setBuyCountryName(areaMap.get(quotation.getBuyCountryId()));
|
|
|
+ quotation.setBuyProvinceName(areaMap.get(quotation.getBuyProvinceId()));
|
|
|
+ quotation.setBuyCityName(areaMap.get(quotation.getBuyCityId()));
|
|
|
+ quotation.setBuyDetailedAddress(quotation.getBuyAddress());
|
|
|
+
|
|
|
+ //赋值产品列表
|
|
|
+ List<QuotationProductVo> quotationProductVos1 = productMap.getOrDefault(quotation.getId(), new ArrayList<>());
|
|
|
+ for (QuotationProductVo quotationProductVo : quotationProductVos1) {
|
|
|
+ //赋值配件列表
|
|
|
+ quotationProductVo.setQuotationProductBomList(qpbMap.get(quotationProductVo.getId()));
|
|
|
+ }
|
|
|
+ quotation.setQuotationProductList(quotationProductVos1);
|
|
|
+
|
|
|
+ //获取报价金额趋势
|
|
|
+ quotation.setQuotationTrendList(quotationTrendList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return saleQuotationVos;
|
|
|
|
|
|
- @Override
|
|
|
- public void delete(Long id) {
|
|
|
- this.removeById(id);
|
|
|
}
|
|
|
|
|
|
+ //==================================================================================================================
|
|
|
+
|
|
|
/**
|
|
|
* 报价单的复制功能(报价单,报价-商品表的 ,报价-收费项目表,根据报价表的ID相关数据复制一份)
|
|
|
*/
|
|
@@ -788,22 +890,22 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 赋值买卖公司地址
|
|
|
- */
|
|
|
- private void setArea(SaleQuotationVo saleQuotationVo) {
|
|
|
-
|
|
|
- List<Long> areaIdList = Arrays.asList(
|
|
|
- saleQuotationVo.getBuyCountryId(),
|
|
|
- saleQuotationVo.getBuyProvinceId(),
|
|
|
- saleQuotationVo.getBuyCityId()
|
|
|
- );
|
|
|
- Map<Long, String> areaMap = CustomizeAreaUtil.getAreaMapByIds(areaIdList);
|
|
|
- saleQuotationVo.setBuyCountryName(areaMap.get(saleQuotationVo.getBuyCountryId()));
|
|
|
- saleQuotationVo.setBuyProvinceName(areaMap.get(saleQuotationVo.getBuyProvinceId()));
|
|
|
- saleQuotationVo.setBuyCityName(areaMap.get(saleQuotationVo.getBuyCityId()));
|
|
|
- saleQuotationVo.setBuyDetailedAddress(saleQuotationVo.getBuyAddress());
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 赋值买卖公司地址
|
|
|
+// */
|
|
|
+// private void setArea(SaleQuotationVo saleQuotationVo) {
|
|
|
+//
|
|
|
+// List<Long> areaIdList = Arrays.asList(
|
|
|
+// saleQuotationVo.getBuyCountryId(),
|
|
|
+// saleQuotationVo.getBuyProvinceId(),
|
|
|
+// saleQuotationVo.getBuyCityId()
|
|
|
+// );
|
|
|
+// Map<Long, String> areaMap = CustomizeAreaUtil.getAreaMapByIds(areaIdList);
|
|
|
+// saleQuotationVo.setBuyCountryName(areaMap.get(saleQuotationVo.getBuyCountryId()));
|
|
|
+// saleQuotationVo.setBuyProvinceName(areaMap.get(saleQuotationVo.getBuyProvinceId()));
|
|
|
+// saleQuotationVo.setBuyCityName(areaMap.get(saleQuotationVo.getBuyCityId()));
|
|
|
+// saleQuotationVo.setBuyDetailedAddress(saleQuotationVo.getBuyAddress());
|
|
|
+// }
|
|
|
|
|
|
|
|
|
}
|