|
|
@@ -21,12 +21,11 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.los.Util.BigDecimalUtils;
|
|
|
import org.springblade.los.Util.CurrencyUtils;
|
|
|
import org.springblade.los.Util.MagicValues;
|
|
|
import org.springblade.los.basic.corps.entity.BCorps;
|
|
|
-import org.springblade.los.basic.corps.entity.BCorpsBank;
|
|
|
-import org.springblade.los.basic.corps.service.IBCorpsBankService;
|
|
|
import org.springblade.los.basic.corps.service.IBCorpsService;
|
|
|
import org.springblade.los.basic.cur.entity.BCurExrate;
|
|
|
import org.springblade.los.basic.reports.service.IReportsBoxService;
|
|
|
@@ -36,6 +35,7 @@ import org.springblade.los.box.entity.TradingBox;
|
|
|
import org.springblade.los.box.service.IExpenseApplicationService;
|
|
|
import org.springblade.los.box.service.ITradingBoxService;
|
|
|
import org.springblade.los.business.amends.entity.Amends;
|
|
|
+import org.springblade.los.business.amends.mapper.AmendsMapper;
|
|
|
import org.springblade.los.business.mktSlot.entity.MktSlot;
|
|
|
import org.springblade.los.business.mktSlot.entity.MktSlotItem;
|
|
|
import org.springblade.los.business.mktSlot.entity.MktSlotQuotation;
|
|
|
@@ -45,7 +45,6 @@ import org.springblade.los.business.mktSlot.service.IMktSlotService;
|
|
|
import org.springblade.los.business.receipt.entity.Receipt;
|
|
|
import org.springblade.los.business.receipt.service.IReceiptService;
|
|
|
import org.springblade.los.business.sea.entity.Bills;
|
|
|
-import org.springblade.los.business.sea.entity.Containers;
|
|
|
import org.springblade.los.business.sea.entity.SeaBillsDetail;
|
|
|
import org.springblade.los.business.sea.service.IBillsService;
|
|
|
import org.springblade.los.business.sea.service.ISeaBillsDetailService;
|
|
|
@@ -53,12 +52,16 @@ import org.springblade.los.finance.fee.dto.ExpenseApplicationFeeReports;
|
|
|
import org.springblade.los.finance.fee.dto.FeeCenterReports;
|
|
|
import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
import org.springblade.los.finance.fee.entity.FeeCenterItems;
|
|
|
+import org.springblade.los.finance.fee.mapper.FinAccBillsMapper;
|
|
|
import org.springblade.los.finance.fee.service.IFeeCenterItemsService;
|
|
|
import org.springblade.los.finance.fee.service.IFeeCenterService;
|
|
|
import org.springblade.los.finance.operatingExpenses.entity.OperatingExpenses;
|
|
|
import org.springblade.los.finance.operatingExpenses.entity.OperatingExpensesItem;
|
|
|
import org.springblade.los.finance.operatingExpenses.service.IOperatingExpensesItemService;
|
|
|
import org.springblade.los.finance.operatingExpenses.service.IOperatingExpensesService;
|
|
|
+import org.springblade.los.statisticAnalysis.*;
|
|
|
+import org.springblade.los.view.entity.FinanceProfit;
|
|
|
+import org.springblade.los.view.mapper.FinanceProfitMapper;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
import org.springblade.system.entity.DictBiz;
|
|
|
import org.springblade.system.feign.IDictBizClient;
|
|
|
@@ -118,7 +121,11 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
|
|
|
|
|
|
private final IReceiptService receiptService;
|
|
|
|
|
|
- private final IBCorpsBankService bankService;
|
|
|
+ private final FinAccBillsMapper finAccBillsMapper;
|
|
|
+
|
|
|
+ private final FinanceProfitMapper financeProfitMapper;
|
|
|
+
|
|
|
+ private final AmendsMapper amendsMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -525,7 +532,7 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
|
|
|
}
|
|
|
} else if (MagicValues.COST.equals(reportCode) &&
|
|
|
(MagicValues.RECEIVABLE_BILL.equals(groupCode) || MagicValues.RECEIVABLE.equals(groupCode)) &&
|
|
|
- MagicValues.XGFY.equals(type) ) {
|
|
|
+ MagicValues.XGFY.equals(type)) {
|
|
|
TradingBox bills = tradingBoxService.getById(billId);
|
|
|
if (bills != null) {
|
|
|
String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
|
|
|
@@ -558,7 +565,7 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
|
|
|
}
|
|
|
} else if (MagicValues.COST.equals(reportCode) &&
|
|
|
(MagicValues.MEET.equals(groupCode) || MagicValues.MEET_BILL.equals(groupCode)) &&
|
|
|
- MagicValues.XGFY.equals(type) ) {
|
|
|
+ MagicValues.XGFY.equals(type)) {
|
|
|
TradingBox bills = tradingBoxService.getById(billId);
|
|
|
if (bills != null) {
|
|
|
String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
|
|
|
@@ -588,15 +595,458 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
|
|
|
} else {
|
|
|
map.put(MagicValues.DATA, null);
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
map.put(MagicValues.DATA, null);
|
|
|
}
|
|
|
return R.data(map);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R getReportDataStatistics(ReportDataStatisticsVO reportDataStatisticsVO) {
|
|
|
- return null;
|
|
|
+ public R getReportDataStatistics(ReportDataStatisticsVO reportDataStatisticsVO) throws ParseException {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> mapData = new HashMap<>();
|
|
|
+ mapData.put("etdStart", reportDataStatisticsVO.getEtdStart());
|
|
|
+ mapData.put("etdEnd", reportDataStatisticsVO.getEtdEnd());
|
|
|
+ mapData.put("user", AuthUtil.getUserName());
|
|
|
+ R<Dept> res = sysClient.getDept(Long.parseLong(AuthUtil.getDeptId()));
|
|
|
+ Dept dept;
|
|
|
+ if (res.isSuccess() && res.getData() != null) {
|
|
|
+ dept = res.getData();
|
|
|
+ String status = sysClient.getParamService("is.update.default");
|
|
|
+ if ("1".equals(status)) {
|
|
|
+ R<User> resUser = userClient.userInfoById(AuthUtil.getUserId());
|
|
|
+ if (resUser.isSuccess() && resUser.getData() != null) {
|
|
|
+ dept.setEmail(resUser.getData().getEmail());
|
|
|
+ dept.setTel(resUser.getData().getPhone());
|
|
|
+ dept.setContacts(resUser.getData().getRealName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("获取报表表头数据失败");
|
|
|
+ }
|
|
|
+ mapData.put("dept", dept);
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ List<FinanceStatisticsReport> financeStatisticsReportList = new ArrayList<>();
|
|
|
+ if (MagicValues.PAYMENT_DETAILS.equals(reportDataStatisticsVO.getReportCode()) &&
|
|
|
+ MagicValues.STATISTICS.equals(reportDataStatisticsVO.getGroupCode()) &&
|
|
|
+ MagicValues.DECISION_ANALYSIS.equals(reportDataStatisticsVO.getReportType())) {
|
|
|
+ FeeSummaryQ feeSummaryQ = new FeeSummaryQ();
|
|
|
+ BeanUtil.copyProperties(reportDataStatisticsVO, feeSummaryQ);
|
|
|
+ feeSummaryQ.setTenantId(AuthUtil.getTenantId());
|
|
|
+ if (!AuthUtil.getUserRole().contains("总部") && !AuthUtil.getUserRole().contains("admin")) {
|
|
|
+ feeSummaryQ.setBranchId(AuthUtil.getDeptId());
|
|
|
+ feeSummaryQ.setBillType("MH,DD");
|
|
|
+ }
|
|
|
+ List<FeeSummaryDetailRD> feeSummaryDetailList = finAccBillsMapper.feeSummaryDetailExportList(feeSummaryQ);
|
|
|
+ List<Bills> billsList = new ArrayList<>();
|
|
|
+ if (!feeSummaryDetailList.isEmpty()) {
|
|
|
+ List<String> mblnoList = feeSummaryDetailList.stream().filter(e -> ObjectUtils.isNotNull(e.getMblNo()) &&
|
|
|
+ ObjectUtils.isNull(e.getHblNo()) && "SE,SI,SEA,SIA".contains(e.getBusinessType())).map(FeeSummaryDetailRD::getMblNo)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ if (!mblnoList.isEmpty()) {
|
|
|
+ List<Bills> mblnoBillsList = billsService.list(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(Bills::getMblno, mblnoList));
|
|
|
+ if (!mblnoBillsList.isEmpty()) {
|
|
|
+ billsList.addAll(mblnoBillsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> hblnoList = feeSummaryDetailList.stream().filter(e -> ObjectUtils.isNotNull(e.getMblNo()) &&
|
|
|
+ ObjectUtils.isNotNull(e.getHblNo()) && "SE,SI,SEA,SIA".contains(e.getBusinessType())).map(FeeSummaryDetailRD::getHblNo)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ if (!mblnoList.isEmpty()) {
|
|
|
+ List<Bills> hblnoBillsList = billsService.list(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(Bills::getHblno, hblnoList));
|
|
|
+ if (!hblnoBillsList.isEmpty()) {
|
|
|
+ billsList.addAll(hblnoBillsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (FeeSummaryDetailRD item : feeSummaryDetailList) {
|
|
|
+ FinanceStatisticsReport report = new FinanceStatisticsReport();
|
|
|
+ report.setCorpName(item.getCorpName());
|
|
|
+ report.setBillNo(item.getBillNo());
|
|
|
+ if (!billsList.isEmpty()) {
|
|
|
+ Bills bills;
|
|
|
+ if (ObjectUtils.isNotNull(item.getMblNo()) &&
|
|
|
+ ObjectUtils.isNull(item.getHblNo()) && "SE,SI,SEA,SIA".contains(item.getBusinessType())) {
|
|
|
+ bills = billsList.stream().filter(e -> e.getMblno().equals(item.getMblNo())
|
|
|
+ && ObjectUtils.isNull(item.getHblNo()) && "SE,SI,SEA,SIA".contains(item.getBusinessType()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ } else if (ObjectUtils.isNotNull(item.getMblNo()) &&
|
|
|
+ ObjectUtils.isNotNull(item.getHblNo()) && "SE,SI,SEA,SIA".contains(item.getBusinessType())) {
|
|
|
+ bills = billsList.stream().filter(e -> e.getHblno().equals(item.getHblNo()) && "SE,SI,SEA,SIA".contains(item.getBusinessType()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ } else {
|
|
|
+ bills = null;
|
|
|
+ }
|
|
|
+ if (bills != null) {
|
|
|
+ report.setVesselName(bills.getVesselCnName());
|
|
|
+ report.setVoyageNo(bills.getVoyageNo());
|
|
|
+ BigDecimal exrate = new BigDecimal("1");
|
|
|
+ if ("SE".equals(bills.getBusinessType()) || "SEA".equals(bills.getBusinessType())) {
|
|
|
+ if (ObjectUtils.isNotNull(bills.getActualEtd())) {
|
|
|
+ List<BCurExrate> curExrateList = currencyUtils.obtainRate(bills.getActualEtd(), "1", bills.getBranchId());
|
|
|
+ exrate = currencyUtils.obtainExrate(reportDataStatisticsVO.getDc(), curExrateList, "USD", "1");
|
|
|
+ report.setEtd(formatter.format(bills.getActualEtd()));
|
|
|
+ }
|
|
|
+ } else if ("SI".equals(bills.getBusinessType()) || "SIA".equals(bills.getBusinessType())) {
|
|
|
+ if (ObjectUtils.isNotNull(bills.getActualEta())) {
|
|
|
+ List<BCurExrate> curExrateList = currencyUtils.obtainRate(bills.getActualEta(), "1", bills.getBranchId());
|
|
|
+ exrate = currencyUtils.obtainExrate(reportDataStatisticsVO.getDc(), curExrateList, "USD", "1");
|
|
|
+ report.setEtd(formatter.format(bills.getActualEta()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ report.setHblNo(bills.getHblno());
|
|
|
+ report.setPol(bills.getPolCnName());
|
|
|
+ report.setPod(bills.getPodCnName());
|
|
|
+ report.setExrate(exrate);
|
|
|
+ report.setQuantityCntrDescr(bills.getQuantityCntrDescr());
|
|
|
+ report.setSalesman(bills.getSrcCnName());
|
|
|
+ report.setOperatorName(bills.getOperatorName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ report.setAmountUsd(item.getAmountUsd());
|
|
|
+ report.setAmount(item.getAmount());
|
|
|
+ report.setAmountInvoicingUsd(item.getAmountInvoicingUsd());
|
|
|
+ report.setAmountInvoicing(item.getAmountInvoicing());
|
|
|
+ report.setAmountInvoicingUsdNot(item.getAmountInvoicingUsdNot());
|
|
|
+ report.setAmountInvoicingNot(item.getAmountInvoicingNot());
|
|
|
+ financeStatisticsReportList.add(report);
|
|
|
+ }
|
|
|
+ if (!financeStatisticsReportList.isEmpty()) {
|
|
|
+ mapData.put(MagicValues.DATA, financeStatisticsReportList);
|
|
|
+ } else {
|
|
|
+ mapData.put(MagicValues.DATA, new ArrayList<>());
|
|
|
+ }
|
|
|
+ } else if (MagicValues.NOT_PAYMENT_DETAILS.equals(reportDataStatisticsVO.getReportCode()) &&
|
|
|
+ MagicValues.STATISTICS.equals(reportDataStatisticsVO.getGroupCode()) &&
|
|
|
+ MagicValues.DECISION_ANALYSIS.equals(reportDataStatisticsVO.getReportType())) {
|
|
|
+ FeeSummaryQ feeSummaryQ = new FeeSummaryQ();
|
|
|
+ BeanUtil.copyProperties(reportDataStatisticsVO, feeSummaryQ);
|
|
|
+ feeSummaryQ.setTenantId(AuthUtil.getTenantId());
|
|
|
+ if (!AuthUtil.getUserRole().contains("总部") && !AuthUtil.getUserRole().contains("admin")) {
|
|
|
+ if (AuthUtil.getUserRole().contains("secondaryAdmin")) {
|
|
|
+ feeSummaryQ.setBillBranchId(AuthUtil.getDeptId());
|
|
|
+ feeSummaryQ.setBranchId(null);
|
|
|
+ } else {
|
|
|
+ feeSummaryQ.setBranchId(AuthUtil.getDeptId());
|
|
|
+ }
|
|
|
+ feeSummaryQ.setBillType("MH,DD");
|
|
|
+ }
|
|
|
+ List<FeeSummaryDetailNotRD> feeSummaryDetailExportNotList = finAccBillsMapper.feeSummaryDetailExportNotList(feeSummaryQ);
|
|
|
+ for (FeeSummaryDetailNotRD item : feeSummaryDetailExportNotList) {
|
|
|
+ item.setAmountnvoicingOther(item.getAmountnvoicingHKD().add(item.getAmountnvoicingSGD()).add(item.getAmountnvoicingVND()));
|
|
|
+ item.setAmountnvoicingOtherNot(item.getAmountnvoicingHKDNot().add(item.getAmountnvoicingSGDNot()).add(item.getAmountnvoicingVNDNot()));
|
|
|
+ item.setAmountOtherNot(item.getAmountHKDNot().add(item.getAmountSGDNot()).add(item.getAmountVNDNot()));
|
|
|
+ }
|
|
|
+ List<Bills> billsList = new ArrayList<>();
|
|
|
+ if (!feeSummaryDetailExportNotList.isEmpty()) {
|
|
|
+ List<String> mblnoList = feeSummaryDetailExportNotList.stream().filter(e -> ObjectUtils.isNotNull(e.getMblNo()) &&
|
|
|
+ ObjectUtils.isNull(e.getHblNo()) && "SE,SI,SEA,SIA".contains(e.getBusinessType())).map(FeeSummaryDetailNotRD::getMblNo)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ if (!mblnoList.isEmpty()) {
|
|
|
+ List<Bills> mblnoBillsList = billsService.list(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(Bills::getMblno, mblnoList));
|
|
|
+ if (!mblnoBillsList.isEmpty()) {
|
|
|
+ billsList.addAll(mblnoBillsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> hblnoList = feeSummaryDetailExportNotList.stream().filter(e -> ObjectUtils.isNotNull(e.getMblNo()) &&
|
|
|
+ ObjectUtils.isNotNull(e.getHblNo()) && "SE,SI,SEA,SIA".contains(e.getBusinessType())).map(FeeSummaryDetailNotRD::getHblNo)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ if (!mblnoList.isEmpty()) {
|
|
|
+ List<Bills> hblnoBillsList = billsService.list(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(Bills::getHblno, hblnoList));
|
|
|
+ if (!hblnoBillsList.isEmpty()) {
|
|
|
+ billsList.addAll(hblnoBillsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (FeeSummaryDetailNotRD item : feeSummaryDetailExportNotList) {
|
|
|
+ FinanceStatisticsReport report = new FinanceStatisticsReport();
|
|
|
+ report.setCorpName(item.getCorpName());
|
|
|
+ report.setBillNo(item.getBillNo());
|
|
|
+ if (!billsList.isEmpty()) {
|
|
|
+ Bills bills;
|
|
|
+ if (ObjectUtils.isNotNull(item.getMblNo()) &&
|
|
|
+ ObjectUtils.isNull(item.getHblNo()) && "SE,SI,SEA,SIA".contains(item.getBusinessType())) {
|
|
|
+ bills = billsList.stream().filter(e -> e.getMblno().equals(item.getMblNo())
|
|
|
+ && ObjectUtils.isNull(item.getHblNo()) && "SE,SI,SEA,SIA".contains(item.getBusinessType()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ } else if (ObjectUtils.isNotNull(item.getMblNo()) &&
|
|
|
+ ObjectUtils.isNotNull(item.getHblNo()) && "SE,SI,SEA,SIA".contains(item.getBusinessType())) {
|
|
|
+ bills = billsList.stream().filter(e -> e.getHblno().equals(item.getHblNo()) && "SE,SI,SEA,SIA".contains(item.getBusinessType()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ } else {
|
|
|
+ bills = null;
|
|
|
+ }
|
|
|
+ if (bills != null) {
|
|
|
+ report.setVesselName(bills.getVesselCnName());
|
|
|
+ report.setVoyageNo(bills.getVoyageNo());
|
|
|
+ BigDecimal exrate = new BigDecimal("1");
|
|
|
+ if ("SE".equals(bills.getBusinessType()) || "SEA".equals(bills.getBusinessType())) {
|
|
|
+ if (ObjectUtils.isNotNull(bills.getActualEtd())) {
|
|
|
+ List<BCurExrate> curExrateList = currencyUtils.obtainRate(bills.getActualEtd(), "1", bills.getBranchId());
|
|
|
+ exrate = currencyUtils.obtainExrate(reportDataStatisticsVO.getDc(), curExrateList, "USD", "1");
|
|
|
+ report.setEtd(formatter.format(bills.getActualEtd()));
|
|
|
+ }
|
|
|
+ } else if ("SI".equals(bills.getBusinessType()) || "SIA".equals(bills.getBusinessType())) {
|
|
|
+ if (ObjectUtils.isNotNull(bills.getActualEta())) {
|
|
|
+ List<BCurExrate> curExrateList = currencyUtils.obtainRate(bills.getActualEta(), "1", bills.getBranchId());
|
|
|
+ exrate = currencyUtils.obtainExrate(reportDataStatisticsVO.getDc(), curExrateList, "USD", "1");
|
|
|
+ report.setEtd(formatter.format(bills.getActualEta()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ report.setHblNo(bills.getHblno());
|
|
|
+ report.setPol(bills.getPolCnName());
|
|
|
+ report.setPod(bills.getPodCnName());
|
|
|
+ report.setExrate(exrate);
|
|
|
+ report.setQuantityCntrDescr(bills.getQuantityCntrDescr());
|
|
|
+ report.setSalesman(bills.getSrcCnName());
|
|
|
+ report.setOperatorName(bills.getOperatorName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ report.setAmountUsd(item.getAmountUsdNot());
|
|
|
+ report.setAmount(item.getAmountNot());
|
|
|
+ report.setAmountInvoicingUsd(item.getAmountInvoicingUsd());
|
|
|
+ report.setAmountInvoicing(item.getAmountInvoicing());
|
|
|
+ report.setAmountInvoicingUsdNot(item.getAmountInvoicingUsdNot());
|
|
|
+ report.setAmountInvoicingNot(item.getAmountInvoicingNot());
|
|
|
+ financeStatisticsReportList.add(report);
|
|
|
+ }
|
|
|
+ if (!financeStatisticsReportList.isEmpty()) {
|
|
|
+ mapData.put(MagicValues.DATA, financeStatisticsReportList);
|
|
|
+ } else {
|
|
|
+ mapData.put(MagicValues.DATA, new ArrayList<>());
|
|
|
+ }
|
|
|
+ } else if (MagicValues.OPERATING_PROFIT.equals(reportDataStatisticsVO.getReportCode()) &&
|
|
|
+ MagicValues.STATISTICS.equals(reportDataStatisticsVO.getGroupCode()) &&
|
|
|
+ MagicValues.DECISION_ANALYSIS.equals(reportDataStatisticsVO.getReportType())) {
|
|
|
+ FinanceProfitDtoList financeProfit = new FinanceProfitDtoList();
|
|
|
+ BeanUtil.copyProperties(reportDataStatisticsVO, financeProfit);
|
|
|
+ financeProfit.setTenantId(AuthUtil.getTenantId());
|
|
|
+ if (!AuthUtil.getUserRole().contains("总部") && !AuthUtil.getUserRole().contains("admin")) {
|
|
|
+ financeProfit.setBranchId(AuthUtil.getDeptId());
|
|
|
+ financeProfit.setBillType("MH,DD");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(financeProfit.getExamineDate()) && "0".equals(financeProfit.getExamineDate())) {
|
|
|
+ financeProfit.setExamineDate(null);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(financeProfit.getExamine()) && "0".equals(financeProfit.getExamine())) {
|
|
|
+ financeProfit.setExamine(null);
|
|
|
+ }
|
|
|
+ List<FinanceProfitDtoList> financeProfitList;
|
|
|
+ //是否合并amend费用 true 合并 false 不合并
|
|
|
+ if (ObjectUtils.isNotNull(financeProfit.getMergeAmendFee())) {
|
|
|
+ financeProfitList = financeProfitMapper.financeProfitListSum(financeProfit);
|
|
|
+ String mblno = financeProfitList.stream().map(FinanceProfitDtoList::getMblNo).filter(Objects::nonNull).distinct().collect(Collectors.joining(","));
|
|
|
+ LambdaQueryWrapper<Amends> lambdaQueryWrapper = new LambdaQueryWrapper<Amends>()
|
|
|
+ .eq(Amends::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Amends::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(mblno,'" + mblno + "')");
|
|
|
+ if (ObjectUtils.isNotNull(financeProfit.getExamine())) {
|
|
|
+ lambdaQueryWrapper.eq(Amends::getStatus, 3);
|
|
|
+ }
|
|
|
+ List<Amends> amendsList = amendsMapper.selectList(lambdaQueryWrapper);
|
|
|
+ List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
+ if (!amendsList.isEmpty()) {
|
|
|
+ List<Long> pids = amendsList.stream().map(Amends::getId).collect(Collectors.toList());
|
|
|
+ if (!pids.isEmpty()) {
|
|
|
+ feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .in(FeeCenter::getPid, pids));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (FinanceProfitDtoList item : financeProfitList) {
|
|
|
+ item.setRealAmountCr(item.getRealAmountCr() == null ? new BigDecimal("0.00") : item.getRealAmountCr());
|
|
|
+ item.setAmountCrUsd(item.getAmountCrUsd() == null ? new BigDecimal("0.00") : item.getAmountCrUsd());
|
|
|
+ item.setRealAmountCrUsd(item.getRealAmountCrUsd() == null ? new BigDecimal("0.00") : item.getRealAmountCrUsd());
|
|
|
+ item.setAmountCrLoc(item.getAmountCrLoc() == null ? new BigDecimal("0.00") : item.getAmountCrLoc());
|
|
|
+ item.setRealAmountCrLoc(item.getRealAmountCrLoc() == null ? new BigDecimal("0.00") : item.getRealAmountCrLoc());
|
|
|
+ item.setAmountDr(item.getAmountDr() == null ? new BigDecimal("0.00") : item.getAmountDr());
|
|
|
+ item.setRealAmountDr(item.getRealAmountDr() == null ? new BigDecimal("0.00") : item.getRealAmountDr());
|
|
|
+ item.setAmountDrUsd(item.getAmountDrUsd() == null ? new BigDecimal("0.00") : item.getAmountDrUsd());
|
|
|
+ item.setRealAmountDrUsd(item.getRealAmountDrUsd() == null ? new BigDecimal("0.00") : item.getRealAmountDrUsd());
|
|
|
+ item.setAmountDrLoc(item.getAmountDrLoc() == null ? new BigDecimal("0.00") : item.getAmountDrLoc());
|
|
|
+ item.setRealAmountDrLoc(item.getRealAmountDrLoc() == null ? new BigDecimal("0.00") : item.getRealAmountDrLoc());
|
|
|
+ item.setAmountProfitLoc(item.getAmountProfitLoc() == null ? new BigDecimal("0.00") : item.getAmountProfitLoc());
|
|
|
+ item.setRealAmountProfitLoc(item.getRealAmountProfitLoc() == null ? new BigDecimal("0.00") : item.getRealAmountProfitLoc());
|
|
|
+ if (!amendsList.isEmpty() && !feeCenterList.isEmpty()) {
|
|
|
+ //获取当前业务类型所有amend
|
|
|
+ List<Amends> amends = amendsList.stream().filter(e -> e.getMblno().equals(item.getMblNo())).collect(Collectors.toList());
|
|
|
+ for (Amends i : amends) {
|
|
|
+ //人民币应收金额
|
|
|
+ BigDecimal feeCentersCD = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "CNY".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //人民币实收金额
|
|
|
+ BigDecimal feeCentersCDReal = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "CNY".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //人民币应付金额
|
|
|
+ BigDecimal feeCentersCC = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "CNY".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //人民币实付金额
|
|
|
+ BigDecimal feeCentersCCReal = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "CNY".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //美金应收金额
|
|
|
+ BigDecimal feeCentersUD = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "USD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //美金实收金额
|
|
|
+ BigDecimal feeCentersUDReal = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "USD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //美金应付金额
|
|
|
+ BigDecimal feeCentersUC = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "USD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //美金实付金额
|
|
|
+ BigDecimal feeCentersUCReal = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "USD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //应收合计金额
|
|
|
+ BigDecimal feeCentersUDLoc = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmountLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //实收合计金额
|
|
|
+ BigDecimal feeCentersUDRealLoc = feeCenterList.stream().filter(e -> i.getId().equals(e.getPid()) && "D".equals(e.getDc()))
|
|
|
+ .reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getStlTtlAmount().multiply(y.getExrate())), BigDecimal::add)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //应付合计金额
|
|
|
+ BigDecimal feeCentersUCLoc = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmountLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //实付合计金额
|
|
|
+ BigDecimal feeCentersUCRealLoc = feeCenterList.stream().filter(e -> i.getId().equals(e.getPid()) && "C".equals(e.getDc()))
|
|
|
+ .reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getStlTtlAmount().multiply(y.getExrate())), BigDecimal::add)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal oceanFreightDr = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "HYF".equals(e.getFeeCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal oceanFreightCr = feeCenterList.stream()
|
|
|
+ .filter(e -> i.getId().equals(e.getPid()) && "HYF".equals(e.getFeeCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal oceanFreightProfit = oceanFreightDr.subtract(oceanFreightCr);
|
|
|
+ item.setOceanFreightCr(item.getOceanFreightCr().add(oceanFreightCr));
|
|
|
+ item.setOceanFreightDr(item.getOceanFreightDr().add(oceanFreightDr));
|
|
|
+ item.setOceanFreightProfit(item.getOceanFreightProfit().add(oceanFreightProfit));
|
|
|
+ item.setAmountCr(item.getAmountCr().add(feeCentersCC));
|
|
|
+ item.setRealAmountCr(item.getRealAmountCr().add(feeCentersCCReal));
|
|
|
+ item.setAmountCrUsd(item.getAmountCrUsd().add(feeCentersUC));
|
|
|
+ item.setRealAmountCrUsd(item.getRealAmountCrUsd().add(feeCentersUCReal));
|
|
|
+ item.setAmountCrLoc(item.getAmountCrLoc().add(feeCentersUCLoc));
|
|
|
+ item.setRealAmountCrLoc(item.getRealAmountCrLoc().add(feeCentersUCRealLoc));
|
|
|
+ item.setAmountDr(item.getAmountDr().add(feeCentersCD));
|
|
|
+ item.setRealAmountDr(item.getRealAmountDr().add(feeCentersCDReal));
|
|
|
+ item.setAmountDrUsd(item.getAmountDrUsd().add(feeCentersUD));
|
|
|
+ item.setRealAmountDrUsd(item.getRealAmountDrUsd().add(feeCentersUDReal));
|
|
|
+ item.setAmountDrLoc(item.getAmountDrLoc().add(feeCentersUDLoc));
|
|
|
+ item.setRealAmountDrLoc(item.getRealAmountDrLoc().add(feeCentersUDRealLoc));
|
|
|
+ item.setAmountProfitLoc(item.getAmountDrLoc().subtract(item.getAmountCrLoc()).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ item.setRealAmountProfitLoc(item.getRealAmountDrLoc().subtract(item.getRealAmountCrLoc()).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ item.setRealAmountProfitLoc(item.getRealAmountDrLoc().subtract(item.getRealAmountCrLoc()).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNotNull(financeProfit.getBusinessType()) &&
|
|
|
+ (financeProfit.getBusinessType().contains("SE") || financeProfit.getBusinessType().contains("SI"))) {
|
|
|
+ financeProfit.setBusinessType(financeProfit.getBusinessType() + ",SEA,SIA,AEA,AIA");
|
|
|
+ }
|
|
|
+ financeProfitList = financeProfitMapper.financeProfitListSum(financeProfit);
|
|
|
+ }
|
|
|
+ List<FinanceProfit> financeProfitDataList = new ArrayList<>();
|
|
|
+ List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
+ if (!financeProfitList.isEmpty()) {
|
|
|
+ String mblNo = financeProfitList.stream().map(FinanceProfitDtoList::getMblNo).distinct().collect(Collectors.joining(","));
|
|
|
+ financeProfitDataList = financeProfitMapper.selectList(new LambdaQueryWrapper<FinanceProfit>()
|
|
|
+ .apply("find_in_set(mblno,'" + mblNo + "')")
|
|
|
+ .apply("find_in_set(business_type,'SE,SI,AE,AI')")
|
|
|
+ );
|
|
|
+ List<Long> idList = financeProfitList.stream().map(FinanceProfitDtoList::getId).distinct().collect(Collectors.toList());
|
|
|
+ if (!financeProfitDataList.isEmpty()) {
|
|
|
+ idList.addAll(financeProfitDataList.stream().map(FinanceProfit::getId).distinct().collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .in(FeeCenter::getPid, idList));
|
|
|
+ }
|
|
|
+ for (FinanceProfitDtoList item : financeProfitList) {
|
|
|
+ if (("SEA".equals(item.getBusinessType()) || "SIA".equals(item.getBusinessType())
|
|
|
+ || "AEA".equals(item.getBusinessType()) || "AIA".equals(item.getBusinessType()))
|
|
|
+ && !financeProfitDataList.isEmpty()) {
|
|
|
+ FinanceProfit profit = financeProfitDataList.stream().filter(e -> e.getMblno().equals(item.getMblNo())).findFirst().orElse(null);
|
|
|
+ if (profit != null) {
|
|
|
+ item.setSalesman(profit.getSrcCnName());
|
|
|
+ item.setAccDeptName(profit.getAccDeptName());
|
|
|
+ item.setLineCnName(profit.getLineCnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!feeCenterList.isEmpty()) {
|
|
|
+ List<FeeCenter> feeCenters = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId())).collect(Collectors.toList());
|
|
|
+ if (!feeCenters.isEmpty()) {
|
|
|
+ assignment(feeCenters, item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FinanceStatisticsReport report = new FinanceStatisticsReport();
|
|
|
+ report.setCorpName(item.getCorpName());
|
|
|
+ report.setBillNo(item.getBillNo());
|
|
|
+ report.setVesselName(item.getVesselCnName());
|
|
|
+ report.setVoyageNo(item.getVoyageNo());
|
|
|
+ BigDecimal exrate = new BigDecimal("1");
|
|
|
+ if (ObjectUtils.isNotNull(item.getStatisticsDate())) {
|
|
|
+ /*List<BCurExrate> curExrateList = currencyUtils.obtainRate(formatter.parse(item.getStatisticsDate()), "1", item.getBranchId());
|
|
|
+ exrate = currencyUtils.obtainExrate(reportDataStatisticsVO.getDc(), curExrateList, "USD", "1");
|
|
|
+ report.setEtd(formatter.format(formatter.parse(item.getStatisticsDate())));*/
|
|
|
+ }
|
|
|
+ report.setHblNo(item.getHblNo());
|
|
|
+ report.setPol(item.getPol());
|
|
|
+ report.setPod(item.getPod());
|
|
|
+ report.setExrate(exrate);
|
|
|
+ report.setQuantityCntrDescr(item.getQuantityCntrDescr());
|
|
|
+ report.setSalesman(item.getSalesman());
|
|
|
+ report.setOperatorName(item.getOperatorName());
|
|
|
+ report.setAmountDr(item.getAmountDr());
|
|
|
+ report.setRealAmountDr(item.getRealAmountDr());
|
|
|
+ report.setNotReceivedDr(item.getNotReceivedDr());
|
|
|
+ report.setAmountDrUsd(item.getAmountDrUsd());
|
|
|
+ report.setRealAmountDrUsd(item.getRealAmountDrUsd());
|
|
|
+ report.setNotReceivedDrUsd(item.getNotReceivedDrUsd());
|
|
|
+ report.setAmountCr(item.getAmountCr());
|
|
|
+ report.setRealAmountCr(item.getRealAmountCr());
|
|
|
+ report.setNotReceivedCr(item.getNotReceivedCr());
|
|
|
+ report.setAmountCrUsd(item.getAmountCrUsd());
|
|
|
+ report.setRealAmountCrUsd(item.getRealAmountCrUsd());
|
|
|
+ report.setNotReceivedCrUsd(item.getNotReceivedCrUsd());
|
|
|
+ report.setAmountProfit(item.getAmountProfit());
|
|
|
+ report.setAmountProfitUsd(item.getAmountProfitUsd());
|
|
|
+ report.setOceanFreightDr(item.getOceanFreightDr());
|
|
|
+ report.setOceanFreightCr(item.getOceanFreightCr());
|
|
|
+ report.setOceanFreightProfit(item.getOceanFreightProfit());
|
|
|
+ financeStatisticsReportList.add(report);
|
|
|
+ }
|
|
|
+ if (!financeStatisticsReportList.isEmpty()) {
|
|
|
+ mapData.put(MagicValues.DATA, financeStatisticsReportList);
|
|
|
+ } else {
|
|
|
+ mapData.put(MagicValues.DATA, new ArrayList<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put(MagicValues.DATA, mapData);
|
|
|
+ return R.data(map);
|
|
|
}
|
|
|
|
|
|
private TradingBox assignmentDc(TradingBox bills, List<FeeCenter> feeCenterList, String curCode, String exrateType, List<BCurExrate> curExrateList) {
|
|
|
@@ -792,4 +1242,174 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
|
|
|
}
|
|
|
return bills;
|
|
|
}
|
|
|
+
|
|
|
+ private FinanceProfitDtoList assignment(List<FeeCenter> feeCenters, FinanceProfitDtoList item) {
|
|
|
+ //应收人民币
|
|
|
+ BigDecimal amountDr = feeCenters.stream().filter(e -> "CNY".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDr(amountDr.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实收人民币
|
|
|
+ BigDecimal realAmountDr = feeCenters.stream().filter(e -> "CNY".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountDr(realAmountDr.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未收人民币
|
|
|
+ item.setNotReceivedDr(amountDr.subtract(realAmountDr));
|
|
|
+ //应收美元
|
|
|
+ BigDecimal amountDrUsd = feeCenters.stream().filter(e -> "USD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDrUsd(amountDrUsd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实收美元
|
|
|
+ BigDecimal realAmountDrUsd = feeCenters.stream().filter(e -> "USD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountDrUsd(realAmountDrUsd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未收美元
|
|
|
+ item.setNotReceivedDrUsd(amountDrUsd.subtract(realAmountDrUsd));
|
|
|
+ //应收HKD
|
|
|
+ BigDecimal amountDrHkd = feeCenters.stream().filter(e -> "HKD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDrHkd(amountDrHkd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实收HKD
|
|
|
+ BigDecimal realAmountDrHkd = feeCenters.stream().filter(e -> "HKD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountDrHkd(realAmountDrHkd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未收HKD
|
|
|
+ item.setNotReceivedDrHkd(amountDrHkd.subtract(amountDrHkd));
|
|
|
+ //应收VND
|
|
|
+ BigDecimal amountDrVnd = feeCenters.stream().filter(e -> "VND".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDrVnd(amountDrVnd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实收VND
|
|
|
+ BigDecimal realAmountDrVnd = feeCenters.stream().filter(e -> "VND".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountDrVnd(realAmountDrVnd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未收VND
|
|
|
+ item.setNotReceivedDrVnd(amountDrVnd.subtract(realAmountDrVnd));
|
|
|
+ //应收SGD
|
|
|
+ BigDecimal amountDrSgd = feeCenters.stream().filter(e -> "SGD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDrSgd(amountDrSgd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实收SGD
|
|
|
+ BigDecimal realAmountDrSgd = feeCenters.stream().filter(e -> "SGD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountDrSgd(realAmountDrSgd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未收SGD
|
|
|
+ item.setNotReceivedDrSgd(amountDrSgd.subtract(realAmountDrSgd));
|
|
|
+ //应收其他
|
|
|
+ BigDecimal amountDrOther = feeCenters.stream().filter(e -> !"CNY,USD".contains(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDrOther(amountDrOther.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实收其他
|
|
|
+ BigDecimal realAmountDrOther = feeCenters.stream().filter(e -> !"CNY,USD".contains(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountDrOther(realAmountDrOther.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未收其他
|
|
|
+ item.setNotReceivedDrOther(amountDrOther.subtract(realAmountDrOther));
|
|
|
+ //合计应收
|
|
|
+ BigDecimal amountDrLoc = feeCenters.stream().filter(e -> "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDrLoc(amountDrLoc.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实际合计应收
|
|
|
+ BigDecimal realAmountDrLoc = feeCenters.stream().filter(e -> "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountDrLoc(realAmountDrLoc.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未收合计
|
|
|
+ item.setNotReceivedLoc(amountDrLoc.subtract(realAmountDrLoc));
|
|
|
+ //应付人民币
|
|
|
+ BigDecimal amountCr = feeCenters.stream().filter(e -> "CNY".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCr(amountCr.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实付人民币
|
|
|
+ BigDecimal realAmountCr = feeCenters.stream().filter(e -> "CNY".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountCr(realAmountCr.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未付人民币
|
|
|
+ item.setNotReceivedCr(amountCr.subtract(realAmountCr));
|
|
|
+ //应付美元
|
|
|
+ BigDecimal amountCrUsd = feeCenters.stream().filter(e -> "USD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCrUsd(amountCrUsd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实付美元
|
|
|
+ BigDecimal realAmountCrUsd = feeCenters.stream().filter(e -> "USD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountCrUsd(realAmountCrUsd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未付美元
|
|
|
+ item.setNotReceivedCrUsd(amountCrUsd.subtract(realAmountCrUsd));
|
|
|
+ //应付HKD
|
|
|
+ BigDecimal amountCrHkd = feeCenters.stream().filter(e -> "HKD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCrHkd(amountCrHkd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实付HKD
|
|
|
+ BigDecimal realAmountCrHkd = feeCenters.stream().filter(e -> "HKD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountCrHkd(realAmountCrHkd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未付HKD
|
|
|
+ item.setNotReceivedCrHkd(amountCrHkd.subtract(realAmountCrHkd));
|
|
|
+ //应付VND
|
|
|
+ BigDecimal amountCrVnd = feeCenters.stream().filter(e -> "VND".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCrVnd(amountCrVnd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实付VND
|
|
|
+ BigDecimal realAmountCrVnd = feeCenters.stream().filter(e -> "VND".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountCrVnd(realAmountCrVnd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未付VND
|
|
|
+ item.setNotReceivedCrVnd(amountCrVnd.subtract(realAmountCrVnd));
|
|
|
+ //应付SGD
|
|
|
+ BigDecimal amountCrSgd = feeCenters.stream().filter(e -> "SGD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCrSgd(amountCrSgd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实付SGD
|
|
|
+ BigDecimal realAmountCrSgd = feeCenters.stream().filter(e -> "SGD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountCrSgd(realAmountCrSgd.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未付SGD
|
|
|
+ item.setNotReceivedCrSgd(amountCrSgd.subtract(realAmountCrSgd));
|
|
|
+ //应付其他
|
|
|
+ BigDecimal amountCrOther = feeCenters.stream().filter(e -> !"CNY,USD".contains(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCrOther(amountCrOther.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实付其他
|
|
|
+ BigDecimal realAmountCrOther = feeCenters.stream().filter(e -> !"CNY,USD".contains(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountCrOther(realAmountCrOther.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未付其他
|
|
|
+ item.setNotReceivedCrOther(amountCrOther.subtract(realAmountCrOther));
|
|
|
+ //合计应付
|
|
|
+ BigDecimal amountCrLoc = feeCenters.stream().filter(e -> "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCrLoc(amountCrLoc.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //实际合计应付
|
|
|
+ BigDecimal realAmountCrLoc = feeCenters.stream().filter(e -> "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getStlTtlAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setRealAmountCrLoc(realAmountCrLoc.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //未付合计
|
|
|
+ item.setNotReceivedCrLoc(amountCrLoc.subtract(realAmountCrLoc));
|
|
|
+ //合计利润
|
|
|
+ item.setAmountProfitLoc(amountDrLoc.subtract(amountCrLoc));
|
|
|
+ //实际单票利润
|
|
|
+ item.setRealAmountProfitLoc(realAmountDrLoc.subtract(realAmountCrLoc));
|
|
|
+ //人民币利润
|
|
|
+ item.setAmountProfit(amountDr.subtract(amountCr));
|
|
|
+ //美元利润
|
|
|
+ item.setAmountProfitUsd(amountDrUsd.subtract(amountCrUsd));
|
|
|
+ //HKD利润
|
|
|
+ item.setAmountProfitHkd(amountDrHkd.subtract(amountCrHkd));
|
|
|
+ //VND利润
|
|
|
+ item.setAmountProfitVnd(amountDrVnd.subtract(amountCrVnd));
|
|
|
+ //SGD利润
|
|
|
+ item.setAmountProfitSgd(amountDrSgd.subtract(amountCrSgd));
|
|
|
+ //其他利润
|
|
|
+ item.setAmountProfitOther(amountDrOther.subtract(amountDrOther));
|
|
|
+ //应收海运费
|
|
|
+ BigDecimal oceanFreightDr = feeCenters.stream().filter(e -> "USD".equals(e.getCurCode()) && "D".equals(e.getDc())
|
|
|
+ && "HYF".equals(e.getFeeCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setOceanFreightDr(oceanFreightDr.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //应付海运费
|
|
|
+ BigDecimal oceanFreightCr = feeCenters.stream().filter(e -> "USD".equals(e.getCurCode()) && "C".equals(e.getDc())
|
|
|
+ && "HYF".equals(e.getFeeCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setOceanFreightCr(oceanFreightCr.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //海运费利润
|
|
|
+ item.setOceanFreightProfit(oceanFreightDr.subtract(oceanFreightCr));
|
|
|
+ return item;
|
|
|
+ }
|
|
|
}
|