|
@@ -369,8 +369,9 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
List<String> ids = Collections.singletonList(projectId);
|
|
|
List<ProjectAmount> res = contractService.selectAmountList(ids);
|
|
|
List<ContractInvoiceRelation> relations = contractInvoiceRelationService.selectAmountByProjectIds(ids);
|
|
|
+ ProjectAmount projectAmount = null;
|
|
|
if(!res.isEmpty()){
|
|
|
- ProjectAmount projectAmount = res.get(0);
|
|
|
+ projectAmount = res.get(0);
|
|
|
BigDecimal invoiceAmount = BigDecimal.ZERO;
|
|
|
BigDecimal returnAmount = BigDecimal.ZERO;
|
|
|
if (relations != null && !relations.isEmpty()) {
|
|
@@ -383,26 +384,29 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
projectAmount.setReturnAmount(returnAmount);
|
|
|
projectAmount.setReceivableAmount(projectAmount.getInvoiceAmount().subtract(projectAmount.getReturnAmount()));
|
|
|
projectAmount.setContractBalance(projectAmount.getVirtualAmount().subtract(projectAmount.getInvoiceAmount()));
|
|
|
- ProjectCostDto costDto = new ProjectCostDto();
|
|
|
- costDto.setProjectIds(ids);
|
|
|
- Map<String, ProjectCostResponse> costMap = projectCostService.calculateCostMap(costDto);
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
- ProjectCostResponse projectCostResponse = costMap.get(projectAmount.getProjectId());
|
|
|
- if(projectCostResponse != null){
|
|
|
- projectAmount.setProjectCost(projectCostResponse.getCost());
|
|
|
- projectAmount.setReimbursementCost(projectCostResponse.getReimbursementCost());
|
|
|
- projectAmount.setTravelCost(projectCostResponse.getTravelCost());
|
|
|
- projectAmount.setSubcontractCost(projectCostResponse.getSubcontractCost());
|
|
|
- projectAmount.setOutsourceCost(projectCostResponse.getOutsourceCost());
|
|
|
- projectAmount.setPaymentCost(projectCostResponse.getPaymentCost());
|
|
|
- }
|
|
|
- projectAmount.setUpdateTime(now);
|
|
|
- ProjectAmount dbEntity = projectAmountService.selectById(projectId);
|
|
|
- if(dbEntity == null){
|
|
|
- projectAmountService.insert(projectAmount);
|
|
|
- } else {
|
|
|
- projectAmountService.update(projectAmount);
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ projectAmount = new ProjectAmount();
|
|
|
+ projectAmount.setProjectId(projectId);
|
|
|
+ }
|
|
|
+ ProjectCostDto costDto = new ProjectCostDto();
|
|
|
+ costDto.setProjectIds(ids);
|
|
|
+ Map<String, ProjectCostResponse> costMap = projectCostService.calculateCostMap(costDto);
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ ProjectCostResponse projectCostResponse = costMap.get(projectAmount.getProjectId());
|
|
|
+ if(projectCostResponse != null){
|
|
|
+ projectAmount.setProjectCost(projectCostResponse.getCost());
|
|
|
+ projectAmount.setReimbursementCost(projectCostResponse.getReimbursementCost());
|
|
|
+ projectAmount.setTravelCost(projectCostResponse.getTravelCost());
|
|
|
+ projectAmount.setSubcontractCost(projectCostResponse.getSubcontractCost());
|
|
|
+ projectAmount.setOutsourceCost(projectCostResponse.getOutsourceCost());
|
|
|
+ projectAmount.setPaymentCost(projectCostResponse.getPaymentCost());
|
|
|
+ }
|
|
|
+ projectAmount.setUpdateTime(now);
|
|
|
+ ProjectAmount dbEntity = projectAmountService.selectById(projectId);
|
|
|
+ if(dbEntity == null){
|
|
|
+ projectAmountService.insert(projectAmount);
|
|
|
+ } else {
|
|
|
+ projectAmountService.update(projectAmount);
|
|
|
}
|
|
|
|
|
|
}
|