1、汇总报错修改
This commit is contained in:
parent
b7de11b494
commit
a5e13b915e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -57,7 +57,7 @@ public class SaleDataLinkUpJob implements IJob {
|
||||
LOGGER.info("======== 销售汇总各板块数据执行完成 ========");
|
||||
|
||||
// 数据同步完成后执行汇总计算
|
||||
LOGGER.info("======== 开始执行一体化-销售数据汇总计算 ========");
|
||||
LOGGER.info("======== 开始执行一体化-销售数据BI汇总计算 ========");
|
||||
//获取汇总计算时间
|
||||
Set<DateRange> collect = list.stream().filter(o -> o.getStartDate() != null || o.getEndDate() != null)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
@ -602,6 +602,75 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
List<BO> bos = new ArrayList<>();
|
||||
// for (String wlmc : distinctList) {
|
||||
// RowMap currentMonthRow = currentMonthMap.get(wlmc);
|
||||
|
||||
|
||||
// for (RowMap currentMonthRow : currentMonthData) {
|
||||
// String wlmc = currentMonthRow.getString("WLMC");
|
||||
// if (currentMonthRow == null || currentMonthRow.getDouble("totalAmount") == 0.0) continue;
|
||||
//
|
||||
// double avgPrice = 0.00;
|
||||
// BO summaryBO = new BO();
|
||||
// summaryBO.set("YEARMONTH", yearMonth);
|
||||
// summaryBO.set("WLMC", wlmc);
|
||||
// if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||
// Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
// double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
// Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
// double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
// summaryBO.set("CGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||
// if (totalAmount!=0 || totalQuantity!=0) {
|
||||
// avgPrice = totalAmount / (totalQuantity / 1000);
|
||||
// }else {
|
||||
// avgPrice = 0;
|
||||
// }
|
||||
// }else {
|
||||
// Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
// double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
// Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
// double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
// summaryBO.set("CGZL", totalQuantity);
|
||||
// if (totalAmount!=0 || totalQuantity!=0) {
|
||||
// avgPrice = totalAmount / totalQuantity;
|
||||
// }else {
|
||||
// avgPrice = 0;
|
||||
// }
|
||||
// }
|
||||
// summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount"));
|
||||
// summaryBO.set("PJDJ", avgPrice);
|
||||
//
|
||||
// // 添加上月数据
|
||||
// RowMap lastMonthRow = lastMonthMap.get(wlmc);
|
||||
// if (lastMonthRow != null) {
|
||||
// Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
// double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
// Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
// double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
// if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||
// summaryBO.set("SQCGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||
// }else {
|
||||
// summaryBO.set("SQCGZL", totalQuantity);
|
||||
// }
|
||||
// summaryBO.set("SQCGZE", totalAmount);
|
||||
// }
|
||||
//
|
||||
// // 添加去年同期数据
|
||||
// RowMap lastYearMonthRow = lastYearMonthMap.get(wlmc);
|
||||
// if (lastYearMonthRow != null) {
|
||||
// Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
// double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
// Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
// double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
// if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||
// summaryBO.set("TQCGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||
// }else {
|
||||
// summaryBO.set("TQCGZL", totalQuantity);
|
||||
// }
|
||||
// summaryBO.set("TQCGZE", totalAmount);
|
||||
// }
|
||||
//
|
||||
// summaryBO.set("BKGS", bkgs);
|
||||
// bos.add(summaryBO);
|
||||
// }
|
||||
for (RowMap currentMonthRow : currentMonthData) {
|
||||
String wlmc = currentMonthRow.getString("WLMC");
|
||||
if (currentMonthRow == null || currentMonthRow.getDouble("totalAmount") == 0.0) continue;
|
||||
@ -610,66 +679,67 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
BO summaryBO = new BO();
|
||||
summaryBO.set("YEARMONTH", yearMonth);
|
||||
summaryBO.set("WLMC", wlmc);
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||
Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
summaryBO.set("CGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||
if (totalAmount!=0 || totalQuantity!=0) {
|
||||
avgPrice = totalAmount / (totalQuantity / 1000);
|
||||
}else {
|
||||
avgPrice = 0;
|
||||
|
||||
Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")) {
|
||||
double adjustedQuantity = totalQuantity != 0 ? totalQuantity / 1000 : 0;
|
||||
summaryBO.set("CGZL", adjustedQuantity);
|
||||
// 防止除零错误
|
||||
if (adjustedQuantity != 0 && totalAmount != 0) {
|
||||
avgPrice = totalAmount / adjustedQuantity;
|
||||
}
|
||||
}else {
|
||||
Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
} else {
|
||||
summaryBO.set("CGZL", totalQuantity);
|
||||
if (totalAmount!=0 || totalQuantity!=0) {
|
||||
// 防止除零错误
|
||||
if (totalQuantity != 0 && totalAmount != 0) {
|
||||
avgPrice = totalAmount / totalQuantity;
|
||||
}else {
|
||||
avgPrice = 0;
|
||||
}
|
||||
}
|
||||
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount"));
|
||||
|
||||
summaryBO.set("CGZE", totalAmount);
|
||||
summaryBO.set("PJDJ", avgPrice);
|
||||
|
||||
// 添加上月数据
|
||||
// 添加上月数据(注意:这里应使用lastMonthRow的数据,而非currentMonthRow)
|
||||
RowMap lastMonthRow = lastMonthMap.get(wlmc);
|
||||
if (lastMonthRow != null) {
|
||||
Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||
summaryBO.set("SQCGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||
}else {
|
||||
summaryBO.set("SQCGZL", totalQuantity);
|
||||
Double lastTotalQuantity1 = lastMonthRow.getDouble("totalQuantity");
|
||||
double lastTotalQuantity = lastTotalQuantity1 != null ? lastTotalQuantity1 : 0.0;
|
||||
Double lastTotalAmount1 = lastMonthRow.getDouble("totalAmount");
|
||||
double lastTotalAmount = lastTotalAmount1 != null ? lastTotalAmount1 : 0.0;
|
||||
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")) {
|
||||
summaryBO.set("SQCGZL", lastTotalQuantity != 0 ? lastTotalQuantity / 1000 : 0);
|
||||
} else {
|
||||
summaryBO.set("SQCGZL", lastTotalQuantity);
|
||||
}
|
||||
summaryBO.set("SQCGZE", totalAmount);
|
||||
summaryBO.set("SQCGZE", lastTotalAmount);
|
||||
}
|
||||
|
||||
// 添加去年同期数据
|
||||
// 添加去年同期数据(注意:这里应使用lastYearMonthRow的数据,而非currentMonthRow)
|
||||
RowMap lastYearMonthRow = lastYearMonthMap.get(wlmc);
|
||||
if (lastYearMonthRow != null) {
|
||||
Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||
summaryBO.set("TQCGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||
}else {
|
||||
summaryBO.set("TQCGZL", totalQuantity);
|
||||
Double lastYearTotalQuantity1 = lastYearMonthRow.getDouble("totalQuantity");
|
||||
double lastYearTotalQuantity = lastYearTotalQuantity1 != null ? lastYearTotalQuantity1 : 0.0;
|
||||
Double lastYearTotalAmount1 = lastYearMonthRow.getDouble("totalAmount");
|
||||
double lastYearTotalAmount = lastYearTotalAmount1 != null ? lastYearTotalAmount1 : 0.0;
|
||||
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")) {
|
||||
summaryBO.set("TQCGZL", lastYearTotalQuantity != 0 ? lastYearTotalQuantity / 1000 : 0);
|
||||
} else {
|
||||
summaryBO.set("TQCGZL", lastYearTotalQuantity);
|
||||
}
|
||||
summaryBO.set("TQCGZE", totalAmount);
|
||||
summaryBO.set("TQCGZE", lastYearTotalAmount);
|
||||
}
|
||||
|
||||
summaryBO.set("BKGS", bkgs);
|
||||
bos.add(summaryBO);
|
||||
}
|
||||
|
||||
|
||||
if (!bos.isEmpty()) {
|
||||
// 批量插入数据
|
||||
int batchSize = 1000;
|
||||
@ -756,16 +826,30 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
BO summaryBO = new BO();
|
||||
summaryBO.set("RQ", dateStr);
|
||||
summaryBO.set("WLMC", wlmc);
|
||||
|
||||
// 安全获取数值,处理可能的空值
|
||||
Double totalQuantity = row.getDouble("totalQuantity");
|
||||
Double totalAmount = row.getDouble("totalAmount");
|
||||
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||
summaryBO.set("CGZL", row.getDouble("totalQuantity")/1000);
|
||||
avgPrice = row.getDouble("totalAmount") != 0 ?
|
||||
row.getDouble("totalAmount") / (row.getDouble("totalQuantity")/1000) : 0;
|
||||
}else {
|
||||
summaryBO.set("CGZL", row.getDouble("totalQuantity"));
|
||||
avgPrice = row.getDouble("totalAmount") != 0 ?
|
||||
row.getDouble("totalAmount") / row.getDouble("totalQuantity") : 0;
|
||||
double adjustedQuantity = (totalQuantity != null ? totalQuantity : 0.0) / 1000;
|
||||
summaryBO.set("CGZL", adjustedQuantity);
|
||||
|
||||
// 防止除零错误
|
||||
if (totalAmount != null && totalAmount != 0 && adjustedQuantity != 0) {
|
||||
avgPrice = totalAmount / adjustedQuantity;
|
||||
}
|
||||
} else {
|
||||
double quantity = totalQuantity != null ? totalQuantity : 0.0;
|
||||
summaryBO.set("CGZL", quantity);
|
||||
|
||||
// 防止除零错误
|
||||
if (totalAmount != null && totalAmount != 0 && quantity != 0) {
|
||||
avgPrice = totalAmount / quantity;
|
||||
}
|
||||
}
|
||||
summaryBO.set("CGZE", row.getDouble("totalAmount"));
|
||||
|
||||
summaryBO.set("CGZE", totalAmount != null ? totalAmount : 0.0);
|
||||
summaryBO.set("PJDJ", avgPrice);
|
||||
summaryBO.set("BKGS", bkgs);
|
||||
bos.add(summaryBO);
|
||||
|
||||
@ -74,6 +74,9 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
LOGGER.error("主配置中BKGS为空,无法进行汇总计算");
|
||||
return;
|
||||
}
|
||||
if (bkgs!="龙牌" || bkgs!="梦牌" || bkgs!="泰山石膏" || bkgs!="北新嘉宝莉" || bkgs!="北新涂料"){
|
||||
LOGGER.error("主配置中板块公司为:{},无需进行计算",bkgs);
|
||||
}
|
||||
if (dateRange == null || dateRange.getStartDate() == null || dateRange.getEndDate() == null) {
|
||||
LOGGER.info("未提供有效时间范围,按当前日期计算");
|
||||
calculateForCurrentDate(bkgs);
|
||||
@ -258,10 +261,6 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
// String lb_1 = map.getString("LB_1");
|
||||
processProductData(lb_1, year, month, yearMonth, bkgs);
|
||||
}
|
||||
// 处理石膏板数据
|
||||
// processProductData("石膏板", year, month, yearMonth, bkgs);
|
||||
// 处理轻钢龙骨数据
|
||||
// processProductData("轻钢龙骨", year, month, yearMonth, bkgs);
|
||||
LOGGER.info("产品销售月明细数据保存成功");
|
||||
} catch (Exception e) {
|
||||
String errorMsg = String.format("产品销售月明细数据计算失败: %s", e.getMessage());
|
||||
@ -288,7 +287,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
for (String brand : salesMap.keySet()) {
|
||||
BO productBO = createBaseBO(bkgs);
|
||||
productBO.set("YEARMONTH", yearMonth);
|
||||
if ("北新嘉宝莉".equals(bkgs)) {
|
||||
if ("北新嘉宝莉".equals(bkgs) || "北新涂料".equals(bkgs)) {
|
||||
if ("其他".equals(productType)){
|
||||
productBO.set("PRODUCT_TYPE", "其他");
|
||||
}else {
|
||||
|
||||
@ -142,17 +142,9 @@ public class SaleDataSyncServiceImpl implements DataSyncService {
|
||||
// 按时间范围删除
|
||||
deleteTargetData(targetTable, targetTimeField, startDate, endDate);
|
||||
}
|
||||
|
||||
// 新增:判断是否为高斯数据库
|
||||
// if ("gaosi".equalsIgnoreCase(ccId)) {
|
||||
// LOGGER.info("检测到高斯数据库特殊配置,使用JDBC连接池查询");
|
||||
// queryGaussDataWithCondition(tableName, timeField, startDate, endDate, partitionField,
|
||||
// fieldMappings, targetTable);
|
||||
// } else {
|
||||
// 查询源表数据(跨库查询)
|
||||
querySourceData(ccId, tableName, timeField, startDate, endDate, partitionField,
|
||||
fieldMappings, targetTable,jezd);
|
||||
// }
|
||||
dateRange.setStartDate(startDate);
|
||||
dateRange.setEndDate(endDate);
|
||||
return dateRange;
|
||||
@ -780,6 +772,11 @@ public class SaleDataSyncServiceImpl implements DataSyncService {
|
||||
if ("梦牌".equals(map.getString("BKGS")) && "梦牌新材料(平邑)有限公司".equals(map.getString("XSZZ"))){
|
||||
continue;
|
||||
}
|
||||
if ("北新防水".equals(map.getString("BKGS")) && "否".equals(map.getString("F_SFNBJY"))
|
||||
&& !map.getString("XSZZ").equals("北新防水工程(辽宁)有限公司")
|
||||
&& !map.getString("XSZZ").equals("北新防水工程(四川)有限公司")){
|
||||
continue;
|
||||
}
|
||||
// 复制所有字段(排除系统字段)
|
||||
for (String key : map.keySet()) {
|
||||
if (!key.equalsIgnoreCase("ID") &&
|
||||
|
||||
Loading…
Reference in New Issue
Block a user