整体修改一体化事业部BI汇总sql逻辑-4

This commit is contained in:
yujh_java 2025-09-17 21:30:27 +08:00
parent ebaa68de13
commit 8458071cb7

View File

@ -113,7 +113,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
newcalculateAndSaveReceivableYear(startDate, yearMonth, bkgs);
// 5. 计算并保存营业收入年度汇总(按月存储)
calculateAndSaveRevenueYear(year, month, yearMonth, bkgs);
calculateAndSaveRevenueYear(startDate,year, month, yearMonth, bkgs);
// 6. 计算并保存产品单价日明细
// calculateAndSaveUnitPriceDaily(year, month, day, currentDate, bkgs);
@ -616,7 +616,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
// calculateAndSaveReceivableYear(year, month, yearMonth, bkgs);
// 5. 营业收入年度汇总
calculateAndSaveRevenueYear(year, month, yearMonth, bkgs);
//calculateAndSaveRevenueYear(year, month, yearMonth, bkgs);
// 移动到下个月
monthCal.add(Calendar.MONTH, 1);
@ -894,7 +894,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
* 营业收入总量 = 石膏板 + 轻钢龙骨 + 涂料
* 同比 = (当年营收 - 去年营收) / 去年营收 * 100%
*/
private void calculateAndSaveRevenueYear(int year, int month, String yearMonth, String bkgs) {
private void calculateAndSaveRevenueYear(String startDate,int year, int month, String yearMonth, String bkgs) {
try {
LOGGER.info("开始计算{}年{}月营业收入累计数据", year, month);
// 构造月份的两位格式如1月转为"01"10月保持"10"
@ -905,6 +905,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
LOGGER.info("准备同步{}年{}月-营业收入累计数据,删除了{}条数据",year, month,delete);
//计算轻钢龙骨和石膏板
String querySql = "SELECT " +
" BKGS,"+
" LB_1, " +
" CASE " +
" WHEN SQ LIKE '%海南%' THEN '海南' " +
@ -916,10 +917,11 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
" FROM BO_EU_BNBM_DATALINKUP_XS_XSL_HZ " +
" WHERE " +
" (SQ LIKE '%海南%' OR SQ LIKE '%新疆%' OR SQ LIKE '%西藏%') " +
" AND DZRQ >= '" + year + "-" + monthStr + "-01' " +
" AND DZRQ >= ? " +
" AND BKGS = ? " +
" AND LB_1 IN('石膏板','轻钢龙骨','涂料') " +
" GROUP BY " +
" BKGS," +
" LB_1, " +
" PROVINCE, " +
" YEARMONTH " +
@ -927,7 +929,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
" YEARMONTH ASC, " +
" PROVINCE ASC, " +
" LB_1 ASC";
List<RowMap> rowMaps = DBSql.getMaps(querySql, bkgs);
List<RowMap> rowMaps = DBSql.getMaps(querySql, startDate,bkgs);
// 保存数据
List<BO> list = new ArrayList<>();
for (RowMap rowMap : rowMaps) {