Commit e766de35 by 叶立庆

Merge remote-tracking branch 'origin/v5.7.1' into v5.7.4

# Conflicts:
#	rpc-dj-mindworkplate-api/pom.xml
#	rpc-dj-mindworkplate/pom.xml
2 parents fd1d8f56 9870e2b0
Showing 25 changed files with 1614 additions and 7 deletions
...@@ -24,4 +24,9 @@ public interface ConfigCenterConstants { ...@@ -24,4 +24,9 @@ public interface ConfigCenterConstants {
*/ */
String CURRENT_SYSTEM_TIME_FOR_TEST = "current.system.time.for.test"; String CURRENT_SYSTEM_TIME_FOR_TEST = "current.system.time.for.test";
/**
* 客户档案录音对应的URL
*/
String RECEPTION_CUSTOMER_FILE_URL = "reception.customer.file.url";
} }
package cn.com.glsx.dj.mindworkplate.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class ReceptionCustomerFileDetailDTO implements Serializable {
private static final long serialVersionUID = 1L;
// --- Recording Info (Top Module) ---
@ApiModelProperty(notes = "车主姓名")
private String customerName;
@ApiModelProperty(notes = "电话")
private String phoneNumber;
@ApiModelProperty(notes = "接待开始时间")
private Date receptionStartTime;
@ApiModelProperty(notes = "车品牌")
private String carBrand;
// --- Customer File Info (Bottom Module) ---
@ApiModelProperty(notes = "主键ID")
private Long id;
@ApiModelProperty(notes = "提交状态, 0-未提交, 1-已提交")
private Integer submitStatus;
@ApiModelProperty(notes = "录音接待id")
private Integer receptionId;
@ApiModelProperty(notes = "接待结果, 0-成交, 1-战败")
private Integer receptionResult;
@ApiModelProperty(notes = "成交归因(接待结果=0时填写), 0-自然成交, 1-活动成交, 2-对比成交, 3-引导成交, 4-口碑成交, 5-培育成交")
private Integer dealAttribution;
@ApiModelProperty(notes = "战败归因(接待结果=1时填写), 0-价格战败, 1-竞品战败, 2-产品战败, 3-需求战败, 4-决策战败, 5-服务战败, 6-其他战败")
private Integer loseReason;
@ApiModelProperty(notes = "用车人, 0-主人本人, 1-公司户, 2-代办, 3-决策者")
private Integer carUserType;
@ApiModelProperty(notes = "客户背景, 0-企业老板, 1-老师, 2-医生, 3-建筑, 4-个体, 5-自由职业, 6-其他")
private Integer customerBackground;
@ApiModelProperty(notes = "是否好沟通, 0-是, 1-否")
private Integer easyCommunication;
@ApiModelProperty(notes = "是否按揭, 0-是, 1-否")
private Integer isMortgage;
@ApiModelProperty(notes = "首付比例, 0-全款, 1-50%, 2-零首付")
private Integer downPaymentRatio;
@ApiModelProperty(notes = "购车背景, 0-首购, 1-增购")
private Integer purchaseBackground;
@ApiModelProperty(notes = "是否本地用车, 0-本地, 1-外地")
private Integer isLocalUse;
@ApiModelProperty(notes = "购车用途, 0-公司车, 1-家庭用车")
private Integer purchasePurpose;
@ApiModelProperty(notes = "购车时加装项目(多选,英文逗号分隔保存int编码), 0-零重力座椅, 1-轮毂, 2-内饰, 3-玻璃")
private String installItems;
@ApiModelProperty(notes = "赠送精品项目(多选,英文逗号分隔保存int编码), 0-脚垫, 1-车衣, 2-底盘护板, 3-电动踏板, 4-小桌板,5-窗膜")
private String giftItems;
@ApiModelProperty(notes = "贴膜品牌(手填文本)")
private String filmBrand;
@ApiModelProperty(notes = "是否了解其它品牌精品, 0-是, 1-否")
private Integer knowOtherBrandGoods;
}
package cn.com.glsx.dj.mindworkplate.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.io.Serializable;
@Data
public class ReceptionCustomerFileExportDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ExcelProperty(value = "驻店人员")
private String salesName;
@ExcelProperty(value = "门店名称")
private String merchantName;
@ExcelProperty(value = "接待日期")
@ColumnWidth(20)
private String receptionStartTimeStr;
@ExcelProperty(value = "客户姓名")
@ColumnWidth(15)
private String customerName;
@ExcelProperty(value = "接待录音链接")
@ColumnWidth(40)
private String fileUrl;
@ExcelProperty(value = "客户手机号")
@ColumnWidth(15)
private String phoneNumber;
@ExcelProperty(value = "车型")
@ColumnWidth(20)
private String carModel;
@ExcelProperty(value = "接待结果")
@ColumnWidth(12)
private String receptionResultStr;
@ExcelProperty(value = "结果归因(新增)")
@ColumnWidth(20)
private String resultAttributionStr;
@ExcelProperty(value = "用车人")
@ColumnWidth(12)
private String carUserTypeStr;
@ExcelProperty(value = "客户背景")
@ColumnWidth(15)
private String customerBackgroundStr;
@ExcelProperty(value = "是否好沟通")
@ColumnWidth(12)
private String easyCommunicationStr;
@ExcelProperty(value = "是否按揭")
@ColumnWidth(12)
private String isMortgageStr;
@ExcelProperty(value = "首付比例")
@ColumnWidth(12)
private String downPaymentRatioStr;
@ExcelProperty(value = "购车背景")
@ColumnWidth(12)
private String purchaseBackgroundStr;
@ExcelProperty(value = "是否本地用车")
@ColumnWidth(15)
private String isLocalUseStr;
@ExcelProperty(value = "购车用途")
@ColumnWidth(15)
private String purchasePurposeStr;
@ExcelProperty(value = "加装项目(多选)")
@ColumnWidth(30)
private String installItemsStr;
@ExcelProperty(value = "赠送精品项目(多选)")
@ColumnWidth(30)
private String giftItemsStr;
@ExcelProperty(value = "窗膜品牌")
@ColumnWidth(15)
private String filmBrand;
@ExcelProperty(value = "是否了解其它品牌精品")
@ColumnWidth(20)
private String knowOtherBrandGoodsStr;
}
package cn.com.glsx.dj.mindworkplate.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class ReceptionCustomerFileSummaryDTO implements Serializable {
private static final long serialVersionUID = 1L;
// From reception_customer_info
private String salesName;
private String merchantName;
private Date receptionStartTime;
private String customerName;
private String phoneNumber;
private String carModel;
// From inspection_conversation_batch
private String fileUrl;
// From reception_customer_file
private Integer receptionResult;
private Integer dealAttribution;
private Integer loseReason;
private Integer carUserType;
private Integer customerBackground;
private Integer easyCommunication;
private Integer isMortgage;
private Integer downPaymentRatio;
private Integer purchaseBackground;
private Integer isLocalUse;
private Integer purchasePurpose;
private String installItems;
private String giftItems;
private String filmBrand;
private Integer knowOtherBrandGoods;
}
package cn.com.glsx.dj.mindworkplate.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class ReceptionCustomerFileUpdateRequestDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "录音接待id", required = true)
private Integer receptionId;
@ApiModelProperty(notes = "接待结果, 0-成交, 1-战败")
private Integer receptionResult;
@ApiModelProperty(notes = "成交归因(接待结果=0时填写), 0-自然成交, 1-活动成交, 2-对比成交, 3-引导成交, 4-口碑成交, 5-培育成交")
private Integer dealAttribution;
@ApiModelProperty(notes = "战败归因(接待结果=1时填写), 0-价格战败, 1-竞品战败, 2-产品战败, 3-需求战败, 4-决策战败, 5-服务战败, 6-其他战败")
private Integer loseReason;
@ApiModelProperty(notes = "用车人, 0-主人本人, 1-公司户, 2-代办, 3-决策者")
private Integer carUserType;
@ApiModelProperty(notes = "客户背景, 0-企业老板, 1-老师, 2-医生, 3-建筑, 4-个体, 5-自由职业, 6-其他")
private Integer customerBackground;
@ApiModelProperty(notes = "是否好沟通, 0-是, 1-否")
private Integer easyCommunication;
@ApiModelProperty(notes = "是否按揭, 0-是, 1-否")
private Integer isMortgage;
@ApiModelProperty(notes = "首付比例, 0-全款, 1-50%, 2-零首付")
private Integer downPaymentRatio;
@ApiModelProperty(notes = "购车背景, 0-首购, 1-增购")
private Integer purchaseBackground;
@ApiModelProperty(notes = "是否本地用车, 0-本地, 1-外地")
private Integer isLocalUse;
@ApiModelProperty(notes = "购车用途, 0-公司车, 1-家庭用车")
private Integer purchasePurpose;
@ApiModelProperty(notes = "购车时加装项目(多选,英文逗号分隔保存int编码), 0-零重力座椅, 1-轮毂, 2-内饰, 3-玻璃")
private String installItems;
@ApiModelProperty(notes = "赠送精品项目(多选,英文逗号分隔保存int编码), 0-脚垫, 1-车衣, 2-底盘护板, 3-电动踏板, 4-小桌板")
private String giftItems;
@ApiModelProperty(notes = "贴膜品牌(手填文本)")
private String filmBrand;
@ApiModelProperty(notes = "是否了解其它品牌精品, 0-是, 1-否")
private Integer knowOtherBrandGoods;
@ApiModelProperty(notes = "修改人")
private String updatedBy;
}
package cn.com.glsx.dj.mindworkplate.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 = "reception_customer_file")
public class ReceptionCustomerFile implements Serializable {
private static final long serialVersionUID = -1L;
/**
* 主键ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 提交状态, 0-未提交, 1-已提交
*/
@Column(name = "submit_status")
private Integer submitStatus;
/**
* 录音接待id
*/
@Column(name = "reception_id")
private Integer receptionId;
/**
* 接待结果, 0-成交, 1-战败
*/
@Column(name = "reception_result")
private Integer receptionResult;
/**
* 成交归因(接待结果=0时填写), 0-自然成交, 1-活动成交, 2-对比成交, 3-引导成交, 4-口碑成交, 5-培育成交
*/
@Column(name = "deal_attribution")
private Integer dealAttribution;
/**
* 战败归因(接待结果=1时填写), 0-价格战败, 1-竞品战败, 2-产品战败, 3-需求战败, 4-决策战败, 5-服务战败, 6-其他战败
*/
@Column(name = "lose_reason")
private Integer loseReason;
/**
* 用车人, 0-主人本人, 1-公司户, 2-代办, 3-决策者
*/
@Column(name = "car_user_type")
private Integer carUserType;
/**
* 客户背景, 0-企业老板, 1-老师, 2-医生, 3-建筑, 4-个体, 5-自由职业, 6-其他
*/
@Column(name = "customer_background")
private Integer customerBackground;
/**
* 是否好沟通, 0-是, 1-否
*/
@Column(name = "easy_communication")
private Integer easyCommunication;
/**
* 是否按揭, 0-是, 1-否
*/
@Column(name = "is_mortgage")
private Integer isMortgage;
/**
* 首付比例, 0-全款, 1-50%, 2-零首付
*/
@Column(name = "down_payment_ratio")
private Integer downPaymentRatio;
/**
* 购车背景, 0-首购, 1-增购
*/
@Column(name = "purchase_background")
private Integer purchaseBackground;
/**
* 是否本地用车, 0-本地, 1-外地
*/
@Column(name = "is_local_use")
private Integer isLocalUse;
/**
* 购车用途, 0-公司车, 1-家庭用车
*/
@Column(name = "purchase_purpose")
private Integer purchasePurpose;
/**
* 购车时加装项目(多选,英文逗号分隔保存int编码), 0-零重力座椅, 1-轮毂, 2-内饰, 3-玻璃
*/
@Column(name = "install_items")
private String installItems;
/**
* 赠送精品项目(多选,英文逗号分隔保存int编码), 0-脚垫, 1-车衣, 2-底盘护板, 3-电动踏板, 4-小桌板, 5-窗膜
*/
@Column(name = "gift_items")
private String giftItems;
/**
* 贴膜品牌(手填文本)
*/
@Column(name = "film_brand")
private String filmBrand;
/**
* 是否了解其它品牌精品, 0-是, 1-否
*/
@Column(name = "know_other_brand_goods")
private Integer knowOtherBrandGoods;
/**
* 创建人
*/
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@Column(name = "deleted_flag")
private String deletedFlag;
}
...@@ -165,5 +165,10 @@ public class ReceptionCustomerInfo implements Serializable { ...@@ -165,5 +165,10 @@ public class ReceptionCustomerInfo implements Serializable {
@Column(name = "car_purchase_method") @Column(name = "car_purchase_method")
private Integer carPurchaseMethod; private Integer carPurchaseMethod;
@Transient
private String staffName;
@Transient
private String staffPhone;
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.mindworkplate.model.warning;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;
@Data
public class CoefficientListMsgDTO implements Serializable {
/**
* 员工id
*/
@ApiModelProperty(notes = "员工id")
private String staffId;
/**
* 员工姓名
*/
@ApiModelProperty(notes = "员工姓名")
private String staffName;
/**
* 员工手机号
*/
@ApiModelProperty(notes = "员工手机号")
private String staffPhone;
/**
* 4s店门店号
*/
@ApiModelProperty(notes = "4s店门店号")
private String merchantId4s;
/**
* 4s门店名称
*/
@ApiModelProperty(notes = "4s门店名称")
private String merchantName4s;
/**
* 周期指标值
*/
@ApiModelProperty(notes = "周期生态/指标值")
private BigDecimal cycleIndicator;
}
\ No newline at end of file \ No newline at end of file
...@@ -203,4 +203,7 @@ public class Rule implements Serializable { ...@@ -203,4 +203,7 @@ public class Rule implements Serializable {
@Transient @Transient
private Integer sortOrder; private Integer sortOrder;
@Transient
private String staffFieldName;
} }
\ No newline at end of file \ No newline at end of file
...@@ -5,6 +5,7 @@ import cn.com.glsx.dj.mindworkplate.dto.monitoring.MonitorBaseRequest; ...@@ -5,6 +5,7 @@ import cn.com.glsx.dj.mindworkplate.dto.monitoring.MonitorBaseRequest;
import cn.com.glsx.dj.mindworkplate.dto.monitoring.MonitorFilterRequest; import cn.com.glsx.dj.mindworkplate.dto.monitoring.MonitorFilterRequest;
import cn.com.glsx.dj.mindworkplate.dto.monitoring.StoreItemResponse; import cn.com.glsx.dj.mindworkplate.dto.monitoring.StoreItemResponse;
import cn.com.glsx.dj.mindworkplate.model.MonitorTypeDict; import cn.com.glsx.dj.mindworkplate.model.MonitorTypeDict;
import cn.com.glsx.dj.mindworkplate.model.warning.CoefficientListMsgDTO;
import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisDTO; import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisDTO;
import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisRequest; import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisRequest;
import cn.com.glsx.dj.mindworkplate.model.warning.MonitoringMsgDTO; import cn.com.glsx.dj.mindworkplate.model.warning.MonitoringMsgDTO;
...@@ -50,4 +51,9 @@ public interface MonitoringRemote { ...@@ -50,4 +51,9 @@ public interface MonitoringRemote {
@ApiParam(name="request",notes="入参",dataType= DataTypeEnum.OBJECT,required=true) @ApiParam(name="request",notes="入参",dataType= DataTypeEnum.OBJECT,required=true)
@ApiResponse("学习前后的指标") @ApiResponse("学习前后的指标")
RpcResponse<LearningEffectAnalysisDTO> findLearningEffectAnalysis(LearningEffectAnalysisRequest request); RpcResponse<LearningEffectAnalysisDTO> findLearningEffectAnalysis(LearningEffectAnalysisRequest request);
@ApiMethod("根据条件获取系数列表")
@ApiParam(name="request",notes="入参",dataType= DataTypeEnum.OBJECT,required=true)
@ApiResponse("系数列表")
RpcResponse<List<CoefficientListMsgDTO>> getCoefficientListByCondition(MonitorBaseRequest request);
} }
package cn.com.glsx.dj.mindworkplate.remote;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
public interface ReceptionCustomerFileRemote {
RpcResponse<ReceptionCustomerFileDetailDTO> findDetailByReceptionId(Integer receptionId);
RpcResponse<Boolean> updateCustomerFile(ReceptionCustomerFileUpdateRequestDTO request);
}
...@@ -165,11 +165,16 @@ ...@@ -165,11 +165,16 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.com.glsx.merchants</groupId> <groupId>cn.com.glsx.merchants</groupId>
<artifactId>platform-merchants-api</artifactId> <artifactId>platform-merchants-api</artifactId>
<version>5.6.1-SNAPSHOT</version> <version>5.6.1-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-alioss</artifactId>
<version>2.2.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.mindworkplate.job.customer;
import cn.com.glsx.dj.mindworkplate.service.customer.ReceptionCustomerFileGenerateService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
//@ElasticJobConf(name = "ReceptionCustomerFileGenerateJob", cron = "0 0/5 * * * ?", description = "生成接待录音对应的客户档案", overwrite = true)
public class ReceptionCustomerFileGenerateJob implements SimpleJob {
//@Autowired
private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
@Override
public void execute(ShardingContext shardingContext) {
try {
log.info("生成接待录音对应的客户档案任务开始执行");
LocalDate date = getJobDate(shardingContext);
receptionCustomerFileGenerateService.generateLightModCustomerFilesByDate(date);
log.info("生成接待录音对应的客户档案任务结束执行, 日期:{}", date);
} catch (Exception e) {
log.error("生成接待录音对应的客户档案任务执行异常", e);
}
}
private LocalDate getJobDate(ShardingContext shardingContext) {
String param = shardingContext.getJobParameter();
if (StringUtils.isBlank(param)) {
return LocalDate.now(ZoneId.systemDefault());
}
try {
return LocalDate.parse(param.trim(), DateTimeFormatter.ISO_LOCAL_DATE);
} catch (DateTimeParseException e) {
log.warn("生成接待录音对应的客户档案任务日期参数解析失败, param:{}", param);
return LocalDate.now(ZoneId.systemDefault());
}
}
}
package cn.com.glsx.dj.mindworkplate.job.customer;
import cn.com.glsx.dj.mindworkplate.service.customer.ReceptionCustomerFileGenerateService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@ElasticJobConf(name = "ReceptionCustomerFileSummaryJob", cron = "0 0 8 ? * MON", description = "每周一汇总轻改业务客户档案信息并推送到埋点群", overwrite = true)
public class ReceptionCustomerFileSummaryJob implements SimpleJob {
@Autowired
private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
@Override
public void execute(ShardingContext shardingContext) {
try {
log.info("每周汇总轻改业务客户档案信息任务开始执行");
String jobParam = shardingContext.getJobParameter();
if (StringUtils.isNotBlank(jobParam)) {
String[] dates = jobParam.split(",");
if (dates.length == 2) {
receptionCustomerFileGenerateService.exportAndPushSummary(dates[0], dates[1]);
} else {
log.warn("定时任务参数格式不正确,期望格式:'yyyy-MM-dd,yyyy-MM-dd',实际:{}", jobParam);
receptionCustomerFileGenerateService.exportAndPushSummary(null, null); // 使用默认日期范围
}
} else {
receptionCustomerFileGenerateService.exportAndPushSummary(null, null); // 使用默认日期范围
}
log.info("每周汇总轻改业务客户档案信息任务结束执行");
} catch (Exception e) {
log.error("每周汇总轻改业务客户档案信息任务执行异常", e);
}
}
}
package cn.com.glsx.dj.mindworkplate.mapper;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileSummaryDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerFile;
import cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface ReceptionCustomerFileMapper extends OreMapper<ReceptionCustomerFile> {
List<ReceptionCustomerInfo> listNeedGenerateTodayLightModReception(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime);
Integer batchInsertInit(@Param("list") List<ReceptionCustomerFile> list);
Integer updateCustomerFileFlag(@Param("ids") List<Integer> ids);
Integer updatePushStatusByReceptionIds(@Param("receptionIds") List<Integer> receptionIds);
ReceptionCustomerFileDetailDTO findDetailByReceptionId(@Param("receptionId") Integer receptionId);
Integer updateByReceptionId(ReceptionCustomerFileUpdateRequestDTO request);
ReceptionCustomerFile selectByReceptionId(@Param("receptionId") Integer receptionId);
List<ReceptionCustomerFileSummaryDTO> listSummaryBetweenDates(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime);
}
...@@ -5,6 +5,7 @@ import cn.com.glsx.dj.mindworkplate.dto.monitoring.MonitorBaseRequest; ...@@ -5,6 +5,7 @@ import cn.com.glsx.dj.mindworkplate.dto.monitoring.MonitorBaseRequest;
import cn.com.glsx.dj.mindworkplate.dto.monitoring.MonitorFilterRequest; import cn.com.glsx.dj.mindworkplate.dto.monitoring.MonitorFilterRequest;
import cn.com.glsx.dj.mindworkplate.dto.monitoring.StoreItemResponse; import cn.com.glsx.dj.mindworkplate.dto.monitoring.StoreItemResponse;
import cn.com.glsx.dj.mindworkplate.model.MonitorTypeDict; import cn.com.glsx.dj.mindworkplate.model.MonitorTypeDict;
import cn.com.glsx.dj.mindworkplate.model.warning.CoefficientListMsgDTO;
import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisDTO; import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisDTO;
import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisRequest; import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisRequest;
import cn.com.glsx.dj.mindworkplate.model.warning.MonitoringMsgDTO; import cn.com.glsx.dj.mindworkplate.model.warning.MonitoringMsgDTO;
...@@ -101,4 +102,13 @@ public class MonitoringRemoteImpl implements MonitoringRemote{ ...@@ -101,4 +102,13 @@ public class MonitoringRemoteImpl implements MonitoringRemote{
} }
} }
@Override
public RpcResponse<List<CoefficientListMsgDTO>> getCoefficientListByCondition(MonitorBaseRequest request) {
try {
return RpcResponse.success(monitoringService.getCoefficientListByCondition(request));
} catch (Exception e) {
log.error("获取系数列表失败: {}", e.getMessage(), e);
return RpcResponse.error( e);
}
}
} }
package cn.com.glsx.dj.mindworkplate.remote;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.dj.mindworkplate.service.customer.ReceptionCustomerFileGenerateService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
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(protocol = "dubbo")
@Component
public class ReceptionCustomerFileRemoteImpl implements ReceptionCustomerFileRemote {
@Autowired
private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
@Override
public RpcResponse<ReceptionCustomerFileDetailDTO> findDetailByReceptionId(Integer receptionId) {
try {
ReceptionCustomerFileDetailDTO result = receptionCustomerFileGenerateService.findDetailByReceptionId(receptionId);
return RpcResponse.success(result);
} catch (RpcServiceException e) {
log.error("查询客户档案详情接口调用异常!", e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("查询客户档案详情接口调用异常!", e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<Boolean> updateCustomerFile(ReceptionCustomerFileUpdateRequestDTO request) {
try {
boolean result = receptionCustomerFileGenerateService.updateCustomerFile(request);
return RpcResponse.success(result);
} catch (RpcServiceException e) {
log.error("更新客户档案接口调用异常!", e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("更新客户档案接口调用异常!", e);
return RpcResponse.error(e);
}
}
}
package cn.com.glsx.dj.mindworkplate.service.customer;
import cn.com.glsx.dj.mindworkplate.util.HttpUtil;
import cn.com.glsx.entmicro.model.request.EntmicroStaffRequest;
import cn.com.glsx.entmicro.model.response.EntmicroStaffResponse;
import cn.com.glsx.entmicro.remote.EntmicroStaffRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.response.SendWorkWechatMessageResponseDTO;
import cn.com.glsx.scrm.wechat.remote.WorkWechatMessageRemote;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
public class QWManager {
@Autowired
private Environment environment;
@Resource
private EntmicroStaffRemote entmicroStaffRemote;
@Autowired
private WorkWechatMessageRemote workWechatMessageRemote;
/**
* 通过http请求发送企微应用消息
*
* @param sendWorkWechatMessageRequestDTO
* @return
*/
public SendWorkWechatMessageResponseDTO sendMessage(SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
log.info("发送企微应用消息:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO));
SendWorkWechatMessageResponseDTO responseDTO=null;
try {
String baseurl = environment.getProperty("wechat.base.path")+"/wechat/message/sendMessage";
responseDTO = HttpUtil.post(baseurl,JSONObject.parseObject(JSONObject.toJSONString(sendWorkWechatMessageRequestDTO)), SendWorkWechatMessageResponseDTO.class);
log.info("发送企微应用消息 ropResponse:{}", JSON.toJSONString(responseDTO));
} catch (Exception e) {
e.printStackTrace();
log.info("发送企微应用消息异常:", e);
}
return responseDTO;
}
public boolean sendSingleWechatMessage(SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
log.info("sendMessage request:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO));
RpcResponse<SendWorkWechatMessageResponseDTO> sendWorkWechatMessageResponseDTORpcResponse = workWechatMessageRemote
.sendMessage(sendWorkWechatMessageRequestDTO);
log.info("sendMessage resp:{}", JSON.toJSONString(sendWorkWechatMessageResponseDTORpcResponse));
if (!sendWorkWechatMessageResponseDTORpcResponse.isSuccess()) {
log.info("发送企微消息,参数为:{},异常:{}", sendWorkWechatMessageRequestDTO,
sendWorkWechatMessageResponseDTORpcResponse.getException());
return false;
}
return true;
}
/**
* 通过商户号+手机号查询企微员工标识
*
* @param merchantId 商户号
* @param mobile 手机号
* @return 企微userId
*/
public String getUserId(Integer merchantId, String mobile) {
log.info("查询企微员工标识, 商户号:{}, 手机号:{}", merchantId, mobile);
String userId = null;
try {
String baseurl = environment.getProperty("wechat.base.path") + "/wechat/oa/getuserid";
JSONObject requestBody = new JSONObject();
requestBody.put("merchantId", merchantId);
requestBody.put("mobile", mobile);
JSONObject responseDTO = HttpUtil.post(baseurl, requestBody, JSONObject.class);
log.info("查询企微员工标识 response:{}", JSON.toJSONString(responseDTO));
if (responseDTO != null && responseDTO.getBoolean("success")) {
userId = responseDTO.getString("userid");
}
} catch (Exception e) {
e.printStackTrace();
log.error("查询企微员工标识异常:", e);
}
return userId;
}
/**
* 获取全量广联数科员工企微
*/
public Map<String, String> getSendUserIds() {
EntmicroStaffRequest entmicroStaffRequest = new EntmicroStaffRequest();
// dev = 44211227 test = 44209813 线上 = 44202977
Integer merchantId = OrePropertyConfigurer.getProperty("dj.send.work.wechat.merchant.id",Integer.class,44202977);
entmicroStaffRequest.setMerchantId(merchantId);
RpcResponse<List<EntmicroStaffResponse>> staffResponse = entmicroStaffRemote.findStaffByMerchantId(entmicroStaffRequest);
if (staffResponse.hasResult()) {
List<EntmicroStaffResponse> result = staffResponse.getResult();
return result.stream().filter(item ->
StringUtils.isNotBlank(item.getStaffPhone()) && StringUtils.isNotBlank(item.getUserId()))
.collect(Collectors.toMap(EntmicroStaffResponse::getStaffPhone, EntmicroStaffResponse::getUserId, (a, b) -> a));
}
if (staffResponse.isFailed()) {
log.warn("获取发送员工失败,失败原因:{}", staffResponse.getException().getMessage());
}
return null;
}
public String getJoinedUserIds(Map<String, String> phoneToUserIdMap, List<String> phoneNumbers) {
StringBuilder userIds = new StringBuilder();
for (String phoneNumber : phoneNumbers) {
String userId = phoneToUserIdMap.get(phoneNumber);
if (userId != null) {
if (userIds.length() > 0) {
userIds.append("|");
}
userIds.append(userId);
}
}
return userIds.toString();
}
}
package cn.com.glsx.dj.mindworkplate.service.customer;
import cn.com.glsx.dj.mindworkplate.consts.ConfigCenterConstants;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileExportDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileSummaryDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.dj.mindworkplate.enums.MindWorkplateServiceErrorEnum;
import cn.com.glsx.dj.mindworkplate.mapper.ReceptionCustomerFileMapper;
import cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerFile;
import cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo;
import cn.com.glsx.dj.mindworkplate.service.MerchantService;
import cn.com.glsx.dj.mindworkplate.service.customer.QWManager;
import cn.com.glsx.dj.mindworkplate.util.ExcelExportUtils;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.proxy.dto.merchant.ListMerchantRequest;
import cn.com.glsx.scrm.proxy.model.merchant.MerchantRopResponse;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.WorkWechatTextCardMessageDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.enums.WorkWechatAppMessageTypeEnum;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.autoconfigure.alioss.entity.AliOssUploadClient;
import org.oreframework.distribute.lock.annotation.GlsxDistributeLockable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
public class ReceptionCustomerFileGenerateService {
@Autowired
private ReceptionCustomerFileMapper receptionCustomerFileMapper;
@Autowired
private Environment env;
@Autowired
private QWManager qwManager;
@Autowired
private AliOssUploadClient aliOssUploadClient;
@Autowired
private MerchantService merchantService;
@Transactional
public void generateLightModCustomerFilesByDate(LocalDate date) {
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime startOfDay = date.atStartOfDay();
LocalDateTime startOfTomorrow = date.plusDays(1).atStartOfDay();
Date startTime = Date.from(startOfDay.atZone(zoneId).toInstant());
Date endTime = Date.from(startOfTomorrow.atZone(zoneId).toInstant());
log.info("开始查询需要生成的客户接待录音,startTime{},endTime{}", startTime, endTime);
List<ReceptionCustomerInfo> receptionList = receptionCustomerFileMapper.listNeedGenerateTodayLightModReception(
startTime, endTime);
if (CollectionUtils.isEmpty(receptionList)) {
//用中文
log.info("未查询到需要生成的客户接待录音,日期: {}", date);
return;
}
// 发送企微消息通知
sendWeChatPushMessages(receptionList);
}
private void sendWeChatPushMessages(List<ReceptionCustomerInfo> receptionList) {
Integer merchantId = env.getProperty(ConfigCenterConstants.DATA_AI_SPARRING_STAFF_WORK_WECHAT_MERCHANT_ID, Integer.class, 44211227);
String baseUrl = env.getProperty("reception.customer.file.url", "http://localhost:8080");
String agentId = env.getProperty("reception.customer.file.wechat.agent.id");
String title = env.getProperty("reception.customer.file.title", "%s辛苦啦!🎉");
String description = env.getProperty("reception.customer.file.description", "检测到你刚才在平板上完成了对 %s(手机尾号%s)的轻改业务接待录音。\n为了确保后续跟进更精准,请点击 这里 👉 补充%s的轻改档案,完善一下意向信息哦,耗时约1分钟。");
List<Integer> successIds = new ArrayList<>();
List<ReceptionCustomerInfo> sucessList = new ArrayList<>();
for (ReceptionCustomerInfo reception : receptionList) {
try {
String staffName = reception.getStaffName() != null ? reception.getStaffName() : "小张";
String customerName = reception.getCustomerName() != null ? reception.getCustomerName() : "客户";
String phone = reception.getPhoneNumber();
String phoneSuffix = (phone != null && phone.length() >= 4) ? phone.substring(phone.length() - 4) : "";
title = String.format(title, staffName);
description = String.format(description, customerName, phoneSuffix, customerName);
String url = (baseUrl != null ? baseUrl : "") + "?id=" + reception.getId();
SendWorkWechatMessageRequestDTO requestDTO = new SendWorkWechatMessageRequestDTO();
requestDTO.setMerchantId(merchantId);
//requestDTO.setAgentId(agentId);
String userId = qwManager.getUserId(merchantId, reception.getStaffPhone());
//判断是否为空
if (StringUtils.isBlank(userId)) {
log.warn("未查询到员工企微用户ID,receptionId: {}", reception.getId());
continue;
}
requestDTO.setToUser(userId);
requestDTO.setMsgType(WorkWechatAppMessageTypeEnum.TEXTCARD.getValue());
WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO();
textCard.setTitle(title);
textCard.setDescription(description);
textCard.setUrl(url);
requestDTO.setTextCard(textCard);
boolean response = qwManager.sendSingleWechatMessage(requestDTO);
//对接大模型
if (response) {
sucessList.add(reception);
successIds.add(reception.getId());
}
} catch (Exception e) {
log.error("发送企微消息失败,receptionId: {}", reception.getId(), e);
}
}
if (CollectionUtils.isNotEmpty(sucessList)) {
//批量更新发送企微状态
Date now = new Date();
List<ReceptionCustomerFile> insertList = receptionList.stream()
.map(x -> buildInitCustomerFile(x, now))
.collect(Collectors.toList());
receptionCustomerFileMapper.batchInsertInit(insertList);
}
}
private ReceptionCustomerFile buildInitCustomerFile(ReceptionCustomerInfo receptionCustomerInfo, Date createdDate) {
ReceptionCustomerFile file = new ReceptionCustomerFile();
file.setSubmitStatus(0);
file.setReceptionId(receptionCustomerInfo.getId());
file.setCreatedBy("system");
file.setCreatedDate(createdDate);
file.setDeletedFlag("N");
return file;
}
public ReceptionCustomerFileDetailDTO findDetailByReceptionId(Integer receptionId) {
ReceptionCustomerFileDetailDTO detailDTO = receptionCustomerFileMapper.findDetailByReceptionId(receptionId);
if (detailDTO != null) {
detailDTO.setPhoneNumber(maskPhoneNumber(detailDTO.getPhoneNumber()));
}
return detailDTO;
}
private String maskPhoneNumber(String phone) {
if (phone == null || phone.length() != 11) {
return phone;
}
return phone.substring(0, 3) + "****" + phone.substring(7);
}
@GlsxDistributeLockable(name="'ReceptionCustomerFileGenerateService_updateCustomerFile_' + #request.receptionId", timeoutException=Exception.class)
@Transactional
public boolean updateCustomerFile(ReceptionCustomerFileUpdateRequestDTO request) {
if (request == null || request.getReceptionId() == null) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL);
}
ReceptionCustomerFile existingFile = receptionCustomerFileMapper.selectByReceptionId(request.getReceptionId());
if (existingFile != null) {
// 记录存在,执行更新
if (existingFile.getSubmitStatus() != null && existingFile.getSubmitStatus() == 1) {
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, "该客户档案已提交,不可重复提交");
}
receptionCustomerFileMapper.updateByReceptionId(request);
} else {
// 记录不存在,执行插入
ReceptionCustomerFile newFile = new ReceptionCustomerFile();
newFile.setReceptionId(request.getReceptionId());
newFile.setReceptionResult(request.getReceptionResult());
newFile.setDealAttribution(request.getDealAttribution());
newFile.setLoseReason(request.getLoseReason());
newFile.setCarUserType(request.getCarUserType());
newFile.setCustomerBackground(request.getCustomerBackground());
newFile.setEasyCommunication(request.getEasyCommunication());
newFile.setIsMortgage(request.getIsMortgage());
newFile.setDownPaymentRatio(request.getDownPaymentRatio());
newFile.setPurchaseBackground(request.getPurchaseBackground());
newFile.setIsLocalUse(request.getIsLocalUse());
newFile.setPurchasePurpose(request.getPurchasePurpose());
newFile.setInstallItems(request.getInstallItems());
newFile.setGiftItems(request.getGiftItems());
newFile.setFilmBrand(request.getFilmBrand());
newFile.setKnowOtherBrandGoods(request.getKnowOtherBrandGoods());
newFile.setSubmitStatus(1); // 插入时直接设置为已提交
newFile.setCreatedBy(request.getUpdatedBy() != null ? request.getUpdatedBy() : "system");
newFile.setCreatedDate(new Date());
newFile.setDeletedFlag("N");
receptionCustomerFileMapper.insert(newFile);
}
return true;
}
public void exportAndPushSummary(String startDateStr, String endDateStr) {
LocalDate prevMonday;
LocalDate prevSunday;
if (StringUtils.isNotBlank(startDateStr) && StringUtils.isNotBlank(endDateStr)) {
prevMonday = LocalDate.parse(startDateStr);
prevSunday = LocalDate.parse(endDateStr);
} else {
// 计算上周时间范围:上周一 00:00:00 到 上周日 23:59:59
LocalDate today = LocalDate.now();
LocalDate thisMonday = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
prevMonday = thisMonday.minusWeeks(1);
prevSunday = thisMonday.minusDays(1);
}
Date startTime = Date.from(prevMonday.atStartOfDay(ZoneId.systemDefault()).toInstant());
Date endTime = Date.from(prevSunday.atTime(LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant());
log.info("汇总导出客户档案数据,范围: {} 至 {}", prevMonday, prevSunday);
List<ReceptionCustomerFileSummaryDTO> summaryList = receptionCustomerFileMapper.listSummaryBetweenDates(startTime, endTime);
if (CollectionUtils.isEmpty(summaryList)) {
log.info("上周无提交的客户档案数据,跳过导出");
return;
}
// 获取所有门店名称
Set<String> merchantNos = summaryList.stream()
.map(ReceptionCustomerFileSummaryDTO::getMerchantName)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
Map<String, String> merchantNameMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(merchantNos)) {
try {
ListMerchantRequest merchantRequest = new ListMerchantRequest();
merchantRequest.setMerchantNoStrSet(String.join(",", merchantNos));
List<MerchantRopResponse> merchantList = merchantService.findMerchantListByCondition(merchantRequest);
if (CollectionUtils.isNotEmpty(merchantList)) {
merchantNameMap = merchantList.stream().collect(Collectors.toMap(MerchantRopResponse::getMerchantNo, MerchantRopResponse::getMerchantName, (k1, k2) -> k1));
}
} catch (Exception e) {
log.error("获取门店名称失败", e);
}
}
Map<String, String> finalMerchantNameMap = merchantNameMap;
List<ReceptionCustomerFileExportDTO> exportList = summaryList.stream().map(s -> {
ReceptionCustomerFileExportDTO e = new ReceptionCustomerFileExportDTO();
e.setSalesName(s.getSalesName());
e.setMerchantName(finalMerchantNameMap.getOrDefault(s.getMerchantName(), s.getMerchantName()));
e.setReceptionStartTimeStr(DateUtil.formatDateTime(s.getReceptionStartTime()));
e.setCustomerName(s.getCustomerName());
e.setFileUrl(s.getFileUrl());
e.setPhoneNumber(s.getPhoneNumber());
e.setCarModel(s.getCarModel());
e.setReceptionResultStr(Objects.equals(s.getReceptionResult(), 0) ? "成交" : "战败");
// 结果归因
if (Objects.equals(s.getReceptionResult(), 0)) {
e.setResultAttributionStr(mapDealAttribution(s.getDealAttribution()));
} else if (Objects.equals(s.getReceptionResult(), 1)) {
e.setResultAttributionStr(mapLoseReason(s.getLoseReason()));
} else {
e.setResultAttributionStr("");
}
e.setCarUserTypeStr(mapCarUserType(s.getCarUserType()));
e.setCustomerBackgroundStr(mapCustomerBackground(s.getCustomerBackground()));
e.setEasyCommunicationStr(Objects.equals(s.getEasyCommunication(), 0) ? "是" : "否");
e.setIsMortgageStr(Objects.equals(s.getIsMortgage(), 0) ? "是" : "否");
e.setDownPaymentRatioStr(mapDownPaymentRatio(s.getDownPaymentRatio()));
e.setPurchaseBackgroundStr(Objects.equals(s.getPurchaseBackground(), 0) ? "首购" : "增购");
e.setIsLocalUseStr(Objects.equals(s.getIsLocalUse(), 0) ? "本地" : "外地");
e.setPurchasePurposeStr(Objects.equals(s.getPurchasePurpose(), 0) ? "公司车" : "家庭用车");
e.setInstallItemsStr(mapMultiSelectItems(s.getInstallItems(), new String[]{"零重力座椅", "轮毂", "内饰", "玻璃"}));
e.setGiftItemsStr(mapMultiSelectItems(s.getGiftItems(), new String[]{"脚垫", "车衣", "底盘护板", "电动踏板", "小桌板", "窗膜"}));
e.setFilmBrand(s.getFilmBrand());
e.setKnowOtherBrandGoodsStr(Objects.equals(s.getKnowOtherBrandGoods(), 0) ? "是" : "否");
return e;
}).collect(Collectors.toList());
String fileName = "轻改业务客户档案汇总_" + prevMonday + "_" + prevSunday;
exportBurialPointRecord(fileName, exportList, ReceptionCustomerFileExportDTO.class);
}
private String mapDealAttribution(Integer val) {
if (val == null) return "";
switch (val) {
case 0: return "自然成交";
case 1: return "活动成交";
case 2: return "对比成交";
case 3: return "引导成交";
case 4: return "口碑成交";
case 5: return "培育成交";
default: return "";
}
}
private String mapLoseReason(Integer val) {
if (val == null) return "";
switch (val) {
case 0: return "价格战败";
case 1: return "竞品战败";
case 2: return "产品战败";
case 3: return "需求战败";
case 4: return "决策战败";
case 5: return "服务战败";
case 6: return "其他战败";
default: return "";
}
}
private String mapCarUserType(Integer val) {
if (val == null) return "";
switch (val) {
case 0: return "主人本人";
case 1: return "公司户";
case 2: return "代办";
case 3: return "决策者";
default: return "";
}
}
private String mapCustomerBackground(Integer val) {
if (val == null) return "";
switch (val) {
case 0: return "企业老板";
case 1: return "老师";
case 2: return "医生";
case 3: return "建筑";
case 4: return "个体";
case 5: return "自由职业";
case 6: return "其他";
default: return "";
}
}
private String mapDownPaymentRatio(Integer val) {
if (val == null) return "";
switch (val) {
case 0: return "全款";
case 1: return "50%";
case 2: return "零首付";
default: return "";
}
}
private String mapMultiSelectItems(String val, String[] names) {
if (StringUtils.isBlank(val)) return "";
try {
return Arrays.stream(val.split(","))
.map(String::trim)
.filter(StringUtils::isNotBlank)
.map(Integer::parseInt)
.filter(i -> i >= 0 && i < names.length)
.map(i -> names[i])
.collect(Collectors.joining("、"));
} catch (Exception e) {
return val;
}
}
/**
* 导出表格数据,并发送机器人
* @param fileName
* @param list
* @param classType
*/
public void exportBurialPointRecord(String fileName, List<? extends Object> list, Class classType) {
byte[] bytes = ExcelExportUtils.excelExportWithoutUpload(fileName + new Date().getTime(), list, classType, null);
InputStream inputStream = new ByteArrayInputStream(bytes);
String bucketName = env.getProperty("ore.alioss.bucketName");
String fileUrl = aliOssUploadClient.uploadFileSimple4InputStream(bucketName, fileName + ".xlsx", inputStream, null);
log.info("埋点文件[{}]返回地址[{}]", fileName, fileUrl);
//发送机器人
String content = fileName + "文件下载地址: " + fileUrl;
String key = env.getProperty("burial.point.excel.qw.robot.key");
if (StringUtils.isEmpty(key)) {
log.info("推送企微机器人消息通知失败,机器人key配置为空");
return;
}
Map<String, Object> body = new HashMap<>();
body.put("msgtype", "markdown");
Map<String, String> markdown = new HashMap<>();
markdown.put("content", content);
body.put("markdown", markdown);
String textMessageUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=" + key;
String post = HttpUtil.post(textMessageUrl, JSON.toJSONString(body));
log.info("推送企微机器人埋点消息通知结果[{}]", post);
}
}
...@@ -11,6 +11,7 @@ import cn.com.glsx.dj.mindworkplate.model.EarlyWarningRuleCondition; ...@@ -11,6 +11,7 @@ import cn.com.glsx.dj.mindworkplate.model.EarlyWarningRuleCondition;
import cn.com.glsx.dj.mindworkplate.model.EarlyWarningRulePrefix; import cn.com.glsx.dj.mindworkplate.model.EarlyWarningRulePrefix;
import cn.com.glsx.dj.mindworkplate.model.MonitorTypeDict; import cn.com.glsx.dj.mindworkplate.model.MonitorTypeDict;
import cn.com.glsx.dj.mindworkplate.model.WarningMsgRuleModel; import cn.com.glsx.dj.mindworkplate.model.WarningMsgRuleModel;
import cn.com.glsx.dj.mindworkplate.model.warning.CoefficientListMsgDTO;
import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisDTO; import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisDTO;
import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisRequest; import cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisRequest;
import cn.com.glsx.dj.mindworkplate.model.warning.MonMetricsDTO; import cn.com.glsx.dj.mindworkplate.model.warning.MonMetricsDTO;
...@@ -653,4 +654,106 @@ public class MonitoringService { ...@@ -653,4 +654,106 @@ public class MonitoringService {
} }
} }
public List<CoefficientListMsgDTO> getCoefficientListByCondition(MonitorBaseRequest request) {
// 参数验证
if (request == null || request.getBusinessType() == null || request.getStartDate() == null || request.getEndDate() == null) {
log.error("参数验证失败: request={}", request);
return new ArrayList<>();
}
try {
List<Rule> rules = ruleMapper.selectByTypeAndMetricType(request.getBusinessType(), request.getMonitorType(), request.getMetricTypeId());
if (CollectionUtils.isEmpty(rules)) {
log.info("未找到匹配的规则: businessType={}, monitorType={}, metricTypeId={}",
request.getBusinessType(), request.getMonitorType(), request.getMetricTypeId());
return new ArrayList<>();
}
List<CompletableFuture<List<ItemDetail>>> futures = new ArrayList<>();
for (Rule rule : rules) {
QueryParams queryParams = buildQueryParams(request, rule);
futures.add(
CompletableFuture.supplyAsync(() -> dateService.getItemDetail(queryParams, DateService.DATE), executor)
);
}
// 等待所有规则执行完成,并扁平化结果
List<ItemDetail> itemDetailList = futures.stream()
.map(CompletableFuture::join) // 阻塞等待每个 future 完成
.flatMap(List::stream) // 合并所有 List<ItemDetail> 为一个流
.collect(Collectors.toList());
List<CoefficientListMsgDTO> coefficientListMsgDTOS = itemDetailList.stream()
.map(this::convertToCoefficientListMsgDTO)
.collect(Collectors.toList());
log.info("获取系数列表成功,返回数据量: {}", coefficientListMsgDTOS.size());
return coefficientListMsgDTOS;
} catch (Exception e) {
log.error("获取系数列表失败: {}", e.getMessage(), e);
return new ArrayList<>();
}
}
/**
* 构建查询参数
*/
private QueryParams buildQueryParams(MonitorBaseRequest request, Rule rule) {
QueryParams queryParams = new QueryParams();
queryParams.setBizs(changeBusiness(request.getBusinessType()));
queryParams.setStartDate(request.getStartDate());
queryParams.setEndDate(request.getEndDate());
queryParams.setDateType(4);
queryParams.setBrandIds(env.getProperty("check.param.brandIds") == null ? "-1,-2,-4,3454" : env.getProperty("check.param.brandIds"));
// 设置分组类型
if (request.getExts() != null) {
if (request.getExts().intValue() == 1) {
queryParams.setExts("merchantIds,staffIds");
} else if (request.getExts().intValue() == 2) {
queryParams.setExts("merchantIds");
}
} else {
queryParams.setExts("merchantIds");
}
// 设置ID和字段代码
if (request.getExts() != null && request.getExts().intValue() == 1) {
// 场景 1: 按员工分组
queryParams.setStaffIds(convertListToString(request.getUuidLists()));
queryParams.setItemCodes(rule.getStaffFieldName());
} else {
// 场景 2 或默认: 按门店分组
queryParams.setMerchantIds(convertListToString(request.getMerchantIds()));
queryParams.setItemCodes(rule.getFieldName());
}
return queryParams;
}
/**
* 转换为CoefficientListMsgDTO
*/
private CoefficientListMsgDTO convertToCoefficientListMsgDTO(ItemDetail itemDetail) {
CoefficientListMsgDTO dto = new CoefficientListMsgDTO();
dto.setCycleIndicator(ecoCoefficientService.getCoefficient(itemDetail.getItemCode(), itemDetail.getItemValue().doubleValue()));
dto.setMerchantId4s(itemDetail.getMerchantId());
dto.setMerchantName4s(itemDetail.getMerchantName());
dto.setStaffId(itemDetail.getStaffId());
dto.setStaffName(itemDetail.getStaffName());
dto.setStaffPhone(itemDetail.getStaffPhone());
return dto;
}
// --- 辅助方法 ---
private String convertListToString(List<?> list) {
if (list == null || list.isEmpty()) {
return "";
}
return list.stream()
.map(Object::toString)
.collect(Collectors.joining(","));
}
} }
...@@ -78,6 +78,34 @@ public class EasyExcelUtils { ...@@ -78,6 +78,34 @@ public class EasyExcelUtils {
head.excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data); head.excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
} }
/**
* 导出
*
* @param os
* @param data
* @param sheetName
* @param clazz
*/
public static void writeExcelWithOutWraypped(OutputStream os, List<? extends Object> data, String sheetName, Class clazz, String serviceProviderType) {
//表头样式
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// 允许自动换行
headWriteCellStyle.setWrapped(true);
//设置表头居中对齐
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
WriteFont writeFont = new WriteFont();
writeFont.setFontHeightInPoints((short) 12);
headWriteCellStyle.setWriteFont(writeFont);
//内容样式
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
//设置内容靠左对齐
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
contentWriteCellStyle.setWrapped(false);
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
ExcelWriterBuilder head = EasyExcel.write(os).head(clazz);
head.excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
}
/** /**
* 导出 * 导出
* *
......
...@@ -50,4 +50,11 @@ public class ExcelExportUtils { ...@@ -50,4 +50,11 @@ public class ExcelExportUtils {
} }
} }
} }
public static byte[] excelExportWithoutUpload(String filename, List<? extends Object> list, Class clazz, String serviceProviderType) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
EasyExcelUtils.writeExcelWithOutWraypped(outputStream, list, filename, clazz, serviceProviderType);
byte[] bytes = outputStream.toByteArray();
return bytes;
}
} }
<?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.ReceptionCustomerFileMapper">
<select id="listNeedGenerateTodayLightModReception" resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo">
select distinct
rci.id as id,
rci.reception_status as receptionStatus,
ieb.employee_name as staffName,
ieb.phone_number as staffPhone,
rci.customer_name as customerName,
rci.phone_number as phoneNumber
from reception_customer_info rci
inner join inspection_badge_recordings ibr on ibr.reception_id = rci.id and ibr.deleted_flag = 'N'
inner join inspection_conversation_batch cb on cb.task_id = rci.id and cb.deleted_flag = 'N'
inner join inspection_conversation_date t2 on cb.conversation_id = t2.id and t2.deleted_flag = 'N'
inner join inspection_employee_badge ieb on ieb.badge_id = t2.badge_id and ieb.deleted_flag = 'N'
where rci.deleted_flag = 'N'
and rci.bussiness_type = 2
and rci.reception_start_time &gt;= #{startTime}
and rci.reception_start_time &lt; #{endTime}
and ibr.recording_id is not null and ibr.recording_id != ''
and not exists (
select 1 from reception_customer_file rcf
where rcf.reception_id = rci.id and rcf.deleted_flag = 'N'
)
order by rci.id asc
</select>
<insert id="batchInsertInit">
insert into reception_customer_file
(submit_status, push_status, reception_id, reception_result, created_by, created_date, deleted_flag)
values
<foreach collection="list" item="item" separator=",">
(#{item.submitStatus}, #{item.pushStatus}, #{item.receptionId}, #{item.receptionResult}, #{item.createdBy}, #{item.createdDate}, #{item.deletedFlag})
</foreach>
</insert>
<update id="updateCustomerFileFlag">
update reception_customer_info
set customer_file_flag = 1, updated_by = 'system', updated_date = now()
where id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<update id="updatePushStatusByReceptionIds">
update reception_customer_file
set push_status = 1, updated_by = 'system', updated_date = now()
where reception_id in
<foreach collection="receptionIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<select id="findDetailByReceptionId" resultType="cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO">
select
rci.customer_name as customerName,
rci.phone_number as phoneNumber,
rci.reception_start_time as receptionStartTime,
rci.car_brand as carBrand,
rcf.id as id,
rcf.submit_status as submitStatus,
rcf.reception_id as receptionId,
rcf.reception_result as receptionResult,
rcf.deal_attribution as dealAttribution,
rcf.lose_reason as loseReason,
rcf.car_user_type as carUserType,
rcf.customer_background as customerBackground,
rcf.easy_communication as easyCommunication,
rcf.is_mortgage as isMortgage,
rcf.down_payment_ratio as downPaymentRatio,
rcf.purchase_background as purchaseBackground,
rcf.is_local_use as isLocalUse,
rcf.purchase_purpose as purchasePurpose,
rcf.install_items as installItems,
rcf.gift_items as giftItems,
rcf.film_brand as filmBrand,
rcf.know_other_brand_goods as knowOtherBrandGoods
from inspection_conversation_batch t2
LEFT JOIN reception_customer_file rcf on rcf.reception_id = t2.record_id and rcf.deleted_flag = 'N'
left join reception_customer_info rci on t2.task_id = rci.id and rci.deleted_flag = 'N'
where t2.record_id = #{receptionId}
limit 1
</select>
<update id="updateByReceptionId">
update reception_customer_file
<set>
<if test="receptionResult != null">reception_result = #{receptionResult},</if>
<if test="dealAttribution != null">deal_attribution = #{dealAttribution},</if>
<if test="loseReason != null">lose_reason = #{loseReason},</if>
<if test="carUserType != null">car_user_type = #{carUserType},</if>
<if test="customerBackground != null">customer_background = #{customerBackground},</if>
<if test="easyCommunication != null">easy_communication = #{easyCommunication},</if>
<if test="isMortgage != null">is_mortgage = #{isMortgage},</if>
<if test="downPaymentRatio != null">down_payment_ratio = #{downPaymentRatio},</if>
<if test="purchaseBackground != null">purchase_background = #{purchaseBackground},</if>
<if test="isLocalUse != null">is_local_use = #{isLocalUse},</if>
<if test="purchasePurpose != null">purchase_purpose = #{purchasePurpose},</if>
<if test="installItems != null">install_items = #{installItems},</if>
<if test="giftItems != null">gift_items = #{giftItems},</if>
<if test="filmBrand != null">film_brand = #{filmBrand},</if>
<if test="knowOtherBrandGoods != null">know_other_brand_goods = #{knowOtherBrandGoods},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
submit_status = 1,
updated_date = now()
</set>
where reception_id = #{receptionId}
and deleted_flag = 'N'
</update>
<select id="listSummaryBetweenDates" resultType="cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileSummaryDTO">
select
ieb.employee_name as salesName,
rci.merchant_id as merchantName,
rci.reception_start_time as receptionStartTime,
rci.customer_name as customerName,
rci.phone_number as phoneNumber,
rci.car_model as carModel,
icb.file_url as fileUrl,
rcf.reception_result as receptionResult,
rcf.deal_attribution as dealAttribution,
rcf.lose_reason as loseReason,
rcf.car_user_type as carUserType,
rcf.customer_background as customerBackground,
rcf.easy_communication as easyCommunication,
rcf.is_mortgage as isMortgage,
rcf.down_payment_ratio as downPaymentRatio,
rcf.purchase_background as purchaseBackground,
rcf.is_local_use as isLocalUse,
rcf.purchase_purpose as purchasePurpose,
rcf.install_items as installItems,
rcf.gift_items as giftItems,
rcf.film_brand as filmBrand,
rcf.know_other_brand_goods as knowOtherBrandGoods
from reception_customer_file rcf
left join inspection_conversation_batch icb on rcf.reception_id = icb.record_id and icb.deleted_flag = 'N'
left join reception_customer_info rci on icb.task_id = rci.id and rci.deleted_flag = 'N'
LEFT JOIN inspection_badge_recordings t3 ON icb.record_id = t3.id and t3.deleted_flag = 'N'
LEFT JOIN inspection_employee_badge ieb ON t3.badge_id = ieb.badge_id and ieb.deleted_flag = 'N'
where rcf.submit_status = 1
and rcf.created_date &gt;= #{startTime}
and rcf.created_date &lt; #{endTime}
and rcf.deleted_flag = 'N'
order by rcf.created_date desc
</select>
<select id="selectByReceptionId" resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerFile">
select
id,
submit_status as submitStatus,
reception_id as receptionId,
reception_result as receptionResult,
deal_attribution as dealAttribution,
lose_reason as loseReason,
car_user_type as carUserType,
customer_background as customerBackground,
easy_communication as easyCommunication,
is_mortgage as isMortgage,
down_payment_ratio as downPaymentRatio,
purchase_background as purchaseBackground,
is_local_use as isLocalUse,
purchase_purpose as purchasePurpose,
install_items as installItems,
gift_items as giftItems,
film_brand as filmBrand,
know_other_brand_goods as knowOtherBrandGoods,
created_by as createdBy,
created_date as createdDate,
updated_by as updatedBy,
updated_date as updatedDate,
deleted_flag as deletedFlag
from reception_customer_file
where reception_id = #{receptionId}
and deleted_flag = 'N'
limit 1
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<result column="field_name" property="fieldName" jdbcType="VARCHAR" /> <result column="field_name" property="fieldName" jdbcType="VARCHAR" />
<result column="sortOrder" property="sortOrder" jdbcType="INTEGER" /> <result column="sortOrder" property="sortOrder" jdbcType="INTEGER" />
<result column="sort_id" property="sortId" jdbcType="INTEGER" /> <result column="sort_id" property="sortId" jdbcType="INTEGER" />
<result column="staff_field_name" property="staffFieldName" jdbcType="VARCHAR" />
</resultMap> </resultMap>
<resultMap id="MsgResultMap" type="cn.com.glsx.dj.mindworkplate.model.warning.WarningMsg" > <resultMap id="MsgResultMap" type="cn.com.glsx.dj.mindworkplate.model.warning.WarningMsg" >
<result column="staff_id" property="staffId" jdbcType="VARCHAR" /> <result column="staff_id" property="staffId" jdbcType="VARCHAR" />
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
</select> </select>
<select id="selectByTypeAndMetricType" <select id="selectByTypeAndMetricType"
resultMap="BaseResultMap"> resultMap="BaseResultMap">
SELECT t1.*,t2.field_name,t3.sort_order as sortOrder FROM early_warning_rule t1 SELECT t1.*,t2.field_name,t2.staff_field_name,t3.sort_order as sortOrder FROM early_warning_rule t1
LEFT JOIN early_warning_rule_condition t2 ON t1.id=t2.rule_id LEFT JOIN early_warning_rule_condition t2 ON t1.id=t2.rule_id
left join monitor_type_dict t3 on t1.monitor_type_dict_id=t3.type_code left join monitor_type_dict t3 on t1.monitor_type_dict_id=t3.type_code
where strategy_flag=1 and t1.deleted_flag='N' where strategy_flag=1 and t1.deleted_flag='N'
......
package cn.com.glsx.dj.mindworkplate.service.customer;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.dj.mindworkplate.service.BaseServiceTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDate;
public class ReceptionCustomerFileGenerateServiceTest extends BaseServiceTest {
@Autowired
private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
@Test
public void testGenerateLightModCustomerFilesByDate() {
//指定日期:2024-05-10
LocalDate date = LocalDate.of(2024, 5, 10);
receptionCustomerFileGenerateService.generateLightModCustomerFilesByDate(date);
}
@Test
public void testUpdateCustomerFile() {
ReceptionCustomerFileUpdateRequestDTO request = new ReceptionCustomerFileUpdateRequestDTO();
request.setReceptionId(823);
request.setReceptionResult(0);
request.setDealAttribution(0);
//request.setLoseReason(0);
request.setCarUserType(0);
request.setCustomerBackground(0);
request.setEasyCommunication(0);
request.setIsMortgage(0);
request.setDownPaymentRatio(0);
request.setPurchaseBackground(0);
request.setIsLocalUse(0);
request.setPurchasePurpose(0);
request.setInstallItems("0");
request.setGiftItems("0");
request.setFilmBrand("");
request.setKnowOtherBrandGoods(0);
request.setUpdatedBy("ffr");
receptionCustomerFileGenerateService.updateCustomerFile(request);
ReceptionCustomerFileDetailDTO detailByReceptionId = receptionCustomerFileGenerateService.findDetailByReceptionId(823);
System.out.println(detailByReceptionId);
}
@Test
public void testExportAndPushSummary() {
receptionCustomerFileGenerateService.exportAndPushSummary("2026-04-06", "2026-04-12");
}
}
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(Top 3)

    1. 严重违规:Mybatis SQL 中使用了子查询

    • 问题描述:在 ReceptionCustomerFileMapper.xml 的 listNeedGenerateTodayLightModReception 查询中,使用了 not exists (select 1 from reception_customer_file ...) 子查询。这直接违反了“mybatis SQL中不允许使用子查询”的重要规则。
    • 影响分析:子查询在某些数据库版本中可能导致执行计划不佳,引发全表扫描,严重影响数据库性能。
    • 优化建议:使用 LEFT JOIN 结合 IS NULL 来替代 NOT EXISTS 子查询。 xml <select id="listNeedGenerateTodayLightModReception" resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo"> select distinct rci.id as id, ... from reception_customer_info rci ... left join reception_customer_file rcf on rcf.reception_id = rci.id and rcf.deleted_flag = 'N' where rci.deleted_flag = 'N' and rci.bussiness_type = 2 ... and rcf.id is null order by rci.id asc </select>

    2. 逻辑错误:批量插入初始化数据时使用了错误的集合

    • 问题描述:在 ReceptionCustomerFileGenerateService.java 的 sendWeChatPushMessages 方法中,代码通过遍历 receptionList 并根据发送企微消息的结果将成功的记录放入 sucessList。但在最后进行批量插入时,虽然判断了 CollectionUtils.isNotEmpty(sucessList),实际构建 insertList 却错误地使用了原始的 receptionList。
    • 影响分析:会导致企微消息发送失败的接待记录也被错误地标记为已发送/已初始化,导致后续可能无法重试或产生脏数据。
    • 优化建议:将 receptionList.stream() 改为 sucessList.stream()。 java if (CollectionUtils.isNotEmpty(sucessList)) { Date now = new Date(); // 修正:使用 sucessList 而不是 receptionList List<ReceptionCustomerFile> insertList = sucessList.stream() .map(x -> buildInitCustomerFile(x, now)) .collect(Collectors.toList()); receptionCustomerFileMapper.batchInsertInit(insertList); }

    3. 健壮性隐患:Mybatis 批量操作未在 XML 层防止空集合报错

    • 问题描述:ReceptionCustomerFileMapper.xml 中的 updateCustomerFileFlag 和 updatePushStatusByReceptionIds 等方法使用了 <foreach> 标签进行 IN 查询或批量更新,但未对传入的集合是否为空进行判断。
    • 影响分析:如果由于业务逻辑漏洞传入了空集合(如 ids 列表为空),Mybatis 会拼装出类似 WHERE id IN () 的残缺 SQL,直接引发 SQL 语法错误(SQLSyntaxErrorException)。
    • 优化建议:虽然在业务层通常会做非空判断,但为了极致的健壮性,建议在业务层做好前置拦截,或在 SQL 中添加容错处理。 java // 在业务层调用前务必加上拦截 if (CollectionUtils.isEmpty(ids)) { return 0; }

    二、评分明细

    • 功能实现的正确性与健壮性(30/40分):违反了 SQL 不允许子查询的硬性规定,且存在集合使用错误的业务逻辑 Bug,扣除 10 分。
    • 安全性与潜在风险(28/30分):整体安全性尚可,未发现明显的 SQL 注入和越权问题,但部分代码存在硬编码(如环境判断或默认商户号),扣除 2 分。
    • 最佳实践与可维护性(15/20分):代码中存在较长的 switch-case 映射代码(如 mapDealAttribution),建议使用枚举类(Enum)来维护映射关系,提高可读性和可维护性;QWManager 存在 URL 字符串硬编码拼接,扣除 5 分。
    • 性能与资源利用(4/5分):在 MonitoringService 中使用了 CompletableFuture 进行并发查询,提升了性能,但未显式设置超时时间,若底层接口阻塞可能拖垮线程池,扣除 1 分。
    • 提交信息质量(4/5分):Commit 信息包含了部分功能点描述,但由于合并产生了冲突信息,略显杂乱,扣除 1 分。

    总分:81分

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