Browse Source

业务利润增加客户来源检索条件
海运出口amend报表打印接口修改

纪新园 5 months ago
parent
commit
d89a0b24c4

+ 6 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/FeeCenter.java

@@ -999,5 +999,11 @@ public class FeeCenter implements Serializable {
 	@ApiModelProperty(value = "是否强制币别")
 	private Integer whetherForceCurNo;
 
+	/**
+	 * 是否系统自动生成  0否1是
+	 */
+	@ApiModelProperty(value = "是否系统自动生成")
+	private String automaticGenerated;
+
 }
 

+ 8 - 2
blade-service-api/blade-los-api/src/main/java/org/springblade/los/statisticAnalysis/FinanceProfitDtoList.java

@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.annotation.write.style.ColumnWidth;
 import com.alibaba.excel.annotation.write.style.ContentRowHeight;
 import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -83,13 +84,13 @@ public class FinanceProfitDtoList {
 	 * 起运港
 	 */
 	@ExcelProperty(value = "起运港")
-	private String pod;
+	private String pol;
 
 	/**
 	 * 目的港
 	 */
 	@ExcelProperty(value = "目的港")
-	private String pol;
+	private String pod;
 
 	/**
 	 * 中文船名
@@ -350,5 +351,10 @@ public class FinanceProfitDtoList {
 	 */
 	@ExcelIgnore
 	private Integer whetherExist;
+	/**
+	 * 客户来源
+	 */
+	@ExcelIgnore
+	private String corpSource;
 
 }

+ 4 - 0
blade-service/blade-los/src/main/java/org/springblade/los/Util/MagicValues.java

@@ -59,6 +59,10 @@ public class MagicValues {
 	public static final String AMEND_SE = "AMENDSE";
 	public static final String AMEND_AE = "AMENDAE";
 	public static final String AMEND_AI = "AMENDAI";
+	public static final String BGSEA = "BGSEA";
+	public static final String BGSIA = "BGSIA";
+	public static final String BGAEA = "BGAEA";
+	public static final String BGAIA = "BGAIA";
 	public static final String SE = "SE";
 	public static final String SI = "SI";
 	public static final String AE = "AE";

+ 422 - 17
blade-service/blade-los/src/main/java/org/springblade/los/basic/reports/service/impl/ReportsServiceImpl.java

@@ -21,7 +21,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.echepei.dto.mail.MailDto;
-import com.echepei.enums.MailTypeEnum;
 import com.echepei.utils.mail.SendMailUtil;
 import lombok.AllArgsConstructor;
 import org.springblade.common.enums.CommonEnum;
@@ -87,14 +86,10 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.math.MathContext;
 import java.math.RoundingMode;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.time.LocalDate;
@@ -223,7 +218,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 			return this.getReportDataAmend(billId, reportCode, groupCode, corpIds, itemIds, type, curCode, BillNumber);
 		} else if (MagicValues.BGSE.equals(type) || MagicValues.BGSI.equals(type) || MagicValues.BGAE.equals(type) || MagicValues.BGAI.equals(type)) {
 			return this.getReportDataBG(billId, reportCode, groupCode, corpIds, itemIds, type, curCode, BillNumber);
-		}else if((MagicValues.SECMS.equals(type) || MagicValues.MFA.equals(type) || MagicValues.EXP.equals(type) || MagicValues.TRUCK.equals(type))){
+		} else if ((MagicValues.SECMS.equals(type) || MagicValues.MFA.equals(type) || MagicValues.EXP.equals(type) || MagicValues.TRUCK.equals(type))) {
 
 		} else {
 			if (MagicValues.PAID_APPLICATION.equals(reportCode) && MagicValues.PAID_APPLICATION.equals(groupCode)) {
@@ -886,7 +881,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 					.eq(HmmEdi::getTenantId, AuthUtil.getTenantId())
 					.eq(HmmEdi::getPid, bills.getId()));
 				bills.setHmmEdi(hmmEdi != null ? hmmEdi : new HmmEdi());
-				bills.setRate(ibCurrencyService.getCnyExrate(bills.getBillDate(), "USD", "D", "1"));
+//				bills.setRate(ibCurrencyService.getCnyExrate(bills.getBillDate(), "USD", "D", "1"));
 				if (ObjectUtils.isNotNull(bills.getAmountProfitLoc()) && ObjectUtils.isNotNull(bills.getAmountDrLoc())) {
 					if (bills.getAmountProfitLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0 ||
 						bills.getAmountDrLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0) {
@@ -935,11 +930,13 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 								}
 							}
 							for (Bills item : billsList) {
-								List<FeeCenter> feeD = feeCenterListMh.stream().filter(e -> MagicValues.D.equals(e.getDc())).collect(Collectors.toList());
+								List<FeeCenter> feeD = feeCenterListMh.stream().filter(e -> MagicValues.D.equals(e.getDc()) &&
+									e.getPid().equals(item.getId())).collect(Collectors.toList());
 								item.setFeeCenterListD(feeD);
-								List<FeeCenter> feeC = feeCenterListMh.stream().filter(e -> MagicValues.C.equals(e.getDc())).collect(Collectors.toList());
+								List<FeeCenter> feeC = feeCenterListMh.stream().filter(e -> MagicValues.C.equals(e.getDc()) &&
+									e.getPid().equals(item.getId())).collect(Collectors.toList());
 								item.setFeeCenterListC(feeC);
-								List<FeeCenter> feeCenterList = feeCenterListMh.stream()
+								List<FeeCenter> feeCenterList = feeCenterListMh.stream().filter(e -> e.getPid().equals(item.getId()))
 									.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
 										Comparator.comparing(f -> f.getFeeId() + f.getCorpId() + f.getCurCode() + f.getDc()))), ArrayList::new));
 								List<FeeCenterReports> feeCenterReportList = new ArrayList<>();
@@ -1029,6 +1026,12 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						}
 					}
 					if (!feeCenterList.isEmpty()) {
+						List<FeeCenter> exrateList = feeCenterList.stream().filter(e-> e.getCurCode().equals("USD")).collect(Collectors.toList());
+						if (!exrateList.isEmpty()){
+							bills.setRate(exrateList.get(0).getExrate());
+						}else{
+							bills.setRate(new BigDecimal("1.00"));
+						}
 						List<FeeCenter> feeCenters = feeCenterList.stream()
 							.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
 								Comparator.comparing(f -> f.getFeeId() + f.getCorpId() + f.getCurCode() + f.getDc()))), ArrayList::new));
@@ -1110,12 +1113,16 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						}
 						allFeeCenter.addAll(feeCenterList);
 						List<FeeCenter> feeD = feeCenterList.stream().filter(e -> MagicValues.D.equals(e.getDc())).collect(Collectors.toList());
-						;
 						bills.setFeeCenterListD(feeD);
 						List<FeeCenter> feeC = feeCenterList.stream().filter(e -> MagicValues.C.equals(e.getDc())).collect(Collectors.toList());
-						;
 						bills.setFeeCenterListC(feeC);
 						if (!feeCenterList.isEmpty()) {
+							List<FeeCenter> exrateList = feeCenterList.stream().filter(e-> e.getCurCode().equals("USD")).collect(Collectors.toList());
+							if (!exrateList.isEmpty()){
+								bills.setRate(exrateList.get(0).getExrate());
+							}else{
+								bills.setRate(new BigDecimal("1.00"));
+							}
 							for (FeeCenter item : feeCenterList) {
 								if (ObjectUtils.isNotNull(item.getShortName())) {
 									item.setCorpCnName(item.getShortName());
@@ -1832,7 +1839,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						.eq(Amends::getTenantId, AuthUtil.getTenantId())
 						.eq(Amends::getIsDeleted, 0)
 						.in(Amends::getOrigId, ids));
-					if (!amendsList.isEmpty()){
+					if (!amendsList.isEmpty()) {
 						ids.addAll(amendsList.stream().map(Amends::getId).collect(Collectors.toList()));
 					}
 				}
@@ -1974,7 +1981,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 				map.put(MagicValues.DATA, null);
 			}
 		} else if (MagicValues.COST.equals(reportCode) &&
-			(MagicValues.MEET.equals(groupCode) || MagicValues.MEET_BILL.equals(groupCode)||
+			(MagicValues.MEET.equals(groupCode) || MagicValues.MEET_BILL.equals(groupCode) ||
 				MagicValues.MEET_BILL_NUMBER.equals(groupCode) || MagicValues.MEET_AMEND.equals(groupCode))
 			&& (MagicValues.HYCK.equals(type) || MagicValues.HYJK.equals(type))) {
 			Bills bills = billsService.getById(billId);
@@ -2001,7 +2008,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						.eq(Amends::getTenantId, AuthUtil.getTenantId())
 						.eq(Amends::getIsDeleted, 0)
 						.in(Amends::getOrigId, ids));
-					if (!amendsList.isEmpty()){
+					if (!amendsList.isEmpty()) {
 						ids.addAll(amendsList.stream().map(Amends::getId).collect(Collectors.toList()));
 					}
 				}
@@ -2143,7 +2150,6 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 					.eq(HmmEdi::getTenantId, AuthUtil.getTenantId())
 					.eq(HmmEdi::getPid, bills.getId()));
 				bills.setHmmEdi(hmmEdi != null ? hmmEdi : new HmmEdi());
-				bills.setRate(ibCurrencyService.getCnyExrate(bills.getBillDate(), "USD", "D", "1"));
 				if (ObjectUtils.isNotNull(bills.getAmountProfitLoc()) && ObjectUtils.isNotNull(bills.getAmountDrLoc())) {
 					if (bills.getAmountProfitLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0 ||
 						bills.getAmountDrLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0) {
@@ -2307,6 +2313,12 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						}
 					}
 					if (!feeCenterList.isEmpty()) {
+						List<FeeCenter> exrateList = feeCenterList.stream().filter(e-> e.getCurCode().equals("USD")).collect(Collectors.toList());
+						if (!exrateList.isEmpty()){
+							bills.setRate(exrateList.get(0).getExrate());
+						}else{
+							bills.setRate(new BigDecimal("1.00"));
+						}
 						List<FeeCenter> feeCenters = feeCenterList.stream()
 							.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
 								Comparator.comparing(f -> f.getFeeId() + f.getCorpId() + f.getCurCode() + f.getDc()))), ArrayList::new));
@@ -2393,6 +2405,12 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						List<FeeCenter> feeC = feeCenterList.stream().filter(e -> MagicValues.C.equals(e.getDc())).collect(Collectors.toList());
 						bills.setFeeCenterListC(feeC);
 						if (!feeCenterList.isEmpty()) {
+							List<FeeCenter> exrateList = feeCenterList.stream().filter(e-> e.getCurCode().equals("USD")).collect(Collectors.toList());
+							if (!exrateList.isEmpty()){
+								bills.setRate(exrateList.get(0).getExrate());
+							}else{
+								bills.setRate(new BigDecimal("1.00"));
+							}
 							for (FeeCenter item : feeCenterList) {
 								if (ObjectUtils.isNotNull(item.getShortName())) {
 									item.setCorpCnName(item.getShortName());
@@ -6104,6 +6122,393 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 			} else {
 				map.put(MagicValues.DATA, list);
 			}
+		} else if ((MagicValues.BGSEA.equals(reportCode) || MagicValues.BGSIA.equals(reportCode) ||
+			MagicValues.BGAEA.equals(reportCode) || MagicValues.BGAIA.equals(reportCode))
+			&& MagicValues.AMEND.equals(type)
+			&& (MagicValues.BGSE.equals(groupCode) || MagicValues.BGSI.equals(groupCode) ||
+			MagicValues.BGAE.equals(groupCode) || MagicValues.BGAI.equals(groupCode))) {
+			List<CustomsDeclaration> list = new ArrayList<>();
+			Amends amends = amendsService.getById(billId);
+			String profitMargin = sysClient.getParamServiceNew(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.isEmpty()) {
+					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));
+				CustomsDeclaration bills = customsDeclarationService.getById(amends.getOrigId());
+				if (bills != null) {
+					R<String> biz = dictBizClient.getOneValue("src_type_los", bills.getSrcType(), AuthUtil.getTenantId());
+					if (biz.isSuccess()) {
+						bills.setSrcType(biz.getData());
+					}
+					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);
+					bills.setRate(ibCurrencyService.getCnyExrate(amends.getBillDate(), "USD", "D", "1"));
+					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.isEmpty()) {
+						for (FeeCenter item : feeCenterList) {
+							if (ObjectUtils.isNotNull(item.getShortName())) {
+								item.setCorpCnName(item.getShortName());
+							} else {
+								item.setCorpCnName("无");
+							}
+							if (ObjectUtils.isNotNull(item.getBillShortName())) {
+								item.setBillCorpCnName(item.getBillShortName());
+							} else {
+								item.setBillCorpCnName("无");
+							}
+						}
+						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.setRemarks(fee.getRemarks());
+							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.isEmpty()) {
+								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.isEmpty()) {
+								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.isEmpty()) {
+								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.isEmpty()) {
+								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);
+
+					if (!list.isEmpty()) {
+						for (CustomsDeclaration 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 amountCrLoc = new BigDecimal("0.00");
+							BigDecimal amountDrLoc = 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"));
+										amountDrLoc = amountDrLoc.add(ObjectUtils.isNotNull(feeReports.getAmountLocD()) ? feeReports.getAmountLocD() : 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"));
+										amountCrLoc = amountCrLoc.add(ObjectUtils.isNotNull(feeReports.getAmountLocC()) ? feeReports.getAmountLocC() : 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"));
+										amountDrLoc = amountDrLoc.add(ObjectUtils.isNotNull(feeReports.getAmountLocD()) ? feeReports.getAmountLocD() : 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"));
+										amountCrLoc = amountCrLoc.add(ObjectUtils.isNotNull(feeReports.getAmountLocC()) ? feeReports.getAmountLocC() : new BigDecimal("0.00"));
+									}
+								}
+								feeCenterReports.add(feeCenterReports1);
+							}
+							item.setAmountProfit(amountDr.subtract(amountCr));
+							item.setAmountProfitUsd(amountDrUsd.subtract(amountCrUsd));
+							item.setAmountProfitLoc(amountDrLoc.subtract(amountCrLoc));
+							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"));
+										amountDrLoc = amountDrLoc.add(ObjectUtils.isNotNull(feeReports.getAmountLocD()) ? feeReports.getAmountLocD() : 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"));
+										amountCrLoc = amountCrLoc.add(ObjectUtils.isNotNull(feeReports.getAmountLocC()) ? feeReports.getAmountLocC() : new BigDecimal("0.00"));
+									}
+								}
+								feeCenterReports.add(feeCenterReports1);
+							}
+
+							item.setAmountDr(amountDr);
+							item.setAmountCr(amountCr);
+							item.setAmountDrUsd(amountDrUsd);
+							item.setAmountCrUsd(amountCrUsd);
+							item.setAmountDrLoc(amountDrLoc);
+							item.setAmountCrLoc(amountCrLoc);
+							item.setAmountProfitUpdate(amountDr.subtract(amountCr));
+							item.setAmountProfitUsdUpdate(amountDrUsd.subtract(amountCrUsd));
+							item.setAmountProfitLocUpdate(amountDrLoc.subtract(amountCrLoc));
+							item.setAmountProfitLocUpdate(item.getAmountProfitLocUpdate().setScale(2, RoundingMode.HALF_UP));
+							item.setAmountProfitLoc(item.getAmountProfitLoc().setScale(2, RoundingMode.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, RoundingMode.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.setDept(dept);
+							item.setFeeCenterList(feeCenterReports);
+						}
+					}
+					map.put(MagicValues.DATA, list);
+				}
+			} else {
+				map.put(MagicValues.DATA, list);
+			}
 		}
 		return R.data(map);
 	}
@@ -6784,7 +7189,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 			new File(baseFilePath).mkdirs();
 		}
 		String realFileName = generateMailVo.getFileName() + "." + generateMailVo.getFileType().toLowerCase();
-		String filePath =  baseFilePath + "/" + realFileName;
+		String filePath = baseFilePath + "/" + realFileName;
 		try {
 			if (Objects.nonNull(generateMailVo.getFileContent())) {
 				Files.write(Paths.get(filePath), generateMailVo.getFileContent());

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/trade/service/impl/PayableStorageFeesServiceImpl.java

@@ -401,6 +401,7 @@ public class PayableStorageFeesServiceImpl extends ServiceImpl<PayableStorageFee
 				feeCenter.setStorageDate(item.getChargingStartDate());
 				feeCenter.setOutboundDate(item.getChargingEndDate());
 				feeCenter.setSrcItemId(item.getId());
+				feeCenter.setAutomaticGenerated("1");
 				feeCenterList.add(feeCenter);
 			} else {
 				throw new RuntimeException("未查到海运进口单据");
@@ -654,6 +655,7 @@ public class PayableStorageFeesServiceImpl extends ServiceImpl<PayableStorageFee
 		List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
 			.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
 			.eq(FeeCenter::getIsDeleted, 0)
+			.eq(FeeCenter::getAutomaticGenerated, 1)
 			.in(FeeCenter::getId, ids));
 		if (!feeCenterList.isEmpty()) {
 			List<Long> feeCenterIdList = feeCenterList.stream().map(FeeCenter::getId).collect(Collectors.toList());

+ 10 - 16
blade-service/blade-los/src/main/java/org/springblade/los/view/mapper/FinanceProfitMapper.xml

@@ -79,6 +79,7 @@
         seb.amount_dr_loc AS amountDrLoc,
         seb.real_amount_dr_loc AS realAmountDrLoc,
         seb.amount_cr_loc AS amountCrLoc,
+        seb.corp_source AS corpSource,
         seb.real_amount_cr_loc AS realAmountCrLoc
         FROM
         los_finance_profit seb
@@ -89,6 +90,9 @@
         <if test="data.billType != null and data.billType != ''">
             and find_in_set(seb.business_type,#{data.billType})
         </if>
+        <if test="data.corpSource != null and data.corpSource != ''">
+            and seb.corp_source = #{data.corpSource}
+        </if>
         <if test="data.billNo != null and data.billNo != ''">
             and seb.bill_no like concat('%', #{data.billNo}, '%')
         </if>
@@ -156,14 +160,7 @@
                 and seb.bill_date &lt;= #{data.statisticsDateEnd}
             </if>
         </if>
-        <if test="data.costMerge != null and data.costMerge != ''">
-            GROUP BY
-            seb.bill_no
-        </if>
-        <if test="data.consistentCorpMerge != null and data.consistentCorpMerge != ''">
-            GROUP BY
-            seb.corp_id
-        </if>
+
         ORDER BY
         seb.create_time
     </select>
@@ -201,6 +198,7 @@
         seb.amount_dr_loc AS amountDrLoc,
         seb.real_amount_dr_loc AS realAmountDrLoc,
         seb.amount_cr_loc AS amountCrLoc,
+        seb.corp_source AS corpSource,
         seb.real_amount_cr_loc AS realAmountCrLoc
         FROM
         los_finance_profit seb
@@ -211,6 +209,9 @@
         <if test="data.billType != null and data.billType != ''">
             and find_in_set(seb.business_type,#{data.billType})
         </if>
+        <if test="data.corpSource != null and data.corpSource != ''">
+            and seb.corp_source = #{data.corpSource}
+        </if>
         <if test="data.billNo != null and data.billNo != ''">
             and seb.bill_no like concat('%', #{data.billNo}, '%')
         </if>
@@ -278,14 +279,7 @@
                 and seb.bill_date &lt;= #{data.statisticsDateEnd}
             </if>
         </if>
-        <if test="data.costMerge != null and data.costMerge != ''">
-            GROUP BY
-            seb.bill_no
-        </if>
-        <if test="data.consistentCorpMerge != null and data.consistentCorpMerge != ''">
-            GROUP BY
-            seb.corp_id
-        </if>
+
         ORDER BY
         seb.create_time
     </select>