首页
关于
友链
推荐
肥啾解析
百度一下
肥啾GPT
Search
1
宝塔面板登录 phpMyAdmin 提示服务器和客户端上指示的HTTPS之间不匹配
323 阅读
2
Customer complaints evolve with in-car tech
226 阅读
3
JavaScript解析
187 阅读
4
所谓关系
151 阅读
5
人类果然都是好争斗的
128 阅读
默认分类
网游架设
手机游戏
python
PHP
Mysql
VBA
C++
JAVASCRIPT
javascript基础
Oracle
生产管理
计划控制
ERP系统开发
APS排产
MES研究
考勤系统
CPA
财管
实务
经济法
战略
审计
税法
藏书架
古典名著
世界名著
编程秘籍
攻防渗透
经管书籍
大佬传经
风雅读物
考试相关
心情格言
拾玉良言
外文报刊
外刊随选
Facebook
Twitter
China Daily
软考
登录
Search
标签搜索
期刊读物
古文
何瑜明
累计撰写
182
篇文章
累计收到
154
条评论
首页
栏目
默认分类
网游架设
手机游戏
python
PHP
Mysql
VBA
C++
JAVASCRIPT
javascript基础
Oracle
生产管理
计划控制
ERP系统开发
APS排产
MES研究
考勤系统
CPA
财管
实务
经济法
战略
审计
税法
藏书架
古典名著
世界名著
编程秘籍
攻防渗透
经管书籍
大佬传经
风雅读物
考试相关
心情格言
拾玉良言
外文报刊
外刊随选
Facebook
Twitter
China Daily
软考
页面
关于
友链
推荐
肥啾解析
百度一下
肥啾GPT
搜索到
182
篇与
的结果
2025-07-15
测试
<?php header('Content-Type: application/json'); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: POST'); // 配置常量 - 同步前端最新配置 define('CONFIG_VALUES', [ '动力类型' => ['FD', 'FB', 'FLB', 'FTB', 'FG', 'FCG', 'FRB', 'FR4D'], '吨位' => [10, 15, 18, 19, 20, 25, 30, 35, 40, 45, '50F', '50TF', 50, 70, 80, 100, '1A', '1B', '1C'], '发动机型号' => ['4JG2', '4TNE98', '6BG1', 'C240', 'K21', 'K21双燃料', 'K25', 'K25双燃料', 'PSI2.4', 'S4S', 'S6S', 'S6S-T', 'L4C25-T', 'V2403-M', 'V2403-CR', 'V2403', 'WG2503-LPG', '全柴485', 'V29-V037', '3E22YG51', '新柴485', '4D27G31', '4D29X41-024', '4D32G31', 'A495BPG', 'A498BPG', 'A498BT1', '新柴C490(国2)', '新柴C490(欧3A)', 'YC4A115-T300'], '国产发动机' => ['A495BPG', 'A498BPG', 'A498BT1', '新柴C490(国2)', '全柴485', '4D29X41-024', '3E22YG51'], '有加速发动机' => ['4TNE98', '6BG1', 'S6S-T', 'S6S', '4JG2', 'C240', 'K25', 'K21', 'C490BPG', 'A498BPG', '4D27G31', 'A495BPG', 'A498BT1', 'C490BPG-51', 'NC485', '4B4-45V32', 'V2403-M', 'S4S'], '电控品牌' => ['Inmotion', '凡几', '嘉晨', '松正', '柯蒂斯', '麦格米特', '维德G2', '维德G3', 'S2', 'M1', '维德25G2', '维德35G3', '维德50G1'], '国产电控' => ['凡几', '嘉晨'], '电压等级' => ['48V铅酸', '51.2V锂电', '72V铅酸', '76.8V锂电', '80V铅酸', '205Ah', '230Ah', '173Ah', '280Ah', '410Ah'], '挡板' => ['铅酸', '锂电'], '年款' => ['16', '17'], '阀片' => ['2SV', '3SV', '4SV', '5SV'], '座椅' => ['丰田样式悬浮座椅', 'TCM样式座椅', 'TCM样式悬浮座椅', '格拉默座椅', '丰田样式座椅(STD)', '丰田样式座椅+座椅开关', '格拉默座椅+拇指开关', 'TCM样式座椅+座椅开关', '薄型座椅', 'TCM样式悬浮座椅+座椅开关', '丰田样式悬浮座椅+座椅开关', '丰田样式悬浮座椅+座椅开关+扶手', '合力样式悬浮座椅'], '默认座椅' => ['丰田样式悬浮座椅'], '其它' => ['闪光警示灯', '蓝光灯', '工作灯', '大灯防护罩', '后腿架', '半圆后视镜', '加长把手', '加长前腿把手', '线槽盖板', '前雨挡', '上雨挡', '后雨挡', '一字红光灯', '货叉架摄像头', '铸造后桥', '加大水箱', '加高水箱', '油水分离', '高排消声器', '灭火消声器', '左高排气', '右高排气', 'OPS', 'LPG', '高挂预滤器', '实心胎', '环保实心胎', '隔音', '手刹开关', '手刹报警', '油水分离', '十叶风扇', '座椅开关', '索达多路阀', '格拉默座椅', '刷卡仪表', '分体式', '前双胎', 'BATI', 'FLB方向盘', '电瓶挡板', 'EGLM', '进箱', '半交流', '暖风', '驾驶室', '充气(STD)', '软连接', '后腿把手', '2SV', '3SV', '4SV', '5SV', '下进气', '高排气', '实心', '加大电瓶'], '其它2' => ['闪光警示灯', '蓝光灯', '工作灯', '大灯防护罩', '后腿架', '半圆后视镜', '加长把手', '加长前腿把手', '线槽盖板', '前雨挡', '上雨挡', '后雨挡', '一字红光灯', '货叉架摄像头', '铸造后桥', '加大水箱', '加高水箱', '油水分离', '高排消声器', '灭火消声器', '左高排气', '右高排气', 'OPS', 'LPG', '高挂预滤器', '实心胎', '环保实心胎', '隔音', '手刹开关', '手刹报警', '油水分离', '十叶风扇', '座椅开关', '索达多路阀', '格拉默座椅', '刷卡仪表', '分体式', '前双胎', 'BATI', 'FLB方向盘', '电瓶挡板', 'EGLM', '进箱', '半交流', '暖风', '驾驶室', '空调', '充气(STD)', '软连接', '后腿把手', '2SV', '3SV', '4SV', '5SV', '下进气', '高排气', '扶手', '电液比例', '实心', '加大电瓶'], '默认轮胎' => ['国产品牌', '充气(STD)'] ]); define('DEFAULT_CONFIGS', [ '充气(STD)', '国产品牌', '丰田样式悬浮座椅' ]); // 发动机型号代称映射表(同步前端) define('ENGINE_ALIASES', [ 'NC485' => '新柴485(国2)', 'C490BPG' => '新柴490(国2)', 'A495BPG' => '新柴495(国2)', 'A498BPG' => '新柴498(国2)', '4N23G31' => '新柴485(国3)', '4D27G31' => '新柴490(国3)', '4D30G31' => '新柴495(国3)', '4D32G31' => '新柴498(国3)', '4D35ZG' => '新柴4D35(国3)', 'C490BPG-51' => '新柴490(欧3A)', 'A498BT1' => '新柴498(欧3A)', '4D29X41-024' => '新柴490(国4)', '3E22YG51' => '新柴(欧5)', '4B4-45V32' => '全柴485(国3)', 'GQ4Y' => 'GQ4Y', '6102' => '6102(国3)', 'YC4A115-T300' => '玉柴(国3)', 'C240' => 'C240(ⅢA/国3)', '4JG2' => '4JG2(欧3A)', '6BG1' => '6BG1', 'K21' => 'K21', 'K25' => 'K25', 'K25EPA' => 'K25EPA', 'S4S' => 'S4S(国3)', '4EG' => '4EG', 'S6S' => 'S6S(ⅢA)', 'S6S-T' => 'S6S-T(国三)', '4TNE98' => '4TNE98(国3)', '4TNV94L' => '4TNV94L(国4)', 'V2403' => 'V2403-CR', 'WG2503-L' => 'WG2503-L', 'QSF3.8' => 'QSF3.8(国3)', 'L4CRTV' => '韩国LS(欧5)', 'PSI认证版' => 'PSI2.4', 'WG2503-GL' => 'WG2503-GL', 'V2403-M' => 'V2403-M', 'V29-50V42' => '全柴490(国4)', '6102(国3)' => '6102', '全柴485(国3)' => '4B4-45V32', '新柴490(国3)' => '4D27G31', '新柴485(国3)' => '4N23G31', '新柴495(国3)' => '4D30G31', '新柴498(国3)' => '4D32G31', '新柴4D35(国3)' => '4D35ZG', '新柴490(国4)' => '4D29X41-024', '4TNV94L(国4)' => '4TNV94L', '全柴490(国4)' => 'V29-50V42', '新柴495(国2)' => 'A495BPG', '新柴498(国2)' => 'A498BPG', '新柴490(国2)' => 'C490BPG', '新柴485(国2)' => 'NC485', '新柴490(欧3A)' => 'C490BPG-51', '新柴498(欧3A)' => 'A498BT1', '新柴(欧5)' => '3E22YG51', 'C240(ⅢA/国3)' => 'C240', '4JG2(欧3A)' => '4JG2', 'GQ4Y' => 'GQ4Y', '玉柴(国3)' => 'YC4A115-T300', '6BG1' => '6BG1', 'K21' => 'K21', 'K25' => 'K25', 'K25EPA' => 'K25EPA', 'S4S(国3)' => 'S4S', '4EG' => '4EG', 'S6S(ⅢA)' => 'S6S', 'S6S-T(国三)' => 'S6S-T', '4TNE98(国3)' => '4TNE98', 'V2403-CR' => 'V2403', 'WG2503-L' => 'WG2503-L', 'QSF3.8(国3)' => 'QSF3.8', '韩国LS(欧5)' => 'L4CRTV', 'PSI2.4' => 'PSI认证版', 'WG2503-GL' => 'WG2503-GL', 'V2403-M' => 'V2403-M', '35G3' => '维德G3', '/G3' => '维德G3' ]); // 获取输入数据 $input = json_decode(file_get_contents('php://input'), true); $productDesc = isset($input['productDesc']) ? trim($input['productDesc']) : ''; $spec = isset($input['spec']) ? trim($input['spec']) : ''; $debugSystem = isset($input['debugSystem']) ? trim($input['debugSystem']) : ''; // 新增调试系统参数 if ($productDesc === '' || $spec === '') { exitJson(['error' => '缺少品号描述或规格']); } // 读取配置数据 $configData = json_decode(file_get_contents('data.json'), true); if (!$configData) { exitJson(['error' => '配置数据未加载']); } // 预处理配置数据:替换发动机代称为标准名称(同步前端逻辑) $configData = array_map(function($item) { $newItem = $item; // 处理规格字段 foreach (ENGINE_ALIASES as $alias => $standard) { if (strpos($newItem['规格'], $alias) !== false) { $newItem['规格'] = str_replace($alias, $standard, $newItem['规格']); } } // 处理名称字段 foreach (ENGINE_ALIASES as $alias => $standard) { if (strpos($newItem['名称'], $alias) !== false) { $newItem['名称'] = str_replace($alias, $standard, $newItem['名称']); } } return $newItem; }, $configData); // 提取动力类型 $powerType = extractPowerType($productDesc, $spec); if (!$powerType) { exitJson(['error' => '无法识别动力类型']); } // 读取系统配置文件 $sysFile = 'systems_' . $powerType . '.json'; if (!file_exists($sysFile)) { exitJson(['error' => '缺少 ' . $powerType . ' 的系统配置文件']); } $systemConfig = json_decode(file_get_contents($sysFile), true); // 提取关键配置值(同步前端逻辑,新增发动机代称处理) $extractedValues = extractConfigValues($productDesc, $spec, $powerType); // 执行匹配(新增调试系统参数) $results = matchConfigurations($configData, $productDesc, $spec, $systemConfig, $extractedValues, $debugSystem); exitJson([ 'powerType' => $powerType, 'extractedValues' => $extractedValues, 'matched' => $results['matched'], 'debugInfo' => $results['debugInfo'] // 返回调试信息 ]); // ========== 函数区 ========== function exitJson($data) { echo json_encode($data, JSON_UNESCAPED_UNICODE); exit; } // 提取动力类型(逻辑不变) function extractPowerType($productDesc, $spec) { $text = $productDesc . ' ' . $spec; foreach (CONFIG_VALUES['动力类型'] as $type) { if (stripos($text, $type) !== false) { return $type; } } return null; } // 提取配置值(同步前端,新增发动机代称处理) function extractConfigValues($productDesc, $spec, $powerType) { $values = [ '动力类型' => $powerType, '吨位' => null, '发动机型号' => null, '电控品牌' => null, '电压等级' => null, '挡板' => null, '年款' => null, '阀片' => null, '座椅' => null ]; $allText = $productDesc . ' ' . $spec; $prodesc = $productDesc; // 提取吨位 - 支持50F、50TF格式 if (preg_match('/(\d+[FT]?F|\d+)/', $prodesc, $tonMatch)) { $matchedTon = $tonMatch[0]; // 处理数字吨位 if (is_numeric($matchedTon)) { $matchedTon = intval($matchedTon); } if (in_array($matchedTon, CONFIG_VALUES['吨位'])) { $values['吨位'] = $matchedTon; } } // 根据动力类型提取不同字段(新增发动机代称映射) if (in_array($powerType, ['FD', 'FR4D', 'FCG', 'FG'])) { // 柴油车型:先匹配标准型号,再匹配代称 $foundEngine = null; // 1. 匹配标准发动机型号 foreach (CONFIG_VALUES['发动机型号'] as $engine) { if (strpos($allText, $engine) !== false) { $foundEngine = $engine; break; } } // 2. 未找到标准型号,匹配代称 if (!$foundEngine) { foreach (ENGINE_ALIASES as $alias => $standard) { if (strpos($allText, $alias) !== false) { $foundEngine = $standard; break; } } } $values['发动机型号'] = $foundEngine; } else if (in_array($powerType, ['FB', 'FLB', 'FRB', 'FTB'])) { // 电动车型 foreach (CONFIG_VALUES['电控品牌'] as $ec) { if (strpos($allText, $ec) !== false) { $values['电控品牌'] = $ec; break; } } foreach (CONFIG_VALUES['电压等级'] as $level) { if (strpos($allText, $level) !== false) { $values['电压等级'] = $level; break; } } foreach (CONFIG_VALUES['挡板'] as $board) { if (strpos($allText, $board) !== false) { $values['挡板'] = $board; break; } } } // 提取其他通用字段 foreach (CONFIG_VALUES['年款'] as $year) { if (strpos($allText, $year) !== false) { $values['年款'] = $year; break; } } foreach (CONFIG_VALUES['阀片'] as $valve) { if (strpos($allText, $valve) !== false) { $values['阀片'] = $valve; break; } } foreach (CONFIG_VALUES['座椅'] as $seat) { if (strpos($allText, $seat) !== false) { $values['座椅'] = $seat; break; } } return $values; } // 匹配配置(新增调试信息返回,同步前端特殊规则) function matchConfigurations($data, $productDesc, $spec, $systemConfig, $extractedValues, $debugSystem) { $allText = $productDesc . ' ' . $spec; $allTextLower = mb_strtolower($allText, 'UTF-8'); $results = []; $debugInfo = []; // 存储调试信息 $defaultConfigsLower = array_map('mb_strtolower', DEFAULT_CONFIGS); $otherKeywords = array_map('mb_strtolower', CONFIG_VALUES['其它']); $otherKeywords2 = array_map('mb_strtolower', CONFIG_VALUES['其它2']); // 确定国产标志(同步前端逻辑) $isDomestic = false; $powerType = $extractedValues['动力类型']; if (in_array($powerType, ['FD', 'FR4D', 'FCG', 'FG'])) { $engineType = $extractedValues['发动机型号'] ?? null; $isDomestic = $engineType && in_array($engineType, CONFIG_VALUES['国产发动机']); } else if (in_array($powerType, ['FB', 'FLB', 'FRB', 'FTB'])) { $electricControl = $extractedValues['电控品牌'] ?? null; $isDomestic = $electricControl && in_array($electricControl, CONFIG_VALUES['国产电控']); } foreach ($systemConfig['order'] as $system) { // 筛选当前系统的配置项 $items = array_filter($data, function($item) use ($system) { return strpos($item['分类'], $system) !== false; }); $items = array_values($items); $keywordRule = $systemConfig['keywords'][$system] ?? ['required' => [], 'optional' => []]; $bestItem = null; $bestScore = PHP_INT_MIN; $candidateDebug = []; // 单个系统的候选调试信息 foreach ($items as $item) { // 计算匹配分数(同步前端逻辑,新增特殊规则) $scoreData = calculateMatchScore($item, $system, $keywordRule, $extractedValues, $allText, $isDomestic); $score = $scoreData['score']; $details = $scoreData['details']; // 存储候选调试信息 $candidateDebug[] = [ 'item' => [ '编号' => $item['编号'], '名称' => $item['名称'], '规格' => $item['规格'] ], 'score' => $score, 'details' => $details ]; if ($score === -9999) { continue; } // 检查非默认配置项是否在输入中存在(同步前端) $itemSpecLower = mb_strtolower($item['规格'], 'UTF-8'); $nonDefaultKeywords = array_diff($otherKeywords, $defaultConfigsLower); $hasUnmatchedNonDefault = false; foreach ($nonDefaultKeywords as $keyword) { if (strpos($itemSpecLower, $keyword) !== false && strpos($allTextLower, $keyword) === false) { $hasUnmatchedNonDefault = true; break; } } if ($hasUnmatchedNonDefault) { $score -= 50; $details['optional'][] = '存在非默认配置项未在输入中匹配,扣50分'; } // 更新最佳匹配 if ($score > $bestScore) { $bestScore = $score; $bestItem = $item; $bestDetails = $details; } } // 检查特殊规则(同步前端所有规则) $specialRule = checkSpecialRules($system, $bestItem, $extractedValues, $allText); if ($bestItem && !$specialRule['pass']) { $bestItem = null; $bestScore = 0; $bestDetails['specialNote'] = $specialRule['note']; } else if ($bestItem) { $bestDetails['specialNote'] = $specialRule['note']; } // 存储当前系统结果 $results[] = $bestItem ? [ 'system' => $system, '编号' => $bestItem['编号'], '规格' => $bestItem['规格'], '名称' => $bestItem['名称'], 'score' => $bestScore, 'details' => $bestDetails ] : [ 'system' => $system, '编号' => null, '规格' => null, '名称' => null, 'score' => 0, 'details' => ['specialNote' => $specialRule['note'] ?? '未找到匹配配置'] ]; // 存储调试信息(仅当指定调试系统时) if ($debugSystem === $system) { $debugInfo = [ 'system' => $system, 'extractedValues' => $extractedValues, 'candidates' => $candidateDebug, 'bestCandidate' => $bestItem ? [ 'item' => $bestItem, 'score' => $bestScore, 'details' => $bestDetails ] : null ]; } } return [ 'matched' => $results, 'debugInfo' => $debugInfo ]; } // 计算匹配分数(同步前端逻辑,新增特殊规则加分) function calculateMatchScore($item, $system, $keywordRule, $extractedValues, $allText, $isDomestic) { $score = 0; $allTextLower = mb_strtolower($allText, 'UTF-8'); $itemSpecLower = mb_strtolower($item['规格'], 'UTF-8'); $itemNameLower = mb_strtolower($item['名称'], 'UTF-8'); $details = [ 'required' => [], 'optional' => [], 'tonnageMatch' => false, 'score' => 0 ]; $powerType = $extractedValues['动力类型']; $deus = explode(',', $item['分类']); // 拆分分类字段 // 1. 检查必须关键字 foreach ($keywordRule['required'] as $key) { $value = $extractedValues[$key] ?? null; if (!$value) { $details['required'][] = "必须关键字【$key】未提取到值,匹配失败"; return ['score' => -9999, 'details' => $details]; } // 吨位特殊处理(支持范围和单值) if ($key === '吨位') { $tonResult = matchTonnage($item['规格'], $extractedValues); if (!$tonResult['matched']) { $details['required'][] = "吨位【$value】不匹配配置范围,匹配失败"; return ['score' => -9999, 'details' => $details]; } $score += 30; $details['required'][] = "吨位【$value】匹配配置范围【{$tonResult['range']}】,加30分"; $details['tonnageMatch'] = true; continue; } // 发动机型号特殊处理(支持代称) if ($key === '发动机型号') { $allEngineNames = [$value]; // 获取所有相关代称 foreach (ENGINE_ALIASES as $alias => $standard) { if ($standard === $value) $allEngineNames[] = $alias; if ($alias === $value) $allEngineNames[] = $standard; } $isMatched = false; foreach ($allEngineNames as $name) { if (strpos($item['规格'], $name) !== false && strpos($allText, $name) !== false) { $isMatched = true; break; } } if (!$isMatched) { $details['required'][] = "发动机型号【$value】及其代称不匹配,匹配失败"; return ['score' => -9999, 'details' => $details]; } $score += 30; $details['required'][] = "发动机型号【$value】匹配,加30分"; continue; } // 其他必须关键字 if (strpos($item['规格'], $value) === false) { $details['required'][] = "必须关键字【$key:$value】不匹配配置,匹配失败"; return ['score' => -9999, 'details' => $details]; } $score += 30; $details['required'][] = "必须关键字【$key:$value】匹配,加30分"; } // 2. 检查可选关键字 foreach ($keywordRule['optional'] as $key) { $value = $extractedValues[$key] ?? null; if ($value && strpos($item['规格'], $value) !== false) { $score += 20; $details['optional'][] = "可选关键字【$key:$value】匹配,加20分"; } // 年款未区分时加分 if ($key === '年款' && !$value && !strpos($item['规格'], '16') && !strpos($item['规格'], '17')) { $score += 20; $details['optional'][] = "未检测到年款区分,加20分"; } } // 3. 特殊系统规则(同步前端所有特殊规则) $systemLower = mb_strtolower($system, 'UTF-8'); // 多路阀规则 if (in_array('多路阀', $deus) || strpos($systemLower, '多路阀') !== false) { if ($isDomestic) { if (!strpos($allTextLower, '进口品牌多路阀') && !strpos($allTextLower, '国产品牌多路阀') && !strpos($allTextLower, '3e22yg51') && strpos($itemNameLower, '国产品牌') !== false) { $score += 20; $details['optional'][] = '国产发动机且非欧五,多路阀国产品牌匹配,加20分'; } else if (strpos($allTextLower, '进口品牌多路阀') !== false && strpos($itemNameLower, '进口品牌') !== false) { $score += 20; $details['optional'][] = '国产发动机但要求进口多路阀,匹配加20分'; } else if (!strpos($allTextLower, '进口品牌多路阀') && !strpos($allTextLower, '国产品牌多路阀') && strpos($allTextLower, '3e22yg51') !== false && strpos($itemNameLower, '进口品牌') !== false) { $score += 20; $details['optional'][] = '欧五发动机默认进口多路阀,匹配加20分'; } } else { if (!strpos($allTextLower, '国产品牌多路阀') && strpos($itemNameLower, '进口品牌') !== false) { $score += 20; $details['optional'][] = '进口发动机多路阀进口品牌匹配,加20分'; } else if (strpos($allTextLower, '国产品牌多路阀') !== false && strpos($itemNameLower, '国产品牌') !== false) { $score += 20; $details['optional'][] = '进口发动机要求国产多路阀,匹配加20分'; } } } // 液压泵规则 if (in_array('液压泵', $deus) || strpos($systemLower, '液压泵') !== false) { if ($isDomestic) { if (!strpos($allTextLower, '进口品牌液压泵') && strpos($itemNameLower, '国产品牌') !== false) { $score += 20; $details['optional'][] = '国产发动机液压泵国产品牌匹配,加20分'; } else if (strpos($allTextLower, '进口品牌液压泵') !== false && strpos($itemNameLower, '进口品牌') !== false) { $score += 20; $details['optional'][] = '国产发动机要求进口液压泵,匹配加20分'; } } else { if (!strpos($allTextLower, '国产品牌液压泵') && strpos($itemNameLower, '进口品牌') !== false) { $score += 20; $details['optional'][] = '进口发动机液压泵进口品牌匹配,加20分'; } else if (strpos($allTextLower, '国产品牌液压泵') !== false && strpos($itemNameLower, '国产品牌') !== false) { $score += 20; $details['optional'][] = '进口发动机要求国产液压泵,匹配加20分'; } } } // 转向器规则 if (in_array('转向', $deus) || strpos($systemLower, '转向') !== false) { if ($isDomestic) { if (!strpos($allTextLower, '进口品牌转向器') && strpos($itemNameLower, '国产品牌') !== false) { $score += 20; $details['optional'][] = '国产发动机转向器国产品牌匹配,加20分'; } else if (strpos($allTextLower, '进口品牌转向器') !== false && strpos($itemNameLower, '进口品牌') !== false) { $score += 20; $details['optional'][] = '国产发动机要求进口转向器,匹配加20分'; } } else { if (!strpos($allTextLower, '国产品牌转向器') && strpos($itemNameLower, '进口品牌') !== false) { $score += 20; $details['optional'][] = '进口发动机转向器进口品牌匹配,加20分'; } else if (strpos($allTextLower, '国产品牌转向器') !== false && strpos($itemNameLower, '国产品牌') !== false) { $score += 20; $details['optional'][] = '进口发动机要求国产转向器,匹配加20分'; } } } // 轮胎规则 if (in_array('轮胎', $deus) || strpos($systemLower, '胎') !== false) { if (!strpos($allTextLower, '实心胎') && !strpos($allTextLower, '充气胎') && strpos($itemSpecLower, '国产品牌') !== false && strpos($itemSpecLower, 'std') !== false) { if (strpos($allTextLower, '前双胎') !== false && strpos($itemSpecLower, '前双胎') !== false) { $score += 30; $details['optional'][] = '前双胎特征匹配,加30分'; } $score += 100; $details['optional'][] = '默认国产品牌充气胎,加100分'; } else if (strpos($allTextLower, '实心胎(国产品牌)') !== false && strpos($itemSpecLower, '国产品牌') !== false && strpos($itemSpecLower, '实心') !== false) { $score += 30; $details['optional'][] = '国产品牌+实心胎匹配,加30分'; } else if (strpos($allTextLower, '实心胎(进口品牌)') !== false && strpos($itemSpecLower, '进口品牌') !== false && strpos($itemSpecLower, '实心') !== false) { $score += 30; $details['optional'][] = '进口品牌+实心胎匹配,加30分'; } else if (strpos($allTextLower, '充气胎(进口品牌)') !== false && strpos($itemSpecLower, '进口品牌') !== false && strpos($itemSpecLower, '充气') !== false) { $score += 30; $details['optional'][] = '进口品牌+充气胎匹配,加30分'; } if (!strpos($allTextLower, '前双胎') && strpos($itemSpecLower, '前双胎') !== false) { $score -= 30; $details['optional'][] = '配置有前双胎但输入无,扣30分'; } } // 覆盖件规则 if (in_array('覆盖件', $deus) || strpos($systemLower, '覆盖件') !== false) { if (strpos($allTextLower, '隔音') !== false && strpos($itemSpecLower, '隔音') !== false) { $score += 20; $details['optional'][] = '隔音要求匹配,加20分'; } else if (!strpos($allTextLower, '隔音') && !strpos($itemSpecLower, '隔音')) { $score += 20; $details['optional'][] = '无隔音要求匹配,加20分'; } } // 座椅规则 if (in_array('座椅', $deus) || strpos($systemLower, '座椅') !== false) { if (!strpos($allTextLower, '座椅') && !strpos($allTextLower, 'fr4d') && !strpos($allTextLower, 'frb') && !strpos($allTextLower, '软连接') && strpos($itemSpecLower, '丰田样式座椅std') !== false) { $score += 20; $details['optional'][] = '默认丰田样式座椅(STD)匹配,加20分'; } } // 驻车制动规则 if (in_array('驻车制动', $deus) || strpos($systemLower, '驻车制动') !== false) { if (strpos($allTextLower, '凡几') !== false && strpos($itemSpecLower, '手刹开关') !== false) { $score += 60; $details['optional'][] = '凡几电控默认手刹开关,加60分'; } if (strpos($allTextLower, '仪表显示') !== false && strpos($itemSpecLower, '手刹开关') !== false) { $score += 20; $details['optional'][] = '仪表显示P要求手刹开关,加20分'; } if ((strpos($allTextLower, '3e22yg51') !== false || strpos($allTextLower, '维德') !== false || strpos($allTextLower, '2403') !== false || strpos($allTextLower, 'wg2503') !== false || strpos($allTextLower, 'psi') !== false || strpos($allTextLower, 'l4crtv') !== false) && strpos($itemSpecLower, '手刹开关') !== false) { $score += 50; $details['optional'][] = '17款欧五/维德等默认手刹开关,加50分'; } } // 欧五发动机下进气规则 if ((in_array('覆盖件', $deus) || strpos($systemLower, '覆盖件') !== false) && (strpos($allTextLower, '3e22yg51') !== false || strpos($allTextLower, 'wg2503-l') !== false || strpos($allTextLower, 'v2403') !== false || strpos($allTextLower, 'psi') !== false || strpos($allTextLower, 'l4crtv') !== false)) { if (strpos($itemSpecLower, '下进气') !== false) { $score += 50; $details['optional'][] = '欧五/久保田等默认下进气,加50分'; } } // 刷卡仪表规则 if (strpos($allTextLower, '刷卡仪表') !== false && strpos($itemSpecLower, 'tsg81') !== false) { $score += 20; $details['optional'][] = '刷卡仪表要求TSG81,加20分'; } // 凡几/嘉晨侧装规则 if ((strpos($allTextLower, '凡几') !== false && strpos($allTextLower, '51.2v锂电') !== false) || (strpos($allTextLower, '嘉晨') !== false && strpos($allTextLower, '76.8v锂电') !== false)) { if (strpos($itemSpecLower, '侧装') !== false) { $score += 20; $details['optional'][] = '侧装配置匹配,加20分'; } if ((in_array('平衡重', $deus) || strpos($systemLower, '平衡重') !== false) && strpos($itemSpecLower, '实心') !== false) { $score += 50; $details['optional'][] = '侧装平衡重含实心配置,加50分'; } } // 50F/50TF规则 if (strpos($allTextLower, '50f') !== false && strpos($itemSpecLower, '50f') !== false) { $score += 20; $details['optional'][] = '50F配置匹配,加20分'; } if (strpos($allTextLower, '50tf') !== false && strpos($itemSpecLower, '50tf') !== false) { $score += 20; $details['optional'][] = '50TF配置匹配,加20分'; } // 发动机型号区分规则(S6S/S6S-T、V2403系列) if (strpos($allTextLower, 's6s') !== false && !strpos($allTextLower, 's6s-t') && strpos($itemSpecLower, 's6s-t') !== false) { $score = 0; $details['optional'][] = 'S6S发动机排除S6S-T配置,得分归零'; } if (strpos($allTextLower, 'v2403') !== false && !strpos($allTextLower, 'v2403-m') && !strpos($allTextLower, 'v2403-cr') && (strpos($itemSpecLower, 'v2403-m') !== false || strpos($itemSpecLower, 'v2403-cr') !== false)) { $score = 0; $details['optional'][] = 'V2403发动机排除V2403-M/V2403-CR配置,得分归零'; } // 手刹未拉报警规则 if (strpos($allTextLower, '3e22yg51') !== false && strpos($allTextLower, '手刹未拉') !== false && strpos($itemSpecLower, '断电手刹报警') !== false) { $score += 50; $details['optional'][] = '欧五发动机手刹未拉提醒,断电手刹报警匹配,加50分'; } if (strpos($allTextLower, 'inmotion') !== false && strpos($allTextLower, '手刹未拉') !== false && strpos($itemSpecLower, '断电手刹报警') !== false) { $score += 50; $details['optional'][] = 'Inmotion电控手刹未拉提醒,断电手刹报警匹配,加50分'; } // 分体式护顶架规则 if (strpos($allTextLower, '分体式') !== false && strpos($itemNameLower, '分体式') !== false) { $score += 30; $details['optional'][] = '分体式护顶架匹配,加30分'; } // 驾驶室规则 if (strpos($allTextLower, '驾驶室') !== false && !strpos($allTextLower, '空调驾驶室') && !strpos($allTextLower, '暖风') && strpos($itemNameLower, '驾驶室') !== false && !strpos($itemNameLower, '空调') && !strpos($itemNameLower, '暖风')) { $score += 20; $details['optional'][] = '普通驾驶室匹配,加20分'; } if (!strpos($allTextLower, '驾驶室') && !strpos($allTextLower, '空调驾驶室') && !strpos($allTextLower, '暖风') && !strpos($itemNameLower, '驾驶室') && !strpos($itemNameLower, '空调') && !strpos($itemNameLower, '暖风')) { $score += 20; $details['optional'][] = '无驾驶室要求匹配,加20分'; } // 其他配置项匹配(CONFIG_VALUES['其它2']) foreach (CONFIG_VALUES['其它2'] as $keyword) { $keywordLower = mb_strtolower($keyword, 'UTF-8'); if (strpos($itemSpecLower, $keywordLower) !== false) { if (strpos($allTextLower, $keywordLower) !== false) { $score += 1; $details['optional'][] = "配置【$keyword】匹配,加1分"; } else { $score -= 30; $details['optional'][] = "配置【$keyword】存在但输入无,扣30分"; } } } $details['score'] = round($score, 1); return ['score' => $score, 'details' => $details]; } // 吨位匹配(支持范围、单值、50F/50TF格式) function matchTonnage($itemSpec, $extractedValues) { $result = ['matched' => false, 'range' => null]; $powerType = $extractedValues['动力类型'] ?? ''; $userTonnage = $extractedValues['吨位'] ?? null; if (!$powerType || $userTonnage === null) { return $result; } // 处理50F、50TF等格式 if (is_string($userTonnage) && preg_match('/(\d+)/', $userTonnage, $numMatch)) { $userTonnageNum = intval($numMatch[1]); } else { $userTonnageNum = intval($userTonnage); } // 查找动力类型位置 $powerPos = mb_strpos($itemSpec, $powerType); if ($powerPos === false) { return $result; } // 提取吨位部分 $tonnagePart = mb_substr($itemSpec, $powerPos + mb_strlen($powerType)); // 1. 匹配范围格式(如:10~30、20-50) if (preg_match('/(\d+)\s*[~-]\s*(\d+)/', $tonnagePart, $rangeMatches)) { $min = intval($rangeMatches[1]); $max = intval($rangeMatches[2]); if ($userTonnageNum >= $min && $userTonnageNum <= $max) { $result['matched'] = true; $result['range'] = "$min-$max"; } return $result; } // 2. 匹配单值格式(如:FD30T、FB25) if (preg_match('/\b(\d+)\b/', $tonnagePart, $singleMatch)) { $specValue = intval($singleMatch[1]); if ($userTonnageNum === $specValue) { $result['matched'] = true; $result['range'] = (string)$specValue; } return $result; } // 3. 匹配字符串格式(如:50F、50TF) if (preg_match('/(\d+[FT]?F)/', $tonnagePart, $strMatch)) { if ($strMatch[1] === $userTonnage) { $result['matched'] = true; $result['range'] = $strMatch[1]; } return $result; } // 4. 直接匹配 if (strpos($itemSpec, (string)$userTonnage) !== false) { $result['matched'] = true; $result['range'] = (string)$userTonnage; } return $result; } // 检查特殊规则(同步前端所有25条规则) function checkSpecialRules($system, $configItem, $extractedValues, $allText) { $note = ''; $pass = true; $allTextLower = mb_strtolower($allText, 'UTF-8'); $powerType = $extractedValues['动力类型'] ?? ''; $engineType = $extractedValues['发动机型号'] ?? ''; $year = $extractedValues['年款'] ?? ''; // 规则1: 3E22YG51发动机电气系统必须含OPS if ($system == '电气' && strpos($allTextLower, '3e22yg51') !== false) { if ($configItem && strpos($configItem['规格'], 'OPS') === false) { $note .= '规则1:3E22YG51发动机电气系统必须含OPS配置,当前配置无'; $pass = false; } else if ($configItem) { $note .= '符合规则1:3E22YG51发动机电气系统含OPS配置'; } } // 规则2: 16款FD铸造桥涉及转向桥、车架 if (in_array($system, ['转向桥', '车架']) && strpos($allTextLower, '铸造') !== false && $year === '16' && $powerType === 'FD') { if ($configItem && strpos($configItem['规格'], '铸造') === false) { $note .= '规则2:16款FD铸造桥需转向桥/车架含铸造配置,当前配置无'; $pass = false; } else if ($configItem) { $note .= '符合规则2:16款FD铸造桥转向桥/车架含铸造配置'; } } // 规则3: 17款FD铸造桥涉及转向桥、车架、液压管路 if (in_array($system, ['转向桥', '车架', '液压管路']) && strpos($allTextLower, '铸造') !== false && $year === '17' && $powerType === 'FD') { if ($configItem && strpos($configItem['规格'], '铸造') === false) { $note .= '规则3:17款FD铸造桥需转向桥/车架/液压管路含铸造配置,当前配置无'; $pass = false; } else if ($configItem) { $note .= '符合规则3:17款FD铸造桥转向桥/车架/液压管路含铸造配置'; } } // 规则4: 仅指定发动机有加速系统 if ($system == '加速') { $supportedEngines = CONFIG_VALUES['有加速发动机']; if ($engineType && !in_array($engineType, $supportedEngines)) { $note .= '规则4:当前发动机型号无加速系统,无需匹配'; $pass = false; } else if ($configItem) { $note .= '符合规则4:当前发动机型号支持加速系统'; } } // 规则5: 传动冷却只区分吨位,全系通用 if ($system == '传动冷却' && in_array($powerType, ['FD', 'FG', 'FCG'])) { $note .= '符合规则5:传动冷却只区分吨位,全系通用'; $pass = true; } // 规则6-1: 16款4D29X41-024 OPS涉及车架、多路阀、多路阀操纵 if (in_array($system, ['车架', '多路阀系统', '多路阀操纵']) && strpos($allTextLower, 'ops') !== false && $year === '16' && $engineType === '4D29X41-024') { if (($configItem && strpos($configItem['规格'], 'OPS') === false) || !$configItem) { $note .= '规则6-1:16款4D29X41-024 OPS需车架/多路阀含OPS配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则6-1:16款4D29X41-024 OPS车架/多路阀含OPS配置'; } } // 规则6-2: 16款4JG2 OPS涉及车架、多路阀、多路阀操纵、液压管路 if (in_array($system, ['车架', '多路阀系统', '多路阀操纵', '液压管路']) && strpos($allTextLower, 'ops') !== false && $year === '16' && $engineType === '4JG2') { if (($configItem && strpos($configItem['规格'], 'OPS') === false) || !$configItem) { $note .= '规则6-2:16款4JG2 OPS需车架/多路阀/液压管路含OPS配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则6-2:16款4JG2 OPS车架/多路阀/液压管路含OPS配置'; } } // 规则6-3: 16款K21/K25 OPS涉及车架、多路阀、液压管路 if (in_array($system, ['车架', '多路阀系统', '液压管路']) && strpos($allTextLower, 'ops') !== false && $year === '16' && in_array($engineType, ['K21', 'K25'])) { if (($configItem && strpos($configItem['规格'], 'OPS') === false) || !$configItem) { $note .= '规则6-3:16款K21/K25 OPS需车架/多路阀/液压管路含OPS配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则6-3:16款K21/K25 OPS车架/多路阀/液压管路含OPS配置'; } } // 规则6-4: 17款FD/FG非欧五OPS涉及多路阀、多路阀操纵 if (in_array($system, ['多路阀系统', '多路阀操纵']) && strpos($allTextLower, 'ops') !== false && $year === '17' && in_array($powerType, ['FD', 'FG']) && $engineType !== '3E22YG51') { if (($configItem && strpos($configItem['规格'], 'OPS') === false) || !$configItem) { $note .= '规则6-4:17款FD/FG非欧五OPS需多路阀含OPS配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则6-4:17款FD/FG非欧五OPS多路阀含OPS配置'; } } // 规则6-5: 17款欧五OPS涉及多路阀、多路阀操纵、电气 if (in_array($system, ['多路阀系统', '多路阀操纵', '电气']) && strpos($allTextLower, 'ops') !== false && $year === '17' && $powerType === 'FD' && $engineType === '3E22YG51') { if (($configItem && strpos($configItem['规格'], 'OPS') === false) || !$configItem) { $note .= '规则6-5:17款欧五OPS需多路阀/电气含OPS配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则6-5:17款欧五OPS多路阀/电气含OPS配置'; } } // 规则6-6: FB OPS涉及多路阀,带刷卡仪表还涉及电器 if (($system == '多路阀系统' && $powerType === 'FB' && strpos($allTextLower, 'ops') !== false) || ($system == '电器' && $powerType === 'FB' && strpos($allTextLower, 'ops') !== false && strpos($allTextLower, '刷卡仪表') !== false)) { if (($configItem && strpos($configItem['规格'], 'OPS') === false) || !$configItem) { $note .= '规则6-6:FB OPS需多路阀/电器含OPS配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则6-6:FB OPS多路阀/电器含OPS配置'; } } // 规则6-7: FLB OPS涉及多路阀 if ($system == '多路阀系统' && $powerType === 'FLB' && strpos($allTextLower, 'ops') !== false) { if (($configItem && strpos($configItem['规格'], 'OPS') === false) || !$configItem) { $note .= '规则6-7:FLB OPS需多路阀含OPS配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则6-7:FLB OPS多路阀含OPS配置'; } } // 规则:年款不匹配防御 if (in_array($year, ['16', '17']) && $configItem && (strpos($configItem['规格'], '16') !== false || strpos($configItem['规格'], '17') !== false) && strpos($configItem['规格'], $year) === false) { $note .= '防御规则:配置年款与提取年款不匹配,禁止输出'; $pass = false; } else if (in_array($year, ['16', '17']) && $configItem && strpos($configItem['规格'], $year) !== false) { $note .= '防御规则:配置年款与提取年款匹配'; } // 规则7: 高排气涉及覆盖件、排气、平衡重(C240左高,其他右高) if (in_array($system, ['覆盖件', '排气', '平衡重']) && strpos($allTextLower, '高排气') !== false) { $target = $engineType === 'C240' ? '左高排气' : '右高排气'; if (($configItem && strpos($configItem['规格'], $target) === false) || !$configItem) { $note .= "规则7:高排气需{$target}配置,当前无"; $pass = false; } else if ($configItem) { $note .= "符合规则7:高排气含{$target}配置"; } } // 规则8: 无座椅指定且非FR4D/FRB/软连接,默认丰田样式座椅(STD) if ($system == '座椅' && strpos($allTextLower, '座椅') === false && !in_array($powerType, ['FR4D', 'FRB']) && strpos($allTextLower, '软连接') === false) { $note .= '符合规则8:无座椅指定,默认丰田样式座椅(STD)'; $pass = true; } // 规则9: 加大水箱/十叶风扇/油水分离涉及动力冷却 if ($system == '动力冷却' && (strpos($allTextLower, '加大水箱') !== false || strpos($allTextLower, '十叶风扇') !== false || strpos($allTextLower, '油水分离') !== false)) { if (($configItem && (strpos($configItem['规格'], '加大水箱') === false && strpos($configItem['规格'], '十叶风扇') === false && strpos($configItem['规格'], '油水分离') === false)) || !$configItem) { $note .= '规则9:加大水箱/十叶风扇/油水分离需动力冷却配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则9:动力冷却含加大水箱/十叶风扇/油水分离配置'; } } // 规则10: FLB电控维德S2/G1有动力冷却,其他无 if ($system == '动力冷却' && $powerType === 'FLB') { if (strpos($allTextLower, '维德s2') !== false || strpos($allTextLower, '维德g1') !== false) { $note .= '符合规则10:FLB维德S2/G1有动力冷却'; $pass = true; } else { $note .= '规则10:FLB非维德S2/G1无动力冷却,无需匹配'; $pass = false; } } // 规则11: 消声器/中排气涉及排气系统 if ($system == '排气' && (strpos($allTextLower, '消声器') !== false || strpos($allTextLower, '中排气') !== false)) { if (($configItem && (strpos($configItem['规格'], '消声器') === false && strpos($configItem['规格'], '中排气') === false)) || !$configItem) { $note .= '规则11:消声器/中排气需排气系统配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则11:排气系统含消声器/中排气配置'; } } // 规则12: 驾驶室涉及护顶架、覆盖件 if (in_array($system, ['护顶架', '覆盖件']) && strpos($allTextLower, '驾驶室') !== false) { if (($configItem && strpos($configItem['规格'], '驾驶室') === false) || !$configItem) { $note .= '规则12:驾驶室需护顶架/覆盖件含驾驶室配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则12:护顶架/覆盖件含驾驶室配置'; } } // 规则13: 凡几电控驻车制动默认手刹开关 if ($system == '驻车制动' && strpos($allTextLower, '凡几') !== false) { if ($configItem && strpos($configItem['规格'], '手刹开关') === false) { $note .= '规则13:凡几电控驻车制动需手刹开关,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则13:凡几电控驻车制动含手刹开关'; } } // 规则14: 17款欧五/维德等驻车制动默认手刹开关 if ($system == '驻车制动' && (strpos($allTextLower, '3e22yg51') !== false || strpos($allTextLower, '维德') !== false || strpos($allTextLower, '2403') !== false || strpos($allTextLower, 'wg2503') !== false || strpos($allTextLower, 'psi') !== false || strpos($allTextLower, 'l4crtv') !== false)) { if ($configItem && strpos($configItem['规格'], '手刹开关') === false) { $note .= '规则14:17款欧五/维德等驻车制动需手刹开关,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则14:17款欧五/维德等驻车制动含手刹开关'; } } // 规则15: 欧五/久保田等覆盖件默认下进气 if ($system == '覆盖件' && (strpos($allTextLower, '3e22yg51') !== false || strpos($allTextLower, 'wg2503-l') !== false || strpos($allTextLower, 'v2403') !== false || strpos($allTextLower, 'psi') !== false || strpos($allTextLower, 'l4crtv') !== false)) { if ($configItem && strpos($configItem['规格'], '下进气') === false) { $note .= '规则15:欧五/久保田等覆盖件需下进气,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则15:欧五/久保田等覆盖件含下进气'; } } // 规则16: 欧五发动机手刹未拉提醒需断电手刹报警 if ($system == '电气' && strpos($allTextLower, '3e22yg51') !== false && strpos($allTextLower, '手刹未拉') !== false) { if ($configItem && strpos($configItem['规格'], '断电手刹报警') === false) { $note .= '规则16:欧五发动机手刹未拉提醒需断电手刹报警,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则16:欧五发动机电气含断电手刹报警'; } } // 规则17: Inmotion电控手刹未拉提醒需断电手刹报警 if ($system == '电气' && strpos($allTextLower, 'inmotion') !== false && strpos($allTextLower, '手刹未拉') !== false) { if ($configItem && strpos($configItem['规格'], '断电手刹报警') === false) { $note .= '规则17:Inmotion电控手刹未拉提醒需断电手刹报警,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则17:Inmotion电控电气含断电手刹报警'; } } // 规则18: 格拉默座椅涉及覆盖件、座椅 if (in_array($system, ['覆盖件', '座椅']) && strpos($allTextLower, '格拉默') !== false) { if ($configItem && strpos($configItem['规格'], '格拉默') === false) { $note .= '规则18:格拉默座椅需覆盖件/座椅含格拉默配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则18:覆盖件/座椅含格拉默配置'; } } // 规则19: 刷卡仪表需TSG81 if ($system == '电器' && strpos($allTextLower, '刷卡') !== false) { if ($configItem && strpos($configItem['规格'], 'TSG81') === false) { $note .= '规则19:刷卡仪表需电器含TSG81配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则19:电器含TSG81配置'; } } // 规则20: 仪表显示P需手刹开关 if ($system == '驻车制动' && strpos($allTextLower, '仪表显示') !== false) { if ($configItem && strpos($configItem['规格'], '手刹开关') === false) { $note .= '规则20:仪表显示P需驻车制动含手刹开关,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则20:驻车制动含手刹开关'; } } // 规则21: 电瓶挡板涉及覆盖件 if ($system == '覆盖件' && strpos($allTextLower, '电瓶挡板') !== false) { if ($configItem && strpos($configItem['规格'], '电瓶挡板') === false) { $note .= '规则21:电瓶挡板需覆盖件含电瓶挡板配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则21:覆盖件含电瓶挡板配置'; } } // 规则22: BATI涉及平衡重 if ($system == '平衡重' && strpos($allTextLower, 'bati') !== false) { if ($configItem && strpos($configItem['规格'], ' BATI') === false) { $note .= '规则22:BATI需平衡重含BATI配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则22:平衡重含BATI配置'; } } // 规则23: FLB方向盘涉及转向系统 if ($system == '转向系统' && strpos($allTextLower, 'flb方向') !== false) { if (($configItem && strpos($configItem['规格'], 'FLB方向') === false) || !$configItem) { $note .= '规则23:FLB方向盘需转向系统含FLB方向配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则23:转向系统含FLB方向配置'; } } // 规则24: 半交流涉及电器、电气系统 if (in_array($system, ['电器', '电气']) && strpos($allTextLower, '半交流') !== false) { if (($configItem && strpos($configItem['规格'], '半交流') === false) || !$configItem) { $note .= '规则24:半交流需电器/电气含半交流配置,当前无'; $pass = false; } else if ($configItem) { $note .= '符合规则24:电器/电气含半交流配置'; } } // 规则25: 欧五发动机默认进口多路阀 if ($system == '多路阀系统' && strpos($allTextLower, '3e22yg51') !== false && strpos($allTextLower, '进口多路阀') !== false) { if (($configItem && strpos($configItem['名称'], '进口') === false) || !$configItem) { $note .= '规则25:欧五发动机需进口多路阀,当前配置非进口'; $pass = false; } else if ($configItem) { $note .= '符合规则25:欧五发动机多路阀为进口品牌'; } } return ['pass' => $pass, 'note' => $note]; } ?>
2025年07月15日
14 阅读
0 评论
0 点赞
2025-07-09
导航页面
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>清爽导航</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; } body { background: linear-gradient(135deg, #f5f7fa 0%, #e4edf9 100%); min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 20px; color: #333; } .container { width: 100%; max-width: 900px; background: rgba(255, 255, 255, 0.92); border-radius: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08); overflow: hidden; backdrop-filter: blur(10px); } header { text-align: center; padding: 30px 20px 20px; background: linear-gradient(to right, #4b6cb7, #6a93cb); color: white; } h1 { font-size: 2.5rem; font-weight: 300; letter-spacing: 1px; margin-bottom: 10px; } .subtitle { font-weight: 300; opacity: 0.9; font-size: 1.1rem; } .tabs { display: flex; background: #f0f5ff; border-bottom: 1px solid #e1e8f7; } .tab { flex: 1; text-align: center; padding: 18px 0; font-size: 1.1rem; font-weight: 500; color: #5a7ab5; cursor: pointer; transition: all 0.3s ease; position: relative; } .tab:hover { background: rgba(106, 147, 203, 0.1); } .tab.active { color: #4b6cb7; background: white; } .tab.active::after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 3px; background: #4b6cb7; } .tab i { margin-right: 10px; font-size: 1.2rem; } .content { padding: 30px; min-height: 400px; } .tab-content { display: none; animation: fadeIn 0.5s ease; } .tab-content.active { display: block; } @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } h2 { color: #4b6cb7; margin-bottom: 20px; font-weight: 500; display: flex; align-items: center; } h2 i { margin-right: 12px; background: #eef4ff; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; } p { line-height: 1.8; color: #555; margin-bottom: 20px; font-size: 1.05rem; } .card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; margin-top: 20px; } .card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.03); transition: transform 0.3s ease, box-shadow 0.3s ease; border: 1px solid #eef2f7; } .card:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(75, 108, 183, 0.15); } .card h3 { color: #4b6cb7; margin-bottom: 15px; display: flex; align-items: center; } .card h3 i { margin-right: 10px; color: #6a93cb; } .card ul { list-style: none; padding-left: 10px; } .card li { padding: 8px 0; border-bottom: 1px dashed #eaeff5; display: flex; align-items: center; } .card li:last-child { border-bottom: none; } .card li i { margin-right: 10px; color: #6a93cb; font-size: 0.9rem; } footer { text-align: center; padding: 20px; color: #7a8fb3; font-size: 0.9rem; border-top: 1px solid #eef2f7; background: #f9fbfe; } @media (max-width: 768px) { .tabs { flex-wrap: wrap; } .tab { flex: 1 0 50%; padding: 15px 0; } h1 { font-size: 2rem; } .content { padding: 20px; } } @media (max-width: 480px) { .tab { flex: 1 0 100%; } .card-grid { grid-template-columns: 1fr; } } </style> </head> <body> <div class="container"> <header> <h1>清爽导航</h1> <p class="subtitle">简洁高效 • 专注体验</p> </header> <div class="tabs"> <div class="tab active" data-tab="dashboard"> <i class="fas fa-home"></i>首页 </div> <div class="tab" data-tab="resources"> <i class="fas fa-book"></i>资源 </div> <div class="tab" data-tab="tools"> <i class="fas fa-tools"></i>工具 </div> <div class="tab" data-tab="settings"> <i class="fas fa-cog"></i>设置 </div> </div> <div class="content"> <!-- 首页内容 --> <div class="tab-content active" id="dashboard"> <h2><i class="fas fa-home"></i>欢迎使用清爽导航</h2> <p>这是一个简洁高效的导航页面,帮助您快速访问常用资源。设计注重用户体验和视觉舒适度,让您的日常操作更加流畅愉悦。</p> <div class="card-grid"> <div class="card"> <h3><i class="fas fa-rocket"></i>快捷入口</h3> <ul> <li><i class="fas fa-envelope"></i>邮箱服务</li> <li><i class="fas fa-calendar"></i>日程管理</li> <li><i class="fas fa-cloud"></i>云存储</li> <li><i class="fas fa-users"></i>团队协作</li> </ul> </div> <div class="card"> <h3><i class="fas fa-history"></i>最近访问</h3> <ul> <li><i class="fas fa-file-alt"></i>项目文档</li> <li><i class="fas fa-chart-bar"></i>数据分析</li> <li><i class="fas fa-shopping-cart"></i>在线商城</li> <li><i class="fas fa-video"></i>视频会议</li> </ul> </div> <div class="card"> <h3><i class="fas fa-bell"></i>通知提醒</h3> <ul> <li><i class="fas fa-check-circle"></i>任务已完成</li> <li><i class="fas fa-exclamation-circle"></i>系统更新</li> <li><i class="fas fa-user-plus"></i>新成员加入</li> <li><i class="fas fa-gift"></i>特别优惠</li> </ul> </div> </div> </div> <!-- 资源内容 --> <div class="tab-content" id="resources"> <h2><i class="fas fa-book"></i>学习资源</h2> <p>精选高质量学习资源,涵盖多个领域,助力您的知识成长与技能提升。</p> <div class="card-grid"> <div class="card"> <h3><i class="fas fa-laptop-code"></i>开发资源</h3> <ul> <li><i class="fab fa-github"></i>GitHub 开源项目</li> <li><i class="fas fa-code"></i>在线编程练习</li> <li><i class="fas fa-book-open"></i>技术文档</li> <li><i class="fas fa-video"></i>教学视频</li> </ul> </div> <div class="card"> <h3><i class="fas fa-paint-brush"></i>设计资源</h3> <ul> <li><i class="fas fa-palette"></i>配色方案</li> <li><i class="fas fa-font"></i>字体资源</li> <li><i class="fas fa-images"></i>图片素材</li> <li><i class="fas fa-cube"></i>3D模型</li> </ul> </div> <div class="card"> <h3><i class="fas fa-book"></i>电子书籍</h3> <ul> <li><i class="fas fa-globe"></i>网络技术</li> <li><i class="fas fa-brain"></i>人工智能</li> <li><i class="fas fa-chart-line"></i>商业经济</li> <li><i class="fas fa-heart"></i>文学艺术</li> </ul> </div> </div> </div> <!-- 工具内容 --> <div class="tab-content" id="tools"> <h2><i class="fas fa-tools"></i>实用工具</h2> <p>精选高效工具,提升您的工作效率和创造力,让复杂任务变得简单。</p> <div class="card-grid"> <div class="card"> <h3><i class="fas fa-calculator"></i>转换计算</h3> <ul> <li><i class="fas fa-ruler"></i>单位换算</li> <li><i class="fas fa-money-bill-wave"></i>货币转换</li> <li><i class="fas fa-percentage"></i>百分比计算</li> <li><i class="fas fa-clock"></i>时区转换</li> </ul> </div> <div class="card"> <h3><i class="fas fa-edit"></i>文档处理</h3> <ul> <li><i class="fas fa-file-pdf"></i>PDF工具</li> <li><i class="fas fa-file-image"></i>图片压缩</li> <li><i class="fas fa-file-word"></i>文档转换</li> <li><i class="fas fa-file-alt"></i>文本处理</li> </ul> </div> <div class="card"> <h3><i class="fas fa-chart-pie"></i>数据分析</h3> <ul> <li><i class="fas fa-table"></i>数据可视化</li> <li><i class="fas fa-chart-line"></i>图表生成</li> <li><i class="fas fa-calculator"></i>统计计算</li> <li><i class="fas fa-database"></i>数据清洗</li> </ul> </div> </div> </div> <!-- 设置内容 --> <div class="tab-content" id="settings"> <h2><i class="fas fa-cog"></i>系统设置</h2> <p>自定义您的导航体验,调整设置以满足您的个人偏好和工作需求。</p> <div class="card-grid"> <div class="card"> <h3><i class="fas fa-user"></i>账户设置</h3> <ul> <li><i class="fas fa-user-edit"></i>个人信息</li> <li><i class="fas fa-shield-alt"></i>安全设置</li> <li><i class="fas fa-bell"></i>通知偏好</li> <li><i class="fas fa-language"></i>语言设置</li> </ul> </div> <div class="card"> <h3><i class="fas fa-paint-brush"></i>外观设置</h3> <ul> <li><i class="fas fa-moon"></i>深色模式</li> <li><i class="fas fa-palette"></i>主题颜色</li> <li><i class="fas fa-font"></i>字体大小</li> <li><i class="fas fa-border-all"></i>布局调整</li> </ul> </div> <div class="card"> <h3><i class="fas fa-sliders-h"></i>高级设置</h3> <ul> <li><i class="fas fa-sync-alt"></i>数据同步</li> <li><i class="fas fa-keyboard"></i>快捷键</li> <li><i class="fas fa-plug"></i>插件管理</li> <li><i class="fas fa-database"></i>数据备份</li> </ul> </div> </div> </div> </div> <footer> <p>© 2023 清爽导航 | 简洁设计,高效体验</p> </footer> </div> <script> document.addEventListener('DOMContentLoaded', function() { const tabs = document.querySelectorAll('.tab'); const tabContents = document.querySelectorAll('.tab-content'); tabs.forEach(tab => { tab.addEventListener('click', () => { // 移除所有活动状态 tabs.forEach(t => t.classList.remove('active')); tabContents.forEach(c => c.classList.remove('active')); // 添加当前活动状态 tab.classList.add('active'); const tabId = tab.getAttribute('data-tab'); document.getElementById(tabId).classList.add('active'); }); }); }); </script> </body> </html>
2025年07月09日
10 阅读
0 评论
0 点赞
2025-07-07
天气API应用实例
//ajax请求api获取天气数据 function getWeather() { $.ajax({ type: "get", dataType: "json", url: "http://wthrcdn.etouch.cn/weather_mini?city=合肥", success: function (data) { var tips = data.data.ganmao; var today = data.data.forecast[0]; var tomorrow = data.data.forecast[1]; var afterTomorrow = data.data.forecast[2]; //填充数据 $("#tips").html("Tips:" + tips); //填充天气数据 setWeather(".today", today); setWeather(".tomorrow", tomorrow); setWeather(".afterTomorrow", afterTomorrow); //设置天气img的src matchType(today.type, ".today"); matchType(tomorrow.type, ".tomorrow"); matchType(afterTomorrow.type, ".afterTomorrow"); } }); } //提取json数据并填充到标签中 function setWeather(date,data) { $(date).find('p').eq(0).html(data.date); $(date).find('p').eq(1).html(data.type); $(date).find('p').eq(2).html(data.high); $(date).find('p').eq(3).html(data.low); } //正则匹配天气类型,修改天气img的src function matchType(type,date) { var rain = /\u96e8/; var sun = /\u6674/; var cloud = /\u4e91/; //var overcast = /\u9634/; var imgName = rain.test(type)?"rain":(sun.test(type)?"sun":(cloud.test(type)?"cloud":"overcast")); $(date).find('img').attr('src','__STATIC__/admin/images/'+imgName+'.png'); //console.log(imgName); }{include file="public/head" /} <style> .am-comment-footer{margin:5px 10px;color: #999;padding:0 2px;border-left:5px solid #ccc} .am-comment-footer a{color: #999;} .comment{border: 1px solid #dedede;margin-top: 10px} .am-comment-bd{padding: 5px 10px} .solid{border-left: 1px solid #ccc} .message{display: inline-block;margin-left: 50px} .weather img{margin-top: -150px} </style> <title>首页</title> </head> <body> <header class="am-topbar am-topbar-fixed-top wos-header"> <div class="am-container"> <h1 class="am-topbar-brand"> <a href="http://www.anhuihym.top" target="_blank"><img src="__STATIC__/images/logo.png"></a> </h1> {include file="public/nav" /} </div> </header> <div class="banner"> <div class="am-g am-container"> <!--轮播图--> <div class="am-u-sm-12 am-u-md-12 am-u-lg-8"> <div data-am-widget="slider" class="am-slider am-slider-c1" data-am-slider='{"directionNav":false}' > <ul class="am-slides"> {volist name="Slide" id="vo"} <li> <a href="{:url('index/NewsDetailController/index',array('id'=>$vo['id']))}"><img src="__STATIC__/news_imgs/{$vo.img}" class="am-u-sm-12 am-u-md-12 am-u-md-8" style="max-height: 455px;"></a> <div class="am-slider-desc">{$vo.title}</div> </li> {/volist} </ul> </div> </div> <!--主要部门--> <div class="am-u-sm-0 am-u-md-0 am-u-lg-4 padding-none"> <div class="star am-container"><span><img src="__STATIC__/images/star2.png">主要部门</span></div> <ul class="padding-none am-gallery am-avg-sm-2 am-avg-md-4 am-avg-lg-2 am-gallery-overlay" data-am-gallery="{ pureview: true }" > {volist name="mainDep" id="vo"} <li> <div class="am-gallery-item"> <a href="{:url('index/NewsListController/index',array('id'=>$vo['id']))}"> <img src="__STATIC__/images/lins.png"/> <h3 class="am-gallery-title">{$vo.name}</h3> </a> </div> </li> {/volist} </ul> </div> </div> </div> <div class="am-g am-container newatype"> <div class="am-u-sm-12 am-u-md-12 am-u-lg-8 oh"> <div data-am-widget="titlebar" class="am-titlebar am-titlebar-default" style="margin-bottom: 10px"> <h2 class="am-titlebar-title ">最新发布</h2> </div> {volist name="newsList" id="vo"} <ul class="am-list am-list-static am-list-border"> <li> <span class="am-badge am-badge-danger">NEW</span> <span class="am-badge am-badge-success am-radius">{$vo.type}</span> <span class="am-badge am-badge-secondary am-radius">{$vo.dep}</span> <span class="am-badge am-badge-error am-radius">{$vo.create_time}</span> <a href="{:url('index/NewsDetailController/index',array('id'=>$vo['id']))}" style="padding: 0">{$vo.title}</a> </li> </ul> {/volist} </div> <div class="am-u-sm-12 am-u-md-12 am-u-lg-4"> <div data-am-widget="titlebar" class="am-titlebar am-titlebar-default" style="margin-bottom: 10px"> <h2 class="am-titlebar-title ">最新评论</h2> </div> {volist name="commentList" id="vo"} <div class="comment"> <header class="am-comment-hd"> <div class="am-comment-meta"> <span class="am-comment-author">{$vo.staff_name}</span> 评论于 <time>{$vo.create_time}</time> </div> </header> <div class="am-comment-bd">{$vo.comment}</div> <div class="am-comment-footer"> <a href="{:url('index/NewsDetailController/index',array('id'=>$vo['id']))}" title="点击查看新闻详情">{$vo.title}</a> </div> </div> {/volist} </div> <div class="am-u-sm-12 am-u-md-12 am-u-lg-12 oh"> <div data-am-widget="titlebar" class="am-titlebar am-titlebar-default" style="margin-bottom: 10px"> <h2 class="am-titlebar-title ">合肥天气 </h2> </div> <div class="am-u-md-12 weather"> <div class="today am-u-md-4"> <img src="__STATIC__/admin/images/sun.png" alt=""> <div class="message"> <p>今天</p> <p>天气</p> <p>最高</p> <p>最低</p> </div> </div> <div class="tomorrow solid am-u-md-4"> <img src="__STATIC__/admin/images/sun.png" alt="" > <div class="message"> <p>明天</p> <p>天气</p> <p>最高</p> <p>最低</p> </div> </div> <div class="afterTomorrow solid am-u-md-4"> <img src="__STATIC__/admin/images/sun.png" alt="" > <div class="message"> <p>后天</p> <p>天气</p> <p>最高</p> <p>最低</p> </div> </div> </div> </div> <div class="am-alert am-alert-secondary am-u-sm-12 am-u-md-12 am-u-lg-12" data-am-alert> <button type="button" class="am-close">×</button> <p id="tips"></p> </div> </div> <div data-am-widget="gotop" class="am-gotop am-gotop-fixed" > <a href="#top" title="回到顶部"> <span class="am-gotop-title">回到顶部</span> <i class="am-gotop-icon am-icon-chevron-up"></i> </a> </div> {include file="public/footer" /} </body> <script> //仪表盘数据 ajax定时获取 window.onload = function () { getWeather(); }; //ajax请求api获取天气数据 function getWeather() { $.ajax({ type: "get", dataType: "json", url: "http://wthrcdn.etouch.cn/weather_mini?city=合肥", success: function (data) { var tips = data.data.ganmao; var today = data.data.forecast[0]; var tomorrow = data.data.forecast[1]; var afterTomorrow = data.data.forecast[2]; //填充数据 $("#tips").html("Tips:" + tips); //填充天气数据 setWeather(".today", today); setWeather(".tomorrow", tomorrow); setWeather(".afterTomorrow", afterTomorrow); //设置天气img的src matchType(today.type, ".today"); matchType(tomorrow.type, ".tomorrow"); matchType(afterTomorrow.type, ".afterTomorrow"); } }); } //提取json数据并填充到标签中 function setWeather(date,data) { $(date).find('p').eq(0).html(data.date); $(date).find('p').eq(1).html(data.type); $(date).find('p').eq(2).html(data.high); $(date).find('p').eq(3).html(data.low); } //正则匹配天气类型,修改天气img的src function matchType(type,date) { var rain = /\u96e8/; var sun = /\u6674/; var cloud = /\u4e91/; //var overcast = /\u9634/; var imgName = rain.test(type)?"rain":(sun.test(type)?"sun":(cloud.test(type)?"cloud":"overcast")); $(date).find('img').attr('src','__STATIC__/admin/images/'+imgName+'.png'); //console.log(imgName); } </script> </html>
2025年07月07日
8 阅读
0 评论
0 点赞
2025-07-07
此内容被密码保护
加密文章,请前往内页查看详情
2025年07月07日
3 阅读
0 评论
0 点赞
2025-07-04
字符串核对
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>字符串比较工具</title> <style> * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } body { background: linear-gradient(135deg, #8e8f93fc 100%, #8e8f93fc 100%); color: #333; min-height: 100vh; padding: 20px; display: flex; justify-content: center; align-items: center; } .container { width: 100%; max-width: 800px; background-color: white; border-radius: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); overflow: hidden; } header { background: linear-gradient(to right, #514d4d, #514d4d); color: white; padding: 25px 30px; text-align: center; } h1 { font-size: 28px; margin-bottom: 8px; } .subtitle { font-size: 16px; opacity: 0.9; max-width: 600px; margin: 0 auto; } .content { padding: 30px; } .input-group { margin-bottom: 25px; } label { display: block; font-weight: 600; margin-bottom: 10px; color: #2c3e50; font-size: 18px; } textarea { width: 100%; height: 120px; padding: 15px; border: 2px solid #ddd; border-radius: 8px; font-size: 16px; resize: vertical; transition: border-color 0.3s; } textarea:focus { border-color: #3498db; outline: none; box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2); } .example { background-color: #f8f9fa; border-left: 4px solid #3498db; padding: 12px 15px; margin-top: 8px; border-radius: 0 4px 4px 0; font-size: 14px; } .example-title { font-weight: bold; margin-bottom: 5px; color: #2c3e50; } .actions { display: flex; justify-content: center; gap: 15px; margin-top: 20px; } button { padding: 14px 28px; font-size: 17px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; } .compare-btn { background: linear-gradient(to right, #35c1a9, #35c1a9); color: white; flex: 1; } .clear-btn { background: #514d4d; color: white; } button:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); } button:active { transform: translateY(0); } .compare-btn:hover { background: linear-gradient(to right, #009a87, #85b536); } .clear-btn:hover { background: #c0392b; } .result-container { margin-top: 30px; padding: 25px; border-radius: 10px; display: none; } .result-title { font-size: 20px; font-weight: bold; margin-bottom: 15px; display: flex; align-items: center; } .result-content { padding: 15px; border-radius: 8px; margin-top: 10px; font-size: 16px; line-height: 1.6; } .success { background-color: rgba(46, 204, 113, 0.1); border: 1px solid #2ecc71; color: #27ae60; } .error { background-color: rgba(231, 76, 60, 0.1); border: 1px solid #e74c3c; color: #c0392b; } .icon { margin-right: 10px; font-size: 24px; } .requirements { background-color: #f8f9fa; border-radius: 10px; padding: 20px; margin-top: 25px; } .requirements h3 { color: #2c3e50; margin-bottom: 15px; display: flex; align-items: center; } .requirements ul { padding-left: 20px; } .requirements li { margin-bottom: 10px; line-height: 1.5; } footer { text-align: center; padding: 20px; color: #7f8c8d; font-size: 14px; border-top: 1px solid #eee; } @media (max-width: 600px) { .content { padding: 20px; } h1 { font-size: 24px; } .actions { flex-direction: column; } } </style> </head> <body> <div class="container"> <header> <h1>字符串比较工具</h1> <p class="subtitle">验证格式并比较两个字符串 - 检查第二个字符串是否是第一个字符串的子集</p> </header> <div class="content"> <div class="input-group"> <label for="str1">第一个字符串 (蓝本):</label> <textarea id="str1" placeholder="请输入第一个字符串,使用英文逗号分隔各项">3SV,实心胎(进口品牌),闪光警示灯,丰田样式悬浮座椅,高挂预滤器,高排气,VM330,3AP</textarea> </div> <div class="input-group"> <label for="str2">第二个字符串 (待比较):</label> <textarea id="str2" placeholder="请输入第二个字符串,使用英文逗号分隔各项">3SV,实心胎(进口品牌),闪光警示灯,丰田样式悬浮座椅,高挂预滤器,高排气</textarea> </div> <div class="actions"> <button class="compare-btn" onclick="compareStrings()"> <span class="icon">✓</span> 比较字符串 </button> <button class="clear-btn" onclick="clearInputs()"> <span class="icon">✕</span> 清空 </button> </div> <div id="result-container" class="result-container"> <div class="result-title"> <span class="icon" id="result-icon">?</span> <span id="result-title">结果</span> </div> <div id="result-content" class="result-content"></div> </div> <div class="requirements"> <h3>字符串要求</h3> <ul> <li>只能使用<strong>英文逗号</strong>作为分隔符(不允许中文逗号)</li> <li>字符串中<strong>不允许包含任何空格</strong></li> <li>第二个字符串必须是第一个字符串的<strong>子集</strong></li> <li>所有元素必须<strong>完全匹配</strong>(包括大小写和特殊字符)</li> <li>元素顺序<strong>不影响</strong>比较结果</li> </ul> </div> </div> </div> <script> function compareStrings() { const str1 = document.getElementById('str1').value.trim(); const str2 = document.getElementById('str2').value.trim(); const resultContainer = document.getElementById('result-container'); const resultContent = document.getElementById('result-content'); const resultTitle = document.getElementById('result-title'); const resultIcon = document.getElementById('result-icon'); // 清空之前的结果 resultContainer.style.display = 'none'; // 验证字符串1 const validation1 = validateString(str1, "第一个字符串"); if (!validation1.isValid) { showError(validation1.message, resultContainer, resultContent, resultTitle, resultIcon); return; } // 验证字符串2 const validation2 = validateString(str2, "第二个字符串"); if (!validation2.isValid) { showError(validation2.message, resultContainer, resultContent, resultTitle, resultIcon); return; } // 获取元素数组 const arr1 = str1.split(','); const arr2 = str2.split(','); // 检查第二个字符串是否是第一个字符串的子集 const missingElements = []; for (const element of arr2) { if (!arr1.includes(element)) { missingElements.push(element); } } // 检查结果并显示 if (missingElements.length === 0) { showSuccess("验证通过!第二个字符串是第一个字符串的子集。", resultContainer, resultContent, resultTitle, resultIcon); } else { showError(`第二个字符串包含第一个字符串中没有的元素:${missingElements.join(', ')}`, resultContainer, resultContent, resultTitle, resultIcon); } } function validateString(str, strName) { // 检查是否为空 if (str === '') { return { isValid: false, message: `${strName}不能为空!` }; } // 检查是否包含空格 if (/\s/.test(str)) { return { isValid: false, message: `${strName}包含空格!请移除所有空格。` }; } // 检查是否包含中文逗号 if (str.includes(',')) { return { isValid: false, message: `${strName}包含中文逗号!请使用英文逗号(,)。` }; } // 检查其他非法符号(只允许中文字符、英文字母、数字、英文逗号和括号) const illegalChars = str.match(/[^\u4e00-\u9fa5a-zA-Z0-9,()]/g); if (illegalChars && illegalChars.length > 0) { const uniqueChars = [...new Set(illegalChars)]; return { isValid: false, message: `${strName}包含非法字符:${uniqueChars.join('')}` }; } // 检查连续逗号或开头/结尾逗号 if (str.startsWith(',') || str.endsWith(',') || str.includes(',,')) { return { isValid: false, message: `${strName}格式错误:存在连续逗号或开头/结尾逗号` }; } return { isValid: true }; } function showError(message, container, content, title, icon) { container.style.display = 'block'; container.classList.remove('success'); container.classList.add('error'); content.innerHTML = message; title.textContent = '验证失败'; icon.textContent = '✕'; container.scrollIntoView({ behavior: 'smooth' }); } function showSuccess(message, container, content, title, icon) { container.style.display = 'block'; container.classList.remove('error'); container.classList.add('success'); content.innerHTML = message; title.textContent = '验证通过'; icon.textContent = '✓'; container.scrollIntoView({ behavior: 'smooth' }); } function clearInputs() { document.getElementById('str1').value = ''; document.getElementById('str2').value = ''; document.getElementById('result-container').style.display = 'none'; } </script> </body> </html>
2025年07月04日
18 阅读
0 评论
0 点赞
1
...
14
15
16
...
37
0:00