综合销售情况表 调整月度,年度 报表数据
This commit is contained in:
@@ -97,5 +97,10 @@
|
|||||||
<artifactId>orai18n</artifactId>
|
<artifactId>orai18n</artifactId>
|
||||||
<version>21.1.0.0</version>
|
<version>21.1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
<version>1.4.7</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -8,5 +8,5 @@ import com.lideeyunji.tool.framework.yunji.model.ResultDataModel;
|
|||||||
*/
|
*/
|
||||||
public interface ReportAroundAdvicePlugin extends ReportBaseAdvicePlugin {
|
public interface ReportAroundAdvicePlugin extends ReportBaseAdvicePlugin {
|
||||||
|
|
||||||
ResultDataModel executeAround(EnhanceReportContext enhanceContext);
|
Object executeAround(EnhanceReportContext enhanceContext);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class ReportPluginManager {
|
|||||||
plugin.execute(enhanceContext);
|
plugin.execute(enhanceContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResultDataModel executeAroundPlugin(String name, EnhanceReportContext enhanceContext) {
|
public static Object executeAroundPlugin(String name, EnhanceReportContext enhanceContext) {
|
||||||
ReportAroundAdvicePlugin plugin = (ReportAroundAdvicePlugin)plugins.get(name);
|
ReportAroundAdvicePlugin plugin = (ReportAroundAdvicePlugin)plugins.get(name);
|
||||||
return plugin.executeAround(enhanceContext);
|
return plugin.executeAround(enhanceContext);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
|
|
||||||
package com.lideeyunji.core.framework.enhance.example.report.xtsy;
|
package com.lideeyunji.core.framework.enhance.example.report.xtsy;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.lideeyunji.core.framework.config.aspect.enhancereport.model.EnhanceReportContext;
|
import com.lideeyunji.core.framework.config.aspect.enhancereport.model.EnhanceReportContext;
|
||||||
import com.lideeyunji.core.framework.config.aspect.enhancereport.plugin.ReportAroundAdvicePlugin;
|
import com.lideeyunji.core.framework.config.aspect.enhancereport.plugin.ReportAroundAdvicePlugin;
|
||||||
import com.lideeyunji.core.framework.config.aspect.enhancereport.plugin.ReportBeforeAdvicePlugin;
|
import com.lideeyunji.core.framework.config.aspect.enhancereport.plugin.ReportBeforeAdvicePlugin;
|
||||||
import com.lideeyunji.core.framework.entity.NewGrBiSaAgg;
|
import com.lideeyunji.core.framework.entity.NewGrBiSaAgg;
|
||||||
|
import com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount;
|
||||||
|
import com.lideeyunji.core.framework.service.INewGrBiSaAggMonthCountService;
|
||||||
import com.lideeyunji.core.framework.service.INewGrBiSaAggService;
|
import com.lideeyunji.core.framework.service.INewGrBiSaAggService;
|
||||||
import com.lideeyunji.tool.framework.exception.lideeYunJiException;
|
import com.lideeyunji.tool.framework.exception.lideeYunJiException;
|
||||||
import com.lideeyunji.tool.framework.yunji.model.ResultDataModel;
|
import com.lideeyunji.tool.framework.yunji.model.ResultDataModel;
|
||||||
|
import com.lideeyunji.tool.framework.yunji.model.global.BaseWebResult;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -15,6 +21,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报表-系统首页-单表
|
* 报表-系统首页-单表
|
||||||
@@ -25,6 +32,8 @@ public class zhxsqkPlugin implements ReportAroundAdvicePlugin {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
INewGrBiSaAggService newGrBiSaAggService;
|
INewGrBiSaAggService newGrBiSaAggService;
|
||||||
|
@Autowired
|
||||||
|
INewGrBiSaAggMonthCountService newGrBiSaAggMonthCountService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDataModel executeAround(EnhanceReportContext enhanceContext) {
|
public ResultDataModel executeAround(EnhanceReportContext enhanceContext) {
|
||||||
@@ -36,11 +45,17 @@ public class zhxsqkPlugin implements ReportAroundAdvicePlugin {
|
|||||||
throw new lideeYunJiException("在选择维度时,“货品名称”不能有值!");
|
throw new lideeYunJiException("在选择维度时,“货品名称”不能有值!");
|
||||||
}
|
}
|
||||||
List<String> groupFieldList = Arrays.asList(params.get("Group by").toString().split(","));
|
List<String> groupFieldList = Arrays.asList(params.get("Group by").toString().split(","));
|
||||||
List<NewGrBiSaAgg> newGrBiSaAggList = newGrBiSaAggService.selectNewGrBiSaAggGroupMonthList(params, groupFieldList);
|
PageHelper.startPage(Integer.parseInt(params.get("pageNo").toString()), Integer.parseInt(params.get("pageSize").toString()));
|
||||||
// return ResultDataModel.fomatList(newGrBiSaAggList);
|
List<NewGrBiSaAggMonthCount> newGrBiSaAggList = newGrBiSaAggMonthCountService.selectNewGrBiSaAggGroupMonthList(params, groupFieldList);
|
||||||
|
PageInfo<NewGrBiSaAggMonthCount> pageInfo = new PageInfo<>(newGrBiSaAggList);
|
||||||
|
List<Map<String, Object>> list = newGrBiSaAggList.stream().map(newGrBiSaAgg -> BeanUtil.beanToMap(newGrBiSaAgg)).collect(Collectors.toList());
|
||||||
|
return ResultDataModel.fomat(pageInfo.getTotal(),list);
|
||||||
}else {
|
}else {
|
||||||
newGrBiSaAggService.selectNewGrBiSaAggList(params);
|
PageHelper.startPage(Integer.parseInt(params.get("pageNo").toString()), Integer.parseInt(params.get("pageSize").toString()));
|
||||||
}
|
List<NewGrBiSaAgg> newGrBiSaAggList = newGrBiSaAggService.selectNewGrBiSaAggList(params);
|
||||||
return null;
|
PageInfo<NewGrBiSaAgg> pageInfo = new PageInfo<>(newGrBiSaAggList);
|
||||||
|
List<Map<String, Object>> list = newGrBiSaAggList.stream().map(newGrBiSaAgg -> BeanUtil.beanToMap(newGrBiSaAgg)).collect(Collectors.toList());
|
||||||
|
return ResultDataModel.fomat(pageInfo.getTotal(),list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class NewGrBiSaAgg implements Serializable
|
|||||||
|
|
||||||
|
|
||||||
@TableField(value = "province_id")
|
@TableField(value = "province_id")
|
||||||
private Long provinceId;
|
private String provinceId;
|
||||||
|
|
||||||
|
|
||||||
@TableField(value = "province_name")
|
@TableField(value = "province_name")
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ public class NewGrBiSaAggMonthCount implements Serializable
|
|||||||
private String useYear;
|
private String useYear;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "ny")
|
||||||
|
private String ny;
|
||||||
|
|
||||||
|
|
||||||
@TableField(value = "use_month")
|
@TableField(value = "use_month")
|
||||||
private Long useMonth;
|
private Long useMonth;
|
||||||
|
|
||||||
@@ -67,7 +71,7 @@ public class NewGrBiSaAggMonthCount implements Serializable
|
|||||||
|
|
||||||
|
|
||||||
@TableField(value = "province_id")
|
@TableField(value = "province_id")
|
||||||
private Long provinceId;
|
private String provinceId;
|
||||||
|
|
||||||
|
|
||||||
@TableField(value = "province_name")
|
@TableField(value = "province_name")
|
||||||
@@ -156,5 +160,19 @@ public class NewGrBiSaAggMonthCount implements Serializable
|
|||||||
@TableField(value = "thisprofit_s")
|
@TableField(value = "thisprofit_s")
|
||||||
private BigDecimal thisMonthProfit_s;
|
private BigDecimal thisMonthProfit_s;
|
||||||
|
|
||||||
|
@TableField(value = "monthsaqty_yoy")
|
||||||
|
private String monthsaqty_yoy;
|
||||||
|
|
||||||
|
@TableField(value = "monthsamoney_yoy")
|
||||||
|
private String monthsamoney_yoy;
|
||||||
|
|
||||||
|
@TableField(value = "lastMonthSaMoney_yoy")
|
||||||
|
private String lastMonthSaMoney_yoy;
|
||||||
|
|
||||||
|
@TableField(value = "this_month_cost_yoy")
|
||||||
|
private String this_month_cost_yoy;
|
||||||
|
|
||||||
|
@TableField(value = "monthprofit_yoy")
|
||||||
|
private String monthprofit_yoy;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package com.lideeyunji.core.framework.mapper;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||||
import com.lideeyunji.core.framework.entity.GrBiSaAgg;
|
import com.lideeyunji.core.framework.entity.GrBiSaAgg;
|
||||||
import com.lideeyunji.core.framework.entity.NewGrBiSaAgg;
|
import com.lideeyunji.core.framework.entity.NewGrBiSaAgg;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.lideeyunji.core.framework.params.SaAggParam;
|
import com.lideeyunji.core.framework.params.SaAggParam;
|
||||||
|
import com.lideeyunji.tool.framework.permission.core.annotation.DataPermission;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,14 +69,9 @@ public interface NewGrBiSaAggMapper extends BaseMapper<NewGrBiSaAgg>
|
|||||||
* @param saAggParam 综合销售情况明细参数
|
* @param saAggParam 综合销售情况明细参数
|
||||||
* @return 综合销售情况明细集合
|
* @return 综合销售情况明细集合
|
||||||
*/
|
*/
|
||||||
public List<NewGrBiSaAgg> selectNewGrBiSaAggList(@Param("saAggParam")SaAggParam saAggParam);
|
@DataPermission(enable = false)
|
||||||
/**
|
@DS(value = "#dataSourceType")
|
||||||
* 批量查询综合销售情况明细列表 -月度
|
public List<NewGrBiSaAgg> selectNewGrBiSaAggList(@Param("dataSourceType") String dataSourceType,@Param("saAggParam")SaAggParam saAggParam);
|
||||||
*
|
|
||||||
* @param saAggParam 综合销售情况明细参数
|
|
||||||
* @return 综合销售情况明细集合
|
|
||||||
*/
|
|
||||||
public List<NewGrBiSaAgg> selectNewGrBiSaAggGroupMonthList(@Param("saAggParam") SaAggParam saAggParam, @Param("params") Map<String, Object> params, @Param("groupFieldList")List<String> groupFieldList);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增综合销售情况明细
|
* 新增综合销售情况明细
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
package com.lideeyunji.core.framework.mapper;
|
package com.lideeyunji.core.framework.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.lideeyunji.core.framework.entity.NewGrBiSaAgg;
|
||||||
import com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount;
|
import com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.lideeyunji.core.framework.params.SaAggParam;
|
import com.lideeyunji.core.framework.params.SaAggParam;
|
||||||
|
import com.lideeyunji.tool.framework.permission.core.annotation.DataPermission;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,4 +69,15 @@ public interface NewGrBiSaAggMonthCountMapper extends BaseMapper<NewGrBiSaAggMon
|
|||||||
|
|
||||||
@DS(value = "#dataSourceType")
|
@DS(value = "#dataSourceType")
|
||||||
List<NewGrBiSaAggMonthCount> getTotalDetail(@Param("dataSourceType") String dataSourceType, @Param("saAggParam") SaAggParam saAggParam);
|
List<NewGrBiSaAggMonthCount> getTotalDetail(@Param("dataSourceType") String dataSourceType, @Param("saAggParam") SaAggParam saAggParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询综合销售情况明细列表 -月度
|
||||||
|
*
|
||||||
|
* @param saAggParam 综合销售情况明细参数
|
||||||
|
* @return 综合销售情况明细集合
|
||||||
|
*/
|
||||||
|
@DataPermission(enable = false)
|
||||||
|
@DS(value = "#dataSourceType")
|
||||||
|
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupMonthList(@Param("dataSourceType") String dataSourceType, @Param("saAggParam") SaAggParam saAggParam, @Param("params") Map<String, Object> params, @Param("groupFieldList")List<String> groupFieldList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.lideeyunji.core.framework.service;
|
package com.lideeyunji.core.framework.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.lideeyunji.core.framework.entity.NewGrBiSaAgg;
|
||||||
import com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount;
|
import com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount;
|
||||||
import com.lideeyunji.core.framework.params.SaAggParam;
|
import com.lideeyunji.core.framework.params.SaAggParam;
|
||||||
|
|
||||||
@@ -61,4 +64,8 @@ public interface INewGrBiSaAggMonthCountService
|
|||||||
public int deleteNewGrBiSaAggMonthCountById(Long id);
|
public int deleteNewGrBiSaAggMonthCountById(Long id);
|
||||||
|
|
||||||
List<NewGrBiSaAggMonthCount> getTotalDetail(SaAggParam saAggParam);
|
List<NewGrBiSaAggMonthCount> getTotalDetail(SaAggParam saAggParam);
|
||||||
|
|
||||||
|
|
||||||
|
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupMonthList(Map<String, Object> params, List<String> groupFieldList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ public interface INewGrBiSaAggService
|
|||||||
*/
|
*/
|
||||||
public List<NewGrBiSaAgg> selectNewGrBiSaAggList(Map<String, Object> params);
|
public List<NewGrBiSaAgg> selectNewGrBiSaAggList(Map<String, Object> params);
|
||||||
|
|
||||||
public List<NewGrBiSaAgg> selectNewGrBiSaAggGroupMonthList(Map<String, Object> params, List<String> groupFieldList);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增综合销售情况明细
|
* 新增综合销售情况明细
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ package com.lideeyunji.core.framework.service.impl;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.lideeyunji.core.framework.entity.NewGrBiSaAgg;
|
||||||
import com.lideeyunji.core.framework.params.SaAggParam;
|
import com.lideeyunji.core.framework.params.SaAggParam;
|
||||||
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
|
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -91,8 +94,14 @@ public class NewGrBiSaAggMonthCountServiceImpl extends ServiceImpl<NewGrBiSaAggM
|
|||||||
return this.baseMapper.deleteNewGrBiSaAggMonthCountById(id);
|
return this.baseMapper.deleteNewGrBiSaAggMonthCountById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<NewGrBiSaAggMonthCount> getTotalDetail(SaAggParam saAggParam) {
|
public List<NewGrBiSaAggMonthCount> getTotalDetail(SaAggParam saAggParam) {
|
||||||
return this.baseMapper.getTotalDetail(lideeYunJiBaseConstant.DS_ERP_BI_DATA, saAggParam);
|
return this.baseMapper.getTotalDetail(lideeYunJiBaseConstant.DS_ERP_BI_DATA, saAggParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupMonthList(Map<String, Object> params, List<String> groupFieldList){
|
||||||
|
SaAggParam saAggParam = NewGrBiSaAggServiceImpl.createParam(params);
|
||||||
|
return this.baseMapper.selectNewGrBiSaAggGroupMonthList(lideeYunJiBaseConstant.DS_ERP_BI_DATA, saAggParam,params, groupFieldList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,14 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
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.core.plugins.IgnoreStrategy;
|
||||||
|
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
|
||||||
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.params.SaAggParam;
|
import com.lideeyunji.core.framework.params.SaAggParam;
|
||||||
import com.lideeyunji.core.framework.service.INewGrBiSaAggMonthCountService;
|
import com.lideeyunji.core.framework.service.INewGrBiSaAggMonthCountService;
|
||||||
import com.lideeyunji.core.framework.service.INewGrBiSaAggYearCountService;
|
import com.lideeyunji.core.framework.service.INewGrBiSaAggYearCountService;
|
||||||
|
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
|
||||||
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;
|
||||||
@@ -138,15 +141,11 @@ public class NewGrBiSaAggServiceImpl extends ServiceImpl<NewGrBiSaAggMapper, New
|
|||||||
public List<NewGrBiSaAgg> selectNewGrBiSaAggList(Map<String, Object> params)
|
public List<NewGrBiSaAgg> selectNewGrBiSaAggList(Map<String, Object> params)
|
||||||
{
|
{
|
||||||
SaAggParam saAggParam = createParam(params);
|
SaAggParam saAggParam = createParam(params);
|
||||||
return this.baseMapper.selectNewGrBiSaAggList(saAggParam);
|
return this.baseMapper.selectNewGrBiSaAggList(lideeYunJiBaseConstant.DS_ERP_BI_DATA, saAggParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<NewGrBiSaAgg> selectNewGrBiSaAggGroupMonthList(Map<String, Object> params, List<String> groupFieldList){
|
|
||||||
SaAggParam saAggParam = createParam(params);
|
|
||||||
return this.baseMapper.selectNewGrBiSaAggGroupMonthList(saAggParam,params, groupFieldList);
|
|
||||||
}
|
|
||||||
|
|
||||||
private SaAggParam createParam(Map<String, Object> params) {
|
public static SaAggParam createParam(Map<String, Object> params) {
|
||||||
SaAggParam saAggParam = new SaAggParam();
|
SaAggParam saAggParam = new SaAggParam();
|
||||||
if (params.containsKey("useyear")) {
|
if (params.containsKey("useyear")) {
|
||||||
saAggParam.setUseYear(params.get("useyear").toString());
|
saAggParam.setUseYear(params.get("useyear").toString());
|
||||||
|
|||||||
@@ -654,489 +654,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectNewGrBiSaAggGroupMonthList" resultMap="NewGrBiSaAggResult">
|
|
||||||
select
|
|
||||||
<if test="groupFieldList.contains('useyear') || params.containsKey('usemonth')">
|
|
||||||
current_month.use_month as usemonth,
|
|
||||||
<choose>
|
|
||||||
<when test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
|
||||||
current_month.use_year as useyear,
|
|
||||||
current_month.use_year as ny, #年月
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
LPAD(current_month.use_month, 2, '0') as ny,
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('customname') || params.containsKey('customname')">
|
|
||||||
current_month.custom_id as customid,
|
|
||||||
current_month.custom_name as customname, #客户名称
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">
|
|
||||||
current_month.zone_id,
|
|
||||||
current_month.zone_name as zonename,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">
|
|
||||||
current_month.sale_type_id,
|
|
||||||
current_month.sale_type_name as saletypename,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">
|
|
||||||
current_month.saler_id,
|
|
||||||
current_month.saler_name as salername, #业务员
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">
|
|
||||||
current_month.dosage_id,
|
|
||||||
current_month.dosage_name as dosagename, #剂型
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')">
|
|
||||||
current_month.std_goods_name as stdGoodsName,
|
|
||||||
</if>
|
|
||||||
current_month.this_month_sa_qty AS thisMonthSaQty, #本月销售数量(件)
|
|
||||||
ROUND(current_month.this_month_sa_money / 10000, 2) AS thisMonthSaMoney, #本月销售金额(元)
|
|
||||||
ROUND(current_month.this_month_profit / 10000, 2) AS thisMonthProfit, #本月毛利额(元)
|
|
||||||
ROUND(current_month.this_month_cost / 10000, 2) AS thisMonthCost, #本月成本(元)
|
|
||||||
last_month_data.last_month_sa_qty AS lastMonthSaQty, #上月销售数量(件)
|
|
||||||
ROUND(last_month_data.last_month_sa_money / 10000, 2) AS lastMonthSaMoney, #上月销售金额(元)
|
|
||||||
ROUND(last_month_data.last_month_profit / 10000, 2) AS lastMonthProfit, #上月毛利额(元)
|
|
||||||
ROUND(last_month_data.last_month_cost / 10000, 2) AS lastMonthCost, #上月成本(元)
|
|
||||||
ROUND(yoy_month.yoy_month_sa_qty / 10000, 2) AS yoyMonthSaQty, #同比月销售数量(件)
|
|
||||||
ROUND(yoy_month.yoy_month_sa_money / 10000, 2) AS yoyMonthSaMoney, #同比月销售金额(元)
|
|
||||||
ROUND(yoy_month.yoy_month_profit / 10000, 2) AS yoyMonthProfit, #同比月毛利额(元)
|
|
||||||
ROUND(yoy_month.yoy_month_cost / 10000, 2) AS yoyMonthCost, #同比月成本(元)
|
|
||||||
current_month.province_id AS province_id, #行政区域ID
|
|
||||||
current_month.province_name AS province_name, #行政区域名称
|
|
||||||
CASE WHEN (CASE WHEN yoy_month.yoy_month_sa_qty = 0 THEN IF(current_month.this_month_sa_qty > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_qty - yoy_month.yoy_month_sa_qty) / yoy_month.yoy_month_sa_qty * 100 END) > 0 THEN
|
|
||||||
CONCAT('🟢 ', ROUND((CASE WHEN yoy_month.yoy_month_sa_qty = 0 THEN IF(current_month.this_month_sa_qty > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_qty - yoy_month.yoy_month_sa_qty) / yoy_month.yoy_month_sa_qty * 100 END), 2))
|
|
||||||
WHEN (CASE WHEN yoy_month.yoy_month_sa_qty = 0 THEN IF(current_month.this_month_sa_qty > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_qty - yoy_month.yoy_month_sa_qty) / yoy_month.yoy_month_sa_qty * 100 END)<0 THEN
|
|
||||||
CONCAT('🔴 ', ROUND((CASE WHEN yoy_month.yoy_month_sa_qty = 0 THEN IF(current_month.this_month_sa_qty > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_qty - yoy_month.yoy_month_sa_qty) / yoy_month.yoy_month_sa_qty * 100 END), 2))
|
|
||||||
END AS monthsaqty_yoy, #本月销量同比
|
|
||||||
|
|
||||||
CASE WHEN (CASE WHEN yoy_month.yoy_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_money - yoy_month.yoy_month_sa_money) / yoy_month.yoy_month_sa_money * 100 END) > 0 THEN
|
|
||||||
CONCAT('🟢 ', ROUND((CASE WHEN yoy_month.yoy_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_money - yoy_month.yoy_month_sa_money) / yoy_month.yoy_month_sa_money * 100 END), 2))
|
|
||||||
WHEN (CASE WHEN yoy_month.yoy_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_money - yoy_month.yoy_month_sa_money) / yoy_month.yoy_month_sa_money * 100 END)<0 THEN
|
|
||||||
CONCAT('🔴 ', ROUND((CASE WHEN yoy_month.yoy_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_money - yoy_month.yoy_month_sa_money) / yoy_month.yoy_month_sa_money * 100 END), 2))
|
|
||||||
ELSE '0.00'
|
|
||||||
END AS monthsamoney_yoy, #本月销售金额同比
|
|
||||||
|
|
||||||
CASE WHEN (CASE WHEN last_month_data.last_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_money - last_month_data.last_month_sa_money) / last_month_data.last_month_sa_money * 100 END) > 0 THEN
|
|
||||||
CONCAT('🟢 ', ROUND((CASE WHEN last_month_data.last_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_money - last_month_data.last_month_sa_money) / last_month_data.last_month_sa_money * 100 END), 2))
|
|
||||||
WHEN (CASE WHEN last_month_data.last_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_money - last_month_data.last_month_sa_money) / last_month_data.last_month_sa_money * 100 END)<0 THEN
|
|
||||||
CONCAT('🔴 ', ROUND((CASE WHEN last_month_data.last_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_sa_money - last_month_data.last_month_sa_money) / last_month_data.last_month_sa_money * 100 END), 2))
|
|
||||||
ELSE '0.00'
|
|
||||||
END AS lastMonthSaMoney_yoy, #本月销售金额增长率
|
|
||||||
|
|
||||||
CASE WHEN (CASE WHEN yoy_month.yoy_month_cost = 0 THEN IF(current_month.this_month_cost > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_cost - yoy_month.yoy_month_cost) / yoy_month.yoy_month_cost * 100 END) > 0 THEN
|
|
||||||
CONCAT('🟢 ', ROUND((CASE WHEN yoy_month.yoy_month_cost = 0 THEN IF(current_month.this_month_cost > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_cost - yoy_month.yoy_month_cost) / yoy_month.yoy_month_cost * 100 END), 2))
|
|
||||||
WHEN (CASE WHEN yoy_month.yoy_month_cost = 0 THEN IF(current_month.this_month_cost > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_cost - yoy_month.yoy_month_cost) / yoy_month.yoy_month_cost * 100 END)<0 THEN
|
|
||||||
CONCAT('🔴 ', ROUND((CASE WHEN yoy_month.yoy_month_cost = 0 THEN IF(current_month.this_month_cost > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_cost - yoy_month.yoy_month_cost) / yoy_month.yoy_month_cost * 100 END), 2))
|
|
||||||
ELSE '0.00'
|
|
||||||
END AS this_month_cost_yoy, #本月销售成本同比
|
|
||||||
|
|
||||||
CASE WHEN (CASE WHEN yoy_month.yoy_month_profit = 0 THEN IF(current_month.this_month_profit > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_profit - yoy_month.yoy_month_profit) / yoy_month.yoy_month_profit * 100 END) > 0 THEN
|
|
||||||
CONCAT('🟢 ', ROUND((CASE WHEN yoy_month.yoy_month_profit = 0 THEN IF(current_month.this_month_profit > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_profit - yoy_month.yoy_month_profit) / yoy_month.yoy_month_profit * 100 END), 2))
|
|
||||||
WHEN (CASE WHEN yoy_month.yoy_month_profit = 0 THEN IF(current_month.this_month_profit > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_profit - yoy_month.yoy_month_profit) / yoy_month.yoy_month_profit * 100 END)<0 THEN
|
|
||||||
CONCAT('🔴 ', ROUND((CASE WHEN yoy_month.yoy_month_profit = 0 THEN IF(current_month.this_month_profit > 0, 100, 0)
|
|
||||||
ELSE (current_month.this_month_profit - yoy_month.yoy_month_profit) / yoy_month.yoy_month_profit * 100 END), 2))
|
|
||||||
ELSE '0.00'
|
|
||||||
END AS monthprofit_yoy, #本月毛利同比
|
|
||||||
|
|
||||||
COALESCE (ROUND( current_month.this_month_sa_money/total_month_data.this_month_sa_money_sum * 100, 2), 0 ) as this_month_sa_money_share, #本月销售金额占比
|
|
||||||
COALESCE (ROUND( current_month.this_month_profit/total_month_data.this_month_profit_sum * 100, 2), 0 ) as this_month_profit_share #本月毛利额占比
|
|
||||||
FROM ( SELECT
|
|
||||||
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
|
||||||
use_year,
|
|
||||||
</if>
|
|
||||||
use_month,
|
|
||||||
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
|
||||||
custom_id,
|
|
||||||
custom_name ,
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')">
|
|
||||||
std_goods_name,
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
|
||||||
zone_id,
|
|
||||||
zone_name,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
|
||||||
sale_type_id,
|
|
||||||
sale_type_name,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">
|
|
||||||
dosage_id,
|
|
||||||
dosage_name,
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">
|
|
||||||
saler_id,
|
|
||||||
saler_name,
|
|
||||||
</if>
|
|
||||||
CONCAT(MAX(use_year), LPAD(MAX(use_month), 2, '0')) AS ny,
|
|
||||||
GROUP_CONCAT(DISTINCT province_id ORDER BY province_id SEPARATOR ',') AS province_id,
|
|
||||||
GROUP_CONCAT(DISTINCT province_name ORDER BY province_name SEPARATOR ',') AS province_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_month_count
|
|
||||||
<where>
|
|
||||||
<if test="saAggParam.useYear != null and saAggParam.useYear != ''"> and use_year = #{saAggParam.useYear}</if>
|
|
||||||
<if test="saAggParam.useMonth != null "> and use_month = #{saAggParam.useMonth}</if>
|
|
||||||
<if test="saAggParam.zoneName != null and saAggParam.zoneName != ''"> and zone_name in
|
|
||||||
<foreach collection="saAggParam.zoneName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.saleTypeName != null and saAggParam.saleTypeName != ''"> and sale_type_name in
|
|
||||||
<foreach collection="saAggParam.saleTypeName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.customName != null and saAggParam.customName != ''"> and custom_name in
|
|
||||||
<foreach collection="saAggParam.customName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.dosageName != null and saAggParam.dosageName != ''"> and dosage_name in
|
|
||||||
<foreach collection="saAggParam.dosageName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.goodsName != null and saAggParam.goodsName != ''"> and goods_name in
|
|
||||||
<foreach collection="saAggParam.goodsName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.provinceName != null and saAggParam.provinceName != ''"> and province_name in
|
|
||||||
<foreach collection="saAggParam.provinceName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.salerName != null and saAggParam.salerName != ''"> and saler_name in
|
|
||||||
<foreach collection="saAggParam.salerName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<if test="saAggParam.stdGoodsName != null and saAggParam.stdGoodsName != ''"> and std_goods_name in
|
|
||||||
<foreach collection="saAggParam.stdGoodsName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
GROUP BY
|
|
||||||
<trim suffixOverrides=",">
|
|
||||||
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
|
||||||
use_year,
|
|
||||||
</if>
|
|
||||||
use_month,
|
|
||||||
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
|
||||||
custom_id,
|
|
||||||
custom_name ,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
|
||||||
std_goods_name,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
|
||||||
zone_id,
|
|
||||||
zone_name,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
|
||||||
sale_type_id,
|
|
||||||
sale_type_name,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
|
||||||
dosage_id,
|
|
||||||
dosage_name,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
|
||||||
saler_id,
|
|
||||||
saler_name,
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
) AS current_month # current_month 本月数据
|
|
||||||
LEFT JOIN (
|
|
||||||
SELECT
|
|
||||||
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
|
||||||
use_year,
|
|
||||||
</if>
|
|
||||||
use_month,
|
|
||||||
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
|
||||||
custom_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
|
||||||
std_goods_name,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
|
||||||
zone_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
|
||||||
sale_type_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
|
||||||
dosage_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
|
||||||
saler_id,
|
|
||||||
</if>
|
|
||||||
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_month_count
|
|
||||||
GROUP BY
|
|
||||||
<trim suffixOverrides=",">
|
|
||||||
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
|
||||||
use_year,
|
|
||||||
</if>
|
|
||||||
use_month,
|
|
||||||
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
|
||||||
custom_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
|
||||||
std_goods_name,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
|
||||||
zone_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
|
||||||
sale_type_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
|
||||||
dosage_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
|
||||||
saler_id,
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
) AS last_month_data # last_month_data 上月数据
|
|
||||||
ON last_month_data.use_month = IF(current_month.use_month = 1, 12, current_month.use_month - 1)
|
|
||||||
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
|
||||||
AND last_month_data.use_year = current_month.use_year - (current_month.use_month = 1)
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
|
||||||
AND current_month.custom_id = last_month_data.custom_id
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
|
||||||
AND current_month.std_goods_name = last_month_data.std_goods_name
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
|
||||||
AND current_month.zone_id = last_month_data.zone_id
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
|
||||||
AND current_month.sale_type_id = last_month_data.sale_type_id
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
|
||||||
AND current_month.dosage_id = last_month_data.dosage_id
|
|
||||||
</if>
|
|
||||||
# if (groupFieldList.contains('salername') || params.containsKey('salername')) {
|
|
||||||
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
|
||||||
AND current_month.saler_id = last_month_data.saler_id
|
|
||||||
</if>
|
|
||||||
LEFT JOIN (
|
|
||||||
SELECT
|
|
||||||
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
|
||||||
use_year,
|
|
||||||
</if>
|
|
||||||
use_month,
|
|
||||||
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
|
||||||
custom_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
|
||||||
std_goods_name,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
|
||||||
zone_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
|
||||||
sale_type_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
|
||||||
dosage_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
|
||||||
saler_id,
|
|
||||||
</if>
|
|
||||||
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_month_count
|
|
||||||
<where>
|
|
||||||
<if test="saAggParam.useYear != null and saAggParam.useYear != ''"> and use_year = #{saAggParam.useYear}</if>
|
|
||||||
<if test="saAggParam.useMonth != null "> and use_month = #{saAggParam.useMonth}</if>
|
|
||||||
<if test="saAggParam.zoneName != null and zoneName != ''"> and zone_name in
|
|
||||||
<foreach collection="saAggParam.zoneName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.saleTypeName != null and saAggParam.saleTypeName != ''"> and sale_type_name in
|
|
||||||
<foreach collection="saAggParam.saleTypeName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.customName != null and saAggParam.customName != ''"> and custom_name in
|
|
||||||
<foreach collection="saAggParam.customName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.dosageName != null and saAggParam.dosageName != ''"> and dosage_name in
|
|
||||||
<foreach collection="saAggParam.dosageName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.goodsName != null and saAggParam.goodsName != ''"> and goods_name in
|
|
||||||
<foreach collection="saAggParam.goodsName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.provinceName != null and saAggParam.provinceName != ''"> and province_name in
|
|
||||||
<foreach collection="saAggParam.provinceName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.salerName != null and saAggParam.salerName != ''"> and saler_name in
|
|
||||||
<foreach collection="saAggParam.salerName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<if test="saAggParam.stdGoodsName != null and saAggParam.stdGoodsName != ''"> and std_goods_name in
|
|
||||||
<foreach collection="saAggParam.stdGoodsName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
GROUP BY
|
|
||||||
<trim suffixOverrides=",">
|
|
||||||
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
|
||||||
use_year,
|
|
||||||
</if>
|
|
||||||
use_month,
|
|
||||||
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
|
||||||
custom_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
|
||||||
std_goods_name,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
|
||||||
zone_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
|
||||||
sale_type_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
|
||||||
dosage_id,
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
|
||||||
saler_id,
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
) yoy_month ON
|
|
||||||
<trim prefixOverrides="and">
|
|
||||||
|
|
||||||
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
|
||||||
and yoy_month.use_year = current_month.use_year - 1 # 同比月数据
|
|
||||||
</if>
|
|
||||||
and yoy_month.use_month = current_month.use_month
|
|
||||||
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
|
||||||
AND yoy_month.custom_id = current_month.custom_id
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
|
||||||
AND yoy_month.std_goods_name = current_month.std_goods_name
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
|
||||||
AND yoy_month.zone_id = current_month.zone_id
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
|
||||||
AND yoy_month.sale_type_id = current_month.sale_type_id
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
|
||||||
AND yoy_month.dosage_id = current_month.dosage_id
|
|
||||||
</if>
|
|
||||||
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
|
||||||
AND yoy_month.saler_id = current_month.saler_id
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
|
|
||||||
LEFT JOIN (
|
|
||||||
SELECT
|
|
||||||
use_year,
|
|
||||||
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
|
|
||||||
) total_month_data ON total_month_data.use_year = current_month.use_year
|
|
||||||
<where>
|
|
||||||
<if test="saAggParam.useYear != null and saAggParam.useYear != ''"> and current_month.use_year = #{saAggParam.useYear}</if>
|
|
||||||
<if test="saAggParam.useMonth != null "> and current_month.use_month = #{saAggParam.useMonth}</if>
|
|
||||||
<if test="saAggParam.zoneName != null and saAggParam.zoneName != ''"> and current_month.zone_name in
|
|
||||||
<foreach collection="saAggParam.zoneName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.saleTypeName != null and saAggParam.saleTypeName != ''"> and current_month.sale_type_name in
|
|
||||||
<foreach collection="saAggParam.saleTypeName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.customName != null and saAggParam.customName != ''"> and current_month.custom_name in
|
|
||||||
<foreach collection="saAggParam.customName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.dosageName != null and saAggParam.dosageName != ''"> and current_month.dosage_name in
|
|
||||||
<foreach collection="saAggParam.dosageName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.goodsName != null and saAggParam.goodsName != ''"> and current_month.goods_name in
|
|
||||||
<foreach collection="saAggParam.goodsName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.provinceName != null and saAggParam.provinceName != ''"> and current_month.province_name in
|
|
||||||
<foreach collection="saAggParam.provinceName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="saAggParam.salerName != null and saAggParam.salerName != ''"> and current_month.saler_name in
|
|
||||||
<foreach collection="saAggParam.salerName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<if test="saAggParam.stdGoodsName != null and saAggParam.stdGoodsName != ''"> and current_month.std_goods_name in
|
|
||||||
<foreach collection="saAggParam.stdGoodsName" item="name" open="(" separator="," close=")">
|
|
||||||
#{name}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectNewGrBiSaAggById" parameterType="Long" resultMap="NewGrBiSaAggResult">
|
<select id="selectNewGrBiSaAggById" parameterType="Long" resultMap="NewGrBiSaAggResult">
|
||||||
<include refid="selectNewGrBiSaAggVo"/>
|
<include refid="selectNewGrBiSaAggVo"/>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<resultMap type="com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount" id="NewGrBiSaAggMonthCountResult">
|
<resultMap type="com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount" id="NewGrBiSaAggMonthCountResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
|
<result property="ny" column="ny" />
|
||||||
<result property="useYear" column="use_year" />
|
<result property="useYear" column="use_year" />
|
||||||
<result property="useMonth" column="use_month" />
|
<result property="useMonth" column="use_month" />
|
||||||
<result property="zoneId" column="zone_id" />
|
<result property="zoneId" column="zone_id" />
|
||||||
@@ -40,6 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="thisMonthProfitShare" column="this_month_profit_share" />
|
<result property="thisMonthProfitShare" column="this_month_profit_share" />
|
||||||
<result property="thisMonthSaMoney_s" column="thissamoney_s" />
|
<result property="thisMonthSaMoney_s" column="thissamoney_s" />
|
||||||
<result property="thisMonthProfit_s" column="thisprofit_s" />
|
<result property="thisMonthProfit_s" column="thisprofit_s" />
|
||||||
|
<result property="monthsaqty_yoy" column="monthsaqty_yoy" />
|
||||||
|
<result property="monthsamoney_yoy" column="monthsamoney_yoy" />
|
||||||
|
<result property="lastMonthSaMoney_yoy" column="lastMonthSaMoney_yoy" />
|
||||||
|
<result property="this_month_cost_yoy" column="this_month_cost_yoy" />
|
||||||
|
<result property="monthprofit_yoy" column="monthprofit_yoy" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectNewGrBiSaAggMonthCountVo">
|
<sql id="selectNewGrBiSaAggMonthCountVo">
|
||||||
@@ -239,4 +245,488 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectNewGrBiSaAggGroupMonthList" resultMap="NewGrBiSaAggMonthCountResult">
|
||||||
|
select
|
||||||
|
<if test="groupFieldList.contains('useyear') || params.containsKey('usemonth')">
|
||||||
|
current_month.use_month ,
|
||||||
|
<choose>
|
||||||
|
<when test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
||||||
|
current_month.use_year,
|
||||||
|
current_month.use_year as ny, #年月
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
LPAD(current_month.use_month, 2, '0') as ny,
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('customname') || params.containsKey('customname')">
|
||||||
|
current_month.custom_id,
|
||||||
|
current_month.custom_name, #客户名称
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">
|
||||||
|
current_month.zone_id,
|
||||||
|
current_month.zone_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">
|
||||||
|
current_month.sale_type_id,
|
||||||
|
current_month.sale_type_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">
|
||||||
|
current_month.saler_id,
|
||||||
|
current_month.saler_name, #业务员
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">
|
||||||
|
current_month.dosage_id,
|
||||||
|
current_month.dosage_name, #剂型
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')">
|
||||||
|
current_month.std_goods_name,
|
||||||
|
</if>
|
||||||
|
current_month.this_month_sa_qty AS this_month_sa_qty, #本月销售数量(件)
|
||||||
|
ROUND(current_month.this_month_sa_money / 10000, 2) AS this_month_sa_money, #本月销售金额(元)
|
||||||
|
ROUND(current_month.this_month_profit / 10000, 2) AS this_month_profit, #本月毛利额(元)
|
||||||
|
ROUND(current_month.this_month_cost / 10000, 2) AS this_month_cost, #本月成本(元)
|
||||||
|
last_month_data.last_month_sa_qty AS last_month_sa_qty, #上月销售数量(件)
|
||||||
|
ROUND(last_month_data.last_month_sa_money / 10000, 2) AS last_month_sa_money, #上月销售金额(元)
|
||||||
|
ROUND(last_month_data.last_month_profit / 10000, 2) AS last_month_profit, #上月毛利额(元)
|
||||||
|
ROUND(last_month_data.last_month_cost / 10000, 2) AS last_month_cost, #上月成本(元)
|
||||||
|
ROUND(yoy_month.yoy_month_sa_qty / 10000, 2) AS yoy_month_sa_qty, #同比月销售数量(件)
|
||||||
|
ROUND(yoy_month.yoy_month_sa_money / 10000, 2) AS yoy_month_sa_money, #同比月销售金额(元)
|
||||||
|
ROUND(yoy_month.yoy_month_profit / 10000, 2) AS yoy_month_profit, #同比月毛利额(元)
|
||||||
|
ROUND(yoy_month.yoy_month_cost / 10000, 2) AS yoy_month_cost, #同比月成本(元)
|
||||||
|
# current_month.province_id AS province_id, #行政区域ID
|
||||||
|
# current_month.province_name AS province_name, #行政区域名称
|
||||||
|
CASE WHEN (CASE WHEN yoy_month.yoy_month_sa_qty = 0 THEN IF(current_month.this_month_sa_qty > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_qty - yoy_month.yoy_month_sa_qty) / yoy_month.yoy_month_sa_qty * 100 END) > 0 THEN
|
||||||
|
CONCAT('🟢 ', ROUND((CASE WHEN yoy_month.yoy_month_sa_qty = 0 THEN IF(current_month.this_month_sa_qty > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_qty - yoy_month.yoy_month_sa_qty) / yoy_month.yoy_month_sa_qty * 100 END), 2))
|
||||||
|
WHEN (CASE WHEN yoy_month.yoy_month_sa_qty = 0 THEN IF(current_month.this_month_sa_qty > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_qty - yoy_month.yoy_month_sa_qty) / yoy_month.yoy_month_sa_qty * 100 END)<0 THEN
|
||||||
|
CONCAT('🔴 ', ROUND((CASE WHEN yoy_month.yoy_month_sa_qty = 0 THEN IF(current_month.this_month_sa_qty > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_qty - yoy_month.yoy_month_sa_qty) / yoy_month.yoy_month_sa_qty * 100 END), 2))
|
||||||
|
END AS monthsaqty_yoy, #本月销量同比
|
||||||
|
|
||||||
|
CASE WHEN (CASE WHEN yoy_month.yoy_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_money - yoy_month.yoy_month_sa_money) / yoy_month.yoy_month_sa_money * 100 END) > 0 THEN
|
||||||
|
CONCAT('🟢 ', ROUND((CASE WHEN yoy_month.yoy_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_money - yoy_month.yoy_month_sa_money) / yoy_month.yoy_month_sa_money * 100 END), 2))
|
||||||
|
WHEN (CASE WHEN yoy_month.yoy_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_money - yoy_month.yoy_month_sa_money) / yoy_month.yoy_month_sa_money * 100 END)<0 THEN
|
||||||
|
CONCAT('🔴 ', ROUND((CASE WHEN yoy_month.yoy_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_money - yoy_month.yoy_month_sa_money) / yoy_month.yoy_month_sa_money * 100 END), 2))
|
||||||
|
ELSE '0.00'
|
||||||
|
END AS monthsamoney_yoy, #本月销售金额同比
|
||||||
|
|
||||||
|
CASE WHEN (CASE WHEN last_month_data.last_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_money - last_month_data.last_month_sa_money) / last_month_data.last_month_sa_money * 100 END) > 0 THEN
|
||||||
|
CONCAT('🟢 ', ROUND((CASE WHEN last_month_data.last_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_money - last_month_data.last_month_sa_money) / last_month_data.last_month_sa_money * 100 END), 2))
|
||||||
|
WHEN (CASE WHEN last_month_data.last_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_money - last_month_data.last_month_sa_money) / last_month_data.last_month_sa_money * 100 END)<0 THEN
|
||||||
|
CONCAT('🔴 ', ROUND((CASE WHEN last_month_data.last_month_sa_money = 0 THEN IF(current_month.this_month_sa_money > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_sa_money - last_month_data.last_month_sa_money) / last_month_data.last_month_sa_money * 100 END), 2))
|
||||||
|
ELSE '0.00'
|
||||||
|
END AS lastMonthSaMoney_yoy, #本月销售金额增长率
|
||||||
|
|
||||||
|
CASE WHEN (CASE WHEN yoy_month.yoy_month_cost = 0 THEN IF(current_month.this_month_cost > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_cost - yoy_month.yoy_month_cost) / yoy_month.yoy_month_cost * 100 END) > 0 THEN
|
||||||
|
CONCAT('🟢 ', ROUND((CASE WHEN yoy_month.yoy_month_cost = 0 THEN IF(current_month.this_month_cost > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_cost - yoy_month.yoy_month_cost) / yoy_month.yoy_month_cost * 100 END), 2))
|
||||||
|
WHEN (CASE WHEN yoy_month.yoy_month_cost = 0 THEN IF(current_month.this_month_cost > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_cost - yoy_month.yoy_month_cost) / yoy_month.yoy_month_cost * 100 END)<0 THEN
|
||||||
|
CONCAT('🔴 ', ROUND((CASE WHEN yoy_month.yoy_month_cost = 0 THEN IF(current_month.this_month_cost > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_cost - yoy_month.yoy_month_cost) / yoy_month.yoy_month_cost * 100 END), 2))
|
||||||
|
ELSE '0.00'
|
||||||
|
END AS this_month_cost_yoy, #本月销售成本同比
|
||||||
|
|
||||||
|
CASE WHEN (CASE WHEN yoy_month.yoy_month_profit = 0 THEN IF(current_month.this_month_profit > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_profit - yoy_month.yoy_month_profit) / yoy_month.yoy_month_profit * 100 END) > 0 THEN
|
||||||
|
CONCAT('🟢 ', ROUND((CASE WHEN yoy_month.yoy_month_profit = 0 THEN IF(current_month.this_month_profit > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_profit - yoy_month.yoy_month_profit) / yoy_month.yoy_month_profit * 100 END), 2))
|
||||||
|
WHEN (CASE WHEN yoy_month.yoy_month_profit = 0 THEN IF(current_month.this_month_profit > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_profit - yoy_month.yoy_month_profit) / yoy_month.yoy_month_profit * 100 END)<0 THEN
|
||||||
|
CONCAT('🔴 ', ROUND((CASE WHEN yoy_month.yoy_month_profit = 0 THEN IF(current_month.this_month_profit > 0, 100, 0)
|
||||||
|
ELSE (current_month.this_month_profit - yoy_month.yoy_month_profit) / yoy_month.yoy_month_profit * 100 END), 2))
|
||||||
|
ELSE '0.00'
|
||||||
|
END AS monthprofit_yoy, #本月毛利同比
|
||||||
|
|
||||||
|
COALESCE (ROUND( current_month.this_month_sa_money/total_month_data.this_month_sa_money_sum * 100, 2), 0 ) as this_month_sa_money_share, #本月销售金额占比
|
||||||
|
COALESCE (ROUND( current_month.this_month_profit/total_month_data.this_month_profit_sum * 100, 2), 0 ) as this_month_profit_share #本月毛利额占比
|
||||||
|
FROM ( SELECT
|
||||||
|
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
||||||
|
use_year,
|
||||||
|
</if>
|
||||||
|
use_month,
|
||||||
|
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
||||||
|
custom_id,
|
||||||
|
custom_name ,
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')">
|
||||||
|
std_goods_name,
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
||||||
|
zone_id,
|
||||||
|
zone_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
||||||
|
sale_type_id,
|
||||||
|
sale_type_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">
|
||||||
|
dosage_id,
|
||||||
|
dosage_name,
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">
|
||||||
|
saler_id,
|
||||||
|
saler_name,
|
||||||
|
</if>
|
||||||
|
CONCAT(MAX(use_year), LPAD(MAX(use_month), 2, '0')) AS ny,
|
||||||
|
# GROUP_CONCAT(DISTINCT province_id ORDER BY province_id SEPARATOR ',') AS province_id,
|
||||||
|
# GROUP_CONCAT(DISTINCT province_name ORDER BY province_name SEPARATOR ',') AS province_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_month_count
|
||||||
|
<where>
|
||||||
|
<if test="saAggParam.useYear != null and saAggParam.useYear != ''"> and use_year = #{saAggParam.useYear}</if>
|
||||||
|
<if test="saAggParam.useMonth != null "> and use_month = #{saAggParam.useMonth}</if>
|
||||||
|
<if test="saAggParam.zoneName != null and saAggParam.zoneName != ''"> and zone_name in
|
||||||
|
<foreach collection="saAggParam.zoneName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.saleTypeName != null and saAggParam.saleTypeName != ''"> and sale_type_name in
|
||||||
|
<foreach collection="saAggParam.saleTypeName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.customName != null and saAggParam.customName != ''"> and custom_name in
|
||||||
|
<foreach collection="saAggParam.customName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.dosageName != null and saAggParam.dosageName != ''"> and dosage_name in
|
||||||
|
<foreach collection="saAggParam.dosageName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.goodsName != null and saAggParam.goodsName != ''"> and goods_name in
|
||||||
|
<foreach collection="saAggParam.goodsName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.provinceName != null and saAggParam.provinceName != ''"> and province_name in
|
||||||
|
<foreach collection="saAggParam.provinceName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.salerName != null and saAggParam.salerName != ''"> and saler_name in
|
||||||
|
<foreach collection="saAggParam.salerName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="saAggParam.stdGoodsName != null and saAggParam.stdGoodsName != ''"> and std_goods_name in
|
||||||
|
<foreach collection="saAggParam.stdGoodsName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY
|
||||||
|
<trim suffixOverrides=",">
|
||||||
|
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
||||||
|
use_year,
|
||||||
|
</if>
|
||||||
|
use_month,
|
||||||
|
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
||||||
|
custom_id,
|
||||||
|
custom_name ,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
||||||
|
std_goods_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
||||||
|
zone_id,
|
||||||
|
zone_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
||||||
|
sale_type_id,
|
||||||
|
sale_type_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
||||||
|
dosage_id,
|
||||||
|
dosage_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
||||||
|
saler_id,
|
||||||
|
saler_name,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
) AS current_month # current_month 本月数据
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
||||||
|
use_year,
|
||||||
|
</if>
|
||||||
|
use_month,
|
||||||
|
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
||||||
|
custom_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
||||||
|
std_goods_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
||||||
|
zone_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
||||||
|
sale_type_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
||||||
|
dosage_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
||||||
|
saler_id,
|
||||||
|
</if>
|
||||||
|
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_month_count
|
||||||
|
GROUP BY
|
||||||
|
<trim suffixOverrides=",">
|
||||||
|
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
||||||
|
use_year,
|
||||||
|
</if>
|
||||||
|
use_month,
|
||||||
|
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
||||||
|
custom_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
||||||
|
std_goods_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
||||||
|
zone_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
||||||
|
sale_type_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
||||||
|
dosage_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
||||||
|
saler_id,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
) AS last_month_data # last_month_data 上月数据
|
||||||
|
ON last_month_data.use_month = IF(current_month.use_month = 1, 12, current_month.use_month - 1)
|
||||||
|
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
||||||
|
AND last_month_data.use_year = current_month.use_year - (current_month.use_month = 1)
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
||||||
|
AND current_month.custom_id = last_month_data.custom_id
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
||||||
|
AND current_month.std_goods_name = last_month_data.std_goods_name
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
||||||
|
AND current_month.zone_id = last_month_data.zone_id
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
||||||
|
AND current_month.sale_type_id = last_month_data.sale_type_id
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
||||||
|
AND current_month.dosage_id = last_month_data.dosage_id
|
||||||
|
</if>
|
||||||
|
# if (groupFieldList.contains('salername') || params.containsKey('salername')) {
|
||||||
|
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
||||||
|
AND current_month.saler_id = last_month_data.saler_id
|
||||||
|
</if>
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
||||||
|
use_year,
|
||||||
|
</if>
|
||||||
|
use_month,
|
||||||
|
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
||||||
|
custom_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
||||||
|
std_goods_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
||||||
|
zone_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
||||||
|
sale_type_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
||||||
|
dosage_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
||||||
|
saler_id,
|
||||||
|
</if>
|
||||||
|
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_month_count
|
||||||
|
<where>
|
||||||
|
<if test="saAggParam.useYear != null and saAggParam.useYear != ''"> and use_year = #{saAggParam.useYear}</if>
|
||||||
|
<if test="saAggParam.useMonth != null "> and use_month = #{saAggParam.useMonth}</if>
|
||||||
|
<if test="saAggParam.zoneName != null and zoneName != ''"> and zone_name in
|
||||||
|
<foreach collection="saAggParam.zoneName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.saleTypeName != null and saAggParam.saleTypeName != ''"> and sale_type_name in
|
||||||
|
<foreach collection="saAggParam.saleTypeName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.customName != null and saAggParam.customName != ''"> and custom_name in
|
||||||
|
<foreach collection="saAggParam.customName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.dosageName != null and saAggParam.dosageName != ''"> and dosage_name in
|
||||||
|
<foreach collection="saAggParam.dosageName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.goodsName != null and saAggParam.goodsName != ''"> and goods_name in
|
||||||
|
<foreach collection="saAggParam.goodsName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.provinceName != null and saAggParam.provinceName != ''"> and province_name in
|
||||||
|
<foreach collection="saAggParam.provinceName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.salerName != null and saAggParam.salerName != ''"> and saler_name in
|
||||||
|
<foreach collection="saAggParam.salerName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="saAggParam.stdGoodsName != null and saAggParam.stdGoodsName != ''"> and std_goods_name in
|
||||||
|
<foreach collection="saAggParam.stdGoodsName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY
|
||||||
|
<trim suffixOverrides=",">
|
||||||
|
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
||||||
|
use_year,
|
||||||
|
</if>
|
||||||
|
use_month,
|
||||||
|
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
||||||
|
custom_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
||||||
|
std_goods_name,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
||||||
|
zone_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
||||||
|
sale_type_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
||||||
|
dosage_id,
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
||||||
|
saler_id,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
) yoy_month ON
|
||||||
|
<trim prefixOverrides="and">
|
||||||
|
|
||||||
|
<if test="groupFieldList.contains('useyear') || params.containsKey('useyear')">
|
||||||
|
and yoy_month.use_year = current_month.use_year - 1 # 同比月数据
|
||||||
|
</if>
|
||||||
|
and yoy_month.use_month = current_month.use_month
|
||||||
|
<if test="groupFieldList.contains('customname') || params.containsKey('customname')"># 客户名称
|
||||||
|
AND yoy_month.custom_id = current_month.custom_id
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')"># 标准品名
|
||||||
|
AND yoy_month.std_goods_name = current_month.std_goods_name
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('zonename') || params.containsKey('zonename')">#业务区域
|
||||||
|
AND yoy_month.zone_id = current_month.zone_id
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('saletypename') || params.containsKey('saletypename')">#销售类型
|
||||||
|
AND yoy_month.sale_type_id = current_month.sale_type_id
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('dosagename') || params.containsKey('dosagename')">#剂型
|
||||||
|
AND yoy_month.dosage_id = current_month.dosage_id
|
||||||
|
</if>
|
||||||
|
<if test="groupFieldList.contains('salername') || params.containsKey('salername')">#业务员
|
||||||
|
AND yoy_month.saler_id = current_month.saler_id
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
use_year,
|
||||||
|
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
|
||||||
|
) total_month_data ON total_month_data.use_year = current_month.use_year
|
||||||
|
<where>
|
||||||
|
<if test="saAggParam.useYear != null and saAggParam.useYear != ''"> and current_month.use_year = #{saAggParam.useYear}</if>
|
||||||
|
<if test="saAggParam.useMonth != null "> and current_month.use_month = #{saAggParam.useMonth}</if>
|
||||||
|
<if test="saAggParam.zoneName != null and saAggParam.zoneName != ''"> and current_month.zone_name in
|
||||||
|
<foreach collection="saAggParam.zoneName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.saleTypeName != null and saAggParam.saleTypeName != ''"> and current_month.sale_type_name in
|
||||||
|
<foreach collection="saAggParam.saleTypeName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.customName != null and saAggParam.customName != ''"> and current_month.custom_name in
|
||||||
|
<foreach collection="saAggParam.customName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.dosageName != null and saAggParam.dosageName != ''"> and current_month.dosage_name in
|
||||||
|
<foreach collection="saAggParam.dosageName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.goodsName != null and saAggParam.goodsName != ''"> and current_month.goods_name in
|
||||||
|
<foreach collection="saAggParam.goodsName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.provinceName != null and saAggParam.provinceName != ''"> and current_month.province_name in
|
||||||
|
<foreach collection="saAggParam.provinceName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="saAggParam.salerName != null and saAggParam.salerName != ''"> and current_month.saler_name in
|
||||||
|
<foreach collection="saAggParam.salerName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="saAggParam.stdGoodsName != null and saAggParam.stdGoodsName != ''"> and current_month.std_goods_name in
|
||||||
|
<foreach collection="saAggParam.stdGoodsName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user