Merge branch 'dev_js_20260420'

This commit is contained in:
king
2026-05-09 16:16:01 +08:00
5 changed files with 191 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
package com.lideeyunji.core.framework.enhance.example.report.xtsy;
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.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;
/**
* 报表-重点客户收入与占比情况-插件
*/
@Slf4j
@Component("zdCustomerPlugin")
public class zdCustomerPlugin implements ReportAroundAdvicePlugin {
@Resource
INewGrBiSaAggMonthCountService newGrBiSaAggMonthCountService;
@Override
public ResultDataModel executeAround(EnhanceReportContext enhanceContext) {
log.info("进入=======>zdCustomerPlugin=======>execute");
Map<String, Object> params = enhanceContext.getParam().getParams();
// 获取一个月前的时间和年月
LocalDateTime lastNow = LocalDateTime.now().minusMonths(1);
int lastYear = lastNow.getYear();
int lastMonth = lastNow.getMonthValue();
if(!params.containsKey("useYearStart")){
params.put("useYearStart", lastYear);
params.put("useMonthStart", "1");
}
if(!params.containsKey("useYearEnd")){
params.put("useYearEnd", lastYear);
params.put("useMonthEnd", lastMonth);
}
Page<Object> page = PageHelper.startPage(Integer.parseInt(params.get("pageNo").toString()), Integer.parseInt(params.get("pageSize").toString()));
// if (params.containsKey("column")) {
// String orderBy = params.get("column") + " " + params.get("order");
//// 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();
//// }
// page.setUnsafeOrderBy(orderBy);
// }
List<Map<String, Object>> newGrBiSaAggList = newGrBiSaAggMonthCountService.zdCustomer(params);
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(newGrBiSaAggList);
// List<Map<String, Object>> list = newGrBiSaAggList.stream().map(BeanUtil::beanToMap).collect(Collectors.toList());
return ResultDataModel.fomat(pageInfo.getTotal(), newGrBiSaAggList);
}
}

View File

@@ -109,4 +109,14 @@ public interface NewGrBiSaAggMonthCountMapper extends BaseMapper<NewGrBiSaAggMon
@DS(value = "#dataSourceType")
public List<NewGrBiSaAggMonthCount> stgoodTop10(@Param("dataSourceType") String dataSourceType, @Param("params") Map<String, Object> params);
/**
* 重点客户收入与占比情况 -月度
*
* @param params 综合销售情况明细参数
* @return 综合销售情况明细集合
*/
@DataPermission(enable = false)
@DS(value = "#dataSourceType")
public List<Map<String, Object>> zdCustomer(@Param("dataSourceType") String dataSourceType, @Param("params") Map<String, Object> params);
}

View File

@@ -72,4 +72,6 @@ public interface INewGrBiSaAggMonthCountService
public List<NewGrBiSaAggMonthCount> selectNewGrBiSaAggGroupNoMonthNoYearList(Map<String, Object> params, List<String> groupFieldList);
List<NewGrBiSaAggMonthCount> stgoodTop10(Map<String, Object> params);
List<Map<String, Object>> zdCustomer(Map<String, Object> params);
}

View File

@@ -119,4 +119,8 @@ public class NewGrBiSaAggMonthCountServiceImpl extends ServiceImpl<NewGrBiSaAggM
public List<NewGrBiSaAggMonthCount> stgoodTop10(Map<String, Object> params) {
return this.baseMapper.stgoodTop10(lideeYunJiBaseConstant.DS_ERP_BI_DATA, params);
}
@Override
public List<Map<String, Object>> zdCustomer(Map<String, Object> params) {
return this.baseMapper.zdCustomer(lideeYunJiBaseConstant.DS_ERP_BI_DATA, params);
}
}

View File

@@ -1385,4 +1385,113 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY
money DESC
</select>
<select id="zdCustomer" resultType="java.util.Map">
WITH TopAllCustomers AS (
SELECT
CONCAT(#{params.useYearStart}, '-', #{params.useMonthStart}, ' ~ ' , #{params.useYearEnd}, '-', #{params.useMonthEnd}) as ny,
a.CUSTOMNAME,
a.THISSAMONEY,
a.THISCOST,
a.THISPROFIT,
a.LASTSAMONEY,
a.LASTPROFIT,
a.THISPROFITRATE,
a.LASTPROFITRATE,
ROW_NUMBER() OVER (ORDER BY a.THISSAMONEY DESC) AS rn
FROM
(
SELECT
`CUSTOMNAME`,
IFNULL(SUM(MONTHSAMONEY),0) AS THISSAMONEY,
SUM(MONTHCOST) AS THISCOST,
SUM(MONTHPROFIT) AS THISPROFIT,
MAX(`LASTSAMONEY`) AS LASTSAMONEY,
MAX(`LASTPROFIT`) AS LASTPROFIT,
MAX(`THISPROFIT`) / MAX(`THISSAMONEY`) AS `THISPROFITRATE`,
MAX(`LASTPROFIT`) / MAX(`LASTSAMONEY`) AS `LASTPROFITRATE`
FROM
`GR_BI_SA_CUSTOMER`
<where>
<if test="params.useYearStart != null">
AND (USEYEAR * 100 + USEMONTH) &gt;= (#{params.useYearStart} * 100 + #{params.useMonthStart})
</if>
<if test="params.useYearEnd != null">
AND (USEYEAR * 100 + USEMONTH) &lt;= (#{params.useYearEnd} * 100 + #{params.useMonthEnd})
</if>
</where>
GROUP BY
`CUSTOMNAME`
) AS a
),
OtherCustomers AS (
SELECT
max(ny) ny,
SUM(`THISSAMONEY`) AS THISSAMONEY,
SUM(`THISCOST`) AS THISCOST,
SUM(`THISPROFIT`) AS THISPROFIT,
SUM(`LASTPROFIT`) AS LASTPROFIT,
SUM(`LASTSAMONEY`) AS LASTSAMONEY,
SUM(`THISPROFIT`) / SUM(`THISSAMONEY`) AS `THISPROFITRATE`,
SUM(`LASTPROFIT`) / SUM(`LASTSAMONEY`) AS `LASTPROFITRATE`
FROM TopAllCustomers
WHERE rn > 10
),
TotalCustomers AS (
SELECT
max(ny) ny,
SUM(`THISSAMONEY`) AS THISSAMONEY,
SUM(`THISCOST`) AS THISCOST,
SUM(`THISPROFIT`) AS THISPROFIT,
SUM(`LASTPROFIT`) AS LASTPROFIT,
SUM(`LASTSAMONEY`) AS LASTSAMONEY,
SUM(`THISPROFIT`) / SUM(`THISSAMONEY`) AS `THISPROFITRATE`,
SUM(`LASTPROFIT`) / SUM(`LASTSAMONEY`) AS `LASTPROFITRATE`
FROM TopAllCustomers
)
SELECT
`CUSTOMNAME` AS `customname`,
ny,
ROUND(`THISSAMONEY`, 2) AS `thissamoney`,
ROUND(`THISCOST`, 2) AS `thiscost`,
ROUND(`THISPROFITRATE`, 2) AS `thisprofitrate`,
ROUND(`LASTPROFITRATE`, 2) AS `lastprofitrate`,
ROUND(`THISPROFIT`, 2) AS `thisprofit`,
ROUND(`LASTPROFIT`, 2) AS `lastprofit`,
ROUND(`THISPROFITRATE`, 2) AS `thisprofitrate1`,
ROUND(`LASTPROFITRATE`, 2) AS `lastprofitrate1`,
1 AS sort_order
FROM TopAllCustomers
WHERE rn &lt;= 10
UNION ALL
SELECT
'其他' AS `CUSTOMNAME`,
ny,
ROUND(`THISSAMONEY`, 2),
ROUND(`THISCOST`, 2),
ROUND(`THISPROFITRATE`, 2),
ROUND(`LASTPROFITRATE`, 2),
ROUND(`THISPROFIT`, 2),
ROUND(`LASTPROFIT`, 2),
ROUND(`THISPROFITRATE`, 2),
ROUND(`LASTPROFITRATE`, 2),
2 AS sort_order
FROM OtherCustomers
UNION ALL
SELECT
'合计' AS `CUSTOMNAME`,
ny,
ROUND(`THISSAMONEY`, 2),
ROUND(`THISCOST`, 2),
ROUND(`THISPROFITRATE`, 2),
ROUND(`LASTPROFITRATE`, 2),
ROUND(`THISPROFIT`, 2),
ROUND(`LASTPROFIT`, 2),
ROUND(`THISPROFITRATE`, 2),
ROUND(`LASTPROFITRATE`, 2),
3 AS sort_order
FROM TotalCustomers
ORDER BY sort_order, `THISSAMONEY` DESC
</select>
</mapper>