企微语料ai解析开发
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.volvo.ai.analytic.center.dto.corpus;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.volvo.common.core.base.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description 会话存档消息记录表-湖仓同步表
|
||||
* @author BEJSON
|
||||
* @date 2025-03-10
|
||||
*/
|
||||
@Data
|
||||
public class OdsVdqwMessageOTD {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String fromUserId;
|
||||
private String acceptUserId;
|
||||
private Date msgTime;
|
||||
// 0:个人,1:群聊
|
||||
private int chatType;
|
||||
private String fromUserUnId;
|
||||
private String acceptUserUnId;
|
||||
private String content;
|
||||
public OdsVdqwMessageOTD() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.volvo.ai.analytic.center.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description 外部联系人表-湖仓同步表
|
||||
* @author BEJSON
|
||||
* @date 2025-03-10
|
||||
*/
|
||||
@Data
|
||||
@TableName("tm_ods_vdqw_externalcontact")
|
||||
public class TmOdsVdqwExternalcontact {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value="id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* group_name
|
||||
*/
|
||||
@TableField("external_user_id")
|
||||
private String externalUserId;
|
||||
|
||||
/**
|
||||
* tag_name
|
||||
*/
|
||||
@TableField("name_info")
|
||||
private String nameInfo;
|
||||
|
||||
/**
|
||||
* avatar
|
||||
*/
|
||||
@TableField("avatar")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* varchar(100)
|
||||
*/
|
||||
@TableField("type_info")
|
||||
private Integer typeInfo;
|
||||
|
||||
/**
|
||||
* gender
|
||||
*/
|
||||
@TableField("gender")
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* union_id
|
||||
*/
|
||||
@TableField("union_id")
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* Position
|
||||
*/
|
||||
@TableField("position")
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* corp_name
|
||||
*/
|
||||
@TableField("corp_name")
|
||||
private String corpName;
|
||||
|
||||
/**
|
||||
* corp_full_name
|
||||
*/
|
||||
@TableField("corp_full_name")
|
||||
private String corpFullName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("creation_time")
|
||||
private String creationTime;
|
||||
|
||||
/**
|
||||
* creator_userId
|
||||
*/
|
||||
@TableField("creator_user_id")
|
||||
private Integer creatorUserId;
|
||||
|
||||
/**
|
||||
* last_modification_time
|
||||
*/
|
||||
@TableField("last_modification_time")
|
||||
private String lastModificationTime;
|
||||
|
||||
/**
|
||||
* last_modifier_user_id
|
||||
*/
|
||||
@TableField("last_modifier_user_id")
|
||||
private Long lastModifierUserId;
|
||||
|
||||
/**
|
||||
* deleter_user_id
|
||||
*/
|
||||
@TableField("deleter_user_id")
|
||||
private Long deleterUserId;
|
||||
|
||||
/**
|
||||
* deletion_time
|
||||
*/
|
||||
@TableField("deletion_time")
|
||||
private Date deletionTime;
|
||||
|
||||
/**
|
||||
* 删除标识(0-未删除,1-已删除)
|
||||
*/
|
||||
@TableField("is_deleted")
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 记录版本号,即乐观锁
|
||||
*/
|
||||
@TableField("version")
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@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("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
public TmOdsVdqwExternalcontact() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.volvo.ai.analytic.center.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.volvo.common.core.base.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description 会话存档消息记录表-湖仓同步表
|
||||
* @author BEJSON
|
||||
* @date 2025-03-10
|
||||
*/
|
||||
@Data
|
||||
@TableName("tm_ods_vdqw_messagearchiving")
|
||||
public class TmOdsVdqwMessagearchiving extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value="id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 消息id
|
||||
*/
|
||||
@TableField(value="msg_id")
|
||||
private String msgId;
|
||||
|
||||
/**
|
||||
* 消息类型:send(发送消息)/recall(撤回消息)/switch(切换企业日志)
|
||||
*/
|
||||
@TableField(value="action_type")
|
||||
private String actionType;
|
||||
|
||||
/**
|
||||
* 发送方Id
|
||||
*/
|
||||
@TableField(value="from_user_id")
|
||||
private String fromUserId;
|
||||
|
||||
/**
|
||||
* 群聊消息Id
|
||||
*/
|
||||
@TableField(value="room_id")
|
||||
private String roomId;
|
||||
|
||||
/**
|
||||
* 消息发送时间
|
||||
*/
|
||||
@TableField(value="msg_time")
|
||||
private Date msgTime;
|
||||
|
||||
/**
|
||||
* 消息类型(maType 消息类型:文本消息:text;图片消息:image;语音消息:voice;视频消息:video;文件消息:file;文本卡片消息:textcard;图文消息:news;)
|
||||
*/
|
||||
@TableField(value="msg_type")
|
||||
private String msgType;
|
||||
|
||||
/**
|
||||
* 消息内容json
|
||||
*/
|
||||
@TableField(value="content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value="creation_time")
|
||||
private Date creationTime;
|
||||
|
||||
/**
|
||||
* 创建人Id
|
||||
*/
|
||||
@TableField(value="creator_user_id")
|
||||
private Long creatorUserId;
|
||||
|
||||
/**
|
||||
* 消息标识
|
||||
*/
|
||||
@TableField(value="seq")
|
||||
private Long seq;
|
||||
|
||||
/**
|
||||
* 消息素材是否需要同步(0:否,1:是)
|
||||
*/
|
||||
@TableField(value="is_material_sync")
|
||||
private Integer isMaterialSync;
|
||||
|
||||
/**
|
||||
* 聊天中素材的下载结果
|
||||
*/
|
||||
@TableField(value="material_result")
|
||||
private String materialResult;
|
||||
|
||||
/**
|
||||
* 素材url
|
||||
*/
|
||||
@TableField(value="material_url")
|
||||
private String materialUrl;
|
||||
|
||||
/**
|
||||
* 接收方id
|
||||
*/
|
||||
@TableField(value="accept_user_id")
|
||||
private String acceptUserId;
|
||||
|
||||
/**
|
||||
* 消息发送类型(0:群聊,1:私聊)
|
||||
*/
|
||||
@TableField(value="chat_type")
|
||||
private Integer chatType;
|
||||
|
||||
/**
|
||||
* type_info
|
||||
*/
|
||||
@TableField(value="type_info")
|
||||
private Integer typeInfo;
|
||||
|
||||
/**
|
||||
* is_revoke
|
||||
*/
|
||||
@TableField(value="is_revoke")
|
||||
private Integer isRevoke;
|
||||
|
||||
/**
|
||||
* 删除标识(0-未删除,1-已删除)
|
||||
*/
|
||||
@TableField(value="is_deleted")
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 记录版本号,即乐观锁
|
||||
*/
|
||||
@TableField(value="version")
|
||||
private Integer version;
|
||||
|
||||
public TmOdsVdqwMessagearchiving() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
package com.volvo.ai.analytic.center.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description 企微成员信息表-湖仓同步表
|
||||
* @author BEJSON
|
||||
* @date 2025-03-10
|
||||
*/
|
||||
@Data
|
||||
@TableName("tm_ods_vdqw_workuserinfo")
|
||||
public class TmOdsVdqwWorkuserinfo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value="id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 成员UserId
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 成员名称
|
||||
*/
|
||||
@TableField("name_info")
|
||||
private String nameInfo;
|
||||
|
||||
/**
|
||||
* 职务信息
|
||||
*/
|
||||
@TableField("position")
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@TableField("mobile")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@TableField("gender")
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@TableField("email")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 企业邮箱
|
||||
*/
|
||||
@TableField("biz_mail")
|
||||
private String bizMail;
|
||||
|
||||
/**
|
||||
* 直属上级UserID
|
||||
*/
|
||||
@TableField("direct_leaders")
|
||||
private String directLeaders;
|
||||
|
||||
/**
|
||||
* 头像url
|
||||
*/
|
||||
@TableField("avatar")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 头像缩略图url
|
||||
*/
|
||||
@TableField("thumb_avatar")
|
||||
private String thumbAvatar;
|
||||
|
||||
/**
|
||||
* 座机
|
||||
*/
|
||||
@TableField("telephone")
|
||||
private String telephone;
|
||||
|
||||
/**
|
||||
* 别名
|
||||
*/
|
||||
@TableField("alias")
|
||||
private String alias;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
@TableField("address")
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 全局唯一id
|
||||
*/
|
||||
@TableField("open_user_id")
|
||||
private String openUserId;
|
||||
|
||||
/**
|
||||
* 主部门
|
||||
*/
|
||||
@TableField("main_department")
|
||||
private Integer mainDepartment;
|
||||
|
||||
/**
|
||||
* 已激活,2=已禁用,4=未激活,5=退出企业, 6 待加入
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 员工个人二维码
|
||||
*/
|
||||
@TableField("qr_code")
|
||||
private String qrCode;
|
||||
|
||||
/**
|
||||
* -对外职务
|
||||
*/
|
||||
@TableField("external_position")
|
||||
private String externalPosition;
|
||||
|
||||
/**
|
||||
* 创建者ID
|
||||
*/
|
||||
@TableField("creation_time")
|
||||
private Date creationTime;
|
||||
|
||||
/**
|
||||
* 主部门
|
||||
*/
|
||||
@TableField("creator_user_id")
|
||||
private Long creatorUserId;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
@TableField("deleter_user_id")
|
||||
private Long deleterUserId;
|
||||
|
||||
/**
|
||||
* 主部门
|
||||
*/
|
||||
@TableField("deletion_time")
|
||||
private Date deletionTime;
|
||||
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
@TableField("last_modification_time")
|
||||
private Date lastModificationTime;
|
||||
|
||||
/**
|
||||
* 最后更新者ID
|
||||
*/
|
||||
@TableField("last_modifier_user_id")
|
||||
private Long lastModifierUserId;
|
||||
|
||||
/**
|
||||
* 是否有效
|
||||
*/
|
||||
@TableField("is_active")
|
||||
private Long isActive;
|
||||
|
||||
/**
|
||||
* 彩信内手机号
|
||||
*/
|
||||
@TableField("mms_mobile")
|
||||
private String mmsMobile;
|
||||
|
||||
/**
|
||||
* 是否开启会话存档 默认否
|
||||
*/
|
||||
@TableField("is_open_msg_audit")
|
||||
private String isOpenMsgAudit;
|
||||
|
||||
/**
|
||||
* 个人素材成员绑定编号
|
||||
*/
|
||||
@TableField("material_bind_number")
|
||||
private String materialBindNumber;
|
||||
|
||||
/**
|
||||
* 经销商Code
|
||||
*/
|
||||
@TableField("dealer_code")
|
||||
private String dealerCode;
|
||||
|
||||
/**
|
||||
* 中台对应员工Code
|
||||
*/
|
||||
@TableField("middle_user_code")
|
||||
private String middleUserCode;
|
||||
|
||||
/**
|
||||
* 中台对应员工Id
|
||||
*/
|
||||
@TableField("middle_user_id")
|
||||
private Long middleUserId;
|
||||
|
||||
/**
|
||||
* UnionId
|
||||
*/
|
||||
@TableField("union_id")
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* 最后邀请加入时间
|
||||
*/
|
||||
@TableField("invite_join_time")
|
||||
private Date inviteJoinTime;
|
||||
|
||||
/**
|
||||
* 是否邀请加入过 默认否
|
||||
*/
|
||||
@TableField("is_invite_join")
|
||||
private String isInviteJoin;
|
||||
|
||||
/**
|
||||
* 是否更新角色,0可修改,1不可修改
|
||||
*/
|
||||
@TableField("is_edit_role")
|
||||
private Integer isEditRole;
|
||||
|
||||
/**
|
||||
* WorkUserInfoId
|
||||
*/
|
||||
@TableField("work_user_info_id")
|
||||
private Integer workUserInfoId;
|
||||
|
||||
/**
|
||||
* is_dimission
|
||||
*/
|
||||
@TableField("is_dimission")
|
||||
private Integer isDimission;
|
||||
|
||||
/**
|
||||
* 删除标识(0-未删除,1-已删除)
|
||||
*/
|
||||
@TableField("is_deleted")
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 记录版本号,即乐观锁
|
||||
*/
|
||||
@TableField("version")
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@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("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
public TmOdsVdqwWorkuserinfo() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -208,6 +208,11 @@
|
||||
<version>3.22.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.2.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.volvo.ai.analytic.center.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.obs.services.model.ObsObject;
|
||||
import com.volvo.ai.analytic.center.feign.DiFyFeign;
|
||||
import com.volvo.ai.analytic.center.utils.ObsUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/dify")
|
||||
public class AiRunDataController {
|
||||
|
||||
@Autowired
|
||||
private DiFyFeign diFyFeign;
|
||||
|
||||
@PostMapping("/data")
|
||||
public void fileUpload(String filePath) throws IOException {
|
||||
|
||||
JSONObject jsonObjectResult;
|
||||
try {
|
||||
|
||||
|
||||
|
||||
// 文件路径
|
||||
// String filePath = "D:\\cpq\\本月的外呼时长大于10s的明细- 首次到店时间在1月2月 (1).xlsx";
|
||||
|
||||
// String filePath = "D:\\cpq\\test20250308.xls";
|
||||
// 打开文件
|
||||
FileInputStream file = new FileInputStream(filePath);
|
||||
Workbook workbook = new XSSFWorkbook(file);
|
||||
Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表
|
||||
|
||||
// 读取内容
|
||||
for (Row row : sheet) {
|
||||
|
||||
try {
|
||||
Cell carModel = row.getCell(4);
|
||||
Cell corpus = row.getCell(7);
|
||||
|
||||
String keyword = "";
|
||||
switch (carModel.toString()){
|
||||
case "S60":
|
||||
keyword = "保养、置换";
|
||||
break;
|
||||
case "S90":
|
||||
keyword = "保养、置换";
|
||||
break;
|
||||
case "XC60":
|
||||
keyword = "保养、置换";
|
||||
break;
|
||||
case "XC40":
|
||||
keyword = "置换";
|
||||
break;
|
||||
case "XC90":
|
||||
keyword = "终身用车无忧、置换";
|
||||
break;
|
||||
case "V60":
|
||||
keyword= "置换";
|
||||
case "V90":
|
||||
keyword= "置换”";
|
||||
case "S60 T8":
|
||||
keyword= "置换、购置税全免";
|
||||
case "S90 T8":
|
||||
keyword= "置换、购置税全免";
|
||||
case "XC60 T8":
|
||||
keyword= "置换、购置税全免";
|
||||
case "XC90 T8":
|
||||
keyword= "终身用车无忧、购置税全免";
|
||||
case "S60 RECHARGE":
|
||||
keyword= "保养、置换";
|
||||
case "S60L":
|
||||
keyword= "保养、置换";
|
||||
case "S90 RECHARGE":
|
||||
keyword= "置换、购置税全免";
|
||||
case "XC60 RECHARGE":
|
||||
keyword= "置换、购置税全免";
|
||||
case "XC90 RECHARGE":
|
||||
keyword= "终身用车无忧、购置税全免";
|
||||
case "V90 Cross Country":
|
||||
keyword= "置换";
|
||||
case "EX30":
|
||||
keyword= "限时权益、置换";
|
||||
case "XC40 RECHARGE":
|
||||
keyword= "置换";
|
||||
}
|
||||
|
||||
|
||||
if(!keyword.equals("") && corpus != null){
|
||||
JSONObject runResultJson = null;
|
||||
try {
|
||||
Map<String ,Object> tpMpMap = new HashMap<>();
|
||||
tpMpMap.put("chat",corpus.toString());
|
||||
tpMpMap.put("keyword",keyword);
|
||||
Map<String ,Object> reqMap = new HashMap<>();
|
||||
reqMap.put("inputs",tpMpMap);
|
||||
reqMap.put("response_mode","blocking");
|
||||
reqMap.put("user","streaming232");
|
||||
// log.info("tpMpMap:{}",tpMpMap);
|
||||
runResultJson = diFyFeign.runWorkflows("Bearer app-P09tlGfUbSi9s0Ms3BbskEQF",reqMap);
|
||||
JSONObject outputs = runResultJson.getJSONObject("data").getJSONObject("outputs");
|
||||
log.info("outputs:{}",outputs);
|
||||
String outputsReplase = outputs.toJSONString().replace("\\n","").replace("\n","").replace("```json","").replace(" ```","").replace("```","");
|
||||
JSONObject text = JSONObject.parseObject(outputsReplase);
|
||||
log.info("text:{}",text);
|
||||
JSONObject data = text.getJSONObject("text");
|
||||
|
||||
if(data.containsKey("质检评分")){
|
||||
// 设置新列的值,这里可以根据需求设置不同的值
|
||||
Cell da1 = row.getCell(14);
|
||||
da1.setCellValue(data.getString("质检评分"));
|
||||
}
|
||||
if(data.containsKey("客户反馈")){
|
||||
Cell da2 = row.getCell(15);
|
||||
da2.setCellValue(data.getJSONObject("客户反馈").getString("兴趣程度"));
|
||||
Cell da3 = row.getCell(16);
|
||||
da3.setCellValue(data.getJSONObject("客户反馈").getString("原因"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info("error:{},{}",row.getCell(1).toString(),e);
|
||||
JSONObject outputs = runResultJson.getJSONObject("data").getJSONObject("outputs");
|
||||
log.info("outputs:{}",outputs);
|
||||
String outputsReplase = outputs.toJSONString().replace("\\n","").replace("\n","").replace("```json","").replace(" ```","").replace("```","");
|
||||
JSONObject text = JSONObject.parseObject(outputsReplase);
|
||||
log.info("text:{}",text);
|
||||
Cell da1 = row.getCell(17);
|
||||
da1.setCellValue(String.valueOf(text));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("error:{}",e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 写入文件
|
||||
FileOutputStream outFile = new FileOutputStream(filePath);
|
||||
workbook.write(outFile);
|
||||
outFile.close();
|
||||
workbook.close();
|
||||
file.close();
|
||||
|
||||
System.out.println("数据已追加写入Excel文件。");
|
||||
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("error:{}",e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.volvo.ai.analytic.center.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.volvo.ai.analytic.center.dto.corpus.OdsVdqwMessageOTD;
|
||||
import com.volvo.ai.analytic.center.entity.TmOdsVdqwExternalcontact;
|
||||
import com.volvo.ai.analytic.center.entity.TmOdsVdqwMessagearchiving;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 会话存档消息记录表-湖仓同步表
|
||||
* @author BEJSON
|
||||
* @date 2025-03-10
|
||||
*/
|
||||
@Mapper
|
||||
public interface TmOdsVdqwExternalcontactMapper extends BaseMapper<TmOdsVdqwExternalcontact> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.volvo.ai.analytic.center.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.volvo.ai.analytic.center.dto.corpus.OdsVdqwMessageOTD;
|
||||
import com.volvo.ai.analytic.center.entity.TmOdsVdqwMessagearchiving;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 会话存档消息记录表-湖仓同步表
|
||||
* @author BEJSON
|
||||
* @date 2025-03-10
|
||||
*/
|
||||
@Mapper
|
||||
public interface TmOdsVdqwMessagearchivingMapper extends BaseMapper<TmOdsVdqwMessagearchiving> {
|
||||
|
||||
List<OdsVdqwMessageOTD> queryOdsVdqwMessageByData(@Param("statTime") String statTime, @Param("endTime") String endTime);
|
||||
|
||||
List<OdsVdqwMessageOTD> queryOdsVdqwMessageByFromUserIdAndAcceptUserId(@Param("statTime") String statTime, @Param("endTime") String endTime, @Param("userIdList") List userIdList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.volvo.ai.analytic.center.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.volvo.ai.analytic.center.dto.corpus.OdsVdqwMessageOTD;
|
||||
import com.volvo.ai.analytic.center.entity.TmOdsVdqwMessagearchiving;
|
||||
import com.volvo.ai.analytic.center.entity.TmOdsVdqwWorkuserinfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 会话存档消息记录表-湖仓同步表
|
||||
* @author BEJSON
|
||||
* @date 2025-03-10
|
||||
*/
|
||||
@Mapper
|
||||
public interface TmOdsVdqwWorkuserinfoMapper extends BaseMapper<TmOdsVdqwWorkuserinfo> {
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class CorpusProcessKafkaConsumer {
|
||||
tmTelephoneCorpus.setCreateTime(LocalDateTime.now());
|
||||
tmTelephoneCorpusService.saveTelephoneCorpus(tmTelephoneCorpus);
|
||||
|
||||
tmTelephoneCorpusService.runDify(aicorpusTelephone);
|
||||
tmTelephoneCorpusService.runTelephoneCorpusDify(aicorpusTelephone);
|
||||
|
||||
// 在这里可以添加对解析后的对象的进一步处理逻辑
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -4,4 +4,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.volvo.ai.analytic.center.entity.AiAnalysisRequestLogs;
|
||||
|
||||
public interface AiAnalysisRequestLogsService extends IService<AiAnalysisRequestLogs> {
|
||||
|
||||
boolean saveAiAnalysisRequestLogs(AiAnalysisRequestLogs aiAnalysisRequestLogs);
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ public interface DiFyService {
|
||||
|
||||
public Object getDiFyObject(DiFyReq diFyReq);
|
||||
|
||||
public JSONObject execDifyFlow(DiFyReq diFyReq, String businessType);
|
||||
public JSONObject executeDifyFlow(DiFyReq diFyReq, String businessType);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.volvo.ai.analytic.center.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.volvo.ai.analytic.center.dto.corpus.OdsVdqwMessageOTD;
|
||||
import com.volvo.ai.analytic.center.entity.TmOdsVdqwMessagearchiving;
|
||||
import java.util.*;
|
||||
/**
|
||||
* @description 电话语料表-同步表
|
||||
* @author BEJSON
|
||||
* @date 2025-03-04
|
||||
*/
|
||||
public interface TmOdsVdqwMessagearchivingService extends IService<TmOdsVdqwMessagearchiving> {
|
||||
|
||||
void runQiWeiCorpusDify();
|
||||
|
||||
}
|
||||
@@ -17,5 +17,9 @@ public interface TmTelephoneCorpusService extends IService<TmTelephoneCorpus> {
|
||||
void saveTelephoneCorpus(TmTelephoneCorpus tmTelephoneCorpus);
|
||||
|
||||
|
||||
void runDify(AicorpusTelephoneDTO aicorpusTelephone);
|
||||
void runTelephoneCorpusDify(AicorpusTelephoneDTO aicorpusTelephone);
|
||||
|
||||
String getCarModelList();
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +1,31 @@
|
||||
package com.volvo.ai.analytic.center.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.volvo.ai.analytic.center.entity.AiAnalysisErrors;
|
||||
import com.volvo.ai.analytic.center.entity.AiAnalysisRequestLogs;
|
||||
import com.volvo.ai.analytic.center.mapper.AiAnalysisRequestLogsMapper;
|
||||
import com.volvo.ai.analytic.center.service.AiAnalysisRequestLogsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AiAnalysisRequestLogsServiceImpl extends ServiceImpl<AiAnalysisRequestLogsMapper, AiAnalysisRequestLogs> implements AiAnalysisRequestLogsService {
|
||||
|
||||
@Autowired
|
||||
private AiAnalysisRequestLogsMapper aiAnalysisRequestLogsMapper;
|
||||
@Override
|
||||
public boolean saveAiAnalysisRequestLogs(AiAnalysisRequestLogs aiAnalysisRequestLogs) {
|
||||
|
||||
LambdaQueryWrapper<AiAnalysisRequestLogs> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AiAnalysisRequestLogs::getAiAnalysisRequestId, aiAnalysisRequestLogs.getAiAnalysisRequestId());
|
||||
AiAnalysisRequestLogs oldAiAnalysisRequestLogs= aiAnalysisRequestLogsMapper.selectOne(queryWrapper);
|
||||
if (oldAiAnalysisRequestLogs == null) {
|
||||
return aiAnalysisRequestLogsMapper.insert(aiAnalysisRequestLogs) > 0;
|
||||
} else {
|
||||
return aiAnalysisRequestLogsMapper.update(aiAnalysisRequestLogs, queryWrapper) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.volvo.ai.analytic.center.dto.req.DiFyReq;
|
||||
import com.volvo.ai.analytic.center.entity.AiAnalysisErrors;
|
||||
import com.volvo.ai.analytic.center.entity.AiAnalysisRequestLogs;
|
||||
import com.volvo.ai.analytic.center.enums.BusinessTypeEnum;
|
||||
import com.volvo.ai.analytic.center.feign.DiFyFeign;
|
||||
import com.volvo.ai.analytic.center.mapper.AiAnalysisErrorsMapper;
|
||||
import com.volvo.ai.analytic.center.mapper.AiAnalysisRequestLogsMapper;
|
||||
import com.volvo.ai.analytic.center.service.AiAnalysisErrorsService;
|
||||
import com.volvo.ai.analytic.center.service.AiAnalysisRequestLogsService;
|
||||
import com.volvo.ai.analytic.center.service.DiFyService;
|
||||
import com.volvo.ai.analytic.center.utils.AiAnalysisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -28,7 +26,7 @@ public class DiFyServiceImpl implements DiFyService{
|
||||
private DiFyFeign diFyFeign;
|
||||
|
||||
@Autowired
|
||||
private AiAnalysisRequestLogsMapper aiAnalysisRequestLogsMapper;
|
||||
private AiAnalysisRequestLogsService aiAnalysisRequestLogsService;
|
||||
|
||||
@Autowired
|
||||
private AiAnalysisErrorsService aiAnalysisErrorsService;
|
||||
@@ -50,24 +48,32 @@ public class DiFyServiceImpl implements DiFyService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject execDifyFlow(DiFyReq diFyReq, String businessType) {
|
||||
public JSONObject executeDifyFlow(DiFyReq diFyReq, String businessType) {
|
||||
String aiAnalysisRequestId = AiAnalysisUtils.getAiAnalysisRequestId(businessType);
|
||||
try {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("inputs",diFyReq.getInputs());
|
||||
map.put("response_mode","blocking");
|
||||
map.put("user",diFyReq.getUser());
|
||||
JSONObject difyResult = diFyFeign.runWorkflows("Bearer "+diFyReq.getFlowId(),map);
|
||||
JSONObject data = difyResult.getJSONObject("data");
|
||||
log.info("execDifyFlow dify response data:{}",data);
|
||||
|
||||
// 保存请求日志
|
||||
aiAnalysisRequestLogsMapper.insert(AiAnalysisRequestLogs.builder()
|
||||
aiAnalysisRequestLogsService.saveAiAnalysisRequestLogs(AiAnalysisRequestLogs.builder()
|
||||
.aiAnalysisRequestId(aiAnalysisRequestId)
|
||||
.businessRequest(JSONObject.toJSONString(""))
|
||||
.difyAgentKey(diFyReq.getFlowId())
|
||||
.difyRequest(JSON.toJSONString(diFyReq))
|
||||
.aiAnalysisRequestType(businessType)
|
||||
.build());
|
||||
|
||||
|
||||
JSONObject difyResult = diFyFeign.runWorkflows("Bearer "+diFyReq.getFlowId(),map);
|
||||
JSONObject data = difyResult.getJSONObject("data");
|
||||
log.info("execDifyFlow dify response data:{}",data);
|
||||
data.put("aiAnalysisRequestId",aiAnalysisRequestId);
|
||||
|
||||
aiAnalysisRequestLogsService.saveAiAnalysisRequestLogs(AiAnalysisRequestLogs.builder()
|
||||
.aiAnalysisRequestId(aiAnalysisRequestId)
|
||||
.businessRequest(JSONObject.toJSONString(""))
|
||||
.difyResponse(data.toJSONString())
|
||||
.build());
|
||||
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.volvo.ai.analytic.center.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.volvo.ai.analytic.center.constant.Constant;
|
||||
import com.volvo.ai.analytic.center.dto.corpus.OdsVdqwMessageOTD;
|
||||
import com.volvo.ai.analytic.center.dto.req.DiFyReq;
|
||||
import com.volvo.ai.analytic.center.dto.req.RunMaskingRuleInput;
|
||||
import com.volvo.ai.analytic.center.entity.*;
|
||||
import com.volvo.ai.analytic.center.enums.BusinessTypeEnum;
|
||||
import com.volvo.ai.analytic.center.feign.RemoteCarModelClient;
|
||||
import com.volvo.ai.analytic.center.mapper.TmOdsVdqwExternalcontactMapper;
|
||||
import com.volvo.ai.analytic.center.mapper.TmOdsVdqwMessagearchivingMapper;
|
||||
import com.volvo.ai.analytic.center.mapper.TmOdsVdqwWorkuserinfoMapper;
|
||||
import com.volvo.ai.analytic.center.service.DataMaskingRuleService;
|
||||
import com.volvo.ai.analytic.center.service.DiFyService;
|
||||
import com.volvo.ai.analytic.center.service.TmOdsVdqwMessagearchivingService;
|
||||
import com.volvo.ai.analytic.center.service.TmTelephoneCorpusService;
|
||||
import com.volvo.ai.analytic.center.utils.FlowResultSplitUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.rocketmq.client.producer.SendCallback;
|
||||
import org.apache.rocketmq.client.producer.SendResult;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @description 企微语料表-同步表
|
||||
* @author rz
|
||||
* @date 2025-03-04
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class TmOdsVdqwMessagearchivingServiceImpl extends ServiceImpl<TmOdsVdqwMessagearchivingMapper, TmOdsVdqwMessagearchiving> implements TmOdsVdqwMessagearchivingService {
|
||||
|
||||
@Autowired
|
||||
private TmOdsVdqwMessagearchivingMapper tmOdsVdqwMessagearchivingMapper;
|
||||
|
||||
@Autowired
|
||||
private TmOdsVdqwExternalcontactMapper tmOdsVdqwExternalcontactMapper;
|
||||
|
||||
@Autowired
|
||||
private TmOdsVdqwWorkuserinfoMapper tmOdsVdqwWorkuserinfoMapper;
|
||||
@Autowired
|
||||
private DiFyService diFyService;
|
||||
|
||||
@Resource
|
||||
private RocketMQTemplate rocketMqTemplate;
|
||||
|
||||
@Value("${rocketmq.corpusTelephone.topic}")
|
||||
private String topic;
|
||||
|
||||
@Autowired
|
||||
private RemoteCarModelClient remoteCarModelClient;
|
||||
|
||||
@Autowired
|
||||
private DataMaskingRuleService dataMaskingRuleService;
|
||||
|
||||
@Autowired
|
||||
private TmTelephoneCorpusService tmTelephoneCorpusService;
|
||||
|
||||
@Override
|
||||
public void runQiWeiCorpusDify() {
|
||||
String statTime = "2025-03-01";
|
||||
String endTime = "2025-03-02";
|
||||
|
||||
List<OdsVdqwMessageOTD> messageList = tmOdsVdqwMessagearchivingMapper.queryOdsVdqwMessageByData(statTime,endTime);
|
||||
messageList.stream().forEach(item->{
|
||||
log.info("企微语料内容:FromUserId:{}, AcceptUserId:{}",item.getFromUserId(), item.getAcceptUserId());
|
||||
// 1,vdqw_workuserinfo 这个表对应是 B端认证中心userId
|
||||
// 2,vdqw_externalcontact 这个表对应是 企微客户unionId
|
||||
String unionId = getUnionId(Arrays.asList(item.getFromUserId(), item.getAcceptUserId()));
|
||||
String userId = getUserId(Arrays.asList(item.getFromUserId(), item.getAcceptUserId()));
|
||||
log.info("企微查询信息为空:unionId:{}, userId:{}", unionId,userId);
|
||||
if(StringUtils.isEmpty(unionId) || StringUtils.isNotBlank(userId)){
|
||||
log.info("企微查询信息为空 ");
|
||||
return;
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(item.getFromUserId()) && StringUtils.isNotBlank(item.getAcceptUserId())){
|
||||
|
||||
|
||||
List<OdsVdqwMessageOTD> contetnList = tmOdsVdqwMessagearchivingMapper.queryOdsVdqwMessageByFromUserIdAndAcceptUserId(statTime,endTime, Arrays.asList(item.getFromUserId(), item.getAcceptUserId()));
|
||||
OdsVdqwMessageOTD maxMsgTimeItem = contetnList.stream()
|
||||
.max((o1, o2) -> o1.getMsgTime().compareTo(o2.getMsgTime()))
|
||||
.orElse(null);
|
||||
contetnList.stream().forEach(contentItem->{
|
||||
|
||||
Map<String, Object> inputMap = new HashMap();
|
||||
DiFyReq diFyImageReq = new DiFyReq();
|
||||
diFyImageReq.setUser("11111");
|
||||
diFyImageReq.setFlowId("app-peJXSjHjVKdkYxjdOUuPnZ5b");
|
||||
|
||||
JSONObject contentJson = JSONObject.parseObject(contentItem.getContent());
|
||||
String content = contentJson.getString("content");
|
||||
List<DataMaskingRule> maskingRuleItems = dataMaskingRuleService.getDataMaskingRuleListByApplicationChannel(Constant.CHANNEL_DCC);
|
||||
|
||||
RunMaskingRuleInput runMaskingRuleInput = new RunMaskingRuleInput();
|
||||
runMaskingRuleInput.setDataMaskingRules(maskingRuleItems);
|
||||
// 拼接 role 和 text
|
||||
String chat = contentItem.getFromUserId().concat(":").concat(content);
|
||||
runMaskingRuleInput.setOldStr(chat);
|
||||
String corpusChat = dataMaskingRuleService.runMaskingRule(runMaskingRuleInput);
|
||||
|
||||
inputMap.put("chat",corpusChat);
|
||||
|
||||
inputMap.put("model",tmTelephoneCorpusService.getCarModelList());
|
||||
diFyImageReq.setInputs(inputMap);
|
||||
|
||||
// 获取配置
|
||||
JSONObject execDifyFlow = diFyService.executeDifyFlow(diFyImageReq, BusinessTypeEnum.SMART_ASSISTANT.getCode());
|
||||
log.info("runDify execDifyFlow {}",execDifyFlow);
|
||||
if(null != execDifyFlow && execDifyFlow.get("status").equals("succeeded")){
|
||||
|
||||
String text = execDifyFlow.getJSONObject("outputs").getString("text");
|
||||
String resultStrOne = FlowResultSplitUtil.flowOutputTextSplit(text, "任务1", "任务2");
|
||||
String resultStrTwo =FlowResultSplitUtil.flowOutputTextSplit(text, "任务2", null);
|
||||
Map<String, String> ltoMap = new HashMap();
|
||||
ltoMap.put("analysisRecordId", execDifyFlow.getString("aiAnalysisRequestId"));
|
||||
ltoMap.put("analysisScene", "1");
|
||||
ltoMap.put("unionId", unionId);
|
||||
ltoMap.put("consultantId", userId);
|
||||
ltoMap.put("communicateDate", DateUtil.format(maxMsgTimeItem.getMsgTime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
ltoMap.put("analysisResult", resultStrOne);
|
||||
ltoMap.put("analysisDetail", resultStrTwo);
|
||||
// 发送MQ
|
||||
|
||||
log.info("send mq {}",ltoMap);
|
||||
rocketMqTemplate.asyncSend(topic, MessageBuilder.withPayload(JSON.toJSONString(ltoMap)).build(),
|
||||
new SendCallback() {
|
||||
@Override
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
log.info("企微语料发送MQ成功 消息体:{}", JSON.toJSONString(ltoMap));
|
||||
}
|
||||
@Override
|
||||
public void onException(Throwable e) {
|
||||
log.error("企微语料发送MQ异常 消息体:{}, 异常:", JSON.toJSONString(ltoMap), e);
|
||||
}
|
||||
}, 10000);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private String getUnionId(List<String> userIds){
|
||||
LambdaQueryWrapper<TmOdsVdqwExternalcontact> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(TmOdsVdqwExternalcontact::getExternalUserId, userIds);
|
||||
queryWrapper.eq(TmOdsVdqwExternalcontact::getIsDeleted, 0);
|
||||
List<TmOdsVdqwExternalcontact> oldAiAnalysisRequestLogs= tmOdsVdqwExternalcontactMapper.selectList(queryWrapper);
|
||||
if(CollectionUtils.isNotEmpty(oldAiAnalysisRequestLogs)){
|
||||
return oldAiAnalysisRequestLogs.get(0).getUnionId();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getUserId(List<String> userIds){
|
||||
LambdaQueryWrapper<TmOdsVdqwWorkuserinfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(TmOdsVdqwWorkuserinfo::getUserId, userIds);
|
||||
queryWrapper.eq(TmOdsVdqwWorkuserinfo::getIsDeleted, 0);
|
||||
List<TmOdsVdqwWorkuserinfo> tmOdsVdqwWorkuserinfoList = tmOdsVdqwWorkuserinfoMapper.selectList(queryWrapper);
|
||||
if(CollectionUtils.isNotEmpty(tmOdsVdqwWorkuserinfoList)){
|
||||
return tmOdsVdqwWorkuserinfoList.get(0).getMiddleUserId().toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,20 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.volvo.ai.analytic.center.constant.Constant;
|
||||
import com.volvo.ai.analytic.center.dto.corpus.AicorpusTelephoneDTO;
|
||||
import com.volvo.ai.analytic.center.dto.req.CarModelReqDTO;
|
||||
import com.volvo.ai.analytic.center.dto.req.DiFyReq;
|
||||
import com.volvo.ai.analytic.center.dto.req.RunMaskingRuleInput;
|
||||
import com.volvo.ai.analytic.center.dto.resp.CarModelRespDTO;
|
||||
import com.volvo.ai.analytic.center.dto.resp.ResultDTO;
|
||||
import com.volvo.ai.analytic.center.entity.DataMaskingRule;
|
||||
import com.volvo.ai.analytic.center.entity.TmTelephoneCorpus;
|
||||
import com.volvo.ai.analytic.center.enums.BizEnum;
|
||||
import com.volvo.ai.analytic.center.enums.BusinessTypeEnum;
|
||||
import com.volvo.ai.analytic.center.feign.RemoteCarModelClient;
|
||||
import com.volvo.ai.analytic.center.mapper.TmTelephoneCorpusMapper;
|
||||
import com.volvo.ai.analytic.center.service.DataMaskingRuleService;
|
||||
import com.volvo.ai.analytic.center.service.DiFyService;
|
||||
import com.volvo.ai.analytic.center.service.TmTelephoneCorpusService;
|
||||
import com.volvo.ai.analytic.center.utils.FlowResultSplitUtil;
|
||||
@@ -55,6 +59,9 @@ public class TmTelephoneCorpusServiceImpl extends ServiceImpl<TmTelephoneCorpusM
|
||||
@Autowired
|
||||
private RemoteCarModelClient remoteCarModelClient;
|
||||
|
||||
@Autowired
|
||||
private DataMaskingRuleService dataMaskingRuleService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveTelephoneCorpus(TmTelephoneCorpus tmTelephoneCorpus) {
|
||||
@@ -62,10 +69,15 @@ public class TmTelephoneCorpusServiceImpl extends ServiceImpl<TmTelephoneCorpusM
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runDify(AicorpusTelephoneDTO aicorpusTelephone) {
|
||||
public void runTelephoneCorpusDify(AicorpusTelephoneDTO aicorpusTelephone) {
|
||||
|
||||
if(null != aicorpusTelephone){
|
||||
|
||||
List<DataMaskingRule> maskingRuleItems = dataMaskingRuleService.getDataMaskingRuleListByApplicationChannel(Constant.CHANNEL_DCC);
|
||||
|
||||
RunMaskingRuleInput runMaskingRuleInput = new RunMaskingRuleInput();
|
||||
runMaskingRuleInput.setDataMaskingRules(maskingRuleItems);
|
||||
|
||||
Map<String, Object> inputMap = new HashMap();
|
||||
DiFyReq diFyImageReq = new DiFyReq();
|
||||
diFyImageReq.setUser("11111");
|
||||
@@ -85,14 +97,16 @@ public class TmTelephoneCorpusServiceImpl extends ServiceImpl<TmTelephoneCorpusM
|
||||
|
||||
// 拼接 role 和 text
|
||||
String chat = role + ": " + text;
|
||||
inputMap.put("chat",chat);
|
||||
runMaskingRuleInput.setOldStr(chat);
|
||||
String corpusChat = dataMaskingRuleService.runMaskingRule(runMaskingRuleInput);
|
||||
inputMap.put("chat",corpusChat);
|
||||
});
|
||||
|
||||
|
||||
inputMap.put("model",getCarModelList());
|
||||
diFyImageReq.setInputs(inputMap);
|
||||
// 获取配置
|
||||
JSONObject execDifyFlow = diFyService.execDifyFlow(diFyImageReq, BusinessTypeEnum.SMART_ASSISTANT.getCode());
|
||||
JSONObject execDifyFlow = diFyService.executeDifyFlow(diFyImageReq, BusinessTypeEnum.SMART_ASSISTANT.getCode());
|
||||
log.info("runDify execDifyFlow {}",execDifyFlow);
|
||||
if(null != execDifyFlow && execDifyFlow.get("status").equals("succeeded")){
|
||||
|
||||
@@ -100,7 +114,7 @@ public class TmTelephoneCorpusServiceImpl extends ServiceImpl<TmTelephoneCorpusM
|
||||
String resultStrOne = FlowResultSplitUtil.flowOutputTextSplit(text, "任务1", "任务2");
|
||||
String resultStrTwo =FlowResultSplitUtil.flowOutputTextSplit(text, "任务2", null);
|
||||
Map<String, String> ltoMap = new HashMap();
|
||||
ltoMap.put("analysisRecordId", aicorpusTelephone.getSourceId());
|
||||
ltoMap.put("analysisRecordId", execDifyFlow.getString("aiAnalysisRequestId"));
|
||||
ltoMap.put("analysisScene", "2");
|
||||
// ltoMap.put("unionId", aicorpusTelephone.getSourceId());
|
||||
ltoMap.put("recordId", aicorpusTelephone.getSourceId());
|
||||
@@ -114,11 +128,11 @@ public class TmTelephoneCorpusServiceImpl extends ServiceImpl<TmTelephoneCorpusM
|
||||
new SendCallback() {
|
||||
@Override
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
log.info("发送导入标签值成功 消息体:{}", JSON.toJSONString(ltoMap));
|
||||
log.info("电话语料发送MQ成功 消息体:{}", JSON.toJSONString(ltoMap));
|
||||
}
|
||||
@Override
|
||||
public void onException(Throwable e) {
|
||||
log.error("发送导入标签值异常 消息体:{}, 异常:", JSON.toJSONString(ltoMap), e);
|
||||
log.error("电话语料发送MQ异常 消息体:{}, 异常:", JSON.toJSONString(ltoMap), e);
|
||||
}
|
||||
}, 10000);
|
||||
|
||||
@@ -126,7 +140,7 @@ public class TmTelephoneCorpusServiceImpl extends ServiceImpl<TmTelephoneCorpusM
|
||||
}
|
||||
}
|
||||
|
||||
private String getCarModelList(){
|
||||
public String getCarModelList(){
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
CarModelReqDTO carModelReqDTO = new CarModelReqDTO();
|
||||
@@ -151,4 +165,5 @@ public class TmTelephoneCorpusServiceImpl extends ServiceImpl<TmTelephoneCorpusM
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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="com.volvo.ai.analytic.center.mapper.TmTelephoneCorpusMapper">
|
||||
|
||||
<select id="queryOdsVdqwMessageByData" resultType="com.volvo.ai.analytic.center.dto.corpus.OdsVdqwMessageOTD" >
|
||||
|
||||
SELECT
|
||||
tovm.from_user_id as fromUserUnId,
|
||||
tovm.accept_user_id as acceptUserId,
|
||||
tovm.msg_time as msgTime,
|
||||
tovm.chat_type as chatType
|
||||
FROM
|
||||
`tm_ods_vdqw_messagearchiving` tovm
|
||||
WHERE
|
||||
tovm.msg_time between #{statTime} and #{endTime}
|
||||
AND tovm.chat_type = 0
|
||||
GROUP BY
|
||||
tovm.from_user_id,
|
||||
tovm.accept_user_id
|
||||
</select>
|
||||
|
||||
<select id="queryOdsVdqwMessageByFromUserIdAndAcceptUserId" resultType="com.volvo.ai.analytic.center.dto.corpus.OdsVdqwMessageOTD" >
|
||||
|
||||
SELECT
|
||||
tovm.msg_time,
|
||||
tovm.content,
|
||||
tovm.from_user_id,
|
||||
tovm.accept_user_id
|
||||
FROM
|
||||
`tm_ods_vdqw_messagearchiving` tovm
|
||||
WHERE
|
||||
tovm.msg_time between #{statTime} and #{endTime}
|
||||
AND tovm.from_user_id IN
|
||||
<foreach collection="fromUserId" item="userIdList" open="(" separator="," close=")">
|
||||
#{userIdList}
|
||||
</foreach>
|
||||
AND tovm.accept_user_id IN
|
||||
<foreach collection="fromUserId" item="userIdList" open="(" separator="," close=")">
|
||||
#{userIdList}
|
||||
</foreach>
|
||||
AND tovm.chat_type = 0
|
||||
and tovm.msg_type='text'
|
||||
and tovm.action_type='send'
|
||||
ORDER BY
|
||||
tovm.msg_time
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user