处理金钱文字转换

main
xueqingkun 1 year ago
parent 798ed92f6c
commit 18ba680aae

@ -402,8 +402,12 @@ and jyzjhm = #{khrzjhm};
${(amount / 100000000)?string[\'0.00\']} 亿
</#if>
</#macro>
${dqzts}${dqzhs}${zzjyrq}${zwjyrq}${jyzbs}
${sjdss}<@formatMoney amount=jyzje/><@formatMoney amount=czje/><@formatMoney amount=jzje/>${czcs}${jzcs}', null, '2024-03-22 09:22:49.284770', null, '2024-03-22 09:22:49.284770', 1);
<#if jyzbs gt 0>
${dqzts}${dqzhs}${zzjyrq}${zwjyrq}${jyzbs}
${sjdss}<@formatMoney amount=jyzje/><@formatMoney amount=czje/><@formatMoney amount=jzje/>${czcs}${jzcs}
<#else>
</#if>', null, '2024-03-22 09:22:49.284770', null, '2024-03-22 09:22:49.284770', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442635079681', '是否为代理或会员?', 1, e'<script>
SELECT js
FROM yxyc_robot_data.yxyc_zhbq
@ -582,7 +586,7 @@ FROM (SELECT yhmc || \':\' || count(distinct jykh) || \'张\' as result_0
<#else>
</#if>', null, '2024-03-22 09:22:49.159600', null, '2024-03-22 09:22:49.159600', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442458918914', '本次账户涉案情况', 1, e'select sum(CAST(saje AS FLOAT)) as sum_asje
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442458918914', '本次账户涉案情况', 1, e'select SUM(CAST(saje AS DECIMAL(18, 2))) as sum_asje
from yxyc_robot_data.yxyc_djmd
where ajid = #{ajid};', '账户涉案金额是${(sum_asje!0)?c}元', null, '2024-03-22 09:22:49.172509', null, '2024-03-22 09:22:49.172509', 1);
INSERT INTO ir_knowledge (id, standard_question, state, sql_template, result_template, create_user_id, create_time, update_user_id, update_time, result_type) VALUES ('1770984442811240449', '代理获取佣金情况', 1, null, null, null, '2024-03-22 09:22:49.256425', null, '2024-03-22 09:22:49.256425', 1);

@ -8,6 +8,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
@ -17,6 +18,7 @@ import java.util.Objects;
@Api(tags = "音频处理")
@RequestMapping("voice")
@RequiredArgsConstructor
@RestController
public class VoiceController {
private final VoiceService voiceService;
@ -24,7 +26,8 @@ public class VoiceController {
@ApiOperation("语音转文字")
@PostMapping("voiceToText")
public String voiceToText(MultipartFile file, String sessionId) throws IOException {
return voiceService.voiceToText(file,sessionId);
return voiceService.voiceToText(file,sessionId);
}
@ApiOperation("文字转语音")

@ -2,6 +2,7 @@ package com.supervision.service.impl;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
@ -35,6 +36,8 @@ import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Slf4j
@ -128,6 +131,26 @@ public class RobotTalkServiceImpl implements RobotTalkService {
return robotTalkDTO;
}
/**
*
* @param input
* @return
*/
private String digitToChineseAmount(String input){
String regex = "(\\d+(\\.\\d+)?)(?=元|万元)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
while (matcher.find()) {
String group = matcher.group();
if (StrUtil.isNotEmpty(group) && NumberUtil.isNumber(group)){
input = input.replace(group,Convert.numberToChinese(NumberUtil.parseDouble(group),false));
}
}
return input;
}
private void setSuspectInfoAndNextFlag(RobotTalkReq robotTalkReq, RobotTalkDTO robotTalkDTO, MatchQuestionAnswerDTO matchQuestionAnswerDTO, IrRobotConfig config) {
String sessionId = robotTalkReq.getSessionId();
@ -200,7 +223,8 @@ public class RobotTalkServiceImpl implements RobotTalkService {
if (StrUtil.isEmpty(message)) {
return null;
}
TtsResultDTO resultDTO = voiceService.textToVoice(message);
String translate = digitToChineseAmount(message);
TtsResultDTO resultDTO = voiceService.textToVoice(translate);
IrVoice irVoice = new IrVoice();
irVoice.setVoiceBase64(resultDTO.getAudio());
if (NumberUtil.isNumber(resultDTO.getDuration())){

Loading…
Cancel
Save