综合销售情况表 分组调整

This commit is contained in:
king
2026-03-19 13:38:31 +08:00
parent ed17f7910c
commit d789026c86
20 changed files with 1905 additions and 528 deletions

View File

@@ -1,6 +1,6 @@
package com.lideeyunji.core.framework.config.job; package com.lideeyunji.core.framework.config.job;
import com.lideeyunji.core.framework.service.IGrBiSaAggService; import com.lideeyunji.core.framework.service.INewGrBiSaAggService;
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant; import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
import com.lideeyunji.tool.framework.quartz.core.handler.JobHandler; import com.lideeyunji.tool.framework.quartz.core.handler.JobHandler;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -24,10 +24,10 @@ import javax.annotation.Resource;
public class GenerateSalesReportJob implements JobHandler { public class GenerateSalesReportJob implements JobHandler {
@Resource @Resource
private IGrBiSaAggService grBiSaAggService; private INewGrBiSaAggService newGrBiSaAggService;
public String execute(String param) { public String execute(String param) {
log.info("*********** 开始生成销售报表 ************"); log.info("*********** 开始生成销售报表 ************");
grBiSaAggService.generateSalesReportJob(lideeYunJiBaseConstant.DS_ERP_BI_DATA); newGrBiSaAggService.generateSalesReportJob(lideeYunJiBaseConstant.DS_ERP_BI_DATA);
log.info("*********** 生成销售报表完成 ************"); log.info("*********** 生成销售报表完成 ************");
return "*********** 生成销售报表完成 ************"; return "*********** 生成销售报表完成 ************";
} }

View File

@@ -85,7 +85,7 @@ public class zhxsqkLineReportEnhance implements ReportBeforeAdvicePlugin {
// executePluginSql.append(" CONCAT(ROUND((SELECT SUM(MONTHSAMONEY) FROM yunji_gr_bi_sa_agg)/100000000 ,2), '亿') AS monthsamoney_s, \n"); // executePluginSql.append(" CONCAT(ROUND((SELECT SUM(MONTHSAMONEY) FROM yunji_gr_bi_sa_agg)/100000000 ,2), '亿') AS monthsamoney_s, \n");
// executePluginSql.append(" CONCAT(ROUND((SELECT SUM(THISSAMONEY) FROM yunji_gr_bi_sa_agg)/100000000,2), '亿') AS thissamoney_s, \n"); // executePluginSql.append(" CONCAT(ROUND((SELECT SUM(THISSAMONEY) FROM yunji_gr_bi_sa_agg)/100000000,2), '亿') AS thissamoney_s, \n");
// executePluginSql.append(" CONCAT(ROUND((SELECT SUM(LASTSAMONEY) FROM yunji_gr_bi_sa_agg)/100000000,2), '亿') AS lastsamoney_s, \n"); // executePluginSql.append(" CONCAT(ROUND((SELECT SUM(LASTSAMONEY) FROM yunji_gr_bi_sa_agg)/100000000,2), '亿') AS lastsamoney_s, \n");
executePluginSql.append(" SUM(tbl_lgbsa.THISSAQTY) as THISSAQTY, \n"); //本年销量 executePluginSql.append(" SUM(tbl_lgbsa.MONTHSAQTY) as THISSAQTY, \n"); //本年销量
executePluginSql.append(" SUM(tbl_lgbsa.LASTSAQTY) as LASTSAQTY, \n"); //上年销量 executePluginSql.append(" SUM(tbl_lgbsa.LASTSAQTY) as LASTSAQTY, \n"); //上年销量
executePluginSql.append(" -- 数量同比(原有) \n"); executePluginSql.append(" -- 数量同比(原有) \n");
executePluginSql.append(" CASE \n"); executePluginSql.append(" CASE \n");
@@ -111,7 +111,11 @@ public class zhxsqkLineReportEnhance implements ReportBeforeAdvicePlugin {
executePluginSql.append(" ELSE (sum(tbl_lgbsa.MONTHSAMONEY) - sum(tbl_lgbsa.LASTYEAROFMONTHSAMONEY)) / sum(tbl_lgbsa.LASTYEAROFMONTHSAMONEY) * 100 END), 2)) \n"); executePluginSql.append(" ELSE (sum(tbl_lgbsa.MONTHSAMONEY) - sum(tbl_lgbsa.LASTYEAROFMONTHSAMONEY)) / sum(tbl_lgbsa.LASTYEAROFMONTHSAMONEY) * 100 END), 2)) \n");
executePluginSql.append(" ELSE '0.00' \n"); executePluginSql.append(" ELSE '0.00' \n");
executePluginSql.append(" END AS monthsamoney_yoy, \n"); executePluginSql.append(" END AS monthsamoney_yoy, \n");
executePluginSql.append(" ROUND(SUM(tbl_lgbsa.THISSAMONEY) / 10000, 2) as THISSAMONEY, \n"); //本年销售金额(元) executePluginSql.append(" ROUND(SUM(tbl_lgbsa.MONTHSAMONEY) / 10000, 2) as THISSAMONEY, \n"); //本年销售金额(元)
// SUM( MONTHSAQTY ) AS THISSAQTY, -- 本年销量
// SUM( MONTHSAMONEY ) AS THISSAMONEY, -- 本年销售金额
// SUM( MONTHCOST) as THISCOST, -- 本年销售成本
// SUM( MONTHPROFIT ) AS THISPROFIT -- 本年毛利额
executePluginSql.append(" CASE \n"); executePluginSql.append(" CASE \n");
executePluginSql.append(" WHEN (CASE WHEN sum(tbl_lgbsa.LAST_MONTH_SAMONEY) = 0 THEN IF(sum(tbl_lgbsa.MONTHSAMONEY) > 0, 100, 0) \n"); executePluginSql.append(" WHEN (CASE WHEN sum(tbl_lgbsa.LAST_MONTH_SAMONEY) = 0 THEN IF(sum(tbl_lgbsa.MONTHSAMONEY) > 0, 100, 0) \n");
executePluginSql.append(" ELSE (sum(tbl_lgbsa.MONTHSAMONEY) - sum(tbl_lgbsa.LAST_MONTH_SAMONEY)) / sum(tbl_lgbsa.LAST_MONTH_SAMONEY) * 100 END) > 0 THEN \n"); executePluginSql.append(" ELSE (sum(tbl_lgbsa.MONTHSAMONEY) - sum(tbl_lgbsa.LAST_MONTH_SAMONEY)) / sum(tbl_lgbsa.LAST_MONTH_SAMONEY) * 100 END) > 0 THEN \n");
@@ -148,8 +152,8 @@ public class zhxsqkLineReportEnhance implements ReportBeforeAdvicePlugin {
executePluginSql.append(" ELSE (sum(tbl_lgbsa.MONTHPROFIT) - sum(tbl_lgbsa.LASTYEAROFMONTHPROFIT)) / sum(tbl_lgbsa.LASTYEAROFMONTHPROFIT) * 100 END), 2)) \n"); executePluginSql.append(" ELSE (sum(tbl_lgbsa.MONTHPROFIT) - sum(tbl_lgbsa.LASTYEAROFMONTHPROFIT)) / sum(tbl_lgbsa.LASTYEAROFMONTHPROFIT) * 100 END), 2)) \n");
executePluginSql.append(" ELSE '0.00' \n"); executePluginSql.append(" ELSE '0.00' \n");
executePluginSql.append(" END AS monthprofit_yoy, \n"); //年度毛利同比 executePluginSql.append(" END AS monthprofit_yoy, \n"); //年度毛利同比
executePluginSql.append(" ROUND(MAX(tbl_lgbsa.THISPROFIT) / 10000, 2) as THISPROFIT, \n"); //本年毛利额(元) executePluginSql.append(" ROUND(SUM(tbl_lgbsa.MONTHPROFIT) / 10000, 2) as THISPROFIT, \n"); //本年毛利额(元)
executePluginSql.append(" ROUND(MAX(tbl_lgbsa.LASTPROFIT) / 10000, 2) as LASTPROFIT, \n"); //上年毛利额(元) executePluginSql.append(" ROUND(SUM(tbl_lgbsa.LASTPROFIT) / 10000, 2) as LASTPROFIT, \n"); //上年毛利额(元)
executePluginSql.append(" -- 新增:毛利同比 \n"); executePluginSql.append(" -- 新增:毛利同比 \n");
executePluginSql.append(" CASE \n"); executePluginSql.append(" CASE \n");
executePluginSql.append(" -- 正数红色圆点emoji + 数值 + % \n"); executePluginSql.append(" -- 正数红色圆点emoji + 数值 + % \n");
@@ -165,19 +169,19 @@ public class zhxsqkLineReportEnhance implements ReportBeforeAdvicePlugin {
executePluginSql.append(" -- 0值直接显示 \n"); executePluginSql.append(" -- 0值直接显示 \n");
executePluginSql.append(" ELSE '0.00' \n"); executePluginSql.append(" ELSE '0.00' \n");
executePluginSql.append(" END AS profit_yoy, \n"); //毛利同比 executePluginSql.append(" END AS profit_yoy, \n"); //毛利同比
executePluginSql.append(" ROUND(SUM(tbl_lgbsa.MONTHCOST) / 10000, 2) as MONTHCOST, \n"); //本月销售成本(元) executePluginSql.append(" ROUND(SUM(tbl_lgbsamc.this_month_cost) / 10000, 2) as this_month_cost, \n"); //本月销售成本(元)
executePluginSql.append(" ROUND(MAX(tbl_lgbsa.THISCOST) / 10000, 2) as THISCOST, \n"); //本年销售成本(元) executePluginSql.append(" ROUND(MAX(tbl_lgbsayc.this_year_cost) / 10000, 2) as this_year_cost, \n"); //本年销售成本(元)
executePluginSql.append(" CASE \n"); executePluginSql.append(" CASE \n");
executePluginSql.append(" WHEN (CASE WHEN sum(tbl_lgbsa.LASTYEAROFMONTHCOST) = 0 THEN IF(sum(tbl_lgbsa.MONTHCOST) > 0, 100, 0) \n"); executePluginSql.append(" WHEN (CASE WHEN sum(tbl_lgbsamc.yoy_last_month_cost) = 0 THEN IF(sum(tbl_lgbsamc.this_month_cost) > 0, 100, 0) \n");
executePluginSql.append(" ELSE (sum(tbl_lgbsa.MONTHCOST) - sum(tbl_lgbsa.LASTYEAROFMONTHCOST)) / sum(tbl_lgbsa.LASTYEAROFMONTHCOST) * 100 END) > 0 THEN \n"); executePluginSql.append(" ELSE (sum(tbl_lgbsamc.this_month_cost) - sum(tbl_lgbsamc.yoy_last_month_cost)) / sum(tbl_lgbsamc.yoy_last_month_cost) * 100 END) > 0 THEN \n");
executePluginSql.append(" CONCAT('🟢 ', ROUND((CASE WHEN sum(tbl_lgbsa.LASTYEAROFMONTHCOST) = 0 THEN IF(sum(tbl_lgbsa.MONTHCOST) > 0, 100, 0) \n"); executePluginSql.append(" CONCAT('🟢 ', ROUND((CASE WHEN sum(tbl_lgbsamc.yoy_last_month_cost) = 0 THEN IF(sum(tbl_lgbsamc.this_month_cost) > 0, 100, 0) \n");
executePluginSql.append(" ELSE (sum(tbl_lgbsa.MONTHCOST) - sum(tbl_lgbsa.LASTYEAROFMONTHCOST)) / sum(tbl_lgbsa.LASTYEAROFMONTHCOST) * 100 END), 2)) \n"); executePluginSql.append(" ELSE (sum(tbl_lgbsamc.this_month_cost) - sum(tbl_lgbsamc.yoy_last_month_cost)) / sum(tbl_lgbsamc.yoy_last_month_cost) * 100 END), 2)) \n");
executePluginSql.append(" WHEN (CASE WHEN sum(tbl_lgbsa.LASTYEAROFMONTHCOST) = 0 THEN IF(sum(tbl_lgbsa.MONTHCOST) > 0, 100, 0) \n"); executePluginSql.append(" WHEN (CASE WHEN sum(tbl_lgbsamc.yoy_last_month_cost) = 0 THEN IF(sum(tbl_lgbsamc.this_month_cost) > 0, 100, 0) \n");
executePluginSql.append(" ELSE (sum(tbl_lgbsa.MONTHCOST) - sum(tbl_lgbsa.LASTYEAROFMONTHCOST)) / sum(tbl_lgbsa.LASTYEAROFMONTHCOST) * 100 END) < 0 THEN \n"); executePluginSql.append(" ELSE (sum(tbl_lgbsamc.this_month_cost) - sum(tbl_lgbsamc.yoy_last_month_cost)) / sum(tbl_lgbsamc.yoy_last_month_cost) * 100 END) < 0 THEN \n");
executePluginSql.append(" CONCAT('🔴 ', ROUND((CASE WHEN sum(tbl_lgbsa.LASTYEAROFMONTHCOST) = 0 THEN IF(sum(tbl_lgbsa.MONTHCOST) > 0, 100, 0) \n"); executePluginSql.append(" CONCAT('🔴 ', ROUND((CASE WHEN sum(tbl_lgbsamc.yoy_last_month_cost) = 0 THEN IF(sum(tbl_lgbsamc.this_month_cost) > 0, 100, 0) \n");
executePluginSql.append(" ELSE (sum(tbl_lgbsa.MONTHCOST) - sum(tbl_lgbsa.LASTYEAROFMONTHCOST)) / sum(tbl_lgbsa.LASTYEAROFMONTHCOST) * 100 END), 2)) \n"); executePluginSql.append(" ELSE (sum(tbl_lgbsamc.this_month_cost) - sum(tbl_lgbsamc.yoy_last_month_cost)) / sum(tbl_lgbsamc.yoy_last_month_cost) * 100 END), 2)) \n");
executePluginSql.append(" ELSE '0.00' \n"); executePluginSql.append(" ELSE '0.00' \n");
executePluginSql.append(" END AS monthcost_yoy, \n"); //本月销售成本同比 executePluginSql.append(" END AS this_month_cost_yoy, \n"); //本月销售成本同比
executePluginSql.append(" ROUND(avg(tbl_lgbsa.PROFITCHANGE), 2) as PROFITCHANGE, \n"); //毛利变动(元) executePluginSql.append(" ROUND(avg(tbl_lgbsa.PROFITCHANGE), 2) as PROFITCHANGE, \n"); //毛利变动(元)
executePluginSql.append(" ROUND(avg(tbl_lgbsa.PROFITGROWTH), 2) as PROFITGROWTH, \n"); //毛利额增长率 executePluginSql.append(" ROUND(avg(tbl_lgbsa.PROFITGROWTH), 2) as PROFITGROWTH, \n"); //毛利额增长率
executePluginSql.append(" ROUND(avg(tbl_lgbsa.THISPROFITRATE), 2) as THISPROFITRATE, \n"); //本年毛利率 executePluginSql.append(" ROUND(avg(tbl_lgbsa.THISPROFITRATE), 2) as THISPROFITRATE, \n"); //本年毛利率

View File

@@ -16,127 +16,67 @@ import java.util.Date;
public class GrBiSaAgg implements Serializable { public class GrBiSaAgg implements Serializable {
private final static long serialVersionUID = 1L; private final static long serialVersionUID = 1L;
@TableId(value = "ID", type = IdType.INPUT) @TableId(value = "id", type = IdType.INPUT)
private Integer id; private Integer id;
@TableField(value = "USEYEAR") @TableField(value = "use_year")
private Integer useYear; private Integer useYear;
@TableField(value = "USEMONTH") @TableField(value = "use_month")
private Integer useMonth; private Integer useMonth;
@TableField(value = "ZONEID") @TableField(value = "zone_id")
private String zoneId; private String zoneId;
@TableField(value = "ZONENAME") @TableField(value = "zone_name")
private String zoneName; private String zoneName;
@TableField(value = "SALETYPEID") @TableField(value = "sale_type_id")
private String saleTypeId; private String saleTypeId;
@TableField(value = "SALETYPENAME") @TableField(value = "sale_type_name")
private String saleTypeName; private String saleTypeName;
@TableField(value = "CUSTOMID") @TableField(value = "custom_id")
private String customId; private String customId;
@TableField(value = "CUSTOMNAME") @TableField(value = "custom_name")
private String customName; private String customName;
@TableField(value = "DOSAGEID") @TableField(value = "dosage_id")
private String dosageId; private String dosageId;
@TableField(value = "DOSAGENAME") @TableField(value = "dosage_name")
private String dosageName; private String dosageName;
@TableField(value = "GOODSNAME") @TableField(value = "goods_id")
private String goodsName;
@TableField(value = "GOODSID")
private String goodsId; private String goodsId;
@TableField(value = "PROVINCEID") @TableField(value = "goods_name")
private String goodsName;
@TableField(value = "province_id")
private String provinceId; private String provinceId;
@TableField(value = "PROVINCENAME") @TableField(value = "province_name")
private String provinceName; private String provinceName;
@TableField(value = "SALERID") @TableField(value = "saler_id")
private String salerId; private String salerId;
@TableField(value = "SALERNAME") @TableField(value = "saler_name")
private String salerName; private String salerName;
@TableField(value = "MONTHSAQTY") @TableField(value = "this_month_sa_qty")
private String monthSaqty; private String thisMonthSaQty;
@TableField(value = "THISSAQTY") @TableField(value = "this_month_sa_money")
private String thisSaqty; private String thisMonthSaMoney;
@TableField(value = "LASTSAQTY") @TableField(value = "this_month_cost")
private String lastSaqty; private String thisMonthCost;
@TableField(value = "MONTHSAMONEY") @TableField(value = "this_month_profit")
private String monthSaMoney; private String thisMonthProfit;
@TableField(value = "THISSAMONEY")
private String thisSaMoney;
@TableField(value = "LASTSAMONEY")
private String lastSaMoney;
@TableField(value = "MONTHPROFIT")
private String monthProfit;
@TableField(value = "THISPROFIT")
private String thisProfit;
@TableField(value = "LASTPROFIT")
private String lastProfit;
@TableField(value = "MONTHCOST")
private String monthCost;
@TableField(value = "THISCOST")
private String thisCost;
@TableField(value = "LASTCOST")
private String lastCost;
@TableField(value = "MONTHPROFITRATE")
private String monthProfitRate;
@TableField(value = "THISPROFITRATE")
private String thisProfitRate;
@TableField(value = "LASTPROFITRATE")
private String lastProfitRate;
@TableField(value = "MONTHSAMONEYSHARE")
private String monthSaMoneyShare;
@TableField(value = "THISSAMONEYSHARE")
private String thisSaMoneyShare;
@TableField(value = "LASTSAMONEYSHARE")
private String lastSaMoneyShare;
@TableField(value = "MONTHPROFITSHARE")
private String monthProfitShare;
@TableField(value = "THISPROFITSHARE")
private String thisProfitShare;
@TableField(value = "LASTPROFITSHARE")
private String lastProfitShare;
@TableField(value = "SAMONEYGROWTH")
private String saMoneyGrowth;
@TableField(value = "PROFITGROWTH")
private String profitGrowth;
@TableField(value = "PROFITCHANGE")
private String profitChange;
} }

View File

@@ -13,22 +13,5 @@ import java.util.List;
public interface GrBiSaAggMapper extends BaseMapper<GrBiSaAgg> { public interface GrBiSaAggMapper extends BaseMapper<GrBiSaAgg> {
List<GrBiSaAgg> generateSalesReport(@Param("pastYearMonth") Integer pastYearMonth,
@Param("currentYearMonth") Integer currentYearMonth);
int deleteSalesReport(@Param("pastYearMonth") Integer pastYearMonth,
@Param("currentYearMonth") Integer currentYearMonth);
void updateThisData();
void updateLastData();
void updateLastMonthSamoney();
void updateLastYearOfMonthData();
void updateComplexCalculate1();
void updateComplexCalculate2();
void updateComplexCalculate3();
void updateComplexCalculate4();
void updateComplexCalculate5();
} }

View File

@@ -0,0 +1,98 @@
package com.lideeyunji.core.framework.mapper;
import java.util.List;
import com.lideeyunji.core.framework.entity.GrBiSaAgg;
import com.lideeyunji.core.framework.entity.NewGrBiSaAgg;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
* 综合销售情况明细Mapper接口
*
* @author king
* @date 2026-03-19
*/
public interface NewGrBiSaAggMapper extends BaseMapper<NewGrBiSaAgg>
{
List<NewGrBiSaAgg> generateSalesReport(@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 deleteSalesReportYear(@Param("pastYear") Integer pastYear,
@Param("currentYear") Integer currentYear);
int insertSelectMonth(@Param("pastYearMonth") Integer pastYearMonth,
@Param("currentYearMonth") Integer currentYearMonth);
int insertSelectYear(@Param("pastYear") Integer pastYear,
@Param("currentYear") Integer currentYear);
// void updateThisYearData();
//
// void updateLastYearData();
// void updateLastMonthSamoney();
//
// void updateYoyMonthData();
//
// void updateComplexCalculate1();
// void updateComplexCalculate2();
// void updateComplexCalculate3();
// void updateComplexCalculate4();
// void updateComplexCalculate5();
/**
* 查询综合销售情况明细
*
* @param id 综合销售情况明细主键
* @return 综合销售情况明细
*/
public NewGrBiSaAgg selectNewGrBiSaAggById(Long id);
/**
* 查询综合销售情况明细列表
*
* @param newGrBiSaAgg 综合销售情况明细
* @return 综合销售情况明细集合
*/
public List<NewGrBiSaAgg> selectNewGrBiSaAggList(NewGrBiSaAgg newGrBiSaAgg);
/**
* 新增综合销售情况明细
*
* @param newGrBiSaAgg 综合销售情况明细
* @return 结果
*/
public int insertNewGrBiSaAgg(NewGrBiSaAgg newGrBiSaAgg);
/**
* 修改综合销售情况明细
*
* @param newGrBiSaAgg 综合销售情况明细
* @return 结果
*/
public int updateNewGrBiSaAgg(NewGrBiSaAgg newGrBiSaAgg);
/**
* 删除综合销售情况明细
*
* @param id 综合销售情况明细主键
* @return 结果
*/
public int deleteNewGrBiSaAggById(Long id);
/**
* 批量删除综合销售情况明细
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteNewGrBiSaAggByIds(Long[] ids);
}

View File

@@ -0,0 +1,62 @@
package com.lideeyunji.core.framework.mapper;
import java.util.List;
import com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 综合销售情况月维度Mapper接口
*
* @author king
* @date 2026-03-19
*/
public interface NewGrBiSaAggMonthCountMapper extends BaseMapper<NewGrBiSaAggMonthCount>
{
/**
* 查询综合销售情况月维度
*
* @param id 综合销售情况月维度主键
* @return 综合销售情况月维度
*/
public NewGrBiSaAggMonthCount selectNewGrBiSaAggMonthCountById(Long id);
/**
* 查询综合销售情况月维度列表
*
* @param newGrBiSaAggMonthCount 综合销售情况月维度
* @return 综合销售情况月维度集合
*/
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggMonthCountList(NewGrBiSaAggMonthCount newGrBiSaAggMonthCount);
/**
* 新增综合销售情况月维度
*
* @param newGrBiSaAggMonthCount 综合销售情况月维度
* @return 结果
*/
public int insertNewGrBiSaAggMonthCount(NewGrBiSaAggMonthCount newGrBiSaAggMonthCount);
/**
* 修改综合销售情况月维度
*
* @param newGrBiSaAggMonthCount 综合销售情况月维度
* @return 结果
*/
public int updateNewGrBiSaAggMonthCount(NewGrBiSaAggMonthCount newGrBiSaAggMonthCount);
/**
* 删除综合销售情况月维度
*
* @param id 综合销售情况月维度主键
* @return 结果
*/
public int deleteNewGrBiSaAggMonthCountById(Long id);
/**
* 批量删除综合销售情况月维度
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteNewGrBiSaAggMonthCountByIds(Long[] ids);
}

View File

@@ -0,0 +1,62 @@
package com.lideeyunji.core.framework.mapper;
import java.util.List;
import com.lideeyunji.core.framework.entity.NewGrBiSaAggYearCount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 综合销售情况年维度Mapper接口
*
* @author king
* @date 2026-03-19
*/
public interface NewGrBiSaAggYearCountMapper extends BaseMapper<NewGrBiSaAggYearCount>
{
/**
* 查询综合销售情况年维度
*
* @param id 综合销售情况年维度主键
* @return 综合销售情况年维度
*/
public NewGrBiSaAggYearCount selectNewGrBiSaAggYearCountById(Long id);
/**
* 查询综合销售情况年维度列表
*
* @param newGrBiSaAggYearCount 综合销售情况年维度
* @return 综合销售情况年维度集合
*/
public List<NewGrBiSaAggYearCount> selectNewGrBiSaAggYearCountList(NewGrBiSaAggYearCount newGrBiSaAggYearCount);
/**
* 新增综合销售情况年维度
*
* @param newGrBiSaAggYearCount 综合销售情况年维度
* @return 结果
*/
public int insertNewGrBiSaAggYearCount(NewGrBiSaAggYearCount newGrBiSaAggYearCount);
/**
* 修改综合销售情况年维度
*
* @param newGrBiSaAggYearCount 综合销售情况年维度
* @return 结果
*/
public int updateNewGrBiSaAggYearCount(NewGrBiSaAggYearCount newGrBiSaAggYearCount);
/**
* 删除综合销售情况年维度
*
* @param id 综合销售情况年维度主键
* @return 结果
*/
public int deleteNewGrBiSaAggYearCountById(Long id);
/**
* 批量删除综合销售情况年维度
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteNewGrBiSaAggYearCountByIds(Long[] ids);
}

View File

@@ -6,7 +6,5 @@ import org.apache.ibatis.annotations.Param;
public interface IGrBiSaAggService extends IService<GrBiSaAgg> { public interface IGrBiSaAggService extends IService<GrBiSaAgg> {
//同步销售明细表
void generateSalesReportJob(@Param("dataSourceType") String dataSourceType);
} }

View File

@@ -0,0 +1,61 @@
package com.lideeyunji.core.framework.service;
import java.util.List;
import com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount;
/**
* 综合销售情况月维度Service接口
*
* @author king
* @date 2026-03-19
*/
public interface INewGrBiSaAggMonthCountService
{
/**
* 查询综合销售情况月维度
*
* @param id 综合销售情况月维度主键
* @return 综合销售情况月维度
*/
public NewGrBiSaAggMonthCount selectNewGrBiSaAggMonthCountById(Long id);
/**
* 查询综合销售情况月维度列表
*
* @param newGrBiSaAggMonthCount 综合销售情况月维度
* @return 综合销售情况月维度集合
*/
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggMonthCountList(NewGrBiSaAggMonthCount newGrBiSaAggMonthCount);
/**
* 新增综合销售情况月维度
*
* @param newGrBiSaAggMonthCount 综合销售情况月维度
* @return 结果
*/
public int insertNewGrBiSaAggMonthCount(NewGrBiSaAggMonthCount newGrBiSaAggMonthCount);
/**
* 修改综合销售情况月维度
*
* @param newGrBiSaAggMonthCount 综合销售情况月维度
* @return 结果
*/
public int updateNewGrBiSaAggMonthCount(NewGrBiSaAggMonthCount newGrBiSaAggMonthCount);
/**
* 批量删除综合销售情况月维度
*
* @param ids 需要删除的综合销售情况月维度主键集合
* @return 结果
*/
public int deleteNewGrBiSaAggMonthCountByIds(Long[] ids);
/**
* 删除综合销售情况月维度信息
*
* @param id 综合销售情况月维度主键
* @return 结果
*/
public int deleteNewGrBiSaAggMonthCountById(Long id);
}

View File

@@ -0,0 +1,64 @@
package com.lideeyunji.core.framework.service;
import java.util.List;
import com.lideeyunji.core.framework.entity.NewGrBiSaAgg;
import org.apache.ibatis.annotations.Param;
/**
* 综合销售情况明细Service接口
*
* @author king
* @date 2026-03-19
*/
public interface INewGrBiSaAggService
{
//同步销售明细表
void generateSalesReportJob(@Param("dataSourceType") String dataSourceType);
/**
* 查询综合销售情况明细
*
* @param id 综合销售情况明细主键
* @return 综合销售情况明细
*/
public NewGrBiSaAgg selectNewGrBiSaAggById(Long id);
/**
* 查询综合销售情况明细列表
*
* @param newGrBiSaAgg 综合销售情况明细
* @return 综合销售情况明细集合
*/
public List<NewGrBiSaAgg> selectNewGrBiSaAggList(NewGrBiSaAgg newGrBiSaAgg);
/**
* 新增综合销售情况明细
*
* @param newGrBiSaAgg 综合销售情况明细
* @return 结果
*/
public int insertNewGrBiSaAgg(NewGrBiSaAgg newGrBiSaAgg);
/**
* 修改综合销售情况明细
*
* @param newGrBiSaAgg 综合销售情况明细
* @return 结果
*/
public int updateNewGrBiSaAgg(NewGrBiSaAgg newGrBiSaAgg);
/**
* 批量删除综合销售情况明细
*
* @param ids 需要删除的综合销售情况明细主键集合
* @return 结果
*/
public int deleteNewGrBiSaAggByIds(Long[] ids);
/**
* 删除综合销售情况明细信息
*
* @param id 综合销售情况明细主键
* @return 结果
*/
public int deleteNewGrBiSaAggById(Long id);
}

View File

@@ -0,0 +1,61 @@
package com.lideeyunji.core.framework.service;
import java.util.List;
import com.lideeyunji.core.framework.entity.NewGrBiSaAggYearCount;
/**
* 综合销售情况年维度Service接口
*
* @author king
* @date 2026-03-19
*/
public interface INewGrBiSaAggYearCountService
{
/**
* 查询综合销售情况年维度
*
* @param id 综合销售情况年维度主键
* @return 综合销售情况年维度
*/
public NewGrBiSaAggYearCount selectNewGrBiSaAggYearCountById(Long id);
/**
* 查询综合销售情况年维度列表
*
* @param newGrBiSaAggYearCount 综合销售情况年维度
* @return 综合销售情况年维度集合
*/
public List<NewGrBiSaAggYearCount> selectNewGrBiSaAggYearCountList(NewGrBiSaAggYearCount newGrBiSaAggYearCount);
/**
* 新增综合销售情况年维度
*
* @param newGrBiSaAggYearCount 综合销售情况年维度
* @return 结果
*/
public int insertNewGrBiSaAggYearCount(NewGrBiSaAggYearCount newGrBiSaAggYearCount);
/**
* 修改综合销售情况年维度
*
* @param newGrBiSaAggYearCount 综合销售情况年维度
* @return 结果
*/
public int updateNewGrBiSaAggYearCount(NewGrBiSaAggYearCount newGrBiSaAggYearCount);
/**
* 批量删除综合销售情况年维度
*
* @param ids 需要删除的综合销售情况年维度主键集合
* @return 结果
*/
public int deleteNewGrBiSaAggYearCountByIds(Long[] ids);
/**
* 删除综合销售情况年维度信息
*
* @param id 综合销售情况年维度主键
* @return 结果
*/
public int deleteNewGrBiSaAggYearCountById(Long id);
}

View File

@@ -6,13 +6,17 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lideeyunji.core.framework.entity.GrBiSaAgg; import com.lideeyunji.core.framework.entity.GrBiSaAgg;
import com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount;
import com.lideeyunji.core.framework.mapper.GrBiSaAggMapper; import com.lideeyunji.core.framework.mapper.GrBiSaAggMapper;
import com.lideeyunji.core.framework.service.IGrBiSaAggService; import com.lideeyunji.core.framework.service.IGrBiSaAggService;
import com.lideeyunji.core.framework.service.INewGrBiSaAggMonthCountService;
import com.lideeyunji.core.framework.service.INewGrBiSaAggYearCountService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@@ -20,74 +24,6 @@ import java.util.List;
@Service @Service
public class GrBiSaAggServiceImpl extends ServiceImpl<GrBiSaAggMapper, GrBiSaAgg> implements IGrBiSaAggService { public class GrBiSaAggServiceImpl extends ServiceImpl<GrBiSaAggMapper, GrBiSaAgg> implements IGrBiSaAggService {
/**
* 计算销售报表
*/
@Override
@DSTransactional
@DS(value = "#dataSourceType")
public void generateSalesReportJob(@Param("dataSourceType") String dataSourceType) {
//获取本地mysql数据库中表中UPDATE_TIME最新的数据
LambdaQueryWrapper<GrBiSaAgg> queryWrapper = new LambdaQueryWrapper<GrBiSaAgg>().orderByDesc(GrBiSaAgg::getUseYear, GrBiSaAgg::getUseMonth).last("LIMIT 1");
GrBiSaAgg 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(3);
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<GrBiSaAgg> grBiSaSetdtlList = this.baseMapper.generateSalesReport(pastYear * 100 + pastMonth, currentYear * 100 + currentMonth);
if (CollUtil.isEmpty(grBiSaSetdtlList)) {
return;
}
//保存数据
removeAndSaveBatch(pastYear, pastMonth, currentYear, currentMonth, grBiSaSetdtlList);
this.baseMapper.updateThisData();
this.baseMapper.updateLastYearOfMonthData();
this.baseMapper.updateLastData();
this.baseMapper.updateLastMonthSamoney();
this.baseMapper.updateComplexCalculate1();
this.baseMapper.updateComplexCalculate2();
this.baseMapper.updateComplexCalculate3();
this.baseMapper.updateComplexCalculate4();
this.baseMapper.updateComplexCalculate5();
}
//批量新增
public void removeAndSaveBatch(Integer pastYear, Integer pastMonth, Integer currentYear, Integer currentMonth, List<GrBiSaAgg> grBiSaSetdtlList) {
int reNum = this.baseMapper.deleteSalesReport(pastYear * 100 + pastMonth, currentYear * 100 + currentMonth);
log.info("删除数量:{}", reNum);
int result = 0;
for (GrBiSaAgg grBiSaSetdtl : grBiSaSetdtlList) {
int re = this.baseMapper.insert(grBiSaSetdtl);
if (re < 1) {
throw new RuntimeException("批量新增异常");
}
result += re;
}
}
} }

View File

@@ -0,0 +1,90 @@
package com.lideeyunji.core.framework.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.lideeyunji.core.framework.mapper.NewGrBiSaAggMonthCountMapper;
import com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount;
import com.lideeyunji.core.framework.service.INewGrBiSaAggMonthCountService;
/**
* 综合销售情况月维度Service业务层处理
*
* @author king
* @date 2026-03-19
*/
@Service
public class NewGrBiSaAggMonthCountServiceImpl extends ServiceImpl<NewGrBiSaAggMonthCountMapper, NewGrBiSaAggMonthCount> implements INewGrBiSaAggMonthCountService
{
/**
* 查询综合销售情况月维度
*
* @param id 综合销售情况月维度主键
* @return 综合销售情况月维度
*/
@Override
public NewGrBiSaAggMonthCount selectNewGrBiSaAggMonthCountById(Long id)
{
return this.baseMapper.selectNewGrBiSaAggMonthCountById(id);
}
/**
* 查询综合销售情况月维度列表
*
* @param newGrBiSaAggMonthCount 综合销售情况月维度
* @return 综合销售情况月维度
*/
@Override
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggMonthCountList(NewGrBiSaAggMonthCount newGrBiSaAggMonthCount)
{
return this.baseMapper.selectNewGrBiSaAggMonthCountList(newGrBiSaAggMonthCount);
}
/**
* 新增综合销售情况月维度
*
* @param newGrBiSaAggMonthCount 综合销售情况月维度
* @return 结果
*/
@Override
public int insertNewGrBiSaAggMonthCount(NewGrBiSaAggMonthCount newGrBiSaAggMonthCount)
{
return this.baseMapper.insertNewGrBiSaAggMonthCount(newGrBiSaAggMonthCount);
}
/**
* 修改综合销售情况月维度
*
* @param newGrBiSaAggMonthCount 综合销售情况月维度
* @return 结果
*/
@Override
public int updateNewGrBiSaAggMonthCount(NewGrBiSaAggMonthCount newGrBiSaAggMonthCount)
{
return this.baseMapper.updateNewGrBiSaAggMonthCount(newGrBiSaAggMonthCount);
}
/**
* 批量删除综合销售情况月维度
*
* @param ids 需要删除的综合销售情况月维度主键
* @return 结果
*/
@Override
public int deleteNewGrBiSaAggMonthCountByIds(Long[] ids)
{
return this.baseMapper.deleteNewGrBiSaAggMonthCountByIds(ids);
}
/**
* 删除综合销售情况月维度信息
*
* @param id 综合销售情况月维度主键
* @return 结果
*/
@Override
public int deleteNewGrBiSaAggMonthCountById(Long id)
{
return this.baseMapper.deleteNewGrBiSaAggMonthCountById(id);
}
}

View File

@@ -0,0 +1,186 @@
package com.lideeyunji.core.framework.service.impl;
import java.time.LocalDateTime;
import java.util.List;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lideeyunji.core.framework.entity.GrBiSaAgg;
import com.lideeyunji.core.framework.service.INewGrBiSaAggMonthCountService;
import com.lideeyunji.core.framework.service.INewGrBiSaAggYearCountService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import com.lideeyunji.core.framework.mapper.NewGrBiSaAggMapper;
import com.lideeyunji.core.framework.entity.NewGrBiSaAgg;
import com.lideeyunji.core.framework.service.INewGrBiSaAggService;
import javax.annotation.Resource;
/**
* 综合销售情况明细Service业务层处理
*
* @author king
* @date 2026-03-19
*/
@Slf4j
@Service
public class NewGrBiSaAggServiceImpl extends ServiceImpl<NewGrBiSaAggMapper, NewGrBiSaAgg> implements INewGrBiSaAggService
{
@Resource
private INewGrBiSaAggMonthCountService newGrBiSaAggMonthCountService;
@Resource
private INewGrBiSaAggYearCountService newGrBiSaAggYearCountService;
/**
* 计算销售报表
*/
@Override
@DSTransactional
@DS(value = "#dataSourceType")
public void generateSalesReportJob(@Param("dataSourceType") String dataSourceType) {
//获取本地mysql数据库中表中UPDATE_TIME最新的数据
LambdaQueryWrapper<NewGrBiSaAgg> queryWrapper = new LambdaQueryWrapper<NewGrBiSaAgg>().orderByDesc(NewGrBiSaAgg::getUseYear, NewGrBiSaAgg::getUseMonth).last("LIMIT 1");
NewGrBiSaAgg 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(3);
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<NewGrBiSaAgg> grBiSaSetdtlList = this.baseMapper.generateSalesReport(pastYear * 100 + pastMonth, currentYear * 100 + currentMonth);
if (CollUtil.isEmpty(grBiSaSetdtlList)) {
return;
}
//保存数据
removeAndSaveBatch(pastYear, pastMonth, currentYear, currentMonth, grBiSaSetdtlList);
// this.baseMapper.updateThisYearData();
// this.baseMapper.updateYoyMonthData();
// this.baseMapper.updateLastYearData();
// this.baseMapper.updateLastMonthSamoney();
// this.baseMapper.updateComplexCalculate1();
// this.baseMapper.updateComplexCalculate2();
// this.baseMapper.updateComplexCalculate3();
// this.baseMapper.updateComplexCalculate4();
// this.baseMapper.updateComplexCalculate5();
}
//批量新增
public void removeAndSaveBatch(Integer pastYear, Integer pastMonth, Integer currentYear, Integer currentMonth, List<NewGrBiSaAgg> grBiSaSetdtlList) {
int reNum = this.baseMapper.deleteSalesReport(pastYear * 100 + pastMonth, currentYear * 100 + currentMonth);
log.info("删除数量:{}", reNum);
int result = 0;
for (NewGrBiSaAgg grBiSaSetdtl : grBiSaSetdtlList) {
int re = this.baseMapper.insert(grBiSaSetdtl);
if (re < 1) {
throw new RuntimeException("批量新增异常");
}
result += re;
}
reNum = this.baseMapper.deleteSalesReportMonth(pastYear * 100 + pastMonth, currentYear * 100 + currentMonth);
log.info("批量新增数量-month{}", reNum);
baseMapper.insertSelectMonth(pastYear * 100 + pastMonth, currentYear * 100 + currentMonth);
reNum = this.baseMapper.deleteSalesReportYear(pastYear, currentYear);
baseMapper.insertSelectYear(pastYear , currentYear * 100);
log.info("批量新增数量-year{}", reNum);
}
/**
* 查询综合销售情况明细
*
* @param id 综合销售情况明细主键
* @return 综合销售情况明细
*/
@Override
public NewGrBiSaAgg selectNewGrBiSaAggById(Long id)
{
return this.baseMapper.selectNewGrBiSaAggById(id);
}
/**
* 查询综合销售情况明细列表
*
* @param newGrBiSaAgg 综合销售情况明细
* @return 综合销售情况明细
*/
@Override
public List<NewGrBiSaAgg> selectNewGrBiSaAggList(NewGrBiSaAgg newGrBiSaAgg)
{
return this.baseMapper.selectNewGrBiSaAggList(newGrBiSaAgg);
}
/**
* 新增综合销售情况明细
*
* @param newGrBiSaAgg 综合销售情况明细
* @return 结果
*/
@Override
public int insertNewGrBiSaAgg(NewGrBiSaAgg newGrBiSaAgg)
{
return this.baseMapper.insertNewGrBiSaAgg(newGrBiSaAgg);
}
/**
* 修改综合销售情况明细
*
* @param newGrBiSaAgg 综合销售情况明细
* @return 结果
*/
@Override
public int updateNewGrBiSaAgg(NewGrBiSaAgg newGrBiSaAgg)
{
return this.baseMapper.updateNewGrBiSaAgg(newGrBiSaAgg);
}
/**
* 批量删除综合销售情况明细
*
* @param ids 需要删除的综合销售情况明细主键
* @return 结果
*/
@Override
public int deleteNewGrBiSaAggByIds(Long[] ids)
{
return this.baseMapper.deleteNewGrBiSaAggByIds(ids);
}
/**
* 删除综合销售情况明细信息
*
* @param id 综合销售情况明细主键
* @return 结果
*/
@Override
public int deleteNewGrBiSaAggById(Long id)
{
return this.baseMapper.deleteNewGrBiSaAggById(id);
}
}

View File

@@ -0,0 +1,90 @@
package com.lideeyunji.core.framework.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.lideeyunji.core.framework.mapper.NewGrBiSaAggYearCountMapper;
import com.lideeyunji.core.framework.entity.NewGrBiSaAggYearCount;
import com.lideeyunji.core.framework.service.INewGrBiSaAggYearCountService;
/**
* 综合销售情况年维度Service业务层处理
*
* @author king
* @date 2026-03-19
*/
@Service
public class NewGrBiSaAggYearCountServiceImpl extends ServiceImpl<NewGrBiSaAggYearCountMapper, NewGrBiSaAggYearCount> implements INewGrBiSaAggYearCountService
{
/**
* 查询综合销售情况年维度
*
* @param id 综合销售情况年维度主键
* @return 综合销售情况年维度
*/
@Override
public NewGrBiSaAggYearCount selectNewGrBiSaAggYearCountById(Long id)
{
return this.baseMapper.selectNewGrBiSaAggYearCountById(id);
}
/**
* 查询综合销售情况年维度列表
*
* @param newGrBiSaAggYearCount 综合销售情况年维度
* @return 综合销售情况年维度
*/
@Override
public List<NewGrBiSaAggYearCount> selectNewGrBiSaAggYearCountList(NewGrBiSaAggYearCount newGrBiSaAggYearCount)
{
return this.baseMapper.selectNewGrBiSaAggYearCountList(newGrBiSaAggYearCount);
}
/**
* 新增综合销售情况年维度
*
* @param newGrBiSaAggYearCount 综合销售情况年维度
* @return 结果
*/
@Override
public int insertNewGrBiSaAggYearCount(NewGrBiSaAggYearCount newGrBiSaAggYearCount)
{
return this.baseMapper.insertNewGrBiSaAggYearCount(newGrBiSaAggYearCount);
}
/**
* 修改综合销售情况年维度
*
* @param newGrBiSaAggYearCount 综合销售情况年维度
* @return 结果
*/
@Override
public int updateNewGrBiSaAggYearCount(NewGrBiSaAggYearCount newGrBiSaAggYearCount)
{
return this.baseMapper.updateNewGrBiSaAggYearCount(newGrBiSaAggYearCount);
}
/**
* 批量删除综合销售情况年维度
*
* @param ids 需要删除的综合销售情况年维度主键
* @return 结果
*/
@Override
public int deleteNewGrBiSaAggYearCountByIds(Long[] ids)
{
return this.baseMapper.deleteNewGrBiSaAggYearCountByIds(ids);
}
/**
* 删除综合销售情况年维度信息
*
* @param id 综合销售情况年维度主键
* @return 结果
*/
@Override
public int deleteNewGrBiSaAggYearCountById(Long id)
{
return this.baseMapper.deleteNewGrBiSaAggYearCountById(id);
}
}

View File

@@ -3,340 +3,4 @@
<mapper namespace="com.lideeyunji.core.framework.mapper.GrBiSaAggMapper"> <mapper namespace="com.lideeyunji.core.framework.mapper.GrBiSaAggMapper">
<select id="generateSalesReport" resultType="com.lideeyunji.core.framework.entity.GrBiSaAgg">
select a.USEYEAR,
a.USEMONTH,
goods.goodsid as GOODSID,
goods.GOODSNAME,
sales.SALEZONEID as ZONEID,
sales.SALEZONENAME as ZONENAME,
province.PROVINCEID,
province.PROVINCENAME,
salestype.SALETYPEID,
salestype.SALETYPENAME,
dosage.DOSAGEID,
dosage.DOSAGENAME,
custom.CUSTOMID,
custom.CUSTOMNAME,
saler.SALERID,
saler.SALERNAME,
a.`本月销量` as MONTHSAQTY,
a.`含税销售额` as MONTHSAMONEY,
a.`销售成本` as MONTHCOST,
a.`毛利额` as MONTHPROFIT
from erp_bi_data.GR_BI_PUB_GOODS as goods
inner join erp_bi_data.GR_BI_PUB_SALEZONE as sales
inner join erp_bi_data.GR_BI_PUB_PROVINCE as province
inner join erp_bi_data.GR_BI_PUB_SALETYPE as salestype
inner join erp_bi_data.GR_BI_PUB_DOSAGE as dosage
inner join erp_bi_data.GR_BI_PUB_CUSTOM as custom
INNER join erp_bi_data.GR_BI_PUB_SALER as saler
left join
(SELECT USEYEAR,
USEMONTH,
SALEZONEID,
SALEZONENAME,
PROVINCEID,
PROVINCENAME,
SALETYPE,
SALETYPENAME,
CUSTOMNAME,
SALERNAME,
DOSAGENAME,
goodsid,
GOODSNAME,
GOODSTYPE,
sum(SAQTY) as 本月销量,
DOSAGEID,
CUSTOMID,
SALERID,
round(SUM(SAMONEY), 2) 除税销售额,
round(sum(SAMONEYTX), 2) 含税销售额,
round(sum(COST), 2) 销售成本,
round(sum(PROFIT), 2) 毛利额
FROM GR_BI_SA_SETDTL
where USESTATUS = 2
GROUP BY SALETYPE, SALEZONEID, SALEZONENAME, PROVINCEID, PROVINCENAME, SALETYPE, SALETYPENAME, CUSTOMID,
CUSTOMNAME, SALERID, SALERNAME, DOSAGEID, DOSAGENAME, GOODSID, GOODSNAME, GOODSTYPE, USEYEAR,
USEMONTH) a
on a.goodsid = goods.goodsid and a.SALEZONEID = sales.SALEZONEID and a.PROVINCEID = province.PROVINCEID
and salestype.SALETYPEID = a.SALETYPE and dosage.DOSAGEID = a.DOSAGEID and
custom.CUSTOMID = a.CUSTOMID and saler.SALERID = a.SALERID
<where>
a.USEYEAR is not NULL
and (a.USEYEAR * 100 + a.USEMONTH) BETWEEN #{pastYearMonth} AND #{currentYearMonth}
</where>
order by a.USEYEAR, a.USEMONTH
</select>
<delete id="deleteSalesReport">
delete from yunji_gr_bi_sa_agg
where (USEYEAR * 100 + USEMONTH) BETWEEN #{pastYearMonth} AND #{currentYearMonth}
</delete>
<update id="updateThisData">
UPDATE yunji_gr_bi_sa_agg a
LEFT JOIN (
SELECT
USEYEAR,
GOODSID,
ZONEID,
PROVINCEID,
SALETYPEID,
DOSAGEID,
CUSTOMID,
SALERID,
SUM( MONTHSAQTY ) AS THISSAQTY, -- 本年销量
SUM( MONTHSAMONEY ) AS THISSAMONEY, -- 本年销售金额
SUM( MONTHCOST) as THISCOST, -- 本年销售成本
SUM( MONTHPROFIT ) AS THISPROFIT -- 本年毛利额
FROM
yunji_gr_bi_sa_agg
GROUP BY
USEYEAR,
GOODSID,
ZONEID,
PROVINCEID,
SALETYPEID,
DOSAGEID,
CUSTOMID,
SALERID
) b ON b.USEYEAR = a.USEYEAR
AND b.GOODSID = a.GOODSID
AND b.ZONEID = a.ZONEID
AND b.PROVINCEID = a.PROVINCEID
AND b.SALETYPEID = a.SALETYPEID
AND b.DOSAGEID = a.DOSAGEID
AND b.CUSTOMID = a.CUSTOMID
AND b.SALERID = a.SALERID
SET a.THISSAQTY = COALESCE ( b.THISSAQTY, 0 ),
a.THISSAMONEY = COALESCE ( b.THISSAMONEY, 0 ),
a.THISCOST = COALESCE ( b.THISCOST, 0 ),
a.THISPROFIT = COALESCE ( b.THISPROFIT, 0 );
</update>
<update id="updateLastYearOfMonthData">
UPDATE yunji_gr_bi_sa_agg a
LEFT JOIN (
SELECT
USEYEAR,
USEMONTH,
GOODSID,
ZONEID,
PROVINCEID,
SALETYPEID,
DOSAGEID,
CUSTOMID,
SALERID,
SUM( MONTHSAQTY ) AS LASTYEAROFMONTHSAQTY,
SUM( MONTHSAMONEY ) AS LASTYEAROFMONTHSAMONEY,
SUM( MONTHCOST) as LASTYEAROFMONTHCOST,
SUM( MONTHPROFIT ) AS LASTYEAROFMONTHPROFIT
FROM
yunji_gr_bi_sa_agg
GROUP BY
USEYEAR,
USEMONTH,
GOODSID,
ZONEID,
PROVINCEID,
SALETYPEID,
DOSAGEID,
CUSTOMID,
SALERID
) b ON b.USEYEAR = a.USEYEAR-1
AND b.USEMONTH = a.USEMONTH
AND b.GOODSID = a.GOODSID
AND b.ZONEID = a.ZONEID
AND b.PROVINCEID = a.PROVINCEID
AND b.SALETYPEID = a.SALETYPEID
AND b.DOSAGEID = a.DOSAGEID
AND b.CUSTOMID = a.CUSTOMID
AND b.SALERID = a.SALERID
SET a.LASTYEAROFMONTHSAQTY = COALESCE ( b.LASTYEAROFMONTHSAQTY, 0 ),
a.LASTYEAROFMONTHSAMONEY = COALESCE ( b.LASTYEAROFMONTHSAMONEY, 0 ),
a.LASTYEAROFMONTHCOST = COALESCE ( b.LASTYEAROFMONTHCOST, 0 ),
a.LASTYEAROFMONTHPROFIT = COALESCE ( b.LASTYEAROFMONTHPROFIT, 0 );
</update>
<update id="updateLastMonthSamoney">
UPDATE yunji_gr_bi_sa_agg AS current_month
JOIN (
SELECT
-- 当前记录的维度和年月
USEYEAR,
USEMONTH,
GOODSID,
ZONEID,
PROVINCEID,
SALETYPEID,
DOSAGEID,
CUSTOMID,
SALERID,
-- 计算上个月的年月
YEAR(DATE_SUB(CONCAT(USEYEAR, '-', USEMONTH, '-01'), INTERVAL 1 MONTH)) AS LAST_YEAR,
MONTH(DATE_SUB(CONCAT(USEYEAR, '-', USEMONTH, '-01'), INTERVAL 1 MONTH)) AS LAST_MONTH,
-- 当前月的销售金额,将作为上个月的金额赋给别的记录
SUM(MONTHSAMONEY) AS CURRENT_MONTH_SAMONEY
FROM yunji_gr_bi_sa_agg
GROUP BY
USEYEAR,
USEMONTH,
GOODSID,
ZONEID,
PROVINCEID,
SALETYPEID,
DOSAGEID,
CUSTOMID,
SALERID
) AS last_month_data
ON current_month.GOODSID = last_month_data.GOODSID
AND current_month.ZONEID = last_month_data.ZONEID
AND current_month.PROVINCEID = last_month_data.PROVINCEID
AND current_month.SALETYPEID = last_month_data.SALETYPEID
AND current_month.DOSAGEID = last_month_data.DOSAGEID
AND current_month.CUSTOMID = last_month_data.CUSTOMID
AND current_month.SALERID = last_month_data.SALERID
AND current_month.USEYEAR = last_month_data.LAST_YEAR
AND current_month.USEMONTH = last_month_data.LAST_MONTH
SET
current_month.LAST_MONTH_SAMONEY = last_month_data.CURRENT_MONTH_SAMONEY;
</update>
<update id="updateLastData">
UPDATE yunji_gr_bi_sa_agg a
LEFT JOIN (
SELECT
USEYEAR,
GOODSID,
ZONEID,
PROVINCEID,
SALETYPEID,
DOSAGEID,
CUSTOMID,
SALERID,
SUM( MONTHSAQTY ) AS LASTSAQTY,
SUM( MONTHSAMONEY ) AS LASTSAMONEY,
SUM( MONTHCOST) as LASTCOST,
SUM( MONTHPROFIT ) AS LASTPROFIT
FROM
yunji_gr_bi_sa_agg
GROUP BY
USEYEAR,
GOODSID,
ZONEID,
PROVINCEID,
SALETYPEID,
DOSAGEID,
CUSTOMID,
SALERID
) b ON b.USEYEAR = a.USEYEAR-1
AND b.GOODSID = a.GOODSID
AND b.ZONEID = a.ZONEID
AND b.PROVINCEID = a.PROVINCEID
AND b.SALETYPEID = a.SALETYPEID
AND b.DOSAGEID = a.DOSAGEID
AND b.CUSTOMID = a.CUSTOMID
AND b.SALERID = a.SALERID
SET a.LASTSAQTY = COALESCE ( b.LASTSAQTY, 0 ),
a.LASTSAMONEY = COALESCE ( b.LASTSAMONEY, 0 ),
a.LASTCOST = COALESCE ( b.LASTCOST, 0 ),
a.LASTPROFIT = COALESCE ( b.LASTPROFIT, 0 );
</update>
<update id="updateComplexCalculate1">
-- 本月毛利率 MONTHPROFITRATE 本月销售毛利/本月销售收入×100%
-- 本年毛利率 THISPROFITRATE 本年销售毛利/本年销售收入×100%
-- 上年毛利率 LASTPROFITRATE 上年销售毛利/上年销售收入×100%
UPDATE yunji_gr_bi_sa_agg
SET
MONTHPROFITRATE = CASE WHEN MONTHSAMONEY = 0 or MONTHSAMONEY is null THEN
IF(MONTHPROFIT > 0, 100, 0) ELSE MONTHPROFIT/ MONTHSAMONEY * 100 END,
THISPROFITRATE = CASE WHEN THISSAMONEY = 0 or THISSAMONEY is null THEN
IF(THISPROFIT > 0, 100, 0) ELSE THISPROFIT/ THISSAMONEY * 100 END,
LASTPROFITRATE =CASE WHEN LASTSAMONEY = 0 or LASTSAMONEY is null THEN
IF(LASTPROFIT > 0, 100, 0) ELSE LASTPROFIT/ LASTSAMONEY * 100 END;
</update>
<update id="updateComplexCalculate2">
-- 本月销售金额占比 MONTHSAMONEYSHARE 当前行本月销售额/本月销售额总和*100%
-- 本月毛利额占比 MONTHPROFITSHARE 当前行本月毛利额/本月毛利额总和*100%
UPDATE yunji_gr_bi_sa_agg a
LEFT JOIN (
SELECT
USEYEAR,
USEMONTH,
SUM( MONTHSAMONEY ) AS MONTHSAMONEY_SUM,
SUM(MONTHPROFIT) AS MONTHPROFIT_SUM
FROM
yunji_gr_bi_sa_agg
GROUP BY
USEYEAR,
USEMONTH
) b ON b.USEYEAR = a.USEYEAR
AND b.USEMONTH = a.USEMONTH
SET a.MONTHSAMONEYSHARE = COALESCE (ROUND( a.MONTHSAMONEY/b.MONTHSAMONEY_SUM * 100, 2), 0 ),
a.MONTHPROFITSHARE = COALESCE (ROUND( a.MONTHPROFIT/b.MONTHPROFIT_SUM * 100, 2), 0 );
</update>
<update id="updateComplexCalculate3">
-- 本年销售金额占比 THISSAMONEYSHARE当前行本年销售额/本年销售额总和*100%
-- 本年毛利额占比 THISPROFITSHARE 当前行本年毛利额/本年毛利额总和*100%
UPDATE yunji_gr_bi_sa_agg a
LEFT JOIN (
SELECT
USEYEAR,
SUM( THISSAMONEY ) AS THISSAMONEY_SUM,
SUM( THISPROFIT ) AS THISPROFIT_SUM
FROM
yunji_gr_bi_sa_agg
GROUP BY
USEYEAR
) b ON b.USEYEAR = a.USEYEAR
SET a.THISSAMONEYSHARE = COALESCE (ROUND( a.THISSAMONEY/b.THISSAMONEY_SUM * 100, 2), 0 ),
a.THISPROFITSHARE = COALESCE (ROUND( a.THISPROFIT/b.THISPROFIT_SUM * 100, 2), 0 );
</update>
<update id="updateComplexCalculate4">
-- 上年销售金额占比 LASTSAMONEYSHARE 当前行上年销售额/上年销售额总和*100%
-- 上年毛利额占比 LASTPROFITSHARE 当前行上年毛利额/上年毛利额总和*100%
UPDATE yunji_gr_bi_sa_agg a
LEFT JOIN (
SELECT
USEYEAR,
SUM(LASTSAMONEY) AS LASTSAMONEY_SUM,
SUM(LASTPROFIT) AS LASTPROFIT_SUM
FROM
yunji_gr_bi_sa_agg
GROUP BY
USEYEAR,
USEMONTH
) b ON b.USEYEAR = a.USEYEAR
SET a.LASTSAMONEYSHARE = COALESCE (ROUND( CASE WHEN LASTSAMONEY_SUM = 0 or LASTSAMONEY_SUM is null THEN IF(a.LASTSAMONEY > 0, 100, 0) ELSE a.LASTSAMONEY/b.LASTSAMONEY_SUM * 100 END, 2), 0 ),
a.LASTPROFITSHARE = COALESCE (ROUND( CASE WHEN LASTPROFIT_SUM = 0 or LASTPROFIT_SUM is null THEN IF(a.LASTPROFIT > 0, 100, 0) ELSE a.LASTPROFIT/b.LASTPROFIT_SUM * 100 END, 2), 0 );
</update>
<update id="updateComplexCalculate5">
-- 销售金额增长率 SAMONEYGROWTH (本年销售额-上年销售额)÷上年销售额×100%
-- 毛利额增长率 PROFITGROWTH (本年毛利额 - 上年毛利额) / 上年毛利额 × 100%
-- 毛利变动 PROFITCHANGE 本年毛利额 - 上年毛利额
UPDATE yunji_gr_bi_sa_agg
SET
SAMONEYGROWTH = CASE
WHEN ( LASTSAMONEY = 0 OR LASTSAMONEY IS NULL ) AND THISSAMONEY IS NOT NULL
THEN IF((THISSAMONEY - LASTSAMONEY) > 0, 100, 0)
ELSE ( THISSAMONEY - LASTSAMONEY )/ LASTSAMONEY * 100
END,
PROFITGROWTH = CASE
WHEN ( LASTPROFIT = 0 OR LASTPROFIT IS NULL ) AND THISPROFIT IS NOT NULL
THEN IF((THISSAMONEY - LASTSAMONEY) > 0, 100, 0)
ELSE ( THISPROFIT - LASTPROFIT )/ LASTPROFIT * 100
END,
PROFITCHANGE = ( THISPROFIT - LASTPROFIT);
</update>
</mapper> </mapper>

View File

@@ -0,0 +1,635 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lideeyunji.core.framework.mapper.NewGrBiSaAggMapper">
<resultMap type="com.lideeyunji.core.framework.entity.NewGrBiSaAgg" id="NewGrBiSaAggResult">
<result property="id" column="id" />
<result property="useYear" column="use_year" />
<result property="useMonth" column="use_month" />
<result property="zoneId" column="zone_id" />
<result property="zoneName" column="zone_name" />
<result property="saleTypeId" column="sale_type_id" />
<result property="saleTypeName" column="sale_type_name" />
<result property="customId" column="custom_id" />
<result property="customName" column="custom_name" />
<result property="dosageId" column="dosage_id" />
<result property="dosageName" column="dosage_name" />
<result property="goodsId" column="goods_id" />
<result property="goodsName" column="goods_name" />
<result property="provinceId" column="province_id" />
<result property="provinceName" column="province_name" />
<result property="salerId" column="saler_id" />
<result property="salerName" column="saler_name" />
<result property="thisMonthSaQty" column="this_month_sa_qty" />
<result property="thisMonthSaMoney" column="this_month_sa_money" />
<result property="thisMonthCost" column="this_month_cost" />
<result property="thisMonthProfit" column="this_month_profit" />
</resultMap>
<sql id="selectNewGrBiSaAggVo">
select id, use_year, use_month, zone_id, zone_name, sale_type_id, sale_type_name, custom_id, custom_name, dosage_id, dosage_name, goods_id, goods_name, province_id, province_name, saler_id, saler_name, this_month_sa_qty, this_month_sa_money, this_month_cost, this_month_profit from new_gr_bi_sa_agg
</sql>
<select id="generateSalesReport" resultType="com.lideeyunji.core.framework.entity.NewGrBiSaAgg">
select a.USEYEAR as use_year,
a.USEMONTH as use_month,
goods.goodsid as goods_id,
goods.GOODSNAME as goods_name,
sales.SALEZONEID as zone_id,
sales.SALEZONENAME as zone_name,
province.PROVINCEID as province_id,
province.PROVINCENAME as province_name,
salestype.SALETYPEID as sale_type_id,
salestype.SALETYPENAME as sale_type_name,
dosage.DOSAGEID as dosage_id,
dosage.DOSAGENAME as dosage_name,
custom.CUSTOMID as custom_id,
custom.CUSTOMNAME as custom_name,
saler.SALERID as saler_id,
saler.SALERNAME as saler_name,
a.`本月销量` as this_month_sa_qty,
a.`含税销售额` as this_month_sa_money,
a.`销售成本` as this_month_cost,
a.`毛利额` as this_month_profit
from erp_bi_data.GR_BI_PUB_GOODS as goods
inner join erp_bi_data.GR_BI_PUB_SALEZONE as sales
inner join erp_bi_data.GR_BI_PUB_PROVINCE as province
inner join erp_bi_data.GR_BI_PUB_SALETYPE as salestype
inner join erp_bi_data.GR_BI_PUB_DOSAGE as dosage
inner join erp_bi_data.GR_BI_PUB_CUSTOM as custom
INNER join erp_bi_data.GR_BI_PUB_SALER as saler
left join
(SELECT USEYEAR,
USEMONTH,
SALEZONEID,
SALEZONENAME,
PROVINCEID,
PROVINCENAME,
SALETYPE,
SALETYPENAME,
CUSTOMNAME,
SALERNAME,
DOSAGENAME,
goodsid,
GOODSNAME,
GOODSTYPE,
sum(SAQTY) as 本月销量,
DOSAGEID,
CUSTOMID,
SALERID,
round(SUM(SAMONEY), 2) 除税销售额,
round(sum(SAMONEYTX), 2) 含税销售额,
round(sum(COST), 2) 销售成本,
round(sum(PROFIT), 2) 毛利额
FROM GR_BI_SA_SETDTL
where USESTATUS = 2
GROUP BY SALETYPE, SALEZONEID, SALEZONENAME, PROVINCEID, PROVINCENAME, SALETYPE, SALETYPENAME, CUSTOMID,
CUSTOMNAME, SALERID, SALERNAME, DOSAGEID, DOSAGENAME, GOODSID, GOODSNAME, GOODSTYPE, USEYEAR,
USEMONTH) a
on a.goodsid = goods.goodsid and a.SALEZONEID = sales.SALEZONEID and a.PROVINCEID = province.PROVINCEID
and salestype.SALETYPEID = a.SALETYPE and dosage.DOSAGEID = a.DOSAGEID and
custom.CUSTOMID = a.CUSTOMID and saler.SALERID = a.SALERID
<where>
a.USEYEAR is not NULL
and (a.USEYEAR * 100 + a.USEMONTH) BETWEEN #{pastYearMonth} AND #{currentYearMonth}
</where>
order by a.USEYEAR, a.USEMONTH
</select>
<delete id="deleteSalesReport">
delete from new_gr_bi_sa_agg
where (use_year * 100 + use_month) BETWEEN #{pastYearMonth} AND #{currentYearMonth}
</delete>
<delete id="deleteSalesReportMonth">
delete from new_gr_bi_sa_agg_month_count
where (use_year * 100 + use_month) BETWEEN #{pastYearMonth} AND #{currentYearMonth}
</delete>
<delete id="deleteSalesReportYear">
delete from new_gr_bi_sa_agg_year_count
where (use_year ) BETWEEN #{pastYear} AND #{currentYear}
</delete>
<insert id="insertSelectMonth">
INSERT INTO new_gr_bi_sa_agg_month_count (
use_year,
use_month,
zone_id,
zone_name,
sale_type_id,
sale_type_name,
custom_id,
custom_name,
dosage_id,
dosage_name,
goods_id,
goods_name,
province_id,
province_name,
saler_id,
saler_name,
this_month_sa_qty,
this_month_sa_money,
this_month_profit,
this_month_cost
) SELECT
use_year,
use_month,
zone_id,
zone_name,
sale_type_id,
sale_type_name,
custom_id,
custom_name,
dosage_id,
dosage_name,
goods_id,
goods_name,
province_id,
province_name,
saler_id,
saler_name,
SUM(this_month_sa_qty) AS this_month_sa_qty, -- 本月销量
SUM(this_month_sa_money) AS this_month_sa_money, -- 本月销售金额
SUM(this_month_cost) AS this_month_cost, -- 本月销售成本
SUM(this_month_profit) AS this_month_profit -- 本月毛利额
FROM
new_gr_bi_sa_agg
where (use_year * 100 + use_month) BETWEEN #{pastYearMonth} AND #{currentYearMonth}
GROUP BY
use_year,
use_month,
zone_id,
zone_name,
sale_type_id,
sale_type_name,
custom_id,
custom_name,
dosage_id,
dosage_name,
goods_id,
goods_name,
province_id,
province_name,
saler_id,
saler_name
</insert>
<insert id="insertSelectYear">
INSERT INTO new_gr_bi_sa_agg_year_count (
use_year,
zone_id,
zone_name,
sale_type_id,
sale_type_name,
custom_id,
custom_name,
dosage_id,
dosage_name,
goods_id,
goods_name,
province_id,
province_name,
saler_id,
saler_name,
this_year_sa_qty,
this_year_sa_money,
this_year_profit,
this_year_cost
) SELECT
use_year,
zone_id,
zone_name,
sale_type_id,
sale_type_name,
custom_id,
custom_name,
dosage_id,
dosage_name,
goods_id,
goods_name,
province_id,
province_name,
saler_id,
saler_name,
SUM(this_month_sa_qty) AS this_year_sa_qty, -- 本年销量
SUM(this_month_sa_money) AS this_year_sa_money, -- 本年销售金额
SUM(this_month_cost) AS this_year_cost, -- 本年销售成本
SUM(this_month_profit) AS this_year_profit -- 本年毛利额
FROM
new_gr_bi_sa_agg_month_count
where use_year BETWEEN #{pastYear} AND #{currentYear}
GROUP BY
use_year,
zone_id,
zone_name,
sale_type_id,
sale_type_name,
custom_id,
custom_name,
dosage_id,
dosage_name,
goods_id,
goods_name,
province_id,
province_name,
saler_id,
saler_name
</insert>
<update id="updateThisYearData">
UPDATE new_gr_bi_sa_agg_year_count a
LEFT JOIN (
SELECT
use_year,
goods_id,
zone_id,
province_id,
sale_type_id,
dosage_id,
custom_id,
saler_id,
SUM( this_month_sa_qty ) AS this_year_sa_qty, -- 本年销量
SUM( this_month_sa_money ) AS this_year_sa_money, -- 本年销售金额
SUM( this_month_cost) as this_year_cost, -- 本年销售成本
SUM( this_month_profit ) AS this_year_profit -- 本年毛利额
FROM
new_gr_bi_sa_agg
GROUP BY
use_year,
goods_id,
zone_id,
province_id,
sale_type_id,
dosage_id,
custom_id,
saler_id
) b ON b.use_year = a.use_year
AND b.goods_id = a.goods_id
AND b.zone_id = a.zone_id
AND b.province_id = a.province_id
AND b.sale_type_id = a.sale_type_id
AND b.dosage_id = a.dosage_id
AND b.custom_id = a.custom_id
AND b.saler_id = a.saler_id
SET a.this_year_sa_qty = COALESCE ( b.this_year_sa_qty, 0 ),
a.this_year_sa_money = COALESCE ( b.this_year_sa_money, 0 ),
a.this_year_profit = COALESCE ( b.this_year_profit, 0 ),
a.this_year_cost = COALESCE ( b.this_year_cost, 0 );
</update>
<update id="updateYoyMonthData">
UPDATE new_gr_bi_sa_agg_month_count a
LEFT JOIN (
SELECT
use_year,
use_month,
goods_id,
zone_id,
province_id,
sale_type_id,
dosage_id,
custom_id,
saler_id,
SUM( this_month_sa_qty ) AS yoy_month_sa_qty, -- 同比月销量
SUM( this_month_sa_money ) AS yoy_month_sa_money, -- 同比月销售金额
SUM( this_month_cost) as yoy_month_cost, -- 同比月销售成本
SUM( this_month_profit ) AS yoy_month_profit -- 同比月毛利额
FROM
new_gr_bi_sa_agg
GROUP BY
use_year,
use_month,
goods_id,
zone_id,
province_id,
sale_type_id,
dosage_id,
custom_id,
saler_id
) b ON b.use_year = a.use_year-1
AND b.use_month = a.use_month
AND b.goods_id = a.goods_id
AND b.zone_id = a.zone_id
AND b.province_id = a.province_id
AND b.sale_type_id = a.sale_type_id
AND b.dosage_id = a.dosage_id
AND b.custom_id = a.custom_id
AND b.saler_id = a.saler_id
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 );
</update>
<update id="updateLastMonthSamoney">
UPDATE new_gr_bi_sa_agg_month_count AS current_month
JOIN (
SELECT
-- 当前记录的维度和年月
use_year,
use_month,
goods_id,
zone_id,
province_id,
sale_type_id,
dosage_id,
custom_id,
saler_id,
-- 计算上个月的年月
YEAR(DATE_SUB(CONCAT(use_year, '-', use_month, '-01'), INTERVAL 1 MONTH)) AS LAST_YEAR,
MONTH(DATE_SUB(CONCAT(use_year, '-', use_month, '-01'), INTERVAL 1 MONTH)) AS LAST_MONTH,
SUM(this_month_sa_qty) AS current_month_sa_qty,
-- 当前月的销售金额,将作为上个月的金额赋给别的记录
SUM(this_month_sa_money) AS current_month_sa_money,
SUM(this_month_cost) AS current_month_cost,
SUM(this_month_profit) AS current_month_profit
FROM new_gr_bi_sa_agg
GROUP BY
use_year,
use_month,
goods_id,
zone_id,
province_id,
sale_type_id,
dosage_id,
custom_id,
saler_id
) AS last_month_data
ON current_month.goods_id = last_month_data.goods_id
AND current_month.zone_id = last_month_data.zone_id
AND current_month.province_id = last_month_data.province_id
AND current_month.sale_type_id = last_month_data.sale_type_id
AND current_month.dosage_id = last_month_data.dosage_id
AND current_month.custom_id = last_month_data.custom_id
AND current_month.saler_id = last_month_data.saler_id
AND current_month.use_year = last_month_data.use_year
AND current_month.use_month = last_month_data.use_month
SET
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_sa_cost = last_month_data.current_month_cost, -- 上月销售成本
current_month.last_month_sa_profit = last_month_data.current_month_profit; -- 上月毛利额
</update>
<update id="updateLastYearData">
UPDATE new_gr_bi_sa_agg_year_count a
LEFT JOIN (
SELECT
use_year,
goods_id,
zone_id,
province_id,
sale_type_id,
dosage_id,
custom_id,
saler_id,
SUM( this_month_sa_qty ) AS last_month_sa_qty,
SUM( this_month_sa_money ) AS last_month_sa_money,
SUM( this_month_cost) as last_month_cost,
SUM( this_month_profit ) AS last_month_profit
FROM
new_gr_bi_sa_agg
GROUP BY
use_year,
goods_id,
zone_id,
province_id,
sale_type_id,
dosage_id,
custom_id,
saler_id
) b ON b.use_year = a.use_year-1
AND b.goods_id = a.goods_id
AND b.zone_id = a.zone_id
AND b.province_id = a.province_id
AND b.sale_type_id = a.sale_type_id
AND b.dosage_id = a.dosage_id
AND b.custom_id = a.custom_id
AND b.saler_id = a.saler_id
SET a.last_month_sa_qty = COALESCE ( b.last_month_sa_qty, 0 ),
a.last_month_sa_money = COALESCE ( b.last_month_sa_money, 0 ),
a.last_month_cost = COALESCE ( b.last_month_cost, 0 ),
a.last_month_profit = COALESCE ( b.last_month_profit, 0 );
</update>
<update id="updateComplexCalculate0">
-- 本月毛利率 MONTHPROFITRATE 本月销售毛利/本月销售收入×100%
UPDATE new_gr_bi_sa_agg_month_count
SET
this_month_profit_rate = CASE WHEN last_month_sa_money = 0 or last_month_sa_money is null THEN
IF(MONTHPROFIT > 0, 100, 0) ELSE MONTHPROFIT/ last_month_sa_money * 100 END;
</update>
<update id="updateComplexCalculate1">
-- 本年毛利率 THISPROFITRATE 本年销售毛利/本年销售收入×100%
-- 上年毛利率 LASTPROFITRATE 上年销售毛利/上年销售收入×100%
UPDATE new_gr_bi_sa_agg_year_count
SET
this_year_profit_rate = CASE WHEN this_year_sa_money = 0 or this_year_sa_money is null THEN
IF(this_year_profit > 0, 100, 0) ELSE this_year_profit/ this_year_sa_money * 100 END,
last_year_profit_rate =CASE WHEN last_year_sa_money = 0 or last_year_sa_money is null THEN
IF(last_year_profit > 0, 100, 0) ELSE last_year_profit/ last_year_sa_money * 100 END;
</update>
<update id="updateComplexCalculate2">
-- 本月销售金额占比 MONTHSAMONEYSHARE 当前行本月销售额/本月销售额总和*100%
-- 本月毛利额占比 MONTHPROFITSHARE 当前行本月毛利额/本月毛利额总和*100%
UPDATE new_gr_bi_sa_agg_month_count a
LEFT JOIN (
SELECT
use_year,
use_month,
SUM( this_month_sa_money ) AS this_month_sa_money_sum,
SUM(this_month_profit) AS this_month_profit_sum
FROM
new_gr_bi_sa_agg
GROUP BY
use_year,
use_month
) 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 );
</update>
<update id="updateComplexCalculate3">
-- 本年销售金额占比 this_year_sa_money_share当前行本年销售额/本年销售额总和*100%
-- 本年毛利额占比 THISPROFITSHARE 当前行本年毛利额/本年毛利额总和*100%
UPDATE new_gr_bi_sa_agg_year_count a
LEFT JOIN (
SELECT
use_year,
SUM( this_year_sa_money ) AS this_year_sa_money_sum,
SUM( this_year_profit ) AS this_year_profit_sum
FROM
new_gr_bi_sa_agg
GROUP BY
use_year
) b ON b.use_year = a.use_year
SET a.this_year_sa_money_share = COALESCE (ROUND( a.this_year_sa_money/b.this_year_sa_money_sum * 100, 2), 0 ),
a.this_year_profit_growth = COALESCE (ROUND( a.this_year_profit/b.this_year_profit_sum * 100, 2), 0 );
</update>
<update id="updateComplexCalculate4">
-- 上年销售金额占比 LASTSAMONEYSHARE 当前行上年销售额/上年销售额总和*100%
-- 上年毛利额占比 LASTPROFITSHARE 当前行上年毛利额/上年毛利额总和*100%
UPDATE new_gr_bi_sa_agg_year_count a
LEFT JOIN (
SELECT
use_year,
SUM(last_year_sa_money) AS last_year_sa_money_sum,
SUM(last_year_profit) AS last_year_profit_sum
FROM
new_gr_bi_sa_agg
GROUP BY
use_year,
use_month
) b ON b.use_year = a.use_year
SET a.last_year_sa_money_share = COALESCE (ROUND( CASE WHEN last_year_sa_money_sum = 0 or last_year_sa_money_sum is null THEN IF(a.last_year_sa_money > 0, 100, 0) ELSE a.last_year_sa_money/b.last_year_sa_money_sum * 100 END, 2), 0 ),
a.last_year_profit_share = COALESCE (ROUND( CASE WHEN last_year_profit_sum = 0 or last_year_profit_sum is null THEN IF(a.last_year_profit > 0, 100, 0) ELSE a.last_year_profit/b.last_year_profit_sum * 100 END, 2), 0 );
</update>
<update id="updateComplexCalculate5">
-- 销售金额增长率 SAMONEYGROWTH (本年销售额-上年销售额)÷上年销售额×100%
-- 毛利额增长率 PROFITGROWTH (本年毛利额 - 上年毛利额) / 上年毛利额 × 100%
-- 毛利变动 PROFITCHANGE 本年毛利额 - 上年毛利额
UPDATE new_gr_bi_sa_agg
SET
this_year_sa_money_growth = CASE
WHEN ( last_year_sa_money = 0 OR last_year_sa_money IS NULL ) AND this_year_sa_money IS NOT NULL
THEN IF((this_year_sa_money - last_year_sa_money) > 0, 100, 0)
ELSE ( this_year_sa_money - last_year_sa_money )/ last_year_sa_money * 100
END,
this_year_profit_growth = CASE
WHEN ( last_year_profit = 0 OR last_year_profit IS NULL ) AND this_year_profit IS NOT NULL
THEN IF((this_year_profit - last_year_profit) > 0, 100, 0)
ELSE ( this_year_profit - last_year_profit )/ last_year_profit * 100
END,
this_year_profit_change = ( this_year_profit - last_year_profit);
</update>
<select id="selectNewGrBiSaAggList" parameterType="com.lideeyunji.core.framework.entity.NewGrBiSaAgg" resultMap="NewGrBiSaAggResult">
<include refid="selectNewGrBiSaAggVo"/>
<where>
<if test="useYear != null and useYear != ''"> and use_year = #{useYear}</if>
<if test="useMonth != null "> and use_month = #{useMonth}</if>
<if test="zoneId != null "> and zone_id = #{zoneId}</if>
<if test="zoneName != null and zoneName != ''"> and zone_name like concat('%', #{zoneName}, '%')</if>
<if test="saleTypeId != null "> and sale_type_id = #{saleTypeId}</if>
<if test="saleTypeName != null and saleTypeName != ''"> and sale_type_name like concat('%', #{saleTypeName}, '%')</if>
<if test="customId != null "> and custom_id = #{customId}</if>
<if test="customName != null and customName != ''"> and custom_name like concat('%', #{customName}, '%')</if>
<if test="dosageId != null "> and dosage_id = #{dosageId}</if>
<if test="dosageName != null and dosageName != ''"> and dosage_name like concat('%', #{dosageName}, '%')</if>
<if test="goodsId != null "> and goods_id = #{goodsId}</if>
<if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
<if test="provinceId != null "> and province_id = #{provinceId}</if>
<if test="provinceName != null and provinceName != ''"> and province_name like concat('%', #{provinceName}, '%')</if>
<if test="salerId != null "> and saler_id = #{salerId}</if>
<if test="salerName != null and salerName != ''"> and saler_name like concat('%', #{salerName}, '%')</if>
<if test="thisMonthSaQty != null "> and this_month_sa_qty = #{thisMonthSaQty}</if>
<if test="thisMonthSaMoney != null "> and this_month_sa_money = #{thisMonthSaMoney}</if>
<if test="thisMonthCost != null "> and this_month_cost = #{thisMonthCost}</if>
<if test="thisMonthProfit != null "> and this_month_profit = #{thisMonthProfit}</if>
</where>
</select>
<select id="selectNewGrBiSaAggById" parameterType="Long" resultMap="NewGrBiSaAggResult">
<include refid="selectNewGrBiSaAggVo"/>
where id = #{id}
</select>
<insert id="insertNewGrBiSaAgg" parameterType="com.lideeyunji.core.framework.entity.NewGrBiSaAgg" useGeneratedKeys="true" keyProperty="id">
insert into new_gr_bi_sa_agg
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="useYear != null">use_year,</if>
<if test="useMonth != null">use_month,</if>
<if test="zoneId != null">zone_id,</if>
<if test="zoneName != null">zone_name,</if>
<if test="saleTypeId != null">sale_type_id,</if>
<if test="saleTypeName != null">sale_type_name,</if>
<if test="customId != null">custom_id,</if>
<if test="customName != null">custom_name,</if>
<if test="dosageId != null">dosage_id,</if>
<if test="dosageName != null">dosage_name,</if>
<if test="goodsId != null">goods_id,</if>
<if test="goodsName != null">goods_name,</if>
<if test="provinceId != null">province_id,</if>
<if test="provinceName != null">province_name,</if>
<if test="salerId != null">saler_id,</if>
<if test="salerName != null">saler_name,</if>
<if test="thisMonthSaQty != null">this_month_sa_qty,</if>
<if test="thisMonthSaMoney != null">this_month_sa_money,</if>
<if test="thisMonthCost != null">this_month_cost,</if>
<if test="thisMonthProfit != null">this_month_profit,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="useYear != null">#{useYear},</if>
<if test="useMonth != null">#{useMonth},</if>
<if test="zoneId != null">#{zoneId},</if>
<if test="zoneName != null">#{zoneName},</if>
<if test="saleTypeId != null">#{saleTypeId},</if>
<if test="saleTypeName != null">#{saleTypeName},</if>
<if test="customId != null">#{customId},</if>
<if test="customName != null">#{customName},</if>
<if test="dosageId != null">#{dosageId},</if>
<if test="dosageName != null">#{dosageName},</if>
<if test="goodsId != null">#{goodsId},</if>
<if test="goodsName != null">#{goodsName},</if>
<if test="provinceId != null">#{provinceId},</if>
<if test="provinceName != null">#{provinceName},</if>
<if test="salerId != null">#{salerId},</if>
<if test="salerName != null">#{salerName},</if>
<if test="thisMonthSaQty != null">#{thisMonthSaQty},</if>
<if test="thisMonthSaMoney != null">#{thisMonthSaMoney},</if>
<if test="thisMonthCost != null">#{thisMonthCost},</if>
<if test="thisMonthProfit != null">#{thisMonthProfit},</if>
</trim>
</insert>
<update id="updateNewGrBiSaAgg" parameterType="com.lideeyunji.core.framework.entity.NewGrBiSaAgg">
update new_gr_bi_sa_agg
<trim prefix="SET" suffixOverrides=",">
<if test="useYear != null">use_year = #{useYear},</if>
<if test="useMonth != null">use_month = #{useMonth},</if>
<if test="zoneId != null">zone_id = #{zoneId},</if>
<if test="zoneName != null">zone_name = #{zoneName},</if>
<if test="saleTypeId != null">sale_type_id = #{saleTypeId},</if>
<if test="saleTypeName != null">sale_type_name = #{saleTypeName},</if>
<if test="customId != null">custom_id = #{customId},</if>
<if test="customName != null">custom_name = #{customName},</if>
<if test="dosageId != null">dosage_id = #{dosageId},</if>
<if test="dosageName != null">dosage_name = #{dosageName},</if>
<if test="goodsId != null">goods_id = #{goodsId},</if>
<if test="goodsName != null">goods_name = #{goodsName},</if>
<if test="provinceId != null">province_id = #{provinceId},</if>
<if test="provinceName != null">province_name = #{provinceName},</if>
<if test="salerId != null">saler_id = #{salerId},</if>
<if test="salerName != null">saler_name = #{salerName},</if>
<if test="thisMonthSaQty != null">this_month_sa_qty = #{thisMonthSaQty},</if>
<if test="thisMonthSaMoney != null">this_month_sa_money = #{thisMonthSaMoney},</if>
<if test="thisMonthCost != null">this_month_cost = #{thisMonthCost},</if>
<if test="thisMonthProfit != null">this_month_profit = #{thisMonthProfit},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteNewGrBiSaAggById" parameterType="Long">
delete from new_gr_bi_sa_agg where id = #{id}
</delete>
<delete id="deleteNewGrBiSaAggByIds" parameterType="String">
delete from new_gr_bi_sa_agg where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,216 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lideeyunji.core.framework.mapper.NewGrBiSaAggMonthCountMapper">
<resultMap type="com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount" id="NewGrBiSaAggMonthCountResult">
<result property="id" column="id" />
<result property="useYear" column="use_year" />
<result property="useMonth" column="use_month" />
<result property="zoneId" column="zone_id" />
<result property="zoneName" column="zone_name" />
<result property="saleTypeId" column="sale_type_id" />
<result property="saleTypeName" column="sale_type_name" />
<result property="customId" column="custom_id" />
<result property="customName" column="custom_name" />
<result property="dosageId" column="dosage_id" />
<result property="dosageName" column="dosage_name" />
<result property="goodsId" column="goods_id" />
<result property="goodsName" column="goods_name" />
<result property="provinceId" column="province_id" />
<result property="provinceName" column="province_name" />
<result property="salerId" column="saler_id" />
<result property="salerName" column="saler_name" />
<result property="thisMonthSaQty" column="this_month_sa_qty" />
<result property="lastMonthSaQty" column="last_month_sa_qty" />
<result property="yoyMonthSaQty" column="yoy_month_sa_qty" />
<result property="thisMonthSaMoney" column="this_month_sa_money" />
<result property="lastMonthSaMoney" column="last_month_sa_money" />
<result property="yoyMonthSaMoney" column="yoy_month_sa_money" />
<result property="thisMonthProfit" column="this_month_profit" />
<result property="lastMonthProfit" column="last_month_profit" />
<result property="yoyMonthProfit" column="yoy_month_profit" />
<result property="thisMonthCost" column="this_month_cost" />
<result property="lastMonthCost" column="last_month_cost" />
<result property="yoyLastMonthCost" column="yoy_last_month_cost" />
<result property="thisMonthProfitRate" column="this_month_profit_rate" />
<result property="lastMonthProfitRate" column="last_month_profit_rate" />
<result property="lastMonthProfitShare" column="last_month_profit_share" />
<result property="thisMonthSaMoneyShare" column="this_month_sa_money_share" />
<result property="thisMonthProfitShare" column="this_month_profit_share" />
</resultMap>
<sql id="selectNewGrBiSaAggMonthCountVo">
select id, use_year, use_month, zone_id, zone_name, sale_type_id, sale_type_name, custom_id, custom_name, dosage_id, dosage_name, goods_id, goods_name, province_id, province_name, saler_id, saler_name, this_month_sa_qty, last_month_sa_qty, yoy_month_sa_qty, this_month_sa_money, last_month_sa_money, yoy_month_sa_money, this_month_profit, last_month_profit, yoy_month_profit, this_month_cost, last_month_cost, yoy_last_month_cost, this_month_profit_rate, last_month_profit_rate, last_month_profit_share, this_month_sa_money_share, this_month_profit_share from new_gr_bi_sa_agg_month_count
</sql>
<select id="selectNewGrBiSaAggMonthCountList" parameterType="com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount" resultMap="NewGrBiSaAggMonthCountResult">
<include refid="selectNewGrBiSaAggMonthCountVo"/>
<where>
<if test="useYear != null and useYear != ''"> and use_year = #{useYear}</if>
<if test="useMonth != null "> and use_month = #{useMonth}</if>
<if test="zoneId != null "> and zone_id = #{zoneId}</if>
<if test="zoneName != null and zoneName != ''"> and zone_name like concat('%', #{zoneName}, '%')</if>
<if test="saleTypeId != null "> and sale_type_id = #{saleTypeId}</if>
<if test="saleTypeName != null and saleTypeName != ''"> and sale_type_name like concat('%', #{saleTypeName}, '%')</if>
<if test="customId != null "> and custom_id = #{customId}</if>
<if test="customName != null and customName != ''"> and custom_name like concat('%', #{customName}, '%')</if>
<if test="dosageId != null "> and dosage_id = #{dosageId}</if>
<if test="dosageName != null and dosageName != ''"> and dosage_name like concat('%', #{dosageName}, '%')</if>
<if test="goodsId != null "> and goods_id = #{goodsId}</if>
<if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
<if test="provinceId != null "> and province_id = #{provinceId}</if>
<if test="provinceName != null and provinceName != ''"> and province_name like concat('%', #{provinceName}, '%')</if>
<if test="salerId != null "> and saler_id = #{salerId}</if>
<if test="salerName != null and salerName != ''"> and saler_name like concat('%', #{salerName}, '%')</if>
<if test="thisMonthSaQty != null "> and this_month_sa_qty = #{thisMonthSaQty}</if>
<if test="lastMonthSaQty != null "> and last_month_sa_qty = #{lastMonthSaQty}</if>
<if test="yoyMonthSaQty != null "> and yoy_month_sa_qty = #{yoyMonthSaQty}</if>
<if test="thisMonthSaMoney != null "> and this_month_sa_money = #{thisMonthSaMoney}</if>
<if test="lastMonthSaMoney != null "> and last_month_sa_money = #{lastMonthSaMoney}</if>
<if test="yoyMonthSaMoney != null "> and yoy_month_sa_money = #{yoyMonthSaMoney}</if>
<if test="thisMonthProfit != null "> and this_month_profit = #{thisMonthProfit}</if>
<if test="lastMonthProfit != null "> and last_month_profit = #{lastMonthProfit}</if>
<if test="yoyMonthProfit != null "> and yoy_month_profit = #{yoyMonthProfit}</if>
<if test="thisMonthCost != null "> and this_month_cost = #{thisMonthCost}</if>
<if test="lastMonthCost != null "> and last_month_cost = #{lastMonthCost}</if>
<if test="yoyLastMonthCost != null "> and yoy_last_month_cost = #{yoyLastMonthCost}</if>
<if test="thisMonthProfitRate != null "> and this_month_profit_rate = #{thisMonthProfitRate}</if>
<if test="lastMonthProfitRate != null "> and last_month_profit_rate = #{lastMonthProfitRate}</if>
<if test="lastMonthProfitShare != null "> and last_month_profit_share = #{lastMonthProfitShare}</if>
<if test="thisMonthSaMoneyShare != null "> and this_month_sa_money_share = #{thisMonthSaMoneyShare}</if>
<if test="thisMonthProfitShare != null "> and this_month_profit_share = #{thisMonthProfitShare}</if>
</where>
</select>
<select id="selectNewGrBiSaAggMonthCountById" parameterType="Long" resultMap="NewGrBiSaAggMonthCountResult">
<include refid="selectNewGrBiSaAggMonthCountVo"/>
where id = #{id}
</select>
<insert id="insertNewGrBiSaAggMonthCount" parameterType="com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount" useGeneratedKeys="true" keyProperty="id">
insert into new_gr_bi_sa_agg_month_count
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="useYear != null">use_year,</if>
<if test="useMonth != null">use_month,</if>
<if test="zoneId != null">zone_id,</if>
<if test="zoneName != null">zone_name,</if>
<if test="saleTypeId != null">sale_type_id,</if>
<if test="saleTypeName != null">sale_type_name,</if>
<if test="customId != null">custom_id,</if>
<if test="customName != null">custom_name,</if>
<if test="dosageId != null">dosage_id,</if>
<if test="dosageName != null">dosage_name,</if>
<if test="goodsId != null">goods_id,</if>
<if test="goodsName != null">goods_name,</if>
<if test="provinceId != null">province_id,</if>
<if test="provinceName != null">province_name,</if>
<if test="salerId != null">saler_id,</if>
<if test="salerName != null">saler_name,</if>
<if test="thisMonthSaQty != null">this_month_sa_qty,</if>
<if test="lastMonthSaQty != null">last_month_sa_qty,</if>
<if test="yoyMonthSaQty != null">yoy_month_sa_qty,</if>
<if test="thisMonthSaMoney != null">this_month_sa_money,</if>
<if test="lastMonthSaMoney != null">last_month_sa_money,</if>
<if test="yoyMonthSaMoney != null">yoy_month_sa_money,</if>
<if test="thisMonthProfit != null">this_month_profit,</if>
<if test="lastMonthProfit != null">last_month_profit,</if>
<if test="yoyMonthProfit != null">yoy_month_profit,</if>
<if test="thisMonthCost != null">this_month_cost,</if>
<if test="lastMonthCost != null">last_month_cost,</if>
<if test="yoyLastMonthCost != null">yoy_last_month_cost,</if>
<if test="thisMonthProfitRate != null">this_month_profit_rate,</if>
<if test="lastMonthProfitRate != null">last_month_profit_rate,</if>
<if test="lastMonthProfitShare != null">last_month_profit_share,</if>
<if test="thisMonthSaMoneyShare != null">this_month_sa_money_share,</if>
<if test="thisMonthProfitShare != null">this_month_profit_share,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="useYear != null">#{useYear},</if>
<if test="useMonth != null">#{useMonth},</if>
<if test="zoneId != null">#{zoneId},</if>
<if test="zoneName != null">#{zoneName},</if>
<if test="saleTypeId != null">#{saleTypeId},</if>
<if test="saleTypeName != null">#{saleTypeName},</if>
<if test="customId != null">#{customId},</if>
<if test="customName != null">#{customName},</if>
<if test="dosageId != null">#{dosageId},</if>
<if test="dosageName != null">#{dosageName},</if>
<if test="goodsId != null">#{goodsId},</if>
<if test="goodsName != null">#{goodsName},</if>
<if test="provinceId != null">#{provinceId},</if>
<if test="provinceName != null">#{provinceName},</if>
<if test="salerId != null">#{salerId},</if>
<if test="salerName != null">#{salerName},</if>
<if test="thisMonthSaQty != null">#{thisMonthSaQty},</if>
<if test="lastMonthSaQty != null">#{lastMonthSaQty},</if>
<if test="yoyMonthSaQty != null">#{yoyMonthSaQty},</if>
<if test="thisMonthSaMoney != null">#{thisMonthSaMoney},</if>
<if test="lastMonthSaMoney != null">#{lastMonthSaMoney},</if>
<if test="yoyMonthSaMoney != null">#{yoyMonthSaMoney},</if>
<if test="thisMonthProfit != null">#{thisMonthProfit},</if>
<if test="lastMonthProfit != null">#{lastMonthProfit},</if>
<if test="yoyMonthProfit != null">#{yoyMonthProfit},</if>
<if test="thisMonthCost != null">#{thisMonthCost},</if>
<if test="lastMonthCost != null">#{lastMonthCost},</if>
<if test="yoyLastMonthCost != null">#{yoyLastMonthCost},</if>
<if test="thisMonthProfitRate != null">#{thisMonthProfitRate},</if>
<if test="lastMonthProfitRate != null">#{lastMonthProfitRate},</if>
<if test="lastMonthProfitShare != null">#{lastMonthProfitShare},</if>
<if test="thisMonthSaMoneyShare != null">#{thisMonthSaMoneyShare},</if>
<if test="thisMonthProfitShare != null">#{thisMonthProfitShare},</if>
</trim>
</insert>
<update id="updateNewGrBiSaAggMonthCount" parameterType="com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount">
update new_gr_bi_sa_agg_month_count
<trim prefix="SET" suffixOverrides=",">
<if test="useYear != null">use_year = #{useYear},</if>
<if test="useMonth != null">use_month = #{useMonth},</if>
<if test="zoneId != null">zone_id = #{zoneId},</if>
<if test="zoneName != null">zone_name = #{zoneName},</if>
<if test="saleTypeId != null">sale_type_id = #{saleTypeId},</if>
<if test="saleTypeName != null">sale_type_name = #{saleTypeName},</if>
<if test="customId != null">custom_id = #{customId},</if>
<if test="customName != null">custom_name = #{customName},</if>
<if test="dosageId != null">dosage_id = #{dosageId},</if>
<if test="dosageName != null">dosage_name = #{dosageName},</if>
<if test="goodsId != null">goods_id = #{goodsId},</if>
<if test="goodsName != null">goods_name = #{goodsName},</if>
<if test="provinceId != null">province_id = #{provinceId},</if>
<if test="provinceName != null">province_name = #{provinceName},</if>
<if test="salerId != null">saler_id = #{salerId},</if>
<if test="salerName != null">saler_name = #{salerName},</if>
<if test="thisMonthSaQty != null">this_month_sa_qty = #{thisMonthSaQty},</if>
<if test="lastMonthSaQty != null">last_month_sa_qty = #{lastMonthSaQty},</if>
<if test="yoyMonthSaQty != null">yoy_month_sa_qty = #{yoyMonthSaQty},</if>
<if test="thisMonthSaMoney != null">this_month_sa_money = #{thisMonthSaMoney},</if>
<if test="lastMonthSaMoney != null">last_month_sa_money = #{lastMonthSaMoney},</if>
<if test="yoyMonthSaMoney != null">yoy_month_sa_money = #{yoyMonthSaMoney},</if>
<if test="thisMonthProfit != null">this_month_profit = #{thisMonthProfit},</if>
<if test="lastMonthProfit != null">last_month_profit = #{lastMonthProfit},</if>
<if test="yoyMonthProfit != null">yoy_month_profit = #{yoyMonthProfit},</if>
<if test="thisMonthCost != null">this_month_cost = #{thisMonthCost},</if>
<if test="lastMonthCost != null">last_month_cost = #{lastMonthCost},</if>
<if test="yoyLastMonthCost != null">yoy_last_month_cost = #{yoyLastMonthCost},</if>
<if test="thisMonthProfitRate != null">this_month_profit_rate = #{thisMonthProfitRate},</if>
<if test="lastMonthProfitRate != null">last_month_profit_rate = #{lastMonthProfitRate},</if>
<if test="lastMonthProfitShare != null">last_month_profit_share = #{lastMonthProfitShare},</if>
<if test="thisMonthSaMoneyShare != null">this_month_sa_money_share = #{thisMonthSaMoneyShare},</if>
<if test="thisMonthProfitShare != null">this_month_profit_share = #{thisMonthProfitShare},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteNewGrBiSaAggMonthCountById" parameterType="Long">
delete from new_gr_bi_sa_agg_month_count where id = #{id}
</delete>
<delete id="deleteNewGrBiSaAggMonthCountByIds" parameterType="String">
delete from new_gr_bi_sa_agg_month_count where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lideeyunji.core.framework.mapper.NewGrBiSaAggYearCountMapper">
<resultMap type="com.lideeyunji.core.framework.entity.NewGrBiSaAggYearCount" id="NewGrBiSaAggYearCountResult">
<result property="id" column="id" />
<result property="useYear" column="use_year" />
<result property="zoneId" column="zone_id" />
<result property="zoneName" column="zone_name" />
<result property="saleTypeId" column="sale_type_id" />
<result property="saleTypeName" column="sale_type_name" />
<result property="customId" column="custom_id" />
<result property="customName" column="custom_name" />
<result property="dosageId" column="dosage_id" />
<result property="dosageName" column="dosage_name" />
<result property="goodsId" column="goods_id" />
<result property="goodsName" column="goods_name" />
<result property="provinceId" column="province_id" />
<result property="provinceName" column="province_name" />
<result property="salerId" column="saler_id" />
<result property="salerName" column="saler_name" />
<result property="thisYearSaQty" column="this_year_sa_qty" />
<result property="lastYearSaQty" column="last_year_sa_qty" />
<result property="thisYearSaMoney" column="this_year_sa_money" />
<result property="lastYearSaMoney" column="last_year_sa_money" />
<result property="thisYearProfit" column="this_year_profit" />
<result property="lastYearProfit" column="last_year_profit" />
<result property="thisYearCost" column="this_year_cost" />
<result property="lastYearCost" column="last_year_cost" />
<result property="thisYearProfitRate" column="this_year_profit_rate" />
<result property="lastYearProfitRate" column="last_year_profit_rate" />
<result property="thisYearProfitShare" column="this_year_profit_share" />
<result property="lastYearProfitShare" column="last_year_profit_share" />
<result property="thisYearSaMoneyShare" column="this_year_sa_money_share" />
<result property="lastYearSaMoneyShare" column="last_year_sa_money_share" />
<result property="thisYearSaMoneyGrowth" column="this_year_sa_money_growth" />
<result property="thisYearProfitGrowth" column="this_year_profit_growth" />
<result property="thisYearProfitChange" column="this_year_profit_change" />
</resultMap>
<sql id="selectNewGrBiSaAggYearCountVo">
select id, use_year, zone_id, zone_name, sale_type_id, sale_type_name, custom_id, custom_name, dosage_id, dosage_name, goods_id, goods_name, province_id, province_name, saler_id, saler_name, this_year_sa_qty, last_year_sa_qty, this_year_sa_money, last_year_sa_money, this_year_profit, last_year_profit, this_year_cost, last_year_cost, this_year_profit_rate, last_year_profit_rate, this_year_profit_share, last_year_profit_share, this_year_sa_money_share, last_year_sa_money_share, this_year_sa_money_growth, this_year_profit_growth, this_year_profit_change from new_gr_bi_sa_agg_year_count
</sql>
<select id="selectNewGrBiSaAggYearCountList" parameterType="com.lideeyunji.core.framework.entity.NewGrBiSaAggYearCount" resultMap="NewGrBiSaAggYearCountResult">
<include refid="selectNewGrBiSaAggYearCountVo"/>
<where>
<if test="useYear != null and useYear != ''"> and use_year = #{useYear}</if>
<if test="zoneId != null "> and zone_id = #{zoneId}</if>
<if test="zoneName != null and zoneName != ''"> and zone_name like concat('%', #{zoneName}, '%')</if>
<if test="saleTypeId != null "> and sale_type_id = #{saleTypeId}</if>
<if test="saleTypeName != null and saleTypeName != ''"> and sale_type_name like concat('%', #{saleTypeName}, '%')</if>
<if test="customId != null "> and custom_id = #{customId}</if>
<if test="customName != null and customName != ''"> and custom_name like concat('%', #{customName}, '%')</if>
<if test="dosageId != null "> and dosage_id = #{dosageId}</if>
<if test="dosageName != null and dosageName != ''"> and dosage_name like concat('%', #{dosageName}, '%')</if>
<if test="goodsId != null "> and goods_id = #{goodsId}</if>
<if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
<if test="provinceId != null "> and province_id = #{provinceId}</if>
<if test="provinceName != null and provinceName != ''"> and province_name like concat('%', #{provinceName}, '%')</if>
<if test="salerId != null "> and saler_id = #{salerId}</if>
<if test="salerName != null and salerName != ''"> and saler_name like concat('%', #{salerName}, '%')</if>
<if test="thisYearSaQty != null "> and this_year_sa_qty = #{thisYearSaQty}</if>
<if test="lastYearSaQty != null "> and last_year_sa_qty = #{lastYearSaQty}</if>
<if test="thisYearSaMoney != null "> and this_year_sa_money = #{thisYearSaMoney}</if>
<if test="lastYearSaMoney != null "> and last_year_sa_money = #{lastYearSaMoney}</if>
<if test="thisYearProfit != null "> and this_year_profit = #{thisYearProfit}</if>
<if test="lastYearProfit != null "> and last_year_profit = #{lastYearProfit}</if>
<if test="thisYearCost != null "> and this_year_cost = #{thisYearCost}</if>
<if test="lastYearCost != null "> and last_year_cost = #{lastYearCost}</if>
<if test="thisYearProfitRate != null "> and this_year_profit_rate = #{thisYearProfitRate}</if>
<if test="lastYearProfitRate != null "> and last_year_profit_rate = #{lastYearProfitRate}</if>
<if test="thisYearProfitShare != null "> and this_year_profit_share = #{thisYearProfitShare}</if>
<if test="lastYearProfitShare != null "> and last_year_profit_share = #{lastYearProfitShare}</if>
<if test="thisYearSaMoneyShare != null "> and this_year_sa_money_share = #{thisYearSaMoneyShare}</if>
<if test="lastYearSaMoneyShare != null "> and last_year_sa_money_share = #{lastYearSaMoneyShare}</if>
<if test="thisYearSaMoneyGrowth != null "> and this_year_sa_money_growth = #{thisYearSaMoneyGrowth}</if>
<if test="thisYearProfitGrowth != null "> and this_year_profit_growth = #{thisYearProfitGrowth}</if>
<if test="thisYearProfitChange != null "> and this_year_profit_change = #{thisYearProfitChange}</if>
</where>
</select>
<select id="selectNewGrBiSaAggYearCountById" parameterType="Long" resultMap="NewGrBiSaAggYearCountResult">
<include refid="selectNewGrBiSaAggYearCountVo"/>
where id = #{id}
</select>
<insert id="insertNewGrBiSaAggYearCount" parameterType="com.lideeyunji.core.framework.entity.NewGrBiSaAggYearCount" useGeneratedKeys="true" keyProperty="id">
insert into new_gr_bi_sa_agg_year_count
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="useYear != null">use_year,</if>
<if test="zoneId != null">zone_id,</if>
<if test="zoneName != null">zone_name,</if>
<if test="saleTypeId != null">sale_type_id,</if>
<if test="saleTypeName != null">sale_type_name,</if>
<if test="customId != null">custom_id,</if>
<if test="customName != null">custom_name,</if>
<if test="dosageId != null">dosage_id,</if>
<if test="dosageName != null">dosage_name,</if>
<if test="goodsId != null">goods_id,</if>
<if test="goodsName != null">goods_name,</if>
<if test="provinceId != null">province_id,</if>
<if test="provinceName != null">province_name,</if>
<if test="salerId != null">saler_id,</if>
<if test="salerName != null">saler_name,</if>
<if test="thisYearSaQty != null">this_year_sa_qty,</if>
<if test="lastYearSaQty != null">last_year_sa_qty,</if>
<if test="thisYearSaMoney != null">this_year_sa_money,</if>
<if test="lastYearSaMoney != null">last_year_sa_money,</if>
<if test="thisYearProfit != null">this_year_profit,</if>
<if test="lastYearProfit != null">last_year_profit,</if>
<if test="thisYearCost != null">this_year_cost,</if>
<if test="lastYearCost != null">last_year_cost,</if>
<if test="thisYearProfitRate != null">this_year_profit_rate,</if>
<if test="lastYearProfitRate != null">last_year_profit_rate,</if>
<if test="thisYearProfitShare != null">this_year_profit_share,</if>
<if test="lastYearProfitShare != null">last_year_profit_share,</if>
<if test="thisYearSaMoneyShare != null">this_year_sa_money_share,</if>
<if test="lastYearSaMoneyShare != null">last_year_sa_money_share,</if>
<if test="thisYearSaMoneyGrowth != null">this_year_sa_money_growth,</if>
<if test="thisYearProfitGrowth != null">this_year_profit_growth,</if>
<if test="thisYearProfitChange != null">this_year_profit_change,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="useYear != null">#{useYear},</if>
<if test="zoneId != null">#{zoneId},</if>
<if test="zoneName != null">#{zoneName},</if>
<if test="saleTypeId != null">#{saleTypeId},</if>
<if test="saleTypeName != null">#{saleTypeName},</if>
<if test="customId != null">#{customId},</if>
<if test="customName != null">#{customName},</if>
<if test="dosageId != null">#{dosageId},</if>
<if test="dosageName != null">#{dosageName},</if>
<if test="goodsId != null">#{goodsId},</if>
<if test="goodsName != null">#{goodsName},</if>
<if test="provinceId != null">#{provinceId},</if>
<if test="provinceName != null">#{provinceName},</if>
<if test="salerId != null">#{salerId},</if>
<if test="salerName != null">#{salerName},</if>
<if test="thisYearSaQty != null">#{thisYearSaQty},</if>
<if test="lastYearSaQty != null">#{lastYearSaQty},</if>
<if test="thisYearSaMoney != null">#{thisYearSaMoney},</if>
<if test="lastYearSaMoney != null">#{lastYearSaMoney},</if>
<if test="thisYearProfit != null">#{thisYearProfit},</if>
<if test="lastYearProfit != null">#{lastYearProfit},</if>
<if test="thisYearCost != null">#{thisYearCost},</if>
<if test="lastYearCost != null">#{lastYearCost},</if>
<if test="thisYearProfitRate != null">#{thisYearProfitRate},</if>
<if test="lastYearProfitRate != null">#{lastYearProfitRate},</if>
<if test="thisYearProfitShare != null">#{thisYearProfitShare},</if>
<if test="lastYearProfitShare != null">#{lastYearProfitShare},</if>
<if test="thisYearSaMoneyShare != null">#{thisYearSaMoneyShare},</if>
<if test="lastYearSaMoneyShare != null">#{lastYearSaMoneyShare},</if>
<if test="thisYearSaMoneyGrowth != null">#{thisYearSaMoneyGrowth},</if>
<if test="thisYearProfitGrowth != null">#{thisYearProfitGrowth},</if>
<if test="thisYearProfitChange != null">#{thisYearProfitChange},</if>
</trim>
</insert>
<update id="updateNewGrBiSaAggYearCount" parameterType="com.lideeyunji.core.framework.entity.NewGrBiSaAggYearCount">
update new_gr_bi_sa_agg_year_count
<trim prefix="SET" suffixOverrides=",">
<if test="useYear != null">use_year = #{useYear},</if>
<if test="zoneId != null">zone_id = #{zoneId},</if>
<if test="zoneName != null">zone_name = #{zoneName},</if>
<if test="saleTypeId != null">sale_type_id = #{saleTypeId},</if>
<if test="saleTypeName != null">sale_type_name = #{saleTypeName},</if>
<if test="customId != null">custom_id = #{customId},</if>
<if test="customName != null">custom_name = #{customName},</if>
<if test="dosageId != null">dosage_id = #{dosageId},</if>
<if test="dosageName != null">dosage_name = #{dosageName},</if>
<if test="goodsId != null">goods_id = #{goodsId},</if>
<if test="goodsName != null">goods_name = #{goodsName},</if>
<if test="provinceId != null">province_id = #{provinceId},</if>
<if test="provinceName != null">province_name = #{provinceName},</if>
<if test="salerId != null">saler_id = #{salerId},</if>
<if test="salerName != null">saler_name = #{salerName},</if>
<if test="thisYearSaQty != null">this_year_sa_qty = #{thisYearSaQty},</if>
<if test="lastYearSaQty != null">last_year_sa_qty = #{lastYearSaQty},</if>
<if test="thisYearSaMoney != null">this_year_sa_money = #{thisYearSaMoney},</if>
<if test="lastYearSaMoney != null">last_year_sa_money = #{lastYearSaMoney},</if>
<if test="thisYearProfit != null">this_year_profit = #{thisYearProfit},</if>
<if test="lastYearProfit != null">last_year_profit = #{lastYearProfit},</if>
<if test="thisYearCost != null">this_year_cost = #{thisYearCost},</if>
<if test="lastYearCost != null">last_year_cost = #{lastYearCost},</if>
<if test="thisYearProfitRate != null">this_year_profit_rate = #{thisYearProfitRate},</if>
<if test="lastYearProfitRate != null">last_year_profit_rate = #{lastYearProfitRate},</if>
<if test="thisYearProfitShare != null">this_year_profit_share = #{thisYearProfitShare},</if>
<if test="lastYearProfitShare != null">last_year_profit_share = #{lastYearProfitShare},</if>
<if test="thisYearSaMoneyShare != null">this_year_sa_money_share = #{thisYearSaMoneyShare},</if>
<if test="lastYearSaMoneyShare != null">last_year_sa_money_share = #{lastYearSaMoneyShare},</if>
<if test="thisYearSaMoneyGrowth != null">this_year_sa_money_growth = #{thisYearSaMoneyGrowth},</if>
<if test="thisYearProfitGrowth != null">this_year_profit_growth = #{thisYearProfitGrowth},</if>
<if test="thisYearProfitChange != null">this_year_profit_change = #{thisYearProfitChange},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteNewGrBiSaAggYearCountById" parameterType="Long">
delete from new_gr_bi_sa_agg_year_count where id = #{id}
</delete>
<delete id="deleteNewGrBiSaAggYearCountByIds" parameterType="String">
delete from new_gr_bi_sa_agg_year_count where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
-->
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
<id>lidee-core</id>
<classpath>
<dir name="D:/project/gr/gr_report_java/lidee-core/target/classes">
</dir>
</classpath>
</application>