Commit fe3e1089 by 叶立庆

Merge branch 'v5.8.3' into 'master'

上线合并

See merge request !25
2 parents 1fc6ee74 261759d1
Showing 42 changed files with 2437 additions and 15 deletions
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</parent> </parent>
<groupId>cn.com.glsx</groupId> <groupId>cn.com.glsx</groupId>
<artifactId>rpc-dj-mindworkplate-api</artifactId> <artifactId>rpc-dj-mindworkplate-api</artifactId>
<version>5.8.2-SNAPSHOT</version> <version>5.8.3-SNAPSHOT</version>
<name>rpc-dj-mindworkplate-api</name> <name>rpc-dj-mindworkplate-api</name>
<properties> <properties>
<deploy.scanPackage>cn.com.glsx.remote</deploy.scanPackage> <deploy.scanPackage>cn.com.glsx.remote</deploy.scanPackage>
......
package cn.com.glsx.dj.mindworkplate.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 客户标签分析结果按手机号列表查询请求
*/
@Data
public class InspectionCustomerTagByPhonesRequestDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "客户手机号列表", required = true)
private List<String> phoneNumbers;
@ApiModelProperty(notes = "结果状态:0-待查询,1-分析中,2-成功,3-失败")
private Integer resultFlag;
}
package cn.com.glsx.dj.mindworkplate.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 客户标签分析结果DTO
*/
@Data
public class InspectionCustomerTagDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "主键")
private Integer id;
@ApiModelProperty(notes = "批次ID")
private Integer batchId;
@ApiModelProperty(notes = "录音ID")
private Integer recordId;
@ApiModelProperty(notes = "大模型任务ID")
private String taskId;
@ApiModelProperty(notes = "结果状态:0-待查询,1-分析中,2-成功,3-失败")
private Integer resultFlag;
@ApiModelProperty(notes = "标签分析结果")
private String tagResult;
@ApiModelProperty(notes = "错误信息")
private String errMessage;
@ApiModelProperty(notes = "创建人")
private String createdBy;
@ApiModelProperty(notes = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate;
@ApiModelProperty(notes = "更新人")
private String updatedBy;
@ApiModelProperty(notes = "更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updatedDate;
@ApiModelProperty(notes = "客户手机号")
private String customerPhone;
}
package cn.com.glsx.dj.mindworkplate.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 客户标签分析结果分页查询请求
*/
@Data
public class InspectionCustomerTagPageRequestDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "批次ID")
private Integer batchId;
@ApiModelProperty(notes = "结果状态:0-待查询,1-分析中,2-成功,3-失败")
private Integer resultFlag;
@ApiModelProperty(notes = "创建时间开始")
private String startTime;
@ApiModelProperty(notes = "创建时间结束")
private String endTime;
}
package cn.com.glsx.dj.mindworkplate.dto.prelearn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
import java.util.List;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("批量查询任务请求")
public class BatchQueryTaskReq implements Serializable {
private static final long serialVersionUID = 1L;
/** 大模型任务ID列表 */
@ApiModelProperty(value = "大模型任务ID列表")
private List<String> modelTaskIds;
}
package cn.com.glsx.dj.mindworkplate.dto.prelearn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
import java.util.List;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("批量查询任务结果响应")
public class BatchQueryTaskResultResp implements Serializable {
private static final long serialVersionUID = 1L;
/** 任务查询结果列表 */
@ApiModelProperty(value = "任务查询结果列表")
private List<TaskQueryResult> results;
}
package cn.com.glsx.dj.mindworkplate.dto.prelearn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
import java.util.List;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("大模型任务提交请求")
public class BigModelTaskSubmitReq implements Serializable {
private static final long serialVersionUID = 1L;
/** 品牌车型 */
@ApiModelProperty(value = "品牌车型")
private String brandCar;
/** 套餐名称 */
@ApiModelProperty(value = "套餐名称")
private String packageName;
/** 套餐包含项 */
@ApiModelProperty(value = "套餐包含项")
private List<String> packageIncludes;
/** 原价 */
@ApiModelProperty(value = "原价")
private Long oldPrice;
/** 新价 */
@ApiModelProperty(value = "新价")
private Long newPrice;
/** ASR文本 */
@ApiModelProperty(value = "ASR文本")
private String asrText;
}
package cn.com.glsx.dj.mindworkplate.dto.prelearn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("获取同品类音频请求")
public class FetchSameCategoryAudioReq implements Serializable {
private static final long serialVersionUID = 1L;
/** 品类 */
@ApiModelProperty(value = "品类")
private String category;
/** 需要的数量 */
@ApiModelProperty(value = "需要的数量")
private int needCount;
}
package cn.com.glsx.dj.mindworkplate.dto.prelearn;
import lombok.Data;
import java.io.Serializable;
/**
* 剧本实战步骤DTO
*/
@Data
public class GameStepDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer stageIndex;
private String stageName;
private Boolean isHighlight;
}
package cn.com.glsx.dj.mindworkplate.dto.prelearn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
import java.util.Date;
/**
* 订单客户DTO - 预学习剧本生成用
*
* @author yangzl
*/
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("订单客户信息")
public class OrderCustomerDTO implements Serializable {
private static final long serialVersionUID = 1L;
/** 订单编码 */
@ApiModelProperty(value = "订单编码")
private String orderCode;
/** 客户手机号 */
@ApiModelProperty(value = "客户手机号")
private String customerPhone;
/** 最早创建时间 */
@ApiModelProperty(value = "最早创建时间")
private Date earliestCreatedDate;
}
package cn.com.glsx.dj.mindworkplate.dto.prelearn;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 剧本内容DTO(大模型返回的完整剧本JSON结构)
*/
@Data
public class ScriptContentDTO implements Serializable {
private static final long serialVersionUID = 1L;
private List<GameStepDTO> gameSteps;
}
package cn.com.glsx.dj.mindworkplate.dto.prelearn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("提交大模型任务响应")
public class SubmitBigModelTaskResp implements Serializable {
private static final long serialVersionUID = 1L;
/** 大模型任务ID */
@ApiModelProperty(value = "大模型任务ID")
private String modelTaskId;
}
package cn.com.glsx.dj.mindworkplate.dto.prelearn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("任务查询结果")
public class TaskQueryResult implements Serializable {
private static final long serialVersionUID = 1L;
/** 任务状态常量 */
public static final String STATUS_PROCESSING = "PROCESSING";
public static final String STATUS_COMPLETED = "COMPLETED";
public static final String STATUS_FAILED = "FAILED";
/** 大模型任务ID */
@ApiModelProperty(value = "大模型任务ID")
private String modelTaskId;
/** 任务状态 */
@ApiModelProperty(value = "任务状态")
private String status;
/** 生成的脚本JSON */
@ApiModelProperty(value = "生成的脚本JSON")
private String scriptJson;
/** 错误信息 */
@ApiModelProperty(value = "错误信息")
private String errorMsg;
public boolean isProcessing() {
return STATUS_PROCESSING.equals(status);
}
public boolean isCompleted() {
return STATUS_COMPLETED.equals(status);
}
public boolean isFailed() {
return STATUS_FAILED.equals(status);
}
}
package cn.com.glsx.dj.mindworkplate.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* AI剧本生成状态枚举
*/
@Getter
@AllArgsConstructor
public enum AiStatusEnum {
GENERATING("GENERATING", "生成中"),
READY("READY", "就绪"),
MODIFIED("MODIFIED", "已变更需重新生成"),
FAILED("FAILED", "生成失败"),
;
private final String value;
private final String displayName;
}
...@@ -250,4 +250,11 @@ public class BadgeRecordings implements Serializable { ...@@ -250,4 +250,11 @@ public class BadgeRecordings implements Serializable {
*/ */
@Column(name = "model_type") @Column(name = "model_type")
private String modelType; private String modelType;
/** 接待开始时间(JOIN自reception_customer_info) */
@Transient
private Date receptionStartTime;
@Transient
private String customerName;
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.mindworkplate.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* 客户标签分析结果表
*/
@Data
@Table(name = "inspection_customer_tag")
public class InspectionCustomerTag implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 批次ID,关联inspection_conversation_batch.id
*/
@Column(name = "batch_id")
@ApiModelProperty(notes = "批次ID")
private Integer batchId;
/**
* 录音ID,关联inspection_badge_recordings.id
*/
@Column(name = "record_id")
@ApiModelProperty(notes = "录音ID")
private Integer recordId;
/**
* 大模型任务ID
*/
@Column(name = "task_id")
@ApiModelProperty(notes = "大模型任务ID")
private String taskId;
/**
* 结果状态:0-待查询,1-分析中,2-成功,3-失败
*/
@Column(name = "result_flag")
@ApiModelProperty(notes = "结果状态:0-待查询,1-分析中,2-成功,3-失败")
private Integer resultFlag;
/**
* 标签分析结果(JSON格式)
*/
@Column(name = "tag_result")
@ApiModelProperty(notes = "标签分析结果")
private String tagResult;
/**
* 错误信息
*/
@Column(name = "err_message")
@ApiModelProperty(notes = "错误信息")
private String errMessage;
/**
* 创建人
*/
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@Column(name = "created_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate;
/**
* 更新人
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* 更新时间
*/
@Column(name = "updated_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updatedDate;
/**
* 删除标识:D-已删除,N-未删除
*/
@Column(name = "deleted_flag")
private String deletedFlag;
}
package cn.com.glsx.dj.mindworkplate.remote;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagDTO;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagByPhonesRequestDTO;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagPageRequestDTO;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import java.util.List;
@ApiService(value = "智享车生活-客户标签分析结果管理", owner = "linyj")
public interface InspectionCustomerTagRemote {
@ApiMethod("分页查询客户标签分析结果")
@ApiParam(name = "req", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("客户标签分析结果列表")
RpcResponse<RpcPagination<InspectionCustomerTagDTO>> inspectionCustomerTagPage(RpcPagination<InspectionCustomerTagPageRequestDTO> req);
@ApiMethod("根据手机号列表查询客户标签分析结果")
@ApiParam(name = "req", notes = "查询条件(包含手机号列表)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("客户标签分析结果列表")
RpcResponse<List<InspectionCustomerTagDTO>> queryByPhoneNumbers(InspectionCustomerTagByPhonesRequestDTO req);
}
package cn.com.glsx.dj.mindworkplate.remote.prelearn;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.BatchQueryTaskReq;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.BatchQueryTaskResultResp;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.BigModelTaskSubmitReq;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.SubmitBigModelTaskResp;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
* 预学习-大模型调用 Dubbo 接口
*
* @author yangzl
*/
@ApiService(value = "预学习-大模型调用", owner = "yangzl")
public interface PreLearnBigModelRemote {
@ApiMethod("提交大模型异步任务")
RpcResponse<SubmitBigModelTaskResp> submitTask(Integer activityId);
@ApiMethod("批量查询大模型结果")
RpcResponse<BatchQueryTaskResultResp> batchQueryResults(BatchQueryTaskReq req);
}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</parent> </parent>
<groupId>org.example</groupId> <groupId>org.example</groupId>
<artifactId>rpc-dj-mindworkplate</artifactId> <artifactId>rpc-dj-mindworkplate</artifactId>
<version>5.7.5-SNAPSHOT</version> <version>5.8.3-SNAPSHOT</version>
<name>rpc-dj-mindworkplate</name> <name>rpc-dj-mindworkplate</name>
<packaging>war</packaging> <packaging>war</packaging>
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<dependency> <dependency>
<groupId>cn.com.glsx.dj.strategy</groupId> <groupId>cn.com.glsx.dj.strategy</groupId>
<artifactId>rpc-dj-strategy-api</artifactId> <artifactId>rpc-dj-strategy-api</artifactId>
<version>5.6.0-SNAPSHOT</version> <version>5.8.3-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<dependency> <dependency>
<groupId>cn.com.glsx</groupId> <groupId>cn.com.glsx</groupId>
<artifactId>rpc-dj-mindworkplate-api</artifactId> <artifactId>rpc-dj-mindworkplate-api</artifactId>
<version>5.8.2-SNAPSHOT</version> <version>5.8.3-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
...@@ -176,5 +176,11 @@ ...@@ -176,5 +176,11 @@
<artifactId>ore-boot-starter-alioss</artifactId> <artifactId>ore-boot-starter-alioss</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>2.2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>cn.com.glsx.dj.strategy</groupId>
<artifactId>rpc-dj-strategy-api</artifactId>
<version>5.8.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.mindworkplate.client;
import cn.com.glsx.dj.mindworkplate.util.HttpUtils;
import cn.com.glsx.dj.strategy.dto.TagCategoryDimensionQueryReqDTO;
import cn.com.glsx.dj.strategy.dto.TagCategoryDimensionRespDTO;
import cn.com.glsx.dj.strategy.dto.TagDimensionRespDTO;
import cn.com.glsx.dj.strategy.dto.TagEnumRespDTO;
import cn.com.glsx.dj.strategy.remote.TagCategoryRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
* 客户标签分析大模型接口客户端
*/
@Slf4j
@Component
public class CustomerTagApiClient {
@Autowired
private Environment environment;
@Autowired
private TagCategoryRemote tagCategoryRemote;
/**
* 获取配置项 - 接口域名
*/
private String getBaseUrl() {
return environment.getProperty("customer-tag.api.base-url");
}
/**
* 获取配置项 - 模板ID
*/
private String getTemplateId() {
return environment.getProperty("customer-tag.api.template-id");
}
/**
* 获取配置项 - 账户ID
*/
private String getAccountId() {
return environment.getProperty("customer-tag.api.account-id");
}
/**
* 获取配置项 - 分类代码
*/
private String getCategoryCode() {
return environment.getProperty("customer-tag.api.category-code");
}
/**
* 提交客户标签分析任务
*
* @param recordingText 录音转文本内容
* @return 返回 task_id
*/
public String submitAnalysis(String recordingText) {
String url = getBaseUrl() + "/api/v1/calls/by-template";
Map<String, Object> request = new HashMap<>();
request.put("template_id", getTemplateId());
request.put("account_id", getAccountId());
Map<String, String> variables = new HashMap<>();
String labelInfo = buildLabelInfo();
variables.put("label_info", labelInfo);
variables.put("recording_text", recordingText);
request.put("variables", variables);
request.put("mode", "async");
log.info("提交客户标签分析任务,url={}, request={}", url, JSON.toJSONString(request));
try {
String response = HttpUtils.post(url, JSON.toJSONString(request));
log.info("提交客户标签分析任务响应,response={}", response);
if (StringUtils.isNotBlank(response)) {
JSONObject result = JSON.parseObject(response);
if ("accepted".equals(result.getString("status"))) {
return result.getString("task_id");
}
throw new RuntimeException("提交客户标签分析任务失败:" + result.getString("message"));
}
} catch (IOException e) {
log.error("提交客户标签分析任务异常", e);
throw new RuntimeException("提交客户标签分析任务异常", e);
}
throw new RuntimeException("提交客户标签分析任务失败:响应为空");
}
/**
* 查询分析结果
*
* @param taskId 任务ID
* @return 分析结果
*/
public CustomerTagResult getResult(String taskId) {
String url = getBaseUrl() + "/api/v1/calls/orchestrate/async?task_id=" + taskId;
log.info("查询客户标签分析结果,url={}", url);
try {
String response = HttpUtils.get(url);
log.info("查询客户标签分析结果响应,response={}", response);
if (StringUtils.isNotBlank(response)) {
JSONObject result = JSON.parseObject(response);
CustomerTagResult tagResult = new CustomerTagResult();
tagResult.setTaskId(result.getString("task_id"));
tagResult.setStatus(result.getString("status"));
tagResult.setProgress(result.getInteger("progress"));
tagResult.setCallRecordStatus(result.getString("call_record_status"));
tagResult.setResponseContent(result.getString("response_content"));
tagResult.setErrorMessage(result.getString("error_message"));
return tagResult;
}
} catch (IOException e) {
log.error("查询客户标签分析结果异常", e);
throw new RuntimeException("查询客户标签分析结果异常", e);
}
throw new RuntimeException("查询客户标签分析结果失败:响应为空");
}
/**
* 构建标签信息 JSON
*/
private String buildLabelInfo() {
try {
String categoryCode = getCategoryCode();
if (StringUtils.isBlank(categoryCode)) {
log.warn("未配置标签分类代码,label_info 返回空");
return "";
}
TagCategoryDimensionQueryReqDTO req = new TagCategoryDimensionQueryReqDTO();
req.setCategoryCode(categoryCode);
RpcResponse<TagCategoryDimensionRespDTO> response = tagCategoryRemote.queryCategoryWithDimensions(req);
if (response == null || !response.isSuccess() || response.getResult() == null) {
log.warn("查询标签分类信息失败,categoryCode={}", categoryCode);
return "";
}
TagCategoryDimensionRespDTO data = response.getResult();
return assembleLabelInfoJson(data);
} catch (Exception e) {
log.error("构建标签信息异常", e);
return "";
}
}
/**
* 组装标签信息 JSON
* 格式:[{categoryName:[{dimensionName:[enumName,enumName,enumName]}]}]
* 按类别分组,每个类别下包含该类别的维度列表
*/
private String assembleLabelInfoJson(TagCategoryDimensionRespDTO data) {
if (data == null || CollectionUtils.isEmpty(data.getDimensions())) {
return "";
}
// 按 categoryName 分组
Map<String, List<TagDimensionRespDTO>> categoryGroupMap = data.getDimensions().stream()
.filter(d -> d != null && StringUtils.isNotBlank(d.getCategoryName()))
.collect(Collectors.groupingBy(TagDimensionRespDTO::getCategoryName, LinkedHashMap::new, Collectors.toList()));
// 构建结果数组:[{categoryName:[{dimensionName:[enumName,enumName,enumName]}]}]
List<Map<String, List<Map<String, List<String>>>>> resultList = new ArrayList<>();
for (Map.Entry<String, List<TagDimensionRespDTO>> categoryEntry : categoryGroupMap.entrySet()) {
String categoryName = categoryEntry.getKey();
List<TagDimensionRespDTO> dimensions = categoryEntry.getValue();
// 构建该类别下的维度列表:[{dimensionName:[enumName,enumName,enumName]}]
List<Map<String, List<String>>> dimensionList = new ArrayList<>();
for (TagDimensionRespDTO dimension : dimensions) {
if (dimension == null || StringUtils.isBlank(dimension.getDimensionName())) {
continue;
}
Map<String, List<String>> dimensionMap = new LinkedHashMap<>();
List<String> enumNames = new ArrayList<>();
if (!CollectionUtils.isEmpty(dimension.getEnums())) {
for (TagEnumRespDTO enumDTO : dimension.getEnums()) {
if (enumDTO != null && StringUtils.isNotBlank(enumDTO.getEnumName())) {
enumNames.add(enumDTO.getEnumName());
}
}
}
dimensionMap.put(dimension.getDimensionName(), enumNames);
dimensionList.add(dimensionMap);
}
// 构建类别节点:{categoryName:[...]}
Map<String, List<Map<String, List<String>>>> categoryMap = new LinkedHashMap<>();
categoryMap.put(categoryName, dimensionList);
resultList.add(categoryMap);
}
return JSON.toJSONString(resultList);
}
}
package cn.com.glsx.dj.mindworkplate.client;
import lombok.Data;
/**
* 客户标签分析结果响应类
*/
@Data
public class CustomerTagResult {
/**
* 任务ID
*/
private String taskId;
/**
* 任务状态:pending/success/failed
*/
private String status;
/**
* 任务进度 0-100
*/
private Integer progress;
/**
* 调用记录状态
*/
private String callRecordStatus;
/**
* 标签分析结果(JSON字符串)
*/
private String responseContent;
/**
* 错误信息
*/
private String errorMessage;
/**
* 判断任务是否成功完成
*/
public boolean isSuccess() {
return "success".equals(status) && "success".equals(callRecordStatus);
}
/**
* 判断任务是否处理中
*/
public boolean isPending() {
return "pending".equals(status) || (progress != null && progress < 100);
}
/**
* 判断任务是否失败
*/
public boolean isFailed() {
return "failed".equals(status) || "failed".equals(callRecordStatus);
}
}
...@@ -3,13 +3,14 @@ package cn.com.glsx.dj.mindworkplate.config; ...@@ -3,13 +3,14 @@ package cn.com.glsx.dj.mindworkplate.config;
import cn.com.glsk.omni.ai.remote.AgiRemote; import cn.com.glsk.omni.ai.remote.AgiRemote;
import cn.com.glsx.dj.beisen.remote.BeiSenCommonRemote; import cn.com.glsx.dj.beisen.remote.BeiSenCommonRemote;
import cn.com.glsx.dj.beisen.remote.BeiSenCoursesRemote; import cn.com.glsx.dj.beisen.remote.BeiSenCoursesRemote;
import cn.com.glsx.dj.beisen.remote.BeiSenDynamicRecordRemote;
import cn.com.glsx.dj.smartcarlife.remote.*; import cn.com.glsx.dj.smartcarlife.remote.*;
import cn.com.glsx.dj.strategy.remote.TagCategoryRemote;
import cn.com.glsx.entmicro.remote.BatchMessagingRemote; import cn.com.glsx.entmicro.remote.BatchMessagingRemote;
import cn.com.glsx.entmicro.remote.EntmicroStaffRemote; import cn.com.glsx.entmicro.remote.EntmicroStaffRemote;
import cn.com.glsx.merchants.remote.MerchantRemote; import cn.com.glsx.merchants.remote.MerchantRemote;
import cn.com.glsx.merchants.remote.MerchantStaffRemote; import cn.com.glsx.merchants.remote.MerchantStaffRemote;
import cn.com.glsx.scrm.clue.remote.BurialPointRecordRemote; import cn.com.glsx.scrm.clue.remote.BurialPointRecordRemote;
import cn.com.glsx.scrm.equity.remote.EquityOrderRemote;
import cn.com.glsx.scrm.equity.remote.ServicePackageRemote; import cn.com.glsx.scrm.equity.remote.ServicePackageRemote;
import cn.com.glsx.scrm.proxy.remote.CommonProxyRemote; import cn.com.glsx.scrm.proxy.remote.CommonProxyRemote;
import cn.com.glsx.scrm.proxy.remote.ShortUrlRemote; import cn.com.glsx.scrm.proxy.remote.ShortUrlRemote;
...@@ -19,7 +20,6 @@ import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFacto ...@@ -19,7 +20,6 @@ import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFacto
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import cn.com.glsx.scrm.equity.remote.EquityOrderRemote;
/** /**
* @author deployer name * @author deployer name
...@@ -182,5 +182,10 @@ public class DubboConfig { ...@@ -182,5 +182,10 @@ public class DubboConfig {
return factory.builder(MerchantRemote.class).check(false).version("2.0.0").timeout(30000).build(); return factory.builder(MerchantRemote.class).check(false).version("2.0.0").timeout(30000).build();
} }
@Bean
public TagCategoryRemote tagCategoryRemote() {
return factory.builder(TagCategoryRemote.class).check(false).timeout(30000).build();
}
} }
package cn.com.glsx.dj.mindworkplate.config; package cn.com.glsx.dj.mindworkplate.config;
import cn.com.glsx.dj.strategy.remote.MarketingActivityRemote;
import cn.com.glsx.dj.strategy.remote.StrategyStaffMessageRemote; import cn.com.glsx.dj.strategy.remote.StrategyStaffMessageRemote;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory; import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -17,4 +18,8 @@ public class StrategyDubboConfig { ...@@ -17,4 +18,8 @@ public class StrategyDubboConfig {
return factory.builder(StrategyStaffMessageRemote.class).check(false).timeout(30000).version("1.0.0").build(); return factory.builder(StrategyStaffMessageRemote.class).check(false).timeout(30000).version("1.0.0").build();
} }
@Bean
public MarketingActivityRemote marketingActivityRemote(){
return factory.builder(MarketingActivityRemote.class).check(false).timeout(30000).build();
}
} }
package cn.com.glsx.dj.mindworkplate.controller; package cn.com.glsx.dj.mindworkplate.controller;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.TaskQueryResult;
import cn.com.glsx.dj.mindworkplate.model.BadgeRecordings; import cn.com.glsx.dj.mindworkplate.model.BadgeRecordings;
import cn.com.glsx.dj.mindworkplate.model.ConversationDetail; import cn.com.glsx.dj.mindworkplate.model.ConversationDetail;
import cn.com.glsx.dj.mindworkplate.model.agi.RecognitionDetail; import cn.com.glsx.dj.mindworkplate.model.agi.RecognitionDetail;
...@@ -7,6 +8,7 @@ import cn.com.glsx.dj.mindworkplate.model.agi.SegmentResult; ...@@ -7,6 +8,7 @@ import cn.com.glsx.dj.mindworkplate.model.agi.SegmentResult;
import cn.com.glsx.dj.mindworkplate.service.AgiService; import cn.com.glsx.dj.mindworkplate.service.AgiService;
import cn.com.glsx.dj.mindworkplate.service.AliyunOssService; import cn.com.glsx.dj.mindworkplate.service.AliyunOssService;
import cn.com.glsx.dj.mindworkplate.service.ConversationDateService; import cn.com.glsx.dj.mindworkplate.service.ConversationDateService;
import cn.com.glsx.dj.mindworkplate.service.prelearn.PreLearnBigModelService;
import cn.com.glsx.dj.mindworkplate.util.FileToByteArray; import cn.com.glsx.dj.mindworkplate.util.FileToByteArray;
import cn.com.glsx.dj.mindworkplate.util.FileUploadServerData; import cn.com.glsx.dj.mindworkplate.util.FileUploadServerData;
import cn.com.glsx.dj.mindworkplate.util.FileUploadUtil; import cn.com.glsx.dj.mindworkplate.util.FileUploadUtil;
...@@ -46,6 +48,9 @@ public class BigModelApiController { ...@@ -46,6 +48,9 @@ public class BigModelApiController {
@Autowired @Autowired
private AliyunOssService aliyunOssService; private AliyunOssService aliyunOssService;
@Autowired
private PreLearnBigModelService preLearnBigModelService;
@PostMapping("/inspection/submit/{checktype}") @PostMapping("/inspection/submit/{checktype}")
public Object submitInspection(@RequestBody String body,@PathVariable("checktype") Integer checktype) { public Object submitInspection(@RequestBody String body,@PathVariable("checktype") Integer checktype) {
log.info("提交话术质检信息,body={}", body); log.info("提交话术质检信息,body={}", body);
...@@ -156,4 +161,27 @@ public class BigModelApiController { ...@@ -156,4 +161,27 @@ public class BigModelApiController {
String string = UUID.randomUUID().toString(); String string = UUID.randomUUID().toString();
return string + ".mp3"; return string + ".mp3";
} }
@GetMapping("/submitTask")
public void submitTask(@RequestParam("activityId") Integer activityId) {
Map<String, Object> result = new HashMap<>();
try {
preLearnBigModelService.submitTask(activityId);
} catch (Exception e) {
log.error("error",e);
}
}
@GetMapping("/queryTaskResult")
public TaskQueryResult queryTaskResult(@RequestParam("modelTaskId") String modelTaskId) {
try {
TaskQueryResult taskQueryResult = preLearnBigModelService.queryTaskResult(modelTaskId);
return taskQueryResult;
} catch (Exception e) {
log.error("error",e);
}
return new TaskQueryResult();
}
} }
package cn.com.glsx.dj.mindworkplate.job;
import cn.com.glsx.dj.mindworkplate.model.InspectionCustomerTag;
import cn.com.glsx.dj.mindworkplate.service.InspectionCustomerTagService;
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.beans.factory.annotation.Autowired;
import java.util.List;
/**
* 获取客户标签分析结果定时任务
*/
@Slf4j
@ElasticJobConf(name = "CustomerTagResultJob", cron = "0 0/5 * * * ?", description = "获取客户标签分析结果", overwrite = false)
public class CustomerTagResultJob implements SimpleJob {
@Autowired
private InspectionCustomerTagService inspectionCustomerTagService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("----------获取客户标签分析结果任务开始----------");
List<InspectionCustomerTag> pendingList = inspectionCustomerTagService.findPendingResults();
if (CollectionUtils.isNotEmpty(pendingList)) {
for (InspectionCustomerTag tag : pendingList) {
try {
inspectionCustomerTagService.getCustomerTagResult(tag);
} catch (Exception e) {
log.error("获取客户标签分析结果异常,id={}", tag.getId(), e);
}
}
}
log.info("----------获取客户标签分析结果任务结束----------");
}
}
package cn.com.glsx.dj.mindworkplate.job;
import cn.com.glsx.dj.mindworkplate.service.InspectionCustomerTagService;
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;
/**
* 历史客户标签分析定时任务
* 用于批量处理历史数据的客户标签分析
*/
@Slf4j
@ElasticJobConf(name = "HistoricalCustomerTagJob", cron = "0 0 1 * * ?", description = "历史客户标签分析任务", overwrite = false)
public class HistoricalCustomerTagJob implements SimpleJob {
@Autowired
private InspectionCustomerTagService inspectionCustomerTagService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("----------历史客户标签分析任务开始----------");
try {
// 自定义参数如:指定开始、截止日期范围{"startDate":"2026-06-01","endDate":"2026-06-22"}
String jobParameter = shardingContext.getJobParameter();
log.info("历史客户标签分析任务参数:{}", jobParameter);
int processedCount = inspectionCustomerTagService.processHistoricalTags(jobParameter);
log.info("----------历史客户标签分析任务结束,处理批次数量:{}----------", processedCount);
} catch (Exception e) {
log.error("历史客户标签分析任务执行异常", e);
}
}
}
package cn.com.glsx.dj.mindworkplate.job;
import cn.com.glsx.dj.mindworkplate.service.prelearn.PreLearnBigModelService;
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;
/**
* 预学习-剧本生成结果轮询任务
* 每3分钟轮询一次,查询20条状态为GENERATING的记录,调用大模型接口查询结果并更新状态
*
* @author yangzl
*/
@Slf4j
@ElasticJobConf(name = "PreLearnScriptPollingJob", cron = "0 0/3 * * * ?", description = "预学习-轮询大模型任务结果", overwrite = false)
public class PreLearnScriptPollingJob implements SimpleJob {
@Autowired
private PreLearnBigModelService preLearnBigModelService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("----------------预学习剧本轮询任务开始-----------------");
try {
preLearnBigModelService.pollTaskResults();
} catch (Exception e) {
log.error("预学习剧本轮询任务异常", e);
}
log.info("----------------预学习剧本轮询任务结束-----------------");
}
}
...@@ -36,4 +36,14 @@ public interface BadgeRecordingsMapper extends OreMapper<BadgeRecordings> { ...@@ -36,4 +36,14 @@ public interface BadgeRecordingsMapper extends OreMapper<BadgeRecordings> {
List<BadgeRecordings> findResolvedFlagList(); List<BadgeRecordings> findResolvedFlagList();
List<BadgeRecordings> findhistorySendCheck(); List<BadgeRecordings> findhistorySendCheck();
/**
* 根据接待记录ID批量查询录音
*/
List<BadgeRecordings> selectByReceptionIds(@Param("receptionIds") List<Integer> receptionIds);
/**
* 根据客户手机号连表查询录音(reception_customer_info LEFT JOIN inspection_badge_recordings)
*/
List<BadgeRecordings> selectByPhoneNumber(@Param("phoneNumber") String phoneNumber);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.mindworkplate.mapper;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagDTO;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagPageRequestDTO;
import cn.com.glsx.dj.mindworkplate.model.ConversationBatch;
import cn.com.glsx.dj.mindworkplate.model.InspectionCustomerTag;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
/**
* 客户标签分析结果Mapper
*/
@Mapper
public interface InspectionCustomerTagMapper extends OreMapper<InspectionCustomerTag> {
/**
* 根据批次ID查询
*/
InspectionCustomerTag selectByBatchId(@Param("batchId") Integer batchId);
/**
* 查询待获取结果的记录(result_flag = 1)
*/
List<InspectionCustomerTag> findPendingResults();
/**
* 更新结果
*/
int updateResult(@Param("id") Integer id,
@Param("resultFlag") Integer resultFlag,
@Param("tagResult") String tagResult,
@Param("errMessage") String errMessage);
/**
* 分页查询客户标签分析结果(关联客户手机号)
*/
List<InspectionCustomerTagDTO> selectPageList(@Param("req") InspectionCustomerTagPageRequestDTO req);
/**
* 根据手机号列表查询客户标签分析结果
*
* @param phoneNumbers 手机号列表
* @param resultFlag 结果状态(可选)
* @return 标签结果列表
*/
List<InspectionCustomerTagDTO> selectByPhoneNumbers(@Param("phoneNumbers") List<String> phoneNumbers,
@Param("resultFlag") Integer resultFlag);
/**
* 查询指定时间范围内未处理的批次(未在inspection_customer_tag表中存在记录)
*
* @param startTime 开始时间
* @param endTime 结束时间
* @return 未处理的批次列表
*/
List<ConversationBatch> findUnprocessedBatchesByTimeRange(@Param("startTime") String startTime,
@Param("endTime") String endTime);
}
package cn.com.glsx.dj.mindworkplate.mapper;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.OrderCustomerDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 预学习-订单查询Mapper
*
* @author yangzl
*/
@Mapper
public interface PreLearnOrderMapper {
/**
* 根据商品编码批量查询订单客户信息(最多50条)
*
* @param goodsCodes 商品编码列表
* @return 订单客户信息列表
*/
List<OrderCustomerDTO> selectOrderCustomersByGoodsCodes(@Param("goodsCodes") List<String> goodsCodes);
}
package cn.com.glsx.dj.mindworkplate.mapper;
import cn.com.glsx.dj.mindworkplate.model.prelearn.PreLearnProductScript;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper
public interface PreLearnProductScriptMapper extends OreMapper<PreLearnProductScript> {
List<String> selectProductByActivity(@Param("activityId") Integer activityId);
List<PreLearnProductScript> selectPendingPolling(
@Param("aiStatus") String aiStatus,
@Param("limit") int limit);
PreLearnProductScript selectOneUnread(
@Param("activityId") Integer activityId,
@Param("activityProductId") String activityProductId,
@Param("aiStatus") String aiStatus,
@Param("excludeIds") List<Integer> excludeIds);
int countByActivityAndProduct(
@Param("activityId") Integer activityId,
@Param("activityProductId") String activityProductId,
@Param("aiStatus") String aiStatus);
int updateAiStatus(
@Param("activityId") Integer activityId,
@Param("activityProductId") String activityProductId,
@Param("aiStatus") String aiStatus);
int updateScriptReady(
@Param("id") Integer id,
@Param("scriptJson") String scriptJson,
@Param("aiStatus") String aiStatus);
int updateScriptFailed(
@Param("id") Integer id,
@Param("errorMsg") String errorMsg,
@Param("aiStatus") String aiStatus);
}
package cn.com.glsx.dj.mindworkplate.model.prelearn;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Data
@Accessors(chain = true)
@Table(name = "dj_prelearn_product_script")
public class PreLearnProductScript implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(notes = "主键ID")
private Integer id;
@ApiModelProperty(notes = "活动ID")
@Column(name = "activity_id")
private Integer activityId;
@ApiModelProperty(notes = "活动商品ID(套餐ID)")
@Column(name = "activity_product_id")
private String activityProductId;
@ApiModelProperty(notes = "剧本序号(0-49)")
@Column(name = "case_index")
private Integer caseIndex;
@ApiModelProperty(notes = "大模型异步任务ID")
@Column(name = "model_task_id")
private String modelTaskId;
@ApiModelProperty(notes = "剧本JSON内容")
@Column(name = "script_json")
private String scriptJson;
@ApiModelProperty(notes = "AI生成状态: GENERATING/READY/MODIFIED/FAILED")
@Column(name = "ai_status")
private String aiStatus;
@ApiModelProperty(notes = "生成失败时的错误信息")
@Column(name = "error_msg")
private String errorMsg;
/**
* 车型
*/
@Column(name = "car_model")
private String carModel;
/**
* 车主姓名
*/
@Column(name = "customer_name")
private String customerName;
@ApiModelProperty(notes = "创建人")
@Column(name = "created_by")
private String createdBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(notes = "创建时间")
@Column(name = "created_date")
private Date createdDate;
@ApiModelProperty(notes = "修改人")
@Column(name = "updated_by")
private String updatedBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(notes = "修改时间")
@Column(name = "updated_date")
private Date updatedDate;
}
package cn.com.glsx.dj.mindworkplate.remote;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagDTO;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagByPhonesRequestDTO;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagPageRequestDTO;
import cn.com.glsx.dj.mindworkplate.service.InspectionCustomerTagService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@Slf4j
@DubboService(protocol = "dubbo")
public class InspectionCustomerTagRemoteImpl implements InspectionCustomerTagRemote {
@Autowired
private InspectionCustomerTagService inspectionCustomerTagService;
@Override
public RpcResponse<RpcPagination<InspectionCustomerTagDTO>> inspectionCustomerTagPage(RpcPagination<InspectionCustomerTagPageRequestDTO> req) {
try {
Page<InspectionCustomerTagDTO> res = inspectionCustomerTagService.inspectionCustomerTagPage(req);
return RpcResponse.success(RpcPagination.copyPage(res));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<List<InspectionCustomerTagDTO>> queryByPhoneNumbers(InspectionCustomerTagByPhonesRequestDTO req) {
try {
List<InspectionCustomerTagDTO> list = inspectionCustomerTagService.queryByPhoneNumbers(req);
return RpcResponse.success(list);
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
}
package cn.com.glsx.dj.mindworkplate.remote.prelearn;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.BatchQueryTaskReq;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.BatchQueryTaskResultResp;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.SubmitBigModelTaskResp;
import cn.com.glsx.dj.mindworkplate.service.prelearn.PreLearnBigModelService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
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 java.util.ArrayList;
import java.util.List;
/**
* 预学习-大模型调用 Dubbo 接口实现
*
* @author yangzl
*/
@Slf4j
@DubboService(protocol = "dubbo")
public class PreLearnBigModelRemoteImpl implements PreLearnBigModelRemote {
@Autowired
private PreLearnBigModelService preLearnBigModelService;
@Override
public RpcResponse<SubmitBigModelTaskResp> submitTask(Integer activityId) {
try {
preLearnBigModelService.submitTask(activityId);
return RpcResponse.success(SubmitBigModelTaskResp.builder()
.modelTaskId("tasks submitted")
.build());
} catch (RpcServiceException e) {
log.error("提交大模型异步任务失败: activityId={}", activityId, e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("提交大模型异步任务系统异常: activityId={}", activityId, e);
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<BatchQueryTaskResultResp> batchQueryResults(BatchQueryTaskReq req) {
try {
List<cn.com.glsx.dj.mindworkplate.dto.prelearn.TaskQueryResult> results = new ArrayList<>();
for (String modelTaskId : req.getModelTaskIds()) {
results.add(preLearnBigModelService.queryTaskResult(modelTaskId));
}
BatchQueryTaskResultResp resp = BatchQueryTaskResultResp.builder()
.results(results)
.build();
return RpcResponse.success(resp);
} catch (RpcServiceException e) {
log.error("批量查询大模型结果失败", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("批量查询大模型结果系统异常", e);
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
}
...@@ -114,6 +114,9 @@ public class ConversationDateService { ...@@ -114,6 +114,9 @@ public class ConversationDateService {
@Autowired @Autowired
private ReceptionModeltypeConfigMapper receptionModeltypeConfigMapper; private ReceptionModeltypeConfigMapper receptionModeltypeConfigMapper;
@Autowired
private InspectionCustomerTagService inspectionCustomerTagService;
/** /**
* 语音文本分批次 * 语音文本分批次
* *
...@@ -403,6 +406,21 @@ public class ConversationDateService { ...@@ -403,6 +406,21 @@ public class ConversationDateService {
log.info("员工badgeId={}的当日话术质检分析完成,conversationId={}", conversationDate.getBadgeId(), conversationId); log.info("员工badgeId={}的当日话术质检分析完成,conversationId={}", conversationDate.getBadgeId(), conversationId);
} }
public String getBadgeText(Integer recordId){
ConversationBatch conversationBatch = conversationBatchMapper.selectByRecordId(recordId);
if(Objects.isNull(conversationBatch)){
return null;
}
//获取文件内容
List<ConversationDetail> conversationDetails = inspectionConversationDetailExtService.listByBatchId(Arrays.asList(
conversationBatch.getId()));
StringBuffer sb = new StringBuffer();
conversationDetails.forEach(conversationDetail -> {
sb.append(String.format("%s %s:%s\n", formatSeconds(conversationDetail.getMergedOffset().intValue()), conversationDetail.getRole(), conversationDetail.getContent()));
});
return sb.toString();
}
/** /**
* 单批次质检分析 * 单批次质检分析
* *
...@@ -423,6 +441,12 @@ public class ConversationDateService { ...@@ -423,6 +441,12 @@ public class ConversationDateService {
log.warn("第{}个批次的对话内容长度为0,conversationId={},batchId={}", num, conversationBatch.getConversationId(), conversationBatch.getId()); log.warn("第{}个批次的对话内容长度为0,conversationId={},batchId={}", num, conversationBatch.getConversationId(), conversationBatch.getId());
return; return;
} }
// 新增:提交客户标签分析
try {
inspectionCustomerTagService.submitCustomerTagAnalysis(conversationBatch, sb.toString());
} catch (Exception e) {
log.error("提交客户标签分析任务异常,batchId={}", conversationBatch.getId(), e);
}
//调用大模型接口获取质检结果信息 //调用大模型接口获取质检结果信息
log.info("请求参数:{}", sb); log.info("请求参数:{}", sb);
int modelType = convertModelType(conversationBatch.getCheckType(), int modelType = convertModelType(conversationBatch.getCheckType(),
......
package cn.com.glsx.dj.mindworkplate.service;
import cn.com.glsx.dj.mindworkplate.client.CustomerTagApiClient;
import cn.com.glsx.dj.mindworkplate.client.CustomerTagResult;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagByPhonesRequestDTO;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagDTO;
import cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagPageRequestDTO;
import cn.com.glsx.dj.mindworkplate.mapper.InspectionCustomerTagMapper;
import cn.com.glsx.dj.mindworkplate.model.ConversationBatch;
import cn.com.glsx.dj.mindworkplate.model.ConversationDetail;
import cn.com.glsx.dj.mindworkplate.model.InspectionCustomerTag;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.scrm.equity.enums.DeleteFlagEnum;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
* 客户标签分析服务
*/
@Slf4j
@Service
public class InspectionCustomerTagService {
@Autowired
private InspectionCustomerTagMapper inspectionCustomerTagMapper;
@Autowired
private CustomerTagApiClient customerTagApiClient;
@Autowired
private InspectionConversationDetailExtService inspectionConversationDetailExtService;
/**
* 提交客户标签分析任务
*
* @param conversationBatch 批次信息
* @param recordingText 录音转文本内容
*/
@Transactional
public void submitCustomerTagAnalysis(ConversationBatch conversationBatch, String recordingText) {
log.info("提交客户标签分析任务,batchId={}, recordId={}",
conversationBatch.getId(), conversationBatch.getRecordId());
// 检查是否已存在记录
InspectionCustomerTag existTag = inspectionCustomerTagMapper.selectByBatchId(conversationBatch.getId());
if (existTag != null) {
log.info("客户标签分析记录已存在,batchId={}, 跳过", conversationBatch.getId());
return;
}
// 调用大模型接口
String taskId = customerTagApiClient.submitAnalysis(recordingText);
log.info("客户标签分析任务已提交,batchId={}, taskId={}", conversationBatch.getId(), taskId);
// 保存记录
InspectionCustomerTag tag = new InspectionCustomerTag();
tag.setBatchId(conversationBatch.getId());
tag.setRecordId(conversationBatch.getRecordId());
tag.setTaskId(taskId);
tag.setResultFlag(1); // 分析中
tag.setCreatedBy("system");
tag.setCreatedDate(new Date());
tag.setDeletedFlag(DeleteFlagEnum.N.getValue());
inspectionCustomerTagMapper.insertSelective(tag);
log.info("客户标签分析记录已保存,batchId={}, id={}", conversationBatch.getId(), tag.getId());
}
/**
* 查询并更新分析结果
*
* @param tag 标签记录
*/
@Transactional
public void getCustomerTagResult(InspectionCustomerTag tag) {
log.info("查询客户标签分析结果,id={}, taskId={}", tag.getId(), tag.getTaskId());
try {
CustomerTagResult result = customerTagApiClient.getResult(tag.getTaskId());
if (result.isSuccess()) {
// 成功
inspectionCustomerTagMapper.updateResult(tag.getId(), 2,
result.getResponseContent(), null);
log.info("客户标签分析成功,id={}", tag.getId());
} else if (result.isFailed()) {
// 失败
inspectionCustomerTagMapper.updateResult(tag.getId(), 3,
null, result.getErrorMessage());
log.warn("客户标签分析失败,id={}, error={}", tag.getId(), result.getErrorMessage());
} else {
// 处理中,不更新状态
log.info("客户标签分析处理中,id={}, progress={}", tag.getId(), result.getProgress());
}
} catch (Exception e) {
log.error("查询客户标签分析结果异常,id={}", tag.getId(), e);
// 更新为失败状态
inspectionCustomerTagMapper.updateResult(tag.getId(), 3,
null, e.getMessage());
}
}
/**
* 查询待获取结果的记录
*
* @return 待处理记录列表
*/
public List<InspectionCustomerTag> findPendingResults() {
return inspectionCustomerTagMapper.findPendingResults();
}
/**
* 根据批次ID查询结果
*
* @param batchId 批次ID
* @return 标签结果
*/
public InspectionCustomerTag findByBatchId(Integer batchId) {
return inspectionCustomerTagMapper.selectByBatchId(batchId);
}
/**
* 分页查询客户标签分析结果
*
* @param req 查询条件
* @return 分页结果
*/
public Page<InspectionCustomerTagDTO> inspectionCustomerTagPage(RpcPagination<InspectionCustomerTagPageRequestDTO> req) {
InspectionCustomerTagPageRequestDTO requestDTO = req.getCondition();
if (requestDTO == null) {
requestDTO = new InspectionCustomerTagPageRequestDTO();
}
PageHelper.startPage(req.getPageNum(), req.getPageSize());
List<InspectionCustomerTagDTO> list = inspectionCustomerTagMapper.selectPageList(requestDTO);
return (Page<InspectionCustomerTagDTO>) list;
}
/**
* 根据手机号列表查询客户标签分析结果
*
* @param req 查询条件(包含手机号列表)
* @return 标签结果列表
*/
public List<InspectionCustomerTagDTO> queryByPhoneNumbers(InspectionCustomerTagByPhonesRequestDTO req) {
if (req == null || CollectionUtils.isEmpty(req.getPhoneNumbers())) {
log.warn("手机号列表为空,返回空列表");
return Collections.emptyList();
}
log.info("根据手机号列表查询客户标签,phoneNumbers.size={}, resultFlag={}",
req.getPhoneNumbers().size(), req.getResultFlag());
List<InspectionCustomerTagDTO> list = inspectionCustomerTagMapper.selectByPhoneNumbers(
req.getPhoneNumbers(), req.getResultFlag());
log.info("查询完成,结果数量={}", list.size());
return list;
}
/**
* 处理历史客户标签分析
* 查询指定时间范围内未处理的批次,并提交客户标签分析任务
*
* @param jobParameter JSON格式参数,如:{"startDate":"2026-06-01","endDate":"2026-06-22"}
* 如果没有入参,则默认使用昨天的时间范围
* @return 处理的批次数量
*/
public int processHistoricalTags(String jobParameter) {
log.info("开始处理历史客户标签分析,参数:{}", jobParameter);
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String startTime;
String endTime;
// 解析JSON参数
if (StringUtils.isNotBlank(jobParameter)) {
try {
JSONObject jsonObject = JSONObject.parseObject(jobParameter);
String startDate = jsonObject.getString("startDate");
String endDate = jsonObject.getString("endDate");
// 开始时间从0点开始
startTime = LocalDate.parse(startDate, dateFormatter).atStartOfDay().format(dateTimeFormatter);
// 结束时间到23:59:59
endTime = LocalDate.parse(endDate, dateFormatter).atTime(23, 59, 59).format(dateTimeFormatter);
} catch (Exception e) {
log.error("解析任务参数失败:{}", jobParameter, e);
return 0;
}
} else {
// 没有入参,使用昨天的时间范围
LocalDate yesterday = LocalDate.now().minusDays(1);
startTime = yesterday.atStartOfDay().format(dateTimeFormatter);
endTime = yesterday.atTime(23, 59, 59).format(dateTimeFormatter);
}
log.info("历史客户标签分析时间范围:{} ~ {}", startTime, endTime);
// 查询未处理的批次
List<ConversationBatch> unprocessedBatches = inspectionCustomerTagMapper.findUnprocessedBatchesByTimeRange(startTime, endTime);
if (CollectionUtils.isEmpty(unprocessedBatches)) {
log.info("未找到需要处理的批次");
return 0;
}
log.info("找到 {} 个未处理的批次", unprocessedBatches.size());
int successCount = 0;
int failCount = 0;
for (ConversationBatch batch : unprocessedBatches) {
try {
// 获取录音文本内容
String recordingText = getRecordingText(batch);
if (recordingText == null || recordingText.isEmpty()) {
log.warn("批次 {} 的录音文本内容为空,跳过", batch.getId());
continue;
}
// 提交客户标签分析任务
submitCustomerTagAnalysis(batch, recordingText);
successCount++;
log.info("批次 {} 处理成功", batch.getId());
} catch (Exception e) {
failCount++;
log.error("处理批次 {} 失败", batch.getId(), e);
// 继续处理下一个批次
}
}
log.info("历史客户标签分析处理完成,成功:{},失败:{}", successCount, failCount);
return successCount;
}
/**
* 获取批次的录音文本内容
*
* @param batch 批次信息
* @return 录音文本内容
*/
private String getRecordingText(ConversationBatch batch) {
List<ConversationDetail> conversationDetails = inspectionConversationDetailExtService.listByBatchId(Arrays.asList(batch.getId()));
if (CollectionUtils.isEmpty(conversationDetails)) {
return null;
}
StringBuilder sb = new StringBuilder();
for (ConversationDetail detail : conversationDetails) {
Long offset = detail.getMergedOffset();
String offsetStr = offset != null ? formatSeconds(offset) : "00:00:00";
sb.append(String.format("%s %s:%s\n", offsetStr, detail.getRole(), detail.getContent()));
}
return sb.toString();
}
/**
* 格式化秒数为 HH:mm:ss 格式
*/
private String formatSeconds(long seconds) {
long hours = seconds / 3600;
long minutes = (seconds % 3600) / 60;
long secs = seconds % 60;
return String.format("%02d:%02d:%02d", hours, minutes, secs);
}
}
package cn.com.glsx.dj.mindworkplate.service.prelearn;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.GameStepDTO;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.OrderCustomerDTO;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.ScriptContentDTO;
import cn.com.glsx.dj.mindworkplate.dto.prelearn.TaskQueryResult;
import cn.com.glsx.dj.mindworkplate.enums.AiStatusEnum;
import cn.com.glsx.dj.mindworkplate.mapper.*;
import cn.com.glsx.dj.mindworkplate.model.BadgeRecordings;
import cn.com.glsx.dj.mindworkplate.model.prelearn.PreLearnProductScript;
import cn.com.glsx.dj.mindworkplate.service.ConversationDateService;
import cn.com.glsx.dj.mindworkplate.util.HttpUtil;
import cn.com.glsx.dj.strategy.dto.MarketingActivityDetailRespDTO;
import cn.com.glsx.dj.strategy.dto.MarketingActivityProductItemRespDTO;
import cn.com.glsx.dj.strategy.dto.MarketingActivityProductRespDTO;
import cn.com.glsx.dj.strategy.remote.MarketingActivityRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import java.util.*;
import java.util.stream.Collectors;
/**
* 预学习-大模型调用服务
*
* @author yangzl
*/
@Slf4j
@Service
public class PreLearnBigModelService {
@Autowired
private MarketingActivityRemote marketingActivityRemote;
@Autowired
private PreLearnProductScriptMapper preLearnProductScriptMapper;
@Autowired
private PreLearnOrderMapper preLearnOrderMapper;
@Autowired
private BadgeRecordingsMapper badgeRecordingsMapper;
@Autowired
private AliAsrModelResMapper aliAsrModelResMapper;
@Autowired
private RestTemplate restTemplate;
@Autowired
private ConversationDateService conversationDateService;
@Autowired
private Environment env;
/**
* 提交大模型异步任务(HTTP POST)
*
* @param recordingText 录音ASR文本
* @return 任务ID
*/
@SuppressWarnings("unchecked")
public String submitAsyncTask(String recordingText) {
try {
String url = env.getProperty("big.model.base.prelearn.url", "http://192.168.1.191:8011/api/v1/calls/by-template");
String template_id = env.getProperty("big.model.base.prelearn.template", "CPPE-BENCH-001");
String account_id = env.getProperty("big.model.base.prelearn.account", "LEGACY-eb0333776935");
JSONObject requestBody = new JSONObject();
requestBody.put("template_id", template_id);
requestBody.put("account_id", account_id);
JSONObject variables = new JSONObject();
variables.put("recording_text", recordingText);
requestBody.put("variables", variables);
requestBody.put("mode", "async");
log.info("submitAsyncTask: 提交大模型任务, url={}, recordingText长度={}", url, recordingText.length());
Map<String, Object> response = HttpUtil.post(url, requestBody, Map.class);
if (response == null) {
log.error("submitAsyncTask: 大模型返回空响应");
return null;
}
String taskId = (String) response.get("task_id");
String status = (String) response.get("status");
log.info("submitAsyncTask: 任务已提交, taskId={}, status={}", taskId, status);
if (!"accepted".equals(status)) {
log.warn("submitAsyncTask: 任务状态异常, status={}, message={}",
status, response.get("message"));
}
return taskId;
} catch (Exception e) {
log.error("submitAsyncTask: HTTP调用大模型失败", e);
return null;
}
}
/**
* 提交预学习剧本生成任务
*
* @param activityId 活动ID
*/
public void submitTask(Integer activityId) {
// 1. 查询活动详情(含商品/套餐信息)
RpcResponse<MarketingActivityDetailRespDTO> activityResp = marketingActivityRemote.detailTotal(activityId);
if (Objects.isNull(activityResp) || !activityResp.hasResult()) {
log.error("获取活动详情失败: activityId={}", activityId);
return;
}
MarketingActivityDetailRespDTO activity = activityResp.getResult();
List<MarketingActivityProductRespDTO> products = activity.getProductRespDTOS();
if (CollectionUtils.isEmpty(products)) {
log.info("活动无商品配置: activityId={}", activityId);
return;
}
// 查询已生成过剧本的activity_product_id
List<String> existingProductIds = preLearnProductScriptMapper.selectProductByActivity(activityId);
Set<String> existingIdSet = CollectionUtils.isEmpty(existingProductIds)
? Collections.emptySet()
: new HashSet<>(existingProductIds);
// 2. 遍历每个商品/套餐
for (MarketingActivityProductRespDTO product : products) {
String activityProductId = String.valueOf(product.getProductId());
// 2a. 检查是否已生成过剧本
if (existingIdSet.contains(activityProductId)) {
log.info("活动商品已有剧本记录,跳过: activityId={}, activityProductId={}",
activityId, activityProductId);
continue;
}
// 2b. 确定商品编码列表: 商品用goodsCode,套餐用子商品编码集合
List<String> goodsCodes = resolveGoodsCodes(product);
if (CollectionUtils.isEmpty(goodsCodes)) {
log.warn("商品无有效编码,跳过: activityId={}, productId={}",
activityId, product.getProductId());
continue;
}
// 2c. 查询订单客户信息(最多50条)
List<OrderCustomerDTO> orderCustomers = preLearnOrderMapper
.selectOrderCustomersByGoodsCodes(goodsCodes);
if (CollectionUtils.isEmpty(orderCustomers)) {
log.info("未查询到订单客户: activityId={}, productId={}",
activityId, product.getProductId());
continue;
}
// 2d. 为每个订单生成剧本
int caseIndex = 1;
for (OrderCustomerDTO orderCustomer : orderCustomers) {
try{
if (caseIndex >= 50) {
break;
}
//获取接待录音数据
BadgeRecordings badgeRecordings = fetchReceptionRecordings(orderCustomer.getCustomerPhone(),
orderCustomer.getEarliestCreatedDate());
if(Objects.isNull(badgeRecordings)){
continue;
}
// 2d-i. 查询录音及ASR文本(连表查询)
String asrText = conversationDateService.getBadgeText(badgeRecordings.getId());
if (!StringUtils.hasText(asrText)) {
log.info("未获取到ASR文本: phone={}, orderCode={}",
orderCustomer.getCustomerPhone(), orderCustomer.getOrderCode());
continue;
}
// 2e. 提交大模型异步任务
String modelTaskId = submitAsyncTask(asrText);
if (!StringUtils.hasText(modelTaskId)) {
log.warn("大模型任务提交失败: phone={}, orderCode={}",
orderCustomer.getCustomerPhone(), orderCustomer.getOrderCode());
continue;
}
// 2f. 新建剧本记录,状态为生产中
PreLearnProductScript script = PreLearnProductScript.builder()
.activityId(activityId)
.activityProductId(activityProductId)
.caseIndex(caseIndex)
.modelTaskId(modelTaskId)
.aiStatus(AiStatusEnum.GENERATING.getValue())
.createdBy("system")
.createdDate(new Date())
.carModel(badgeRecordings.getCarModel())
.customerName(badgeRecordings.getCustomerName())
.build();
preLearnProductScriptMapper.insert(script);
caseIndex++;
}catch (Exception e){
log.error("生成案例异常,e",e);
log.error("生成案例失败: activityId={}, activityProductId={}, 提交数量={}",
activityId, activityProductId, caseIndex);
}
}
log.info("活动商品剧本提交完成: activityId={}, activityProductId={}, 提交数量={}",
activityId, activityProductId, caseIndex);
}
}
private BadgeRecordings fetchReceptionRecordings(String phoneNumber, Date orderDate) {
// 1. 连表查询录音(reception_customer_info LEFT JOIN inspection_badge_recordings)
List<BadgeRecordings> recordings = badgeRecordingsMapper.selectByPhoneNumber(phoneNumber);
if (CollectionUtils.isEmpty(recordings)) {
log.info("未找到录音记录: phone={}", phoneNumber);
return null;
}
// 2. 取接待时间与earliestCreatedDate最接近的一条录音
BadgeRecordings closestRecording = findClosestByReceptionTime(recordings, orderDate);
if (closestRecording == null || !StringUtils.hasText(closestRecording.getProcessTaskId())) {
log.info("无有效录音或processTaskId: phone={}", phoneNumber);
return null;
}
return closestRecording;
}
/**
* 查询大模型任务结果(HTTP GET)
*
* @param modelTaskId 模型任务ID
* @return 任务查询结果
*/
@SuppressWarnings("unchecked")
public TaskQueryResult queryTaskResult(String modelTaskId) {
try {
String baseUrl = env.getProperty("big.model.base.prelearn.query.url", "http://192.168.1.191:8011/api/v1/calls/orchestrate/async?task_id=");
String url = baseUrl + modelTaskId;
log.info("queryTaskResult: 查询任务结果, taskId={}", modelTaskId);
Map<String, Object> response = restTemplate.getForObject(url, Map.class);
if (response == null) {
return TaskQueryResult.builder()
.modelTaskId(modelTaskId)
.status(TaskQueryResult.STATUS_PROCESSING)
.build();
}
String status = (String) response.get("status");
TaskQueryResult result = TaskQueryResult.builder()
.modelTaskId(modelTaskId)
.build();
if ("success".equalsIgnoreCase(status)) {
result.setStatus(TaskQueryResult.STATUS_COMPLETED);
Object responseContent = response.get("response_content");
if (responseContent != null) {
result.setScriptJson(responseContent.toString());
}
} else if ("failed".equalsIgnoreCase(status)) {
result.setStatus(TaskQueryResult.STATUS_FAILED);
Object errorMsg = response.get("error_message");
result.setErrorMsg(errorMsg != null ? errorMsg.toString() : "未知错误");
} else {
result.setStatus(TaskQueryResult.STATUS_PROCESSING);
}
return result;
} catch (Exception e) {
log.error("queryTaskResult: 查询大模型任务结果失败, taskId={}", modelTaskId, e);
return TaskQueryResult.builder()
.modelTaskId(modelTaskId)
.status(TaskQueryResult.STATUS_PROCESSING)
.build();
}
}
/**
* 轮询大模型任务结果,更新剧本状态
* 一次查询20条状态为GENERATING的记录,根据大模型返回结果更新状态
*/
public void pollTaskResults() {
log.info("pollTaskResults: 开始轮询大模型任务结果");
List<PreLearnProductScript> pendingList = preLearnProductScriptMapper
.selectPendingPolling(AiStatusEnum.GENERATING.getValue(), 50);
if (CollectionUtils.isEmpty(pendingList)) {
log.info("pollTaskResults: 无待轮询的记录");
return;
}
log.info("pollTaskResults: 查询到{}条待轮询记录", pendingList.size());
int readyCount = 0;
int failedCount = 0;
int processingCount = 0;
for (PreLearnProductScript script : pendingList) {
if (!StringUtils.hasText(script.getModelTaskId())) {
log.warn("pollTaskResults: modelTaskId为空, scriptId={}", script.getId());
continue;
}
try {
TaskQueryResult result = queryTaskResult(script.getModelTaskId());
if (result.isCompleted()) {
// 校验 scriptJson 质量: gameSteps >= 5 且 isHighlight >= 3
boolean isValid = false;
String failReason = null;
if (StringUtils.hasText(result.getScriptJson())) {
try {
ScriptContentDTO content = JSONObject.parseObject(
result.getScriptJson(), ScriptContentDTO.class);
List<GameStepDTO> gameSteps = content.getGameSteps();
if (gameSteps != null && gameSteps.size() >= 5) {
long highlightCount = gameSteps.stream()
.filter(s -> Boolean.TRUE.equals(s.getIsHighlight()))
.count();
if (highlightCount >= 3) {
isValid = true;
} else {
failReason = "isHighlight=true的步骤不足3个(实际" + highlightCount + ")";
}
} else {
failReason = "gameSteps不足5个(实际"
+ (gameSteps != null ? gameSteps.size() : 0) + ")";
}
} catch (Exception e) {
failReason = "JSON解析失败: " + e.getMessage();
log.warn("pollTaskResults: 校验gameSteps失败, scriptId={}", script.getId(), e);
}
} else {
failReason = "scriptJson为空";
}
if (isValid) {
preLearnProductScriptMapper.updateScriptReady(
script.getId(),
result.getScriptJson(),
AiStatusEnum.READY.getValue());
log.info("pollTaskResults: 剧本校验通过, scriptId={}, taskId={}",
script.getId(), script.getModelTaskId());
readyCount++;
} else {
preLearnProductScriptMapper.updateScriptFailed(
script.getId(),
failReason,
AiStatusEnum.FAILED.getValue());
log.warn("pollTaskResults: 剧本校验不通过, scriptId={}, taskId={}, reason={}",
script.getId(), script.getModelTaskId(), failReason);
failedCount++;
}
} else if (result.isFailed()) {
// 大模型调用失败: 写入error_msg,更新状态为FAILED
preLearnProductScriptMapper.updateScriptFailed(
script.getId(),
result.getErrorMsg(),
AiStatusEnum.FAILED.getValue());
log.warn("pollTaskResults: 剧本生成失败, scriptId={}, taskId={}, error={}",
script.getId(), script.getModelTaskId(), result.getErrorMsg());
failedCount++;
} else {
// 仍在处理中
processingCount++;
}
} catch (Exception e) {
log.error("pollTaskResults: 处理记录异常, scriptId={}, taskId={}",
script.getId(), script.getModelTaskId(), e);
}
}
log.info("pollTaskResults: 轮询完成, 成功={}, 失败={}, 处理中={}",
readyCount, failedCount, processingCount);
}
// ==================== 私有方法 ====================
/**
* 根据产品类型解析商品编码列表
* - GOODS(1): 直接使用goodsCode
* - PACKAGE(0): 收集所有子商品的goodsCode
*/
private List<String> resolveGoodsCodes(MarketingActivityProductRespDTO product) {
if (product.getProductType() != null && product.getProductType() == 1) {
// 商品类型
if (StringUtils.hasText(product.getGoodsCode())) {
return Collections.singletonList(product.getGoodsCode());
}
return Collections.emptyList();
}
// 套餐类型: 收集子商品编码
if (!CollectionUtils.isEmpty(product.getPackageItems())) {
return product.getPackageItems().stream()
.map(MarketingActivityProductItemRespDTO::getGoodsCode)
.filter(StringUtils::hasText)
.collect(Collectors.toList());
}
return Collections.emptyList();
}
/**
* 根据手机号和订单日期查询最接近的录音ASR文本
* 使用连表查询: reception_customer_info LEFT JOIN inspection_badge_recordings
*
* @param phoneNumber 客户手机号
* @param orderDate 订单最早创建日期
* @return ASR文本,获取失败返回null
*/
private String fetchAsrText(String phoneNumber, Date orderDate) {
try {
// 1. 连表查询录音(reception_customer_info LEFT JOIN inspection_badge_recordings)
List<BadgeRecordings> recordings = badgeRecordingsMapper.selectByPhoneNumber(phoneNumber);
if (CollectionUtils.isEmpty(recordings)) {
log.info("未找到录音记录: phone={}", phoneNumber);
return null;
}
// 2. 取接待时间与earliestCreatedDate最接近的一条录音
BadgeRecordings closestRecording = findClosestByReceptionTime(recordings, orderDate);
if (closestRecording == null || !StringUtils.hasText(closestRecording.getProcessTaskId())) {
log.info("无有效录音或processTaskId: phone={}", phoneNumber);
return null;
}
// // 3. 查询ASR结果
// AliAsrModelRes asrProbe = new AliAsrModelRes();
// asrProbe.setTaskId(closestRecording.getProcessTaskId());
// asrProbe.setTaskStatus(1); // 任务成功
// AliAsrModelRes asrResult = aliAsrModelResMapper.selectOne(asrProbe);
// if (asrResult == null || !StringUtils.hasText(asrResult.getOutputData())) {
// log.info("ASR结果为空: phone={}, taskId={}", phoneNumber, closestRecording.getProcessTaskId());
// return null;
// }
// 4. 解析ASR JSON并拼接文本
// return parseAsrOutputData(asrResult.getOutputData());
return conversationDateService.getBadgeText(closestRecording.getId());
} catch (Exception e) {
log.warn("获取ASR文本异常: phone={}", phoneNumber, e);
return null;
}
}
/**
* 从录音列表中找到接待开始时间(receptionStartTime)最接近订单日期的录音
*/
private BadgeRecordings findClosestByReceptionTime(List<BadgeRecordings> recordings, Date orderDate) {
if (orderDate == null) {
return recordings.get(0);
}
if(recordings.size() == 1){
return recordings.get(0);
}
return recordings.stream()
.filter(r -> r.getReceptionStartTime() != null)
.min(Comparator.comparingLong(r ->
Math.abs(r.getReceptionStartTime().getTime() - orderDate.getTime())))
.orElse(recordings.get(0));
}
}
package cn.com.glsx.dj.mindworkplate.util; package cn.com.glsx.dj.mindworkplate.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HTTP;
import org.apache.http.ssl.SSLContexts; import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
public class HttpUtils { public class HttpUtils {
...@@ -36,7 +33,7 @@ public class HttpUtils { ...@@ -36,7 +33,7 @@ public class HttpUtils {
request.addHeader("Content-Type", "application/json;charset=utf-8"); request.addHeader("Content-Type", "application/json;charset=utf-8");
HttpResponse response = client.execute(request); HttpResponse response = client.execute(request);
int code = response.getStatusLine().getStatusCode(); int code = response.getStatusLine().getStatusCode();
if (code == 200) { // 请求成功 if (code == 200 || code == 202) { // 请求成功
in = new BufferedReader(new InputStreamReader(response in = new BufferedReader(new InputStreamReader(response
.getEntity().getContent(), "utf-8")); .getEntity().getContent(), "utf-8"));
StringBuffer sb = new StringBuffer(""); StringBuffer sb = new StringBuffer("");
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
<result column="check_type" jdbcType="TINYINT" property="checkType" /> <result column="check_type" jdbcType="TINYINT" property="checkType" />
<result column="car_brandId" jdbcType="TINYINT" property="carBrandId" /> <result column="car_brandId" jdbcType="TINYINT" property="carBrandId" />
<result column="one_car_brandId" jdbcType="TINYINT" property="oneCarBrandId" /> <result column="one_car_brandId" jdbcType="TINYINT" property="oneCarBrandId" />
<result column="reception_start_time" jdbcType="TIMESTAMP" property="receptionStartTime" />
<result column="customer_name" jdbcType="VARCHAR" property="customerName" />
<result column="car_model" jdbcType="VARCHAR" property="carModel" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
...@@ -114,6 +117,32 @@ ...@@ -114,6 +117,32 @@
select * from select * from
inspection_badge_recordings t1,ali_asr_model_res t2 where t1.process_task_id=t2.task_id and t2.task_status=1 and t1.resolved_flag=0; inspection_badge_recordings t1,ali_asr_model_res t2 where t1.process_task_id=t2.task_id and t2.task_status=1 and t1.resolved_flag=0;
</select> </select>
<select id="selectByReceptionIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from inspection_badge_recordings
where reception_id IN
<foreach collection="receptionIds" item="receptionId" open="(" separator="," close=")">
#{receptionId}
</foreach>
AND deleted_flag = 'N'
</select>
<select id="selectByPhoneNumber" resultMap="BaseResultMap">
SELECT
i.id, i.badge_id, i.recording_md5, i.work_order_number, i.recording_filename, i.recording_filesize,
i.recording_start_time, i.recording_end_time, i.recording_duration, i.recording_url, i.right_channel_recording_url,
i.sync_time, i.recording_id, i.resolved_flag, i.upload_flag, i.upload_url, i.process_task_id, i.created_by, i.created_date,
i.updated_by, i.updated_date, i.deleted_flag,i.reception_id,
c.reception_start_time AS reception_start_time,c.car_model,c.customer_name
FROM reception_customer_info c
LEFT JOIN inspection_badge_recordings i ON i.reception_id = c.id
WHERE c.phone_number = #{phoneNumber}
AND c.deleted_flag = 'N'
AND i.deleted_flag = 'N'
AND i.id IS NOT NULL
</select>
<select id="findhistorySendCheck" <select id="findhistorySendCheck"
resultMap="BaseResultMap"> resultMap="BaseResultMap">
select * from inspection_badge_recordings select * from inspection_badge_recordings
......
<?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.InspectionCustomerTagMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.InspectionCustomerTag">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="batch_id" property="batchId" jdbcType="INTEGER"/>
<result column="record_id" property="recordId" jdbcType="INTEGER"/>
<result column="task_id" property="taskId" jdbcType="VARCHAR"/>
<result column="result_flag" property="resultFlag" jdbcType="TINYINT"/>
<result column="tag_result" property="tagResult" jdbcType="LONGVARCHAR"/>
<result column="err_message" property="errMessage" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, batch_id, record_id, task_id, result_flag, tag_result, err_message,
created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<select id="selectByBatchId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM inspection_customer_tag
WHERE batch_id = #{batchId}
AND deleted_flag = 'N'
</select>
<select id="findPendingResults" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM inspection_customer_tag
WHERE result_flag = 1
AND deleted_flag = 'N'
</select>
<update id="updateResult">
UPDATE inspection_customer_tag
SET result_flag = #{resultFlag},
<if test="tagResult != null">
tag_result = #{tagResult},
</if>
<if test="errMessage != null">
err_message = #{errMessage},
</if>
updated_date = NOW()
WHERE id = #{id}
</update>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagDTO">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="batch_id" property="batchId" jdbcType="INTEGER"/>
<result column="record_id" property="recordId" jdbcType="INTEGER"/>
<result column="task_id" property="taskId" jdbcType="VARCHAR"/>
<result column="result_flag" property="resultFlag" jdbcType="TINYINT"/>
<result column="tag_result" property="tagResult" jdbcType="LONGVARCHAR"/>
<result column="err_message" property="errMessage" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="customer_phone" property="customerPhone" jdbcType="VARCHAR"/>
</resultMap>
<select id="selectPageList" resultMap="DTOResultMap">
SELECT
t.id,
t.batch_id,
t.record_id,
t.task_id,
t.result_flag,
t.tag_result,
t.err_message,
t.created_by,
t.created_date,
t.updated_by,
t.updated_date,
rci.phone_number AS customer_phone
FROM inspection_customer_tag t
LEFT JOIN inspection_conversation_batch icb ON t.batch_id = icb.id
LEFT JOIN reception_customer_info rci ON icb.task_id = rci.id
WHERE t.deleted_flag = 'N'
<if test="req.batchId != null">
AND t.batch_id = #{req.batchId}
</if>
<if test="req.resultFlag != null">
AND t.result_flag = #{req.resultFlag}
</if>
<if test="req.startTime != null and req.startTime != ''">
AND t.created_date &gt;= #{req.startTime}
</if>
<if test="req.endTime != null and req.endTime != ''">
AND t.created_date &lt;= #{req.endTime}
</if>
ORDER BY t.created_date DESC
</select>
<select id="selectByPhoneNumbers" resultMap="DTOResultMap">
SELECT
t.id,
t.batch_id,
t.record_id,
t.task_id,
t.result_flag,
t.tag_result,
t.err_message,
t.created_by,
t.created_date,
t.updated_by,
t.updated_date,
rci.phone_number AS customer_phone
FROM inspection_customer_tag t
LEFT JOIN inspection_conversation_batch icb ON t.batch_id = icb.id
LEFT JOIN reception_customer_info rci ON icb.task_id = rci.id
WHERE t.deleted_flag = 'N'
AND rci.phone_number IN
<foreach collection="phoneNumbers" item="phone" open="(" separator="," close=")">
#{phone}
</foreach>
<if test="resultFlag != null">
AND t.result_flag = #{resultFlag}
</if>
ORDER BY t.created_date DESC
</select>
<!-- ConversationBatch ResultMap for historical tag job -->
<resultMap id="ConversationBatchResultMap" type="cn.com.glsx.dj.mindworkplate.model.ConversationBatch">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="conversation_id" property="conversationId" jdbcType="INTEGER"/>
<result column="task_id" property="taskId" jdbcType="INTEGER"/>
<result column="num" property="num" jdbcType="INTEGER"/>
<result column="start_time" property="startTime" jdbcType="VARCHAR"/>
<result column="end_time" property="endTime" jdbcType="VARCHAR"/>
<result column="duration" property="duration" jdbcType="VARCHAR"/>
<result column="file_url" property="fileUrl" jdbcType="VARCHAR"/>
<result column="estimated_result" property="estimatedResult" jdbcType="VARCHAR"/>
<result column="score" property="score" jdbcType="DECIMAL"/>
<result column="digest" property="digest" jdbcType="VARCHAR"/>
<result column="quality_inspection" property="qualityInspection" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR"/>
<result column="che_taskId" property="cheTaskId" jdbcType="VARCHAR"/>
<result column="che_result_flag" property="cheResultFlag" jdbcType="INTEGER"/>
<result column="che_err_message" property="cheErrMessage" jdbcType="VARCHAR"/>
<result column="record_id" property="recordId" jdbcType="INTEGER"/>
</resultMap>
<!-- 查询指定时间范围内未处理的批次 -->
<select id="findUnprocessedBatchesByTimeRange" resultMap="ConversationBatchResultMap">
SELECT
cb.id,
cb.conversation_id,
cb.task_id,
cb.num,
cb.start_time,
cb.end_time,
cb.duration,
cb.file_url,
cb.estimated_result,
cb.score,
cb.digest,
cb.quality_inspection,
cb.created_by,
cb.created_date,
cb.updated_by,
cb.updated_date,
cb.deleted_flag,
cb.che_taskId,
cb.che_result_flag,
cb.che_err_message,
cb.record_id
FROM inspection_conversation_batch cb
INNER JOIN inspection_conversation_date cd ON cb.conversation_id = cd.id
LEFT JOIN inspection_customer_tag ict ON cb.id = ict.batch_id
WHERE cd.created_date BETWEEN #{startTime} AND #{endTime}
AND ict.id IS NULL
AND cd.deleted_flag = 'N'
AND cb.record_id IS NOT NULL
ORDER BY cd.created_date ASC
</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.mindworkplate.mapper.PreLearnOrderMapper" >
<resultMap id="OrderCustomerResultMap" type="cn.com.glsx.dj.mindworkplate.dto.prelearn.OrderCustomerDTO" >
<result column="order_code" property="orderCode" jdbcType="VARCHAR" />
<result column="customer_phone" property="customerPhone" jdbcType="VARCHAR" />
<result column="earliest_created_date" property="earliestCreatedDate" jdbcType="TIMESTAMP" />
</resultMap>
<select id="selectOrderCustomersByGoodsCodes" resultMap="OrderCustomerResultMap">
SELECT
goc.order_code,
goc.customer_phone,
MIN(gsr.created_date) AS earliest_created_date
FROM
dj_car_life_goods_order_customer goc
LEFT JOIN dj_car_life_goods_sub_order gsr ON goc.order_code = gsr.order_code
LEFT JOIN dj_car_life_merchant_goods_info mgi ON mgi.upgrade_goods_id = gsr.upgrade_goods_id
WHERE
mgi.merchant_goods_code IN
<foreach collection="goodsCodes" item="goodsCode" open="(" separator="," close=")">
#{goodsCode}
</foreach>
AND mgi.deleted_flag = 'N'
AND goc.deleted_flag = 'N'
AND gsr.deleted_flag = 'N'
GROUP BY
goc.order_code,
goc.customer_phone
LIMIT 50
</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.mindworkplate.mapper.PreLearnProductScriptMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.prelearn.PreLearnProductScript" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="activity_id" property="activityId" jdbcType="INTEGER" />
<result column="activity_product_id" property="activityProductId" jdbcType="VARCHAR" />
<result column="case_index" property="caseIndex" jdbcType="INTEGER" />
<result column="model_task_id" property="modelTaskId" jdbcType="VARCHAR" />
<result column="script_json" property="scriptJson" jdbcType="LONGVARCHAR" />
<result column="ai_status" property="aiStatus" jdbcType="VARCHAR" />
<result column="error_msg" property="errorMsg" jdbcType="VARCHAR" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, activity_id, activity_product_id, case_index, model_task_id, script_json, ai_status,
error_msg, created_by, created_date, updated_by, updated_date
</sql>
<select id="selectPendingPolling" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM dj_prelearn_product_script
WHERE ai_status = #{aiStatus}
AND model_task_id IS NOT NULL
LIMIT #{limit}
</select>
<select id="selectOneUnread" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM dj_prelearn_product_script
WHERE activity_id = #{activityId}
AND activity_product_id = #{activityProductId}
AND ai_status = #{aiStatus}
<if test="excludeIds != null and excludeIds.size() > 0">
AND id NOT IN
<foreach collection="excludeIds" item="excludeId" open="(" separator="," close=")">
#{excludeId}
</foreach>
</if>
ORDER BY RAND()
LIMIT 1
</select>
<select id="countByActivityAndProduct" resultType="int">
SELECT COUNT(*)
FROM dj_prelearn_product_script
WHERE activity_id = #{activityId}
AND activity_product_id = #{activityProductId}
AND ai_status = #{aiStatus}
</select>
<select id="selectProductByActivity" resultType="java.lang.String">
SELECT
distinct
activity_product_id AS activitProductId
FROM dj_prelearn_product_script
WHERE activity_id = #{activityId}
</select>
<update id="updateAiStatus">
UPDATE dj_prelearn_product_script
SET ai_status = #{aiStatus}
WHERE activity_id = #{activityId}
AND activity_product_id = #{activityProductId}
</update>
<update id="updateScriptReady">
UPDATE dj_prelearn_product_script
SET script_json = #{scriptJson},
ai_status = #{aiStatus}
WHERE id = #{id}
</update>
<update id="updateScriptFailed">
UPDATE dj_prelearn_product_script
SET error_msg = #{errorMsg},
ai_status = #{aiStatus}
WHERE id = #{id}
</update>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!