|
|
@@ -477,12 +477,22 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
|
|
|
feeCenterReports1.setAmountD(feeCenterReportsD.getAmountD());
|
|
|
feeCenterReports1.setAmountLocD(feeCenterReportsD.getAmountLocD());
|
|
|
feeCenterReports1.setAmountUsdD(feeCenterReportsD.getAmountUsdD());
|
|
|
+ System.out.println("+++++++1"+fee.getBillCorpCnName());
|
|
|
+ System.out.println("+++++++1"+feeCenterReportsD.getBillCorpCnName());
|
|
|
+ if (ObjectUtils.isNotNull(fee.getBillCorpCnName()) && !fee.getBillCorpCnName().equals(feeCenterReportsD.getBillCorpCnName())){
|
|
|
+ feeCenterReports.add(feeCenterReports1);
|
|
|
+ }
|
|
|
}
|
|
|
if (feeCenterReportsC != null) {
|
|
|
feeCenterReports1.setCorpCnName(feeCenterReportsC.getCorpCnName());
|
|
|
feeCenterReports1.setAmountC(feeCenterReportsC.getAmountC());
|
|
|
feeCenterReports1.setAmountLocC(feeCenterReportsC.getAmountLocC());
|
|
|
feeCenterReports1.setAmountUsdC(feeCenterReportsC.getAmountUsdC());
|
|
|
+ System.out.println("+++++++2"+fee.getCorpCnName());
|
|
|
+ System.out.println("+++++++2"+feeCenterReportsC.getCorpCnName());
|
|
|
+ if (ObjectUtils.isNotNull(fee.getCorpCnName()) && !fee.getCorpCnName().equals(feeCenterReportsC.getCorpCnName())){
|
|
|
+ feeCenterReports.add(feeCenterReports1);
|
|
|
+ }
|
|
|
}
|
|
|
feeCenterReports.add(feeCenterReports1);
|
|
|
}
|
|
|
@@ -1324,7 +1334,844 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
|
|
|
} else {
|
|
|
map.put(MagicValues.DATA, null);
|
|
|
}
|
|
|
- } else if (MagicValues.AMEND_SI.equals(reportCode) && MagicValues.AMEND.equals(type)
|
|
|
+ } else if ((MagicValues.AMEND_SI.equals(reportCode) || MagicValues.AMEND_SE.equals(reportCode)) && MagicValues.AMEND.equals(type)
|
|
|
+ && (MagicValues.SE.equals(groupCode) || MagicValues.SI.equals(groupCode) || MagicValues.AE.equals(groupCode) || MagicValues.AI.equals(groupCode))) {
|
|
|
+ List<Bills> list = new ArrayList<>();
|
|
|
+ Amends amends = amendsService.getById(billId);
|
|
|
+ String profitMargin = sysClient.getParamService(MagicValues.PROFIT_MARGIN);
|
|
|
+ if (amends != null) {
|
|
|
+ List<BCorps> bCorpsList = bCorpsService.list(new LambdaQueryWrapper<BCorps>()
|
|
|
+ .eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BCorps::getIsDeleted, 0)
|
|
|
+ .eq(BCorps::getStatus, 0));
|
|
|
+ List<Amends> amendsList = amendsService.list(new LambdaQueryWrapper<Amends>()
|
|
|
+ .eq(Amends::getOrigId, amends.getOrigId())
|
|
|
+ .eq(Amends::getStatus, 3)
|
|
|
+ .eq(Amends::getIsDeleted, 0)
|
|
|
+ .eq(Amends::getTenantId, AuthUtil.getTenantId()));
|
|
|
+ List<Long> amendsIds = amendsList.stream().map(Amends::getId).collect(Collectors.toList());
|
|
|
+ if (amendsIds.size() > 0) {
|
|
|
+ amendsIds.add(amends.getId());
|
|
|
+ } else {
|
|
|
+ amendsIds = new ArrayList<>();
|
|
|
+ amendsIds.add(amends.getId());
|
|
|
+ }
|
|
|
+ List<FeeCenter> amendFeeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .in(FeeCenter::getPid, amendsIds)
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0));
|
|
|
+ Bills bills = billsService.getById(amends.getOrigId());
|
|
|
+ if (bills != null) {
|
|
|
+ BCorps carrierCorps = bCorpsList.stream().filter(e -> e.getId().equals(bills.getCarrierId())).findFirst().orElse(null);
|
|
|
+ if (carrierCorps != null && ObjectUtils.isNotNull(carrierCorps.getShortName())) {
|
|
|
+ bills.setCarrierCnName(carrierCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ bills.setCarrierCnName(bills.getCarrierCnName());
|
|
|
+ }
|
|
|
+ String analysis = "";
|
|
|
+ if ("OWN".equals(bills.getSrcType())) {
|
|
|
+ analysis = "公司";
|
|
|
+ } else if ("AGENT".equals(bills.getSrcType())) {
|
|
|
+ analysis = "代理";
|
|
|
+ } else if ("SALES".equals(bills.getSrcType())) {
|
|
|
+ analysis = "业务员";
|
|
|
+ }
|
|
|
+ analysis = analysis + "/" + bills.getSrcCnName() + "/";
|
|
|
+ BCorps corps = bCorpsList.stream().filter(e -> e.getId().equals(bills.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (corps != null && ObjectUtils.isNotNull(corps.getShortName())) {
|
|
|
+ analysis += corps.getShortName();
|
|
|
+ } else {
|
|
|
+ analysis += bills.getCorpCnName();
|
|
|
+ }
|
|
|
+ bills.setAnalysis(analysis);
|
|
|
+ if (bCurrency != null) {
|
|
|
+ bills.setRate(bCurrency.getExrate());
|
|
|
+ } else {
|
|
|
+ bills.setRate(new BigDecimal(MagicValues.ZERO));
|
|
|
+ }
|
|
|
+ if (MagicValues.MM.equals(bills.getBillType()) || MagicValues.DD.equals(bills.getBillType())) {
|
|
|
+ List<Bills> billsList = billsService.list(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getMasterId, bills.getId())
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0));
|
|
|
+ if (billsList.size() > 0) {
|
|
|
+ List<Long> ids = billsList.stream().map(Bills::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ if (ids.size() > 0) {
|
|
|
+ List<FeeCenter> feeCenterListMh = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .in(FeeCenter::getPid, ids)
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0));
|
|
|
+ feeCenterListMh.stream().filter(e -> ObjectUtils.isNull(e.getReportType())).forEach(e -> e.setReportType("0"));
|
|
|
+ for (Bills item : billsList) {
|
|
|
+ for (FeeCenter feeCenter : amendFeeCenterList) {
|
|
|
+ if (feeCenter.getPid().equals(amends.getId())) {
|
|
|
+ feeCenter.setReportType(MagicValues.ONE);
|
|
|
+ } else {
|
|
|
+ feeCenter.setReportType(MagicValues.TWO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenterListMh.addAll(amendFeeCenterList);
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterListMh.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
|
|
|
+ Comparator.comparing(f -> f.getFeeId() + f.getCorpId() + f.getCurCode() + f.getReportType()))), ArrayList::new));
|
|
|
+ List<FeeCenterReports> feeCenterReportList = new ArrayList<>();
|
|
|
+ for (FeeCenter fee : feeCenterList) {
|
|
|
+ FeeCenterReports feeCenterReports = new FeeCenterReports();
|
|
|
+ feeCenterReports.setPid(item.getId());
|
|
|
+ feeCenterReports.setFeeCnName(fee.getFeeCnName());
|
|
|
+ feeCenterReports.setDc(fee.getDc());
|
|
|
+ List<FeeCenter> feeCenterListD;
|
|
|
+ List<FeeCenter> feeCenterListUsdD;
|
|
|
+ List<FeeCenter> feeCenterListC;
|
|
|
+ List<FeeCenter> feeCenterListUsdC;
|
|
|
+ if (MagicValues.ONE.equals(fee.getReportType())) {
|
|
|
+ feeCenterListD = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else if (MagicValues.TWO.equals(fee.getReportType())) {
|
|
|
+ feeCenterListD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(item.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(item.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(item.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(item.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ feeCenterListD = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(item.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(item.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(item.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(item.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListD.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setBillCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setBillCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountD(feeCenterListD.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocD(feeCenterListD.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListUsdD.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setBillCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setBillCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountUsdD(feeCenterListUsdD.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocD(feeCenterListUsdD.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListC.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountC(feeCenterListC.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocC(feeCenterListC.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListUsdC.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountUsdC(feeCenterListUsdC.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocC(feeCenterListUsdC.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+ feeCenterReportList.add(feeCenterReports);
|
|
|
+ }
|
|
|
+ item.setFeeCenterList(feeCenterReportList);
|
|
|
+ list.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getPid, bills.getId())
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0));
|
|
|
+ for (FeeCenter feeCenter : amendFeeCenterList) {
|
|
|
+ if (feeCenter.getPid().equals(amends.getId())) {
|
|
|
+ feeCenter.setReportType(MagicValues.ONE);
|
|
|
+ } else {
|
|
|
+ feeCenter.setReportType(MagicValues.TWO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenterList.addAll(amendFeeCenterList);
|
|
|
+ if (feeCenterList.size() > 0) {
|
|
|
+ feeCenterList.stream().filter(e -> ObjectUtils.isNull(e.getReportType())).forEach(e -> e.setReportType("0"));
|
|
|
+ List<FeeCenter> feeCenters = feeCenterList.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
|
|
|
+ Comparator.comparing(f -> f.getFeeId() + f.getCorpId() + f.getCurCode() + f.getReportType()))), ArrayList::new));
|
|
|
+ List<FeeCenterReports> feeCenterReportList = new ArrayList<>();
|
|
|
+ for (FeeCenter fee : feeCenters) {
|
|
|
+ FeeCenterReports feeCenterReports = new FeeCenterReports();
|
|
|
+ feeCenterReports.setPid(bills.getId());
|
|
|
+ feeCenterReports.setFeeCnName(fee.getFeeCnName());
|
|
|
+ feeCenterReports.setReportType(fee.getReportType());
|
|
|
+ List<FeeCenter> feeCenterListD;
|
|
|
+ List<FeeCenter> feeCenterListUsdD;
|
|
|
+ List<FeeCenter> feeCenterListC;
|
|
|
+ List<FeeCenter> feeCenterListUsdC;
|
|
|
+ if (MagicValues.ONE.equals(fee.getReportType())) {
|
|
|
+ feeCenterListD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else if (MagicValues.TWO.equals(fee.getReportType())) {
|
|
|
+ feeCenterListD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ feeCenterListD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ feeCenterReports.setDc(fee.getDc());
|
|
|
+
|
|
|
+ if (feeCenterListD.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setBillCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setBillCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountD(feeCenterListD.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocD(feeCenterListD.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+ if (feeCenterListUsdD.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setBillCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setBillCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountUsdD(feeCenterListUsdD.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocD(feeCenterListUsdD.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+ if (feeCenterListC.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountC(feeCenterListC.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocC(feeCenterListC.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+ if (feeCenterListUsdC.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountUsdC(feeCenterListUsdC.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocC(feeCenterListUsdC.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+ feeCenterReportList.add(feeCenterReports);
|
|
|
+ }
|
|
|
+ bills.setFeeCenterList(feeCenterReportList);
|
|
|
+ }
|
|
|
+ list.add(0, bills);
|
|
|
+ } else if (MagicValues.MH.equals(bills.getBillType())) {
|
|
|
+ Bills details = billsService.getOne(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getId, bills.getMasterId())
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0));
|
|
|
+ if (details != null) {
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getPid, bills.getId())
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0));
|
|
|
+ for (FeeCenter feeCenter : amendFeeCenterList) {
|
|
|
+ if (feeCenter.getPid().equals(amends.getId())) {
|
|
|
+ feeCenter.setReportType(MagicValues.ONE);
|
|
|
+ } else {
|
|
|
+ feeCenter.setReportType(MagicValues.TWO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenterList.addAll(amendFeeCenterList);
|
|
|
+ if (feeCenterList.size() > 0) {
|
|
|
+ feeCenterList.stream().filter(e -> ObjectUtils.isNull(e.getReportType())).forEach(e -> e.setReportType("0"));
|
|
|
+ List<FeeCenter> feeCenters = feeCenterList.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
|
|
|
+ Comparator.comparing(f -> f.getFeeId() + f.getCorpId() + f.getCurCode() + f.getReportType()))), ArrayList::new));
|
|
|
+ List<FeeCenterReports> feeCenterReportList = new ArrayList<>();
|
|
|
+ for (FeeCenter fee : feeCenters) {
|
|
|
+ FeeCenterReports feeCenterReports = new FeeCenterReports();
|
|
|
+ feeCenterReports.setPid(bills.getId());
|
|
|
+ feeCenterReports.setFeeCnName(fee.getFeeCnName());
|
|
|
+ feeCenterReports.setDc(fee.getDc());
|
|
|
+ feeCenterReports.setReportType(fee.getReportType());
|
|
|
+ List<FeeCenter> feeCenterListD;
|
|
|
+ List<FeeCenter> feeCenterListUsdD;
|
|
|
+ List<FeeCenter> feeCenterListC;
|
|
|
+ List<FeeCenter> feeCenterListUsdC;
|
|
|
+ if (MagicValues.ONE.equals(fee.getReportType())) {
|
|
|
+ feeCenterListD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else if (MagicValues.TWO.equals(fee.getReportType())) {
|
|
|
+ feeCenterListD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ feeCenterListD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(bills.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListD.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setBillCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setBillCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountD(feeCenterListD.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocD(feeCenterListD.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListUsdD.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setBillCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setBillCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountUsdD(feeCenterListUsdD.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocD(feeCenterListUsdD.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListC.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountC(feeCenterListC.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocC(feeCenterListC.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListUsdC.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountUsdC(feeCenterListUsdC.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocC(feeCenterListUsdC.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+ feeCenterReportList.add(feeCenterReports);
|
|
|
+ }
|
|
|
+ bills.setFeeCenterList(feeCenterReportList);
|
|
|
+ }
|
|
|
+ list.add(bills);
|
|
|
+ List<FeeCenter> feeCenterListMh = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getPid, details.getId())
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0));
|
|
|
+ feeCenterListMh.stream().filter(e -> ObjectUtils.isNull(e.getReportType())).forEach(e -> e.setReportType("0"));
|
|
|
+ for (FeeCenter feeCenter : amendFeeCenterList) {
|
|
|
+ if (feeCenter.getPid().equals(amends.getId())) {
|
|
|
+ feeCenter.setReportType(MagicValues.ONE);
|
|
|
+ } else {
|
|
|
+ feeCenter.setReportType(MagicValues.TWO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenterListMh.addAll(amendFeeCenterList);
|
|
|
+ List<FeeCenter> feeCenterList1 = feeCenterListMh.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
|
|
|
+ Comparator.comparing(f -> f.getFeeId() + f.getCorpId() + f.getCurCode() + f.getReportType()))), ArrayList::new));
|
|
|
+ List<FeeCenterReports> feeCenterReportList = new ArrayList<>();
|
|
|
+ for (FeeCenter fee : feeCenterList1) {
|
|
|
+ FeeCenterReports feeCenterReports = new FeeCenterReports();
|
|
|
+ feeCenterReports.setPid(details.getId());
|
|
|
+ feeCenterReports.setFeeCnName(fee.getFeeCnName());
|
|
|
+ feeCenterReports.setDc(fee.getDc());
|
|
|
+ feeCenterReports.setReportType(fee.getReportType());
|
|
|
+ List<FeeCenter> feeCenterListD;
|
|
|
+ List<FeeCenter> feeCenterListUsdD;
|
|
|
+ List<FeeCenter> feeCenterListC;
|
|
|
+ List<FeeCenter> feeCenterListUsdC;
|
|
|
+ if (MagicValues.ONE.equals(fee.getReportType())) {
|
|
|
+ feeCenterListD = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(amends.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else if (MagicValues.TWO.equals(fee.getReportType())) {
|
|
|
+ feeCenterListD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(details.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(details.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(details.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterList.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && !e.getPid().equals(amends.getId()) && !e.getPid().equals(details.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ feeCenterListD = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(details.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdD = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.D.equals(e.getDc()) && e.getPid().equals(details.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListC = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(details.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.CNY.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ feeCenterListUsdC = feeCenterListMh.stream()
|
|
|
+ .filter(e -> MagicValues.C.equals(e.getDc()) && e.getPid().equals(details.getId()) &&
|
|
|
+ e.getFeeId().equals(fee.getFeeId()) && MagicValues.USD.equals(e.getCurCode()) && fee.getCurCode().equals(e.getCurCode()) &&
|
|
|
+ e.getCorpId().equals(fee.getCorpId()) && e.getReportType().equals(fee.getReportType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListD.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setBillCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setBillCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountD(feeCenterListD.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocD(feeCenterListD.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListUsdD.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setBillCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setBillCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountUsdD(feeCenterListUsdD.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocD(feeCenterListUsdD.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListC.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountC(feeCenterListC.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocC(feeCenterListC.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (feeCenterListUsdC.size() > 0) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(fee.getCorpId())).findFirst().orElse(null);
|
|
|
+ if (bCorps != null && ObjectUtils.isNotNull(bCorps.getShortName())) {
|
|
|
+ feeCenterReports.setCorpCnName(bCorps.getShortName());
|
|
|
+ } else {
|
|
|
+ feeCenterReports.setCorpCnName(fee.getCorpCnName());
|
|
|
+ }
|
|
|
+ feeCenterReports.setAmountUsdC(feeCenterListUsdC.stream().map(FeeCenter::getAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ feeCenterReports.setAmountLocC(feeCenterListUsdC.stream().map(FeeCenter::getAmountLoc)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+ feeCenterReportList.add(feeCenterReports);
|
|
|
+ }
|
|
|
+ details.setFeeCenterList(feeCenterReportList);
|
|
|
+ list.add(0, details);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (list.size() > 0) {
|
|
|
+ for (Bills item : list) {
|
|
|
+ List<FeeCenterReports> feeCenterReports = new ArrayList<>();
|
|
|
+ List<FeeCenterReports> feeCenterReportsList = item.getFeeCenterList().stream().filter(e -> !MagicValues.ONE.equals(e.getReportType()) && !MagicValues.TWO.equals(e.getReportType())).collect(Collectors.toList());
|
|
|
+ List<FeeCenterReports> feeCenterReportsList1 = item.getFeeCenterList().stream().filter(e -> MagicValues.ONE.equals(e.getReportType())).collect(Collectors.toList());
|
|
|
+ List<FeeCenterReports> feeCenterReportsList2 = item.getFeeCenterList().stream().filter(e -> MagicValues.TWO.equals(e.getReportType())).collect(Collectors.toList());
|
|
|
+ List<FeeCenterReports> feeCenters = feeCenterReportsList.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
|
|
|
+ Comparator.comparing(FeeCenterReports::getFeeCnName))), ArrayList::new));
|
|
|
+ List<FeeCenterReports> feeCenters1 = feeCenterReportsList1.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
|
|
|
+ Comparator.comparing(FeeCenterReports::getFeeCnName))), ArrayList::new));
|
|
|
+ List<FeeCenterReports> feeCenters2 = feeCenterReportsList2.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
|
|
|
+ Comparator.comparing(FeeCenterReports::getFeeCnName))), ArrayList::new));
|
|
|
+ BigDecimal amountDr = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountCr = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountDrUsd = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountCrUsd = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountDrUpdate = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountCrUpdate = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountDrUsdUpdate = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountCrUsdUpdate = new BigDecimal("0.00");
|
|
|
+ for (FeeCenterReports fee : feeCenters) {
|
|
|
+ FeeCenterReports feeReports = item.getFeeCenterList().stream()
|
|
|
+ .filter(e -> e.getFeeCnName().equals(fee.getFeeCnName()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ FeeCenterReports feeCenterReports1 = new FeeCenterReports();
|
|
|
+ feeCenterReports1.setFeeCnName(fee.getFeeCnName());
|
|
|
+ feeCenterReports1.setHblno(fee.getHblno());
|
|
|
+ feeCenterReports1.setPid(fee.getPid());
|
|
|
+ feeCenterReports1.setReportType(fee.getReportType());
|
|
|
+ feeCenterReports1.setDc(fee.getDc());
|
|
|
+ if (feeReports != null) {
|
|
|
+ if ((ObjectUtils.isNotNull(feeReports.getAmountD()) && feeReports.getAmountD().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ || (ObjectUtils.isNotNull(feeReports.getAmountUsdD()) && feeReports.getAmountUsdD().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ ) {
|
|
|
+ feeCenterReports1.setBillCorpCnName(feeReports.getBillCorpCnName());
|
|
|
+ feeCenterReports1.setAmountD(feeReports.getAmountD());
|
|
|
+ feeCenterReports1.setAmountLocD(feeReports.getAmountLocD());
|
|
|
+ feeCenterReports1.setAmountUsdD(feeReports.getAmountUsdD());
|
|
|
+ amountDr = amountDr.add(ObjectUtils.isNotNull(feeReports.getAmountD()) ? feeReports.getAmountD() : new BigDecimal("0.00"));
|
|
|
+ amountDrUsd = amountDrUsd.add(ObjectUtils.isNotNull(feeReports.getAmountUsdD()) ? feeReports.getAmountUsdD() : new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ if ((ObjectUtils.isNotNull(feeReports.getAmountC()) && feeReports.getAmountC().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ || (ObjectUtils.isNotNull(feeReports.getAmountUsdC()) && feeReports.getAmountUsdC().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ ) {
|
|
|
+ feeCenterReports1.setCorpCnName(feeReports.getCorpCnName());
|
|
|
+ feeCenterReports1.setAmountC(feeReports.getAmountC());
|
|
|
+ feeCenterReports1.setAmountLocC(feeReports.getAmountLocC());
|
|
|
+ feeCenterReports1.setAmountUsdC(feeReports.getAmountUsdC());
|
|
|
+ amountCr = amountCr.add(ObjectUtils.isNotNull(feeReports.getAmountC()) ? feeReports.getAmountC() : new BigDecimal("0.00"));
|
|
|
+ amountCrUsd = amountCrUsd.add(ObjectUtils.isNotNull(feeReports.getAmountUsdC()) ? feeReports.getAmountUsdC() : new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenterReports.add(feeCenterReports1);
|
|
|
+ }
|
|
|
+ for (FeeCenterReports fee : feeCenters2) {
|
|
|
+ FeeCenterReports feeReports = feeCenterReportsList2.stream()
|
|
|
+ .filter(e -> e.getFeeCnName().equals(fee.getFeeCnName()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ FeeCenterReports feeCenterReports1 = new FeeCenterReports();
|
|
|
+ feeCenterReports1.setFeeCnName(fee.getFeeCnName());
|
|
|
+ feeCenterReports1.setHblno(fee.getHblno());
|
|
|
+ feeCenterReports1.setPid(fee.getPid());
|
|
|
+ feeCenterReports1.setReportType(fee.getReportType());
|
|
|
+ feeCenterReports1.setDc(fee.getDc());
|
|
|
+ if (feeReports != null) {
|
|
|
+ if ((ObjectUtils.isNotNull(feeReports.getAmountD()) && feeReports.getAmountD().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ || (ObjectUtils.isNotNull(feeReports.getAmountUsdD()) && feeReports.getAmountUsdD().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ ) {
|
|
|
+ feeCenterReports1.setBillCorpCnName(feeReports.getBillCorpCnName());
|
|
|
+ feeCenterReports1.setAmountD(feeReports.getAmountD());
|
|
|
+ feeCenterReports1.setAmountLocD(feeReports.getAmountLocD());
|
|
|
+ feeCenterReports1.setAmountUsdD(feeReports.getAmountUsdD());
|
|
|
+ amountDr = amountDr.add(ObjectUtils.isNotNull(feeReports.getAmountD()) ? feeReports.getAmountD() : new BigDecimal("0.00"));
|
|
|
+ amountDrUsd = amountDrUsd.add(ObjectUtils.isNotNull(feeReports.getAmountUsdD()) ? feeReports.getAmountUsdD() : new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ if ((ObjectUtils.isNotNull(feeReports.getAmountC()) && feeReports.getAmountC().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ || (ObjectUtils.isNotNull(feeReports.getAmountUsdC()) && feeReports.getAmountUsdC().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ ) {
|
|
|
+ feeCenterReports1.setCorpCnName(feeReports.getCorpCnName());
|
|
|
+ feeCenterReports1.setAmountC(feeReports.getAmountC());
|
|
|
+ feeCenterReports1.setAmountLocC(feeReports.getAmountLocC());
|
|
|
+ feeCenterReports1.setAmountUsdC(feeReports.getAmountUsdC());
|
|
|
+ amountCr = amountCr.add(ObjectUtils.isNotNull(feeReports.getAmountC()) ? feeReports.getAmountC() : new BigDecimal("0.00"));
|
|
|
+ amountCrUsd = amountCrUsd.add(ObjectUtils.isNotNull(feeReports.getAmountUsdC()) ? feeReports.getAmountUsdC() : new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenterReports.add(feeCenterReports1);
|
|
|
+ }
|
|
|
+ item.setAmountProfit(amountDr.subtract(amountCr));
|
|
|
+ item.setAmountProfitUsd(amountDrUsd.subtract(amountCrUsd));
|
|
|
+ BigDecimal amountDrCny = ibCurrencyService.converterCny(MagicValues.USD, amountDrUsd, MagicValues.D);
|
|
|
+ BigDecimal amountCrCny = ibCurrencyService.converterCny(MagicValues.USD, amountCrUsd, MagicValues.C);
|
|
|
+ item.setAmountProfitLoc(amountDr.subtract(amountCr).add(amountDrCny.subtract(amountCrCny)));
|
|
|
+ for (FeeCenterReports fee : feeCenters1) {
|
|
|
+ FeeCenterReports feeReports = feeCenterReportsList1.stream()
|
|
|
+ .filter(e -> e.getFeeCnName().equals(fee.getFeeCnName()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ FeeCenterReports feeCenterReports1 = new FeeCenterReports();
|
|
|
+ feeCenterReports1.setFeeCnName(fee.getFeeCnName());
|
|
|
+ feeCenterReports1.setHblno(fee.getHblno());
|
|
|
+ feeCenterReports1.setPid(fee.getPid());
|
|
|
+ feeCenterReports1.setReportType(fee.getReportType());
|
|
|
+ feeCenterReports1.setDc(fee.getDc());
|
|
|
+ if (feeReports != null) {
|
|
|
+ if ((ObjectUtils.isNotNull(feeReports.getAmountD()) && feeReports.getAmountD().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ || (ObjectUtils.isNotNull(feeReports.getAmountUsdD()) && feeReports.getAmountUsdD().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ ) {
|
|
|
+ feeCenterReports1.setBillCorpCnName(feeReports.getBillCorpCnName());
|
|
|
+ feeCenterReports1.setAmountD(feeReports.getAmountD());
|
|
|
+ feeCenterReports1.setAmountLocD(feeReports.getAmountLocD());
|
|
|
+ feeCenterReports1.setAmountUsdD(feeReports.getAmountUsdD());
|
|
|
+ amountDr = amountDr.add(ObjectUtils.isNotNull(feeReports.getAmountD()) ? feeReports.getAmountD() : new BigDecimal("0.00"));
|
|
|
+ amountDrUsd = amountDrUsd.add(ObjectUtils.isNotNull(feeReports.getAmountUsdD()) ? feeReports.getAmountUsdD() : new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((ObjectUtils.isNotNull(feeReports.getAmountC()) && feeReports.getAmountC().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ || (ObjectUtils.isNotNull(feeReports.getAmountUsdC()) && feeReports.getAmountUsdC().compareTo(new BigDecimal("0.00")) != 0)
|
|
|
+ ) {
|
|
|
+ feeCenterReports1.setCorpCnName(feeReports.getCorpCnName());
|
|
|
+ feeCenterReports1.setAmountC(feeReports.getAmountC());
|
|
|
+ feeCenterReports1.setAmountLocC(feeReports.getAmountLocC());
|
|
|
+ feeCenterReports1.setAmountUsdC(feeReports.getAmountUsdC());
|
|
|
+ amountCr = amountCr.add(ObjectUtils.isNotNull(feeReports.getAmountC()) ? feeReports.getAmountC() : new BigDecimal("0.00"));
|
|
|
+ amountCrUsd = amountCrUsd.add(ObjectUtils.isNotNull(feeReports.getAmountUsdC()) ? feeReports.getAmountUsdC() : new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenterReports.add(feeCenterReports1);
|
|
|
+ }
|
|
|
+
|
|
|
+ item.setAmountDr(amountDr);
|
|
|
+ item.setAmountCr(amountCr);
|
|
|
+ item.setAmountDrUsd(amountDrUsd);
|
|
|
+ item.setAmountDrUsd(amountCrUsd);
|
|
|
+ item.setAmountDrLoc(amountDr.add(ibCurrencyService.converterCny(MagicValues.USD, amountDrUsd, MagicValues.D)));
|
|
|
+ item.setAmountCrLoc(amountCr.add(ibCurrencyService.converterCny(MagicValues.USD, amountCrUsd, MagicValues.C)));
|
|
|
+ item.setAmountProfitUpdate(amountDr.subtract(amountCr));
|
|
|
+ item.setAmountProfitUsdUpdate(amountDrUsd.subtract(amountCrUsd));
|
|
|
+ BigDecimal amountDrCnyUpdate = ibCurrencyService.converterCny(MagicValues.USD, amountDrUsd, MagicValues.D);
|
|
|
+ BigDecimal amountCrCnyUpdate = ibCurrencyService.converterCny(MagicValues.USD, amountCrUsd, MagicValues.C);
|
|
|
+ item.setAmountProfitLocUpdate(amountDr.subtract(amountCr).add(amountDrCnyUpdate.subtract(amountCrCnyUpdate)));
|
|
|
+ item.setAmountProfitLocUpdate(item.getAmountProfitLocUpdate().setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ item.setAmountProfitLoc(item.getAmountProfitLoc().setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ item.setResponsibleParty(amends.getResponsibleParty());
|
|
|
+ if (ObjectUtils.isNotNull(item.getAmountProfitLocUpdate()) && ObjectUtils.isNotNull(item.getAmountDrLoc())) {
|
|
|
+ if (item.getAmountProfitLocUpdate().compareTo(new BigDecimal(MagicValues.ZERO)) == 0 ||
|
|
|
+ item.getAmountDrLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0) {
|
|
|
+ item.setGrossMargin(new BigDecimal(MagicValues.ZERO));
|
|
|
+ } else {
|
|
|
+ item.setGrossMargin(item.getAmountProfitLocUpdate().divide(item.getAmountDrLoc(), 4, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ item.setGrossMargin(new BigDecimal(MagicValues.ZERO));
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(profitMargin)) {
|
|
|
+ BigDecimal margin = new BigDecimal(profitMargin).divide(new BigDecimal(MagicValues.HUNDRED), 2, RoundingMode.HALF_UP);
|
|
|
+ if (margin.compareTo(item.getGrossMargin()) > 0) {
|
|
|
+ item.setProfitMargin("Profit was low!");
|
|
|
+ } else {
|
|
|
+ item.setProfitMargin("");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ item.setProfitMargin("");
|
|
|
+ }
|
|
|
+ item.setFeeCenterList(feeCenterReports);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put(MagicValues.DATA, list);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ map.put(MagicValues.DATA, list);
|
|
|
+ }
|
|
|
+ } else if ((MagicValues.AMEND_AE.equals(reportCode) || MagicValues.AMEND_AI.equals(reportCode)) && MagicValues.AMEND.equals(type)
|
|
|
&& (MagicValues.SE.equals(groupCode) || MagicValues.SI.equals(groupCode) || MagicValues.AE.equals(groupCode) || MagicValues.AI.equals(groupCode))) {
|
|
|
List<Bills> list = new ArrayList<>();
|
|
|
Amends amends = amendsService.getById(billId);
|
|
|
@@ -2161,7 +3008,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
|
|
|
} else {
|
|
|
map.put(MagicValues.DATA, list);
|
|
|
}
|
|
|
- }else if (MagicValues.BUSINESS.equals(reportCode) && MagicValues.SALES_REPORT.equals(groupCode) && (MagicValues.KYCK.equals(type) || MagicValues.KYJK.equals(type))) {
|
|
|
+ } else if (MagicValues.BUSINESS.equals(reportCode) && MagicValues.SALES_REPORT.equals(groupCode) && (MagicValues.KYCK.equals(type) || MagicValues.KYJK.equals(type))) {
|
|
|
List<AeaBills> list = new ArrayList<>();
|
|
|
AeaBills bills = aeaBillsService.getById(billId);
|
|
|
if (bills != null) {
|