初始化dify调用功能

This commit is contained in:
zhangfan
2024-12-13 10:23:42 +08:00
parent b53fe2c24e
commit 91ef35ae9e
28 changed files with 1129 additions and 7 deletions

View File

@@ -0,0 +1,6 @@
package com.volvo.ai.analytic.center.constant;
public class Constant {
public static final String rabbitMqFormQueue = "Voc-Defeat-Dcc";
}

View File

@@ -0,0 +1,10 @@
package com.volvo.ai.analytic.center.constant;
/**
* 是非
*/
public interface YesOrNoConstants {
int YES = 1;
int NO = 0;
}

View File

@@ -0,0 +1,163 @@
package com.volvo.ai.analytic.center.dto.req;
import java.util.List;
/**
* mq消息体解析对象
*/
public class RabbitMqFormData {
private String formId;
private int sinceType;
private int subSinceType;
private Data data;
// Getters and Setters
public String getFormId() {
return formId;
}
public void setFormId(String formId) {
this.formId = formId;
}
public int getSinceType() {
return sinceType;
}
public void setSinceType(int sinceType) {
this.sinceType = sinceType;
}
public int getSubSinceType() {
return subSinceType;
}
public void setSubSinceType(int subSinceType) {
this.subSinceType = subSinceType;
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
}
class Data {
private String businessId;
private String vdqwUserId;
private String vdqwCustomerId;
private String defeatTime;
private String approveCode;
private String approveResult;
private String approveOpinion;
private List<CallList> callList;
// Getters and Setters
public String getBusinessId() {
return businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public String getVdqwUserId() {
return vdqwUserId;
}
public void setVdqwUserId(String vdqwUserId) {
this.vdqwUserId = vdqwUserId;
}
public String getVdqwCustomerId() {
return vdqwCustomerId;
}
public void setVdqwCustomerId(String vdqwCustomerId) {
this.vdqwCustomerId = vdqwCustomerId;
}
public String getDefeatTime() {
return defeatTime;
}
public void setDefeatTime(String defeatTime) {
this.defeatTime = defeatTime;
}
public String getApproveCode() {
return approveCode;
}
public void setApproveCode(String approveCode) {
this.approveCode = approveCode;
}
public String getApproveResult() {
return approveResult;
}
public void setApproveResult(String approveResult) {
this.approveResult = approveResult;
}
public String getApproveOpinion() {
return approveOpinion;
}
public void setApproveOpinion(String approveOpinion) {
this.approveOpinion = approveOpinion;
}
public List<CallList> getCallList() {
return callList;
}
public void setCallList(List<CallList> callList) {
this.callList = callList;
}
}
class CallList {
private String sessionId;
private String sourceId;
private String audioTime;
private int audioBillsec;
// Getters and Setters
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public String getSourceId() {
return sourceId;
}
public void setSourceId(String sourceId) {
this.sourceId = sourceId;
}
public String getAudioTime() {
return audioTime;
}
public void setAudioTime(String audioTime) {
this.audioTime = audioTime;
}
public int getAudioBillsec() {
return audioBillsec;
}
public void setAudioBillsec(int audioBillsec) {
this.audioBillsec = audioBillsec;
}
}

View File

@@ -0,0 +1,14 @@
package com.volvo.ai.analytic.center.dto.req;
import com.volvo.ai.analytic.center.entity.DataMaskingRule;
import lombok.Data;
import java.util.List;
@Data
public class RunMaskingRuleInput {
private String oldStr;
private List<DataMaskingRule> dataMaskingRules;
private String opinionId;
}

View File

@@ -0,0 +1,94 @@
package com.volvo.ai.analytic.center.dto.resp;
import java.util.List;
/**
* mq消息体解析对象
*/
public class RabbitMqToData {
private String formId;
private int sinceType;
private int subSinceType;
private Data data;
// Getters and Setters
public String getFormId() {
return formId;
}
public void setFormId(String formId) {
this.formId = formId;
}
public int getSinceType() {
return sinceType;
}
public void setSinceType(int sinceType) {
this.sinceType = sinceType;
}
public int getSubSinceType() {
return subSinceType;
}
public void setSubSinceType(int subSinceType) {
this.subSinceType = subSinceType;
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
}
class Data {
private String businessId;
private String responseCode;
private String responseMsg;
private String label;
private String describe;
public String getBusinessId() {
return businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public String getResponseCode() {
return responseCode;
}
public void setResponseCode(String responseCode) {
this.responseCode = responseCode;
}
public String getResponseMsg() {
return responseMsg;
}
public void setResponseMsg(String responseMsg) {
this.responseMsg = responseMsg;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescribe() {
return describe;
}
public void setDescribe(String describe) {
this.describe = describe;
}
}

View File

@@ -0,0 +1,121 @@
package com.volvo.ai.analytic.center.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.volvo.common.core.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 数据脱敏规则表
*/
@Data
@Accessors
@EqualsAndHashCode(callSuper = true)
@TableName("tm_datamaskingrule")
public class DataMaskingRule extends BaseEntity {
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 删除标识0-未删除1-已删除)
*/
@TableField("is_deleted")
private Integer isDeleted;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
/**
* 创建人
*/
@TableField("create_by")
private String createBy;
/**
* 更新人
*/
@TableField("update_by")
private String updateBy;
/**
* 创建sql人
*/
@TableField("create_sqlby")
private String createSqlby;
/**
* 更新sql人
*/
@TableField("update_sqlby")
private String updateSqlby;
/**
* 乐观锁
*/
@TableField("versions")
private Integer versions;
/**
* 脱敏规则名称
*/
@TableField("rule_name")
private String ruleName;
/**
* 规则类型(文本、正则)
*/
@TableField("category_name")
private String categoryName;
/**
* 规则文本(要替换的文本、正则表达式匹配文本)
*/
@TableField("rule_text")
private String ruleText;
/**
* 规则映射值
*/
@TableField("rule_mapping_text")
private String ruleMappingText;
/**
* 优先级
*/
@TableField("rule_priority")
private Integer rulePriority;
/**
* 适用渠道
*/
@TableField("application_channel")
private String applicationChannel;
/**
* 状态(启用、禁用)
*/
@TableField("rule_status")
private Integer ruleStatus;
/**
* 规则备注
*/
@TableField("rule_remarks")
private String ruleRemarks;
}

View File

@@ -0,0 +1,124 @@
package com.volvo.ai.analytic.center.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.volvo.common.core.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
@Data
@Accessors
@EqualsAndHashCode(callSuper = true)
@TableName("tt_diffdefeat_approve")
public class DiffdefeatApprove extends BaseEntity {
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 删除标识0-未删除1-已删除)
*/
@TableField("is_deleted")
private Integer isDeleted;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
/**
* 创建人
*/
@TableField("create_by")
private String createBy;
/**
* 更新人
*/
@TableField("update_by")
private String updateBy;
/**
* 创建sql人
*/
@TableField("create_sqlby")
private String createSqlby;
/**
* 更新sql人
*/
@TableField("update_sqlby")
private String updateSqlby;
/**
* 乐观锁
*/
@TableField("versions")
private Integer versions;
/**
* 请求入参
*/
@TableField("input_str")
private String inputStr;
/**
* 业务Id
*/
@TableField("form_id")
private String formId;
/**
* 商机Id
*/
@TableField("business_id")
private String businessId;
/**
* 业务时间
*/
@TableField("defeat_time")
private Date defeatTime;
/**
* 用户状态
*/
@TableField("user_status")
private String userStatus;
/**
* 真假战败文本信息
*/
@TableField("appointment_result")
private String appointmentResult;
/**
* 审批结果编码
*/
@TableField("approve_code")
private String approveCode;
/**
* 审批结果文本
*/
@TableField("approve_result")
private String approveResult;
/**
* 经理审批意见
*/
@TableField("approve_opinion")
private String approveOpinion;
}

View File

@@ -0,0 +1,126 @@
package com.volvo.ai.analytic.center.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.volvo.common.core.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* MQ接收数据表实体类
*/
@Data
@Accessors
@EqualsAndHashCode(callSuper = true)
@TableName("tt_mq_message_record")
public class MqMessageRecord extends BaseEntity {
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 场景类型 1质检分析
*/
@TableField("since_type")
private Integer sinceType;
/**
* 1,新车销售2二手车销售3收车销售4 首定保5延保
*/
@TableField("sub_since_type")
private Integer subSinceType;
/**
* sessionId
*/
@TableField("biz_no")
private String bizNo;
/**
* sourceId
*/
@TableField("sub_biz_no")
private String subBizNo;
/**
* 消息体小于4000直接存消息体大于存Iobs key
*/
@TableField("message_content")
private String messageContent;
/**
* mq消息体Iobs key
*/
@TableField("message_iobs_key")
private String messageIobsKey;
/**
* mq message key
*/
@TableField("message_key")
private String messageKey;
/**
* 批处理重试次数,默认3次
*/
@TableField("retry_count")
private Integer retryCount;
/**
* 最后一次重试时间
*/
@TableField("last_retry_time")
private Date lastRetryTime;
/**
* 响应码
*/
@TableField("resp_code")
private String respCode;
/**
* 错误消息 截取200长度字符
*/
@TableField("resp_content")
private String respContent;
/**
* 任务状态: 0:待分析,1.分析中, 2.分析完成, 3.分析失败
*/
@TableField("task_status")
private Integer taskStatus;
/**
* 删除标识0-未删除1-已删除)
*/
@TableField("is_deleted")
private Integer isDeleted;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
/**
* 创建人
*/
@TableField("create_by")
private String createBy;
/**
* 更新人
*/
@TableField("update_by")
private String updateBy;
}

View File

@@ -0,0 +1,51 @@
package com.volvo.ai.analytic.center.enums;
import lombok.Getter;
import lombok.ToString;
import java.util.Objects;
/**
* @author: zhangfan
* @date: 2024/12/12 13:32
* @description:
*/
@Getter
@ToString
public enum BizEnum {
BAD_REQUEST(4000, "参数不合法"),
METHOD_NOT_ALLOWED(4001, "方法不允许"),
MISS_PARAM(4002, "参数缺失"),
QUERY_FAILED(4003, "查询失败"),
;
private Integer code;
private String msg;
BizEnum(Integer code, String msg){
this.code = code;
this.msg = msg;
}
/**
* 通过状态码获取枚举对象
* @param code 状态码
* @return 枚举对象
*/
public static BizEnum getByCode(String code) {
for (BizEnum resultCode : BizEnum.values()) {
if (Objects.equals(resultCode.getCode(),code)) {
return resultCode;
}
}
return null;
}
}

View File

@@ -0,0 +1,60 @@
package com.volvo.ai.analytic.center.exception;
import com.volvo.ai.analytic.center.enums.BizEnum;
import com.volvo.common.core.util.ResultMsg;
public class BizException extends CoreException {
private static final long serialVersionUID = 1L;
private Integer code;
public BizException() {
super();
}
/**
* 自定义异常
*
* @param resultEnum 返回枚举对象
*/
public BizException(BizEnum resultEnum) {
super(resultEnum.getMsg());
this.code = resultEnum.getCode();
}
public BizException(String msg) {
super(msg);
}
public BizException(String msg, Throwable e) {
super(msg, e);
}
public BizException(Integer code, String msg) {
super(msg);
this.code = code;
}
public BizException(Integer code, String msg, Throwable e) {
super(msg, e);
this.code = code;
}
public BizException(ResultMsg result) {
this(result.getCode(), result.getMsg());
}
public BizException(ResultMsg result, Throwable e) {
this(result.getCode(), result.getMsg(), e);
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
}

View File

@@ -0,0 +1,54 @@
package com.volvo.ai.analytic.center.exception;
import com.volvo.common.core.util.ResultMsg;
/**
* @author: zhangfan
* @date: 2024/12/12 13:27
* @description:通用业务异常
*/
public class BusinessException extends CoreException {
private static final long serialVersionUID = 1L;
private Integer code;
public BusinessException() {
super();
}
public BusinessException(String msg) {
super(msg);
}
public BusinessException(String msg, Throwable e) {
super(msg, e);
}
public BusinessException(Integer code, String msg) {
super(msg);
this.code = code;
}
public BusinessException(Integer code, String msg, Throwable e) {
super(msg, e);
this.code = code;
}
public BusinessException(ResultMsg result) {
this(result.getCode(), result.getMsg());
}
public BusinessException(ResultMsg result, Throwable e) {
this(result.getCode(), result.getMsg(), e);
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
}

View File

@@ -0,0 +1,24 @@
package com.volvo.ai.analytic.center.exception;
/**
* @author: zhangfan
* @date: 2024/12/12 13:27
* @description:
*/
public class CoreException extends RuntimeException {
public CoreException() {
}
public CoreException(String message) {
super(message);
}
public CoreException(String message, Throwable cause) {
super(message, cause);
}
public CoreException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,17 @@
package com.volvo.ai.analytic.center.feign;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@FeignClient(name = "difyClient", url = "${service.dify.url}")
public interface DiFyFeign {
@PostMapping(value = "v1/workflows/run"
, consumes = MediaType.APPLICATION_JSON_VALUE
, produces = MediaType.APPLICATION_JSON_VALUE)
Object runWorkflows(@RequestHeader(value = "Authorization") String authorization, @RequestBody Map<String, Object> map);
}