|
|
@@ -6,7 +6,9 @@ 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.IDeptUtils;
|
|
|
+import org.springblade.los.basic.cur.entity.BCurrency;
|
|
|
import org.springblade.los.basic.cur.service.IBCurrencyService;
|
|
|
import org.springblade.los.business.aea.entity.AeaBills;
|
|
|
import org.springblade.los.business.aea.mapper.AeaBillsMapper;
|
|
|
@@ -16,6 +18,7 @@ import org.springblade.los.business.customsDeclaration.entity.CustomsDeclaration
|
|
|
import org.springblade.los.business.customsDeclaration.mapper.CustomsDeclarationMapper;
|
|
|
import org.springblade.los.business.sea.entity.Bills;
|
|
|
import org.springblade.los.business.sea.mapper.BillsMapper;
|
|
|
+import org.springblade.los.excel.BoxNumberProfitExcel;
|
|
|
import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
import org.springblade.los.finance.fee.mapper.FeeCenterMapper;
|
|
|
import org.springblade.los.finance.fee.mapper.FinAccBillsMapper;
|
|
|
@@ -25,6 +28,8 @@ import org.springblade.los.finance.stl.entity.FinStlBills;
|
|
|
import org.springblade.los.finance.stl.mapper.FinStlBillsMapper;
|
|
|
import org.springblade.los.statisticAnalysis.*;
|
|
|
import org.springblade.los.statisticAnalysis.service.IStatisticAnalysisService;
|
|
|
+import org.springblade.los.view.entity.BoxNumberProfit;
|
|
|
+import org.springblade.los.view.mapper.BoxNumberProfitMapper;
|
|
|
import org.springblade.los.view.mapper.FinanceProfitMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -58,6 +63,8 @@ public class StatisticAnalysisServiceImpl implements IStatisticAnalysisService {
|
|
|
|
|
|
private final IDeptUtils deptUtils;
|
|
|
|
|
|
+ private final BoxNumberProfitMapper boxNumberProfitMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public R<IPage<DecisionAnalysis>> decisionAnalysis(DecisionAnalysis decisionAnalysis, IPage<DecisionAnalysis> page) {
|
|
|
return R.data(page.setRecords(billsMapper.decisionAnalysis(decisionAnalysis, page)));
|
|
|
@@ -77,28 +84,11 @@ public class StatisticAnalysisServiceImpl implements IStatisticAnalysisService {
|
|
|
|
|
|
@Override
|
|
|
public R<IPage<FinanceProfitDtoList>> financeProfit(FinanceProfitDtoList financeProfit, IPage<FinanceProfitDtoList> page) {
|
|
|
- /*if (financeProfit.getBillType().contains("SE") || financeProfit.getBillType().contains("AE")) {
|
|
|
- List<FinanceProfitDtoList> financeProfitListHy = billsMapper.financeProfit(financeProfit);
|
|
|
- if (!financeProfitListHy.isEmpty()) {
|
|
|
- financeProfitList.addAll(financeProfitListHy);
|
|
|
- }
|
|
|
- } else if (financeProfit.getBillType().contains("SI") || financeProfit.getBillType().contains("AI")) {
|
|
|
- List<FinanceProfitDtoList> financeProfitListKy = aeaBillsMapper.financeProfit(financeProfit);
|
|
|
- if (!financeProfitListKy.isEmpty()) {
|
|
|
- financeProfitList.addAll(financeProfitListKy);
|
|
|
- }
|
|
|
- } else if (financeProfit.getBillType().contains("BGSE") || financeProfit.getBillType().contains("BGSI")
|
|
|
- || financeProfit.getBillType().contains("BGAE") || financeProfit.getBillType().contains("BGAI")) {
|
|
|
- List<FinanceProfitDtoList> financeProfitListBg = customsDeclarationMapper.financeProfit(financeProfit);
|
|
|
- if (!financeProfitListBg.isEmpty()) {
|
|
|
- financeProfitList.addAll(financeProfitListBg);
|
|
|
- }
|
|
|
- }*/
|
|
|
financeProfit.setTenantId(AuthUtil.getTenantId());
|
|
|
financeProfit.setBranchId(deptUtils.getDeptPid() + "");
|
|
|
List<FinanceProfitDtoList> financeProfitList = new ArrayList<>();
|
|
|
- BigDecimal exrateC = bCurrencyService.getCnyExrate("USD", "C","2");
|
|
|
- BigDecimal exrateD = bCurrencyService.getCnyExrate("USD", "D","2");
|
|
|
+ BigDecimal exrateC = bCurrencyService.getCnyExrate("USD", "C", "2");
|
|
|
+ BigDecimal exrateD = bCurrencyService.getCnyExrate("USD", "D", "2");
|
|
|
//是否合并amend费用 true 合并 false 不合并
|
|
|
if ("1".equals(financeProfit.getMergeAmendFee())) {
|
|
|
financeProfitList = financeProfitMapper.financeProfit(financeProfit, page);
|
|
|
@@ -267,10 +257,6 @@ public class StatisticAnalysisServiceImpl implements IStatisticAnalysisService {
|
|
|
financeProfit.setBillType(financeProfit.getBillType() + ",SEA,SIA,AEA,AIA");
|
|
|
}
|
|
|
financeProfitList = financeProfitMapper.financeProfit(financeProfit, page);
|
|
|
- /*List<FinanceProfitDtoList> financeProfitListBg = amendsMapper.financeProfit(financeProfit);
|
|
|
- if (!financeProfitListBg.isEmpty()) {
|
|
|
- financeProfitList.addAll(financeProfitListBg);
|
|
|
- }*/
|
|
|
}
|
|
|
for (FinanceProfitDtoList item : financeProfitList) {
|
|
|
if (null != item) {
|
|
|
@@ -725,8 +711,8 @@ public class StatisticAnalysisServiceImpl implements IStatisticAnalysisService {
|
|
|
financeProfit.setTenantId(AuthUtil.getTenantId());
|
|
|
financeProfit.setBranchId(deptUtils.getDeptPid() + "");
|
|
|
List<FinanceProfitDtoList> financeProfitList = new ArrayList<>();
|
|
|
- BigDecimal exrateC = bCurrencyService.getCnyExrate("USD", "C","2");
|
|
|
- BigDecimal exrateD = bCurrencyService.getCnyExrate("USD", "D","2");
|
|
|
+ BigDecimal exrateC = bCurrencyService.getCnyExrate("USD", "C", "2");
|
|
|
+ BigDecimal exrateD = bCurrencyService.getCnyExrate("USD", "D", "2");
|
|
|
//是否合并amend费用 true 合并 false 不合并
|
|
|
if ("1".equals(financeProfit.getMergeAmendFee())) {
|
|
|
financeProfitList = financeProfitMapper.financeProfitSum(financeProfit);
|
|
|
@@ -929,8 +915,8 @@ public class StatisticAnalysisServiceImpl implements IStatisticAnalysisService {
|
|
|
financeProfit.setTenantId(AuthUtil.getTenantId());
|
|
|
financeProfit.setBranchId(deptUtils.getDeptPid() + "");
|
|
|
List<FinanceProfitDtoList> financeProfitList = new ArrayList<>();
|
|
|
- BigDecimal exrateC = bCurrencyService.getCnyExrate("USD", "C","2");
|
|
|
- BigDecimal exrateD = bCurrencyService.getCnyExrate("USD", "D","2");
|
|
|
+ BigDecimal exrateC = bCurrencyService.getCnyExrate("USD", "C", "2");
|
|
|
+ BigDecimal exrateD = bCurrencyService.getCnyExrate("USD", "D", "2");
|
|
|
//是否合并amend费用 true 合并 false 不合并
|
|
|
if (ObjectUtils.isNotNull(financeProfit.getMergeAmendFee())) {
|
|
|
financeProfitList = financeProfitMapper.financeProfitSum(financeProfit);
|
|
|
@@ -1110,4 +1096,303 @@ public class StatisticAnalysisServiceImpl implements IStatisticAnalysisService {
|
|
|
}
|
|
|
return financeProfitList;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R<IPage<BoxNumberProfitExcel>> boxNumberProfitStatistics(IPage<BoxNumberProfitExcel> page, BoxNumberProfitQ boxNumberProfit) {
|
|
|
+ boxNumberProfit.setTenantId(AuthUtil.getTenantId());
|
|
|
+ boxNumberProfit.setBranchId(deptUtils.getDeptPid() + "");
|
|
|
+ List<BoxNumberProfit> boxNumberProfitList = boxNumberProfitMapper.selectBoxNumberProfitPage(page, boxNumberProfit);
|
|
|
+ List<BoxNumberProfitExcel> boxNumberProfitExcelList = new ArrayList<>();
|
|
|
+ if (!boxNumberProfitList.isEmpty()) {
|
|
|
+ List<Long> ids = boxNumberProfitList.stream().map(BoxNumberProfit::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .in(FeeCenter::getPid, ids));
|
|
|
+ BCurrency bCurrencyD = new BCurrency();
|
|
|
+ bCurrencyD.setDc("D");
|
|
|
+ bCurrencyD.setType("1");
|
|
|
+ List<BCurrency> currencyListD = bCurrencyService.getExrate(bCurrencyD);
|
|
|
+ BCurrency bCurrencyC = new BCurrency();
|
|
|
+ bCurrencyC.setDc("C");
|
|
|
+ bCurrencyC.setType("1");
|
|
|
+ List<BCurrency> currencyListC = bCurrencyService.getExrate(bCurrencyC);
|
|
|
+ for (BoxNumberProfit item : boxNumberProfitList) {
|
|
|
+ if ("ASE".equals(item.getBusinessType()) || "ASI".equals(item.getBusinessType())) {
|
|
|
+ BigDecimal amountDr = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "D".equals(e.getDc())
|
|
|
+ && "CNY".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDr(amountDr);
|
|
|
+ BigDecimal amountCr = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "C".equals(e.getDc())
|
|
|
+ && "CNY".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCr(amountCr);
|
|
|
+ BigDecimal amountDrUsd = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "D".equals(e.getDc())
|
|
|
+ && "USD".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDr(amountDrUsd);
|
|
|
+ BigDecimal amountCrUsd = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "C".equals(e.getDc())
|
|
|
+ && "USD".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCrUsd(amountCrUsd);
|
|
|
+ currencyListD.stream().filter(e -> "USD".equals(e.getCode())).findFirst()
|
|
|
+ .ifPresent(currencyD -> item.setAmountDrLoc(amountDr.add(amountDrUsd.multiply(currencyD.getExrate()))));
|
|
|
+ currencyListC.stream().filter(e -> "USD".equals(e.getCode())).findFirst()
|
|
|
+ .ifPresent(currencyC -> item.setAmountCrLoc(amountCr.add(amountCrUsd.multiply(currencyC.getExrate()))));
|
|
|
+ item.setAmountProfit(amountDr.subtract(amountCr));
|
|
|
+ item.setAmountProfitUsd(amountDrUsd.subtract(amountCrUsd));
|
|
|
+ item.setAmountProfitLoc(item.getAmountDrLoc().subtract(item.getAmountCrLoc()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boxNumberProfitExcelList = BeanUtil.copy(boxNumberProfitList, BoxNumberProfitExcel.class);
|
|
|
+ }
|
|
|
+ return R.data(page.setRecords(boxNumberProfitExcelList));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R boxNumberProfitStatisticsSum(BoxNumberProfitQ boxNumberProfit) {
|
|
|
+ boxNumberProfit.setTenantId(AuthUtil.getTenantId());
|
|
|
+ boxNumberProfit.setBranchId(deptUtils.getDeptPid() + "");
|
|
|
+ List<BoxNumberProfit> boxNumberProfitList = boxNumberProfitMapper.selectBoxNumberProfitList(boxNumberProfit);
|
|
|
+ List<BoxNumberProfitExcel> boxNumberProfitExcelList = new ArrayList<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ if (!boxNumberProfitList.isEmpty()) {
|
|
|
+ List<Long> ids = boxNumberProfitList.stream().map(BoxNumberProfit::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .in(FeeCenter::getPid, ids));
|
|
|
+ BCurrency bCurrencyD = new BCurrency();
|
|
|
+ bCurrencyD.setDc("D");
|
|
|
+ bCurrencyD.setType("1");
|
|
|
+ List<BCurrency> currencyListD = bCurrencyService.getExrate(bCurrencyD);
|
|
|
+ BCurrency bCurrencyC = new BCurrency();
|
|
|
+ bCurrencyC.setDc("C");
|
|
|
+ bCurrencyC.setType("1");
|
|
|
+ List<BCurrency> currencyListC = bCurrencyService.getExrate(bCurrencyC);
|
|
|
+ for (BoxNumberProfit item : boxNumberProfitList) {
|
|
|
+ if ("ASE".equals(item.getBusinessType()) || "ASI".equals(item.getBusinessType())) {
|
|
|
+ BigDecimal amountDr = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "D".equals(e.getDc())
|
|
|
+ && "CNY".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDr(amountDr);
|
|
|
+ BigDecimal amountCr = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "C".equals(e.getDc())
|
|
|
+ && "CNY".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCr(amountCr);
|
|
|
+ BigDecimal amountDrUsd = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "D".equals(e.getDc())
|
|
|
+ && "USD".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDr(amountDrUsd);
|
|
|
+ BigDecimal amountCrUsd = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "C".equals(e.getDc())
|
|
|
+ && "USD".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCrUsd(amountCrUsd);
|
|
|
+ currencyListD.stream().filter(e -> "USD".equals(e.getCode())).findFirst()
|
|
|
+ .ifPresent(currencyD -> item.setAmountDrLoc(amountDr.add(amountDrUsd.multiply(currencyD.getExrate()))));
|
|
|
+ currencyListC.stream().filter(e -> "USD".equals(e.getCode())).findFirst()
|
|
|
+ .ifPresent(currencyC -> item.setAmountCrLoc(amountCr.add(amountCrUsd.multiply(currencyC.getExrate()))));
|
|
|
+ item.setAmountProfit(amountDr.subtract(amountCr));
|
|
|
+ item.setAmountProfitUsd(amountDrUsd.subtract(amountCrUsd));
|
|
|
+ item.setAmountProfitLoc(item.getAmountDrLoc().subtract(item.getAmountCrLoc()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boxNumberProfitExcelList = BeanUtil.copy(boxNumberProfitList, BoxNumberProfitExcel.class);
|
|
|
+ map.put("teu", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getTeu).filter(Objects::nonNull).reduce(0, Integer::sum));
|
|
|
+ map.put("quantityV20", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getQuantityV20).filter(Objects::nonNull).reduce(0, Integer::sum));
|
|
|
+ map.put("quantityV40", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getQuantityV40).filter(Objects::nonNull).reduce(0, Integer::sum));
|
|
|
+ map.put("quantityV45", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getQuantityV45).filter(Objects::nonNull).reduce(0, Integer::sum));
|
|
|
+ map.put("quantityV48", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getQuantityV48).filter(Objects::nonNull).reduce(0, Integer::sum));
|
|
|
+ map.put("quantityV40hc", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getQuantityV40hc).filter(Objects::nonNull).reduce(0, Integer::sum));
|
|
|
+ map.put("amountDr", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getAmountDr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ map.put("amountCr", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getAmountCr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ map.put("amountProfit", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getAmountProfit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ map.put("amountDrUsd", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getAmountDrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ map.put("amountCrUsd", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getAmountCrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ map.put("amountProfitUsd", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getAmountProfitUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ map.put("amountDrLoc", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getAmountDrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ map.put("amountCrLoc", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getAmountCrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ map.put("amountProfitLoc", boxNumberProfitExcelList.stream().map(BoxNumberProfitExcel::getAmountProfitLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ } else {
|
|
|
+ map.put("teu", 0);
|
|
|
+ map.put("quantityV20", 0);
|
|
|
+ map.put("quantityV40", 0);
|
|
|
+ map.put("quantityV45", 0);
|
|
|
+ map.put("quantityV48", 0);
|
|
|
+ map.put("quantityV40hc", 0);
|
|
|
+ map.put("amountDr", new BigDecimal("0.00"));
|
|
|
+ map.put("amountCr", new BigDecimal("0.00"));
|
|
|
+ map.put("amountProfit", new BigDecimal("0.00"));
|
|
|
+ map.put("amountDrUsd", new BigDecimal("0.00"));
|
|
|
+ map.put("amountCrUsd", new BigDecimal("0.00"));
|
|
|
+ map.put("amountProfitUsd", new BigDecimal("0.00"));
|
|
|
+ map.put("amountDrLoc", new BigDecimal("0.00"));
|
|
|
+ map.put("amountCrLoc", new BigDecimal("0.00"));
|
|
|
+ map.put("amountProfitLoc", new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ return R.data(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BoxNumberProfitExcel> boxNumberProfitStatisticsList(BoxNumberProfitQ boxNumberProfit) {
|
|
|
+ boxNumberProfit.setTenantId(AuthUtil.getTenantId());
|
|
|
+ boxNumberProfit.setBranchId(deptUtils.getDeptPid() + "");
|
|
|
+ List<BoxNumberProfit> boxNumberProfitList = boxNumberProfitMapper.selectBoxNumberProfitList(boxNumberProfit);
|
|
|
+ List<BoxNumberProfitExcel> boxNumberProfitExcelList = new ArrayList<>();
|
|
|
+ if (!boxNumberProfitList.isEmpty()) {
|
|
|
+ List<Long> ids = boxNumberProfitList.stream().map(BoxNumberProfit::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .in(FeeCenter::getPid, ids));
|
|
|
+ BCurrency bCurrencyD = new BCurrency();
|
|
|
+ bCurrencyD.setDc("D");
|
|
|
+ bCurrencyD.setType("1");
|
|
|
+ List<BCurrency> currencyListD = bCurrencyService.getExrate(bCurrencyD);
|
|
|
+ BCurrency bCurrencyC = new BCurrency();
|
|
|
+ bCurrencyC.setDc("C");
|
|
|
+ bCurrencyC.setType("1");
|
|
|
+ List<BCurrency> currencyListC = bCurrencyService.getExrate(bCurrencyC);
|
|
|
+ for (BoxNumberProfit item : boxNumberProfitList) {
|
|
|
+ if ("ASE".equals(item.getBusinessType()) || "ASI".equals(item.getBusinessType())) {
|
|
|
+ BigDecimal amountDr = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "D".equals(e.getDc())
|
|
|
+ && "CNY".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDr(amountDr);
|
|
|
+ BigDecimal amountCr = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "C".equals(e.getDc())
|
|
|
+ && "CNY".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCr(amountCr);
|
|
|
+ BigDecimal amountDrUsd = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "D".equals(e.getDc())
|
|
|
+ && "USD".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDr(amountDrUsd);
|
|
|
+ BigDecimal amountCrUsd = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "C".equals(e.getDc())
|
|
|
+ && "USD".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCrUsd(amountCrUsd);
|
|
|
+ currencyListD.stream().filter(e -> "USD".equals(e.getCode())).findFirst()
|
|
|
+ .ifPresent(currencyD -> item.setAmountDrLoc(amountDr.add(amountDrUsd.multiply(currencyD.getExrate()))));
|
|
|
+ currencyListC.stream().filter(e -> "USD".equals(e.getCode())).findFirst()
|
|
|
+ .ifPresent(currencyC -> item.setAmountCrLoc(amountCr.add(amountCrUsd.multiply(currencyC.getExrate()))));
|
|
|
+ item.setAmountProfit(amountDr.subtract(amountCr));
|
|
|
+ item.setAmountProfitUsd(amountDrUsd.subtract(amountCrUsd));
|
|
|
+ item.setAmountProfitLoc(item.getAmountDrLoc().subtract(item.getAmountCrLoc()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boxNumberProfitExcelList = BeanUtil.copy(boxNumberProfitList, BoxNumberProfitExcel.class);
|
|
|
+ }
|
|
|
+ return boxNumberProfitExcelList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R boxNumberProfitStatisticsChart(BoxNumberProfitQ boxNumberProfit) {
|
|
|
+ boxNumberProfit.setTenantId(AuthUtil.getTenantId());
|
|
|
+ boxNumberProfit.setBranchId(deptUtils.getDeptPid() + "");
|
|
|
+ List<BoxNumberProfit> boxNumberProfitList = boxNumberProfitMapper.selectBoxNumberProfitList(boxNumberProfit);
|
|
|
+ List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ if (!boxNumberProfitList.isEmpty()) {
|
|
|
+ List<Long> ids = boxNumberProfitList.stream().map(BoxNumberProfit::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .in(FeeCenter::getPid, ids));
|
|
|
+ BCurrency bCurrencyD = new BCurrency();
|
|
|
+ bCurrencyD.setDc("D");
|
|
|
+ bCurrencyD.setType("1");
|
|
|
+ List<BCurrency> currencyListD = bCurrencyService.getExrate(bCurrencyD);
|
|
|
+ BCurrency bCurrencyC = new BCurrency();
|
|
|
+ bCurrencyC.setDc("C");
|
|
|
+ bCurrencyC.setType("1");
|
|
|
+ List<BCurrency> currencyListC = bCurrencyService.getExrate(bCurrencyC);
|
|
|
+ for (BoxNumberProfit item : boxNumberProfitList) {
|
|
|
+ if ("ASE".equals(item.getBusinessType()) || "ASI".equals(item.getBusinessType())) {
|
|
|
+ BigDecimal amountDr = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "D".equals(e.getDc())
|
|
|
+ && "CNY".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDr(amountDr);
|
|
|
+ BigDecimal amountCr = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "C".equals(e.getDc())
|
|
|
+ && "CNY".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCr(amountCr);
|
|
|
+ BigDecimal amountDrUsd = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "D".equals(e.getDc())
|
|
|
+ && "USD".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountDr(amountDrUsd);
|
|
|
+ BigDecimal amountCrUsd = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()) && "C".equals(e.getDc())
|
|
|
+ && "USD".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setAmountCrUsd(amountCrUsd);
|
|
|
+ currencyListD.stream().filter(e -> "USD".equals(e.getCode())).findFirst()
|
|
|
+ .ifPresent(currencyD -> item.setAmountDrLoc(amountDr.add(amountDrUsd.multiply(currencyD.getExrate()))));
|
|
|
+ currencyListC.stream().filter(e -> "USD".equals(e.getCode())).findFirst()
|
|
|
+ .ifPresent(currencyC -> item.setAmountCrLoc(amountCr.add(amountCrUsd.multiply(currencyC.getExrate()))));
|
|
|
+ item.setAmountProfit(amountDr.subtract(amountCr));
|
|
|
+ item.setAmountProfitUsd(amountDrUsd.subtract(amountCrUsd));
|
|
|
+ item.setAmountProfitLoc(item.getAmountDrLoc().subtract(item.getAmountCrLoc()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("1".equals(boxNumberProfit.getType())) {
|
|
|
+ List<Long> carrierId = boxNumberProfitList.stream().map(BoxNumberProfit::getCarrierId)
|
|
|
+ .filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ int teuSum = 0;
|
|
|
+ BigDecimal amountProfitSum = new BigDecimal("0.00");
|
|
|
+ BigDecimal profitMarginSum = new BigDecimal("0.00");
|
|
|
+ for (Long item : carrierId) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ Integer teu = boxNumberProfitList.stream().filter(e -> e.getCarrierId().equals(item)).map(BoxNumberProfit::getTeu).filter(Objects::nonNull).reduce(0, Integer::sum);
|
|
|
+ map.put("teu", teu);
|
|
|
+ teuSum = teuSum + teu;
|
|
|
+ BigDecimal amountDrLoc = boxNumberProfitList.stream().filter(e -> e.getCarrierId().equals(item)).map(BoxNumberProfit::getAmountDrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal amountProfitLoc = boxNumberProfitList.stream().filter(e -> e.getCarrierId().equals(item)).map(BoxNumberProfit::getAmountProfitLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ map.put("amountProfitLoc", amountProfitLoc);
|
|
|
+ amountProfitSum = amountProfitSum.add(amountProfitLoc);
|
|
|
+ BigDecimal profitMargin = amountProfitLoc.divide(amountDrLoc, MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
|
|
|
+ map.put("profitMargin", profitMargin);
|
|
|
+ profitMarginSum = profitMarginSum.add(profitMargin);
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ Map<String, Object> mapSum = new HashMap<>();
|
|
|
+ mapSum.put("teu", teuSum);
|
|
|
+ mapSum.put("amountProfitLoc", amountProfitSum);
|
|
|
+ mapSum.put("profitMargin", profitMarginSum);
|
|
|
+ mapList.add(0, mapSum);
|
|
|
+ } else if ("2".equals(boxNumberProfit.getType())) {
|
|
|
+ List<Long> corpId = boxNumberProfitList.stream().map(BoxNumberProfit::getCorpId)
|
|
|
+ .filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ int teuSum = 0;
|
|
|
+ BigDecimal amountProfitSum = new BigDecimal("0.00");
|
|
|
+ BigDecimal profitMarginSum = new BigDecimal("0.00");
|
|
|
+ for (Long item : corpId) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ Integer teu = boxNumberProfitList.stream().filter(e -> e.getCorpId().equals(item)).map(BoxNumberProfit::getTeu).filter(Objects::nonNull).reduce(0, Integer::sum);
|
|
|
+ map.put("teu", teu);
|
|
|
+ teuSum = teuSum + teu;
|
|
|
+ BigDecimal amountDrLoc = boxNumberProfitList.stream().filter(e -> e.getCorpId().equals(item)).map(BoxNumberProfit::getAmountDrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal amountProfitLoc = boxNumberProfitList.stream().filter(e -> e.getCorpId().equals(item)).map(BoxNumberProfit::getAmountProfitLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ map.put("amountProfitLoc", amountProfitLoc);
|
|
|
+ amountProfitSum = amountProfitSum.add(amountProfitLoc);
|
|
|
+ BigDecimal profitMargin = amountProfitLoc.divide(amountDrLoc, MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
|
|
|
+ map.put("profitMargin", profitMargin);
|
|
|
+ profitMarginSum = profitMarginSum.add(profitMargin);
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ Map<String, Object> mapSum = new HashMap<>();
|
|
|
+ mapSum.put("teu", teuSum);
|
|
|
+ mapSum.put("amountProfitLoc", amountProfitSum);
|
|
|
+ mapSum.put("profitMargin", profitMarginSum);
|
|
|
+ mapList.add(0, mapSum);
|
|
|
+ } else if ("3".equals(boxNumberProfit.getType())) {
|
|
|
+ List<Long> srcId = boxNumberProfitList.stream().filter(e -> e.getSrcType().equals("SALES")).map(BoxNumberProfit::getSrcId)
|
|
|
+ .filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ int teuSum = 0;
|
|
|
+ BigDecimal amountProfitSum = new BigDecimal("0.00");
|
|
|
+ BigDecimal profitMarginSum = new BigDecimal("0.00");
|
|
|
+ for (Long item : srcId) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ Integer teu = boxNumberProfitList.stream().filter(e -> e.getSrcId().equals(item) && e.getSrcType().equals("SALES")).map(BoxNumberProfit::getTeu).filter(Objects::nonNull).reduce(0, Integer::sum);
|
|
|
+ map.put("teu", teu);
|
|
|
+ teuSum = teuSum + teu;
|
|
|
+ BigDecimal amountDrLoc = boxNumberProfitList.stream().filter(e -> e.getSrcId().equals(item) && e.getSrcType().equals("SALES")).map(BoxNumberProfit::getAmountDrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal amountProfitLoc = boxNumberProfitList.stream().filter(e -> e.getSrcId().equals(item) && e.getSrcType().equals("SALES")).map(BoxNumberProfit::getAmountProfitLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ map.put("amountProfitLoc", amountProfitLoc);
|
|
|
+ amountProfitSum = amountProfitSum.add(amountProfitLoc);
|
|
|
+ BigDecimal profitMargin = amountProfitLoc.divide(amountDrLoc, MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
|
|
|
+ map.put("profitMargin", profitMargin);
|
|
|
+ profitMarginSum = profitMarginSum.add(profitMargin);
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ Map<String, Object> mapSum = new HashMap<>();
|
|
|
+ mapSum.put("teu", teuSum);
|
|
|
+ mapSum.put("amountProfitLoc", amountProfitSum);
|
|
|
+ mapSum.put("profitMargin", profitMarginSum);
|
|
|
+ mapList.add(0, mapSum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(mapList);
|
|
|
+ }
|
|
|
}
|