Commit 47df54bc authored by alex yao's avatar alex yao

style: agent应用数据上报

parent 7581c5e3
......@@ -266,7 +266,10 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
agentSystem, kdIds.toArray(new Integer[0]), infoEntity.getCommunicationTurn(), topP,
temperature, dto.getMessages(), tools, dto.getFileUrls(), true, httpServletResponse);
//数据采集
dataReport(dto, userBaseEntity, agentId, pointDeductionNum);
if (StringUtils.isBlank(dto.getChannel())) {
dto.setChannel(DataAnalyzeChannelEnum.preview.getChannel());
}
dataAnalyzeReportService.dataReport(dto.getAgentId(), DataAnalyzeChannelEnum.valueOf(dto.getChannel()), userBaseEntity.getUserId(), pointDeductionNum);
} catch (Exception e) {
httpServletResponse.setContentType("text/event-stream");
PrintWriter writer = httpServletResponse.getWriter();
......@@ -479,14 +482,4 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
Assert.notNull(agentId);
LongMemory.clean(agentId);
}
private void dataReport(AgentApplicationPreviewDto dto, UserBaseEntity userBaseEntity, String agentId, Long
pointDeductionNum) {
if (StringUtils.isBlank(dto.getChannel())) {
dto.setChannel(DataAnalyzeChannelEnum.preview.getChannel());
}
BigDecimal points = new BigDecimal(pointDeductionNum).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
dataAnalyzeReportService.dataReportByDialogue(userBaseEntity.getUserId(), DataAnalyzeTypeEnum.AGENT, agentId, DataAnalyzeChannelEnum.valueOf(dto.getChannel()));
dataAnalyzeReportService.dataReportByPoint(userBaseEntity.getUserId(), points, DataAnalyzeTypeEnum.AGENT, agentId, DataAnalyzeChannelEnum.valueOf(dto.getChannel()));
}
}
\ No newline at end of file
......@@ -34,4 +34,13 @@ public interface DataAnalyzeReportService {
*/
void dataReportByDialogue(Long memberId, DataAnalyzeTypeEnum type, String relationId, DataAnalyzeChannelEnum channel);
/**
* 数据上报-聚合上报【对话次数+积分使用情况】
*
* @param agentId 应用ID
* @param channel 渠道
* @param userId 用户ID
* @param pointDeductionNum 积分扣除数量-单位分
*/
boolean dataReport(String agentId, DataAnalyzeChannelEnum channel, Long userId, Long pointDeductionNum);
}
......@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* @author alex.yao
......@@ -59,4 +60,12 @@ public class DataAnalyzeReportServiceImpl implements DataAnalyzeReportService {
logger.error("对话次数统计情况-数据统计异常", e);
}
}
@Override
public boolean dataReport(String agentId, DataAnalyzeChannelEnum channel, Long userId, Long pointDeductionNum) {
BigDecimal points = new BigDecimal(pointDeductionNum).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
this.dataReportByDialogue(userId, DataAnalyzeTypeEnum.AGENT, agentId, channel);
this.dataReportByPoint(userId, points, DataAnalyzeTypeEnum.AGENT, agentId, channel);
return true;
}
}
......@@ -154,7 +154,7 @@ public class AgentApplicationApiServiceImpl implements AgentApplicationApiServic
memberEquityService.rollbackPoint(reduceSn);
}
//数据采集
dataReport(agentId, DataAnalyzeChannelEnum.api.getChannel(), profileEntity.getMemberId(), pointDeductionNum);
dataAnalyzeReportService.dataReport(agentId, DataAnalyzeChannelEnum.api, profileEntity.getMemberId(), pointDeductionNum);
}
private void saveRecord(String conversationId, String query, String agentId, BizAgentApplicationApiProfileEntity profileEntity, Long inputTimestamp, BizAgentApplicationPublishEntity infoEntity, String output) throws Exception {
......@@ -305,11 +305,4 @@ public class AgentApplicationApiServiceImpl implements AgentApplicationApiServic
messages.add(message);
return messages;
}
private void dataReport(String agentId, String channel, Long userId, Long pointDeductionNum) {
BigDecimal points = new BigDecimal(pointDeductionNum).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
dataAnalyzeReportService.dataReportByDialogue(userId, DataAnalyzeTypeEnum.AGENT, agentId, DataAnalyzeChannelEnum.valueOf(channel));
dataAnalyzeReportService.dataReportByPoint(userId, points, DataAnalyzeTypeEnum.AGENT, agentId, DataAnalyzeChannelEnum.valueOf(channel));
}
}
......@@ -185,7 +185,10 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
outputRecord.setContent(output);
bizAgentApplicationDialoguesRecordService.save(outputRecord);
//数据采集
dataReport(agentId, channel, userBaseEntity, pointDeductionNum);
if (StringUtils.isBlank(channel)) {
channel = DataAnalyzeChannelEnum.link_share.getChannel();
}
dataAnalyzeReportService.dataReport(agentId,DataAnalyzeChannelEnum.valueOf(channel),userBaseEntity.getUserId(),pointDeductionNum);
} catch (Exception e) {
memberEquityService.rollbackPoint(reduceSn);
throw new BusinessException(e.getMessage());
......@@ -438,15 +441,4 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
logger.info("--------- Build Messages dialogsId:{},agentId:{},messages:{}--------------", dialogsId, agentId, messages);
return messages;
}
private void dataReport(String agentId, String channel, UserBaseEntity userBaseEntity, Long pointDeductionNum) {
if (StringUtils.isBlank(channel)) {
channel = DataAnalyzeChannelEnum.link_share.getChannel();
}
BigDecimal points = new BigDecimal(pointDeductionNum).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
dataAnalyzeReportService.dataReportByDialogue(userBaseEntity.getUserId(), DataAnalyzeTypeEnum.AGENT, agentId, DataAnalyzeChannelEnum.valueOf(channel));
dataAnalyzeReportService.dataReportByPoint(userBaseEntity.getUserId(), points, DataAnalyzeTypeEnum.AGENT, agentId, DataAnalyzeChannelEnum.valueOf(channel));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment