|
@@ -54,6 +54,12 @@ public class AssetsProductionServiceImpl extends ServiceImpl<AssetsProductionMap
|
|
|
@Autowired
|
|
|
private IProductionFundService productionFundService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IAssetsEvaluationTargetService assetsEvaluationTargetService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBusinessProductionChoiceLogService choiceLogService;
|
|
|
+
|
|
|
/**
|
|
|
* 根据资产业务id查询资产业务产品
|
|
|
*
|
|
@@ -78,8 +84,19 @@ public class AssetsProductionServiceImpl extends ServiceImpl<AssetsProductionMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean add(TaskRecordDTO<AssetsProduction> taskRecordDTO) {
|
|
|
- return this.save(taskRecordDTO.getTaskData());
|
|
|
+ public Boolean add(AssetsProduction assetsProduction) {
|
|
|
+ // 选择产品时给当前选择产品的评估对象添加选择产品记录
|
|
|
+ List<BusinessProductionChoiceLog> choiceLogList = new ArrayList<>();
|
|
|
+ for (Long targetId : assetsProduction.getTargetIdList()){
|
|
|
+ BusinessProductionChoiceLog choiceLog = new BusinessProductionChoiceLog();
|
|
|
+ choiceLog.setBusinessType("ASSET_BUSINESS");
|
|
|
+ choiceLog.setProductionType(assetsProduction.getProductionType());
|
|
|
+ choiceLog.setBusinessId(assetsProduction.getBusinessId());
|
|
|
+ choiceLog.setTargetId(targetId);
|
|
|
+ choiceLogList.add(choiceLog);
|
|
|
+ }
|
|
|
+ choiceLogService.saveBatch(choiceLogList);
|
|
|
+ return this.save(assetsProduction);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -130,14 +147,8 @@ public class AssetsProductionServiceImpl extends ServiceImpl<AssetsProductionMap
|
|
|
}
|
|
|
// 生成产品二维码
|
|
|
assetsProduction.setQrCode(businessProductionService.doCreateNormalCode(assetsProduction.getProductionType(), assetsProduction.getProductionNo()));
|
|
|
- // 新增收款信息
|
|
|
-// AssetsProduction productionType = this.getOne(new LambdaQueryWrapper<AssetsProduction>()
|
|
|
-// .select(AssetsProduction::getProductionType)
|
|
|
-// .eq(AssetsProduction::getProductionNo, assetsProduction.getProductionNo())
|
|
|
-// .eq(AssetsProduction::getId, assetsProduction.getId()));
|
|
|
-// if (ObjectUtil.isNotNull(productionType) && !productionType.getProductionType().equals("STATEMENT")){
|
|
|
-// addAssetsShouldAmount(assetsProduction);
|
|
|
-// }
|
|
|
+ // 新增产品收款信息
|
|
|
+ addAssetsProShouldAmount(assetsProduction);
|
|
|
return assetsProductionMapper.writeAssetsProduction(assetsProduction);
|
|
|
}
|
|
|
|
|
@@ -290,35 +301,32 @@ public class AssetsProductionServiceImpl extends ServiceImpl<AssetsProductionMap
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 新增订单收款信息
|
|
|
- *
|
|
|
+ * 新增订单产品收款信息
|
|
|
* @param assetsProduction 资产订单信息
|
|
|
*/
|
|
|
- public void addAssetsShouldAmount(AssetsProduction assetsProduction) {
|
|
|
- // 从订单收款表获取应收款信息
|
|
|
- OrderFund orderFund = new OrderFund();
|
|
|
- orderFund = orderFundService.getOne(new LambdaQueryWrapper<OrderFund>()
|
|
|
- .select(OrderFund::getOrderId, OrderFund::getShouldAmount)
|
|
|
- .eq(OrderFund::getBusinessId, assetsProduction.getBusinessId())
|
|
|
- .eq(OrderFund::getBusinessType, "ASSET_BUSINESS"));
|
|
|
-
|
|
|
- if (ObjectUtil.isNotNull(orderFund) && ObjectUtil.isNotNull(orderFund.getShouldAmount())) {
|
|
|
+ public void addAssetsProShouldAmount(AssetsProduction assetsProduction) {
|
|
|
+ // 根据报告号获取评估对象信息
|
|
|
+ List<AssetsEvaluationTarget> targetList = assetsEvaluationTargetService.list(new LambdaQueryWrapper<AssetsEvaluationTarget>()
|
|
|
+ .select(AssetsEvaluationTarget::getCheckValue)
|
|
|
+ .eq(AssetsEvaluationTarget::getReportNo, assetsProduction.getProductionNo()));
|
|
|
+ if (ObjectUtil.isNotNull(targetList) && ObjectUtil.isNotEmpty(targetList)){
|
|
|
+ // 使用流计算审核价格的总和
|
|
|
+ BigDecimal total = targetList.stream()
|
|
|
+ .map(AssetsEvaluationTarget::getCheckValue)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ // 新增产品收款信息
|
|
|
+ OrderFund orderFund = orderFundService.getOne(new LambdaQueryWrapper<OrderFund>()
|
|
|
+ .select(OrderFund::getId)
|
|
|
+ .eq(OrderFund::getBusinessId, assetsProduction.getBusinessId()));
|
|
|
ProductionFund productionFund = new ProductionFund();
|
|
|
+ productionFund.setBusinessType("ASSET_BUSINESS");
|
|
|
+ productionFund.setBusinessId(assetsProduction.getBusinessId());
|
|
|
productionFund.setOrderFundId(orderFund.getId());
|
|
|
- productionFund.setProductionShouldAmount(orderFund.getShouldAmount());
|
|
|
+ productionFund.setEvaluateAmount(total);
|
|
|
productionFund.setProductionNo(assetsProduction.getProductionNo());
|
|
|
- // 新增产品的收款信息
|
|
|
- productionFundService.save(productionFund);
|
|
|
- } else {
|
|
|
- Assets assets = assetsService.getById(assetsProduction.getBusinessId());
|
|
|
- orderFund.setBusinessId(assets.getId());
|
|
|
- orderFund.setOrderId(assets.getOrderId());
|
|
|
- orderFund.setOrderName(assets.getName());
|
|
|
- orderFund.setBusinessType("ASSET_BUSINESS");
|
|
|
- orderFund.setShouldAmount(BigDecimal.valueOf(0));
|
|
|
- orderFundService.save(orderFund);
|
|
|
- // 订单应收款新增后 继续调用方法添加产品收款信息
|
|
|
- addAssetsShouldAmount(assetsProduction);
|
|
|
+ productionFund.setProductionType(assetsProduction.getProductionType());
|
|
|
+ productionFundService.add(productionFund);
|
|
|
}
|
|
|
}
|
|
|
}
|