3 Commits

Author SHA1 Message Date
king
8d8e68043a Merge branch 'dev_js_20260420' 2026-04-25 14:58:24 +08:00
king
55e47f0165 删除多余导入 2026-04-25 14:58:09 +08:00
king
588279f433 销售汇总报表 编写, 发布 2026-04-25 14:57:34 +08:00
5 changed files with 237 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
package com.lideeyunji.core.framework.enhance.example.report.xtsy;
import cn.hutool.core.util.StrUtil;
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.INewGrBiSaAggMonthCountService;
import com.lideeyunji.tool.framework.yunji.model.ResultDataModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* 报表-综合销售表_剂型-插件
*/
@Slf4j
@Component("zhxsqkPluginHZ")
public class ZhxsqkPluginHZ implements ReportAroundAdvicePlugin {
@Resource
INewGrBiSaAggMonthCountService newGrBiSaAggMonthCountService;
@Override
public ResultDataModel executeAround(EnhanceReportContext enhanceContext) {
log.info("进入=======>zhxsqkPluginJx=======>execute");
LocalDateTime now = LocalDateTime.now();
String currentYear = Integer.toString(now.getYear());
int currentMonth = now.getMonthValue();
List<Integer> monthList = IntStream.rangeClosed(1, currentMonth).boxed().collect(Collectors.toList());
Map<String, Object> params = enhanceContext.getParam().getParams();
List<Map<String, Object>> records = newGrBiSaAggMonthCountService.selectNewGrBiSaAggGroupHZList(params);
for(Map<String, Object> record : records){
if(!record.containsKey("zone_name") || StrUtil.isEmpty(record.get("zone_name").toString())){
record.put("zone_name","-");
}
if(!record.containsKey("position") || StrUtil.isEmpty(record.get("position").toString())){
record.put("position","-");
}
if(!record.containsKey("saler_name") || StrUtil.isEmpty(record.get("saler_name").toString())){
record.put("saler_name","-");
}
if(!record.containsKey("year_sa_money") || StrUtil.isEmpty(record.get("year_sa_money").toString())){
record.put("year_sa_money","-");
}
for (Integer month : monthList){
if(!record.containsKey("month_sa_money_" + month) || StrUtil.isEmpty(record.get("month_sa_money_" + month).toString())){
record.put("month_sa_money_" + month,"-");
}
}
}
return ResultDataModel.fomatList(records);
}
}

View File

@@ -80,6 +80,16 @@ public interface NewGrBiSaAggMonthCountMapper extends BaseMapper<NewGrBiSaAggMon
@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);
/**
* 批量查询综合销售情况明细列表 -汇总
*
* @param saAggParam 综合销售情况明细参数
* @return 综合销售情况明细集合
*/
@DataPermission(enable = false)
@DS(value = "#dataSourceType")
public List<Map<String, Object>> selectNewGrBiSaAggGroupHZList(@Param("dataSourceType") String dataSourceType, @Param("saAggParam") SaAggParam saAggParam, @Param("params") Map<String, Object> params);
/**
* 批量查询综合销售情况明细列表 -月度
*

View File

@@ -68,6 +68,8 @@ public interface INewGrBiSaAggMonthCountService
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupMonthList(Map<String, Object> params, List<String> groupFieldList);
public List<Map<String, Object>> selectNewGrBiSaAggGroupHZList(Map<String, Object> params);
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupNoMonthNoYearList(Map<String, Object> params, List<String> groupFieldList);
}

View File

@@ -104,6 +104,13 @@ public class NewGrBiSaAggMonthCountServiceImpl extends ServiceImpl<NewGrBiSaAggM
SaAggParam saAggParam = NewGrBiSaAggServiceImpl.createParam(params);
return this.baseMapper.selectNewGrBiSaAggGroupMonthList(lideeYunJiBaseConstant.DS_ERP_BI_DATA, saAggParam,params, groupFieldList);
}
@Override
public List<Map<String, Object>> selectNewGrBiSaAggGroupHZList(Map<String, Object> params){
SaAggParam saAggParam = NewGrBiSaAggServiceImpl.createParam(params);
return this.baseMapper.selectNewGrBiSaAggGroupHZList(lideeYunJiBaseConstant.DS_ERP_BI_DATA, saAggParam,params);
}
@Override
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupNoMonthNoYearList(Map<String, Object> params, List<String> groupFieldList){
SaAggParam saAggParam = NewGrBiSaAggServiceImpl.createParam(params);

View File

@@ -1159,4 +1159,162 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectNewGrBiSaAggGroupHZList" resultType="java.util.Map">
SELECT
'自营品种' as bk,
IF(GROUPING (saler_name, zone_name) = 2, CONCAT(zone_name, "总计"), IFNULL(zone_name, '省区合计')) AS zone_name,
c.position,
saler_name,
-- GROUPING (saler_name, zone_name, c.position),
ROUND(SUM(IF(use_month = '1', this_month_sa_money, null)), 2) AS month_sa_money_1,
ROUND(SUM(IF(`use_month` = '2', this_month_sa_money, null)), 2) AS month_sa_money_2,
ROUND(SUM(IF(`use_month` = '3', this_month_sa_money, null)), 2) AS month_sa_money_3,
ROUND(SUM(IF(`use_month` = '4', this_month_sa_money, null)), 2) AS month_sa_money_4,
ROUND(SUM(IF(`use_month` = '5', this_month_sa_money, null)), 2) AS month_sa_money_5,
ROUND(SUM(IF(`use_month` = '6', this_month_sa_money, null)), 2) AS month_sa_money_6,
ROUND(SUM(IF(`use_month` = '7', this_month_sa_money, null)), 2) AS month_sa_money_7,
ROUND(SUM(IF(`use_month` = '8', this_month_sa_money, null)), 2) AS month_sa_money_8,
ROUND(SUM(IF(`use_month` = '9', this_month_sa_money, null)), 2) AS month_sa_money_9,
ROUND(SUM(IF(`use_month` = '10', this_month_sa_money, null)), 2) AS month_sa_money_10,
ROUND(SUM(IF(`use_month` = '11', this_month_sa_money, null)), 2) AS month_sa_money_11,
ROUND(SUM(IF(`use_month` = '12', this_month_sa_money, null)), 2) AS month_sa_money_12,
ROUND(SUM(this_month_sa_money), 2) AS year_sa_money
FROM
new_gr_bi_sa_agg_month_count a
LEFT JOIN gr_contacts c ON a.saler_name = c.`name`
AND a.zone_name = c.zone
WHERE
use_year = YEAR(CURDATE())
AND sale_type_name = '自营品种'
GROUP BY
zone_name,
saler_name,
c.position WITH ROLLUP
HAVING GROUPING (saler_name, zone_name, c.position) != 1
UNION ALL
SELECT
'代理品种' as bk,
a.*
FROM
(
SELECT
IF(
GROUPING (p.proxy_name, saler_name) = 0,
IFNULL(p.proxy_name, '其他'),
IF(GROUPING (p.proxy_name, saler_name) = 3, IFNULL(p.proxy_name, '代理品种合计'), p.proxy_name)
) proxy_name,
'',
ROUND(SUM(IF(use_month = MONTH(CURDATE()), this_month_sa_qty, null)), 2) AS this_month_sa_qty,
ROUND(SUM(IF(use_month = '1', this_month_sa_money, null)), 2) AS month_sa_money_1,
ROUND(SUM(IF(`use_month` = '2', this_month_sa_money, null)), 2) AS month_sa_money_2,
ROUND(SUM(IF(`use_month` = '3', this_month_sa_money, null)), 2) AS month_sa_money_3,
ROUND(SUM(IF(`use_month` = '4', this_month_sa_money, null)), 2) AS month_sa_money_4,
ROUND(SUM(IF(`use_month` = '5', this_month_sa_money, null)), 2) AS month_sa_money_5,
ROUND(SUM(IF(`use_month` = '6', this_month_sa_money, null)), 2) AS month_sa_money_6,
ROUND(SUM(IF(`use_month` = '7', this_month_sa_money, null)), 2) AS month_sa_money_7,
ROUND(SUM(IF(`use_month` = '8', this_month_sa_money, null)), 2) AS month_sa_money_8,
ROUND(SUM(IF(`use_month` = '9', this_month_sa_money, null)), 2) AS month_sa_money_9,
ROUND(SUM(IF(`use_month` = '10', this_month_sa_money, null)), 2) AS month_sa_money_10,
ROUND(SUM(IF(`use_month` = '11', this_month_sa_money, null)), 2) AS month_sa_money_11,
ROUND(SUM(IF(`use_month` = '12', this_month_sa_money, null)), 2) AS month_sa_money_12,
ROUND(SUM(this_month_sa_money), 2) AS year_sa_money
FROM
new_gr_bi_sa_agg a
LEFT JOIN gr_googs_proxy p ON a.goods_id = p.goods_id
WHERE
use_year = YEAR(CURDATE())
AND sale_type_name = '代理品种'
GROUP BY
p.proxy_name,
saler_name WITH ROLLUP
HAVING GROUPING (saler_name, p.proxy_name) != 2
ORDER BY
GROUPING (saler_name, p.proxy_name),
p.proxy_name DESC
) a
UNION ALL
SELECT
'业务拓展' as bk,
IF(GROUPING (sale_type_name) = 1, IFNULL(sale_type_name, '业务拓展合计'),sale_type_name) sale_type_name,
'' ,
'',
ROUND(SUM(IF(use_month = '1', this_month_sa_money, null)), 2) AS month_sa_money_1,
ROUND(SUM(IF(`use_month` = '2', this_month_sa_money, null)), 2) AS month_sa_money_2,
ROUND(SUM(IF(`use_month` = '3', this_month_sa_money, null)), 2) AS month_sa_money_3,
ROUND(SUM(IF(`use_month` = '4', this_month_sa_money, null)), 2) AS month_sa_money_4,
ROUND(SUM(IF(`use_month` = '5', this_month_sa_money, null)), 2) AS month_sa_money_5,
ROUND(SUM(IF(`use_month` = '6', this_month_sa_money, null)), 2) AS month_sa_money_6,
ROUND(SUM(IF(`use_month` = '7', this_month_sa_money, null)), 2) AS month_sa_money_7,
ROUND(SUM(IF(`use_month` = '8', this_month_sa_money, null)), 2) AS month_sa_money_8,
ROUND(SUM(IF(`use_month` = '9', this_month_sa_money, null)), 2) AS month_sa_money_9,
ROUND(SUM(IF(`use_month` = '10', this_month_sa_money, null)), 2) AS month_sa_money_10,
ROUND(SUM(IF(`use_month` = '11', this_month_sa_money, null)), 2) AS month_sa_money_11,
ROUND(SUM(IF(`use_month` = '12', this_month_sa_money, null)), 2) AS month_sa_money_12,
ROUND(SUM(this_month_sa_money), 2) AS year_sa_money
FROM
new_gr_bi_sa_agg_month_count a
WHERE
use_year = YEAR(CURDATE())
AND sale_type_name in ( '公司出口','委托加工','外贸品种')
GROUP BY
sale_type_name WITH ROLLUP
UNION ALL
SELECT
'其他收入' as bk,
'其他收入',
'' ,
'' ,
ROUND(SUM(IF(use_month = '1', this_month_sa_money, null)), 2) AS month_sa_money_1,
ROUND(SUM(IF(`use_month` = '2', this_month_sa_money, null)), 2) AS month_sa_money_2,
ROUND(SUM(IF(`use_month` = '3', this_month_sa_money, null)), 2) AS month_sa_money_3,
ROUND(SUM(IF(`use_month` = '4', this_month_sa_money, null)), 2) AS month_sa_money_4,
ROUND(SUM(IF(`use_month` = '5', this_month_sa_money, null)), 2) AS month_sa_money_5,
ROUND(SUM(IF(`use_month` = '6', this_month_sa_money, null)), 2) AS month_sa_money_6,
ROUND(SUM(IF(`use_month` = '7', this_month_sa_money, null)), 2) AS month_sa_money_7,
ROUND(SUM(IF(`use_month` = '8', this_month_sa_money, null)), 2) AS month_sa_money_8,
ROUND(SUM(IF(`use_month` = '9', this_month_sa_money, null)), 2) AS month_sa_money_9,
ROUND(SUM(IF(`use_month` = '10', this_month_sa_money, null)), 2) AS month_sa_money_10,
ROUND(SUM(IF(`use_month` = '11', this_month_sa_money, null)), 2) AS month_sa_money_11,
ROUND(SUM(IF(`use_month` = '12', this_month_sa_money, null)), 2) AS month_sa_money_12,
ROUND(SUM(this_month_sa_money), 2) AS year_sa_money
FROM
new_gr_bi_sa_agg_month_count a
WHERE
use_year = YEAR(CURDATE())
AND sale_type_name = '其他收入'
-- group by sale_type_name
UNION ALL
SELECT
'总计',
'总计',
'' ,
'',
ROUND(SUM(IF(use_month = '1', this_month_sa_money, null)), 2) AS month_sa_money_1,
ROUND(SUM(IF(`use_month` = '2', this_month_sa_money, null)), 2) AS month_sa_money_2,
ROUND(SUM(IF(`use_month` = '3', this_month_sa_money, null)), 2) AS month_sa_money_3,
ROUND(SUM(IF(`use_month` = '4', this_month_sa_money, null)), 2) AS month_sa_money_4,
ROUND(SUM(IF(`use_month` = '5', this_month_sa_money, null)), 2) AS month_sa_money_5,
ROUND(SUM(IF(`use_month` = '6', this_month_sa_money, null)), 2) AS month_sa_money_6,
ROUND(SUM(IF(`use_month` = '7', this_month_sa_money, null)), 2) AS month_sa_money_7,
ROUND(SUM(IF(`use_month` = '8', this_month_sa_money, null)), 2) AS month_sa_money_8,
ROUND(SUM(IF(`use_month` = '9', this_month_sa_money, null)), 2) AS month_sa_money_9,
ROUND(SUM(IF(`use_month` = '10', this_month_sa_money, null)), 2) AS month_sa_money_10,
ROUND(SUM(IF(`use_month` = '11', this_month_sa_money, null)), 2) AS month_sa_money_11,
ROUND(SUM(IF(`use_month` = '12', this_month_sa_money, null)), 2) AS month_sa_money_12,
ROUND(SUM(this_month_sa_money), 2) AS year_sa_money
FROM
new_gr_bi_sa_agg_month_count a
WHERE
use_year = YEAR(CURDATE()) and sale_type_name in ( '代理品种','其他收入','自营品种','公司出口','委托加工','外贸品种')
</select>
</mapper>