|
...
|
...
|
@@ -362,13 +362,10 @@ public class SalesmanQuotationServiceImpl |
|
362
|
362
|
createLineVo.setQuantity(lineVo.getQuantity());
|
|
363
|
363
|
createLineVo.setPurchasePrice(lineVo.getPurchasePrice());
|
|
364
|
364
|
createLineVo.setApplicationAttrition(lineVo.getApplicationAttrition());
|
|
|
365
|
+ createLineVo.setEstimatedLoss(lineVo.getEstimatedLoss());
|
|
365
|
366
|
createLineVo.setItemId(lineVo.getItemId());
|
|
366
|
|
- String lineId = salesmanQuotationLineService.create(createLineVo);
|
|
367
|
367
|
|
|
368
|
|
- BreedRelationship breedRelationship = breedMap.get(lineVo.getProductId());
|
|
369
|
|
- BigDecimal estimatedLoss = calculateEstimatedLoss(lineVo.getPurchasePrice(),
|
|
370
|
|
- lineVo.getApplicationAttrition(), breedRelationship.getAttritionRate(), priced);
|
|
371
|
|
- updateLineEstimatedLoss(lineId, estimatedLoss);
|
|
|
368
|
+ salesmanQuotationLineService.create(createLineVo);
|
|
372
|
369
|
}
|
|
373
|
370
|
}
|
|
374
|
371
|
|
|
...
|
...
|
@@ -391,10 +388,6 @@ public class SalesmanQuotationServiceImpl |
|
391
|
388
|
|
|
392
|
389
|
List<String> existIdList = new ArrayList<>();
|
|
393
|
390
|
for (UpdateSalesmanQuotationLineVo lineVo : lineList) {
|
|
394
|
|
- BreedRelationship breedRelationship = breedMap.get(lineVo.getProductId());
|
|
395
|
|
- BigDecimal estimatedLoss = calculateEstimatedLoss(lineVo.getPurchasePrice(),
|
|
396
|
|
- lineVo.getApplicationAttrition(), breedRelationship.getAttritionRate(), priced);
|
|
397
|
|
-
|
|
398
|
391
|
if (StringUtils.isNotBlank(lineVo.getId())) {
|
|
399
|
392
|
SalesmanQuotationLine oldLine = oldLineMap.get(lineVo.getId());
|
|
400
|
393
|
if (oldLine == null) {
|
|
...
|
...
|
@@ -407,7 +400,6 @@ public class SalesmanQuotationServiceImpl |
|
407
|
400
|
lineVo.setItemId(oldLine.getItemId());
|
|
408
|
401
|
}
|
|
409
|
402
|
salesmanQuotationLineService.update(lineVo);
|
|
410
|
|
- updateLineEstimatedLoss(lineVo.getId(), estimatedLoss);
|
|
411
|
403
|
} else {
|
|
412
|
404
|
CreateSalesmanQuotationLineVo createLineVo = new CreateSalesmanQuotationLineVo();
|
|
413
|
405
|
createLineVo.setQuotationId(quotationId);
|
|
...
|
...
|
@@ -416,9 +408,10 @@ public class SalesmanQuotationServiceImpl |
|
416
|
408
|
createLineVo.setQuantity(lineVo.getQuantity());
|
|
417
|
409
|
createLineVo.setPurchasePrice(lineVo.getPurchasePrice());
|
|
418
|
410
|
createLineVo.setApplicationAttrition(lineVo.getApplicationAttrition());
|
|
419
|
|
- createLineVo.setItemId(StringUtils.defaultIfBlank(lineVo.getItemId(), IdUtil.getId()));
|
|
|
411
|
+ createLineVo.setEstimatedLoss(lineVo.getEstimatedLoss());
|
|
|
412
|
+ createLineVo.setItemId(lineVo.getItemId());
|
|
420
|
413
|
String lineId = salesmanQuotationLineService.create(createLineVo);
|
|
421
|
|
- updateLineEstimatedLoss(lineId, estimatedLoss);
|
|
|
414
|
+
|
|
422
|
415
|
existIdList.add(lineId);
|
|
423
|
416
|
}
|
|
424
|
417
|
}
|
|
...
|
...
|
@@ -434,19 +427,6 @@ public class SalesmanQuotationServiceImpl |
|
434
|
427
|
}
|
|
435
|
428
|
|
|
436
|
429
|
/**
|
|
437
|
|
- * 更新预计损耗
|
|
438
|
|
- *
|
|
439
|
|
- * @param lineId 明细ID
|
|
440
|
|
- * @param estimatedLoss 预计损耗
|
|
441
|
|
- */
|
|
442
|
|
- private void updateLineEstimatedLoss(String lineId, BigDecimal estimatedLoss) {
|
|
443
|
|
- SalesmanQuotationLine updateLine = new SalesmanQuotationLine();
|
|
444
|
|
- updateLine.setId(lineId);
|
|
445
|
|
- updateLine.setEstimatedLoss(estimatedLoss);
|
|
446
|
|
- salesmanQuotationLineService.updateById(updateLine);
|
|
447
|
|
- }
|
|
448
|
|
-
|
|
449
|
|
- /**
|
|
450
|
430
|
* 计算数量合计
|
|
451
|
431
|
*
|
|
452
|
432
|
* @param lineList 明细列表
|
|
...
|
...
|
@@ -461,30 +441,6 @@ public class SalesmanQuotationServiceImpl |
|
461
|
441
|
}
|
|
462
|
442
|
|
|
463
|
443
|
/**
|
|
464
|
|
- * 计算预计损耗
|
|
465
|
|
- *
|
|
466
|
|
- * @param purchasePrice 采购价
|
|
467
|
|
- * @param applicationAttrition 申请损耗
|
|
468
|
|
- * @param fixedAttrition 固定损耗率
|
|
469
|
|
- * @param priced 是否为点价
|
|
470
|
|
- * @return 预计损耗
|
|
471
|
|
- */
|
|
472
|
|
- private BigDecimal calculateEstimatedLoss(BigDecimal purchasePrice, BigDecimal applicationAttrition,
|
|
473
|
|
- BigDecimal fixedAttrition, Boolean priced) {
|
|
474
|
|
- if (!Boolean.TRUE.equals(priced) || purchasePrice == null) {
|
|
475
|
|
- return null;
|
|
476
|
|
- }
|
|
477
|
|
-
|
|
478
|
|
- BigDecimal useRate = applicationAttrition != null ? applicationAttrition : fixedAttrition;
|
|
479
|
|
- if (useRate == null) {
|
|
480
|
|
- return null;
|
|
481
|
|
- }
|
|
482
|
|
-
|
|
483
|
|
- return purchasePrice.multiply(useRate)
|
|
484
|
|
- .divide(new BigDecimal("100"), 10, RoundingMode.HALF_UP);
|
|
485
|
|
- }
|
|
486
|
|
-
|
|
487
|
|
- /**
|
|
488
|
444
|
* 查询必填品种映射
|
|
489
|
445
|
*
|
|
490
|
446
|
* @param productIds 品种ID集合
|
...
|
...
|
|