浏览代码

reactor:宜宾工单受理新增文本检查;

zhangchong 8 月之前
父节点
当前提交
ba5f1b3244

+ 9 - 1
.env.development

@@ -23,4 +23,12 @@ VITE_VOICE_ASSISTANT_SOCKET_URL=ws://118.121.59.30:19005
 # 捷通华声通话记录请求地址
 VITE_JTHS_API_URL=http://118.121.58.161:19021
 # 捷通华声AppKey
-VITE_JTHS_APPKEY=MTAwMDAx
+VITE_JTHS_APPKEY=MTAwMDAx
+# 捷通华声错别字检测请求地址
+VITE_JTHS_ERROR_WORD_URL=http://118.122.73.80:19102
+# 捷通华声错别字检测请求签名
+VITE_JTHS_ERROR_WORD_SIGN=327c474854be9e3c259b34b9df025236b7321a55
+# 捷通华声错别字检测请求Nonce
+VITE_JTHS_ERROR_WORD_NONCE=726061.054747415
+# 捷通华声错别字检测请求KEY
+VITE_JTHS_ERROR_WORD_KEY=MTAwMDAw

+ 9 - 1
.env.production

@@ -23,4 +23,12 @@ VITE_VOICE_ASSISTANT_SOCKET_URL=ws://118.121.59.30:19005
 # 捷通华声通话记录请求地址
 VITE_JTHS_API_URL=http://118.121.58.161:19021
 # 捷通华声AppKey
-VITE_JTHS_APPKEY=MTAwMDAx
+VITE_JTHS_APPKEY=MTAwMDAx
+# 捷通华声错别字检测请求地址
+VITE_JTHS_ERROR_WORD_URL=http://118.122.73.80:19102
+# 捷通华声错别字检测请求签名
+VITE_JTHS_ERROR_WORD_SIGN=327c474854be9e3c259b34b9df025236b7321a55
+# 捷通华声错别字检测请求Nonce
+VITE_JTHS_ERROR_WORD_NONCE=726061.054747415
+# 捷通华声错别字检测请求KEY
+VITE_JTHS_ERROR_WORD_KEY=MTAwMDAw

+ 9 - 1
.env.st

@@ -23,4 +23,12 @@ VITE_VOICE_ASSISTANT_SOCKET_URL=ws://118.121.59.30:19005
 # 捷通华声通话记录请求地址
 VITE_JTHS_API_URL=http://118.121.58.161:19021
 # 捷通华声AppKey
-VITE_JTHS_APPKEY=MTAwMDAx
+VITE_JTHS_APPKEY=MTAwMDAx
+# 捷通华声错别字检测请求地址
+VITE_JTHS_ERROR_WORD_URL=http://118.122.73.80:19102
+# 捷通华声错别字检测请求签名
+VITE_JTHS_ERROR_WORD_SIGN=327c474854be9e3c259b34b9df025236b7321a55
+# 捷通华声错别字检测请求Nonce
+VITE_JTHS_ERROR_WORD_NONCE=726061.054747415
+# 捷通华声错别字检测请求KEY
+VITE_JTHS_ERROR_WORD_KEY=MTAwMDAw

+ 9 - 1
.env.yibin

@@ -23,4 +23,12 @@ VITE_VOICE_ASSISTANT_SOCKET_URL=ws://218.6.151.146:50108
 # 捷通华声通话记录请求地址
 VITE_JTHS_API_URL=http://218.6.151.146:50110
 # 捷通华声AppKey
-VITE_JTHS_APPKEY=MTAwMDAx
+VITE_JTHS_APPKEY=MTAwMDAx
+# 捷通华声错别字检测请求地址
+VITE_JTHS_ERROR_WORD_URL=http://118.122.73.80:19102
+# 捷通华声错别字检测请求签名
+VITE_JTHS_ERROR_WORD_SIGN=327c474854be9e3c259b34b9df025236b7321a55
+# 捷通华声错别字检测请求Nonce
+VITE_JTHS_ERROR_WORD_NONCE=726061.054747415
+# 捷通华声错别字检测请求KEY
+VITE_JTHS_ERROR_WORD_KEY=MTAwMDAw

+ 26 - 2
src/api/todo/voiceAssistant.ts

@@ -4,7 +4,7 @@
  */
 import request from '@/utils/request';
 /**
- * @description 链接坐席辅助
+ * @description 链接捷通华声坐席辅助
  * @param {string} telNo
  */
 export const voiceAssistant = (telNo: string) => {
@@ -20,7 +20,7 @@ export const voiceAssistant = (telNo: string) => {
 	);
 };
 /**
- * @description 获取识别内容
+ * @description 获取捷通华声识别内容
  * @param {string} callId
  */
 export const voiceAssistantContent = (callId: string) => {
@@ -54,4 +54,28 @@ export const jthsRecord = (data: object) => {
 			error_message_show: false,
 		}
 	);
+};
+/**
+ * @description 捷通华声错别字检测
+ * @param {object} data
+ */
+export const jthsErrorWord = (data: object) => {
+	return request(
+		{
+			url: `/nlp/service/analyse/atc`,
+			method: 'post',
+			data,
+			baseURL: import.meta.env.VITE_JTHS_ERROR_WORD_URL,
+			headers: {
+				Signature: import.meta.env.VITE_JTHS_ERROR_WORD_SIGN,
+				Timestamp: 1689148449820,
+				'Org-Key':import.meta.env.VITE_JTHS_ERROR_WORD_KEY,
+				Nonce: import.meta.env.VITE_JTHS_ERROR_WORD_NONCE,
+				'content-type':'application/json;charset=UTF-8'
+			},
+		},
+		{
+			error_message_show: false,
+		}
+	);
 };

+ 93 - 27
src/components/CommonAdvice/index.vue

@@ -18,6 +18,7 @@
 				<el-button type="primary" @click="onAddAdvice" :disabled="props.disabled">添加到常用意见</el-button>
 			</span>
 		</div>
+		<pre v-if="highlightedText" v-html="highlightedText" class="highlighted-text"></pre>
 		<el-drawer v-model="state.showDrawer" :size="props.drawerWidth" :show-close="false" :modal="props.modal">
 			<template #header="{ close }">
 				<div class="comments-header">
@@ -109,17 +110,15 @@
 				</div>
 			</template>
 		</el-drawer>
-		<div v-if="wrongText" class="wrong-text">
-			<span class="wrong-label">错别字:</span><span class="color-danger wrong-content">{{ wrongText }}</span>
-		</div>
 	</div>
 </template>
 
 <script setup lang="ts" name="commonAdvice">
-import { reactive, ref, computed } from 'vue';
+import { reactive, ref, computed, watch } from 'vue';
 import { ElMessage, ElMessageBox, FormInstance } from 'element-plus';
 import { commonList, addCommon, deleteCommon } from '@/api/auxiliary/advice';
 import { commonEnum } from '@/utils/constants';
+import { jthsErrorWord } from '@/api/todo/voiceAssistant';
 const emit = defineEmits(['chooseAdvice', 'update:modelValue']);
 const props = defineProps({
 	modal: {
@@ -191,7 +190,6 @@ const state = reactive<any>({
 	loading: false, // 是否显示loading
 	commonType: '', // 类型
 });
-
 // 打开常用意见管理
 const showAdvice = () => {
 	openDialog();
@@ -321,9 +319,51 @@ const chooseAdvice = (item: any) => {
 const closeDialog = () => {
 	state.showDrawer = false;
 };
+// 字节位置转换为字符位置的函数
+const byteToCharIndex=(text:string, byteIndex:number)=> {
+	let charIndex = 0;
+	let byteCount = 0;
+
+	while (byteCount < byteIndex && charIndex < text.length) {
+		const char = text[charIndex];
+		byteCount += new Blob([char]).size;
+		if (byteCount <= byteIndex) {
+			charIndex++;
+		}
+	}
+
+	return charIndex;
+}
+// 计算属性,生成高亮文本
+const highlightedFn= (text:string, errors:any[]) => {
+	let highlighted = text;
+	const errorPositions = errors.map(error => {
+		const startCharPos = byteToCharIndex(value.value, error.begPos);
+		const endCharPos = byteToCharIndex(value.value, error.begPos + error.length);
+		return { startCharPos, endCharPos };
+	});
+
+	// 逆序处理,以避免更改已经处理的部分
+	errorPositions.reverse().forEach(({ startCharPos, endCharPos }) => {
+		const before = highlighted.slice(0, startCharPos);
+		const errorText = highlighted.slice(startCharPos, endCharPos);
+		const after = highlighted.slice(endCharPos);
+		highlighted = `${before}<b class="color-danger">${errorText}</b>${after}`;
+	});
+
+	return highlighted;
+}
 // 文件检查
-const wrongText = ref('');
+const highlightedText = ref('');
+const errorWordsArray = ref([]);
 const textCheck = () => {
+	if(!value.value) {
+		ElMessage.warning({
+			message:props.placeholder,
+			grouping:true
+		});
+		return;
+	}
 	ElMessageBox.confirm(`确认要检查文本内容?`, '提示', {
 		confirmButtonText: '确认',
 		cancelButtonText: '取消',
@@ -335,22 +375,41 @@ const textCheck = () => {
 			if (action === 'confirm') {
 				instance.confirmButtonLoading = true;
 				instance.confirmButtonText = '检查中,请稍后';
-				setTimeout(() => {
-					done();
-					instance.confirmButtonLoading = false;
-				}, 700);
+				const request = {
+					text: value.value,
+					resource: {
+						property: '',
+					},
+				};
+				jthsErrorWord(request)
+					.then((res: any) => {
+						ElMessage.success('检查完成');
+						highlightedText.value = '';
+						errorWordsArray.value = res?.result ?? [];
+						highlightedText.value = highlightedFn(value.value, errorWordsArray.value);
+						done();
+						instance.confirmButtonLoading = false;
+					})
+					.catch((err) => {
+						console.log(err);
+						done();
+						ElMessage.error(err.response.data.msg);
+					});
 			} else {
 				done();
 			}
 		},
 	})
 		.then(async () => {
-			ElMessage.success('检查成功');
+			/*ElMessage.success('检查成功');
 			wrongText.value = '';
-			closeDialog();
+			closeDialog();*/
 		})
 		.catch(() => {});
 };
+watch(()=>value.value,(val)=>{
+	if(!val) highlightedText.value = '';
+})
 // 暴露变量
 defineExpose({
 	openDialog,
@@ -368,12 +427,33 @@ defineExpose({
 	}
 	.buttons {
 		position: absolute;
-		right: 80px;
+		right: 100px;
 		bottom: 10px;
 	}
 	:deep(.el-textarea__inner) {
 		padding-bottom: 40px;
 	}
+	.highlighted-text {
+		margin-top:10px;
+		background-color: var(--el-input-bg-color, var(--el-fill-color-blank));
+		background-image: none;
+		border: none;
+		border-radius: var(--el-input-border-radius, var(--el-border-radius-base));
+		box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)) inset;
+		box-sizing: border-box;
+		color: var(--el-input-text-color, var(--el-text-color-regular));
+		display: block;
+		font-family: inherit;
+		font-size: inherit;
+		line-height: 1.5;
+		padding: 5px 11px;
+		position: relative;
+		resize: vertical;
+		transition: var(--el-transition-box-shadow);
+		width: 100%;
+		text-wrap: wrap;
+		word-wrap: break-word;
+	}
 }
 .comments-container {
 	.comments-box {
@@ -400,20 +480,6 @@ defineExpose({
 		}
 	}
 }
-.wrong-text{
-	line-height: 24px;
-	display: flex;
-	margin-top: 5px;
-	.wrong-label{
-		flex: 0 0 auto;
-	}
-	.wrong-content{
-		align-items: center;
-		flex:1;
-		min-width: 0;
-		word-break: break-all;
-	}
-}
 .comments-header {
 	.active {
 		color: var(--el-color-primary);

+ 4 - 7
src/layout/navBars/breadcrumb/ybTel.vue

@@ -858,7 +858,7 @@ const websocket_connect = () => {
 		onMessage: onMessage, // 接收消息
 		onError: onError, // 错误
 		autoReconnect: {
-			delay: 2000,
+			delay: 5000,
 		}, // 自动重连
 		heartbeat: {
 			message: JSON.stringify({ cmd: 'ping' }),
@@ -905,7 +905,8 @@ const onConnected = () => {
 };
 // 呼叫中心链接关闭
 const onDisconnected = (event: any) => {
-	globalState.callCenterWs = null;
+	globalState.callCenterWs = null; //
+	globalState.callCenterIsSignIn = false; // 签出状态
 	resetState();
 	const currentTel = Local.get('currentTel');
 	const name: string = `天润分机号:${currentTel}的websocket断开链接`;
@@ -917,7 +918,6 @@ const onDisconnected = (event: any) => {
 		executeUrl: callCenterSocketUrl,
 	};
 	submitLogFn(request);
-	globalState.callCenterIsSignIn = false; // 签出状态
 	console.log(`${getNowDateTime()}:呼叫中心断开链接`, event);
 };
 // 来电弹屏方式 1-接通弹屏;2-振铃弹屏
@@ -1462,11 +1462,8 @@ const offDutyFn = () => {
 			dutyOff()
 				.then(() => {
 					sendMsg('logout');
-					olaRef.value.logout(currentTel.value.telNo); //签出
-					useTimeoutFn(() => {
-						olaRef.value.close();
-					}, 500);
 					resetState();
+					olaRef.value.logout(currentTel.value.telNo); //签出
 					state.loading = false;
 				})
 				.catch(() => {})

+ 1 - 0
src/views/todo/seats/accept/ybAccept.vue

@@ -474,6 +474,7 @@
 											:loading="state.formLoading"
 											:commonEnum="commonEnum.Seat"
 											modal
+											showTextCheck
 										/>
 									</el-form-item>
 								</el-col>