Commit 7be5f7db by 谢海旭

202601月底版本 策略中心:pad_message_box表调整、兜底指标备份定时任务

1 parent 5daea1c3
......@@ -12,11 +12,16 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum ModuleTypeEnums {
//模块分类:0-系统通知,1-优秀话术,2-话术预警,3-AI导师(短课程),4-学习任务(长课程), 6-学习类策略,7-优秀案例分享策略,8-任务型策略
// 模块分类:0-系统通知,1-优秀话术,2-话术预警,3-ai导师(短课程), 4-学习任务(长课程),5-活动中心,6-学习类策略,7-优秀案例分享策略,8-任务型策略
/** 系统通知 */
SYSTEM_NOTICE(0, "系统通知"),
/** 优秀话术 */
SCRIPT_EXCELLENT(1, "优秀话术"),
/** 话术预警 */
SCRIPT_WARN(2, "话术预警"),
/** AI导师(短课程) */
AI_MENTOR(3, "AI导师"),
/** 学习任务(长课程) */
STUDY_TASK(4, "学习任务"),
/** 活动中心 */
ACTIVITY_CENTER(5, "活动中心"),
......
package cn.com.glsx.dj.mindworkplate.enums.messagebox;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 提醒类型枚举
*
* @Description 消息盒子提醒类型
* @Author system
* @Date 2026/01/16
* @Version 1.0
*/
@AllArgsConstructor
@Getter
public enum ReminderTypeEnums {
// 提醒类型:1-首次提醒,2-进度提醒
/** 首次提醒 */
FIRST_REMINDER((byte) 1, "首次提醒"),
/** 进度提醒 */
PROGRESS_REMINDER((byte) 2, "进度提醒");
private final Byte code;
private final String name;
/**
* 根据code获取名称
*
* @param code 提醒类型编码
* @return 提醒类型名称
*/
public static String getName(Byte code) {
for (ReminderTypeEnums item : values()) {
if (item.getCode().equals(code)) {
return item.getName();
}
}
return null;
}
/**
* 根据name获取code
*
* @param name 提醒类型名称
* @return 提醒类型编码
*/
public static Byte getCode(String name) {
for (ReminderTypeEnums item : values()) {
if (item.getName().equals(name)) {
return item.getCode();
}
}
return null;
}
/**
* 验证code是否有效
*
* @param code 提醒类型编码
* @return 是否有效
*/
public static boolean isValid(Byte code) {
if (code == null) {
return false;
}
for (ReminderTypeEnums item : values()) {
if (item.getCode().equals(code)) {
return true;
}
}
return false;
}
}
package cn.com.glsx.dj.mindworkplate.model;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import lombok.Data;
/**
* 门店-指标历史记录表
*/
@Table(name = "early_warning_threshold_config_history")
@Data
public class EarlyWarningThresholdConfigHistory implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 记录年月(YYYY-MM格式)
*/
@Column(name = "record_year_month")
@ApiModelProperty(notes = "记录年月(YYYY-MM格式)")
private String recordYearMonth;
/**
* 商户号
*/
@Column(name = "merchant_no")
private String merchantNo;
/**
* 延保转化率
*/
@Column(name = "ew_con_rate")
@ApiModelProperty(notes = "延保转化率")
private BigDecimal ewConRate;
/**
* 延保安心包转化率
*/
@Column(name = "ew_axb_con_rate")
@ApiModelProperty(notes = "延保安心包转化率")
private BigDecimal ewAxbConRate;
/**
* 延保轮胎转化率
*/
@Column(name = "ew_lt_con_rate")
@ApiModelProperty(notes = "延保轮胎转化率")
private BigDecimal ewLtConRate;
/**
* 延保电池转化率
*/
@Column(name = "battery_conversion_rate")
@ApiModelProperty(notes = "延保电池转化率")
private BigDecimal batteryConversionRate;
/**
* 权益转化率
*/
@Column(name = "ri_con_rate")
@ApiModelProperty(notes = "权益转化率")
private BigDecimal riConRate;
/**
* 延保渗透率
*/
@Column(name = "ew_penetration_rate")
@ApiModelProperty(notes = "延保渗透率")
private BigDecimal ewPenetrationRate;
/**
* 延保安心包渗透率
*/
@Column(name = "ew_axb_penetration_rate")
@ApiModelProperty(notes = "延保安心包渗透率")
private BigDecimal ewAxbPenetrationRate;
/**
* 延保轮胎渗透率
*/
@Column(name = "ew_lt_penetration_rate")
@ApiModelProperty(notes = "延保轮胎渗透率")
private BigDecimal ewLtPenetrationRate;
/**
* 延保电池渗透率
*/
@Column(name = "battery_penetration_rate")
@ApiModelProperty(notes = "延保电池渗透率")
private BigDecimal batteryPenetrationRate;
/**
* 创建时间
*/
@Column(name = "created_date")
private Date createdDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@Column(name = "deleted_flag")
private String deletedFlag;
}
......@@ -30,7 +30,7 @@ public class PadMessageBox implements Serializable {
private Integer moduleType;
/**
* 业务场景:0-延保,1-精品
* 业务场景:0-延保,1-精品, 2-权益
* @see BusinessTypeEnums
*/
@Column(name = "business_type")
......@@ -114,4 +114,35 @@ public class PadMessageBox implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date latestReadTime;
/**
* 提醒类型:1-首次提醒,2-进度提醒
* @see cn.com.glsx.dj.mindworkplate.enums.messagebox.ReminderTypeEnums
*/
@ApiModelProperty(notes = "提醒类型:1-首次提醒,2-进度提醒")
@Column(name = "reminder_type")
private Byte reminderType;
/**
* 消息标题
*/
@ApiModelProperty(notes = "消息标题")
@Column(name = "msg_title")
private String msgTitle;
/**
* 任务类型消息-任务开始时间
*/
@ApiModelProperty(notes = "任务类型消息-任务开始时间")
@Column(name = "task_start_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date taskStartTime;
/**
* 任务类型消息-任务结束时间
*/
@ApiModelProperty(notes = "任务类型消息-任务结束时间")
@Column(name = "start_end_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startEndTime;
}
\ No newline at end of file
package cn.com.glsx.dj.mindworkplate.job.warning;
import cn.com.glsx.dj.mindworkplate.service.EarlyWarningThresholdConfigService;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Description 门店指标配置月度备份定时任务
* 每月1号凌晨1点执行,将early_warning_threshold_config表中每个门店的指标记录
* copy到early_warning_threshold_config_history表中作为每个门店上一个月的指标数据
* @Date 2026-01-16
*/
@Slf4j
@Service
@ElasticJobConf(name = "ThresholdConfigMonthlyBackupJob", cron = "0 0 1 1 * ?", description = "门店指标配置月度备份任务", overwrite = false)
public class ThresholdConfigMonthlyBackupJob implements SimpleJob {
@Autowired
private EarlyWarningThresholdConfigService earlyWarningThresholdConfigService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("门店指标配置月度备份任务开始执行");
try {
earlyWarningThresholdConfigService.backupThresholdConfigToHistory();
log.info("门店指标配置月度备份任务执行成功");
} catch (Exception e) {
log.error("门店指标配置月度备份任务执行失败", e);
}
log.info("门店指标配置月度备份任务执行结束");
}
}
package cn.com.glsx.dj.mindworkplate.mapper;
import cn.com.glsx.dj.mindworkplate.model.EarlyWarningThresholdConfigHistory;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface EarlyWarningThresholdConfigHistoryMapper extends OreMapper<EarlyWarningThresholdConfigHistory> {
/**
* 直接从配置表备份数据到历史表,自动计算上一个月的年月
* @return 插入条数
*/
int backupConfigToHistory();
}
package cn.com.glsx.dj.mindworkplate.service;
import cn.com.glsx.dj.mindworkplate.mapper.EarlyWarningThresholdConfigHistoryMapper;
import cn.com.glsx.dj.mindworkplate.mapper.EarlyWarningThresholdConfigMapper;
import cn.com.glsx.dj.mindworkplate.mapper.EarlyWarningThresholdRangeConfigMapper;
import cn.com.glsx.dj.mindworkplate.model.EarlyWarningThresholdConfig;
import cn.com.glsx.dj.mindworkplate.model.EarlyWarningThresholdRangeConfig;
import java.util.Date;
import org.springframework.beans.BeanUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Slf4j
@Service
public class EarlyWarningThresholdConfigService {
......@@ -18,6 +21,9 @@ public class EarlyWarningThresholdConfigService {
@Autowired
private EarlyWarningThresholdRangeConfigMapper earlyWarningThresholdRangeConfigMapper;
@Autowired
private EarlyWarningThresholdConfigHistoryMapper earlyWarningThresholdConfigHistoryMapper;
/**
* 根据商户号查询预警阈值
*
......@@ -80,4 +86,22 @@ public class EarlyWarningThresholdConfigService {
earlyWarningThresholdConfigMapper.insert(earlyWarningThresholdConfig);
}
}
/**
* 备份当前所有门店的指标记录到历史表
* 每月1号凌晨1点执行,记录上一个月的指标数据
*/
public void backupThresholdConfigToHistory() {
log.info("开始备份门店指标记录到历史表");
try {
// 直接使用SQL将数据从配置表备份到历史表,SQL内部自动计算上一个月的年月
int insertCount = earlyWarningThresholdConfigHistoryMapper.backupConfigToHistory();
log.info("成功备份{}条门店指标记录到历史表", insertCount);
} catch (Exception e) {
log.error("备份门店指标记录到历史表失败", e);
throw new RuntimeException("备份门店指标记录失败: " + e.getMessage(), e);
}
}
}
<?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.mindworkplate.mapper.EarlyWarningThresholdConfigHistoryMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.EarlyWarningThresholdConfigHistory" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="record_year_month" property="recordYearMonth" jdbcType="VARCHAR" />
<result column="merchant_no" property="merchantNo" jdbcType="VARCHAR" />
<result column="ew_con_rate" property="ewConRate" jdbcType="DECIMAL" />
<result column="ew_axb_con_rate" property="ewAxbConRate" jdbcType="DECIMAL" />
<result column="ew_lt_con_rate" property="ewLtConRate" jdbcType="DECIMAL" />
<result column="battery_conversion_rate" property="batteryConversionRate" jdbcType="DECIMAL" />
<result column="ri_con_rate" property="riConRate" jdbcType="DECIMAL" />
<result column="ew_penetration_rate" property="ewPenetrationRate" jdbcType="DECIMAL" />
<result column="ew_axb_penetration_rate" property="ewAxbPenetrationRate" jdbcType="DECIMAL" />
<result column="ew_lt_penetration_rate" property="ewLtPenetrationRate" jdbcType="DECIMAL" />
<result column="battery_penetration_rate" property="batteryPenetrationRate" jdbcType="DECIMAL" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, record_year_month, merchant_no, ew_con_rate, ew_axb_con_rate, ew_lt_con_rate,
battery_conversion_rate, ri_con_rate, ew_penetration_rate, ew_axb_penetration_rate,
ew_lt_penetration_rate, battery_penetration_rate, created_date, deleted_flag
</sql>
<!-- 直接从配置表备份数据到历史表,自动计算上一个月的年月 -->
<insert id="backupConfigToHistory">
INSERT INTO early_warning_threshold_config_history
(record_year_month, merchant_no, ew_con_rate, ew_axb_con_rate, ew_lt_con_rate,
battery_conversion_rate, ri_con_rate, ew_penetration_rate, ew_axb_penetration_rate,
ew_lt_penetration_rate, battery_penetration_rate, created_date, deleted_flag)
SELECT
DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m'),
merchant_no,
ew_con_rate,
ew_axb_con_rate,
ew_lt_con_rate,
battery_conversion_rate,
ri_con_rate,
ew_penetration_rate,
ew_axb_penetration_rate,
ew_lt_penetration_rate,
battery_penetration_rate,
NOW(),
'N'
FROM early_warning_threshold_config
WHERE deleted_flag = 'N'
</insert>
</mapper>
......@@ -21,6 +21,10 @@
<result column="read_type" property="readType" jdbcType="INTEGER"/>
<result column="read_count" property="readCount" jdbcType="INTEGER"/>
<result column="latest_read_time" property="latestReadTime" jdbcType="TIMESTAMP"/>
<result column="reminder_type" property="reminderType" jdbcType="TINYINT"/>
<result column="msg_title" property="msgTitle" jdbcType="VARCHAR"/>
<result column="task_start_time" property="taskStartTime" jdbcType="TIMESTAMP"/>
<result column="start_end_time" property="startEndTime" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap id="ScriptRecordPadPushDTOMap" extends="BaseResultMap"
......@@ -71,7 +75,8 @@
WARNING - @mbg.generated
-->
id, module_type, business_type, uuid, phone, name, status, created_by, created_time,
updated_by, updated_time, del_flag
updated_by, updated_time, del_flag, popup_count, read_type, read_count, latest_read_time,
reminder_type, msg_title, task_start_time, start_end_time
</sql>
<select id="listMessageBoxRecordDetail" parameterType="cn.com.glsx.dj.mindworkplate.dto.script.ScriptSearchDTO"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!