From e685531b71fa5930ef45336ad0e28f0c83c82632 Mon Sep 17 00:00:00 2001 From: king Date: Wed, 22 Apr 2026 15:34:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1-=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E9=94=80=E5=94=AE=E6=8A=A5=E8=A1=A8-=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E8=B0=83=E6=95=B4,=20=E4=BE=9B=E5=BA=94=E5=95=86?= =?UTF-8?q?=E8=A1=A8=20=E5=90=8C=E6=AD=A5=E8=B0=83=E6=95=B4,=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20=E5=AE=A2=E6=88=B7=E9=94=80=E5=94=AE=E6=83=85?= =?UTF-8?q?=E5=86=B5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/framework/entity/GrBiSaCustomer.java | 4 +-- .../mapper/GrBiSaCustomerMapper.java | 4 +-- .../framework/mapper/NewGrBiSaAggMapper.java | 28 +++++++-------- .../impl/GrBiPubSupplyServiceImpl.java | 1 + .../impl/GrBiSaCustomerServiceImpl.java | 36 +++++++++++++++++-- .../service/impl/GrBiSaOrderServiceImpl.java | 1 + .../service/impl/NewGrBiSaAggServiceImpl.java | 8 ++--- .../mapper/framework/GrBiSaCustomerMapper.xml | 6 ++++ .../mapper/framework/NewGrBiSaAggMapper.xml | 13 ++++--- 9 files changed, 70 insertions(+), 31 deletions(-) diff --git a/lidee-core/src/main/java/com/lideeyunji/core/framework/entity/GrBiSaCustomer.java b/lidee-core/src/main/java/com/lideeyunji/core/framework/entity/GrBiSaCustomer.java index 0a3619f..3b6387e 100644 --- a/lidee-core/src/main/java/com/lideeyunji/core/framework/entity/GrBiSaCustomer.java +++ b/lidee-core/src/main/java/com/lideeyunji/core/framework/entity/GrBiSaCustomer.java @@ -23,11 +23,11 @@ public class GrBiSaCustomer implements Serializable @TableField(value = "USEYEAR") - private Long useyear; + private Integer useyear; @TableField(value = "USEMONTH") - private Long usemonth; + private Integer usemonth; @TableField(value = "CUSTOMID") diff --git a/lidee-core/src/main/java/com/lideeyunji/core/framework/mapper/GrBiSaCustomerMapper.java b/lidee-core/src/main/java/com/lideeyunji/core/framework/mapper/GrBiSaCustomerMapper.java index 088f27a..0205ac6 100644 --- a/lidee-core/src/main/java/com/lideeyunji/core/framework/mapper/GrBiSaCustomerMapper.java +++ b/lidee-core/src/main/java/com/lideeyunji/core/framework/mapper/GrBiSaCustomerMapper.java @@ -64,8 +64,8 @@ public interface GrBiSaCustomerMapper extends BaseMapper public int deleteGrBiSaCustomerByIds(Long[] ids); @DS(value = "#dataSourceType") - List getCustomerList(@Param("dataSourceType") String dataSourceType); + List getCustomerList(@Param("dataSourceType") String dataSourceType, @Param("pastYearMonth") Integer pastYearMonth,@Param("currentYearMonth") Integer currentYearMonth); @DS(value = "#dataSourceType") - int deleteOldCustomer(@Param("dataSourceType") String dataSourceType); + int deleteOldCustomer(@Param("dataSourceType") String dataSourceType, @Param("pastYearMonth") Integer pastYearMonth,@Param("currentYearMonth") Integer currentYearMonth); } diff --git a/lidee-core/src/main/java/com/lideeyunji/core/framework/mapper/NewGrBiSaAggMapper.java b/lidee-core/src/main/java/com/lideeyunji/core/framework/mapper/NewGrBiSaAggMapper.java index 9199666..f0c616b 100644 --- a/lidee-core/src/main/java/com/lideeyunji/core/framework/mapper/NewGrBiSaAggMapper.java +++ b/lidee-core/src/main/java/com/lideeyunji/core/framework/mapper/NewGrBiSaAggMapper.java @@ -22,35 +22,31 @@ import org.apache.ibatis.annotations.Param; public interface NewGrBiSaAggMapper extends BaseMapper { - List generateSalesReport(@Param("pastYearMonth") Integer pastYearMonth, - @Param("currentYearMonth") Integer currentYearMonth); + List generateSalesReport(@Param("pastYearMonth") Integer pastYearMonth,@Param("currentYearMonth") Integer currentYearMonth); - int deleteSalesReport(@Param("pastYearMonth") Integer pastYearMonth, - @Param("currentYearMonth") Integer currentYearMonth); + int deleteSalesReport(@Param("pastYearMonth") Integer pastYearMonth,@Param("currentYearMonth") Integer currentYearMonth); - int deleteSalesReportMonth(@Param("pastYearMonth") Integer pastYearMonth, - @Param("currentYearMonth") Integer currentYearMonth); + int deleteSalesReportMonth(@Param("pastYearMonth") Integer pastYearMonth,@Param("currentYearMonth") Integer currentYearMonth); - int deleteSalesReportYear(@Param("pastYear") Integer pastYear, - @Param("currentYear") Integer currentYear); + int deleteSalesReportYear(@Param("pastYear") Integer pastYear,@Param("currentYear") Integer currentYear); - int insertSelectMonth(@Param("pastYearMonth") Integer pastYearMonth, - @Param("currentYearMonth") Integer currentYearMonth); + int insertSelectMonth(@Param("pastYearMonth") Integer pastYearMonth,@Param("currentYearMonth") Integer currentYearMonth); - int insertSelectYear(@Param("pastYear") Integer pastYear, - @Param("currentYear") Integer currentYear); + int insertSelectYear(@Param("pastYear") Integer pastYear,@Param("currentYear") Integer currentYear); // void updateThisYearData(); // // void updateLastYearData(); //批量明细的 月度数据 - void updateLastMonthSamoney(); - void updateYoyMonthData(); + void updateLastMonthSamoney(@Param("pastYearMonth") Integer pastYearMonth,@Param("currentYearMonth") Integer currentYearMonth); - void updateComplexCalculateMonth1(); - void updateComplexCalculateMonth2(); + void updateYoyMonthData(@Param("pastYearMonth") Integer pastYearMonth,@Param("currentYearMonth") Integer currentYearMonth); + + void updateComplexCalculateMonth1(@Param("pastYearMonth") Integer pastYearMonth,@Param("currentYearMonth") Integer currentYearMonth); + + void updateComplexCalculateMonth2(@Param("pastYearMonth") Integer pastYearMonth,@Param("currentYearMonth") Integer currentYearMonth); // // void updateComplexCalculateYear(); // void updateComplexCalculate3(); diff --git a/lidee-core/src/main/java/com/lideeyunji/core/framework/service/impl/GrBiPubSupplyServiceImpl.java b/lidee-core/src/main/java/com/lideeyunji/core/framework/service/impl/GrBiPubSupplyServiceImpl.java index b2b09f9..4714e52 100644 --- a/lidee-core/src/main/java/com/lideeyunji/core/framework/service/impl/GrBiPubSupplyServiceImpl.java +++ b/lidee-core/src/main/java/com/lideeyunji/core/framework/service/impl/GrBiPubSupplyServiceImpl.java @@ -114,5 +114,6 @@ public class GrBiPubSupplyServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper().orderByDesc(GrBiSaCustomer::getUseyear, GrBiSaCustomer::getUsemonth).last("LIMIT 1"); + GrBiSaCustomer grBiSaAgg = this.baseMapper.selectOne(queryWrapper); + int lastUserYear = 2022; + int lastUserMonth = 1; + if(grBiSaAgg != null){ + lastUserYear = grBiSaAgg.getUseyear(); + lastUserMonth = grBiSaAgg.getUsemonth(); + } + // 获取当前时间的年和月 + LocalDateTime now = LocalDateTime.now(); + int currentYear = now.getYear(); + int currentMonth = now.getMonthValue(); + + // 获取二个月前的时间和年月 + LocalDateTime threeMonthsAgo = now.minusMonths(2); + int pastYear = threeMonthsAgo.getYear(); + int pastMonth = threeMonthsAgo.getMonthValue(); + + log.info("最后更新的年月:{}年{}月", lastUserYear, lastUserMonth); + log.info("当前:{}年{}月", currentYear, currentMonth); + log.info("二个月前:{}年{}月", pastYear, pastMonth); + if (lastUserYear < pastYear || (lastUserYear == pastYear && lastUserMonth < pastMonth)) { + pastYear = lastUserYear; + pastMonth = lastUserMonth; + + } + log.info("开始时间:{}年{}月, 结束时间:{}年{}月", pastYear, pastMonth, currentYear, currentMonth); // 获取数据 - List grBiSaCustomerList = this.baseMapper.getCustomerList(lideeYunJiBaseConstant.DS_ORACLE_GRYYBI); + List grBiSaCustomerList = this.baseMapper.getCustomerList(lideeYunJiBaseConstant.DS_ORACLE_GRYYBI,pastYear * 100 + pastMonth, currentYear * 100 + currentMonth); if (CollUtil.isEmpty(grBiSaCustomerList)) { return; } //保存数据 - int reNum = this.baseMapper.deleteOldCustomer(lideeYunJiBaseConstant.DS_ERP_BI_DATA); + int reNum = this.baseMapper.deleteOldCustomer(lideeYunJiBaseConstant.DS_ERP_BI_DATA, pastYear * 100 + pastMonth, currentYear * 100 + currentMonth); log.info("删除数量:{}", reNum); for (GrBiSaCustomer grBiPubStorage : grBiSaCustomerList) { int re = this.baseMapper.insert(grBiPubStorage); @@ -114,5 +145,6 @@ public class GrBiSaCustomerServiceImpl extends ServiceImpl @@ -180,5 +183,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from gr_bi_sa_customer + + (USEYEAR * 100 + USEMONTH) BETWEEN #{pastYearMonth} AND #{currentYearMonth} + \ No newline at end of file diff --git a/lidee-core/src/main/resources/mapper/framework/NewGrBiSaAggMapper.xml b/lidee-core/src/main/resources/mapper/framework/NewGrBiSaAggMapper.xml index 528c692..8237e94 100644 --- a/lidee-core/src/main/resources/mapper/framework/NewGrBiSaAggMapper.xml +++ b/lidee-core/src/main/resources/mapper/framework/NewGrBiSaAggMapper.xml @@ -429,7 +429,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SET a.yoy_month_sa_qty = COALESCE ( b.yoy_month_sa_qty, 0 ), a.yoy_month_sa_money = COALESCE ( b.yoy_month_sa_money, 0 ), a.yoy_month_cost = COALESCE ( b.yoy_month_cost, 0 ), - a.yoy_month_profit = COALESCE ( b.yoy_month_profit, 0 ); + a.yoy_month_profit = COALESCE ( b.yoy_month_profit, 0 ) + where (a.use_year * 100 + a.use_month) BETWEEN #{pastYearMonth} AND #{currentYearMonth}; @@ -483,7 +484,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" current_month.last_month_sa_qty = last_month_data.current_month_sa_qty, -- 上月销量 current_month.last_month_sa_money = last_month_data.current_month_sa_money, -- 上月销售金额 current_month.last_month_cost = last_month_data.current_month_cost, -- 上月销售成本 - current_month.last_month_profit = last_month_data.current_month_profit; -- 上月毛利额 + current_month.last_month_profit = last_month_data.current_month_profit -- 上月毛利额 + where (current_month.use_year * 100 + current_month.use_month) BETWEEN #{pastYearMonth} AND #{currentYearMonth}; UPDATE new_gr_bi_sa_agg_year_count a @@ -535,8 +537,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" UPDATE new_gr_bi_sa_agg SET this_month_profit_rate = CASE WHEN last_month_sa_money = 0 or last_month_sa_money is null THEN - IF(this_month_profit > 0, 100, 0) ELSE this_month_profit/ last_month_sa_money * 100 END; - + IF(this_month_profit > 0, 100, 0) ELSE this_month_profit/ last_month_sa_money * 100 END + where (use_year * 100 + use_month) BETWEEN #{pastYearMonth} AND #{currentYearMonth}; @@ -557,7 +559,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) b ON b.use_year = a.use_year AND b.use_month = a.use_month SET a.this_month_sa_money_share = COALESCE (ROUND( a.this_month_sa_money/b.this_month_sa_money_sum * 100, 2), 0 ), - a.this_month_profit_share = COALESCE (ROUND( a.this_month_profit/b.this_month_profit_sum * 100, 2), 0 ); + a.this_month_profit_share = COALESCE (ROUND( a.this_month_profit/b.this_month_profit_sum * 100, 2), 0 ) + where (a.use_year * 100 + a.use_month) BETWEEN #{pastYearMonth} AND #{currentYearMonth};