Commit fe3e1089 by 叶立庆

Merge branch 'v5.8.3' into 'master'

上线合并

See merge request !25
2 parents 1fc6ee74 261759d1
Showing 42 changed files with 1679 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.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!