|
@@ -225,6 +225,19 @@ public class ContractDistributorStandardController extends DefaultBaseController |
|
@@ -225,6 +225,19 @@ public class ContractDistributorStandardController extends DefaultBaseController |
|
225
|
List<SysDept> regionList = sysDeptService.listByIds(regionIds);
|
225
|
List<SysDept> regionList = sysDeptService.listByIds(regionIds);
|
|
226
|
regionMap = regionList.stream().collect(Collectors.toMap(SysDept::getId, SysDept::getName));
|
226
|
regionMap = regionList.stream().collect(Collectors.toMap(SysDept::getId, SysDept::getName));
|
|
227
|
}
|
227
|
}
|
|
|
|
228
|
+ List<String> priceLockUserIds = boList.stream()
|
|
|
|
229
|
+ .map(QueryContractDistributorStandardBo::getPriceLockUserId)
|
|
|
|
230
|
+ .filter(StringUtils::isNotBlank)
|
|
|
|
231
|
+ .distinct()
|
|
|
|
232
|
+ .collect(Collectors.toList());
|
|
|
|
233
|
+ final Map<String, SysUser> priceLockUserMap;
|
|
|
|
234
|
+ if (CollectionUtils.isNotEmpty(priceLockUserIds)) {
|
|
|
|
235
|
+ priceLockUserMap = CollectionUtils.emptyIfNull(sysUserService.listByIds(priceLockUserIds))
|
|
|
|
236
|
+ .stream()
|
|
|
|
237
|
+ .collect(Collectors.toMap(SysUser::getId, Function.identity()));
|
|
|
|
238
|
+ } else {
|
|
|
|
239
|
+ priceLockUserMap = Collections.emptyMap();
|
|
|
|
240
|
+ }
|
|
228
|
Map<String, String> finalRegionMap = regionMap;
|
241
|
Map<String, String> finalRegionMap = regionMap;
|
|
229
|
boList.forEach(bo -> {
|
242
|
boList.forEach(bo -> {
|
|
230
|
if (bo == null) {
|
243
|
if (bo == null) {
|
|
@@ -267,6 +280,10 @@ public class ContractDistributorStandardController extends DefaultBaseController |
|
@@ -267,6 +280,10 @@ public class ContractDistributorStandardController extends DefaultBaseController |
|
267
|
Customer customer = customerMap.get(bo.getStockUpCompanyId());
|
280
|
Customer customer = customerMap.get(bo.getStockUpCompanyId());
|
|
268
|
bo.setStockUpCompanyName(customer == null ? "" : customer.getName());
|
281
|
bo.setStockUpCompanyName(customer == null ? "" : customer.getName());
|
|
269
|
}
|
282
|
}
|
|
|
|
283
|
+ if (StringUtils.isNotBlank(bo.getPriceLockUserId())) {
|
|
|
|
284
|
+ SysUser priceLockUser = priceLockUserMap.get(bo.getPriceLockUserId());
|
|
|
|
285
|
+ bo.setPriceLockUserName(priceLockUser == null ? "" : priceLockUser.getName());
|
|
|
|
286
|
+ }
|
|
270
|
//合同状态(标准合同列表展示)
|
287
|
//合同状态(标准合同列表展示)
|
|
271
|
if (vo != null && "STANDARD".equals(vo.getStatus())) {
|
288
|
if (vo != null && "STANDARD".equals(vo.getStatus())) {
|
|
272
|
String contractId = bo.getId();
|
289
|
String contractId = bo.getId();
|
|
@@ -374,6 +391,7 @@ public class ContractDistributorStandardController extends DefaultBaseController |
|
@@ -374,6 +391,7 @@ public class ContractDistributorStandardController extends DefaultBaseController |
|
374
|
contractDistributorLineBo.setProductName(productName);
|
391
|
contractDistributorLineBo.setProductName(productName);
|
|
375
|
lineBoList.add(contractDistributorLineBo);
|
392
|
lineBoList.add(contractDistributorLineBo);
|
|
376
|
});
|
393
|
});
|
|
|
|
394
|
+ fillUnlockedContractLineRemainingQuantity(result, lineBoList);
|
|
377
|
|
395
|
|
|
378
|
result.setContractDistributorLineList(lineBoList);
|
396
|
result.setContractDistributorLineList(lineBoList);
|
|
379
|
}
|
397
|
}
|
|
@@ -413,6 +431,10 @@ public class ContractDistributorStandardController extends DefaultBaseController |
|
@@ -413,6 +431,10 @@ public class ContractDistributorStandardController extends DefaultBaseController |
|
413
|
Customer customer1 = customerService.findById(result.getStockUpCompanyId());
|
431
|
Customer customer1 = customerService.findById(result.getStockUpCompanyId());
|
|
414
|
result.setStockUpCompanyName(customer1 == null ? null : customer1.getName());
|
432
|
result.setStockUpCompanyName(customer1 == null ? null : customer1.getName());
|
|
415
|
}
|
433
|
}
|
|
|
|
434
|
+ if (StringUtils.isNotBlank(result.getPriceLockUserId())) {
|
|
|
|
435
|
+ SysUser priceLockUser = sysUserService.findById(result.getPriceLockUserId());
|
|
|
|
436
|
+ result.setPriceLockUserName(priceLockUser == null ? null : priceLockUser.getName());
|
|
|
|
437
|
+ }
|
|
416
|
//合同状态(标准合同列表展示)
|
438
|
//合同状态(标准合同列表展示)
|
|
417
|
if ("STANDARD".equals(data.getStatus())) {
|
439
|
if ("STANDARD".equals(data.getStatus())) {
|
|
418
|
String shippingStatusName = Stream.of(
|
440
|
String shippingStatusName = Stream.of(
|
|
@@ -447,6 +469,58 @@ public class ContractDistributorStandardController extends DefaultBaseController |
|
@@ -447,6 +469,58 @@ public class ContractDistributorStandardController extends DefaultBaseController |
|
447
|
}
|
469
|
}
|
|
448
|
|
470
|
|
|
449
|
/**
|
471
|
/**
|
|
|
|
472
|
+ * 回填未锁规合同子表剩余锁规数量
|
|
|
|
473
|
+ *
|
|
|
|
474
|
+ * @param contract 合同
|
|
|
|
475
|
+ * @param lineBoList 合同子表
|
|
|
|
476
|
+ */
|
|
|
|
477
|
+ private void fillUnlockedContractLineRemainingQuantity(GetContractDistributorStandardBo contract,
|
|
|
|
478
|
+ List<GetContractDistributorLineBo> lineBoList) {
|
|
|
|
479
|
+ if (contract == null || CollectionUtils.isEmpty(lineBoList)) {
|
|
|
|
480
|
+ return;
|
|
|
|
481
|
+ }
|
|
|
|
482
|
+ if (!"DRAFT_DIST_AGMT".equals(contract.getType()) && !"INTL_OPEN_SPEC_AGMT".equals(contract.getType())) {
|
|
|
|
483
|
+ return;
|
|
|
|
484
|
+ }
|
|
|
|
485
|
+ if (StringUtils.isBlank(contract.getId())) {
|
|
|
|
486
|
+ return;
|
|
|
|
487
|
+ }
|
|
|
|
488
|
+
|
|
|
|
489
|
+ Wrapper<ContractDistributorStandard> childWrapper = Wrappers.lambdaQuery(ContractDistributorStandard.class)
|
|
|
|
490
|
+ .select(ContractDistributorStandard::getId)
|
|
|
|
491
|
+ .eq(ContractDistributorStandard::getParentId, contract.getId());
|
|
|
|
492
|
+ List<String> childContractIds = CollectionUtils.emptyIfNull(contractDistributorStandardService.list(childWrapper))
|
|
|
|
493
|
+ .stream()
|
|
|
|
494
|
+ .map(ContractDistributorStandard::getId)
|
|
|
|
495
|
+ .filter(StringUtils::isNotBlank)
|
|
|
|
496
|
+ .collect(Collectors.toList());
|
|
|
|
497
|
+
|
|
|
|
498
|
+ Map<String, BigDecimal> lockedQuantityMap = Collections.emptyMap();
|
|
|
|
499
|
+ if (CollectionUtils.isNotEmpty(childContractIds)) {
|
|
|
|
500
|
+ Wrapper<ContractDistributorLine> childLineWrapper = Wrappers.lambdaQuery(ContractDistributorLine.class)
|
|
|
|
501
|
+ .select(ContractDistributorLine::getItemId, ContractDistributorLine::getQuantity)
|
|
|
|
502
|
+ .in(ContractDistributorLine::getContractId, childContractIds);
|
|
|
|
503
|
+ lockedQuantityMap = CollectionUtils.emptyIfNull(contractDistributorLineService.list(childLineWrapper))
|
|
|
|
504
|
+ .stream()
|
|
|
|
505
|
+ .filter(Objects::nonNull)
|
|
|
|
506
|
+ .filter(item -> StringUtils.isNotBlank(item.getItemId()))
|
|
|
|
507
|
+ .filter(item -> item.getQuantity() != null)
|
|
|
|
508
|
+ .collect(Collectors.groupingBy(ContractDistributorLine::getItemId,
|
|
|
|
509
|
+ Collectors.reducing(BigDecimal.ZERO, ContractDistributorLine::getQuantity, BigDecimal::add)));
|
|
|
|
510
|
+ }
|
|
|
|
511
|
+
|
|
|
|
512
|
+ Map<String, BigDecimal> finalLockedQuantityMap = lockedQuantityMap;
|
|
|
|
513
|
+ lineBoList.forEach(line -> {
|
|
|
|
514
|
+ BigDecimal quantity = line.getQuantity() == null ? BigDecimal.ZERO : line.getQuantity();
|
|
|
|
515
|
+ BigDecimal lockedQuantity = StringUtils.isBlank(line.getItemId())
|
|
|
|
516
|
+ ? BigDecimal.ZERO
|
|
|
|
517
|
+ : finalLockedQuantityMap.getOrDefault(line.getItemId(), BigDecimal.ZERO);
|
|
|
|
518
|
+ BigDecimal remainingQuantity = quantity.subtract(lockedQuantity);
|
|
|
|
519
|
+ line.setRemainingQuantity(remainingQuantity);
|
|
|
|
520
|
+ });
|
|
|
|
521
|
+ }
|
|
|
|
522
|
+
|
|
|
|
523
|
+ /**
|
|
450
|
* 新增
|
524
|
* 新增
|
|
451
|
*/
|
525
|
*/
|
|
452
|
@ApiOperation("新增")
|
526
|
@ApiOperation("新增")
|