소스 검색

Sales Report

wfg 3 달 전
부모
커밋
aacd6d6df5

+ 23 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/sea/entity/Bills.java

@@ -2348,4 +2348,27 @@ public class Bills implements Serializable {
 	 */
 	@TableField(exist = false)
 	private String payableAt;
+
+	/**
+	 * 业务来源 报表中 dictionaryConversion 函数更改了 srcType 值
+	 */
+	@TableField(exist = false)
+	private String srcTypeDisplay;
+
+	/**
+	 * hpaymode  报表中 dictionaryConversion 函数更改了 hpaymode 值
+	 */
+	@TableField(exist = false)
+	private String hpaymodeDisplay;
+
+	/**
+	 * mpaymode  报表中 dictionaryConversion 函数更改了 mpaymode 值
+	 */
+	@TableField(exist = false)
+	private String mpaymodeDisplay;
+	/**
+	 * 签单方式 报表中 dictionaryConversion 函数更改了 issueType 值
+	 */
+	@TableField(exist = false)
+	private String issueTypeDisplay;
 }

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/corps/service/impl/BCorpsServiceImpl.java

@@ -438,11 +438,13 @@ public class BCorpsServiceImpl extends ServiceImpl<CorpsMapper, BCorps> implemen
 			if (corps == null) {
 				BeanUtil.copy(item, bCorps);
 				//首字母为空
+				/*
 				if (null == bCorps.getInitials() || "".equals(bCorps.getInitials())) {
 					//获得名称首字母
 					String initials = getSpells(bCorps.getCnName());
 					bCorps.setInitials(initials.substring(0, 1));
 				}
+				*/
 				/*if (cname > 0) {
 					throw new RuntimeException("中文名称" + bCorps.getCnName() + "不允许重复");
 				}

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

@@ -869,7 +869,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 		} else {
 			throw new RuntimeException("获取报表表头数据失败");
 		}
-		// 销售报告 SALES REPORT
+		// 销售报告 SALES REPORT 费用
 		if (MagicValues.BUSINESS.equals(reportCode) && MagicValues.SALES_REPORT.equals(groupCode) && (MagicValues.HYCK.equals(type) || MagicValues.HYJK.equals(type))) {
 			List<Bills> list = new ArrayList<>();
 			// String profitMargin = sysClient.getParamServiceNew(MagicValues.PROFIT_MARGIN);
@@ -881,13 +881,13 @@ 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"));
+				BigDecimal currentCnyExrate = ibCurrencyService.getCnyExrate(MagicValues.HYCK.equals(type) ? bills.getEtd() : bills.getEta(), "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) {
 						bills.setGrossMargin(new BigDecimal(MagicValues.ZERO));
 					} else {
-						bills.setGrossMargin(bills.getAmountProfitLoc().divide(bills.getAmountDrLoc(), 4, RoundingMode.HALF_UP));
+						bills.setGrossMargin(bills.getAmountProfitLoc().divide(bills.getAmountDrLoc(), 3, RoundingMode.HALF_UP));
 					}
 				} else {
 					bills.setGrossMargin(new BigDecimal(MagicValues.ZERO));
@@ -1030,7 +1030,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						if (!exrateList.isEmpty()){
 							bills.setRate(exrateList.get(0).getExrate());
 						}else{
-							bills.setRate(new BigDecimal("1.00"));
+							bills.setRate(currentCnyExrate);
 						}
 						List<FeeCenter> feeCenters = feeCenterList.stream()
 							.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
@@ -1121,7 +1121,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 							if (!exrateList.isEmpty()){
 								bills.setRate(exrateList.get(0).getExrate());
 							}else{
-								bills.setRate(new BigDecimal("1.00"));
+								bills.setRate(currentCnyExrate);
 							}
 							for (FeeCenter item : feeCenterList) {
 								if (ObjectUtils.isNotNull(item.getShortName())) {
@@ -1344,7 +1344,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 								item.getAmountDrLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0) {
 								item.setGrossMargin(new BigDecimal(MagicValues.ZERO));
 							} else {
-								item.setGrossMargin(item.getAmountProfitLoc().divide(item.getAmountDrLoc(), 4, RoundingMode.HALF_UP));
+								item.setGrossMargin(item.getAmountProfitLoc().divide(item.getAmountDrLoc(), 3, RoundingMode.HALF_UP));
 							}
 						} else {
 							item.setGrossMargin(new BigDecimal(MagicValues.ZERO));
@@ -1370,8 +1370,6 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						// 12731	W0689	W0689
 						String specPScorpIds = ",1425,1561,3415,5110,6363,10120,11794,12247,12431,12731,";
 
-						List<FeeCenter> feeList = Stream.concat(item.getFeeCenterListD().stream(), item.getFeeCenterListC().stream()).collect(Collectors.toList());
-
 						BigDecimal usdOFProfit = new BigDecimal(BigInteger.ZERO);
 						BigDecimal ofInAmtProfit = new BigDecimal(BigInteger.ZERO);
 						Integer ofCNYCount = 0;
@@ -1388,6 +1386,14 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						// 高收退费客户 Id
 						Long hpsCorpId = 0L;
 
+						List<FeeCenter> feeList = null;
+						if (item.equals(bills)) {
+							feeList = allFeeCenter;
+							// feeList = Stream.concat(item.getFeeCenterListD().stream(), item.getFeeCenterListC().stream()).collect(Collectors.toList());
+						}else{
+							feeList = Stream.concat(item.getFeeCenterListD().stream(), item.getFeeCenterListC().stream()).collect(Collectors.toList());
+						}
+
 						if (ObjectUtils.isNotNull(feeList)) {
 							for (FeeCenter fee : feeList) {
 								if (specPSCorpId == 0 && ObjectUtils.isNotNull(fee.getCorpId())) {
@@ -1443,7 +1449,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						Integer corpIsDC = 0;
 						if (ObjectUtils.isNotNull(bCorps11)) {
 							PsRate = new BigDecimal(bCorps11.getPsRate());
-							if (ObjectUtils.isNotNull(bCorps11.getCorpTypeName()) && bCorps11.getCorpTypeName().indexOf("国内直接客户") >= 0) {
+							if (ObjectUtils.isNotNull(bCorps11.getCorpTypeName()) && bCorps11.getCorpTypeName().contains("国内直接客户")) {
 								corpIsDC = 1;
 							}
 						}
@@ -1490,8 +1496,8 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						}
 
 						if (("PP".equals(item.getMpaymode()) && (MagicValues.DD.equals(item.getBillType()) || MagicValues.MM.equals(item.getBillType())))
-							|| ("PP".equals(item.getMpaymode()) && ObjectUtils.isNotNull(item.getHblno()))) {
-							if (specPScorpIds.indexOf("," + specPSCorpId.toString() + ",") >= 0) {
+							|| ("CC".equals(item.getMpaymode()) && ObjectUtils.isNotNull(item.getHblno()))) {
+							if (specPScorpIds.contains("," + specPSCorpId.toString() + ",")) {
 								if (usdOFProfit.compareTo(BigDecimal.ZERO) != 0) {
 									BigDecimal tt1 = usdOFProfit.add(ofInAmtProfit).add(HPSProfit).setScale(2, BigDecimal.ROUND_HALF_UP);
 									if (tt1.compareTo(BigDecimal.ZERO) != 0) {
@@ -1592,7 +1598,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 								profitRate = sumProfitLoc.divide(sumLocDr, 4, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
 							}
 
-							String profitStatus = "";
+							String profitStatus = "F";
 							if (!ps_ps.isEmpty()) {
 								profitStatus = "U";
 							}
@@ -2155,7 +2161,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						bills.getAmountDrLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0) {
 						bills.setGrossMargin(new BigDecimal(MagicValues.ZERO));
 					} else {
-						bills.setGrossMargin(bills.getAmountProfitLoc().divide(bills.getAmountDrLoc(), 4, RoundingMode.HALF_UP));
+						bills.setGrossMargin(bills.getAmountProfitLoc().divide(bills.getAmountDrLoc(), 3, RoundingMode.HALF_UP));
 					}
 				} else {
 					bills.setGrossMargin(new BigDecimal(MagicValues.ZERO));
@@ -2165,6 +2171,8 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 					System.out.println("GrossMargin: " + bills.getGrossMargin().toString());
 				}
 
+				BigDecimal currentCnyExrate = ibCurrencyService.getCnyExrate(MagicValues.HYCK.equals(type) ? bills.getEtd() : bills.getEta(), "USD", "D", "1");
+
 				List<FeeCenter> allFeeCenter = new ArrayList<>();
 
 				// 直单或主单
@@ -2317,7 +2325,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						if (!exrateList.isEmpty()){
 							bills.setRate(exrateList.get(0).getExrate());
 						}else{
-							bills.setRate(new BigDecimal("1.00"));
+							bills.setRate(currentCnyExrate);
 						}
 						List<FeeCenter> feeCenters = feeCenterList.stream()
 							.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
@@ -2409,7 +2417,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 							if (!exrateList.isEmpty()){
 								bills.setRate(exrateList.get(0).getExrate());
 							}else{
-								bills.setRate(new BigDecimal("1.00"));
+								bills.setRate(currentCnyExrate);
 							}
 							for (FeeCenter item : feeCenterList) {
 								if (ObjectUtils.isNotNull(item.getShortName())) {
@@ -2633,7 +2641,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 								item.getAmountDrLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0) {
 								item.setGrossMargin(new BigDecimal(MagicValues.ZERO));
 							} else {
-								item.setGrossMargin(item.getAmountProfitLoc().divide(item.getAmountDrLoc(), 4, RoundingMode.HALF_UP));
+								item.setGrossMargin(item.getAmountProfitLoc().divide(item.getAmountDrLoc(), 3, RoundingMode.HALF_UP));
 							}
 						} else {
 							item.setGrossMargin(new BigDecimal(MagicValues.ZERO));
@@ -2779,7 +2787,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						}
 
 						if (("PP".equals(item.getMpaymode()) && (MagicValues.DD.equals(item.getBillType()) || MagicValues.MM.equals(item.getBillType())))
-							|| ("PP".equals(item.getMpaymode()) && ObjectUtils.isNotNull(item.getHblno()))) {
+							|| ("CC".equals(item.getMpaymode()) && ObjectUtils.isNotNull(item.getHblno()))) {
 							if (specPScorpIds.indexOf("," + specPSCorpId.toString() + ",") >= 0) {
 								if (usdOFProfit.compareTo(BigDecimal.ZERO) != 0) {
 									BigDecimal tt1 = usdOFProfit.add(ofInAmtProfit).add(HPSProfit).setScale(2, BigDecimal.ROUND_HALF_UP);
@@ -2889,7 +2897,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 							bills.setAmountProfitLoc(bills.getAmountProfit().add(bills.getAmountProfitUsd().multiply(bills.getRate())));
 							BigDecimal dAll = bills.getAmountDr().add(bills.getAmountDrUsd().multiply(bills.getRate()));
 							bills.setGrossMargin(bills.getAmountProfitLoc().compareTo(BigDecimal.ZERO) == 0 || dAll.compareTo(BigDecimal.ZERO) == 0 ?
-								BigDecimal.ZERO : bills.getAmountProfitLoc().divide(dAll, 4, RoundingMode.HALF_UP));
+								BigDecimal.ZERO : bills.getAmountProfitLoc().divide(dAll, 3, RoundingMode.HALF_UP));
 							BigDecimal sumProfitUSD = sumUSDDr.subtract(sumUSDCr).setScale(2, BigDecimal.ROUND_HALF_UP);
 							BigDecimal sumProfitCNY = sumCNYDr.subtract(sumCNYCr).setScale(2, BigDecimal.ROUND_HALF_UP);
 							BigDecimal sumProfitLoc = sumLocDr.subtract(sumLocCr).setScale(2, BigDecimal.ROUND_HALF_UP);
@@ -2915,6 +2923,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 								}
 							}
 
+							// Amend
 							item.setProfitStatus(profitStatus);
 							//[IF([WFPK_ProfitStatus]='Z', 'Profit was zero!',
 							// IF([WFPK_ProfitStatus]='D', 'Profit was unfair and low !',
@@ -3075,7 +3084,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						bills.getAmountDrLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0) {
 						bills.setGrossMargin(new BigDecimal(MagicValues.ZERO));
 					} else {
-						bills.setGrossMargin(bills.getAmountProfitLoc().divide(bills.getAmountDrLoc(), 4, RoundingMode.HALF_UP));
+						bills.setGrossMargin(bills.getAmountProfitLoc().divide(bills.getAmountDrLoc(), 3, RoundingMode.HALF_UP));
 					}
 				} else {
 					bills.setGrossMargin(new BigDecimal(MagicValues.ZERO));
@@ -5176,7 +5185,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 									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));
+									item.setGrossMargin(item.getAmountProfitLocUpdate().divide(item.getAmountDrLoc(), 3, RoundingMode.HALF_UP));
 								}
 							} else {
 								item.setGrossMargin(new BigDecimal(MagicValues.ZERO));
@@ -6098,7 +6107,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 									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));
+									item.setGrossMargin(item.getAmountProfitLocUpdate().divide(item.getAmountDrLoc(), 3, RoundingMode.HALF_UP));
 								}
 							} else {
 								item.setGrossMargin(new BigDecimal(MagicValues.ZERO));
@@ -6485,7 +6494,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 									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));
+									item.setGrossMargin(item.getAmountProfitLocUpdate().divide(item.getAmountDrLoc(), 3, RoundingMode.HALF_UP));
 								}
 							} else {
 								item.setGrossMargin(new BigDecimal(MagicValues.ZERO));
@@ -6559,7 +6568,7 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 						bills.getAmountDrLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0) {
 						bills.setGrossMargin(new BigDecimal(MagicValues.ZERO));
 					} else {
-						bills.setGrossMargin(bills.getAmountProfitLoc().divide(bills.getAmountDrLoc(), 4, RoundingMode.HALF_UP));
+						bills.setGrossMargin(bills.getAmountProfitLoc().divide(bills.getAmountDrLoc(), 3, RoundingMode.HALF_UP));
 					}
 				} else {
 					bills.setGrossMargin(new BigDecimal(MagicValues.ZERO));
@@ -7293,23 +7302,34 @@ public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports> impl
 	 * @return 转换后数据
 	 */
 	private Bills dictionaryConversion(Bills bills) {
-		R<String> biz = dictBizClient.getOneValue("src_type_los", bills.getSrcType(), AuthUtil.getTenantId());
-		if (biz.isSuccess()) {
-			bills.setSrcType(biz.getData());
-		}
-		R<DictBiz> resDictBiz = dictBizClient.getDictBiz("payment_method_los", bills.getHpaymode(), AuthUtil.getTenantId());
-		if (resDictBiz.isSuccess() && ObjectUtils.isNotNull(resDictBiz.getData())) {
-			bills.setHpaymode(resDictBiz.getData().getRemark());
-		}
-		R<DictBiz> resDictBizM = dictBizClient.getDictBiz("payment_method_los", bills.getMpaymode(), AuthUtil.getTenantId());
-		if (resDictBizM.isSuccess() && ObjectUtils.isNotNull(resDictBizM.getData())) {
-			bills.setMpaymode(resDictBizM.getData().getRemark());
-		}
-		R<DictBiz> resDictBiz1 = dictBizClient.getDictBiz("issue_type_F", bills.getIssueType(), AuthUtil.getTenantId());
-		if (resDictBiz1.isSuccess() && ObjectUtils.isNotNull(resDictBiz1.getData())) {
-			bills.setIssueType(resDictBiz1.getData().getRemark());
+		if(ObjectUtils.isNotNull(bills)) {
+			bills.setCorpShortName(bills.getShortName());
+
+			bills.setSrcTypeDisplay(bills.getSrcType());
+			R<String> biz = dictBizClient.getOneValue("src_type_los", bills.getSrcType(), AuthUtil.getTenantId());
+			if (biz.isSuccess()) {
+				bills.setSrcTypeDisplay(biz.getData());
+			}
+
+			bills.setHpaymodeDisplay(bills.getHpaymode());
+			R<DictBiz> resDictBiz = dictBizClient.getDictBiz("payment_method_los", bills.getHpaymode(), AuthUtil.getTenantId());
+			if (resDictBiz.isSuccess() && ObjectUtils.isNotNull(resDictBiz.getData())) {
+				bills.setHpaymodeDisplay(resDictBiz.getData().getRemark());
+			}
+
+			bills.setMpaymodeDisplay(bills.getMpaymode());
+			R<DictBiz> resDictBizM = dictBizClient.getDictBiz("payment_method_los", bills.getMpaymode(), AuthUtil.getTenantId());
+			if (resDictBizM.isSuccess() && ObjectUtils.isNotNull(resDictBizM.getData())) {
+				bills.setMpaymodeDisplay(resDictBizM.getData().getRemark());
+			}
+
+			bills.setIssueTypeDisplay(bills.getIssueType());
+			R<DictBiz> resDictBiz1 = dictBizClient.getDictBiz("issue_type_F", bills.getIssueType(), AuthUtil.getTenantId());
+			if (resDictBiz1.isSuccess() && ObjectUtils.isNotNull(resDictBiz1.getData())) {
+				bills.setIssueTypeDisplay(resDictBiz1.getData().getRemark());
+			}
 		}
+
 		return bills;
 	}
-
 }