123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>江苏医保社保卡读取测试</title>
- <meta charset="utf-8">
- <style>
- body { font-family: Arial, sans-serif; margin: 20px; }
- .container { max-width: 1000px; margin: 0 auto; }
- .section { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }
- .button { padding: 10px 20px; margin: 5px; background: #007bff; color: white; border: none; border-radius: 3px; cursor: pointer; }
- .button:hover { background: #0056b3; }
- .result { margin-top: 10px; padding: 10px; background: #f8f9fa; border-radius: 3px; font-family: monospace; white-space: pre-wrap; }
- .success { background: #d4edda; color: #155724; }
- .error { background: #f8d7da; color: #721c24; }
- .config-input { width: 100%; margin: 5px 0; padding: 5px; }
- </style>
- </head>
- <body>
- <div class="container">
- <h1>江苏医保社保卡读取系统测试</h1>
- <p><strong>基于HeaSecReadInfo.dll</strong> - 严格按照江苏医保规范v0.9.9.15实现</p>
- <!-- 系统状态 -->
- <div class="section">
- <h2>1. 系统状态检查</h2>
- <button class="button" onclick="checkHealth()">健康检查</button>
- <button class="button" onclick="getStatus()">获取状态</button>
- <div id="statusResult" class="result"></div>
- </div>
- <!-- 系统初始化 -->
- <div class="section">
- <h2>2. 系统初始化</h2>
- <h3>配置参数 (JSON格式):</h3>
- <div>
- <label>IP地址: <input type="text" id="configIP" class="config-input" value="10.61.165.3"></label>
- <label>端口: <input type="number" id="configPORT" class="config-input" value="8086"></label>
- <label>超时时间(秒): <input type="number" id="configTIMEOUT" class="config-input" value="30"></label>
- <label>日志路径: <input type="text" id="configLOG_PATH" class="config-input" value="E:\\huaihaiProject\\readCard\\ThCardReader\\logs\\"></label>
- <label>电子凭证URL: <input type="text" id="configEC_URL" class="config-input" value="http://10.61.165.3:8086/localcfc/api/hsecfc/localQrCodeQuery"></label>
- <label>卡密码验证方式: <select id="configCARD_PASSTYPE" class="config-input"><option value="1">1-验证卡PIN</option><option value="2" selected>2-验证数据库密码</option></select></label>
- <label>API名称: <input type="text" id="configAPI_NAME" class="config-input" value="hssServives"></label>
- <label>API版本: <input type="text" id="configAPI_VERSION" class="config-input" value="1.0.0"></label>
- <label>访问密钥: <input type="text" id="configACCESS_KEY" class="config-input" value="a94971b5ecee4bb994bce25c9291ccbf"></label>
- <label>密钥: <input type="text" id="configSECRETKEY" class="config-input" value="3ni3n+nWhGCsiu6SITGUqNfzvx8="></label>
- <label>定点编号: <input type="text" id="configORG_ID" class="config-input" value="H32132200561"></label>
- <label>扩展参数: <input type="text" id="configEXT" class="config-input" value="{}"></label>
- <label>行政区划代码: <input type="text" id="configAREA_CODE" class="config-input" value="321322"></label>
- </div>
- <button class="button" onclick="initSystem()">初始化系统</button>
- <button class="button" onclick="initSystemSimple()">使用默认配置初始化</button>
- <div id="initResult" class="result"></div>
- </div>
- <!-- 读卡功能 -->
- <div class="section">
- <h2>3. 社保卡读取功能</h2>
- <button class="button" onclick="readCard()">读取社保卡</button>
- <button class="button" onclick="readCardWithPIN()">读卡+验证PIN</button>
- <button class="button" onclick="readCardURL()">URL方式读卡</button>
- <div id="readResult" class="result"></div>
- </div>
- <!-- PIN码操作 -->
- <div class="section">
- <h2>4. PIN码操作</h2>
- <button class="button" onclick="verifyPIN()">验证PIN码</button>
- <button class="button" onclick="changePIN()">修改PIN码</button>
- <div id="pinResult" class="result"></div>
- </div>
- <!-- 四合一介质 -->
- <div class="section">
- <h2>5. 四合一介质支持</h2>
- <select id="mediaType">
- <option value="socialcard">社保卡</option>
- <option value="idcard">身份证</option>
- <option value="electronic">电子凭证</option>
- <option value="esocialcard">电子社保卡</option>
- </select>
- <button class="button" onclick="getPersonInfo()">获取个人信息</button>
- <div id="personResult" class="result"></div>
- </div>
- <!-- 系统管理 -->
- <div class="section">
- <h2>6. 系统管理</h2>
- <button class="button" onclick="resetSystem()">重置系统状态</button>
- <button class="button" onclick="checkDllFile()">检查DLL文件</button>
- <button class="button" onclick="getHelp()">API帮助</button>
- <div id="manageResult" class="result"></div>
- </div>
- <!-- 智能重置测试 -->
- <div class="section">
- <h2>7. 智能重置策略测试</h2>
- <p>测试连续失败自动重置功能(需要先初始化系统)</p>
- <button class="button" onclick="testSmartReset()">模拟连续失败</button>
- <div id="smartResetResult" class="result"></div>
- </div>
- </div>
- <script>
- const baseUrl = 'http://localhost:8321';
- let consecutiveFailures = 0;
- const MAX_FAILURES = 3;
- // 显示结果
- function showResult(elementId, data, isError = false) {
- const element = document.getElementById(elementId);
- element.className = 'result ' + (isError ? 'error' : 'success');
- element.textContent = JSON.stringify(data, null, 2);
- }
- // 健康检查
- async function checkHealth() {
- try {
- const response = await fetch(`${baseUrl}/readcard/jiangsu/status`);
- const data = await response.json();
- showResult('statusResult', data, !data.success);
- } catch (error) {
- showResult('statusResult', { error: error.message }, true);
- }
- }
- // 获取状态
- async function getStatus() {
- try {
- const response = await fetch(`${baseUrl}/readcard/jiangsu/status`);
- const data = await response.json();
- showResult('statusResult', data, !data.success);
- } catch (error) {
- showResult('statusResult', { error: error.message }, true);
- }
- }
- // 初始化系统(带配置)
- async function initSystem() {
- try {
- const config = {
- action: 'init',
- config: {
- "IP": document.getElementById('configIP').value,
- "PORT": parseInt(document.getElementById('configPORT').value),
- "TIMEOUT": parseInt(document.getElementById('configTIMEOUT').value),
- "LOG_PATH": document.getElementById('configLOG_PATH').value,
- "EC_URL": document.getElementById('configEC_URL').value,
- "CARD_PASSTYPE": document.getElementById('configCARD_PASSTYPE').value,
- "API_NAME": document.getElementById('configAPI_NAME').value,
- "API_VERSION": document.getElementById('configAPI_VERSION').value,
- "ACCESS_KEY": document.getElementById('configACCESS_KEY').value,
- "SECRETKEY": document.getElementById('configSECRETKEY').value,
- "ORG_ID": document.getElementById('configORG_ID').value,
- "EXT": document.getElementById('configEXT').value,
- "AREA_CODE": document.getElementById('configAREA_CODE').value
- }
- };
- const response = await fetch(`${baseUrl}/readcard/jiangsu`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(config)
- });
- const data = await response.json();
- showResult('initResult', data, !data.success);
- } catch (error) {
- showResult('initResult', { error: error.message }, true);
- }
- }
- // 使用默认配置初始化
- async function initSystemSimple() {
- try {
- const response = await fetch(`${baseUrl}/readcard/jiangsu/init`);
- const data = await response.json();
- showResult('initResult', data, !data.success);
- } catch (error) {
- showResult('initResult', { error: error.message }, true);
- }
- }
- // 读取社保卡
- async function readCard() {
- try {
- const response = await fetch(`${baseUrl}/readcard/jiangsu/readcard`);
- const data = await response.json();
- consecutiveFailures = data.success ? 0 : consecutiveFailures + 1;
- showResult('readResult', data, !data.success);
- } catch (error) {
- consecutiveFailures++;
- showResult('readResult', { error: error.message }, true);
- }
- }
- // 读卡+验证PIN
- async function readCardWithPIN() {
- try {
- const response = await fetch(`${baseUrl}/readcard/jiangsu/readcard_pin`);
- const data = await response.json();
- consecutiveFailures = data.success ? 0 : consecutiveFailures + 1;
- showResult('readResult', data, !data.success);
- } catch (error) {
- consecutiveFailures++;
- showResult('readResult', { error: error.message }, true);
- }
- }
- // URL方式读卡(模拟前端调用)
- async function readCardURL() {
- try {
- const response = await fetch(`${baseUrl}/readcard/entry/jiangsu_readcard`);
- const data = await response.json();
- showResult('readResult', data, data.code !== 200);
- } catch (error) {
- showResult('readResult', { error: error.message }, true);
- }
- }
- // 验证PIN
- async function verifyPIN() {
- try {
- const response = await fetch(`${baseUrl}/readcard/jiangsu/verifypin`);
- const data = await response.json();
- showResult('pinResult', data, !data.success);
- } catch (error) {
- showResult('pinResult', { error: error.message }, true);
- }
- }
- // 修改PIN
- async function changePIN() {
- try {
- const response = await fetch(`${baseUrl}/readcard/jiangsu/changepin`);
- const data = await response.json();
- showResult('pinResult', data, !data.success);
- } catch (error) {
- showResult('pinResult', { error: error.message }, true);
- }
- }
- // 获取个人信息
- async function getPersonInfo() {
- try {
- const mediaType = document.getElementById('mediaType').value;
- const response = await fetch(`${baseUrl}/readcard/jiangsu`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- action: 'getpersoninfo',
- mediaType: mediaType,
- inputData: ''
- })
- });
- const data = await response.json();
- showResult('personResult', data, !data.success);
- } catch (error) {
- showResult('personResult', { error: error.message }, true);
- }
- }
- // 重置系统
- async function resetSystem() {
- try {
- const response = await fetch(`${baseUrl}/readcard/jiangsu/reset`);
- const data = await response.json();
- consecutiveFailures = 0; // 重置失败计数
- showResult('manageResult', data, !data.success);
- } catch (error) {
- showResult('manageResult', { error: error.message }, true);
- }
- }
- // 检查DLL文件
- async function checkDllFile() {
- try {
- const response = await fetch(`${baseUrl}/readcard/entry/jiangsu_checkdll`);
- const data = await response.json();
- showResult('manageResult', data, data.code !== 200);
- } catch (error) {
- showResult('manageResult', { error: error.message }, true);
- }
- }
- // 获取帮助
- async function getHelp() {
- try {
- const helpInfo = {
- "江苏医保API接口": {
- "基础URL": "http://localhost:8321/readcard/jiangsu/{action}",
- "支持的操作": [
- "init - 初始化系统",
- "readcard - 读取社保卡",
- "readcard_pin - 读卡并验证PIN",
- "verifypin - 验证PIN码",
- "changepin - 修改PIN码",
- "status - 获取设备状态",
- "reset - 重置系统状态",
- "getpersoninfo - 四合一介质获取个人信息"
- ],
- "POST接口": "/readcard/jiangsu (支持复杂参数)",
- "DLL文件": "HeaSecReadInfo.dll",
- "规范版本": "v0.9.9.15"
- }
- };
- showResult('manageResult', helpInfo);
- } catch (error) {
- showResult('manageResult', { error: error.message }, true);
- }
- }
- // 智能重置策略测试
- async function testSmartReset() {
- let testResult = { testSteps: [], finalResult: '' };
-
- try {
- // 模拟连续失败3次
- for (let i = 1; i <= 3; i++) {
- try {
- // 尝试读卡(假设会失败)
- const response = await fetch(`${baseUrl}/readcard/jiangsu/readcard`);
- const data = await response.json();
-
- testResult.testSteps.push({
- step: i,
- action: 'readcard',
- success: data.success,
- message: data.message
- });
-
- if (!data.success) {
- consecutiveFailures++;
-
- if (consecutiveFailures >= MAX_FAILURES) {
- // 自动重置
- testResult.testSteps.push({
- step: i + 0.5,
- action: 'auto_reset',
- message: '连续失败达到阈值,触发自动重置'
- });
-
- const resetResponse = await fetch(`${baseUrl}/readcard/jiangsu/reset`);
- const resetData = await resetResponse.json();
-
- testResult.testSteps.push({
- step: i + 0.6,
- action: 'reset',
- success: resetData.success,
- message: resetData.message
- });
-
- // 重新初始化
- const initResponse = await fetch(`${baseUrl}/readcard/jiangsu/init`);
- const initData = await initResponse.json();
-
- testResult.testSteps.push({
- step: i + 0.7,
- action: 'reinit',
- success: initData.success,
- message: initData.message
- });
-
- consecutiveFailures = 0;
- break;
- }
- } else {
- consecutiveFailures = 0;
- break;
- }
- } catch (error) {
- consecutiveFailures++;
- testResult.testSteps.push({
- step: i,
- action: 'readcard',
- success: false,
- error: error.message
- });
- }
-
- // 短暂延迟
- await new Promise(resolve => setTimeout(resolve, 500));
- }
-
- testResult.finalResult = `智能重置策略测试完成。当前连续失败次数: ${consecutiveFailures}`;
- showResult('smartResetResult', testResult);
-
- } catch (error) {
- testResult.error = error.message;
- showResult('smartResetResult', testResult, true);
- }
- }
- // 页面加载完成后检查状态
- window.onload = function() {
- checkHealth();
- };
- </script>
- </body>
- </html>
|