调整保持数据库JSON对象
This commit is contained in:
@@ -2,9 +2,7 @@ package com.volvo.ai.analytic.center.constant;
|
|||||||
|
|
||||||
public class Constant {
|
public class Constant {
|
||||||
|
|
||||||
public static final String rabbitMqFormQueue = "Voc-Defeat-Dcc";
|
|
||||||
|
|
||||||
public static final String rabbitToFormQueue = "Voc-DefeatResponse-Dcc";
|
|
||||||
|
|
||||||
public static final String CHANNEL_DCC = "Channel_Dcc";
|
public static final String CHANNEL_DCC = "Channel_Dcc";
|
||||||
|
|
||||||
|
public static final String DISPLAY_STATUS = "FINISHED";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
|||||||
* mq消息体解析对象
|
* mq消息体解析对象
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RabbitMqFormData {
|
public class MqFormData {
|
||||||
private String formId;
|
private String formId;
|
||||||
private Integer sinceType;
|
private Integer sinceType;
|
||||||
private Integer subSinceType;
|
private Integer subSinceType;
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.volvo.ai.analytic.center.dto.req;
|
package com.volvo.ai.analytic.center.dto.req;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class Result {
|
public class Result {
|
||||||
|
|
||||||
|
@JSONField(name = "analysis_info")
|
||||||
private AnalysisInfo analysisInfo;
|
private AnalysisInfo analysisInfo;
|
||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
|||||||
* mq消息体解析对象
|
* mq消息体解析对象
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RabbitMqToData {
|
public class MqToData {
|
||||||
private String formId;
|
private String formId;
|
||||||
private int sinceType;
|
private int sinceType;
|
||||||
private int subSinceType;
|
private int subSinceType;
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.volvo.ai.analytic.center.enums;
|
||||||
|
|
||||||
|
public enum RuleCategoryEnum {
|
||||||
|
|
||||||
|
TEXT("文本", "文本"),
|
||||||
|
REGEX("正则", "正则"),
|
||||||
|
;
|
||||||
|
private String code;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
RuleCategoryEnum(String code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return this.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.volvo.ai.analytic.center.constant.YesOrNoConstants;
|
import com.volvo.ai.analytic.center.constant.YesOrNoConstants;
|
||||||
import com.volvo.ai.analytic.center.dto.req.RunMaskingRuleInput;
|
import com.volvo.ai.analytic.center.dto.req.RunMaskingRuleInput;
|
||||||
import com.volvo.ai.analytic.center.entity.DataMaskingRule;
|
import com.volvo.ai.analytic.center.entity.DataMaskingRule;
|
||||||
|
import com.volvo.ai.analytic.center.enums.RuleCategoryEnum;
|
||||||
import com.volvo.ai.analytic.center.mapper.DataMaskingRuleMapper;
|
import com.volvo.ai.analytic.center.mapper.DataMaskingRuleMapper;
|
||||||
import com.volvo.ai.analytic.center.service.DataMaskingRuleService;
|
import com.volvo.ai.analytic.center.service.DataMaskingRuleService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -34,15 +36,17 @@ public class DataMaskingRuleServiceImpl extends ServiceImpl<DataMaskingRuleMappe
|
|||||||
if (input.getDataMaskingRules() != null && !input.getDataMaskingRules().isEmpty()) {
|
if (input.getDataMaskingRules() != null && !input.getDataMaskingRules().isEmpty()) {
|
||||||
for (DataMaskingRule ruleItem : input.getDataMaskingRules()) {
|
for (DataMaskingRule ruleItem : input.getDataMaskingRules()) {
|
||||||
try {
|
try {
|
||||||
if ("文本".equals(ruleItem.getCategoryName())) {
|
if (Objects.equals(RuleCategoryEnum.TEXT.getCode(),ruleItem.getCategoryName())) {
|
||||||
output = output.replace(ruleItem.getRuleText(), ruleItem.getRuleMappingText());
|
output = output.replace(ruleItem.getRuleText(), ruleItem.getRuleMappingText());
|
||||||
} else if ("正则".equals(ruleItem.getCategoryName())) {
|
} else if (Objects.equals(RuleCategoryEnum.REGEX.getCode(),ruleItem.getCategoryName())) {
|
||||||
Pattern pattern = Pattern.compile(ruleItem.getRuleText(), Pattern.CASE_INSENSITIVE);
|
Pattern pattern = Pattern.compile(ruleItem.getRuleText(), Pattern.CASE_INSENSITIVE);
|
||||||
Matcher matcher = pattern.matcher(output);
|
Matcher matcher = pattern.matcher(output);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
String matchedValue = matcher.group();
|
String matchedValue = matcher.group();
|
||||||
output = output.replace(matchedValue, ruleItem.getRuleMappingText());
|
output = output.replace(matchedValue, ruleItem.getRuleMappingText());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.info("runMaskingRule categoryName:{} not support", ruleItem.getCategoryName());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
|||||||
public boolean processMessageByMQ(String message) {
|
public boolean processMessageByMQ(String message) {
|
||||||
log.info("processMessageByMQ message: {}", message);
|
log.info("processMessageByMQ message: {}", message);
|
||||||
LocalDateTime currTime = LocalDateTime.now();
|
LocalDateTime currTime = LocalDateTime.now();
|
||||||
RabbitMqFormData oldItem = JSONObject.parseObject(message, RabbitMqFormData.class);
|
MqFormData oldItem = JSONObject.parseObject(message, MqFormData.class);
|
||||||
log.info("processMessageByMQ 真假战败数据已获取 {}",oldItem.getFormId());
|
log.info("processMessageByMQ 真假战败数据已获取 {}",oldItem.getFormId());
|
||||||
MqMessageRecord curMQMessageRecord = new MqMessageRecord();
|
MqMessageRecord curMQMessageRecord = new MqMessageRecord();
|
||||||
try {
|
try {
|
||||||
@@ -101,7 +101,7 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processMqSinceType51(RabbitMqFormData oldItem,MqMessageRecord curMQMessageRecord){
|
private void processMqSinceType51(MqFormData oldItem, MqMessageRecord curMQMessageRecord){
|
||||||
log.info("processMqSinceType51 辨别数据为分析请求 {}" ,SubSinceTypeEnum.SINCETYPE51.getCode());
|
log.info("processMqSinceType51 辨别数据为分析请求 {}" ,SubSinceTypeEnum.SINCETYPE51.getCode());
|
||||||
DiffDefeatanAlysis diffDefeatanAlysis = JSON.parseObject(JSON.toJSONString(oldItem.getData()), DiffDefeatanAlysis.class);
|
DiffDefeatanAlysis diffDefeatanAlysis = JSON.parseObject(JSON.toJSONString(oldItem.getData()), DiffDefeatanAlysis.class);
|
||||||
DiffDefeatAnalyseOutputResult response = this.processChatRecord(diffDefeatanAlysis);
|
DiffDefeatAnalyseOutputResult response = this.processChatRecord(diffDefeatanAlysis);
|
||||||
@@ -143,7 +143,7 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processMqSinceType52(RabbitMqFormData oldItem,MqMessageRecord curMQMessageRecord){
|
private void processMqSinceType52(MqFormData oldItem, MqMessageRecord curMQMessageRecord){
|
||||||
log.info("processMqSinceType52 辨别数据为分析请求 {}" ,SubSinceTypeEnum.SINCETYPE52.getCode());
|
log.info("processMqSinceType52 辨别数据为分析请求 {}" ,SubSinceTypeEnum.SINCETYPE52.getCode());
|
||||||
com.volvo.ai.analytic.center.dto.req.DiffDefeatanApprove curDiffDefeatApprove = JSON.parseObject(JSON.toJSONString(oldItem.getData()), com.volvo.ai.analytic.center.dto.req.DiffDefeatanApprove.class);
|
com.volvo.ai.analytic.center.dto.req.DiffDefeatanApprove curDiffDefeatApprove = JSON.parseObject(JSON.toJSONString(oldItem.getData()), com.volvo.ai.analytic.center.dto.req.DiffDefeatanApprove.class);
|
||||||
DiffdefeatApprove approveEntity = diffdefeatApproveService.lambdaQuery().eq(DiffdefeatApprove::getFormId, oldItem.getFormId()).last("limit 1").one();
|
DiffdefeatApprove approveEntity = diffdefeatApproveService.lambdaQuery().eq(DiffdefeatApprove::getFormId, oldItem.getFormId()).last("limit 1").one();
|
||||||
@@ -210,8 +210,8 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
|||||||
log.info("processChatRecord 企微用户信息为空,不附加企微数据");
|
log.info("processChatRecord 企微用户信息为空,不附加企微数据");
|
||||||
}else {
|
}else {
|
||||||
try {
|
try {
|
||||||
String userIdSql = "select distinct userid as userid from ods_workuserinfo_d where middleuserid ='" + input.getVdqwUserId()
|
String userIdSql = "select distinct userid as userid from ods_workuserinfo_d where middleuserid =" + input.getVdqwUserId()
|
||||||
+ "' union ALL select externaluserid as userid from ods_externalcontact_d where unionid ='" + input.getVdqwCustomerId() + "'";
|
+ " union ALL select externaluserid as userid from ods_externalcontact_d where unionid ='" + input.getVdqwCustomerId() + "'";
|
||||||
log.info("processChatRecord 查询企微用户数据sql {}",userIdSql);
|
log.info("processChatRecord 查询企微用户数据sql {}",userIdSql);
|
||||||
List<Map<String, Object>> userList = clickhouseJdbcTemplate.queryForList(userIdSql);
|
List<Map<String, Object>> userList = clickhouseJdbcTemplate.queryForList(userIdSql);
|
||||||
if (!CollectionUtils.isEmpty(userList) && userList.size() == 2) {
|
if (!CollectionUtils.isEmpty(userList) && userList.size() == 2) {
|
||||||
@@ -262,7 +262,7 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
|||||||
CollectTranscriberJobResponse resp = JSON.parseObject(item.getCorpuText(), CollectTranscriberJobResponse.class);
|
CollectTranscriberJobResponse resp = JSON.parseObject(item.getCorpuText(), CollectTranscriberJobResponse.class);
|
||||||
// CollectTranscriberJobResponse resp = JSON.parseObject(oldItem.getDisplay(), CollectTranscriberJobResponse.class);
|
// CollectTranscriberJobResponse resp = JSON.parseObject(oldItem.getDisplay(), CollectTranscriberJobResponse.class);
|
||||||
// 检查状态并处理Segments
|
// 检查状态并处理Segments
|
||||||
if (Objects.equals("FINISHED",resp.getStatus()) && !CollectionUtils.isEmpty(resp.getSegments())) {
|
if (Objects.equals(Constant.DISPLAY_STATUS,resp.getStatus()) && !CollectionUtils.isEmpty(resp.getSegments())) {
|
||||||
StringBuilder vocStr = new StringBuilder();
|
StringBuilder vocStr = new StringBuilder();
|
||||||
for (Segment segment : resp.getSegments()) {
|
for (Segment segment : resp.getSegments()) {
|
||||||
if (Objects.equals(RoleEnum.AGENT.getCode(),segment.getResult().getAnalysisInfo().getRole())) {
|
if (Objects.equals(RoleEnum.AGENT.getCode(),segment.getResult().getAnalysisInfo().getRole())) {
|
||||||
@@ -328,7 +328,7 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
|||||||
}
|
}
|
||||||
for (MqMessageRecord curMQMessageRecord : mqMessageRecords){
|
for (MqMessageRecord curMQMessageRecord : mqMessageRecords){
|
||||||
log.info("processMessageByTask 辨别数据为分析请求");
|
log.info("processMessageByTask 辨别数据为分析请求");
|
||||||
RabbitMqFormData oldItem = JSONObject.parseObject(curMQMessageRecord.getMessageContent(), RabbitMqFormData.class);
|
MqFormData oldItem = JSONObject.parseObject(curMQMessageRecord.getMessageContent(), MqFormData.class);
|
||||||
try {
|
try {
|
||||||
if (Objects.equals(SinceTypeEnum.SINCETYPE2.getCode(),curMQMessageRecord.getSinceType()) && Objects.equals(SubSinceTypeEnum.SINCETYPE51.getCode(),curMQMessageRecord.getSubSinceType())) {
|
if (Objects.equals(SinceTypeEnum.SINCETYPE2.getCode(),curMQMessageRecord.getSinceType()) && Objects.equals(SubSinceTypeEnum.SINCETYPE51.getCode(),curMQMessageRecord.getSubSinceType())) {
|
||||||
DiffDefeatResult diffDefeatResult;
|
DiffDefeatResult diffDefeatResult;
|
||||||
@@ -464,19 +464,19 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toMqSinceType53(DiffDefeatanAlysis diffDefeatanAlysis, DiffDefeatResult diffDefeatResult, RabbitMqFormData oldItem){
|
public void toMqSinceType53(DiffDefeatanAlysis diffDefeatanAlysis, DiffDefeatResult diffDefeatResult, MqFormData oldItem){
|
||||||
String userStatus = getUserStatus(diffDefeatResult.getUserStatus());
|
String userStatus = getUserStatus(diffDefeatResult.getUserStatus());
|
||||||
DiffDefeatanCallbak curDiffDefeatCallback = new DiffDefeatanCallbak();
|
DiffDefeatanCallbak curDiffDefeatCallback = new DiffDefeatanCallbak();
|
||||||
curDiffDefeatCallback.setBusinessId(diffDefeatanAlysis.getBusinessId());
|
curDiffDefeatCallback.setBusinessId(diffDefeatanAlysis.getBusinessId());
|
||||||
curDiffDefeatCallback.setResponseCode(HandleStatusEnum.ANALYSIS_NORMAL.getCode().toString());
|
curDiffDefeatCallback.setResponseCode(HandleStatusEnum.ANALYSIS_NORMAL.getCode().toString());
|
||||||
curDiffDefeatCallback.setLabel(userStatus);
|
curDiffDefeatCallback.setLabel(userStatus);
|
||||||
curDiffDefeatCallback.setDescribe(diffDefeatResult.getAppointmentResult());
|
curDiffDefeatCallback.setDescribe(diffDefeatResult.getAppointmentResult());
|
||||||
RabbitMqToData rabbitMqToData = new RabbitMqToData();
|
MqToData mqToData = new MqToData();
|
||||||
rabbitMqToData.setFormId(oldItem.getFormId());
|
mqToData.setFormId(oldItem.getFormId());
|
||||||
rabbitMqToData.setSinceType(SinceTypeEnum.SINCETYPE2.getCode());
|
mqToData.setSinceType(SinceTypeEnum.SINCETYPE2.getCode());
|
||||||
rabbitMqToData.setSubSinceType(SubSinceTypeEnum.SINCETYPE53.getCode());
|
mqToData.setSubSinceType(SubSinceTypeEnum.SINCETYPE53.getCode());
|
||||||
rabbitMqToData.setData(curDiffDefeatCallback);
|
mqToData.setData(curDiffDefeatCallback);
|
||||||
String callbackInput = JSONObject.toJSONString(rabbitMqToData);
|
String callbackInput = JSONObject.toJSONString(mqToData);
|
||||||
// rabbitTemplate.convertAndSend(Constant.rabbitToFormQueue, callbackInput);
|
// rabbitTemplate.convertAndSend(Constant.rabbitToFormQueue, callbackInput);
|
||||||
rocketMQTemplate.syncSend(topic, callbackInput);
|
rocketMQTemplate.syncSend(topic, callbackInput);
|
||||||
log.info("toMqSinceType53 发送回调MQ完成: {}", callbackInput);
|
log.info("toMqSinceType53 发送回调MQ完成: {}", callbackInput);
|
||||||
|
|||||||
Reference in New Issue
Block a user