新增 综合销售表_疗效分类 报表, 综合销售表_销售类型 报表, 综合销售表_剂型 报表
This commit is contained in:
@@ -0,0 +1,83 @@
|
|||||||
|
|
||||||
|
package com.lideeyunji.core.framework.enhance.example.report.xtsy;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
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.plugin.ReportAroundAdvicePlugin;
|
||||||
|
import com.lideeyunji.core.framework.entity.NewGrBiSaAggYearCount;
|
||||||
|
import com.lideeyunji.core.framework.service.INewGrBiSaAggYearCountService;
|
||||||
|
import com.lideeyunji.tool.framework.yunji.model.ResultDataModel;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报表-综合销售表_剂型-插件
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component("zhxsqkPluginJx")
|
||||||
|
public class zhxsqkPluginJx implements ReportAroundAdvicePlugin {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
INewGrBiSaAggYearCountService newGrBiSaAggYearCountService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultDataModel executeAround(EnhanceReportContext enhanceContext) {
|
||||||
|
log.info("进入=======>zhxsqkPluginJx=======>execute");
|
||||||
|
List<String> groupFieldList = Arrays.asList("useYear","dosageName");
|
||||||
|
return zhxsqkFun(enhanceContext, groupFieldList, newGrBiSaAggYearCountService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
static ResultDataModel zhxsqkFun(EnhanceReportContext enhanceContext, List<String> groupFieldList, INewGrBiSaAggYearCountService newGrBiSaAggYearCountService) {
|
||||||
|
Map<String, Object> params = enhanceContext.getParam().getParams();
|
||||||
|
Page<Object> page = PageHelper.startPage(Integer.parseInt(params.get("pageNo").toString()), Integer.parseInt(params.get("pageSize").toString()));
|
||||||
|
if(params.containsKey("column")){
|
||||||
|
String orderBy = "";
|
||||||
|
if ("thisYearSaQty".equals(params.get("column"))) {
|
||||||
|
orderBy = "this_year_sa_qty " + params.get("order").toString();
|
||||||
|
}
|
||||||
|
if ("saqty_yoy".equals(params.get("column"))) {
|
||||||
|
orderBy = "CAST(TRIM(REGEXP_SUBSTR(saqty_yoy, '-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)')) AS DECIMAL(10,2)) " + params.get("order").toString();
|
||||||
|
}
|
||||||
|
if ("thisYearSaMoney".equals(params.get("column"))) {
|
||||||
|
orderBy = "this_year_sa_money " + params.get("order").toString();
|
||||||
|
}
|
||||||
|
if ("samoney_yoy".equals(params.get("column"))) {
|
||||||
|
orderBy = "CAST(TRIM(REGEXP_SUBSTR(samoney_yoy, '-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)')) AS DECIMAL(10,2)) " + params.get("order").toString();
|
||||||
|
}
|
||||||
|
if ("thisYearProfit".equals(params.get("column"))) {
|
||||||
|
orderBy = "this_year_profit " + params.get("order").toString();
|
||||||
|
}
|
||||||
|
if ("profit_yoy".equals(params.get("column"))) {
|
||||||
|
orderBy = "CAST(TRIM(REGEXP_SUBSTR(profit_yoy, '-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)')) AS DECIMAL(10,2)) " + params.get("order").toString();
|
||||||
|
}
|
||||||
|
if ("thisYearCost".equals(params.get("column"))) {
|
||||||
|
orderBy = "this_year_cost " + params.get("order").toString();
|
||||||
|
}
|
||||||
|
if ("thisYearSaMoneyShare".equals(params.get("column"))) {
|
||||||
|
orderBy = "this_year_sa_money_share " + params.get("order").toString();
|
||||||
|
}
|
||||||
|
if ("thisprofitshare".equals(params.get("column"))) {
|
||||||
|
orderBy = "thisprofitshare " + params.get("order").toString();
|
||||||
|
}
|
||||||
|
if ("thisYearSaMoneyGrowth".equals(params.get("column"))) {
|
||||||
|
orderBy = "CAST(TRIM(REGEXP_SUBSTR(this_year_sa_money_growth, '-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)')) AS DECIMAL(10,2)) " + params.get("order").toString();
|
||||||
|
}
|
||||||
|
page.setUnsafeOrderBy(orderBy);
|
||||||
|
}
|
||||||
|
List<NewGrBiSaAggYearCount> newGrBiSaAggList = newGrBiSaAggYearCountService.selectNewGrBiSaAggGroupYearList(params, groupFieldList);
|
||||||
|
PageInfo<NewGrBiSaAggYearCount> pageInfo = new PageInfo<>(newGrBiSaAggList);
|
||||||
|
List<Map<String, Object>> list = newGrBiSaAggList.stream().map(BeanUtil::beanToMap).collect(Collectors.toList());
|
||||||
|
return ResultDataModel.fomat(pageInfo.getTotal(),list);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
package com.lideeyunji.core.framework.enhance.example.report.xtsy;
|
||||||
|
|
||||||
|
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.service.INewGrBiSaAggYearCountService;
|
||||||
|
import com.lideeyunji.tool.framework.yunji.model.ResultDataModel;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.lideeyunji.core.framework.enhance.example.report.xtsy.zhxsqkPluginJx.zhxsqkFun;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报表-综合销售表_剂型-插件
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component("zhxsqkPluginLxfl")
|
||||||
|
public class zhxsqkPluginLxfl implements ReportAroundAdvicePlugin {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
INewGrBiSaAggYearCountService newGrBiSaAggYearCountService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultDataModel executeAround(EnhanceReportContext enhanceContext) {
|
||||||
|
log.info("进入=======>zhxsqkPluginLxfl=======>execute");
|
||||||
|
List<String> groupFieldList = Arrays.asList("useYear","effectName");
|
||||||
|
return zhxsqkFun(enhanceContext, groupFieldList, newGrBiSaAggYearCountService);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
package com.lideeyunji.core.framework.enhance.example.report.xtsy;
|
||||||
|
|
||||||
|
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.service.INewGrBiSaAggYearCountService;
|
||||||
|
import com.lideeyunji.tool.framework.yunji.model.ResultDataModel;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.lideeyunji.core.framework.enhance.example.report.xtsy.zhxsqkPluginJx.zhxsqkFun;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报表-综合销售表_剂型-插件
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component("zhxsqkPluginXslx")
|
||||||
|
public class zhxsqkPluginXslx implements ReportAroundAdvicePlugin {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
INewGrBiSaAggYearCountService newGrBiSaAggYearCountService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultDataModel executeAround(EnhanceReportContext enhanceContext) {
|
||||||
|
log.info("进入=======>zhxsqkPluginXslx=======>execute");
|
||||||
|
List<String> groupFieldList = Arrays.asList("useYear","saleTypeName");
|
||||||
|
return zhxsqkFun(enhanceContext, groupFieldList, newGrBiSaAggYearCountService);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,6 +63,11 @@ public class NewGrBiSaAgg implements Serializable
|
|||||||
@TableField(value = "dosage_name")
|
@TableField(value = "dosage_name")
|
||||||
private String dosageName;
|
private String dosageName;
|
||||||
|
|
||||||
|
@TableField(value = "effect_id")
|
||||||
|
private Integer effectId;
|
||||||
|
|
||||||
|
@TableField(value = "effect_name")
|
||||||
|
private String effectName;
|
||||||
|
|
||||||
@TableField(value = "goods_id")
|
@TableField(value = "goods_id")
|
||||||
private Long goodsId;
|
private Long goodsId;
|
||||||
|
|||||||
@@ -76,10 +76,15 @@ public class NewGrBiSaAggMonthCount implements Serializable
|
|||||||
@TableField(value = "dosage_name")
|
@TableField(value = "dosage_name")
|
||||||
private String dosageName;
|
private String dosageName;
|
||||||
|
|
||||||
|
@TableField(value = "effect_id")
|
||||||
|
private Integer effectId;
|
||||||
|
|
||||||
|
@TableField(value = "effect_name")
|
||||||
|
private String effectName;
|
||||||
|
|
||||||
@TableField(value = "std_goods_name")
|
@TableField(value = "std_goods_name")
|
||||||
private String stdGoodsName;
|
private String stdGoodsName;
|
||||||
|
|
||||||
|
|
||||||
@TableField(value = "province_id")
|
@TableField(value = "province_id")
|
||||||
private String provinceId;
|
private String provinceId;
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ public class NewGrBiSaAggYearCount implements Serializable
|
|||||||
@TableField(value = "dosage_name")
|
@TableField(value = "dosage_name")
|
||||||
private String dosageName;
|
private String dosageName;
|
||||||
|
|
||||||
|
@TableField(value = "effect_id")
|
||||||
|
private Integer effectId;
|
||||||
|
|
||||||
|
@TableField(value = "effect_name")
|
||||||
|
private String effectName;
|
||||||
|
|
||||||
@TableField(value = "std_goods_name")
|
@TableField(value = "std_goods_name")
|
||||||
private String stdGoodsName;
|
private String stdGoodsName;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class SaAggParam {
|
|||||||
private List<String> customName;
|
private List<String> customName;
|
||||||
private List<String> zoneName;
|
private List<String> zoneName;
|
||||||
private List<String> saleTypeName;
|
private List<String> saleTypeName;
|
||||||
|
private List<String> effectName;
|
||||||
private List<String> salerName;
|
private List<String> salerName;
|
||||||
private List<String> dosageName;
|
private List<String> dosageName;
|
||||||
private List<String> stdGoodsName;
|
private List<String> stdGoodsName;
|
||||||
|
|||||||
@@ -1,31 +1,26 @@
|
|||||||
package com.lideeyunji.core.framework.service.impl;
|
package com.lideeyunji.core.framework.service.impl;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
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.NewGrBiSaAgg;
|
||||||
import com.lideeyunji.core.framework.entity.NewGrBiSaAggMonthCount;
|
import com.lideeyunji.core.framework.mapper.NewGrBiSaAggMapper;
|
||||||
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.INewGrBiSaAggService;
|
||||||
import com.lideeyunji.core.framework.service.INewGrBiSaAggYearCountService;
|
import com.lideeyunji.core.framework.service.INewGrBiSaAggYearCountService;
|
||||||
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
|
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;
|
||||||
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;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 综合销售情况明细Service业务层处理
|
* 综合销售情况明细Service业务层处理
|
||||||
@@ -178,8 +173,11 @@ public class NewGrBiSaAggServiceImpl extends ServiceImpl<NewGrBiSaAggMapper, New
|
|||||||
if (params.containsKey("zoneName")) {
|
if (params.containsKey("zoneName")) {
|
||||||
saAggParam.setZoneName(Arrays.asList(params.get("zoneName").toString().split( ",")));
|
saAggParam.setZoneName(Arrays.asList(params.get("zoneName").toString().split( ",")));
|
||||||
}
|
}
|
||||||
if (params.containsKey("saletypeName")) {
|
if (params.containsKey("saleTypeName")) {
|
||||||
saAggParam.setSaleTypeName(Arrays.asList(params.get("saletypeName").toString().split( ",")));
|
saAggParam.setSaleTypeName(Arrays.asList(params.get("saleTypeName").toString().split( ",")));
|
||||||
|
}
|
||||||
|
if (params.containsKey("effectName")) {
|
||||||
|
saAggParam.setEffectName(Arrays.asList(params.get("effectName").toString().split( ",")));
|
||||||
}
|
}
|
||||||
if (params.containsKey("dosageName")) {
|
if (params.containsKey("dosageName")) {
|
||||||
saAggParam.setDosageName(Arrays.asList(params.get("dosageName").toString().split( ",")));
|
saAggParam.setDosageName(Arrays.asList(params.get("dosageName").toString().split( ",")));
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="customName" column="custom_name" />
|
<result property="customName" column="custom_name" />
|
||||||
<result property="dosageId" column="dosage_id" />
|
<result property="dosageId" column="dosage_id" />
|
||||||
<result property="dosageName" column="dosage_name" />
|
<result property="dosageName" column="dosage_name" />
|
||||||
|
<result property="effectId" column="effect_id" />
|
||||||
|
<result property="effectName" column="effect_name" />
|
||||||
<result property="goodsId" column="goods_id" />
|
<result property="goodsId" column="goods_id" />
|
||||||
<result property="goodsName" column="goods_name" />
|
<result property="goodsName" column="goods_name" />
|
||||||
<result property="provinceId" column="province_id" />
|
<result property="provinceId" column="province_id" />
|
||||||
@@ -41,6 +43,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="customName" column="custom_name" />
|
<result property="customName" column="custom_name" />
|
||||||
<result property="dosageId" column="dosage_id" />
|
<result property="dosageId" column="dosage_id" />
|
||||||
<result property="dosageName" column="dosage_name" />
|
<result property="dosageName" column="dosage_name" />
|
||||||
|
<result property="effectId" column="effect_id" />
|
||||||
|
<result property="effectName" column="effect_name" />
|
||||||
<result property="stdGoodsName" column="std_goods_name" />
|
<result property="stdGoodsName" column="std_goods_name" />
|
||||||
<result property="stdGoodsName" column="std_goods_name" />
|
<result property="stdGoodsName" column="std_goods_name" />
|
||||||
<result property="provinceId" column="province_id" />
|
<result property="provinceId" column="province_id" />
|
||||||
@@ -86,6 +90,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="customName" column="custom_name" />
|
<result property="customName" column="custom_name" />
|
||||||
<result property="dosageId" column="dosage_id" />
|
<result property="dosageId" column="dosage_id" />
|
||||||
<result property="dosageName" column="dosage_name" />
|
<result property="dosageName" column="dosage_name" />
|
||||||
|
<result property="effectId" column="effect_id" />
|
||||||
|
<result property="effectName" column="effect_name" />
|
||||||
<result property="stdGoodsName" column="std_goods_name" />
|
<result property="stdGoodsName" column="std_goods_name" />
|
||||||
<result property="goodsName" column="goods_name" />
|
<result property="goodsName" column="goods_name" />
|
||||||
<result property="goodsId" column="goods_id" />
|
<result property="goodsId" column="goods_id" />
|
||||||
@@ -121,74 +127,69 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectNewGrBiSaAggVo">
|
<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
|
select id, use_year, use_month, zone_id, zone_name, sale_type_id, sale_type_name, custom_id, custom_name, dosage_id, dosage_name, effect_id, effect_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>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
<select id="generateSalesReport" resultType="com.lideeyunji.core.framework.entity.NewGrBiSaAgg">
|
<select id="generateSalesReport" resultType="com.lideeyunji.core.framework.entity.NewGrBiSaAgg">
|
||||||
select a.USEYEAR as use_year,
|
SELECT
|
||||||
a.USEMONTH as use_month,
|
a.USEYEAR AS use_year,
|
||||||
goods.goodsid as goods_id,
|
a.USEMONTH AS use_month,
|
||||||
goods.GOODSNAME as goods_name,
|
goods.GOODSID AS goods_id,
|
||||||
goods.STDGOODSNAME as std_goods_name,
|
goods.GOODSNAME AS goods_name,
|
||||||
sales.SALEZONEID as zone_id,
|
a.EFFECTID AS effect_id,
|
||||||
sales.SALEZONENAME as zone_name,
|
a.EFFECTNAME AS effect_name,
|
||||||
province.PROVINCEID as province_id,
|
goods.STDGOODSNAME AS std_goods_name,
|
||||||
province.PROVINCENAME as province_name,
|
sales.SALEZONEID AS zone_id,
|
||||||
salestype.SALETYPEID as sale_type_id,
|
sales.SALEZONENAME AS zone_name,
|
||||||
salestype.SALETYPENAME as sale_type_name,
|
province.PROVINCEID AS province_id,
|
||||||
dosage.DOSAGEID as dosage_id,
|
province.PROVINCENAME AS province_name,
|
||||||
dosage.DOSAGENAME as dosage_name,
|
salestype.SALETYPEID AS sale_type_id,
|
||||||
custom.CUSTOMID as custom_id,
|
salestype.SALETYPENAME AS sale_type_name,
|
||||||
custom.CUSTOMNAME as custom_name,
|
dosage.DOSAGEID AS dosage_id,
|
||||||
saler.SALERID as saler_id,
|
dosage.DOSAGENAME AS dosage_name,
|
||||||
saler.SALERNAME as saler_name,
|
custom.CUSTOMID AS custom_id,
|
||||||
a.`本月销量` as this_month_sa_qty,
|
custom.CUSTOMNAME AS custom_name,
|
||||||
a.`含税销售额` as this_month_sa_money,
|
saler.SALERID AS saler_id,
|
||||||
a.`销售成本` as this_month_cost,
|
saler.SALERNAME AS saler_name,
|
||||||
a.`毛利额` as this_month_profit
|
sum(SAQTY) AS this_month_sa_qty,
|
||||||
from erp_bi_data.GR_BI_PUB_GOODS as goods
|
round(sum(SAMONEYTX), 2) AS this_month_sa_money,
|
||||||
inner join erp_bi_data.GR_BI_PUB_SALEZONE as sales
|
round(sum(COST), 2) AS this_month_cost,
|
||||||
inner join erp_bi_data.GR_BI_PUB_PROVINCE as province
|
round(sum(PROFIT), 2) AS this_month_profit
|
||||||
inner join erp_bi_data.GR_BI_PUB_SALETYPE as salestype
|
FROM
|
||||||
inner join erp_bi_data.GR_BI_PUB_DOSAGE as dosage
|
GR_BI_SA_SETDTL AS a
|
||||||
inner join erp_bi_data.GR_BI_PUB_CUSTOM as custom
|
LEFT JOIN erp_bi_data.GR_BI_PUB_GOODS AS goods ON a.goodsid = goods.goodsid
|
||||||
INNER join erp_bi_data.GR_BI_PUB_SALER as saler
|
LEFT JOIN erp_bi_data.GR_BI_PUB_SALEZONE AS sales ON a.SALEZONEID = sales.SALEZONEID
|
||||||
left join
|
LEFT JOIN erp_bi_data.GR_BI_PUB_PROVINCE AS province ON a.PROVINCEID = province.PROVINCEID
|
||||||
(SELECT USEYEAR,
|
LEFT JOIN erp_bi_data.GR_BI_PUB_SALETYPE AS salestype ON salestype.SALETYPEID = a.SALETYPE
|
||||||
USEMONTH,
|
LEFT JOIN erp_bi_data.GR_BI_PUB_DOSAGE AS dosage ON dosage.DOSAGEID = a.DOSAGEID
|
||||||
SALEZONEID,
|
LEFT JOIN erp_bi_data.GR_BI_PUB_CUSTOM AS custom ON custom.CUSTOMID = a.CUSTOMID
|
||||||
SALEZONENAME,
|
LEFT JOIN erp_bi_data.GR_BI_PUB_SALER AS saler ON saler.SALERID = a.SALERID
|
||||||
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>
|
<where>
|
||||||
a.USEYEAR is not NULL
|
USESTATUS = 2
|
||||||
|
AND a.USEYEAR IS NOT NULL
|
||||||
and (a.USEYEAR * 100 + a.USEMONTH) BETWEEN #{pastYearMonth} AND #{currentYearMonth}
|
and (a.USEYEAR * 100 + a.USEMONTH) BETWEEN #{pastYearMonth} AND #{currentYearMonth}
|
||||||
</where>
|
</where>
|
||||||
|
GROUP BY
|
||||||
|
a.USEYEAR,
|
||||||
|
a.USEMONTH,
|
||||||
|
goods.GOODSID,
|
||||||
|
goods.GOODSNAME,
|
||||||
|
a.EFFECTID,
|
||||||
|
a.EFFECTNAME,
|
||||||
|
goods.STDGOODSNAME,
|
||||||
|
sales.SALEZONEID,
|
||||||
|
sales.SALEZONENAME,
|
||||||
|
province.PROVINCEID,
|
||||||
|
province.PROVINCENAME,
|
||||||
|
salestype.SALETYPEID,
|
||||||
|
salestype.SALETYPENAME,
|
||||||
|
dosage.DOSAGEID,
|
||||||
|
dosage.DOSAGENAME,
|
||||||
|
custom.CUSTOMID,
|
||||||
|
custom.CUSTOMNAME,
|
||||||
|
saler.SALERID,
|
||||||
|
saler.SALERNAME
|
||||||
order by a.USEYEAR, a.USEMONTH
|
order by a.USEYEAR, a.USEMONTH
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -217,6 +218,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
custom_name,
|
custom_name,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
dosage_name,
|
dosage_name,
|
||||||
|
effect_id,
|
||||||
|
effect_name,
|
||||||
std_goods_name,
|
std_goods_name,
|
||||||
province_id,
|
province_id,
|
||||||
province_name,
|
province_name,
|
||||||
@@ -237,6 +240,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
custom_name,
|
custom_name,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
dosage_name,
|
dosage_name,
|
||||||
|
effect_id,
|
||||||
|
effect_name,
|
||||||
std_goods_name,
|
std_goods_name,
|
||||||
province_id,
|
province_id,
|
||||||
province_name,
|
province_name,
|
||||||
@@ -260,6 +265,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
custom_name,
|
custom_name,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
dosage_name,
|
dosage_name,
|
||||||
|
effect_id,
|
||||||
|
effect_name,
|
||||||
std_goods_name,
|
std_goods_name,
|
||||||
province_id,
|
province_id,
|
||||||
province_name,
|
province_name,
|
||||||
@@ -279,6 +286,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
custom_name,
|
custom_name,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
dosage_name,
|
dosage_name,
|
||||||
|
effect_id,
|
||||||
|
effect_name,
|
||||||
std_goods_name,
|
std_goods_name,
|
||||||
province_id,
|
province_id,
|
||||||
province_name,
|
province_name,
|
||||||
@@ -298,6 +307,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
custom_name,
|
custom_name,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
dosage_name,
|
dosage_name,
|
||||||
|
effect_id,
|
||||||
|
effect_name,
|
||||||
std_goods_name,
|
std_goods_name,
|
||||||
province_id,
|
province_id,
|
||||||
province_name,
|
province_name,
|
||||||
@@ -318,6 +329,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
sale_type_name,
|
sale_type_name,
|
||||||
custom_id,
|
custom_id,
|
||||||
custom_name,
|
custom_name,
|
||||||
|
effect_id,
|
||||||
|
effect_name,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
dosage_name,
|
dosage_name,
|
||||||
std_goods_name,
|
std_goods_name,
|
||||||
@@ -378,6 +391,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
province_id,
|
province_id,
|
||||||
sale_type_id,
|
sale_type_id,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
|
effect_id,
|
||||||
custom_id,
|
custom_id,
|
||||||
saler_id,
|
saler_id,
|
||||||
SUM( this_month_sa_qty ) AS yoy_month_sa_qty, -- 同比月销量
|
SUM( this_month_sa_qty ) AS yoy_month_sa_qty, -- 同比月销量
|
||||||
@@ -394,6 +408,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
province_id,
|
province_id,
|
||||||
sale_type_id,
|
sale_type_id,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
|
effect_id,
|
||||||
custom_id,
|
custom_id,
|
||||||
saler_id
|
saler_id
|
||||||
) b ON b.use_year = a.use_year-1
|
) b ON b.use_year = a.use_year-1
|
||||||
@@ -403,6 +418,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
AND b.province_id = a.province_id
|
AND b.province_id = a.province_id
|
||||||
AND b.sale_type_id = a.sale_type_id
|
AND b.sale_type_id = a.sale_type_id
|
||||||
AND b.dosage_id = a.dosage_id
|
AND b.dosage_id = a.dosage_id
|
||||||
|
AND b.effect_id = a.effect_id
|
||||||
AND b.custom_id = a.custom_id
|
AND b.custom_id = a.custom_id
|
||||||
AND b.saler_id = a.saler_id
|
AND b.saler_id = a.saler_id
|
||||||
SET a.yoy_month_sa_qty = COALESCE ( b.yoy_month_sa_qty, 0 ),
|
SET a.yoy_month_sa_qty = COALESCE ( b.yoy_month_sa_qty, 0 ),
|
||||||
@@ -424,6 +440,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
province_id,
|
province_id,
|
||||||
sale_type_id,
|
sale_type_id,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
|
effect_id,
|
||||||
custom_id,
|
custom_id,
|
||||||
saler_id,
|
saler_id,
|
||||||
-- 计算上个月的年月
|
-- 计算上个月的年月
|
||||||
@@ -443,6 +460,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
province_id,
|
province_id,
|
||||||
sale_type_id,
|
sale_type_id,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
|
effect_id,
|
||||||
custom_id,
|
custom_id,
|
||||||
saler_id
|
saler_id
|
||||||
) AS last_month_data
|
) AS last_month_data
|
||||||
@@ -451,6 +469,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
AND current_month.province_id = last_month_data.province_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.sale_type_id = last_month_data.sale_type_id
|
||||||
AND current_month.dosage_id = last_month_data.dosage_id
|
AND current_month.dosage_id = last_month_data.dosage_id
|
||||||
|
AND current_month.effect_id = last_month_data.effect_id
|
||||||
AND current_month.custom_id = last_month_data.custom_id
|
AND current_month.custom_id = last_month_data.custom_id
|
||||||
AND current_month.saler_id = last_month_data.saler_id
|
AND current_month.saler_id = last_month_data.saler_id
|
||||||
AND last_month_data.use_year = current_month.use_year - (current_month.use_month = 1)
|
AND last_month_data.use_year = current_month.use_year - (current_month.use_month = 1)
|
||||||
@@ -471,6 +490,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
province_id,
|
province_id,
|
||||||
sale_type_id,
|
sale_type_id,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
|
effect_id,
|
||||||
custom_id,
|
custom_id,
|
||||||
saler_id,
|
saler_id,
|
||||||
SUM( this_month_sa_qty ) AS last_year_sa_qty,
|
SUM( this_month_sa_qty ) AS last_year_sa_qty,
|
||||||
@@ -486,6 +506,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
province_id,
|
province_id,
|
||||||
sale_type_id,
|
sale_type_id,
|
||||||
dosage_id,
|
dosage_id,
|
||||||
|
effect_id,
|
||||||
custom_id,
|
custom_id,
|
||||||
saler_id
|
saler_id
|
||||||
) b ON b.use_year = a.use_year-1
|
) b ON b.use_year = a.use_year-1
|
||||||
@@ -494,6 +515,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
AND b.province_id = a.province_id
|
AND b.province_id = a.province_id
|
||||||
AND b.sale_type_id = a.sale_type_id
|
AND b.sale_type_id = a.sale_type_id
|
||||||
AND b.dosage_id = a.dosage_id
|
AND b.dosage_id = a.dosage_id
|
||||||
|
AND b.effect_id = a.effect_id
|
||||||
AND b.custom_id = a.custom_id
|
AND b.custom_id = a.custom_id
|
||||||
AND b.saler_id = a.saler_id
|
AND b.saler_id = a.saler_id
|
||||||
SET a.last_year_sa_qty = COALESCE ( b.last_year_sa_qty, 0 ),
|
SET a.last_year_sa_qty = COALESCE ( b.last_year_sa_qty, 0 ),
|
||||||
@@ -617,6 +639,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
tbl_lgbsa.custom_name,
|
tbl_lgbsa.custom_name,
|
||||||
tbl_lgbsa.dosage_id,
|
tbl_lgbsa.dosage_id,
|
||||||
tbl_lgbsa.dosage_name,
|
tbl_lgbsa.dosage_name,
|
||||||
|
tbl_lgbsa.effect_id,
|
||||||
|
tbl_lgbsa.effect_name,
|
||||||
tbl_lgbsa.goods_id,
|
tbl_lgbsa.goods_id,
|
||||||
tbl_lgbsa.goods_name,
|
tbl_lgbsa.goods_name,
|
||||||
tbl_lgbsa.std_goods_name,
|
tbl_lgbsa.std_goods_name,
|
||||||
|
|||||||
@@ -269,6 +269,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
current_year_data.dosage_id,
|
current_year_data.dosage_id,
|
||||||
current_year_data.dosage_name,
|
current_year_data.dosage_name,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="groupFieldList.contains('effectName') || params.containsKey('effectName')">
|
||||||
|
current_year_data.effect_id,
|
||||||
|
current_year_data.effect_name,
|
||||||
|
</if>
|
||||||
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')">
|
<if test="groupFieldList.contains('stdGoodsName') || params.containsKey('stdGoodsName')">
|
||||||
current_year_data.std_goods_name,
|
current_year_data.std_goods_name,
|
||||||
</if>
|
</if>
|
||||||
@@ -350,6 +354,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
dosage_id,
|
dosage_id,
|
||||||
dosage_name,
|
dosage_name,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="groupFieldList.contains('effectName') || params.containsKey('effectName')">
|
||||||
|
effect_id,
|
||||||
|
effect_name,
|
||||||
|
</if>
|
||||||
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
||||||
saler_id,
|
saler_id,
|
||||||
saler_name,
|
saler_name,
|
||||||
@@ -362,8 +370,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
ifnull(sum(this_year_profit), 0) AS this_year_profit
|
ifnull(sum(this_year_profit), 0) AS this_year_profit
|
||||||
FROM new_gr_bi_sa_agg_year_count
|
FROM new_gr_bi_sa_agg_year_count
|
||||||
<where>
|
<where>
|
||||||
<!--<if test="saAggParam.useYear != null and saAggParam.useYear != ''"> and use_year = #{saAggParam.useYear}</if>-->
|
<if test="saAggParam.useYear != null and saAggParam.useYear != ''"> and use_year = #{saAggParam.useYear}</if>
|
||||||
|
|
||||||
<if test="saAggParam.useYearStart != null and saAggParam.useYearStart != ''"> and use_year >= #{saAggParam.useYearStart}</if>
|
<if test="saAggParam.useYearStart != null and saAggParam.useYearStart != ''"> and use_year >= #{saAggParam.useYearStart}</if>
|
||||||
<if test="saAggParam.useYearEnd != null and saAggParam.useYearEnd != ''"> and use_year <= #{saAggParam.useYearEnd}</if>
|
<if test="saAggParam.useYearEnd != null and saAggParam.useYearEnd != ''"> and use_year <= #{saAggParam.useYearEnd}</if>
|
||||||
<if test="saAggParam.zoneName != null and saAggParam.zoneName != ''"> and zone_name in
|
<if test="saAggParam.zoneName != null and saAggParam.zoneName != ''"> and zone_name in
|
||||||
@@ -386,6 +393,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
#{name}
|
#{name}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
<if test="saAggParam.effectName != null and saAggParam.effectName != ''"> and effect_name in
|
||||||
|
<foreach collection="saAggParam.effectName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
<if test="saAggParam.goodsName != null and saAggParam.goodsName != ''"> and goods_name in
|
<if test="saAggParam.goodsName != null and saAggParam.goodsName != ''"> and goods_name in
|
||||||
<foreach collection="saAggParam.goodsName" item="name" open="(" separator="," close=")">
|
<foreach collection="saAggParam.goodsName" item="name" open="(" separator="," close=")">
|
||||||
#{name}
|
#{name}
|
||||||
@@ -430,6 +442,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
dosage_id,
|
dosage_id,
|
||||||
dosage_name,
|
dosage_name,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="groupFieldList.contains('effectName') || params.containsKey('effectName')">
|
||||||
|
effect_id,
|
||||||
|
effect_name,
|
||||||
|
</if>
|
||||||
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
||||||
saler_id,
|
saler_id,
|
||||||
saler_name,
|
saler_name,
|
||||||
@@ -453,6 +469,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="groupFieldList.contains('dosageName') || params.containsKey('dosageName')">
|
<if test="groupFieldList.contains('dosageName') || params.containsKey('dosageName')">
|
||||||
dosage_id,
|
dosage_id,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="groupFieldList.contains('effectName') || params.containsKey('effectName')">
|
||||||
|
effect_id,
|
||||||
|
</if>
|
||||||
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
||||||
saler_id,
|
saler_id,
|
||||||
</if>
|
</if>
|
||||||
@@ -484,6 +503,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
#{name}
|
#{name}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
<if test="saAggParam.effectName != null and saAggParam.effectName != ''"> and effect_name in
|
||||||
|
<foreach collection="saAggParam.effectName" item="name" open="(" separator="," close=")">
|
||||||
|
#{name}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
<if test="saAggParam.goodsName != null and saAggParam.goodsName != ''"> and goods_name in
|
<if test="saAggParam.goodsName != null and saAggParam.goodsName != ''"> and goods_name in
|
||||||
<foreach collection="saAggParam.goodsName" item="name" open="(" separator="," close=")">
|
<foreach collection="saAggParam.goodsName" item="name" open="(" separator="," close=")">
|
||||||
#{name}
|
#{name}
|
||||||
@@ -524,6 +548,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="groupFieldList.contains('dosageName') || params.containsKey('dosageName')">
|
<if test="groupFieldList.contains('dosageName') || params.containsKey('dosageName')">
|
||||||
dosage_id,
|
dosage_id,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="groupFieldList.contains('effectName') || params.containsKey('effectName')">
|
||||||
|
effect_id,
|
||||||
|
</if>
|
||||||
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
||||||
saler_id,
|
saler_id,
|
||||||
</if>
|
</if>
|
||||||
@@ -546,6 +573,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="groupFieldList.contains('dosageName') || params.containsKey('dosageName')">
|
<if test="groupFieldList.contains('dosageName') || params.containsKey('dosageName')">
|
||||||
AND current_year_data.dosage_id = last_year_data.dosage_id
|
AND current_year_data.dosage_id = last_year_data.dosage_id
|
||||||
</if>
|
</if>
|
||||||
|
<if test="groupFieldList.contains('effectName') || params.containsKey('effectName')">
|
||||||
|
AND current_year_data.effect_id = last_year_data.effect_id
|
||||||
|
</if>
|
||||||
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
||||||
AND current_year_data.saler_id = last_year_data.saler_id
|
AND current_year_data.saler_id = last_year_data.saler_id
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user