|
|
@@ -25,10 +25,7 @@ import com.jzg.commons.entity.finance.dto.*;
|
|
|
import com.jzg.commons.entity.finance.po.*;
|
|
|
import com.jzg.commons.entity.finance.vo.*;
|
|
|
import com.jzg.commons.entity.orders.po.InsOrderAdjust;
|
|
|
-import com.jzg.commons.entity.po.EsmInsCompany;
|
|
|
-import com.jzg.commons.entity.po.InsFeeOrders;
|
|
|
-import com.jzg.commons.entity.po.PtlAgreement;
|
|
|
-import com.jzg.commons.entity.po.SysUploadFiles;
|
|
|
+import com.jzg.commons.entity.po.*;
|
|
|
import com.jzg.commons.entity.quote.vo.orders.InsOrdersVo;
|
|
|
import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
|
|
|
import com.jzg.commons.exception.ServiceException;
|
|
|
@@ -792,15 +789,65 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
// 未结算金额
|
|
|
followCompanyFeeVO.setTotalUnSettlementAmount(totalInvoiced.subtract(totalSettlementAmount));
|
|
|
followCompanyFeeVO.setCompanyName(null != data.get(partnerCompanyId) ? data.get(partnerCompanyId).getName() : "");
|
|
|
+ followCompanyFeeVO.setYear(year);
|
|
|
+ followCompanyFeeVO.setMonth(month);
|
|
|
|
|
|
resultList.add(followCompanyFeeVO);
|
|
|
}
|
|
|
|
|
|
-// for (FollowCompanyFeeVO followCompanyFeeVo : followCompanyFeeVos) {
|
|
|
-// followCompanyFeeVo.setCompanyName(null != data.get(followCompanyFeeVo.getPartnerCompanyId()) ? data.get(followCompanyFeeVo.getPartnerCompanyId()).getName() : "");
|
|
|
-// followCompanyFeeVo.setTotalUnSettlementAmount(followCompanyFeeVo.getTotalInvoiced().subtract(followCompanyFeeVo.getTotalSettlementAmount()));
|
|
|
-// followCompanyFeeVo.setTotalUnInvoiced(followCompanyFeeVo.getTotalReceivable().subtract(followCompanyFeeVo.getTotalInvoiced()));
|
|
|
-// }
|
|
|
+
|
|
|
+ // 根据incomes的partnerCompanyId + signYear + signMonth,过滤resultList的partnerCompanyId + year + month,根据过滤后的数据进行partnerCompanyId + signYear + signMonth的分组,然后将过滤后剩余的数据,将入到resultList中,
|
|
|
+ // 并且设置partnerCompanyId、year、month、totalReceivable为incomes的partnerCompanyId、signYear、signMonth、jq_other_costs_premiums + sy_other_costs_premiums
|
|
|
+ List<InsPlyIncomeDto> incomes = baseMapper.queryFollowIncome(null, null, baseController.getSystemCode());
|
|
|
+ if (CollUtil.isNotEmpty(incomes)) {
|
|
|
+ // 1. 将resultList现有数据构建 key: partnerCompanyId_year_month 映射,方便快速匹配
|
|
|
+ Map<String, FollowCompanyFeeVO> existVoMap = resultList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ vo -> vo.getPartnerCompanyId() + "_" + vo.getYear() + "_" + vo.getMonth(),
|
|
|
+ Function.identity(),
|
|
|
+ (oldVal, newVal) -> oldVal // 重复key保留原有
|
|
|
+ ));
|
|
|
+
|
|
|
+ // 2. 将incomes按 partnerCompanyId_signYear_signMonth 分组
|
|
|
+ Map<String, List<InsPlyIncomeDto>> incomeGroupMap = incomes.stream()
|
|
|
+ .collect(Collectors.groupingBy(income -> income.getPartnerCompanyId() + "_" + income.getSignYear() + "_" + income.getSignMonth()));
|
|
|
+
|
|
|
+ // 3. 遍历分组后的收入数据
|
|
|
+ for (Map.Entry<String, List<InsPlyIncomeDto>> entry : incomeGroupMap.entrySet()) {
|
|
|
+ String groupKey = entry.getKey();
|
|
|
+ List<InsPlyIncomeDto> dtoList = entry.getValue();
|
|
|
+ InsPlyIncomeDto firstDto = CollUtil.getFirst(dtoList);
|
|
|
+ String partnerCompanyId = firstDto.getPartnerCompanyId();
|
|
|
+ String signYear = firstDto.getSignYear();
|
|
|
+ String signMonth = firstDto.getSignMonth();
|
|
|
+
|
|
|
+ // 汇总其他费用应收:jq_other_costs_premiums + sy_other_costs_premiums
|
|
|
+ BigDecimal totalOtherReceivable = dtoList.stream()
|
|
|
+ .map(dto -> new BigDecimal(dto.getJqOtherCostsPremiums()).add(new BigDecimal(dto.getSyOtherCostsPremiums())))
|
|
|
+ .reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
|
|
|
+
|
|
|
+ // 4. 判断当前分组是否已经存在于resultList(原有跟单数据)
|
|
|
+ FollowCompanyFeeVO existVo = existVoMap.get(groupKey);
|
|
|
+ if (existVo == null) {
|
|
|
+ // 不存在原有数据,新建VO加入结果集
|
|
|
+ FollowCompanyFeeVO newVo = new FollowCompanyFeeVO();
|
|
|
+ newVo.setPartnerCompanyId(partnerCompanyId);
|
|
|
+ newVo.setYear(signYear);
|
|
|
+ newVo.setMonth(signMonth);
|
|
|
+ // 设置总应收为其他费用合计
|
|
|
+ newVo.setTotalReceivable(totalOtherReceivable);
|
|
|
+ // 其余金额默认0(无开票、结算数据)
|
|
|
+ newVo.setTotalInvoiced(BigDecimal.ZERO);
|
|
|
+ newVo.setTotalUnInvoiced(BigDecimal.ZERO);
|
|
|
+ newVo.setTotalSettlementAmount(BigDecimal.ZERO);
|
|
|
+ newVo.setTotalUnSettlementAmount(BigDecimal.ZERO);
|
|
|
+ // 匹配公司名称
|
|
|
+ newVo.setCompanyName(null != data.get(partnerCompanyId) ? data.get(partnerCompanyId).getName() : "");
|
|
|
+ resultList.add(newVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return resultList;
|
|
|
}
|
|
|
|