Commit 24e9d0e1 by 叶立庆

Merge branch 'v5.7.1' into 'master'

上线合并

See merge request !7
2 parents 6ddca1da 73a2204b
Showing 49 changed files with 2476 additions and 12 deletions
......@@ -7,7 +7,7 @@
</parent>
<groupId>cn.com.glsx.dj.peanalysis</groupId>
<artifactId>rpc-dj-pe-analysis-api</artifactId>
<version>5.7.0-SNAPSHOT</version>
<version>5.7.1-SNAPSHOT</version>
<name>rpc-dj-pe-analysis-api</name>
<properties>
<deploy.scanPackage>cn.com.glsx.dj.peanalysis.remote</deploy.scanPackage>
......
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 com.fasterxml.jackson.annotation.JsonFormat;
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;
import java.util.Date;
/**
* 数据报告生成请求参数。
*
* @author lyj
* @since 2026/03/24
*/
@Data
@ToString
public class DataReportGenerateReq implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 报告类型:1-周报,2-月报。
* @see cn.com.glsx.dj.peanalysis.enums.DataReportTypeEnum
*/
@NotNull(message = "报告类型不能为空")
@ApiModelProperty(notes = "报告类型:1-周报,2-月报")
private Byte reportType;
/**
* 周期键,例如 2026W12、2026M03。
*/
@NotBlank(message = "周期键不能为空")
@ApiModelProperty(notes = "周期键,例如 2026W12、2026M03")
private String periodKey;
/**
* 统计周期开始时间。
*/
@ApiModelProperty(notes = "统计周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date periodStart;
/**
* 统计周期结束时间。
*/
@ApiModelProperty(notes = "统计周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
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 org.springframework.format.annotation.DateTimeFormat;
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
@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;
/**
* 统计周期开始时间。
*/
@ApiModelProperty(notes = "统计周期开始时间")
@NotNull(message = "统计周期开始时间不能为空")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date periodStart;
/**
* 统计周期结束时间。
*/
@ApiModelProperty(notes = "统计周期结束时间")
@NotNull(message = "统计周期结束时间不能为空")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date periodEnd;
/**
* 业务类型:1-延保,2-轻改,3-权益。
*/
@NotNull(message = "业务类型不能为空")
@ApiModelProperty(notes = "业务类型:1-延保,2-轻改,3-权益")
private Byte businessType;
/**
* 品牌ID(查询品牌维度时可选)。
*/
@ApiModelProperty(notes = "品牌ID(查询品牌维度时可选)")
private Integer brandId;
/**
* 生成状态:0未生成,1-生成中,2-生成成功,3-生成失败。
*/
private Integer generateStatus;
}
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;
private final String currentDesc;
private final String lastDesc;
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;
/**
* 品牌排序号,用于控制品牌在报告中的显示顺序。
*/
@ApiModelProperty(notes = "品牌排序号,用于控制品牌在报告中的显示顺序。数值越小越靠前,默认为 0")
@Column(name = "order_num")
private Integer orderNum;
/**
* 品牌维度指标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;
/**
* 快照生成状态:0-未生成,1-生成中,2-生成成功,3-生成失败。
*/
@Column(name = "generate_status")
private Integer generateStatus;
/**
* 创建人。
*/
@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 java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
@Data
@Table(name = "dj_report_subscribe_config")
public class DjReportSubscribeConfig implements Serializable {
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 用户ID
*/
@Column(name = "user_id")
private String userId;
/**
* 用户名称
*/
@Column(name = "user_name")
private String userName;
/**
* 用户手机号
*/
@Column(name = "user_phone")
private String userPhone;
/**
* 展业周报订阅状态:0:未订阅,1:已订阅
*/
@Column(name = "weekly_report_subscribe")
private Integer weeklyReportSubscribe;
/**
* 展业月报订阅状态:0:未订阅,1:已订阅
*/
@Column(name = "monthly_report_subscribe")
private Integer monthlyReportSubscribe;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createdTime;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updatedTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
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.remote;
import cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiParams;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
@ApiService(value = "数据报告订阅", version = "1.0.0", protocol = ApiService.ProtocolEnum.dubbo, type = ApiService.ApiTypeEnum.DUBBO, alias = "ReportSubscribeRemote", owner = "system")
public interface ReportSubscribeRemote {
@ApiMethod("更新展业周报订阅状态")
@ApiResponse("更新结果")
@ApiParams({
@ApiParam(name = "userId", notes = "用户ID", dataType = ApiParam.DataTypeEnum.INTEGER, required = true),
@ApiParam(name = "userName", notes = "用户名称", dataType = ApiParam.DataTypeEnum.STRING, required = true),
@ApiParam(name = "userPhone", notes = "用户手机号", dataType = ApiParam.DataTypeEnum.STRING, required = true),
@ApiParam(name = "subscribeStatus", notes = "订阅状态:0:未订阅,1:已订阅", dataType = ApiParam.DataTypeEnum.INTEGER, required = true)
})
RpcResponse<Boolean> updateWeeklyReportSubscribe(String userId, String userName, String userPhone, Integer subscribeStatus);
@ApiMethod("更新展业月报订阅状态")
@ApiResponse("更新结果")
@ApiParams({
@ApiParam(name = "userId", notes = "用户ID", dataType = ApiParam.DataTypeEnum.INTEGER, required = true),
@ApiParam(name = "userName", notes = "用户名称", dataType = ApiParam.DataTypeEnum.STRING, required = true),
@ApiParam(name = "userPhone", notes = "用户手机号", dataType = ApiParam.DataTypeEnum.STRING, required = true),
@ApiParam(name = "subscribeStatus", notes = "订阅状态:0:未订阅,1:已订阅", dataType = ApiParam.DataTypeEnum.INTEGER, required = true)
})
RpcResponse<Boolean> updateMonthlyReportSubscribe(String userId, String userName, String userPhone, Integer subscribeStatus);
@ApiMethod("查询用户订阅配置")
@ApiResponse("订阅配置")
@ApiParams({
@ApiParam(name = "userId", notes = "用户ID", dataType = ApiParam.DataTypeEnum.INTEGER, required = true)
})
RpcResponse<DjReportSubscribeConfig> getSubscribeConfig(String userId);
}
\ No newline at end of file
......@@ -15,9 +15,11 @@
<platform-merchants.api.version>5.5.1-SNAPSHOT</platform-merchants.api.version>
<smartcarlife.api.version>5.6.4-SNAPSHOT</smartcarlife.api.version>
<mindworkplate.api.version>5.7.0-SNAPSHOT</mindworkplate.api.version>
<pe-analysis.api.version>5.7.0-SNAPSHOT</pe-analysis.api.version>
<pe-analysis.api.version>5.7.1-SNAPSHOT</pe-analysis.api.version>
<strategy.api.version>5.7.0-SNAPSHOT</strategy.api.version>
<supervisor.api.version>1.0.0-SNAPSHOT</supervisor.api.version>
<wechat.api.version>4.54.0-SNAPSHOT</wechat.api.version>
<entmicro.api.version>5.3.0-SNAPSHOT</entmicro.api.version>
</properties>
<dependencies>
......@@ -87,5 +89,15 @@
<artifactId>rpc-dj-supervisor-api</artifactId>
<version>${supervisor.api.version}</version>
</dependency>
</dependencies>
<dependency>
<groupId>cn.com.glsx</groupId>
<artifactId>rpc-scrm-wechat-api</artifactId>
<version>${wechat.api.version}</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.entmicro</groupId>
<artifactId>rpc-scrm-entmicro-api</artifactId>
<version>${entmicro.api.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package cn.com.glsx.dj.peanalysis.config;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Configurable;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
......@@ -148,6 +148,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 +168,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.二手车 必传
......@@ -237,4 +250,22 @@ public class DataStatsConstants {
return res;
}
private final static List<String> RATE_VALUE_ITEM_CODES = Lists.newArrayList(
ITEM_CODE_A064, ITEM_CODE_A085, ITEM_CODE_A077,
ITEM_CODE_A067, ITEM_CODE_A0100, ITEM_CODE_A099,
ITEM_CODE_A094, ITEM_CODE_A0103, ITEM_CODE_A091,
ITEM_CODE_A092, ITEM_CODE_A0101, ITEM_CODE_A089,
ITEM_CODE_A093, ITEM_CODE_A0102, ITEM_CODE_A090,
ITEM_CODE_A0108, ITEM_CODE_A0109, ITEM_CODE_A0110,
ITEM_CODE_A0118, ITEM_CODE_A0119, ITEM_CODE_A0120,
ITEM_CODE_A0113, ITEM_CODE_A0114, ITEM_CODE_A0115,
ITEM_CODE_A0104, ITEM_CODE_A0105);
public static boolean isRateItemCode(String itemCode){
if (StringUtils.isBlank(itemCode)) {
return false;
}
return RATE_VALUE_ITEM_CODES.contains(itemCode);
}
}
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.config.dubbo;
import cn.com.glsx.entmicro.remote.EntmicroStaffRemote;
import cn.com.glsx.scrm.wechat.remote.WorkWechatMessageRemote;
import lombok.RequiredArgsConstructor;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* scrm dubbo 配置
*/
@Configuration
@RequiredArgsConstructor
public class ScrmDubboConfig {
private final ReferenceBuilderFactory factory;
@Bean
public EntmicroStaffRemote getEntmicroStaffRemote() {
return factory.builder(EntmicroStaffRemote.class)
.check(false)
.timeout(30000)
.version("1.0.0")
.build();
}
@Bean
public WorkWechatMessageRemote workWechatMessageRemote() {
return factory.builder(WorkWechatMessageRemote.class)
.check(false)
.timeout(30000)
.version("1.0.0")
.build();
}
}
\ No newline at end of file
package cn.com.glsx.dj.peanalysis.enums;
import cn.com.glsx.dj.peanalysis.config.DataStatsConstants;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* 数据报告指标枚举
* <p>
* 支持混合模式:
* 1. 枚举中定义常用指标(编译时固定)
* 2. 支持从环境变量/配置文件读取额外指标(运行时动态加载)
* 3. 通过 getAllMetrics() 方法获取完整指标列表(枚举 + 配置)
*
* @author lyj
* @since 2026/03/26
*/
@Getter
@Slf4j
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, "交付客单价"),
CUSTOM_AVG_PRICE(DataStatsConstants.ITEM_CODE_A0125, "触客客单价"),
// ========== 延保业务指标 ==========
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;
}
// ==================== 动态指标注册表 ====================
/**
* 动态指标注册表
* key: 指标代码
* value: 指标名称
* 用于存储从配置文件或环境变量中读取的额外指标
*/
private static final Map<String, String> DYNAMIC_METRICS = new ConcurrentHashMap<>();
/**
* 注册动态指标(配置优先模式)
* <p>
* 如果指标代码已存在于枚举中,会用配置的名称覆盖枚举的名称
*
* @param code 指标代码
* @param name 指标名称
*/
public static void registerDynamicMetric(String code, String name) {
if (StringUtils.isNotBlank(code) && StringUtils.isNotBlank(name)) {
// 检查是否与枚举中的指标冲突
DataReportMetricEnum existingEnum = fromCode(code);
if (existingEnum != null) {
log.warn("智能问数-动态指标[{}]与枚举中的指标[{}]代码相同,配置优先,将使用配置名称[{}]覆盖枚举名称",
code, existingEnum.getName(), name);
}
DYNAMIC_METRICS.put(code, name);
log.debug("智能问数-注册动态指标: {} - {}", code, name);
}
}
/**
* 根据代码获取指标名称(支持枚举 + 动态指标)
*
* @param code 指标代码
* @return 指标名称,如果未找到则返回 null
*/
public static String getMetricName(String code) {
if (code == null) {
return null;
}
// 优先从动态指标中查找(配置优先)
String dynamicName = DYNAMIC_METRICS.get(code);
if (dynamicName != null) {
return dynamicName;
}
// 再从枚举中查找
DataReportMetricEnum enumMetric = fromCode(code);
if (enumMetric != null) {
return enumMetric.getName();
}
return null;
}
/**
* 获取所有指标(枚举 + 动态指标)
*
* @return 完整的指标映射表
*/
public static Map<String, String> getAllMetrics() {
Map<String, String> allMetrics = new LinkedHashMap<>();
// 先添加枚举中的指标
for (DataReportMetricEnum metric : values()) {
allMetrics.put(metric.getCode(), metric.getName());
}
// 再添加动态指标(会覆盖同名的枚举指标)
allMetrics.putAll(DYNAMIC_METRICS);
return Collections.unmodifiableMap(allMetrics);
}
}
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 = "DataReportAiTextSummaryPollJob",
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 = "DataReportAiTextSummarySubmitJob",
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.mapper.DataReportBrandSnapshotMapper;
import cn.com.glsx.dj.peanalysis.mapper.DataReportBusinessSnapshotMapper;
import cn.com.glsx.dj.peanalysis.model.DataReportBrandSnapshot;
import cn.com.glsx.dj.peanalysis.model.DataReportBusinessSnapshot;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 刷新报告生成状态
*
* @author lyj
* @since 2026/04/03
*/
@Slf4j
@Component
@ElasticJobConf(
name = "DataReportGenerateStatusRefreshJob",
cron = "0 */10 * * * ?",
description = "刷新报告生成状态",
overwrite = false
)
public class DataReportGenerateStatusRefreshJob implements SimpleJob {
@Resource
private DataReportBusinessSnapshotMapper businessSnapshotMapper;
@Resource
private DataReportBrandSnapshotMapper brandSnapshotMapper;
@Override
public void execute(ShardingContext shardingContext) {
log.info("开始刷新报告生成状态 Job");
try {
// 查询所有处理中的业务数据
List<DataReportBusinessSnapshot> processingBusinessData = getProcessingBusinessData();
if (CollectionUtils.isEmpty(processingBusinessData)) {
log.info("没有处理中的业务数据");
return;
}
Map<String, List<DataReportBusinessSnapshot>> groupByKey = processingBusinessData.stream()
.collect(Collectors.groupingBy(p -> p.getReportType() + "_" + p.getPeriodKey()));
groupByKey.forEach((key, itemList) -> {
// 查询其下所有品牌数据,是否全部已完成,如果全部完成,则更新快照状态为完成
List<DataReportBrandSnapshot> brandData = getBrandDataByBusiness(itemList);
if (CollectionUtils.isNotEmpty(brandData)) {
boolean allBrandSuccess = brandData.stream().allMatch(p -> Objects.equals(p.getSummaryTaskStatus(), 2));
if (!allBrandSuccess) {
List<Integer> unFinishBrandIds = brandData.stream()
.filter(p -> !Objects.equals(p.getSummaryTaskStatus(), 2))
.map(DataReportBrandSnapshot::getId)
.collect(Collectors.toList());
log.info("品牌数据未全部完成, id:{}", unFinishBrandIds);
}
} else {
log.info("没有品牌数据,异常数据");
return;
}
// 批量更新快照状态为完成
updateBusinessSuccess(itemList);
});
log.info("刷新报告生成状态执行结束");
} catch (Exception e) {
log.error("刷新报告生成状态 Job 执行失败", e);
throw e;
}
}
private List<DataReportBusinessSnapshot> getProcessingBusinessData() {
Example bizExample = new Example(DataReportBusinessSnapshot.class);
bizExample.createCriteria()
.andEqualTo("generateStatus", 1)
.andEqualTo("deletedFlag", "N");
return businessSnapshotMapper.selectByExample(bizExample);
}
private List<DataReportBrandSnapshot> getBrandDataByBusiness(List<DataReportBusinessSnapshot> itemList) {
Example brandExample = new Example(DataReportBrandSnapshot.class);
brandExample.createCriteria()
.andEqualTo("reportType", itemList.get(0).getReportType())
.andEqualTo("periodKey", itemList.get(0).getPeriodKey())
.andEqualTo("deletedFlag", "N");
return brandSnapshotMapper.selectByExample(brandExample);
}
private void updateBusinessSuccess(List<DataReportBusinessSnapshot> itemList) {
List<Integer> udpIds = itemList.stream().map(DataReportBusinessSnapshot::getId).collect(Collectors.toList());
Example udpExample = new Example(DataReportBusinessSnapshot.class);
udpExample.createCriteria()
.andIn("id", udpIds)
.andEqualTo("generateStatus", 1)
.andEqualTo("deletedFlag", "N");
DataReportBusinessSnapshot udpRecord = new DataReportBusinessSnapshot();
udpRecord.setGenerateStatus(2);
udpRecord.setUpdatedDate(new Date());
int udpCnt = businessSnapshotMapper.updateByExampleSelective(udpRecord, udpExample);
log.info("批量更新快照状态为完成,总数:{}, 更新数量:{}", udpIds.size(), udpCnt);
}
}
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.core.env.Environment;
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;
@Resource
private Environment environment;
@Override
public void execute(ShardingContext shardingContext) {
log.info("开始执行数据报告月报快照生成任务");
try {
DataReportGenerateReq req = new DataReportGenerateReq();
// 构建上月的周期键(格式:YYYYMM,如2026M03)
buildLastMonthPeriodKey(req, shardingContext);
String periodKey = req.getPeriodKey();
log.info("计算得到上月周期键:{}", periodKey);
// 构建生成请求参数
req.setReportType((byte) 2); // 2-月报
req.setOperator("SYSTEM"); // 系统任务
// 调用服务生成快照
Boolean result = dataReportSnapshotService.generateSnapshot(req);
if (result) {
log.info("数据报告月报快照生成任务执行成功,periodKey:{}", periodKey);
} else {
log.error("数据报告月报快照生成任务执行失败,periodKey:{}", periodKey);
}
// 处理历史数据
handleHistoryData();
} catch (Exception e) {
log.error("数据报告月报快照生成任务执行异常", e);
throw e; // 重新抛出异常,让ElasticJob框架处理重试
}
}
public void handleHistoryData() {
Boolean historySwitch = environment.getProperty("dj.pe.analysis.data.report.handle.history.switch", Boolean.class, false);
if (historySwitch) {
log.info("数据报告历史数据处理开关已打开,开始处理历史数据");
dataReportSnapshotService.handlerHistoryData();
}
}
/**
* 构建上月的周期键。
* 格式为YYYYMmm(如2026M03),其中mm为两位数的月份
*/
private void buildLastMonthPeriodKey(DataReportGenerateReq req, 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);
req.setPeriodKey(periodKey);
req.setPeriodStart(DateUtil.beginOfMonth(date));
req.setPeriodEnd(DateUtil.endOfMonth(date));
}
}
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 {
DataReportGenerateReq req = new DataReportGenerateReq();
// 构建上周的周期键(格式:YYYYWww,如2026W12)
buildLastWeekPeriodKey(req, shardingContext);
String periodKey = req.getPeriodKey();
log.info("计算得到上周周期键:{}", periodKey);
// 构建生成请求参数
req.setReportType((byte) 1); // 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)
*/
private void buildLastWeekPeriodKey(DataReportGenerateReq req, 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);
req.setPeriodKey(periodKey);
req.setPeriodStart(DateUtil.beginOfWeek(date));
req.setPeriodEnd(DateUtil.endOfWeek(date));
}
}
package cn.com.glsx.dj.peanalysis.job;
import cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig;
import cn.com.glsx.dj.peanalysis.service.ReportSubscribeService;
import cn.com.glsx.dj.peanalysis.service.WeComMessageService;
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 javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Slf4j
@ElasticJobConf(name = "MonthlyReportPushJob", cron = "0 0 9 1 * ?", description = "每月1日上午9:00推送展业月报", overwrite = false)
public class MonthlyReportPushJob implements SimpleJob {
@Resource
private ReportSubscribeService reportSubscribeService;
@Resource
private WeComMessageService weComMessageService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("开始推送展业月报");
try {
// 获取所有已订阅月报的用户
List<DjReportSubscribeConfig> subscribers = reportSubscribeService.getMonthlySubscribers();
if (subscribers == null || subscribers.isEmpty()) {
log.info("没有用户订阅展业月报");
return;
}
// 计算上月的开始和结束日期
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
Date startDate = calendar.getTime();
calendar.add(Calendar.MONTH, 1);
calendar.add(Calendar.DAY_OF_MONTH, -1);
Date endDate = calendar.getTime();
// 获取年份和月份
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1; // 月份从0开始,需要加1
// 批量发送月报通知
boolean success = weComMessageService.sendBatchMonthlyReportNotice(subscribers, startDate, endDate, year, month);
if (success) {
log.info("批量推送展业月报成功,订阅用户数: {}", subscribers.size());
} else {
log.error("批量推送展业月报失败");
}
} catch (Exception e) {
log.error("推送展业月报时发生异常", e);
}
log.info("推送展业月报完成");
}
}
\ No newline at end of file
package cn.com.glsx.dj.peanalysis.job;
import cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig;
import cn.com.glsx.dj.peanalysis.service.ReportSubscribeService;
import cn.com.glsx.dj.peanalysis.service.WeComMessageService;
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 javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Slf4j
@ElasticJobConf(name = "WeeklyReportPushJob", cron = "0 0 9 ? * MON", description = "每周一上午9:00推送展业周报", overwrite = false)
public class WeeklyReportPushJob implements SimpleJob {
@Resource
private ReportSubscribeService reportSubscribeService;
@Resource
private WeComMessageService weComMessageService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("开始推送展业周报");
try {
// 获取所有已订阅周报的用户
List<DjReportSubscribeConfig> subscribers = reportSubscribeService.getWeeklySubscribers();
if (subscribers == null || subscribers.isEmpty()) {
log.info("没有用户订阅展业周报");
return;
}
// 计算上周的开始和结束日期
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.add(Calendar.WEEK_OF_YEAR, -1);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
Date startDate = calendar.getTime();
calendar.add(Calendar.DAY_OF_WEEK, 6);
Date endDate = calendar.getTime();
// 获取年份和周数
int year = calendar.get(Calendar.YEAR);
int week = calendar.get(Calendar.WEEK_OF_YEAR);
// 批量发送周报通知
boolean success = weComMessageService.sendBatchWeeklyReportNotice(subscribers, startDate, endDate, year, week);
if (success) {
log.info("批量推送展业周报成功,订阅用户数: {}", subscribers.size());
} else {
log.error("批量推送展业周报失败");
}
} catch (Exception e) {
log.error("推送展业周报时发生异常", e);
}
log.info("推送展业周报完成");
}
}
\ No newline at end of file
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.mapper;
import cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface DjReportSubscribeConfigMapper {
/**
* 根据用户ID查询订阅配置
* @param userId 用户ID
* @return 订阅配置
*/
DjReportSubscribeConfig selectByUserId(@Param("userId") String userId);
/**
* 插入订阅配置
* @param record 订阅配置
* @return 影响行数
*/
int insert(DjReportSubscribeConfig record);
/**
* 更新订阅配置
* @param record 订阅配置
* @return 影响行数
*/
int updateByPrimaryKeySelective(DjReportSubscribeConfig record);
/**
* 查询所有已订阅周报的用户
* @return 已订阅周报的用户列表
*/
java.util.List<DjReportSubscribeConfig> selectWeeklySubscribers();
/**
* 查询所有已订阅月报的用户
* @return 已订阅月报的用户列表
*/
java.util.List<DjReportSubscribeConfig> selectMonthlySubscribers();
}
\ No newline at end of file
package cn.com.glsx.dj.peanalysis.mapper;
import cn.com.glsx.dj.peanalysis.dto.StoreSettingDTO;
import cn.com.glsx.dj.peanalysis.dto.MerchantInfoDTO;
import cn.com.glsx.dj.peanalysis.dto.MerchantQueryDTO;
import cn.com.glsx.dj.peanalysis.dto.StoreSettingDTO;
import cn.com.glsx.dj.peanalysis.model.ServiceMerchant;
import cn.com.glsx.dj.peanalysis.service.model.StoreInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -44,4 +45,8 @@ public interface ServiceMerchantMapper extends OreMapper<ServiceMerchant> {
List<StoreInfo> findYydList(@Param("list") List<Integer> collected);
List<Map<Integer, Object>> findMerchantTargetAvgCustomerPrice(@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("merchantIds") List<Integer> merchantIds,
@Param("sceneType") Byte sceneType);
}
\ No newline at end of file
package cn.com.glsx.dj.peanalysis.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
@Data
@Table(name = "dj_report_subscribe_config")
public class DjReportSubscribeConfig implements Serializable {
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 用户ID
*/
@Column(name = "user_id")
private String userId;
/**
* 用户名称
*/
@Column(name = "user_name")
private String userName;
/**
* 用户手机号
*/
@Column(name = "user_phone")
private String userPhone;
/**
* 展业周报订阅状态:0:未订阅,1:已订阅
*/
@Column(name = "weekly_report_subscribe")
private Integer weeklyReportSubscribe;
/**
* 展业月报订阅状态:0:未订阅,1:已订阅
*/
@Column(name = "monthly_report_subscribe")
private Integer monthlyReportSubscribe;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createdTime;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updatedTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
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.generateSnapshotAsync(request);
log.info("远程调用:生成数据报告快照完成,结果:{}", result);
return RpcResponse.success(result);
} catch (Exception e) {
log.error("远程调用:生成数据报告快照失败", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
}
package cn.com.glsx.dj.peanalysis.remote;
import cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig;
import cn.com.glsx.dj.peanalysis.service.ReportSubscribeService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@DubboService(validation = "true")
public class ReportSubscribeRemoteImpl implements ReportSubscribeRemote {
@Autowired
private ReportSubscribeService reportSubscribeService;
@Override
public RpcResponse<Boolean> updateWeeklyReportSubscribe(String userId, String userName, String userPhone, Integer subscribeStatus) {
try {
boolean result = reportSubscribeService.updateWeeklyReportSubscribe(userId, userName, userPhone, subscribeStatus);
return RpcResponse.success(result);
} catch (Exception e) {
log.error("更新展业周报订阅状态失败: userId={}, subscribeStatus={}", userId, subscribeStatus, e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<Boolean> updateMonthlyReportSubscribe(String userId, String userName, String userPhone, Integer subscribeStatus) {
try {
boolean result = reportSubscribeService.updateMonthlyReportSubscribe(userId, userName, userPhone, subscribeStatus);
return RpcResponse.success(result);
} catch (Exception e) {
log.error("更新展业月报订阅状态失败: userId={}, subscribeStatus={}", userId, subscribeStatus, e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<DjReportSubscribeConfig> getSubscribeConfig(String userId) {
try {
DjReportSubscribeConfig config = reportSubscribeService.getSubscribeConfig(userId);
return RpcResponse.success(config);
} catch (Exception e) {
log.error("查询用户订阅配置失败: userId={}", userId, e);
return RpcResponse.error(e);
}
}
}
\ No newline at end of file
......@@ -2341,10 +2341,20 @@ public class BusinessSceneAnalysisService {
return wariningList.stream().map(MonitoringMsgDTO::getWarningText).collect(Collectors.toList());
}
private BigDecimal queryTargetAvgCustomerPrice(SceneBaseReq req) {
public BigDecimal queryTargetAvgCustomerPrice(SceneBaseReq req) {
// 实现获取最近一次嘀加上架记录中的预估目标客单价的逻辑
// 目前暂无该表具体 Mapper,先返回 null
return null;
List<Map<Integer, Object>> result = merchantBasicInfoService.getMerchantTargetAvgCustomerPrice(
req.getStartTime(), req.getEndTime(), req.getMerchantIds(), req.getSceneType());
if (CollectionUtils.isEmpty(result)) {
log.error("获取最近一次嘀加上架记录中的预估目标客单价异常");
return null;
}
log.info("最近一次嘀加上架记录中的预估目标客单价: {}", result);
Integer merchantId = req.getMerchantIds().get(0);
return result.stream()
.filter(p -> Objects.equals(Integer.valueOf(Objects.toString(p.get("merchant_id"))), merchantId) && p.get("estimated_customer_unit_price") != null)
.map(p -> new BigDecimal(Objects.toString(p.get("estimated_customer_unit_price"))))
.findFirst().orElse(null);
}
/**
......
......@@ -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
......@@ -88,7 +89,7 @@ public class GetDataStatsService {
queryCopy.setItemCodes(itemCode);
String jsonBody = JSONUtil.toJsonStr(queryCopy);
log.info("jsonBody: {}", jsonBody);
log.info("ready to query [{}] data", itemCode);
futures.add(CompletableFuture.runAsync(() -> {
try {
DataResp<List<DataBusinessDTO>> dataResp = this.getListDataResp(jsonBody);
......@@ -132,7 +133,7 @@ public class GetDataStatsService {
BeanUtil.copyProperties(queryDataBiz, queryCopy);
queryCopy.setItemCodes(itemCode);
String jsonBody = JSONUtil.toJsonStr(queryCopy);
log.info("jsonBody: {}", jsonBody);
log.info("ready to query [{}] data", itemCode);
futures.add(CompletableFuture.runAsync(() -> {
try {
DataResp<List<DataBusinessDTO>> dataResp = this.getListDataResp(jsonBody);
......@@ -168,7 +169,7 @@ public class GetDataStatsService {
DataBizQueryParamsDTO queryCopy = new DataBizQueryParamsDTO();
BeanUtil.copyProperties(query, queryCopy);
String jsonBody = JSONUtil.toJsonStr(queryCopy);
log.info("jsonBody: {}", jsonBody);
log.info("ready to query [{}] data", key);
futures.add(CompletableFuture.runAsync(() -> {
try {
DataResp<List<DataBusinessDTO>> dataResp = this.getListDataResp(jsonBody);
......@@ -278,4 +279,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;
}
}
......@@ -14,6 +14,7 @@ import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import cn.com.glsx.merchants.model.response.merchant.MerchantBasicInfoListResponse;
import cn.com.glsx.merchants.remote.MerchantRemote;
import cn.com.glsx.merchants.remote.MerchantStaffRemote;
import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -256,4 +257,9 @@ public class MerchantBasicInfoService {
// 线上运营不用过滤
return configUuids;
}
public List<Map<Integer, Object>> getMerchantTargetAvgCustomerPrice(String startTime, String endTime, List<Integer> merchantIds, Byte sceneType) {
return serviceMerchantMapper.findMerchantTargetAvgCustomerPrice(
DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)), merchantIds, sceneType);
}
}
package cn.com.glsx.dj.peanalysis.service;
import cn.com.glsx.dj.peanalysis.mapper.DjReportSubscribeConfigMapper;
import cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class ReportSubscribeService {
@Autowired
private DjReportSubscribeConfigMapper djReportSubscribeConfigMapper;
/**
* 更新用户的展业周报订阅状态
* @param userId 用户ID
* @param userName 用户名称
* @param userPhone 用户手机号
* @param subscribeStatus 订阅状态:0:未订阅,1:已订阅
* @return 更新结果
*/
public boolean updateWeeklyReportSubscribe(String userId, String userName, String userPhone, Integer subscribeStatus) {
try {
// 查找用户的订阅配置
DjReportSubscribeConfig config = djReportSubscribeConfigMapper.selectByUserId(userId);
if (config == null) {
// 如果不存在,创建新的配置
config = new DjReportSubscribeConfig();
config.setUserId(userId);
config.setUserName(userName);
config.setUserPhone(userPhone);
config.setWeeklyReportSubscribe(subscribeStatus);
config.setMonthlyReportSubscribe(0);
djReportSubscribeConfigMapper.insert(config);
} else {
// 如果存在,更新配置
config.setUserName(userName);
config.setUserPhone(userPhone);
config.setWeeklyReportSubscribe(subscribeStatus);
djReportSubscribeConfigMapper.updateByPrimaryKeySelective(config);
}
return true;
} catch (Exception e) {
log.error("更新展业周报订阅状态失败: userId={}, subscribeStatus={}", userId, subscribeStatus, e);
throw new RpcServiceException("更新展业周报订阅状态失败");
}
}
/**
* 更新用户的展业月报订阅状态
* @param userId 用户ID
* @param userName 用户名称
* @param userPhone 用户手机号
* @param subscribeStatus 订阅状态:0:未订阅,1:已订阅
* @return 更新结果
*/
public boolean updateMonthlyReportSubscribe(String userId, String userName, String userPhone, Integer subscribeStatus) {
try {
// 查找用户的订阅配置
DjReportSubscribeConfig config = djReportSubscribeConfigMapper.selectByUserId(userId);
if (config == null) {
// 如果不存在,创建新的配置
config = new DjReportSubscribeConfig();
config.setUserId(userId);
config.setUserName(userName);
config.setUserPhone(userPhone);
config.setWeeklyReportSubscribe(0);
config.setMonthlyReportSubscribe(subscribeStatus);
djReportSubscribeConfigMapper.insert(config);
} else {
// 如果存在,更新配置
config.setUserName(userName);
config.setUserPhone(userPhone);
config.setMonthlyReportSubscribe(subscribeStatus);
djReportSubscribeConfigMapper.updateByPrimaryKeySelective(config);
}
return true;
} catch (Exception e) {
log.error("更新展业月报订阅状态失败: userId={}, subscribeStatus={}", userId, subscribeStatus, e);
throw new RpcServiceException("更新展业月报订阅状态失败");
}
}
/**
* 查询用户的订阅配置
* @param userId 用户ID
* @return 订阅配置
*/
public DjReportSubscribeConfig getSubscribeConfig(String userId) {
try {
return djReportSubscribeConfigMapper.selectByUserId(userId);
} catch (Exception e) {
log.error("查询用户订阅配置失败: userId={}", userId, e);
throw new RpcServiceException("查询用户订阅配置失败");
}
}
/**
* 获取所有已订阅周报的用户
* @return 已订阅周报的用户列表
*/
public java.util.List<DjReportSubscribeConfig> getWeeklySubscribers() {
try {
return djReportSubscribeConfigMapper.selectWeeklySubscribers();
} catch (Exception e) {
log.error("获取已订阅周报的用户失败", e);
throw new RpcServiceException("获取已订阅周报的用户失败");
}
}
/**
* 获取所有已订阅月报的用户
* @return 已订阅月报的用户列表
*/
public java.util.List<DjReportSubscribeConfig> getMonthlySubscribers() {
try {
return djReportSubscribeConfigMapper.selectMonthlySubscribers();
} catch (Exception e) {
log.error("获取已订阅月报的用户失败", e);
throw new RpcServiceException("获取已订阅月报的用户失败");
}
}
}
\ No newline at end of file
<?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="order_num" jdbcType="INTEGER" property="orderNum"/>
<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, order_num, 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 order_num ASC
</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="generate_status" jdbcType="TINYINT" property="generateStatus"/>
<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, generate_status, 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 deleted_flag = 'N'
AND report_type = #{reportType}
AND period_key = #{periodKey}
<if test="businessType != null">
AND business_type = #{businessType}
</if>
<if test="generateStatus != null">
AND generate_status = #{generateStatus}
</if>
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
<?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.DjReportSubscribeConfigMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="VARCHAR" />
<result column="user_name" property="userName" jdbcType="VARCHAR" />
<result column="user_phone" property="userPhone" jdbcType="VARCHAR" />
<result column="weekly_report_subscribe" property="weeklyReportSubscribe" jdbcType="INTEGER" />
<result column="monthly_report_subscribe" property="monthlyReportSubscribe" jdbcType="INTEGER" />
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP" />
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP" />
</resultMap>
<select id="selectByUserId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select id, user_id, user_name, user_phone, weekly_report_subscribe, monthly_report_subscribe, created_time, updated_time
from dj_report_subscribe_config
where user_id = #{userId, jdbcType=VARCHAR}
</select>
<insert id="insert" parameterType="cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig" >
insert into dj_report_subscribe_config (user_id, user_name, user_phone, weekly_report_subscribe, monthly_report_subscribe, created_time, updated_time)
values (#{userId, jdbcType=VARCHAR}, #{userName, jdbcType=VARCHAR}, #{userPhone, jdbcType=VARCHAR}, #{weeklyReportSubscribe, jdbcType=INTEGER}, #{monthlyReportSubscribe, jdbcType=INTEGER}, now(), now())
</insert>
<update id="updateByPrimaryKeySelective" parameterType="cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig" >
update dj_report_subscribe_config
<set >
<if test="userName != null" >
user_name = #{userName, jdbcType=VARCHAR},
</if>
<if test="userPhone != null" >
user_phone = #{userPhone, jdbcType=VARCHAR},
</if>
<if test="weeklyReportSubscribe != null" >
weekly_report_subscribe = #{weeklyReportSubscribe, jdbcType=INTEGER},
</if>
<if test="monthlyReportSubscribe != null" >
monthly_report_subscribe = #{monthlyReportSubscribe, jdbcType=INTEGER},
</if>
updated_time = now()
</set>
where id = #{id, jdbcType=INTEGER}
</update>
<select id="selectWeeklySubscribers" resultMap="BaseResultMap" >
select id, user_id, user_name, user_phone, weekly_report_subscribe, monthly_report_subscribe, created_time, updated_time
from dj_report_subscribe_config
where weekly_report_subscribe = 1
</select>
<select id="selectMonthlySubscribers" resultMap="BaseResultMap" >
select id, user_id, user_name, user_phone, weekly_report_subscribe, monthly_report_subscribe, created_time, updated_time
from dj_report_subscribe_config
where monthly_report_subscribe = 1
</select>
</mapper>
\ No newline at end of file
......@@ -679,4 +679,27 @@
and sub_merchant_type in (6, 8);
</select>
<select id="findMerchantTargetAvgCustomerPrice" resultType="java.util.HashMap">
SELECT
t1.merchant_id,
t1.estimated_customer_unit_price
FROM dj_car_life_create_business_approve_merchant t1
INNER JOIN (
SELECT
merchant_id,
scene_type,
MAX(created_date) AS max_created_date
FROM dj_car_life_create_business_approve_merchant
WHERE deleted_flag = 'N'
AND created_date BETWEEN #{startTime} AND #{endTime}
AND merchant_id IN
<foreach item="item" index="index" collection="merchantIds" open="(" separator="," close=")">
#{item}
</foreach>
AND scene_type = #{sceneType}
GROUP BY merchant_id, scene_type
) t2 ON t1.merchant_id = t2.merchant_id AND t1.scene_type = t2.scene_type AND t1.created_date = t2.max_created_date
WHERE t1.deleted_flag = 'N';
</select>
</mapper>
package cn.com.glsx.dj.peanalysis.job;
import cn.com.glsx.dj.peanalysis.remote.BaseRemoteTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class MonthlyReportPushJobTest extends BaseRemoteTest {
@Autowired
private MonthlyReportPushJob monthlyReportPushJob;
@Test
public void testExecute() {
monthlyReportPushJob.execute(null);
System.out.println("MonthlyReportPushJob执行完成");
}
}
package cn.com.glsx.dj.peanalysis.job;
import cn.com.glsx.dj.peanalysis.remote.BaseRemoteTest;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class WeeklyReportPushJobTest extends BaseRemoteTest {
@Autowired
private WeeklyReportPushJob weeklyReportPushJob;
@Test
public void testExecute() {
System.out.println("测试WeeklyReportPushJob执行");
weeklyReportPushJob.execute(null);
System.out.println("WeeklyReportPushJob执行完成");
}
}
......@@ -2,18 +2,20 @@ package cn.com.glsx.dj.peanalysis.service;
import cn.com.glsx.dj.peanalysis.dto.req.UserdCarDataStats.StockStoreAnalysisReq;
import cn.com.glsx.dj.peanalysis.dto.req.output.SceneBaseReq;
import cn.com.glsx.dj.peanalysis.dto.res.output.LostStoreDetailResponse;
import cn.com.glsx.dj.peanalysis.dto.res.output.SceneOutputResponse;
import cn.com.glsx.dj.peanalysis.dto.res.output.StoreEmployeeRankResponse;
import cn.com.glsx.dj.peanalysis.dto.res.output.LostStoreDetailResponse;
import cn.com.glsx.dj.peanalysis.dto.res.output.StoreSceneSummaryResponse;
import cn.com.glsx.dj.peanalysis.dto.strategy.StaffAnalysisDTO;
import cn.com.glsx.dj.peanalysis.remote.BaseRemoteTest;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -327,4 +329,16 @@ public class BusinessSceneAnalysisServiceTest extends BaseRemoteTest {
SceneOutputResponse staffOutputDTOS = service.querySupervisorOutput(req);
System.out.println(JSON.toJSONString(staffOutputDTOS));
}
@Test
public void testQueryTargetAvgCustomerPrice() {
SceneBaseReq req = new SceneBaseReq();
req.setStartTime(DateUtil.formatDate(DateUtil.offsetDay(new Date(), -300)));
req.setEndTime(DateUtil.formatDate(new Date()));
req.setSceneType((byte) 1);
req.setMerchantIds(Lists.newArrayList(44217732));
System.out.println(service.queryTargetAvgCustomerPrice(req));
req.setMerchantIds(Lists.newArrayList(44217700));
System.out.println(service.queryTargetAvgCustomerPrice(req));
}
}
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 com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.executor.ShardingContexts;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Collections;
/**
* 数据报告快照服务单元测试。
*
* @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() {
ShardingContexts mockContexts = new ShardingContexts(null, null, 0, "2026-02-01", Collections.emptyMap(), 0);
dataReportMonthlySnapshotJob.execute(new ShardingContext(mockContexts, 0));
}
@Test
public void dataReportWeeklySnapshotJobTest() {
dataReportWeeklySnapshotJob.execute(null);
}
@Test
public void handlerHistoryDataTest() {
dataReportSnapshotService.handlerHistoryData();
}
@Test
public void dataReportAiTextSummarySubmitJobTest() {
dataReportAiTextSummarySubmitJob.execute(null);
}
@Test
public void dataReportAiTextSummaryPollJobTest() {
dataReportAiTextSummaryPollJob.execute(null);
}
}
\ No newline at end of file
package cn.com.glsx.dj.peanalysis.service;
import cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig;
import cn.com.glsx.dj.peanalysis.remote.BaseRemoteTest;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.List;
public class ReportSubscribeServiceTest extends BaseRemoteTest {
@Autowired
private ReportSubscribeService reportSubscribeService;
@Test
public void testUpdateWeeklyReportSubscribe() {
boolean result = reportSubscribeService.updateWeeklyReportSubscribe("1001", "张三", "13476670746", 1);
System.out.println("更新展业周报订阅状态(订阅): " + result);
result = reportSubscribeService.updateWeeklyReportSubscribe("1001", "张三", "13476670746", 0);
System.out.println("更新展业周报订阅状态(取消订阅): " + result);
}
@Test
public void testUpdateMonthlyReportSubscribe() {
boolean result = reportSubscribeService.updateMonthlyReportSubscribe("1001", "李四", "13800138002", 1);
System.out.println("更新展业月报订阅状态(订阅): " + result);
result = reportSubscribeService.updateMonthlyReportSubscribe("1001", "李四", "13800138002", 0);
System.out.println("更新展业月报订阅状态(取消订阅): " + result);
}
@Test
public void testGetSubscribeConfig() {
DjReportSubscribeConfig config = reportSubscribeService.getSubscribeConfig("1001");
System.out.println("查询用户订阅配置: " + JSON.toJSONString(config));
}
@Test
public void testGetWeeklySubscribers() {
List<DjReportSubscribeConfig> subscribers = reportSubscribeService.getWeeklySubscribers();
System.out.println("查询已订阅周报的用户列表: " + JSON.toJSONString(subscribers));
}
@Test
public void testGetMonthlySubscribers() {
List<DjReportSubscribeConfig> subscribers = reportSubscribeService.getMonthlySubscribers();
System.out.println("查询已订阅月报的用户列表: " + JSON.toJSONString(subscribers));
}
@Test
public void testBatchSubscribe() {
reportSubscribeService.updateWeeklyReportSubscribe("12121", "王五", "13800138003", 1);
reportSubscribeService.updateWeeklyReportSubscribe("121212", "赵六", "13800138004", 1);
reportSubscribeService.updateWeeklyReportSubscribe("121213", "孙七", "13800138005", 1);
List<DjReportSubscribeConfig> subscribers = reportSubscribeService.getWeeklySubscribers();
System.out.println("批量订阅后查询已订阅周报的用户列表: " + JSON.toJSONString(subscribers));
}
@Test
public void testUpdateExistingUser() {
reportSubscribeService.updateWeeklyReportSubscribe("1001", "张三", "13800138001", 1);
reportSubscribeService.updateMonthlyReportSubscribe("1001", "张三", "13800138001", 1);
DjReportSubscribeConfig config = reportSubscribeService.getSubscribeConfig("1001");
System.out.println("更新已有用户订阅配置后查询: " + JSON.toJSONString(config));
}
}
\ No newline at end of file
package cn.com.glsx.dj.peanalysis.service;
import cn.com.glsx.dj.peanalysis.model.DjReportSubscribeConfig;
import cn.com.glsx.dj.peanalysis.remote.BaseRemoteTest;
import com.google.common.collect.Lists;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.List;
public class WeComMessageServiceTest extends BaseRemoteTest {
@Autowired
private WeComMessageService weComMessageService;
@Test
public void testSendBatchWeeklyReportNotice() {
System.out.println("测试批量发送展业周报通知");
// 创建测试数据
List<DjReportSubscribeConfig> subscribers = Lists.newArrayList();
DjReportSubscribeConfig config1 = new DjReportSubscribeConfig();
config1.setUserId("1001");
config1.setUserName("张三");
config1.setUserPhone("13800138001");
config1.setWeeklyReportSubscribe(1);
subscribers.add(config1);
DjReportSubscribeConfig config2 = new DjReportSubscribeConfig();
config2.setUserId("1002");
config2.setUserName("李四");
config2.setUserPhone("13476670746");
config2.setWeeklyReportSubscribe(1);
subscribers.add(config2);
// 测试批量发送
Date startDate = new Date();
Date endDate = new Date();
boolean result = weComMessageService.sendBatchWeeklyReportNotice(subscribers, startDate, endDate, 2026, 13);
System.out.println("批量发送展业周报通知结果: " + result);
}
@Test
public void testSendBatchMonthlyReportNotice() {
System.out.println("测试批量发送展业月报通知");
// 创建测试数据
List<DjReportSubscribeConfig> subscribers = Lists.newArrayList();
DjReportSubscribeConfig config1 = new DjReportSubscribeConfig();
config1.setUserId("1001");
config1.setUserName("张三");
config1.setUserPhone("13800138001");
config1.setMonthlyReportSubscribe(1);
subscribers.add(config1);
DjReportSubscribeConfig config2 = new DjReportSubscribeConfig();
config2.setUserId("1002");
config2.setUserName("李四");
config2.setUserPhone("13476670746");
config2.setMonthlyReportSubscribe(1);
subscribers.add(config2);
// 测试批量发送
Date startDate = new Date();
Date endDate = new Date();
boolean result = weComMessageService.sendBatchMonthlyReportNotice(subscribers, startDate, endDate, 2026, 3);
System.out.println("批量发送展业月报通知结果: " + result);
}
}
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议,如果必要,给出代码示例(仅限 Top 3)

    1. 业务快照状态更新逻辑错误,导致状态不一致(重要性:高)

    • 问题描述:在 DataReportGenerateStatusRefreshJob 类的 execute 方法中,检查品牌数据是否全部完成时(allBrandSuccess),如果为 false,仅打印了日志,并未阻断后续流程。这导致紧接着执行了 updateBusinessSuccess(itemList)。
    • 影响分析:即使品牌摘要任务尚未全部完成,业务汇总快照的状态也会被提前置为“完成(2)”。这将导致报告的状态流转异常,前端可能向用户展示不完整或尚未生成完毕的数据。
    • 优化建议:在 if (!allBrandSuccess) 分支中增加 return; 以跳过当前业务快照的状态更新。 java if (!allBrandSuccess) { List<Integer> unFinishBrandIds = brandData.stream() .filter(p -> !Objects.equals(p.getSummaryTaskStatus(), 2)) .map(DataReportBrandSnapshot::getId) .collect(Collectors.toList()); log.info("品牌数据未全部完成, id:{}", unFinishBrandIds); return; // 增加 return,防止提前更新业务快照状态 }

    2. 集合未判空直接取值,存在越界或空指针风险(重要性:高)

    • 问题描述:在 BusinessSceneAnalysisService.java 的 queryTargetAvgCustomerPrice 方法中,直接调用了 Integer merchantId = req.getMerchantIds().get(0);,未对 req.getMerchantIds() 进行 Null 或 Empty 检查。
    • 影响分析:如果上游调用方传入的 req 中 merchantIds 为空列表或 null,此处将直接抛出 IndexOutOfBoundsException 或 NullPointerException,导致整个业务场景分析接口异常中断。
    • 优化建议:在获取 merchantId 之前,增加对集合的判空校验。 java if (CollectionUtils.isEmpty(req.getMerchantIds())) { log.error("merchantIds不能为空"); return null; } Integer merchantId = req.getMerchantIds().get(0);

    3. 定时任务批量处理未做分页,存在 OOM 风险(重要性:中)

    • 问题描述:在 DataReportAiTextSummarySubmitJob、DataReportAiTextSummaryPollJob 等定时任务中,调用 findPendingSnapshots 是一次性查询出所有符合条件(如状态为待提交/处理中)的记录并加载到内存中。
    • 影响分析:当系统出现突发流量、二方接口响应变慢或任务积压时,待处理的记录数可能急剧增加。一次性加载大量数据极易造成 JVM 内存溢出(OOM),并引发数据库慢查询。
    • 优化建议:建议在进行批量任务处理时引入分页机制(如 PageHelper 或限制 LIMIT),每次最多查询固定数量(如 500 条)进行分批处理。

    二、评分明细

    1. 功能实现的正确性与健壮性(32/40分):整体业务逻辑和结构清晰,未见 Mybatis 子查询问题。但存在明显的流程控制缺陷(如状态定时刷新任务漏写 return 导致状态错乱)以及集合操作缺少防御性检查,健壮性有待提升。
    2. 安全性与潜在风险(28/30分):系统无明显的 SQL 注入、越权等高级别安全漏洞;外部 HTTP 调用(RestTemplate)良好地配置了连接和读取超时时间,有效防止了线程阻塞。
    3. 最佳实践与可维护性(17/20分):代码具有良好的结构分层,注释详尽,巧妙使用了枚举和配置类相分离的混合模式来管理指标。不过部分枚举的查找方法(如 fromCode)每次都遍历数组,在大量调用时可优化为静态 Map 缓存。
    4. 性能与资源利用(3/5分):定时任务处理全量数据时缺少分页限制机制,在数据积压的极端情况下存在明显的性能瓶颈和内存溢出风险。
    5. 提交信息质量(4/5分):Commit 信息较为清晰,详细说明了功能重构、Bug 修复等内容,具备良好的可追溯性。

    总分:84分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!