Commit 93a5351a by 林永健

feat(report): 新增数据报告相关接口和快照任务

- 新增DataReportController,提供数据报告汇总查询接口
- 定义DataReportQueryRequest和DataReportQueryResponse数据模型
- 配置数据报告指标映射和默认指标列表
- 实现延保、轻改、权益业务多品牌、多维度指标配置管理
- 新增AI文本摘要服务配置和对应的提交、轮询任务
- 实现周报和月报快照生成定时任务,自动构建周期键
- 添加数据报告品牌和业务快照Mapper接口
- 实现数据报告快照远程服务接口Stub
- 配置RestTemplate用于调用外部HTTP服务
- 完善日志记录和异常处理,确保任务稳定执行
1 parent bff534ab
Showing 26 changed files with 1542 additions and 1 deletions
package cn.com.glsx.dj.peanalysis.dto.analysis;
import cn.com.glsx.dj.peanalysis.model.DataReportBrandSnapshot;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.io.Serializable;
/**
* 数据报告-品牌维度汇总响应。
*
* @author lyj
* @since 2026/03/24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class DataReportBrandSummaryResp extends DataReportBrandSnapshot implements Serializable {
private static final long serialVersionUID = 1L;
}
package cn.com.glsx.dj.peanalysis.dto.analysis;
import cn.com.glsx.dj.peanalysis.model.DataReportBusinessSnapshot;
import lombok.*;
import java.io.Serializable;
/**
* 数据报告-业务维度汇总响应。
*
* @author lyj
* @since 2026/03/24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class DataReportBusinessSummaryResp extends DataReportBusinessSnapshot implements Serializable {
private static final long serialVersionUID = 1L;
}
package cn.com.glsx.dj.peanalysis.dto.analysis;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* 数据报告生成请求参数。
*
* @author lyj
* @since 2026/03/24
*/
@Data
public class DataReportGenerateReq implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 报告类型:1-周报,2-月报。
*/
@NotNull(message = "报告类型不能为空")
@ApiModelProperty(notes = "报告类型:1-周报,2-月报")
private Byte reportType;
/**
* 周期键,例如 2026W12、2026M03。
*/
@NotBlank(message = "周期键不能为空")
@ApiModelProperty(notes = "周期键,例如 2026W12、2026M03")
private String periodKey;
/**
* 统计周期开始时间。
*/
@ApiModelProperty(notes = "统计周期开始时间")
private Date periodStart;
/**
* 统计周期结束时间。
*/
@ApiModelProperty(notes = "统计周期结束时间")
private Date periodEnd;
/**
* 操作人,定时任务可传 SYSTEM。
*/
@NotBlank(message = "操作人不能为空")
@ApiModelProperty(notes = "操作人,定时任务可传 SYSTEM")
private String operator;
}
package cn.com.glsx.dj.peanalysis.dto.analysis;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 数据报告查询请求参数。
*
* @author lyj
* @since 2026/03/24
*/
@Data
@ToString
public class DataReportQueryReq implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 报告类型:1-周报,2-月报。
*/
@NotNull(message = "报告类型不能为空")
@ApiModelProperty(notes = "报告类型:1-周报,2-月报")
private Byte reportType;
/**
* 周期键,例如 2026W12、2026M03。
*/
@NotBlank(message = "周期键不能为空")
@ApiModelProperty(notes = "周期键,例如 2026W12、2026M03")
private String periodKey;
/**
* 业务类型:1-延保,2-轻改,3-权益。
*/
@NotNull(message = "业务类型不能为空")
@ApiModelProperty(notes = "业务类型:1-延保,2-轻改,3-权益")
private Byte businessType;
/**
* 品牌ID(查询品牌维度时可选)。
*/
@ApiModelProperty(notes = "品牌ID(查询品牌维度时可选)")
private Integer brandId;
}
package cn.com.glsx.dj.peanalysis.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 数据报告类型枚举。
*
* @author lyj
* @since 2026/03/24
*/
@Getter
@AllArgsConstructor
public enum DataReportTypeEnum {
/**
* 展业周报。
*/
WEEKLY((byte) 1, "weekly"),
/**
* 展业月报。
*/
MONTHLY((byte) 2, "monthly");
private final byte code;
private final String name;
public static DataReportTypeEnum fromCode(Byte code) {
if (code == null) {
return null;
}
for (DataReportTypeEnum item : values()) {
if (item.code == code) {
return item;
}
}
return null;
}
}
package cn.com.glsx.dj.peanalysis.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* 数据报告品牌维度快照实体。
*
* @author lyj
* @since 2026/03/24
*/
@Table(name = "dj_data_report_brand_snapshot")
@Accessors(chain = true)
@Data
@ToString(callSuper = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class DataReportBrandSnapshot implements Serializable {
/**
* 主键ID。
*/
@ApiModelProperty(notes = "主键ID")
@Id
private Integer id;
/**
* 报告类型:1-周报,2-月报。
*/
@ApiModelProperty(notes = "报告类型:1-周报,2-月报")
@Column(name = "report_type")
private Byte reportType;
/**
* 周期键,例如 2026W12、2026M03。
*/
@ApiModelProperty(notes = "周期键,例如 2026W12、2026M03")
@Column(name = "period_key")
private String periodKey;
/**
* 业务类型:1-延保,2-轻改,3-权益。
*/
@ApiModelProperty(notes = "业务类型:1-延保,2-轻改,3-权益")
@Column(name = "business_type")
private Byte businessType;
/**
* 品牌 ID 列表,支持单个或多个品牌(多个品牌时使用逗号分隔,如:"1,2,3")。
* 同一份周月报的某一项可能针对一个品牌,也可能同时针对多个品牌。
*/
@ApiModelProperty(notes = "品牌 ID 列表,支持单个或多个品牌(多个品牌时使用逗号分隔,如:\"1,2,3\")")
@Column(name = "brand_id")
private String brandId;
/**
* 品牌名称。
*/
@ApiModelProperty(notes = "品牌名称")
@Column(name = "brand_name")
private String brandName;
/**
* 品牌维度指标JSON。
*/
@ApiModelProperty(notes = "品牌维度指标JSON")
@Column(name = "metric_payload")
private String metricPayload;
/**
* 整体结论文本。
*/
@ApiModelProperty(notes = "整体结论文本")
@Column(name = "overall_conclusion")
private String overallConclusion;
/**
* 行动建议文本。
*/
@ApiModelProperty(notes = "行动建议文本")
@Column(name = "action_suggestion")
private String actionSuggestion;
/**
* 文本摘要生成任务ID
*/
@ApiModelProperty(notes = "文本摘要生成任务ID")
@Column(name = "summary_task_id")
private String summaryTaskId;
/**
* 文本摘要生成状态:0-待提交,1-处理中,2-成功,3-失败。
*/
@ApiModelProperty(notes = "文本摘要生成状态:0-待提交,1-处理中,2-成功,3-失败")
@Column(name = "summary_task_status")
private Integer summaryTaskStatus;
@ApiModelProperty(notes = "最大重试次数")
@Column(name = "max_try")
private Integer maxTry;
/**
* 快照版本号,用于统计口径变更时的版本管理。
*/
@ApiModelProperty(notes = "快照版本号,用于统计口径变更时的版本管理")
@Column(name = "version")
private Integer version;
/**
* 快照生成时间。
*/
@ApiModelProperty(notes = "快照生成时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "generated_at")
private Date generatedAt;
/**
* 创建人。
*/
@ApiModelProperty(notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间。
*/
@ApiModelProperty(notes = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人。
*/
@ApiModelProperty(notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间。
*/
@ApiModelProperty(notes = "修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标记:N-未删除,D-已删除。
*/
@ApiModelProperty(notes = "删除标记:N-未删除,D-已删除")
@Column(name = "deleted_flag")
private String deletedFlag;
private static final long serialVersionUID = 1L;
}
package cn.com.glsx.dj.peanalysis.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* 数据报告业务维度快照实体。
*
* @author lyj
* @since 2026/03/24
*/
@Table(name = "dj_data_report_business_snapshot")
@Accessors(chain = true)
@Data
@ToString(callSuper = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class DataReportBusinessSnapshot implements Serializable {
/**
* 主键ID。
*/
@ApiModelProperty(notes = "主键ID")
@Id
private Integer id;
/**
* 报告类型:1-周报,2-月报。
*/
@ApiModelProperty(notes = "报告类型:1-周报,2-月报")
@Column(name = "report_type")
private Byte reportType;
/**
* 周期键,例如 2026W12、2026M03。
*/
@ApiModelProperty(notes = "周期键,例如 2026W12、2026M03")
@Column(name = "period_key")
private String periodKey;
/**
* 统计周期开始时间。
*/
@ApiModelProperty(notes = "统计周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "period_start")
private Date periodStart;
/**
* 统计周期结束时间。
*/
@ApiModelProperty(notes = "统计周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "period_end")
private Date periodEnd;
/**
* 业务类型:1-延保,2-轻改,3-权益。
*/
@ApiModelProperty(notes = "业务类型:1-延保,2-轻改,3-权益")
@Column(name = "business_type")
private Byte businessType;
/**
* 结构化汇总数据JSON。
*/
@ApiModelProperty(notes = "结构化汇总数据JSON")
@Column(name = "summary_payload")
private String summaryPayload;
/**
* 快照生成时间。
*/
@ApiModelProperty(notes = "快照生成时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "generated_at")
private Date generatedAt;
/**
* 创建人。
*/
@ApiModelProperty(notes = "创建人")
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间。
*/
@ApiModelProperty(notes = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人。
*/
@ApiModelProperty(notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间。
*/
@ApiModelProperty(notes = "修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标记:N-未删除,D-已删除。
*/
@ApiModelProperty(notes = "删除标记:N-未删除,D-已删除")
@Column(name = "deleted_flag")
private String deletedFlag;
private static final long serialVersionUID = 1L;
}
package cn.com.glsx.dj.peanalysis.remote;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportBrandSummaryResp;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportBusinessSummaryResp;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportGenerateReq;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportQueryReq;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import java.util.List;
/**
* 数据报告快照远程接口。
*
* @author lyj
* @since 2026/03/24
*/
@ApiService(value = "数据报告快照", owner = "lyj", protocol = ApiService.ProtocolEnum.dubbo)
public interface DataReportSnapshotRemote {
/**
* 按周期查询业务维度汇总。
*
* @param request 查询参数
* @return 业务维度汇总结果
*/
RpcResponse<List<DataReportBusinessSummaryResp>> queryBusinessSummary(DataReportQueryReq request);
/**
* 按周期查询品牌维度汇总。
*
* @param request 查询参数
* @return 品牌维度汇总结果
*/
RpcResponse<List<DataReportBrandSummaryResp>> queryBrandSummary(DataReportQueryReq request);
/**
* 手工触发快照生成(补算)。
*
* @param request 生成参数
* @return 处理结果
*/
RpcResponse<Boolean> generateSnapshot(DataReportGenerateReq request);
}
package cn.com.glsx.dj.peanalysis.config;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.collections4.MapUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.*;
/**
* 数据报告指标配置
* 用于配置不同业务类型需要查询的指标
*
* @author lyj
* @since 2026/03/26
*/
@Data
@Component
@ConfigurationProperties(prefix = "data.report.metrics")
@Slf4j
public class DataReportMetricsConfig {
/**
* 业务维度指标配置
* key: 业务类型 (1-延保,2-轻改,3-权益)
* value: 指标代码列表 [展业新店,展业老店,流失预警]
*
* 默认配置:所有业务都查询相同的三个门店指标
*/
private Map<Integer, List<String>> businessMetrics = Maps.newHashMap();
/**
* 品牌维度指标配置(统一结构)
* key: 业务类型 (1-延保,2-轻改,3-权益)
* value: Map<品牌 ID, 指标代码列表>
*
* 默认配置按业务 + 品牌分别定义:
* - 延保业务:
* - 问界:11 个指标
* - 智界/享界/尊界/尚界:5 个基本指标
* - 其他品牌:5 个基本指标
* - 轻改业务:问界 7 个指标
* - 权益业务:问界 5 个指标
*/
private Map<Integer, Map<String, List<String>>> brandMetrics = Maps.newHashMap();
/**
* 品牌 ID 与品牌名称的映射
* key: 品牌 ID
* value: 品牌名称
*/
private Map<String, String> brandNameMap = Maps.newHashMap();
/**
* 是否覆写
* true: 配置会覆盖默认配置
* false: 配置会追加到默认配置
*/
private Boolean isOverwrite = Boolean.FALSE;
@PostConstruct
public void initConfig() {
// 先设置默认值,然后允许配置文件覆盖
Map<Integer, List<String>> defaultBusinessMetrics = Maps.newHashMap();
Map<Integer, Map<String, List<String>>> defaultBrandMetrics = Maps.newHashMap();
Map<String, String> defaultBrandNameMap = Maps.newHashMap();
if (!isOverwrite) {
defaultBusinessMetrics = getDefaultBusinessMetrics();
defaultBrandMetrics = getDefaultBrandMetrics();
defaultBrandNameMap = getDefaultBrandNameMap();
}
// 初始化默认值
if (MapUtils.isNotEmpty(businessMetrics)) {
log.info("智能问数-周月报业务门店经营概况相关配置初始化");
defaultBusinessMetrics.putAll(businessMetrics);
}
if (MapUtils.isNotEmpty(brandMetrics)) {
log.info("智能问数-周月报品牌数据汇总相关配置初始化");
defaultBrandMetrics.putAll(brandMetrics);
}
if (MapUtils.isNotEmpty(brandNameMap)) {
log.info("智能问数-品牌组合映射初始化");
defaultBrandNameMap.putAll(brandNameMap);
}
businessMetrics = defaultBusinessMetrics;
brandMetrics = defaultBrandMetrics;
brandNameMap = defaultBrandNameMap;
}
/**
* 默认配置:品牌-名称
*/
private Map<String, String> getDefaultBrandNameMap() {
return Maps.newHashMap(
ImmutableMap.of(
"2695", "问界",
"2698,2741,2740", "智界/享界/尊界",
"2797", "尚界",
"-1", "通用"
)
);
}
/**
* 默认配置:业务-品牌-指标
*/
private Map<Integer, Map<String, List<String>>> getDefaultBrandMetrics() {
List<String> commonItemCodes = Lists.newArrayList(
DataStatsConstants.ITEM_CODE_A062, // 新车交付数
DataStatsConstants.ITEM_CODE_A063, // 售前触客数
DataStatsConstants.ITEM_CODE_A064 // 触客率
);
List<String> specialBrandItemCodes1 = ListUtils.union(commonItemCodes, Lists.newArrayList(
DataStatsConstants.ITEM_CODE_A066, // 整车延保-成交数
DataStatsConstants.ITEM_CODE_A067 // 整车延保-渗透率(门店)
));
List<String> specialBrandItemCodes2 = ListUtils.union(specialBrandItemCodes1, Lists.newArrayList(
DataStatsConstants.ITEM_CODE_A086, // 安心包-成交数
DataStatsConstants.ITEM_CODE_A092, // 安心包-渗透率(门店)
DataStatsConstants.ITEM_CODE_A070, // 电池-成交数
DataStatsConstants.ITEM_CODE_A094, // 电池-渗透率(门店)
DataStatsConstants.ITEM_CODE_A087, // 轮胎成交数
DataStatsConstants.ITEM_CODE_A093 // 轮胎渗透率(门店)
));
List<String> specialBrandItemCodes3 = ListUtils.union(commonItemCodes, Lists.newArrayList(
// DataStatsConstants.ITEM_CODE_A086, // 广联权益成交数
// DataStatsConstants.ITEM_CODE_A092 // 广联权益渗透率
));
List<String> specialBrandItemCodes4 = ListUtils.union(commonItemCodes, Lists.newArrayList(
// DataStatsConstants.ITEM_CODE_A095, // 升级率
// DataStatsConstants.ITEM_CODE_A098, // 交付客单价
DataStatsConstants.ITEM_CODE_A076, // 升级客单价
DataStatsConstants.ITEM_CODE_A0125 // 触客客单价
));
Map<String, List<String>> yanbaoConfig = Maps.newHashMap(ImmutableMap.of(
"2695", specialBrandItemCodes2, // 问界
"2698,2741,2740", specialBrandItemCodes1, // 智界/享界/尊界
"2797", specialBrandItemCodes1, // 尚界
"-1", specialBrandItemCodes1 // 通用
)
);
HashMap<String, List<String>> quanyiConfig = Maps.newHashMap(ImmutableMap.of(
"2695", specialBrandItemCodes3 // 问界
)
);
HashMap<String, List<String>> qinggaiConfig = Maps.newHashMap(ImmutableMap.of(
"2695", specialBrandItemCodes4 // 问界
)
);
return Maps.newHashMap(ImmutableMap.of(1, yanbaoConfig, 2, quanyiConfig, 3, qinggaiConfig));
}
/**
* 默认配置:业务-门店指标
*/
private Map<Integer, List<String>> getDefaultBusinessMetrics() {
List<String> commonItemCodes = Lists.newArrayList(
DataStatsConstants.ITEM_CODE_A0126, // 展业新店
DataStatsConstants.ITEM_CODE_A0127, // 展业老店
DataStatsConstants.ITEM_CODE_A0128 // 流失预警
);
return Maps.newHashMap(
ImmutableMap.of(
1, commonItemCodes,
2, commonItemCodes,
3, commonItemCodes
)
);
}
public List<String> getBusinessMetrics(Integer bizType) {
return businessMetrics.get(bizType);
}
public Map<String, List<String>> getBrandItemCodes(Integer bizType) {
return brandMetrics.get(bizType);
}
public String getBrandName(String brandId) {
return brandNameMap.getOrDefault(brandId, "未知品牌");
}
}
package cn.com.glsx.dj.peanalysis.config;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Configurable;
import java.util.List;
......@@ -148,6 +147,16 @@ public class DataStatsConstants {
/** 售后转化率 */
public static final String ITEM_CODE_A0105 = "A0105";
// ========== 业务维度指标代码 ==========
/** 展业新店 */
public static final String ITEM_CODE_A0126 = "A0126";
/** 展业老店 */
public static final String ITEM_CODE_A0127 = "A0127";
/** 流失预警门店 */
public static final String ITEM_CODE_A0128 = "A0128";
/** 全业务产值 */
public static final String ITEM_CODE_A0018 = "A0018";
......@@ -158,6 +167,9 @@ public class DataStatsConstants {
/** 全业务门店数 */
public static final String ITEM_CODE_A0025 = "A0025";
/** 触客客单价 */
public static final String ITEM_CODE_A0125 = "A0125";
/**
* 指定业务场景+聚合类型查询品类code
* bizs:1.延保 2.轻改 3.权益 4.二手车 必传
......
package cn.com.glsx.dj.peanalysis.config;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* AI 文本摘要服务配置
* 用于配置二方 HTTP 接口地址
*
* @author lyj
* @since 2026/03/27
*/
@Data
@Component
@ConfigurationProperties(prefix = "ai.text.summary")
@Slf4j
public class DateReportAiTextSummaryConfig {
/**
* AI 文本摘要服务基础 URL
* 默认值:http://192.168.3.226:8798/rpc-omni-ai
*/
private String baseUrl = "http://192.168.3.226:8798/rpc-omni-ai";
/**
* 启动任务接口路径
* 默认值:/api/inspection/llm/launch_task
*/
private String launchTaskPath = "/api/inspection/llm/launch_task?businessType=301";
/**
* 查询结果接口路径
* 默认值:/api/inspection/llm/get_task_result
*/
private String queryResultPath = "/api/inspection/llm/get_task_result";
/**
* 完整的启动任务 URL
*/
private String launchTaskUrl;
/**
* 完整的查询结果 URL
*/
private String queryResultUrl;
@PostConstruct
public void init() {
this.launchTaskUrl = baseUrl + launchTaskPath;
this.queryResultUrl = baseUrl + queryResultPath;
log.info("AI 文本摘要服务配置初始化完成,launchTaskUrl: {}, queryResultUrl: {}",
launchTaskUrl, queryResultUrl);
}
}
package cn.com.glsx.dj.peanalysis.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
/**
* RestTemplate配置类。
* 配置HTTP客户端用于调用外部服务
*
* @author lyj
* @since 2026/03/24
*/
@Configuration
public class RestTemplateConfig {
/**
* 创建RestTemplate Bean。
* 配置连接超时和读取超时
*
* @return RestTemplate实例
*/
@Bean
public RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(clientHttpRequestFactory());
// 设置消息转换器,优先使用 JSON
List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
messageConverters.add(new StringHttpMessageConverter(StandardCharsets.UTF_8));
restTemplate.setMessageConverters(messageConverters);
return restTemplate;
}
/**
* 创建HTTP请求工厂。
* 配置连接参数
*
* @return ClientHttpRequestFactory实例
*/
@Bean
public ClientHttpRequestFactory clientHttpRequestFactory() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(15000); // 连接超时15秒
factory.setReadTimeout(30000); // 读取超时30秒
return factory;
}
}
\ No newline at end of file
package cn.com.glsx.dj.peanalysis.enums;
import cn.com.glsx.dj.peanalysis.config.DataStatsConstants;
import lombok.Getter;
/**
* 数据报告指标枚举
*
* @author lyj
* @since 2026/03/26
*/
@Getter
public enum DataReportMetricEnum {
// ========== 业务维度指标 ==========
STORE_NEW(DataStatsConstants.ITEM_CODE_A0126, "展业新店"),
STORE_ACTIVE(DataStatsConstants.ITEM_CODE_A0127, "展业老店"),
STORE_WARNING(DataStatsConstants.ITEM_CODE_A0128, "流失预警"),
// ========== 通用指标 ==========
NEW_CAR_DELIVERY(DataStatsConstants.ITEM_CODE_A062, "新车交付数"),
PRE_SALES_CONTACT(DataStatsConstants.ITEM_CODE_A063, "售前触客数"),
CONTACT_RATE(DataStatsConstants.ITEM_CODE_A064, "触客率"),
DEAL_COUNT(DataStatsConstants.ITEM_CODE_A075, "成交数"),
PENETRATION_RATE(DataStatsConstants.ITEM_CODE_A077, "渗透率"),
CONVERSION_RATE(DataStatsConstants.ITEM_CODE_A085, "转化率"),
UPGRADE_AVG_PRICE(DataStatsConstants.ITEM_CODE_A076, "升级客单价"),
AVG_PRICE(DataStatsConstants.ITEM_CODE_A095, "平均客单价"),
DELIVERY_AVG_PRICE(DataStatsConstants.ITEM_CODE_A036, "交付客单价"),
// ========== 延保业务指标 ==========
WARRANTY_PENETRATION(DataStatsConstants.ITEM_CODE_A067, "整车延保渗透率"),
WARRANTY_DEAL_COUNT(DataStatsConstants.ITEM_CODE_A066, "整车延保成交数"),
WARRANTY_CONVERSION(DataStatsConstants.ITEM_CODE_A099, "整车延保转化率"),
BATTERY_WARRANTY_PENETRATION(DataStatsConstants.ITEM_CODE_A094, "电池延保渗透率"),
BATTERY_WARRANTY_DEAL(DataStatsConstants.ITEM_CODE_A070, "电池延保成交数"),
BATTERY_CONVERSION(DataStatsConstants.ITEM_CODE_A091, "电池延保转化率"),
ANXIN_PACKAGE_PENETRATION(DataStatsConstants.ITEM_CODE_A092, "安心包渗透率"),
ANXIN_PACKAGE_DEAL(DataStatsConstants.ITEM_CODE_A086, "安心包成交数"),
ANXIN_CONVERSION(DataStatsConstants.ITEM_CODE_A089, "安心包转化率"),
TIRE_DEAL_COUNT(DataStatsConstants.ITEM_CODE_A087, "轮胎成交数"),
TIRE_PENETRATION(DataStatsConstants.ITEM_CODE_A093, "轮胎险渗透率"),
TIRE_CONVERSION(DataStatsConstants.ITEM_CODE_A090, "轮胎转化率"),
// ========== 轻改业务指标 ==========
WINDOW_FILM_DEAL(DataStatsConstants.ITEM_CODE_A0106, "车窗膜成交数"),
WINDOW_FILM_VALUE(DataStatsConstants.ITEM_CODE_A0107, "车窗膜产值"),
WINDOW_FILM_PENETRATION(DataStatsConstants.ITEM_CODE_A0108, "车窗膜渗透率"),
WINDOW_FILM_CONVERSION(DataStatsConstants.ITEM_CODE_A0109, "车窗膜转化率"),
BODY_FILM_DEAL(DataStatsConstants.ITEM_CODE_A0111, "车身膜成交数"),
BODY_FILM_VALUE(DataStatsConstants.ITEM_CODE_A0112, "车身膜产值"),
BODY_FILM_PENETRATION(DataStatsConstants.ITEM_CODE_A0113, "车身膜渗透率"),
BODY_FILM_CONVERSION(DataStatsConstants.ITEM_CODE_A0114, "车身膜转化率"),
ACCESSORIES_DEAL(DataStatsConstants.ITEM_CODE_A0116, "精品附件成交数"),
ACCESSORIES_VALUE(DataStatsConstants.ITEM_CODE_A0117, "精品附件产值"),
ACCESSORIES_PENETRATION(DataStatsConstants.ITEM_CODE_A0118, "精品附件渗透率"),
ACCESSORIES_CONVERSION(DataStatsConstants.ITEM_CODE_A0119, "精品附件转化率");
/**
* 指标代码
*/
private final String code;
/**
* 指标名称
*/
private final String name;
DataReportMetricEnum(String code, String name) {
this.code = code;
this.name = name;
}
/**
* 根据代码获取枚举
*
* @param code 指标代码
* @return 枚举对象,如果未找到则返回 null
*/
public static DataReportMetricEnum fromCode(String code) {
if (code == null) {
return null;
}
for (DataReportMetricEnum metric : values()) {
if (metric.code.equals(code)) {
return metric;
}
}
return null;
}
public static String getNameByCode(String code) {
DataReportMetricEnum metricEnum = fromCode(code);
if (metricEnum == null) {
return null;
}
return metricEnum.getName();
}
}
package cn.com.glsx.dj.peanalysis.job;
import cn.com.glsx.dj.peanalysis.model.DataReportBrandSnapshot;
import cn.com.glsx.dj.peanalysis.service.DataReportAiTextSummaryService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* AI 文本摘要结果轮询 Job
* 轮询所有"处理中"状态的快照数据,调用二方接口查询结果并入库
*
* @author lyj
* @since 2026/03/27
*/
@Slf4j
@Component
@ElasticJobConf(
name = "AiTextSummaryPollJob",
cron = "0 */5 * * * ?", // 每 5 分钟执行一次(可根据需要调整)
description = "AI 文本摘要结果轮询",
overwrite = false
)
public class DataReportAiTextSummaryPollJob implements SimpleJob {
@Resource
private DataReportAiTextSummaryService dataReportAiTextSummaryService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("开始执行 AI 文本摘要结果轮询 Job");
try {
// 查询所有处理中状态的快照
List<DataReportBrandSnapshot> processingSnapshots = dataReportAiTextSummaryService.findProcessingSnapshots();
if (processingSnapshots == null || processingSnapshots.isEmpty()) {
log.info("没有处理中的快照数据");
return;
}
// 批量轮询快照结果
int successCount = dataReportAiTextSummaryService.pollProcessingSnapshots(processingSnapshots);
log.info("AI 文本摘要结果轮询完成,总数:{}, 成功:{}", processingSnapshots.size(), successCount);
} catch (Exception e) {
log.error("AI 文本摘要结果轮询 Job 执行失败", e);
throw e;
}
}
}
package cn.com.glsx.dj.peanalysis.job;
import cn.com.glsx.dj.peanalysis.model.DataReportBrandSnapshot;
import cn.com.glsx.dj.peanalysis.service.DataReportAiTextSummaryService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* AI 文本摘要任务提交 Job
* 遍历所有"待提交"状态的快照数据,调用二方接口触发异步任务
*
* @author lyj
* @since 2026/03/27
*/
@Slf4j
@Component
@ElasticJobConf(
name = "AiTextSummarySubmitJob",
cron = "0 */10 * * * ?", // 每 10 分钟执行一次(可根据需要调整)
description = "AI 文本摘要任务提交",
overwrite = false
)
public class DataReportAiTextSummarySubmitJob implements SimpleJob {
@Resource
private DataReportAiTextSummaryService dataReportAiTextSummaryService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("开始执行 AI 文本摘要任务提交 Job");
try {
// 查询所有待提交状态的快照
List<DataReportBrandSnapshot> pendingSnapshots = dataReportAiTextSummaryService.findPendingSnapshots();
if (pendingSnapshots == null || pendingSnapshots.isEmpty()) {
log.info("没有待提交的快照数据");
return;
}
// 批量提交快照
int successCount = dataReportAiTextSummaryService.submitPendingSnapshots(pendingSnapshots);
log.info("AI 文本摘要任务提交完成,总数:{}, 成功:{}", pendingSnapshots.size(), successCount);
} catch (Exception e) {
log.error("AI 文本摘要任务提交 Job 执行失败", e);
throw e;
}
}
}
package cn.com.glsx.dj.peanalysis.job;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportGenerateReq;
import cn.com.glsx.dj.peanalysis.service.DataReportSnapshotService;
import cn.hutool.core.date.DateUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
/**
* 数据报告月报快照生成任务。
*
* @author lyj
* @since 2026/03/24
*/
@Slf4j
@Component
@ElasticJobConf(name = "DataReportMonthlySnapshotJob", cron = "0 0 9 1 * ?", description = "每月1日09:00生成展业月报快照", overwrite = false)
public class DataReportMonthlySnapshotJob implements SimpleJob {
@Resource
private DataReportSnapshotService dataReportSnapshotService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("开始执行数据报告月报快照生成任务");
try {
// 构建上月的周期键(格式:YYYYMM,如2026M03)
String periodKey = buildLastMonthPeriodKey(shardingContext);
log.info("计算得到上月周期键:{}", periodKey);
// 构建生成请求参数
DataReportGenerateReq req = new DataReportGenerateReq();
req.setReportType((byte) 2); // 2-月报
req.setPeriodKey(periodKey);
req.setPeriodStart(DateUtil.beginOfMonth(DateUtil.offsetMonth(new Date(), -1)));
req.setPeriodEnd(DateUtil.endOfMonth(DateUtil.offsetMonth(new Date(), -1)));
req.setPeriodKey(periodKey);
req.setOperator("SYSTEM"); // 系统任务
// 调用服务生成快照
Boolean result = dataReportSnapshotService.generateSnapshot(req);
if (result) {
log.info("数据报告月报快照生成任务执行成功,periodKey:{}", periodKey);
} else {
log.error("数据报告月报快照生成任务执行失败,periodKey:{}", periodKey);
}
} catch (Exception e) {
log.error("数据报告月报快照生成任务执行异常", e);
throw e; // 重新抛出异常,让ElasticJob框架处理重试
}
}
/**
* 构建上月的周期键。
* 格式为YYYYMmm(如2026M03),其中mm为两位数的月份
*
* @return 上月周期键字符串
*/
private String buildLastMonthPeriodKey(ShardingContext shardingContext) {
Date date = shardingContext != null && shardingContext.getJobParameter() != null
? DateUtil.parseDate(shardingContext.getJobParameter())
: DateUtil.lastMonth();
// 格式化为YYYYMmm格式,如2026M03
String periodKey = DateUtil.format(date, "yyyy'M'MM");
log.debug("构建上月周期键:日期={}, 结果={}", date, periodKey);
return periodKey;
}
}
package cn.com.glsx.dj.peanalysis.job;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportGenerateReq;
import cn.com.glsx.dj.peanalysis.service.DataReportSnapshotService;
import cn.hutool.core.date.DateUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
/**
* 数据报告周报快照生成任务。
*
* @author lyj
* @since 2026/03/24
*/
@Slf4j
@Component
@ElasticJobConf(name = "DataReportWeeklySnapshotJob", cron = "0 0 9 ? * MON", description = "每周一09:00生成展业周报快照", overwrite = false)
public class DataReportWeeklySnapshotJob implements SimpleJob {
@Resource
private DataReportSnapshotService dataReportSnapshotService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("开始执行数据报告周报快照生成任务");
try {
// 构建上周的周期键(格式:YYYYWww,如2026W12)
String periodKey = buildLastWeekPeriodKey(shardingContext);
log.info("计算得到上周周期键:{}", periodKey);
// 构建生成请求参数
DataReportGenerateReq req = new DataReportGenerateReq();
req.setReportType((byte) 1); // 1-周报
req.setPeriodKey(periodKey);
req.setPeriodStart(DateUtil.beginOfMonth(DateUtil.offsetMonth(new Date(), -1)));
req.setPeriodEnd(DateUtil.endOfMonth(DateUtil.offsetMonth(new Date(), -1)));
req.setOperator("SYSTEM"); // 系统任务
// 调用服务生成快照
Boolean result = dataReportSnapshotService.generateSnapshot(req);
if (result) {
log.info("数据报告周报快照生成任务执行成功,periodKey:{}", periodKey);
} else {
log.error("数据报告周报快照生成任务执行失败,periodKey:{}", periodKey);
}
} catch (Exception e) {
log.error("数据报告周报快照生成任务执行异常", e);
throw e; // 重新抛出异常,让ElasticJob框架处理重试
}
}
/**
* 构建上周的周期键。
* 使用中国周计算标准(周一为一周的开始),格式为YYYYWww(如2026W12)
*
* @return 上周周期键字符串
*/
private String buildLastWeekPeriodKey(ShardingContext shardingContext) {
Date date = shardingContext != null && shardingContext.getJobParameter() != null
? DateUtil.parseDate(shardingContext.getJobParameter())
: DateUtil.lastWeek();
// 格式化为YYYYWww格式,如2026W12
String periodKey = DateUtil.format(date, "yyyy'W'ww");
log.debug("构建上周周期键:日期={}, 结果={}", date, periodKey);
return periodKey;
}
}
package cn.com.glsx.dj.peanalysis.mapper;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportQueryReq;
import cn.com.glsx.dj.peanalysis.model.DataReportBrandSnapshot;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 数据报告品牌维度快照Mapper。
*
* @author lyj
* @since 2026/03/24
*/
@Mapper
@Repository
public interface DataReportBrandSnapshotMapper extends OreMapper<DataReportBrandSnapshot> {
/**
* 按报告类型、周期和业务类型查询品牌快照列表。
*/
List<DataReportBrandSnapshot> queryByPeriodAndBusiness(DataReportQueryReq req);
List<DataReportBrandSnapshot> findByPeriodKeyAndBrand(DataReportBrandSnapshot req);
}
package cn.com.glsx.dj.peanalysis.mapper;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportQueryReq;
import cn.com.glsx.dj.peanalysis.model.DataReportBusinessSnapshot;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 数据报告业务维度快照Mapper。
*
* @author lyj
* @since 2026/03/24
*/
@Mapper
@Repository
public interface DataReportBusinessSnapshotMapper extends OreMapper<DataReportBusinessSnapshot> {
/**
* 按报告类型、周期和业务类型查询业务快照。
*/
List<DataReportBusinessSnapshot> queryByPeriodAndBusiness(DataReportQueryReq req);
DataReportBusinessSnapshot findByPeriodKey(@Param("periodKey") String periodKey, @Param("businessType") Byte businessType);
}
package cn.com.glsx.dj.peanalysis.remote;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportBrandSummaryResp;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportBusinessSummaryResp;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportGenerateReq;
import cn.com.glsx.dj.peanalysis.dto.analysis.DataReportQueryReq;
import cn.com.glsx.dj.peanalysis.service.DataReportSnapshotService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import javax.annotation.Resource;
import java.util.List;
/**
* 数据报告快照远程实现。
*
* @author lyj
* @since 2026/03/24
*/
@Slf4j
@DubboService(validation = "true", version = "1.0.0")
public class DataReportSnapshotRemoteImpl implements DataReportSnapshotRemote {
@Resource
private DataReportSnapshotService dataReportSnapshotService;
@Override
public RpcResponse<List<DataReportBusinessSummaryResp>> queryBusinessSummary(DataReportQueryReq request) {
log.info("远程调用:查询数据报告业务汇总开始");
try {
List<DataReportBusinessSummaryResp> result = dataReportSnapshotService.queryBusinessSummary(request);
log.info("远程调用:查询数据报告业务汇总成功,返回{}条记录", result != null ? result.size() : 0);
return RpcResponse.success(result); // Changed from RpcResponse.success(result) to RpcResponse.success(result)
} catch (Exception e) {
log.error("远程调用:查询数据报告业务汇总失败", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<List<DataReportBrandSummaryResp>> queryBrandSummary(DataReportQueryReq request) {
log.info("远程调用:查询数据报告品牌汇总开始");
try {
List<DataReportBrandSummaryResp> result = dataReportSnapshotService.queryBrandSummary(request);
log.info("远程调用:查询数据报告品牌汇总成功,返回{}条记录", result != null ? result.size() : 0);
return RpcResponse.success(result);
} catch (Exception e) {
log.error("远程调用:查询数据报告品牌汇总失败", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<Boolean> generateSnapshot(DataReportGenerateReq request) {
log.info("远程调用:生成数据报告快照开始");
try {
Boolean result = dataReportSnapshotService.generateSnapshot(request);
log.info("远程调用:生成数据报告快照完成,结果:{}", result);
return RpcResponse.success(result);
} catch (Exception e) {
log.error("远程调用:生成数据报告快照失败", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
}
......@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Service
@Slf4j
......@@ -36,6 +37,8 @@ public class GetDataStatsService {
DataResp<List<DataBusinessDTO>> dataResp;
// String url = OrePropertyConfigurer.getProperty("total.data.url", String.class, "http://dc.glsx.com.cn/data");
String url = OrePropertyConfigurer.getProperty("total.data.url", String.class, "http://192.168.3.211:8021/data");
long l = System.currentTimeMillis();
// post请求
String jsonResponse;
try {
......@@ -43,6 +46,8 @@ public class GetDataStatsService {
jsonResponse = HttpRequestUtils.postJson(url, jsonBody, new HashMap<>());
} catch (Exception e) {
throw new RpcServiceException("查询统计数据异常");
} finally {
log.info("查询统计数据耗时: {}ms", System.currentTimeMillis() - l);
}
dataResp = JSONUtil.toBean(jsonResponse, new TypeReference<DataResp<List<DataBusinessDTO>>>() {
}, true);
......@@ -52,6 +57,30 @@ public class GetDataStatsService {
return dataResp;
}
public List<DataBusinessDTO> getListData(DataBizQueryParamsDTO queryDataBiz) {
if (queryDataBiz == null) {
return new ArrayList<>();
}
String jsonBody = JSONUtil.toJsonStr(queryDataBiz);
return getListData(jsonBody);
}
/**
* 直接以 JSON 请求体查询指标系统并返回明细列表
* <p>
* 适用于需要传入字符串形式的聚合字段(例如 bizs/itemCodes 以逗号拼接)且保持 exts 维度返回的场景。
*/
public List<DataBusinessDTO> getListData(String jsonBody) {
try {
DataResp<List<DataBusinessDTO>> dataResp = this.getListDataResp(jsonBody);
return dataResp.getContent();
} catch (Exception e) {
log.error("查询统计数据异常,jsonBody={}", jsonBody, e);
throw new RpcServiceException("查询统计数据异常");
}
}
/**
* 通用并行调用方法 - 返回Map: 指标代码 -> 数据
* @param itemCodes 指标编码列表
......@@ -258,4 +287,33 @@ public class GetDataStatsService {
return resultMap;
}
/**
* 串行调用,拿到数据后分组处理
* @param itemCodes 指标编码列表
* @param queryDataBiz 请求参数
* @return
*/
public Map<String, List<DataBusinessDTO>> serialCallListMap(List<String> itemCodes, DataBizQueryParamsDTO queryDataBiz) {
String itemCodeParam = String.join(",", itemCodes);
Map<String, List<DataBusinessDTO>> resultMap = new ConcurrentHashMap<>();
DataBizQueryParamsDTO queryCopy = new DataBizQueryParamsDTO();
BeanUtil.copyProperties(queryDataBiz, queryCopy);
queryCopy.setItemCodes(itemCodeParam);
String jsonBody = JSONUtil.toJsonStr(queryCopy);
try {
DataResp<List<DataBusinessDTO>> dataResp = this.getListDataResp(jsonBody);
List<DataBusinessDTO> content = dataResp.getContent();
if (CollUtil.isEmpty(content)) {
log.info("itemCodeParam:{}, dataResp:{}", itemCodeParam, JSONUtil.toJsonPrettyStr(dataResp));
return null;
}
resultMap = content.stream().collect(Collectors.groupingBy(p -> p.getItemCode()));
} catch (Exception e) {
log.error("Error processing itemCodeParam: {}, cause: {}", itemCodeParam, ExceptionUtils.getStackTrace(e));
return resultMap;
}
return resultMap;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.dj.peanalysis.mapper.DataReportBrandSnapshotMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.peanalysis.model.DataReportBrandSnapshot">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="report_type" jdbcType="TINYINT" property="reportType"/>
<result column="period_key" jdbcType="VARCHAR" property="periodKey"/>
<result column="business_type" jdbcType="TINYINT" property="businessType"/>
<result column="brand_id" jdbcType="VARCHAR" property="brandId"/>
<result column="brand_name" jdbcType="VARCHAR" property="brandName"/>
<result column="metric_payload" jdbcType="LONGVARCHAR" property="metricPayload"/>
<result column="overall_conclusion" jdbcType="LONGVARCHAR" property="overallConclusion"/>
<result column="action_suggestion" jdbcType="LONGVARCHAR" property="actionSuggestion"/>
<result column="summary_task_id" jdbcType="VARCHAR" property="summaryTaskId"/>
<result column="summary_task_status" jdbcType="INTEGER" property="summaryTaskStatus"/>
<result column="max_try" jdbcType="INTEGER" property="maxTry"/>
<result column="generated_at" jdbcType="TIMESTAMP" property="generatedAt"/>
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="deleted_flag" jdbcType="CHAR" property="deletedFlag"/>
</resultMap>
<sql id="Base_Column_List">
id, report_type, period_key, business_type, brand_id, brand_name, metric_payload, overall_conclusion,
action_suggestion, summary_task_id, summary_task_status, generated_at, created_by, created_date, updated_by,
max_try, updated_date, deleted_flag
</sql>
<select id="queryByPeriodAndBusiness" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM dj_data_report_brand_snapshot
WHERE report_type = #{reportType}
AND period_key = #{periodKey}
AND business_type = #{businessType}
<if test="brandId != null">
AND brand_id = #{brandId}
</if>
AND deleted_flag = 'N'
ORDER BY id DESC
</select>
<select id="findByPeriodKeyAndBrand" resultMap="BaseResultMap">
select * from dj_data_report_brand_snapshot
where period_key = #{periodKey}
and brand_id = #{brandId}
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.dj.peanalysis.mapper.DataReportBusinessSnapshotMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.peanalysis.model.DataReportBusinessSnapshot">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="report_type" jdbcType="TINYINT" property="reportType"/>
<result column="period_key" jdbcType="VARCHAR" property="periodKey"/>
<result column="period_start" jdbcType="TIMESTAMP" property="periodStart"/>
<result column="period_end" jdbcType="TIMESTAMP" property="periodEnd"/>
<result column="business_type" jdbcType="TINYINT" property="businessType"/>
<result column="summary_payload" jdbcType="LONGVARCHAR" property="summaryPayload"/>
<result column="generated_at" jdbcType="TIMESTAMP" property="generatedAt"/>
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="deleted_flag" jdbcType="CHAR" property="deletedFlag"/>
</resultMap>
<sql id="Base_Column_List">
id, report_type, period_key, period_start, period_end, business_type,
summary_payload, generated_at, created_by,
created_date, updated_by, updated_date, deleted_flag
</sql>
<select id="queryByPeriodAndBusiness" parameterType="cn.com.glsx.dj.peanalysis.dto.analysis.DataReportQueryReq"
resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM dj_data_report_business_snapshot
WHERE report_type = #{reportType}
AND period_key = #{periodKey}
AND business_type = #{businessType}
AND deleted_flag = 'N'
ORDER BY id DESC
</select>
<select id="findByPeriodKey" resultMap="BaseResultMap">
select * from dj_data_report_business_snapshot
WHERE period_key = #{periodKey}
AND business_type = #{businessType}
AND deleted_flag = 'N'
ORDER BY id DESC
limit 1
</select>
</mapper>
\ No newline at end of file
package cn.com.glsx.dj.peanalysis.service;
import cn.com.glsx.dj.peanalysis.job.DataReportAiTextSummaryPollJob;
import cn.com.glsx.dj.peanalysis.job.DataReportAiTextSummarySubmitJob;
import cn.com.glsx.dj.peanalysis.job.DataReportMonthlySnapshotJob;
import cn.com.glsx.dj.peanalysis.job.DataReportWeeklySnapshotJob;
import cn.com.glsx.dj.peanalysis.remote.BaseRemoteTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 数据报告快照服务单元测试。
*
* @author lyj
* @since 2026/03/24
*/
public class DataReportSnapshotServiceTest extends BaseRemoteTest {
@Autowired
private DataReportSnapshotService dataReportSnapshotService;
@Autowired
private DataReportAiTextSummaryPollJob dataReportAiTextSummaryPollJob;
@Autowired
private DataReportAiTextSummarySubmitJob dataReportAiTextSummarySubmitJob;
@Autowired
private DataReportMonthlySnapshotJob dataReportMonthlySnapshotJob;
@Autowired
private DataReportWeeklySnapshotJob dataReportWeeklySnapshotJob;
@Test
public void dataReportMonthlySnapshotJobTest() {
dataReportMonthlySnapshotJob.execute(null);
}
@Test
public void dataReportWeeklySnapshotJobTest() {
dataReportWeeklySnapshotJob.execute(null);
}
@Test
public void dataReportAiTextSummarySubmitJobTest() {
dataReportAiTextSummarySubmitJob.execute(null);
}
@Test
public void dataReportAiTextSummaryPollJobTest() {
dataReportAiTextSummaryPollJob.execute(null);
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!