新增定时任务, 综合销售跨度查询,
This commit is contained in:
@@ -0,0 +1,84 @@
|
|||||||
|
package com.lideeyunji.core.framework.config.job;
|
||||||
|
|
||||||
|
import com.lideeyunji.core.framework.entity.GrBiSaSetdtl;
|
||||||
|
import com.lideeyunji.core.framework.mapper.GrBiSaSetdtlMapper;
|
||||||
|
import com.lideeyunji.core.framework.mapper.OracleProcedureMapper;
|
||||||
|
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
|
||||||
|
import com.lideeyunji.tool.framework.quartz.core.handler.JobHandler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oracle 存储过程调用定时任务 ,RP中间库
|
||||||
|
* 用于定时调用 Oracle 存储过程进行数据处理
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component("oracleProcedureUpdateErpDataJob")
|
||||||
|
public class OracleProcedureUpdateErpDataJob implements JobHandler {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OracleProcedureMapper oracleProcedureMapper;
|
||||||
|
@Resource
|
||||||
|
private GrBiSaSetdtlMapper grBiSaSetdtlMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String execute(String param) throws Exception {
|
||||||
|
log.info("========== 开始执行 Oracle 存储过程定时任务 ,ERP中间库,参数:{} ==========", param);
|
||||||
|
|
||||||
|
try {
|
||||||
|
callErpDataCore();
|
||||||
|
log.info("========== Oracle 存储过程定时任务,ERP中间库 执行成功 ==========");
|
||||||
|
return "Oracle 存储过程定时任务,ERP中间库 执行成功";
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("========== Oracle E存储过程定时任务,ERP中间库 执行失败 ==========", e);
|
||||||
|
throw new RuntimeException("Oracle 存储过程,ERP中间库 调用失败:" + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用简单存储过程
|
||||||
|
*/
|
||||||
|
private void callErpDataCore() {
|
||||||
|
log.info("开始调用存储过程...");
|
||||||
|
//获取本地mysql数据库中表中UPDATE_TIME最新的数据
|
||||||
|
GrBiSaSetdtl grBiSaAgg = grBiSaSetdtlMapper.selectLastOne(lideeYunJiBaseConstant.DS_ERP_BI_DATA);
|
||||||
|
int lastUserYear = 2022;
|
||||||
|
int lastUserMonth = 1;
|
||||||
|
if(grBiSaAgg != null){
|
||||||
|
lastUserYear = grBiSaAgg.getUSEYEAR();
|
||||||
|
lastUserMonth = grBiSaAgg.getUSEMONTH();
|
||||||
|
}
|
||||||
|
// 获取当前时间的年和月
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
int currentYear = now.getYear();
|
||||||
|
int currentMonth = now.getMonthValue();
|
||||||
|
|
||||||
|
// 获取上个月前的时间和年月
|
||||||
|
LocalDateTime threeMonthsAgo = now.minusMonths(1);
|
||||||
|
int pastYear = threeMonthsAgo.getYear();
|
||||||
|
int pastMonth = threeMonthsAgo.getMonthValue();
|
||||||
|
|
||||||
|
log.info("最后更新的年月:{}年{}月", lastUserYear, lastUserMonth);
|
||||||
|
log.info("当前:{}年{}月", currentYear, currentMonth);
|
||||||
|
log.info("上个月前:{}年{}月", pastYear, pastMonth);
|
||||||
|
if (lastUserYear < pastYear || (lastUserYear == pastYear && lastUserMonth < pastMonth)) {
|
||||||
|
pastYear = lastUserYear;
|
||||||
|
pastMonth = lastUserMonth;
|
||||||
|
|
||||||
|
}
|
||||||
|
log.info("开始时间:{}年{}月, 结束时间:{}年{}月", pastYear, pastMonth, currentYear, currentMonth);
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("result", new Object()); // 用于接收输出参数
|
||||||
|
|
||||||
|
oracleProcedureMapper.callErpDataCore(lideeYunJiBaseConstant.DS_ORACLE_GRYYBI, pastYear, pastMonth, currentYear, currentMonth);
|
||||||
|
|
||||||
|
// 获取输出参数值
|
||||||
|
Object result = params.get("result");
|
||||||
|
log.info("存储过程执行结果:{}", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -100,11 +100,11 @@ public class NewGrBiSaAggMonthCountController extends BaseController
|
|||||||
if (params.containsKey("provinceName")){
|
if (params.containsKey("provinceName")){
|
||||||
saAggParam.setProvinceName(Arrays.asList(params.get("provinceName").toString().split( ",")));
|
saAggParam.setProvinceName(Arrays.asList(params.get("provinceName").toString().split( ",")));
|
||||||
}
|
}
|
||||||
if (groupField.contains("useMonth")){
|
if (groupField.contains("useYear") && !groupField.contains("useMonth")){
|
||||||
List<NewGrBiSaAggMonthCount> list = newGrBiSaAggMonthCountService.getTotalDetail(saAggParam);
|
List<NewGrBiSaAggYearCount> list = newGrBiSaAggYearCountService.getTotalDetail(saAggParam);
|
||||||
return BaseWebResult.success(list);
|
return BaseWebResult.success(list);
|
||||||
}else{
|
}else{
|
||||||
List<NewGrBiSaAggYearCount> list = newGrBiSaAggYearCountService.getTotalDetail(saAggParam);
|
List<NewGrBiSaAggMonthCount> list = newGrBiSaAggMonthCountService.getTotalDetail(saAggParam);
|
||||||
return BaseWebResult.success(list);
|
return BaseWebResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,16 +44,22 @@ public class zhxsqkPlugin implements ReportAroundAdvicePlugin {
|
|||||||
public ResultDataModel executeAround(EnhanceReportContext enhanceContext) {
|
public ResultDataModel executeAround(EnhanceReportContext enhanceContext) {
|
||||||
log.info("进入=======>zhxsqkPlugin=======>execute");
|
log.info("进入=======>zhxsqkPlugin=======>execute");
|
||||||
Map<String, Object> params = enhanceContext.getParam().getParams();
|
Map<String, Object> params = enhanceContext.getParam().getParams();
|
||||||
|
|
||||||
if (params.containsKey("Group by")) {
|
if (params.containsKey("Group by")) {
|
||||||
|
List<String> groupFieldList = Arrays.asList(params.get("Group by").toString().split(","));
|
||||||
|
if(!groupFieldList.contains("useYearMonthStart") && !params.containsKey("useYearMonthEnd")){
|
||||||
|
throw new lideeYunJiException("年月范围 不能为空!");
|
||||||
|
}
|
||||||
if (params.containsKey("goodsName")) {
|
if (params.containsKey("goodsName")) {
|
||||||
throw new lideeYunJiException("在选择维度时,“货品名称”不能有值!");
|
throw new lideeYunJiException("在选择维度时,“货品名称”不能有值!");
|
||||||
}
|
}
|
||||||
List<String> groupFieldList = Arrays.asList(params.get("Group by").toString().split(","));
|
|
||||||
if(!groupFieldList.contains("useYear") && !params.containsKey("useYear")){
|
|
||||||
throw new lideeYunJiException("维度选中时,“年”维度不能为空!");
|
|
||||||
}
|
|
||||||
Page<Object> page = PageHelper.startPage(Integer.parseInt(params.get("pageNo").toString()), Integer.parseInt(params.get("pageSize").toString()));
|
Page<Object> page = PageHelper.startPage(Integer.parseInt(params.get("pageNo").toString()), Integer.parseInt(params.get("pageSize").toString()));
|
||||||
|
if(!groupFieldList.contains("useMonth") && !groupFieldList.contains("useYear")){
|
||||||
|
setMonthOrderBy(params, page);
|
||||||
|
List<NewGrBiSaAggMonthCount> newGrBiSaAggList = newGrBiSaAggMonthCountService.selectNewGrBiSaAggGroupNoMonthNoYearList(params, groupFieldList);
|
||||||
|
PageInfo<NewGrBiSaAggMonthCount> pageInfo = new PageInfo<>(newGrBiSaAggList);
|
||||||
|
List<Map<String, Object>> list = newGrBiSaAggList.stream().map(BeanUtil::beanToMap).collect(Collectors.toList());
|
||||||
|
return ResultDataModel.fomat(pageInfo.getTotal(),list);
|
||||||
|
}
|
||||||
if(groupFieldList.contains("useMonth") || params.containsKey("useMonth")){
|
if(groupFieldList.contains("useMonth") || params.containsKey("useMonth")){
|
||||||
setMonthOrderBy(params, page);
|
setMonthOrderBy(params, page);
|
||||||
List<NewGrBiSaAggMonthCount> newGrBiSaAggList = newGrBiSaAggMonthCountService.selectNewGrBiSaAggGroupMonthList(params, groupFieldList);
|
List<NewGrBiSaAggMonthCount> newGrBiSaAggList = newGrBiSaAggMonthCountService.selectNewGrBiSaAggGroupMonthList(params, groupFieldList);
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ public class GrBiSaSetdtl implements Serializable {
|
|||||||
private Integer DOSAGEID;
|
private Integer DOSAGEID;
|
||||||
@TableField(value = "DOSAGENAME")
|
@TableField(value = "DOSAGENAME")
|
||||||
private String DOSAGENAME;
|
private String DOSAGENAME;
|
||||||
|
@TableField(value = "EFFECTID")
|
||||||
|
private Integer EFFECTID;
|
||||||
|
@TableField(value = "EFFECTNAME")
|
||||||
|
private String EFFECTNAME;
|
||||||
@TableField(value = "STDGOODSNAME")
|
@TableField(value = "STDGOODSNAME")
|
||||||
private String STDGOODSNAME;
|
private String STDGOODSNAME;
|
||||||
@TableField(value = "GOODSID")
|
@TableField(value = "GOODSID")
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.lideeyunji.core.framework.mapper;
|
package com.lideeyunji.core.framework.mapper;
|
||||||
|
|
||||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.lideeyunji.core.framework.entity.GrBiSaSetdtl;
|
import com.lideeyunji.core.framework.entity.GrBiSaSetdtl;
|
||||||
@@ -26,10 +27,12 @@ public interface GrBiSaSetdtlMapper extends BaseMapper<GrBiSaSetdtl> {
|
|||||||
default List<GrBiSaSetdtl> getByUpdateTime(@Param("dataSourceType") String dataSourceType, String updateTime) {
|
default List<GrBiSaSetdtl> getByUpdateTime(@Param("dataSourceType") String dataSourceType, String updateTime) {
|
||||||
try {
|
try {
|
||||||
// 假设 updateTime 格式为 "yyyy-MM-dd HH:mm:ss"
|
// 假设 updateTime 格式为 "yyyy-MM-dd HH:mm:ss"
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
Date startTime = sdf.parse(updateTime);
|
|
||||||
QueryWrapper<GrBiSaSetdtl> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<GrBiSaSetdtl> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.gt("UPDATE_TIME", startTime);
|
if(updateTime != null){
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Date startTime = sdf.parse(updateTime);
|
||||||
|
queryWrapper.gt("UPDATE_TIME", startTime);
|
||||||
|
}
|
||||||
return this.selectList(queryWrapper);
|
return this.selectList(queryWrapper);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 处理异常
|
// 处理异常
|
||||||
@@ -52,4 +55,11 @@ public interface GrBiSaSetdtlMapper extends BaseMapper<GrBiSaSetdtl> {
|
|||||||
return this.updateById(grBiSaSetdtl);
|
return this.updateById(grBiSaSetdtl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DS(value = "#dataSourceType")
|
||||||
|
default GrBiSaSetdtl selectLastOne(@Param("dataSourceType") String dataSourceType) {
|
||||||
|
LambdaQueryWrapper<GrBiSaSetdtl> queryWrapper = new LambdaQueryWrapper<GrBiSaSetdtl>().orderByDesc(GrBiSaSetdtl::getUSEYEAR, GrBiSaSetdtl::getUSEMONTH).last("LIMIT 1");
|
||||||
|
return this.selectOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,4 +80,14 @@ public interface NewGrBiSaAggMonthCountMapper extends BaseMapper<NewGrBiSaAggMon
|
|||||||
@DS(value = "#dataSourceType")
|
@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);
|
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupMonthList(@Param("dataSourceType") String dataSourceType, @Param("saAggParam") SaAggParam saAggParam, @Param("params") Map<String, Object> params, @Param("groupFieldList")List<String> groupFieldList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询综合销售情况明细列表 -月度
|
||||||
|
*
|
||||||
|
* @param saAggParam 综合销售情况明细参数
|
||||||
|
* @return 综合销售情况明细集合
|
||||||
|
*/
|
||||||
|
@DataPermission(enable = false)
|
||||||
|
@DS(value = "#dataSourceType")
|
||||||
|
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupNoMonthNoYearList(@Param("dataSourceType") String dataSourceType, @Param("saAggParam") SaAggParam saAggParam, @Param("params") Map<String, Object> params, @Param("groupFieldList")List<String> groupFieldList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,4 +34,14 @@ public interface OracleProcedureMapper {
|
|||||||
@DataPermission(enable = false)
|
@DataPermission(enable = false)
|
||||||
void callUpdateCore(@Param("dataSourceType") String dataSourceType);
|
void callUpdateCore(@Param("dataSourceType") String dataSourceType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用 Oracle 存储过程 - 示例
|
||||||
|
*
|
||||||
|
* @param dataSourceType 存储过程参数
|
||||||
|
* @return 执行结果
|
||||||
|
*/
|
||||||
|
@DS(value = "#dataSourceType")
|
||||||
|
@DataPermission(enable = false)
|
||||||
|
void callErpDataCore(@Param("dataSourceType") String dataSourceType, @Param("pastYear") Integer pastYear, @Param("pastMonth") Integer pastMonth,@Param("currentYear") Integer currentYear, @Param("currentMonth") Integer currentMonth);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,4 +68,6 @@ public interface INewGrBiSaAggMonthCountService
|
|||||||
|
|
||||||
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupMonthList(Map<String, Object> params, List<String> groupFieldList);
|
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupMonthList(Map<String, Object> params, List<String> groupFieldList);
|
||||||
|
|
||||||
|
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupNoMonthNoYearList(Map<String, Object> params, List<String> groupFieldList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class GrBiSaSetdtlServiceImpl extends ServiceImpl<GrBiSaSetdtlMapper, GrB
|
|||||||
|
|
||||||
//本地不存在空的情况 之前会手动导入的情况
|
//本地不存在空的情况 之前会手动导入的情况
|
||||||
//查询大于本地最大更新时间的oracle里的数据
|
//查询大于本地最大更新时间的oracle里的数据
|
||||||
List<GrBiSaSetdtl> grBiSaSetdtlList = this.baseMapper.getByUpdateTime(lideeYunJiBaseConstant.DS_ORACLE_GRYYBI, grBiSaSetdtl.getUPDATETIME());
|
List<GrBiSaSetdtl> grBiSaSetdtlList = this.baseMapper.getByUpdateTime(lideeYunJiBaseConstant.DS_ORACLE_GRYYBI, grBiSaSetdtl== null ? null : grBiSaSetdtl.getUPDATETIME());
|
||||||
|
|
||||||
if (CollUtil.isEmpty(grBiSaSetdtlList)) {
|
if (CollUtil.isEmpty(grBiSaSetdtlList)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -104,4 +104,9 @@ public class NewGrBiSaAggMonthCountServiceImpl extends ServiceImpl<NewGrBiSaAggM
|
|||||||
SaAggParam saAggParam = NewGrBiSaAggServiceImpl.createParam(params);
|
SaAggParam saAggParam = NewGrBiSaAggServiceImpl.createParam(params);
|
||||||
return this.baseMapper.selectNewGrBiSaAggGroupMonthList(lideeYunJiBaseConstant.DS_ERP_BI_DATA, saAggParam,params, groupFieldList);
|
return this.baseMapper.selectNewGrBiSaAggGroupMonthList(lideeYunJiBaseConstant.DS_ERP_BI_DATA, saAggParam,params, groupFieldList);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupNoMonthNoYearList(Map<String, Object> params, List<String> groupFieldList){
|
||||||
|
SaAggParam saAggParam = NewGrBiSaAggServiceImpl.createParam(params);
|
||||||
|
return this.baseMapper.selectNewGrBiSaAggGroupNoMonthNoYearList(lideeYunJiBaseConstant.DS_ERP_BI_DATA, saAggParam,params, groupFieldList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,6 +257,201 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectNewGrBiSaAggGroupNoMonthNoYearList" resultMap="NewGrBiSaAggMonthCountResult">
|
||||||
|
select
|
||||||
|
CONCAT (#{params.useYearMonthStart} , '~' , #{params.useYearMonthEnd}) as ny,
|
||||||
|
<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,
|
||||||
|
|
||||||
|
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('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>
|
||||||
|
ifnull(sum(this_month_sa_qty), 0) AS this_month_sa_qty,
|
||||||
|
ifnull(sum(this_month_sa_money), 0) AS this_month_sa_money,
|
||||||
|
ifnull(sum(this_month_cost), 0) AS this_month_cost,
|
||||||
|
ifnull(sum(this_month_profit), 0) AS this_month_profit
|
||||||
|
FROM
|
||||||
|
new_gr_bi_sa_agg_month_count
|
||||||
|
<where>
|
||||||
|
(use_year * 100 + use_month) >= (#{saAggParam.useYearStart} * 100 + #{saAggParam.useMonthStart})
|
||||||
|
AND (use_year * 100 + use_month) <= (#{saAggParam.useYearEnd} * 100 + #{saAggParam.useMonthEnd})
|
||||||
|
<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('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
|
||||||
|
|
||||||
|
, (
|
||||||
|
SELECT
|
||||||
|
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
|
||||||
|
WHERE
|
||||||
|
(use_year * 100 + use_month) >= (#{saAggParam.useYearStart} * 100 + #{saAggParam.useMonthStart})
|
||||||
|
AND (use_year * 100 + use_month) <= (#{saAggParam.useYearEnd} * 100 + #{saAggParam.useMonthEnd})
|
||||||
|
) total_month_data
|
||||||
|
<where>
|
||||||
|
<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="selectNewGrBiSaAggGroupMonthList" resultMap="NewGrBiSaAggMonthCountResult">
|
<select id="selectNewGrBiSaAggGroupMonthList" resultMap="NewGrBiSaAggMonthCountResult">
|
||||||
select
|
select
|
||||||
current_month.use_month ,
|
current_month.use_month ,
|
||||||
@@ -392,10 +587,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
saler_name,
|
saler_name,
|
||||||
</if>
|
</if>
|
||||||
CONCAT(MAX(use_year), LPAD(MAX(use_month), 2, '0')) AS ny,
|
CONCAT(MAX(use_year), LPAD(MAX(use_month), 2, '0')) AS ny,
|
||||||
sum(this_month_sa_qty) AS this_month_sa_qty,
|
ifnull(sum(this_month_sa_qty), 0) AS this_month_sa_qty,
|
||||||
sum(this_month_sa_money) AS this_month_sa_money,
|
ifnull(sum(this_month_sa_money), 0) AS this_month_sa_money,
|
||||||
sum(this_month_cost) AS this_month_cost,
|
ifnull(sum(this_month_cost), 0) AS this_month_cost,
|
||||||
sum(this_month_profit) AS this_month_profit
|
ifnull(sum(this_month_profit), 0) AS this_month_profit
|
||||||
FROM
|
FROM
|
||||||
new_gr_bi_sa_agg_month_count
|
new_gr_bi_sa_agg_month_count
|
||||||
<where>
|
<where>
|
||||||
@@ -506,10 +701,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
||||||
saler_id,
|
saler_id,
|
||||||
</if>
|
</if>
|
||||||
SUM(this_month_sa_qty) AS last_month_sa_qty,
|
ifnull(SUM(this_month_sa_qty), 0) AS last_month_sa_qty,
|
||||||
SUM(this_month_sa_money) AS last_month_sa_money,
|
ifnull(SUM(this_month_sa_money), 0) AS last_month_sa_money,
|
||||||
SUM(this_month_cost) AS last_month_cost,
|
ifnull(SUM(this_month_cost), 0) AS last_month_cost,
|
||||||
SUM(this_month_profit) AS last_month_profit
|
ifnull(SUM(this_month_profit), 0) AS last_month_profit
|
||||||
FROM new_gr_bi_sa_agg_month_count
|
FROM new_gr_bi_sa_agg_month_count
|
||||||
GROUP BY
|
GROUP BY
|
||||||
<trim suffixOverrides=",">
|
<trim suffixOverrides=",">
|
||||||
@@ -583,10 +778,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
||||||
saler_id,
|
saler_id,
|
||||||
</if>
|
</if>
|
||||||
SUM(this_month_sa_qty) AS yoy_month_sa_qty,
|
ifnull(SUM(this_month_sa_qty), 0) AS yoy_month_sa_qty,
|
||||||
SUM(this_month_sa_money) AS yoy_month_sa_money,
|
ifnull(SUM(this_month_sa_money), 0) AS yoy_month_sa_money,
|
||||||
SUM(this_month_cost) as yoy_month_cost,
|
ifnull(SUM(this_month_cost), 0) as yoy_month_cost,
|
||||||
SUM(this_month_profit) AS yoy_month_profit
|
ifnull(SUM(this_month_profit), 0) AS yoy_month_profit
|
||||||
FROM new_gr_bi_sa_agg_month_count
|
FROM new_gr_bi_sa_agg_month_count
|
||||||
<where>
|
<where>
|
||||||
<!-- <if test="saAggParam.useYear != null and saAggParam.useYear != ''"> and use_year = #{saAggParam.useYear }- 1</if>-->
|
<!-- <if test="saAggParam.useYear != null and saAggParam.useYear != ''"> and use_year = #{saAggParam.useYear }- 1</if>-->
|
||||||
@@ -688,8 +883,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
use_year,
|
use_year,
|
||||||
SUM( this_month_sa_money ) AS this_month_sa_money_sum,
|
ifnull(SUM( this_month_sa_money ), 0) AS this_month_sa_money_sum,
|
||||||
SUM(this_month_profit) AS this_month_profit_sum
|
ifnull(SUM(this_month_profit), 0) AS this_month_profit_sum
|
||||||
FROM new_gr_bi_sa_agg
|
FROM new_gr_bi_sa_agg
|
||||||
GROUP BY
|
GROUP BY
|
||||||
use_year
|
use_year
|
||||||
|
|||||||
@@ -356,10 +356,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</if>
|
</if>
|
||||||
GROUP_CONCAT(DISTINCT province_id ORDER BY province_id SEPARATOR ',') AS province_id,
|
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,
|
GROUP_CONCAT(DISTINCT province_name ORDER BY province_name SEPARATOR ',') AS province_name,
|
||||||
sum(this_year_sa_qty) AS this_year_sa_qty,
|
ifnull(sum(this_year_sa_qty), 0) AS this_year_sa_qty,
|
||||||
sum(this_year_sa_money) AS this_year_sa_money,
|
ifnull(sum(this_year_sa_money), 0) AS this_year_sa_money,
|
||||||
sum(this_year_cost) AS this_year_cost,
|
ifnull(sum(this_year_cost), 0) AS this_year_cost,
|
||||||
sum(this_year_profit) 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>-->
|
||||||
@@ -456,10 +456,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
<if test="groupFieldList.contains('salerName') || params.containsKey('salerName')">
|
||||||
saler_id,
|
saler_id,
|
||||||
</if>
|
</if>
|
||||||
SUM(this_year_sa_qty) AS last_year_sa_qty,
|
ifnull(SUM(this_year_sa_qty), 0) AS last_year_sa_qty,
|
||||||
SUM(this_year_sa_money) AS last_year_sa_money,
|
ifnull(SUM(this_year_sa_money), 0) AS last_year_sa_money,
|
||||||
SUM(this_year_cost) AS last_year_cost,
|
ifnull(SUM(this_year_cost), 0) AS last_year_cost,
|
||||||
SUM(this_year_profit) AS last_year_profit
|
ifnull(SUM(this_year_profit), 0) AS last_year_profit
|
||||||
FROM new_gr_bi_sa_agg_year_count
|
FROM new_gr_bi_sa_agg_year_count
|
||||||
|
|
||||||
<where>
|
<where>
|
||||||
@@ -550,8 +550,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
AND current_year_data.saler_id = last_year_data.saler_id
|
AND current_year_data.saler_id = last_year_data.saler_id
|
||||||
</if>
|
</if>
|
||||||
LEFT JOIN (SELECT use_year,
|
LEFT JOIN (SELECT use_year,
|
||||||
SUM(this_year_sa_money) AS this_year_sa_money_sum,
|
ifnull(SUM(this_year_sa_money), 0) AS this_year_sa_money_sum,
|
||||||
SUM(this_year_profit) AS this_year_profit_sum
|
ifnull(SUM(this_year_profit), 0) AS this_year_profit_sum
|
||||||
FROM new_gr_bi_sa_agg_year_count
|
FROM new_gr_bi_sa_agg_year_count
|
||||||
GROUP BY use_year) as total_year_data
|
GROUP BY use_year) as total_year_data
|
||||||
ON total_year_data.use_year = current_year_data.use_year
|
ON total_year_data.use_year = current_year_data.use_year
|
||||||
|
|||||||
@@ -11,4 +11,8 @@
|
|||||||
<select id="callUpdateCore" statementType="CALLABLE" >
|
<select id="callUpdateCore" statementType="CALLABLE" >
|
||||||
{call P_ERP_DATA_FAST()}
|
{call P_ERP_DATA_FAST()}
|
||||||
</select>
|
</select>
|
||||||
|
<!-- 调用示例存储过程 -->
|
||||||
|
<select id="callErpDataCore" statementType="CALLABLE" >
|
||||||
|
{call p_erp_data(#{pastYear},#{pastMonth},#{currentYear},#{currentMonth})}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user