Commit c9973a06 by 杨卫

feat:效果分析查询策略统计明细

1 parent a6ab8d87
package cn.com.glsx.dj.strategy.dto; package cn.com.glsx.dj.strategy.dto;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* 门店策略统计 * 门店策略统计
...@@ -11,6 +13,7 @@ import java.io.Serializable; ...@@ -11,6 +13,7 @@ import java.io.Serializable;
* @since 2026/01/22 16:29 * @since 2026/01/22 16:29
*/ */
@Data @Data
@Accessors(chain = true)
public class MerchantStrategyStatisticsRespDTO implements Serializable { public class MerchantStrategyStatisticsRespDTO implements Serializable {
/** /**
...@@ -22,4 +25,14 @@ public class MerchantStrategyStatisticsRespDTO implements Serializable { ...@@ -22,4 +25,14 @@ public class MerchantStrategyStatisticsRespDTO implements Serializable {
* 策略数量 * 策略数量
*/ */
private Integer strategyCount; private Integer strategyCount;
/**
* 策略类型统计
*/
private Integer strategyType;
/**
* 策略类型统计列表
*/
private List<StrategyTypeStatisticsRespDTO> strategyTypeStatisticsList;
} }
...@@ -450,6 +450,32 @@ public class StrategyDetailService { ...@@ -450,6 +450,32 @@ public class StrategyDetailService {
public List<MerchantStrategyStatisticsRespDTO> findStrategyStatisticsGroupMerchantNo(MerchantStrategyStatisticsReqDTO request) { public List<MerchantStrategyStatisticsRespDTO> findStrategyStatisticsGroupMerchantNo(MerchantStrategyStatisticsReqDTO request) {
BeanValidationUtils.validateAndThrow(request); BeanValidationUtils.validateAndThrow(request);
return strategyInfoMapper.findStrategyStatisticsGroupMerchantNo(request); List<MerchantStrategyStatisticsRespDTO> strategyStatisticsGroupMerchantNo = strategyInfoMapper.findStrategyStatisticsGroupMerchantNo(request);
if (CollUtil.isEmpty(strategyStatisticsGroupMerchantNo)) {
log.info("策略分析-门店策略分布结果为空");
return Lists.newArrayList();
}
Map<Integer, String> strategyTypeMap = Arrays.stream(StrategyTypeEnum.values())
.collect(Collectors.toMap(StrategyTypeEnum::getValue, StrategyTypeEnum::getDisplayName, (v1, v2) -> v1));
Map<Integer, List<MerchantStrategyStatisticsRespDTO>> merchantNoMapStrategyStrategyStatistics = strategyStatisticsGroupMerchantNo.stream()
.collect(Collectors.groupingBy(MerchantStrategyStatisticsRespDTO::getMerchantNo));
return merchantNoMapStrategyStrategyStatistics.entrySet()
.stream()
.map(entry -> {
Integer key = entry.getKey();
List<MerchantStrategyStatisticsRespDTO> value = Optional.ofNullable(entry.getValue()).orElseGet(ArrayList::new);
return new MerchantStrategyStatisticsRespDTO()
.setMerchantNo(key)
.setStrategyCount(value.stream().map(MerchantStrategyStatisticsRespDTO::getStrategyCount).reduce(0, Integer::sum))
.setStrategyTypeStatisticsList(
value.stream().map(ele -> StrategyTypeStatisticsRespDTO.builder()
.strategyType(ele.getStrategyType())
.strategyTypeName(strategyTypeMap.get(ele.getStrategyType()))
.strategyCount(ele.getStrategyCount())
.build()
).collect(Collectors.toList())
);
}).collect(Collectors.toList());
} }
} }
...@@ -137,7 +137,8 @@ ...@@ -137,7 +137,8 @@
resultType="cn.com.glsx.dj.strategy.dto.MerchantStrategyStatisticsRespDTO"> resultType="cn.com.glsx.dj.strategy.dto.MerchantStrategyStatisticsRespDTO">
select select
merchant_id merchantNo, merchant_id merchantNo,
count(*) strategyCount count(*) strategyCount,
strategy_type strategyType
from dj_car_life_strategy_info from dj_car_life_strategy_info
where deleted_flag = 'N' where deleted_flag = 'N'
<if test="businessType != null and businessType != ''"> <if test="businessType != null and businessType != ''">
...@@ -152,7 +153,7 @@ ...@@ -152,7 +153,7 @@
<if test="startDate != null and endDate != null"> <if test="startDate != null and endDate != null">
AND created_date between #{startDate} and #{endDate} AND created_date between #{startDate} and #{endDate}
</if> </if>
group by merchant_id order by strategyCount desc group by merchant_id, strategy_type order by strategyCount desc
</select> </select>
<select id="selectStrategyIdsForPush" resultType="java.lang.Integer"> <select id="selectStrategyIdsForPush" resultType="java.lang.Integer">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!