diff --git a/app/api/evaluation_points/reviews.ts b/app/api/evaluation_points/reviews.ts index 4ce2043..afac551 100644 --- a/app/api/evaluation_points/reviews.ts +++ b/app/api/evaluation_points/reviews.ts @@ -73,6 +73,7 @@ interface ReviewPointResult { suggestion: string; result?: boolean; score: number; + evaluatedPointResultsLog?: Array>; } // 定义统计数据类型 @@ -241,6 +242,11 @@ export async function getReviewPoints(fileId: string) { const point = pointsMap.get(result.evaluation_point_id) || {} as EvaluationPoint; const group = groupsMap.get(point.evaluation_point_groups_id || 0) || {} as EvaluationPointGroup; const editAuditStatus = editAuditStatusMap.get(result.evaluation_point_id) || {id: '', status: 0}; + + // 评查结果内容改成由evaluated_point_results_log中获取 + // const evaluatedPointResultsLog = result.evaluated_point_results_log; + // console.log('evaluatedPointResultsLog-------', evaluatedPointResultsLog); + // 从 evaluated_results 中提取数据 let message = ''; @@ -328,7 +334,121 @@ export async function getReviewPoints(fileId: string) { // } // 评查配置: point.evaluation_config - evaluationConfig: point.evaluation_config || {} + evaluationConfig: point.evaluation_config || {}, + + // evaluatedPointResultsLog: evaluatedPointResultsLog || {} + evaluatedPointResultsLog: [ + { + "id": "1", + "type": "consistency", + "config": { + "logic": "and", + "pairs": [ + { + "sourceField": {"现场笔录-被检查人名称":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-营业执照-名称":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"现场笔录-法定代表人(负责人)":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-营业执照-法定代表人":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"现场笔录-烟草专卖许可证号码":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-烟草专卖零售许可证-许可证号":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"证据复制(提取)单-烟草专卖零售许可证-企业名称":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-营业执照-名称":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"证据复制(提取)单-烟草专卖零售许可证-负责人姓名":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-营业执照-法定代表人":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"立案报告表-当事人-单位-名称":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-营业执照-名称":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"立案报告表-当事人-单位-法定代表人(负责人)":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-营业执照-法定代表人":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"立案报告表-当事人-单位-地址":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-营业执照-住所":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + } + ], + "selectedFields": [] + } + }, + { + "id": "2", + "type": "consistency", + "config": { + "logic": "and", + "pairs": [ + { + "sourceField": {"现场笔录-被检查人姓名":{page: 1,value: '张三'}}, + "targetField": {"立案报告表-当事人-个人(个体工商户)-姓名":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"立案报告表-当事人-个人(个体工商户)-姓名":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-居民身份证-姓名":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"现场笔录-性别":{page: 1,value: '张三'}}, + "targetField": {"立案报告表-当事人-个人(个体工商户)-性别":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"立案报告表-当事人-个人(个体工商户)-性别":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-居民身份证-性别":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"现场笔录-证件类型及号码":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-居民身份证-公民身份号码":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"现场笔录-地址":{page: 1,value: '张三'}}, + "targetField": {"立案报告表-当事人-个人(个体工商户)-住址":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + }, + { + "sourceField": {"立案报告表-当事人-个人(个体工商户)-住址":{page: 1,value: '张三'}}, + "targetField": {"证据复制(提取)单-居民身份证-住址":{page: 1,value: '张三'}}, + "compareMethod": "exact", + "result": true + } + ], + "selectedFields": [] + } + } + ] }; }); diff --git a/app/components/reviews/ReviewPointsList.tsx b/app/components/reviews/ReviewPointsList.tsx index 2787342..d6a8660 100644 --- a/app/components/reviews/ReviewPointsList.tsx +++ b/app/components/reviews/ReviewPointsList.tsx @@ -65,6 +65,7 @@ export interface ReviewPoint { }; }>; }; + evaluatedPointResultsLog?: Array>; } // 统计数据类型 @@ -200,11 +201,11 @@ export function ReviewPointsList({ // 过滤"错误"状态 matchesStatus = point.result === false && point.status === 'error'; } - console.log('筛选point', point); + // console.log('筛选point', point); return matchesSearch && matchesStatus; }); - console.log('筛选filteredReviewPoints', filteredReviewPoints); + // console.log('筛选filteredReviewPoints', filteredReviewPoints); /** * 处理一键替换操作 @@ -501,7 +502,7 @@ export function ReviewPointsList({ // 将content按照规则分组 contentEntries.forEach(entry => { - const [key, value] = entry; + const [key] = entry; // 检查是否属于某个consistency规则 let assigned = false; @@ -751,6 +752,292 @@ export function ReviewPointsList({ }; + /** + * 渲染评查点一致性的规则的样式 + * @param reviewPoint 评查点 + * @returns 评查点一致性的规则的样式 + */ + const renderConsistencyRule = (singleReviewPoint: Record) => { + if (!singleReviewPoint || Object.keys(singleReviewPoint).length === 0) { + return null; + } + + // 检查是否存在配置和pairs数组 + const config = singleReviewPoint.config as { logic?: string; pairs?: Array<{ sourceField: Record; targetField: Record; result: boolean }>; selectedFields?: string[] } | undefined; + if (!config || !config.pairs || !Array.isArray(config.pairs) || config.pairs.length === 0) { + return null; + } + + // 处理配对数据 + const pairs = config.pairs; + + // 查找链条关系 + const findChains = () => { + type ChainItem = { + field: string; + data: { + key: string; + page: number; + value: string + }; + result: boolean + }; + + const chains: Array> = []; + const visited = new Set(); + + // 构建字段映射关系 + const fieldMap = new Map>(); + + pairs.forEach(pair => { + // 提取源字段和目标字段的名称 + const sourceFieldKey = Object.keys(pair.sourceField)[0]; + const targetFieldKey = Object.keys(pair.targetField)[0]; + + if (!fieldMap.has(sourceFieldKey)) { + fieldMap.set(sourceFieldKey, []); + } + + fieldMap.get(sourceFieldKey)?.push({ + targetField: targetFieldKey, + data: { + source: { key: sourceFieldKey, ...pair.sourceField[sourceFieldKey] }, + target: { key: targetFieldKey, ...pair.targetField[targetFieldKey] } + }, + result: pair.result + }); + }); + console.log('fieldMap-------', fieldMap); + + // 查找链条的起始点(只作为源不作为目标的字段) + const startPoints = new Set(); + for (const [key] of fieldMap.entries()) { + let isTarget = false; + for (const pair of pairs) { + const targetFieldKey = Object.keys(pair.targetField)[0]; + if (targetFieldKey === key) { + isTarget = true; + break; + } + } + if (!isTarget) { + startPoints.add(key); + } + } + + // 从每个起始点开始构建链条 + for (const startPoint of startPoints) { + if (visited.has(startPoint)) continue; + + const chain: Array = []; + let currentField = startPoint; + + // 向后构建链条 + while (fieldMap.has(currentField)) { + const targets = fieldMap.get(currentField); + if (!targets || targets.length === 0) break; + + // 找到第一个未访问的目标 + let nextTarget = null; + for (const target of targets) { + if (!visited.has(target.targetField)) { + nextTarget = target; + break; + } + } + + if (!nextTarget) break; + + // 添加源字段到链条 + if (chain.length === 0) { + chain.push({ + field: currentField, + data: nextTarget.data.source, + result: nextTarget.result + }); + } + + // 添加目标字段到链条 + chain.push({ + field: nextTarget.targetField, + data: nextTarget.data.target, + result: nextTarget.result + }); + + // 标记为已访问 + visited.add(currentField); + visited.add(nextTarget.targetField); + + // 移动到下一个字段 + currentField = nextTarget.targetField; + } + + if (chain.length > 0) { + chains.push(chain); + } + } + + // 处理没有找到的孤立对 + for (const pair of pairs) { + const sourceFieldKey = Object.keys(pair.sourceField)[0]; + const targetFieldKey = Object.keys(pair.targetField)[0]; + + if (!visited.has(sourceFieldKey) || !visited.has(targetFieldKey)) { + const isolatedPair: Array = [ + { + field: sourceFieldKey, + data: { key: sourceFieldKey, ...pair.sourceField[sourceFieldKey] }, + result: pair.result + }, + { + field: targetFieldKey, + data: { key: targetFieldKey, ...pair.targetField[targetFieldKey] }, + result: pair.result + } + ]; + + chains.push(isolatedPair); + visited.add(sourceFieldKey); + visited.add(targetFieldKey); + } + } + + return chains; + }; + + const chains = findChains(); + + return ( +
+
+ {chains.map((chain, chainIndex) => { + const isLongChain = chain.length > 2; + const result = chain[0].result; + + // 确定样式类名 + const itemClassName = result + ? "comparison-item match" + : "comparison-item mismatch"; + + // 如果是长链(3个或以上元素) + if (isLongChain) { + return ( +
+
+
+
+ {chain.map((item, idx) => ( + + {item.field} + {idx < chain.length - 1 && ( + + )} + + ))} +
+
+ {chain.map((item, idx) => ( + + ))} +
+
+
+
+ {result ? ( + + ) : ( + + )} +
+
+ ); + } + + // 如果是标准的成对比较(2个元素) + return ( +
+
+ {chain[0].field.split('-').pop()} +
+
+ + +
+
+ {result ? ( + + ) : ( + + )} + {result ? '一致' : '不一致'} +
+
+ ); + })} +
+
+ ); + }; + /** * 渲染评查点内容与建议 * @param reviewPoint 评查点 @@ -857,7 +1144,7 @@ export function ReviewPointsList({ )} {/* 评查点内容显示区域 */} {reviewPoint.content && Object.entries(reviewPoint.content).length > 0 && ( -
+
{/* 修改评查结果的结构之后,显示新的结构 */} {renderContent(reviewPoint, true)}
@@ -1142,6 +1429,9 @@ export function ReviewPointsList({ {/* 人工审核注释 */} {renderHumanReviewNote(reviewPoint)} + {/* 评查点一致性的规则的样式渲染 */} + {renderConsistencyRule(reviewPoint.evaluatedPointResultsLog?.[0] || {})} + {/* 评查点内容和操作 */} {renderReviewPointContent(reviewPoint)}
diff --git a/app/routes/reviews.tsx b/app/routes/reviews.tsx index 1b8f518..44ad887 100644 --- a/app/routes/reviews.tsx +++ b/app/routes/reviews.tsx @@ -593,7 +593,7 @@ export default function ReviewDetails() { {activeTab === 'preview' && (
{/* 左侧:文件预览 */} -
+
{/* 右侧:评查结果 */} -
+
+ + + + + 评查结果 - 卡片对比版 + + + + + +
+ +
+

评查结果

+

烟草专卖行政执法案件评查报告

+
+ + +
+
+ 55 + 总计 +
+
+ 49 + 通过 +
+
+ 6 + 警告 +
+
+ 0 + 错误 +
+
+ + +
+ + + + +
+ +
+
+
+ + 当事人基本情况记载完整、准确 +
+
+ + 通过 +
+
+
+ +
+ + +
+ +
+
+
立案报告表-姓名
+
江小妹
+
+
+
身份证-姓名
+
江小妹
+
+
+
+ + 一致 +
+
+ +
+ +
+
+
立案报告表-性别
+
+
+
+
身份证-性别
+
+
+
+
+ + 一致 +
+
+ +
+ +
+
+
立案报告表-民族
+
汉人
+
+
+
身份证-民族
+
汉族
+
+
+
+ + 不一致 +
+
+ +
+ +
+
+
立案报告表-身份证号
+
445322198602014328
+
+
+
身份证-身份证号
+
445322198602014328
+
+
+
+ + 一致 +
+
+ +
+ +
+
+
立案报告表-住址 身份证-住址
+
广东省云浮市郁南县宋桂镇宋桂村委尾一村6号
+
+
+
广东省云浮市郁南县宋桂镇宋桂村委尾一村6号
+
+
+
+ + 一致 +
+
+
+ + +
+
+ + 单位信息对比 +
+ +
+ +
+
+
立案报告表-单位名称 营业执照-单位名称
+
郁南县连滩镇领航烟酒商行
+
+
+
郁南县连滩镇领航烟酒商行
+
+
+
+ + 一致 +
+
+ +
+ +
+
+
立案报告表-地址 营业执照-住所
+
郁南县连滩镇中华路106号一楼
+
+
+
郁南县连滩镇中华路106号一楼
+
+
+
+ + 一致 +
+
+
+ + +
+
+ + 必要信息完整性检查 +
+ +
+
法定代表人
+
江小妹
+
+ + 已填写 +
+
+ +
+
年龄
+
38
+
+ + 已填写 +
+
+ +
+
联系电话
+
13430472175
+
+ + 已填写 +
+
+
+ + +
+
+ + 检查总结 +
+
+ 检查结果:当事人基本情况记录完整,与身份证信息基本一致。
+ 发现问题:民族字段存在细微差异("汉人" vs "汉族"),建议统一表述。
+ 建议:将立案报告表中的"汉人"修改为"汉族"以保持一致性。 +
+
+
+
+
+ + +
+ + +
+
+
+ + + + \ No newline at end of file